@zuke/dart
`@zuke/dart` — typed `DartTasks` wrappers for the [Dart](https://dart.dev)
@zuke/dart on JSR ↗ 25 symbols
Symbols
class DartAnalyzeSettings extends DartSettings Settings for dart analyze.
| Member | Signature | Doc |
|---|---|---|
path | path(path: PathLike): this | A file or directory to analyze (defaults to the current one); repeatable. |
fatalInfos | fatalInfos(): this | Treat info-level issues as fatal (--fatal-infos). |
noFatalWarnings | noFatalWarnings(): this | Do not fail on warnings (--no-fatal-warnings). |
format | format(name: default | json | machine): this | The output format: default, json or machine (--format). |
packages | packages(path: PathLike): this | The package resolution file to use (--packages). |
class DartCompileSettings extends DartVmSettings Settings for dart compile <target>.
| Member | Signature | Doc |
|---|---|---|
enableAsserts | enableAsserts(): this | Enable assert statements (--enable-asserts); not for kernel. |
verbosity | verbosity(level: error | warning | info | all): this | How much to print (--verbosity); not for wasm. |
entry | entry(path: PathLike): this | The Dart entry point to compile; required. |
output | output(path: PathLike): this | Where to write the compiled artifact (--output). |
targetOs | targetOs(os: DartTargetOs): this | Cross-compile for another OS (--target-os); exe and aot-snapshot only. |
saveDebuggingInfo | saveDebuggingInfo(path: PathLike): this | Strip debugging information into a separate file (--save-debugging-info); exe and aot-snapshot only. |
depfile | depfile(path: PathLike): this | Write a Makefile-style dependency file (--depfile); not for js. |
optimize | optimize(level: number): this | The optimization level, 0 to 4 (-O<level>); js and wasm only. |
type DartCompileTarget = aot-snapshot | exe | jit-snapshot | js | kernel | wasm A dart compile target: what the entry point is compiled to.
type DartCompileTask = unknown A task that runs dart compile <target>; .entry() is required.
class DartCreateSettings extends DartSettings Settings for dart create.
| Member | Signature | Doc |
|---|---|---|
dir | dir(path: PathLike): this | The directory to create the project in; required. |
template | template(name: DartCreateTemplate): this | The project template, instead of console (--template). |
noPub | noPub(): this | Skip the implicit dart pub get (--no-pub). |
force | force(): this | Create into a directory that already exists (--force). |
type DartCreateTemplate = cli | console | package | server-shelf | web A dart create template (--template).
class DartDocSettings extends DartSettings Settings for dart doc.
| Member | Signature | Doc |
|---|---|---|
dir | dir(path: PathLike): this | The package directory to document (defaults to the current one). |
output | output(path: PathLike): this | Where to write the generated docs, instead of doc/api (--output). |
validateLinks | validateLinks(): this | Check the generated docs for broken links (--validate-links). |
dryRun | dryRun(): this | Report what would be documented without writing files (--dry-run). |
class DartFixSettings extends DartSettings Settings for dart fix.
| Member | Signature | Doc |
|---|---|---|
dir | dir(path: PathLike): this | The directory to fix (defaults to the current one). |
apply | apply(): this | Apply the proposed fixes (--apply). Without it or .dryRun(), dart fix only prints usage. |
dryRun | dryRun(): this | List the proposed fixes without applying them (--dry-run). |
code | code(code: string): this | Apply only the fix for one diagnostic code (--code); repeatable. |
class DartFormatSettings extends DartSettings Settings for dart format. With no .path() the current directory is formatted: dart format itself would read stdin instead, and in CI — no terminal, empty stdin — a .setExitIfChanged() check would pass vacuously.
| Member | Signature | Doc |
|---|---|---|
path | path(path: PathLike): this | A file or directory to format (defaults to .); repeatable. |
output | output(mode: write | show | json | none): this | What to do with formatted code: write (default), show, json or none (--output). |
setExitIfChanged | setExitIfChanged(): this | Exit with code 1 when any file would change — the CI check (--set-exit-if-changed). |
lineLength | lineLength(columns: number): this | Wrap lines longer than this (--line-length). |
show | show(which: all | changed | none): this | Which files to list: all, changed (default) or none (--show). |
summary | summary(kind: line | profile | none): this | The summary to print: line (default), profile or none (--summary). |
followLinks | followLinks(): this | Follow symbolic links into directories (--follow-links). |
languageVersion | languageVersion(version: string): this | The language version to parse as, e.g. 3.3 (--language-version). |
enableExperiment | enableExperiment(name: string): this | Enable an experimental language feature (--enable-experiment); repeatable. |
class DartInfoSettings extends DartSettings Settings for dart info, which prints diagnostic details about the SDK.
| Member | Signature | Doc |
|---|---|---|
noRemoveFilePaths | noRemoveFilePaths(): this | Keep file paths in the output instead of redacting them (--no-remove-file-paths). |
class DartPubDepsSettings extends DartSettings Settings for dart pub deps.
| Member | Signature | Doc |
|---|---|---|
style | style(name: compact | tree | list): this | The layout: compact, tree (default) or list (--style). |
noDev | noDev(): this | Leave dev dependencies out (--no-dev). |
executables | executables(): this | List the executables the dependencies expose instead (--executables). |
json | json(): this | Print the dependency graph as JSON (--json). |
class DartPubDowngradeSettings extends DartSettings Settings for dart pub downgrade.
| Member | Signature | Doc |
|---|---|---|
package | package(name: string): this | Downgrade only this package (defaults to all); repeatable. |
offline | offline(): this | Resolve from the local pub cache only (--offline). |
dryRun | dryRun(): this | Report what would change without changing it (--dry-run). |
tighten | tighten(): this | Lower the constraints in pubspec.yaml to the resolved versions (--tighten). |
class DartPubGetSettings extends DartSettings Settings for dart pub get.
| Member | Signature | Doc |
|---|---|---|
offline | offline(): this | Resolve from the local pub cache only (--offline). |
enforceLockfile | enforceLockfile(): this | Fail rather than change pubspec.lock (--enforce-lockfile). |
dryRun | dryRun(): this | Report what would change without changing it (--dry-run). |
noPrecompile | noPrecompile(): this | Skip precompiling executables (--no-precompile). |
class DartPubOutdatedSettings extends DartSettings Settings for dart pub outdated.
| Member | Signature | Doc |
|---|---|---|
json | json(): this | Print machine-readable JSON (--json). |
showAll | showAll(): this | Include packages that are already up to date (--show-all). |
noDevDependencies | noDevDependencies(): this | Leave dev dependencies out (--no-dev-dependencies). |
noTransitive | noTransitive(): this | Leave transitive dependencies out (--no-transitive). |
prereleases | prereleases(): this | Include prereleases when looking for newer versions (--prereleases). |
class DartPubPackagesSettings extends DartSettings Settings for dart pub add and dart pub remove.
| Member | Signature | Doc |
|---|---|---|
package | package(spec: string): this | A package to add or remove; repeatable, at least one is required. For add it takes pub's descriptor syntax: http, http:^1.2.0, or dev:mocktail for a dev dependency. |
offline | offline(): this | Resolve from the local pub cache only (--offline). |
dryRun | dryRun(): this | Report what would change without changing it (--dry-run). |
class DartPubPublishSettings extends DartSettings Settings for dart pub publish.
| Member | Signature | Doc |
|---|---|---|
dryRun | dryRun(): this | Validate the package without uploading it (--dry-run). |
force | force(): this | Publish without the confirmation prompt — what CI needs (--force). |
skipValidation | skipValidation(): this | Publish even when validation reports warnings (--skip-validation). |
class DartPubUpgradeSettings extends DartSettings Settings for dart pub upgrade.
| Member | Signature | Doc |
|---|---|---|
package | package(name: string): this | Upgrade only this package (defaults to all); repeatable. |
offline | offline(): this | Resolve from the local pub cache only (--offline). |
dryRun | dryRun(): this | Report what would change without changing it (--dry-run). |
majorVersions | majorVersions(): this | Also raise constraints in pubspec.yaml across majors (--major-versions). |
tighten | tighten(): this | Raise lower bounds in pubspec.yaml to the resolved versions (--tighten). |
unlockTransitive | unlockTransitive(): this | Also upgrade the transitive dependencies of the named packages (--unlock-transitive). |
class DartRunSettings extends DartVmSettings Settings for dart run. The entry point is the last token the settings build, so anything passed through .args() lands after it and reaches the program, not the VM — without an .entry(), the first .args() token is what dart run takes as the program, exactly as on the command line.
| Member | Signature | Doc |
|---|---|---|
entry | entry(fileOrTarget: PathLike): this | The Dart file to run, or a package executable such as build_runner or test:test. Without one, dart run runs the current package's own executable. |
observe | observe(bind?: string): this | Start the VM service with the debugging conveniences and pause on start (--observe=<port>[/<bind-address>]). The value is attached with = because dart run reads the option's value from the next token, which would otherwise be the entry point. |
enableVmService | enableVmService(bind?: string): this | Start the VM service without pausing (--enable-vm-service=<port>[/<bind-address>]). |
class DartSettings extends ToolSettings Base for all dart settings: the binary is dart, found on PATH.
type DartTargetOs = android | fuchsia | ios | linux | macos | windows An operating system dart compile exe|aot-snapshot can target (--target-os).
const DartTasks: DartTasksApi Typed task functions for the dart CLI.
interface DartTasksApi The shape of DartTasks.
| Member | Signature | Doc |
|---|---|---|
analyze | analyze(configure?: Configure<DartAnalyzeSettings>): Promise<CommandOutput> | Analyze the project's Dart code: dart analyze. |
format | format(configure?: Configure<DartFormatSettings>): Promise<CommandOutput> | Format Dart code, or check it with .setExitIfChanged(): dart format. |
fix | fix(configure?: Configure<DartFixSettings>): Promise<CommandOutput> | Apply analyzer fixes: dart fix. |
test | test(configure?: Configure<DartTestSettings>): Promise<CommandOutput> | Run the tests: dart test. |
run | run(configure?: Configure<DartRunSettings>): Promise<CommandOutput> | Run a Dart program or package executable: dart run. |
doc | doc(configure?: Configure<DartDocSettings>): Promise<CommandOutput> | Generate API documentation: dart doc. |
create | create(configure: Configure<DartCreateSettings>): Promise<CommandOutput> | Scaffold a project: dart create. |
pubGet | pubGet(configure?: Configure<DartPubGetSettings>): Promise<CommandOutput> | Resolve dependencies: dart pub get. |
pubUpgrade | pubUpgrade(configure?: Configure<DartPubUpgradeSettings>): Promise<CommandOutput> | Upgrade dependencies: dart pub upgrade. |
pubDowngrade | pubDowngrade(configure?: Configure<DartPubDowngradeSettings>): Promise<CommandOutput> | Downgrade dependencies to their lowest allowed versions: dart pub downgrade. |
pubOutdated | pubOutdated(configure?: Configure<DartPubOutdatedSettings>): Promise<CommandOutput> | List outdated dependencies: dart pub outdated. |
pubDeps | pubDeps(configure?: Configure<DartPubDepsSettings>): Promise<CommandOutput> | Print the dependency graph: dart pub deps. |
pubAdd | pubAdd(configure: Configure<DartPubPackagesSettings>): Promise<CommandOutput> | Add dependencies to pubspec.yaml: dart pub add. |
pubRemove | pubRemove(configure: Configure<DartPubPackagesSettings>): Promise<CommandOutput> | Remove dependencies from pubspec.yaml: dart pub remove. |
pubPublish | pubPublish(configure?: Configure<DartPubPublishSettings>): Promise<CommandOutput> | Publish the package to pub.dev: dart pub publish. |
info | info(configure?: Configure<DartInfoSettings>): Promise<CommandOutput> | Print diagnostic details about the SDK: dart info. |
version | version(configure?: Configure<DartVersionSettings>): Promise<CommandOutput> | Print the Dart SDK version: dart --version. |
compileExe | compileExe: DartCompileTask | Compile to a self-contained executable: dart compile exe. |
compileAotSnapshot | compileAotSnapshot: DartCompileTask | Compile to an AOT snapshot for dartaotruntime: dart compile aot-snapshot. |
compileJitSnapshot | compileJitSnapshot: DartCompileTask | Compile to a JIT snapshot: dart compile jit-snapshot. |
compileKernel | compileKernel: DartCompileTask | Compile to a kernel binary: dart compile kernel. |
compileJs | compileJs: DartCompileTask | Compile to JavaScript: dart compile js. |
compileWasm | compileWasm: DartCompileTask | Compile to WebAssembly: dart compile wasm. |
class DartTestSettings extends DartSettings Settings for dart test.
| Member | Signature | Doc |
|---|---|---|
path | path(path: PathLike): this | A test file or directory to run (defaults to test/); repeatable. |
name | name(pattern: string): this | Run only tests whose name matches a regular expression (--name); repeatable. |
plainName | plainName(text: string): this | Run only tests whose name contains a string (--plain-name); repeatable. |
tags | tags(expression: string): this | Run only tests with a tag expression (--tags). |
excludeTags | excludeTags(expression: string): this | Skip tests matching a tag expression (--exclude-tags). |
preset | preset(name: string): this | Apply a preset from dart_test.yaml (--preset); repeatable. |
runSkipped | runSkipped(): this | Run skipped tests too (--run-skipped). |
failFast | failFast(): this | Stop after the first failure (--fail-fast). |
platform | platform(name: string): this | Run on a platform, e.g. vm, chrome or node (--platform); repeatable. |
compiler | compiler(name: string): this | The compiler for a platform, e.g. dart2js, dart2wasm or kernel (--compiler); repeatable. |
concurrency | concurrency(count: number): this | How many test suites to run at once (--concurrency). |
timeout | timeout(value: string): this | The default per-test timeout, e.g. 30s or 2x (--timeout). |
coverage | coverage(dir: PathLike): this | Collect coverage into a directory of JSON reports (--coverage). |
reporter | reporter(name: string): this | The console reporter: compact, expanded, failures-only, github, json or silent (--reporter). |
fileReporter | fileReporter(spec: string): this | Also write a reporter's output to a file, e.g. json:report.json (--file-reporter). |
randomizeOrderingSeed | randomizeOrderingSeed(seed: string | number): this | Shuffle test order with a seed, or random (--test-randomize-ordering-seed). |
ignoreTimeouts | ignoreTimeouts(): this | Do not stop a test at its timeout (--ignore-timeouts). |
noColor | noColor(): this | Print stack traces without colour codes (--no-color). |
shard | shard(index: number, total: number): this | Run one shard of the suite: shard(index, total) renders --total-shards total --shard-index index, with index from 0. |
class DartVersionSettings extends DartSettings Settings for dart --version.
class DartVmSettings extends DartSettings Flags shared by the commands that load Dart code into the VM — compile and run: --define, --enable-asserts, --enable-experiment, --packages and --verbosity. Valued options render as --flag=value: dart compile js hands its argv to dart2js, whose parser accepts only that spelling, and Dart's args package accepts it everywhere else.
| Member | Signature | Doc |
|---|---|---|
define | define(name: string, value: string): this | Define an environment declaration (--define=name=value); repeatable. |
enableAsserts | enableAsserts(): this | Enable assert statements (--enable-asserts). |
enableExperiment | enableExperiment(name: string): this | Enable an experimental language feature (--enable-experiment); repeatable. |
packages | packages(path: PathLike): this | The package resolution file to use (--packages). |
verbosity | verbosity(level: error | warning | info | all): this | How much to print: error, warning, info or all (--verbosity). |