@convesoft/nx-rust 0.0.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/PLUGIN.md +106 -0
- package/README.md +51 -1
- package/docs/artifacts.mara.md +374 -0
- package/docs/caching.mara.md +999 -0
- package/docs/ci.mara.md +308 -0
- package/docs/configuration.mara.md +508 -0
- package/docs/decisions.mara.md +3267 -0
- package/docs/execution.mara.md +533 -0
- package/docs/index.mara.md +51 -0
- package/docs/product.mara.md +366 -0
- package/docs/release.mara.md +493 -0
- package/docs/setup.mara.md +486 -0
- package/docs/targets.mara.md +704 -0
- package/docs/testing.mara.md +431 -0
- package/docs/verification.mara.md +465 -0
- package/docs/workspaces.mara.md +445 -0
- package/executors.json +35 -0
- package/generators.json +19 -0
- package/package.json +17 -4
- package/src/cargo/build-settings.d.ts +61 -0
- package/src/cargo/build-settings.js +103 -0
- package/src/cargo/build-settings.js.map +1 -0
- package/src/cargo/configured-runner.d.ts +36 -0
- package/src/cargo/configured-runner.js +99 -0
- package/src/cargo/configured-runner.js.map +1 -0
- package/src/cargo/configured-tools.d.ts +35 -0
- package/src/cargo/configured-tools.js +46 -0
- package/src/cargo/configured-tools.js.map +1 -0
- package/src/cargo/dep-info-basedir.d.ts +18 -0
- package/src/cargo/dep-info-basedir.js +38 -0
- package/src/cargo/dep-info-basedir.js.map +1 -0
- package/src/cargo/directories.d.ts +40 -0
- package/src/cargo/directories.js +89 -0
- package/src/cargo/directories.js.map +1 -0
- package/src/cargo/host-triple.d.ts +7 -0
- package/src/cargo/host-triple.js +21 -0
- package/src/cargo/host-triple.js.map +1 -0
- package/src/cargo/lockfile.d.ts +63 -0
- package/src/cargo/lockfile.js +157 -0
- package/src/cargo/lockfile.js.map +1 -0
- package/src/cargo/metadata.d.ts +114 -0
- package/src/cargo/metadata.js +37 -0
- package/src/cargo/metadata.js.map +1 -0
- package/src/cargo/package-specs.d.ts +54 -0
- package/src/cargo/package-specs.js +109 -0
- package/src/cargo/package-specs.js.map +1 -0
- package/src/cargo/paths-crates.d.ts +27 -0
- package/src/cargo/paths-crates.js +69 -0
- package/src/cargo/paths-crates.js.map +1 -0
- package/src/cargo/print-artifact-folders.d.ts +1 -0
- package/src/cargo/print-artifact-folders.js +58 -0
- package/src/cargo/print-artifact-folders.js.map +1 -0
- package/src/cargo/redirections.d.ts +90 -0
- package/src/cargo/redirections.js +200 -0
- package/src/cargo/redirections.js.map +1 -0
- package/src/cargo/run-cargo.d.ts +31 -0
- package/src/cargo/run-cargo.js +75 -0
- package/src/cargo/run-cargo.js.map +1 -0
- package/src/cargo/target-triples.d.ts +98 -0
- package/src/cargo/target-triples.js +265 -0
- package/src/cargo/target-triples.js.map +1 -0
- package/src/cargo/version-req.d.ts +12 -0
- package/src/cargo/version-req.js +122 -0
- package/src/cargo/version-req.js.map +1 -0
- package/src/cargo/warnings-setting.d.ts +24 -0
- package/src/cargo/warnings-setting.js +81 -0
- package/src/cargo/warnings-setting.js.map +1 -0
- package/src/compatibility/cargo-version.d.ts +43 -0
- package/src/compatibility/cargo-version.js +83 -0
- package/src/compatibility/cargo-version.js.map +1 -0
- package/src/compatibility/nx-bridge.d.ts +312 -0
- package/src/compatibility/nx-bridge.js +407 -0
- package/src/compatibility/nx-bridge.js.map +1 -0
- package/src/compatibility/nx-version.d.ts +104 -0
- package/src/compatibility/nx-version.js +272 -0
- package/src/compatibility/nx-version.js.map +1 -0
- package/src/executors/affected-inputs.d.ts +29 -0
- package/src/executors/affected-inputs.js +259 -0
- package/src/executors/affected-inputs.js.map +1 -0
- package/src/executors/affected-run.d.ts +54 -0
- package/src/executors/affected-run.js +394 -0
- package/src/executors/affected-run.js.map +1 -0
- package/src/executors/affected.d.ts +239 -0
- package/src/executors/affected.js +589 -0
- package/src/executors/affected.js.map +1 -0
- package/src/executors/baseline-context.d.ts +85 -0
- package/src/executors/baseline-context.js +227 -0
- package/src/executors/baseline-context.js.map +1 -0
- package/src/executors/baseline.d.ts +123 -0
- package/src/executors/baseline.js +356 -0
- package/src/executors/baseline.js.map +1 -0
- package/src/executors/batch.d.ts +75 -0
- package/src/executors/batch.js +434 -0
- package/src/executors/batch.js.map +1 -0
- package/src/executors/build-records.d.ts +110 -0
- package/src/executors/build-records.js +267 -0
- package/src/executors/build-records.js.map +1 -0
- package/src/executors/cargo/executor.d.ts +28 -0
- package/src/executors/cargo/executor.js +58 -0
- package/src/executors/cargo/executor.js.map +1 -0
- package/src/executors/cargo/schema.json +58 -0
- package/src/executors/cargo-invocation.d.ts +81 -0
- package/src/executors/cargo-invocation.js +109 -0
- package/src/executors/cargo-invocation.js.map +1 -0
- package/src/executors/cargo-output.d.ts +218 -0
- package/src/executors/cargo-output.js +660 -0
- package/src/executors/cargo-output.js.map +1 -0
- package/src/executors/command.d.ts +331 -0
- package/src/executors/command.js +547 -0
- package/src/executors/command.js.map +1 -0
- package/src/executors/coverage-baseline.d.ts +23 -0
- package/src/executors/coverage-baseline.js +284 -0
- package/src/executors/coverage-baseline.js.map +1 -0
- package/src/executors/declared-options.d.ts +21 -0
- package/src/executors/declared-options.js +58 -0
- package/src/executors/declared-options.js.map +1 -0
- package/src/executors/denied-warnings.d.ts +99 -0
- package/src/executors/denied-warnings.js +188 -0
- package/src/executors/denied-warnings.js.map +1 -0
- package/src/executors/digests.d.ts +94 -0
- package/src/executors/digests.js +190 -0
- package/src/executors/digests.js.map +1 -0
- package/src/executors/dotenv-check.d.ts +79 -0
- package/src/executors/dotenv-check.js +553 -0
- package/src/executors/dotenv-check.js.map +1 -0
- package/src/executors/group-invocations.d.ts +80 -0
- package/src/executors/group-invocations.js +253 -0
- package/src/executors/group-invocations.js.map +1 -0
- package/src/executors/group-run.d.ts +114 -0
- package/src/executors/group-run.js +601 -0
- package/src/executors/group-run.js.map +1 -0
- package/src/executors/groups.d.ts +118 -0
- package/src/executors/groups.js +304 -0
- package/src/executors/groups.js.map +1 -0
- package/src/executors/input-check.d.ts +52 -0
- package/src/executors/input-check.js +271 -0
- package/src/executors/input-check.js.map +1 -0
- package/src/executors/kept-files.d.ts +98 -0
- package/src/executors/kept-files.js +341 -0
- package/src/executors/kept-files.js.map +1 -0
- package/src/executors/lockfile/executor.d.ts +16 -0
- package/src/executors/lockfile/executor.js +37 -0
- package/src/executors/lockfile/executor.js.map +1 -0
- package/src/executors/lockfile/schema.json +50 -0
- package/src/executors/napi-build.d.ts +73 -0
- package/src/executors/napi-build.js +420 -0
- package/src/executors/napi-build.js.map +1 -0
- package/src/executors/nextest.d.ts +189 -0
- package/src/executors/nextest.js +504 -0
- package/src/executors/nextest.js.map +1 -0
- package/src/executors/nx-command.d.ts +95 -0
- package/src/executors/nx-command.js +205 -0
- package/src/executors/nx-command.js.map +1 -0
- package/src/executors/nx-task-files.d.ts +82 -0
- package/src/executors/nx-task-files.js +156 -0
- package/src/executors/nx-task-files.js.map +1 -0
- package/src/executors/print-test-mode.d.ts +1 -0
- package/src/executors/print-test-mode.js +25 -0
- package/src/executors/print-test-mode.js.map +1 -0
- package/src/executors/release-publish/executor.d.ts +24 -0
- package/src/executors/release-publish/executor.js +165 -0
- package/src/executors/release-publish/executor.js.map +1 -0
- package/src/executors/release-publish/schema.json +30 -0
- package/src/executors/run/executor.d.ts +12 -0
- package/src/executors/run/executor.js +27 -0
- package/src/executors/run/executor.js.map +1 -0
- package/src/executors/run/schema.json +45 -0
- package/src/executors/runner-script.d.ts +12 -0
- package/src/executors/runner-script.js +22 -0
- package/src/executors/runner-script.js.map +1 -0
- package/src/executors/runtime-input-check.d.ts +24 -0
- package/src/executors/runtime-input-check.js +87 -0
- package/src/executors/runtime-input-check.js.map +1 -0
- package/src/executors/shared-artifacts.d.ts +44 -0
- package/src/executors/shared-artifacts.js +132 -0
- package/src/executors/shared-artifacts.js.map +1 -0
- package/src/executors/split-words.d.ts +24 -0
- package/src/executors/split-words.js +111 -0
- package/src/executors/split-words.js.map +1 -0
- package/src/executors/stage.d.ts +163 -0
- package/src/executors/stage.js +526 -0
- package/src/executors/stage.js.map +1 -0
- package/src/executors/staged-run.d.ts +24 -0
- package/src/executors/staged-run.js +110 -0
- package/src/executors/staged-run.js.map +1 -0
- package/src/executors/task-env.d.ts +271 -0
- package/src/executors/task-env.js +494 -0
- package/src/executors/task-env.js.map +1 -0
- package/src/executors/task-execution.d.ts +61 -0
- package/src/executors/task-execution.js +122 -0
- package/src/executors/task-execution.js.map +1 -0
- package/src/executors/task-guards.d.ts +112 -0
- package/src/executors/task-guards.js +435 -0
- package/src/executors/task-guards.js.map +1 -0
- package/src/executors/task-options.d.ts +114 -0
- package/src/executors/task-options.js +258 -0
- package/src/executors/task-options.js.map +1 -0
- package/src/executors/task.d.ts +166 -0
- package/src/executors/task.js +527 -0
- package/src/executors/task.js.map +1 -0
- package/src/executors/test-mode.d.ts +185 -0
- package/src/executors/test-mode.js +397 -0
- package/src/executors/test-mode.js.map +1 -0
- package/src/executors/test-runner.d.ts +44 -0
- package/src/executors/test-runner.js +159 -0
- package/src/executors/test-runner.js.map +1 -0
- package/src/executors/test-steps.d.ts +121 -0
- package/src/executors/test-steps.js +566 -0
- package/src/executors/test-steps.js.map +1 -0
- package/src/executors/wasm-build.d.ts +56 -0
- package/src/executors/wasm-build.js +216 -0
- package/src/executors/wasm-build.js.map +1 -0
- package/src/generators/crate/binary.schema.json +28 -0
- package/src/generators/crate/crate.d.ts +24 -0
- package/src/generators/crate/crate.js +108 -0
- package/src/generators/crate/crate.js.map +1 -0
- package/src/generators/crate/enclosing-workspace.d.ts +25 -0
- package/src/generators/crate/enclosing-workspace.js +58 -0
- package/src/generators/crate/enclosing-workspace.js.map +1 -0
- package/src/generators/crate/library.schema.json +28 -0
- package/src/generators/init/graph-check.d.ts +81 -0
- package/src/generators/init/graph-check.js +299 -0
- package/src/generators/init/graph-check.js.map +1 -0
- package/src/generators/init/init.d.ts +23 -0
- package/src/generators/init/init.js +113 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/report.d.ts +19 -0
- package/src/generators/init/report.js +93 -0
- package/src/generators/init/report.js.map +1 -0
- package/src/generators/init/schema.json +9 -0
- package/src/graph/artifact-kinds.d.ts +29 -0
- package/src/graph/artifact-kinds.js +50 -0
- package/src/graph/artifact-kinds.js.map +1 -0
- package/src/graph/artifact-names.d.ts +97 -0
- package/src/graph/artifact-names.js +276 -0
- package/src/graph/artifact-names.js.map +1 -0
- package/src/graph/build-records.d.ts +74 -0
- package/src/graph/build-records.js +104 -0
- package/src/graph/build-records.js.map +1 -0
- package/src/graph/caching.d.ts +148 -0
- package/src/graph/caching.js +681 -0
- package/src/graph/caching.js.map +1 -0
- package/src/graph/clippy-input.d.ts +53 -0
- package/src/graph/clippy-input.js +107 -0
- package/src/graph/clippy-input.js.map +1 -0
- package/src/graph/collisions.d.ts +113 -0
- package/src/graph/collisions.js +156 -0
- package/src/graph/collisions.js.map +1 -0
- package/src/graph/computation-reports.d.ts +89 -0
- package/src/graph/computation-reports.js +216 -0
- package/src/graph/computation-reports.js.map +1 -0
- package/src/graph/declared-files.d.ts +190 -0
- package/src/graph/declared-files.js +600 -0
- package/src/graph/declared-files.js.map +1 -0
- package/src/graph/discovery.d.ts +190 -0
- package/src/graph/discovery.js +661 -0
- package/src/graph/discovery.js.map +1 -0
- package/src/graph/edges.d.ts +25 -0
- package/src/graph/edges.js +94 -0
- package/src/graph/edges.js.map +1 -0
- package/src/graph/entries.d.ts +83 -0
- package/src/graph/entries.js +259 -0
- package/src/graph/entries.js.map +1 -0
- package/src/graph/inputs.d.ts +422 -0
- package/src/graph/inputs.js +756 -0
- package/src/graph/inputs.js.map +1 -0
- package/src/graph/lockfile-task.d.ts +74 -0
- package/src/graph/lockfile-task.js +105 -0
- package/src/graph/lockfile-task.js.map +1 -0
- package/src/graph/names.d.ts +41 -0
- package/src/graph/names.js +34 -0
- package/src/graph/names.js.map +1 -0
- package/src/graph/napi.d.ts +107 -0
- package/src/graph/napi.js +206 -0
- package/src/graph/napi.js.map +1 -0
- package/src/graph/nx-glob.d.ts +36 -0
- package/src/graph/nx-glob.js +152 -0
- package/src/graph/nx-glob.js.map +1 -0
- package/src/graph/nx-internals.d.ts +57 -0
- package/src/graph/nx-internals.js +128 -0
- package/src/graph/nx-internals.js.map +1 -0
- package/src/graph/options.d.ts +32 -0
- package/src/graph/options.js +80 -0
- package/src/graph/options.js.map +1 -0
- package/src/graph/outputs.d.ts +75 -0
- package/src/graph/outputs.js +140 -0
- package/src/graph/outputs.js.map +1 -0
- package/src/graph/path-dependencies.d.ts +122 -0
- package/src/graph/path-dependencies.js +459 -0
- package/src/graph/path-dependencies.js.map +1 -0
- package/src/graph/plugin-package.d.ts +36 -0
- package/src/graph/plugin-package.js +132 -0
- package/src/graph/plugin-package.js.map +1 -0
- package/src/graph/plugin-version.d.ts +20 -0
- package/src/graph/plugin-version.js +153 -0
- package/src/graph/plugin-version.js.map +1 -0
- package/src/graph/projects.d.ts +141 -0
- package/src/graph/projects.js +193 -0
- package/src/graph/projects.js.map +1 -0
- package/src/graph/reached-projects.d.ts +46 -0
- package/src/graph/reached-projects.js +102 -0
- package/src/graph/reached-projects.js.map +1 -0
- package/src/graph/real-path.d.ts +47 -0
- package/src/graph/real-path.js +113 -0
- package/src/graph/real-path.js.map +1 -0
- package/src/graph/redirected-uses.d.ts +98 -0
- package/src/graph/redirected-uses.js +434 -0
- package/src/graph/redirected-uses.js.map +1 -0
- package/src/graph/registration.d.ts +121 -0
- package/src/graph/registration.js +233 -0
- package/src/graph/registration.js.map +1 -0
- package/src/graph/rustfmt-config.d.ts +42 -0
- package/src/graph/rustfmt-config.js +173 -0
- package/src/graph/rustfmt-config.js.map +1 -0
- package/src/graph/script-input.d.ts +46 -0
- package/src/graph/script-input.js +65 -0
- package/src/graph/script-input.js.map +1 -0
- package/src/graph/settings.d.ts +178 -0
- package/src/graph/settings.js +479 -0
- package/src/graph/settings.js.map +1 -0
- package/src/graph/target-defaults-causes.d.ts +33 -0
- package/src/graph/target-defaults-causes.js +202 -0
- package/src/graph/target-defaults-causes.js.map +1 -0
- package/src/graph/target-defaults-layers.d.ts +186 -0
- package/src/graph/target-defaults-layers.js +420 -0
- package/src/graph/target-defaults-layers.js.map +1 -0
- package/src/graph/target-defaults-meaning.d.ts +95 -0
- package/src/graph/target-defaults-meaning.js +292 -0
- package/src/graph/target-defaults-meaning.js.map +1 -0
- package/src/graph/target-defaults-report.d.ts +77 -0
- package/src/graph/target-defaults-report.js +242 -0
- package/src/graph/target-defaults-report.js.map +1 -0
- package/src/graph/target-defaults.d.ts +79 -0
- package/src/graph/target-defaults.js +425 -0
- package/src/graph/target-defaults.js.map +1 -0
- package/src/graph/target-fields.d.ts +16 -0
- package/src/graph/target-fields.js +134 -0
- package/src/graph/target-fields.js.map +1 -0
- package/src/graph/target-tables.d.ts +45 -0
- package/src/graph/target-tables.js +299 -0
- package/src/graph/target-tables.js.map +1 -0
- package/src/graph/targets.d.ts +371 -0
- package/src/graph/targets.js +408 -0
- package/src/graph/targets.js.map +1 -0
- package/src/graph/unification.d.ts +141 -0
- package/src/graph/unification.js +459 -0
- package/src/graph/unification.js.map +1 -0
- package/src/graph/unignored-directories.d.ts +25 -0
- package/src/graph/unignored-directories.js +89 -0
- package/src/graph/unignored-directories.js.map +1 -0
- package/src/graph/visibility.d.ts +17 -0
- package/src/graph/visibility.js +67 -0
- package/src/graph/visibility.js.map +1 -0
- package/src/graph/warnings.d.ts +38 -0
- package/src/graph/warnings.js +77 -0
- package/src/graph/warnings.js.map +1 -0
- package/src/graph/wasm.d.ts +56 -0
- package/src/graph/wasm.js +77 -0
- package/src/graph/wasm.js.map +1 -0
- package/src/index.d.ts +68 -0
- package/src/index.js +109 -0
- package/src/index.js.map +1 -0
- package/src/release/manifests.d.ts +95 -0
- package/src/release/manifests.js +164 -0
- package/src/release/manifests.js.map +1 -0
- package/src/release/places.d.ts +127 -0
- package/src/release/places.js +368 -0
- package/src/release/places.js.map +1 -0
- package/src/release/publish-cargo.d.ts +177 -0
- package/src/release/publish-cargo.js +351 -0
- package/src/release/publish-cargo.js.map +1 -0
- package/src/release/publish-crates.d.ts +124 -0
- package/src/release/publish-crates.js +242 -0
- package/src/release/publish-crates.js.map +1 -0
- package/src/release/publish-environments.d.ts +50 -0
- package/src/release/publish-environments.js +284 -0
- package/src/release/publish-environments.js.map +1 -0
- package/src/release/publish-messages.d.ts +66 -0
- package/src/release/publish-messages.js +273 -0
- package/src/release/publish-messages.js.map +1 -0
- package/src/release/publish-registry.d.ts +27 -0
- package/src/release/publish-registry.js +135 -0
- package/src/release/publish-registry.js.map +1 -0
- package/src/release/publish-settings.d.ts +26 -0
- package/src/release/publish-settings.js +56 -0
- package/src/release/publish-settings.js.map +1 -0
- package/src/release/publish.d.ts +59 -0
- package/src/release/publish.js +620 -0
- package/src/release/publish.js.map +1 -0
- package/src/release/repository.d.ts +73 -0
- package/src/release/repository.js +219 -0
- package/src/release/repository.js.map +1 -0
- package/src/release/requirements.d.ts +34 -0
- package/src/release/requirements.js +30 -0
- package/src/release/requirements.js.map +1 -0
- package/src/release/toml-edit.d.ts +67 -0
- package/src/release/toml-edit.js +453 -0
- package/src/release/toml-edit.js.map +1 -0
- package/src/release/version-actions.d.ts +133 -0
- package/src/release/version-actions.js +474 -0
- package/src/release/version-actions.js.map +1 -0
- package/src/release/version-checks.d.ts +21 -0
- package/src/release/version-checks.js +151 -0
- package/src/release/version-checks.js.map +1 -0
- package/src/release/version-lockfiles.d.ts +61 -0
- package/src/release/version-lockfiles.js +222 -0
- package/src/release/version-lockfiles.js.map +1 -0
- package/src/tools/napi-cli.d.ts +70 -0
- package/src/tools/napi-cli.js +63 -0
- package/src/tools/napi-cli.js.map +1 -0
- package/src/tools/optional-tools.d.ts +121 -0
- package/src/tools/optional-tools.js +303 -0
- package/src/tools/optional-tools.js.map +1 -0
- package/src/tools/print-napi-cli.d.ts +1 -0
- package/src/tools/print-napi-cli.js +24 -0
- package/src/tools/print-napi-cli.js.map +1 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { TargetConfiguration } from "@nx/devkit";
|
|
2
|
+
import type { CargoMetadata, CargoPackage } from "../cargo/metadata";
|
|
3
|
+
import type { CargoDiscovery, CargoWorkspace } from "./discovery";
|
|
4
|
+
import { TargetNames } from "./options";
|
|
5
|
+
/** The test runner of a workspace (`DES-TEST-RUN`). */
|
|
6
|
+
export type TestRunner = "cargo" | "nextest";
|
|
7
|
+
/** The feature-unification strategy of a workspace (`DES-UNIFICATION`). */
|
|
8
|
+
export type FeatureUnification = "hakari" | "cargo" | "workspace-build";
|
|
9
|
+
/** A kind of artifact that `artifacts` names (`DES-ARTIFACT-STEPS`). */
|
|
10
|
+
export type ArtifactKind = "napi" | "wasm";
|
|
11
|
+
/** The options of one entry of the plugin in `nx.json`, validated. */
|
|
12
|
+
export interface PluginOptions {
|
|
13
|
+
targetNames: TargetNames;
|
|
14
|
+
/** Locked mode for the plugin's commands (`DES-INVOCATION`); `false` where unset. */
|
|
15
|
+
locked: boolean;
|
|
16
|
+
testRunner?: TestRunner;
|
|
17
|
+
affectedTests?: boolean;
|
|
18
|
+
featureUnification?: FeatureUnification;
|
|
19
|
+
envInputs: readonly string[];
|
|
20
|
+
runtimeInputs: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
/** The header of a metadata table, which messages name. */
|
|
23
|
+
export type MetadataTable = "[package.metadata.nx]" | "[workspace.metadata.nx]" | "[workspace.metadata.nx.project]";
|
|
24
|
+
/** A `targets.<name>` table of a metadata table, with where it is written. */
|
|
25
|
+
export interface TargetTable {
|
|
26
|
+
/**
|
|
27
|
+
* The key of the table. It addresses the inferred target of that name
|
|
28
|
+
* after `targetNames`, or else defines an extra target.
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/** The table as written, shaped like an Nx target. */
|
|
32
|
+
target: TargetConfiguration;
|
|
33
|
+
/** The manifest that holds it, relative to the repository root. */
|
|
34
|
+
manifest: string;
|
|
35
|
+
/** The table it is under. */
|
|
36
|
+
table: MetadataTable;
|
|
37
|
+
}
|
|
38
|
+
/** A pattern of `fileInputs`, which is relative to the folder of the manifest that holds it. */
|
|
39
|
+
export interface FileInput {
|
|
40
|
+
pattern: string;
|
|
41
|
+
/** The manifest that holds the pattern, relative to the repository root. */
|
|
42
|
+
manifest: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The settings of one workspace: the plugin options of the entry that
|
|
46
|
+
* received it, with `[workspace.metadata.nx]` of its root manifest laid
|
|
47
|
+
* over them (`DES-PLUGIN-OPTIONS`).
|
|
48
|
+
*/
|
|
49
|
+
export interface WorkspaceSettings {
|
|
50
|
+
/** The workspace's root manifest, relative to the repository root. */
|
|
51
|
+
rootManifest: string;
|
|
52
|
+
/** Locked mode, from the plugin options only (`DES-INVOCATION`). */
|
|
53
|
+
locked: boolean;
|
|
54
|
+
testRunner: TestRunner;
|
|
55
|
+
affectedTests: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The strategy that the workspace table or the plugin options set.
|
|
58
|
+
* `undefined` means the default of `DES-UNIFICATION`, which depends on
|
|
59
|
+
* whether the workspace has a cargo-hakari configuration (nxr-k64tm5).
|
|
60
|
+
*/
|
|
61
|
+
featureUnification?: FeatureUnification;
|
|
62
|
+
/** Put in front of the package name of each member without a `name` of its own. */
|
|
63
|
+
namePrefix?: string;
|
|
64
|
+
/** The workspace table's tags, which every member and the workspace project have. */
|
|
65
|
+
tags: readonly string[];
|
|
66
|
+
/** The workspace table's implicit dependencies, which every member has. */
|
|
67
|
+
implicitDependencies: readonly string[];
|
|
68
|
+
/** The variables of the plugin options and of the workspace table. */
|
|
69
|
+
envInputs: readonly string[];
|
|
70
|
+
/** The commands of the plugin options and of the workspace table. */
|
|
71
|
+
runtimeInputs: readonly string[];
|
|
72
|
+
/** The patterns of the workspace table. */
|
|
73
|
+
fileInputs: readonly FileInput[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* What the settings give one project of the plugin: a crate, or the
|
|
77
|
+
* workspace project of a root manifest without a crate. Lists that add up
|
|
78
|
+
* across levels hold the values of every level that applies to the project.
|
|
79
|
+
*/
|
|
80
|
+
export interface ProjectSettings {
|
|
81
|
+
workspace: WorkspaceSettings;
|
|
82
|
+
/**
|
|
83
|
+
* The `name` that the crate's table, or the `project` table for a
|
|
84
|
+
* workspace project, sets.
|
|
85
|
+
*/
|
|
86
|
+
name?: string;
|
|
87
|
+
tags: readonly string[];
|
|
88
|
+
implicitDependencies: readonly string[];
|
|
89
|
+
/** The variables of the plugin options and of both tables, for a crate; none for a workspace project. */
|
|
90
|
+
envInputs: readonly string[];
|
|
91
|
+
/** The commands of the plugin options and of both tables, for a crate; none for a workspace project. */
|
|
92
|
+
runtimeInputs: readonly string[];
|
|
93
|
+
/** The patterns of both tables, for a crate; none for a workspace project. */
|
|
94
|
+
fileInputs: readonly FileInput[];
|
|
95
|
+
/** The crate's `artifacts`, in place of the inferred kinds; absent where it sets none. */
|
|
96
|
+
artifacts?: readonly ArtifactKind[];
|
|
97
|
+
/** The target tables for the project, in order of precedence: the workspace table's first. */
|
|
98
|
+
targets: readonly TargetTable[];
|
|
99
|
+
}
|
|
100
|
+
/** The settings of every workspace and project of one graph computation. */
|
|
101
|
+
export declare class GraphSettings {
|
|
102
|
+
readonly options: PluginOptions;
|
|
103
|
+
private readonly workspaces;
|
|
104
|
+
private readonly crates;
|
|
105
|
+
private readonly workspaceProjects;
|
|
106
|
+
constructor(options: PluginOptions, workspaces: ReadonlyMap<CargoWorkspace, WorkspaceSettings>, crates: ReadonlyMap<string, ProjectSettings>, workspaceProjects: ReadonlyMap<CargoWorkspace, ProjectSettings>);
|
|
107
|
+
/** The settings of a workspace that discovery found. */
|
|
108
|
+
workspace(workspace: CargoWorkspace): WorkspaceSettings;
|
|
109
|
+
/** The settings of a member that discovery handed over. */
|
|
110
|
+
crate(pkg: CargoPackage): ProjectSettings;
|
|
111
|
+
/** The settings of the workspace project of a root manifest without a crate. */
|
|
112
|
+
workspaceProject(workspace: CargoWorkspace): ProjectSettings;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Reads the options of the plugin's entry in `nx.json`, as Nx passes them to
|
|
116
|
+
* `createNodes`: each setting that `DES-PLUGIN-OPTIONS` gives the plugin
|
|
117
|
+
* options, validated.
|
|
118
|
+
*
|
|
119
|
+
* @throws {Error} When a key is unknown there or a value is invalid, naming
|
|
120
|
+
* `nx.json` and each such key.
|
|
121
|
+
*/
|
|
122
|
+
export declare function readPluginOptions(options: unknown): PluginOptions;
|
|
123
|
+
/**
|
|
124
|
+
* Reads `[workspace.metadata.nx]` of each workspace that discovery found,
|
|
125
|
+
* with its `project` table, and `[package.metadata.nx]` of each member that
|
|
126
|
+
* becomes a project, from the `cargo metadata` reports (`DES-METADATA-REPORT`),
|
|
127
|
+
* and combines them with the plugin options by the precedence of
|
|
128
|
+
* `DES-PLUGIN-OPTIONS`: a crate's value wins over the workspace's, which wins
|
|
129
|
+
* over the plugin options', and tags, `implicitDependencies`, `fileInputs`,
|
|
130
|
+
* `envInputs` and `runtimeInputs` add up.
|
|
131
|
+
*
|
|
132
|
+
* @throws {Error} Naming every manifest with an unknown key, an invalid
|
|
133
|
+
* value, an `implicitDependencies` entry starting with `!`, or a `project`
|
|
134
|
+
* table in a root manifest that defines a crate.
|
|
135
|
+
*/
|
|
136
|
+
export declare function readSettings(discovery: CargoDiscovery, options: PluginOptions): GraphSettings;
|
|
137
|
+
/**
|
|
138
|
+
* The error for a workspace that turns on the selection of affected tests
|
|
139
|
+
* without the nextest runner (`REQ-AFFECTED-TESTS`, `DES-DIAGNOSTICS`): it
|
|
140
|
+
* names both options, where each of their values comes from, and what to
|
|
141
|
+
* change. `undefined` where the workspace does not select or uses nextest.
|
|
142
|
+
*/
|
|
143
|
+
export declare function affectedTestsRunnerProblem(rootManifest: string, table: {
|
|
144
|
+
testRunner?: TestRunner;
|
|
145
|
+
affectedTests?: boolean;
|
|
146
|
+
}, options: {
|
|
147
|
+
testRunner?: TestRunner;
|
|
148
|
+
affectedTests?: boolean;
|
|
149
|
+
}): string | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* The `fileInputs` of a crate that another crate's inputs name by its
|
|
152
|
+
* folder, beside an edge, such as a path dependency without a project: those
|
|
153
|
+
* of its workspace's table and of its own, each with its manifest, as
|
|
154
|
+
* {@link readSettings} reads them for a project (`DES-INPUTS`). Only that key
|
|
155
|
+
* is read.
|
|
156
|
+
*
|
|
157
|
+
* @param report The `cargo metadata` report of the crate's workspace.
|
|
158
|
+
* @param problems Where a value of the wrong type is reported.
|
|
159
|
+
*/
|
|
160
|
+
export declare function readCrateFileInputs(pkg: CargoPackage, report: CargoMetadata, repositoryRoot: string, problems: string[]): FileInput[];
|
|
161
|
+
/**
|
|
162
|
+
* The variables and commands that a crate adds to its key with `envInputs`
|
|
163
|
+
* and `runtimeInputs` in its workspace's table and in its own, each once, for
|
|
164
|
+
* a crate that another crate's inputs name by its folder in place of an
|
|
165
|
+
* edge, which would have brought them in the crate's named input
|
|
166
|
+
* (`DES-INPUTS`, "Added variables and commands"). Only those keys are read,
|
|
167
|
+
* as {@link readSettings} reads them for a project; the plugin options'
|
|
168
|
+
* additions reach every crate of the entry already.
|
|
169
|
+
*
|
|
170
|
+
* @param report The `cargo metadata` report of the crate's workspace.
|
|
171
|
+
* @param problems Where a value of the wrong type is reported.
|
|
172
|
+
*/
|
|
173
|
+
export declare function readCrateAddedInputs(pkg: CargoPackage, report: CargoMetadata, repositoryRoot: string, problems: string[]): {
|
|
174
|
+
envInputs: string[];
|
|
175
|
+
runtimeInputs: string[];
|
|
176
|
+
};
|
|
177
|
+
/** The header of a target table in messages, such as `[package.metadata.nx.targets.test]`. */
|
|
178
|
+
export declare function targetHeader(table: MetadataTable, target: string, ...path: string[]): string;
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphSettings = void 0;
|
|
4
|
+
exports.readPluginOptions = readPluginOptions;
|
|
5
|
+
exports.readSettings = readSettings;
|
|
6
|
+
exports.affectedTestsRunnerProblem = affectedTestsRunnerProblem;
|
|
7
|
+
exports.readCrateFileInputs = readCrateFileInputs;
|
|
8
|
+
exports.readCrateAddedInputs = readCrateAddedInputs;
|
|
9
|
+
exports.targetHeader = targetHeader;
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const options_1 = require("./options");
|
|
12
|
+
const target_fields_1 = require("./target-fields");
|
|
13
|
+
/** The settings of every workspace and project of one graph computation. */
|
|
14
|
+
class GraphSettings {
|
|
15
|
+
constructor(options, workspaces, crates, workspaceProjects) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.workspaces = workspaces;
|
|
18
|
+
this.crates = crates;
|
|
19
|
+
this.workspaceProjects = workspaceProjects;
|
|
20
|
+
}
|
|
21
|
+
/** The settings of a workspace that discovery found. */
|
|
22
|
+
workspace(workspace) {
|
|
23
|
+
return found(this.workspaces.get(workspace), workspace.rootManifest);
|
|
24
|
+
}
|
|
25
|
+
/** The settings of a member that discovery handed over. */
|
|
26
|
+
crate(pkg) {
|
|
27
|
+
return found(this.crates.get(pkg.manifest_path), pkg.manifest_path);
|
|
28
|
+
}
|
|
29
|
+
/** The settings of the workspace project of a root manifest without a crate. */
|
|
30
|
+
workspaceProject(workspace) {
|
|
31
|
+
return found(this.workspaceProjects.get(workspace), workspace.rootManifest);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.GraphSettings = GraphSettings;
|
|
35
|
+
function found(value, manifest) {
|
|
36
|
+
if (value === undefined) {
|
|
37
|
+
throw new Error(`nx-rust read no settings for ${manifest}. Please report this at https://github.com/convesoft/nx-rust/issues.`);
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
const pluginOptionsLabel = "the options of the @convesoft/nx-rust entry";
|
|
42
|
+
/** Each key that a place accepts, in the order of `DES-PLUGIN-OPTIONS`. */
|
|
43
|
+
const keysOf = {
|
|
44
|
+
plugin: [
|
|
45
|
+
"targetNames",
|
|
46
|
+
"locked",
|
|
47
|
+
"testRunner",
|
|
48
|
+
"affectedTests",
|
|
49
|
+
"featureUnification",
|
|
50
|
+
"envInputs",
|
|
51
|
+
"runtimeInputs",
|
|
52
|
+
],
|
|
53
|
+
workspace: [
|
|
54
|
+
"testRunner",
|
|
55
|
+
"affectedTests",
|
|
56
|
+
"featureUnification",
|
|
57
|
+
"namePrefix",
|
|
58
|
+
"tags",
|
|
59
|
+
"targets",
|
|
60
|
+
"implicitDependencies",
|
|
61
|
+
"envInputs",
|
|
62
|
+
"runtimeInputs",
|
|
63
|
+
"fileInputs",
|
|
64
|
+
"project",
|
|
65
|
+
],
|
|
66
|
+
project: ["name", "tags", "targets"],
|
|
67
|
+
package: [
|
|
68
|
+
"name",
|
|
69
|
+
"artifacts",
|
|
70
|
+
"tags",
|
|
71
|
+
"targets",
|
|
72
|
+
"implicitDependencies",
|
|
73
|
+
"envInputs",
|
|
74
|
+
"runtimeInputs",
|
|
75
|
+
"fileInputs",
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
/** Where a key that a place does not accept can be set instead, for the message. */
|
|
79
|
+
const placesOf = {
|
|
80
|
+
targetNames: "the options of the plugin's entry in nx.json",
|
|
81
|
+
locked: "the options of the plugin's entry in nx.json",
|
|
82
|
+
testRunner: "[workspace.metadata.nx] or the options of the plugin's entry in nx.json",
|
|
83
|
+
affectedTests: "[workspace.metadata.nx] or the options of the plugin's entry in nx.json",
|
|
84
|
+
featureUnification: "[workspace.metadata.nx] or the options of the plugin's entry in nx.json",
|
|
85
|
+
namePrefix: "[workspace.metadata.nx] of a workspace's root manifest",
|
|
86
|
+
name: "[package.metadata.nx] of a crate, or [workspace.metadata.nx.project] for a workspace project",
|
|
87
|
+
artifacts: "[package.metadata.nx] of a crate",
|
|
88
|
+
tags: "[package.metadata.nx], [workspace.metadata.nx] or [workspace.metadata.nx.project]",
|
|
89
|
+
targets: "[package.metadata.nx], [workspace.metadata.nx] or [workspace.metadata.nx.project]",
|
|
90
|
+
implicitDependencies: "[package.metadata.nx] or [workspace.metadata.nx]",
|
|
91
|
+
envInputs: "[package.metadata.nx], [workspace.metadata.nx] or the options of the plugin's entry in nx.json",
|
|
92
|
+
runtimeInputs: "[package.metadata.nx], [workspace.metadata.nx] or the options of the plugin's entry in nx.json",
|
|
93
|
+
fileInputs: "[package.metadata.nx] or [workspace.metadata.nx]",
|
|
94
|
+
project: "[workspace.metadata.nx]",
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Reads the options of the plugin's entry in `nx.json`, as Nx passes them to
|
|
98
|
+
* `createNodes`: each setting that `DES-PLUGIN-OPTIONS` gives the plugin
|
|
99
|
+
* options, validated.
|
|
100
|
+
*
|
|
101
|
+
* @throws {Error} When a key is unknown there or a value is invalid, naming
|
|
102
|
+
* `nx.json` and each such key.
|
|
103
|
+
*/
|
|
104
|
+
// @mara implements DES-PLUGIN-OPTIONS
|
|
105
|
+
function readPluginOptions(options) {
|
|
106
|
+
const problems = [];
|
|
107
|
+
if (options !== undefined && options !== null && !isTable(options)) {
|
|
108
|
+
throw new Error(`nx.json: ${pluginOptionsLabel} have to be an object, not ${JSON.stringify(options)}.`);
|
|
109
|
+
}
|
|
110
|
+
const reader = new TableReader("nx.json", pluginOptionsLabel, isTable(options) ? options : {}, problems);
|
|
111
|
+
reader.unknownKeys("plugin");
|
|
112
|
+
const read = {
|
|
113
|
+
targetNames: {},
|
|
114
|
+
locked: false,
|
|
115
|
+
testRunner: reader.oneOf("testRunner", testRunners),
|
|
116
|
+
affectedTests: reader.boolean("affectedTests"),
|
|
117
|
+
featureUnification: reader.oneOf("featureUnification", featureUnifications),
|
|
118
|
+
envInputs: reader.strings("envInputs", "the names of environment variables"),
|
|
119
|
+
runtimeInputs: reader.strings("runtimeInputs", "commands"),
|
|
120
|
+
};
|
|
121
|
+
if (problems.length > 0) {
|
|
122
|
+
throw new Error(problems.join("\n"));
|
|
123
|
+
}
|
|
124
|
+
// They name their own problems in the words their checks have used since 0.1.
|
|
125
|
+
read.targetNames = (0, options_1.readTargetNames)(options);
|
|
126
|
+
read.locked = (0, options_1.readLocked)(options);
|
|
127
|
+
return read;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Reads `[workspace.metadata.nx]` of each workspace that discovery found,
|
|
131
|
+
* with its `project` table, and `[package.metadata.nx]` of each member that
|
|
132
|
+
* becomes a project, from the `cargo metadata` reports (`DES-METADATA-REPORT`),
|
|
133
|
+
* and combines them with the plugin options by the precedence of
|
|
134
|
+
* `DES-PLUGIN-OPTIONS`: a crate's value wins over the workspace's, which wins
|
|
135
|
+
* over the plugin options', and tags, `implicitDependencies`, `fileInputs`,
|
|
136
|
+
* `envInputs` and `runtimeInputs` add up.
|
|
137
|
+
*
|
|
138
|
+
* @throws {Error} Naming every manifest with an unknown key, an invalid
|
|
139
|
+
* value, an `implicitDependencies` entry starting with `!`, or a `project`
|
|
140
|
+
* table in a root manifest that defines a crate.
|
|
141
|
+
*/
|
|
142
|
+
// @mara implements DES-METADATA-TABLES
|
|
143
|
+
// @mara implements DES-PLUGIN-OPTIONS
|
|
144
|
+
// @mara implements REQ-METADATA-OVERRIDES
|
|
145
|
+
function readSettings(discovery, options) {
|
|
146
|
+
var _a, _b, _c, _d, _e;
|
|
147
|
+
const problems = [];
|
|
148
|
+
const workspaces = new Map();
|
|
149
|
+
const crates = new Map();
|
|
150
|
+
const workspaceProjects = new Map();
|
|
151
|
+
for (const workspace of discovery.workspaces) {
|
|
152
|
+
const rootManifestPath = (0, node_path_1.join)(workspace.report.workspace_root, "Cargo.toml");
|
|
153
|
+
const rootIsCrate = workspace.report.packages.some((pkg) => pkg.manifest_path === rootManifestPath);
|
|
154
|
+
const table = readWorkspaceTable(workspace, rootIsCrate, problems);
|
|
155
|
+
const settings = {
|
|
156
|
+
rootManifest: workspace.rootManifest,
|
|
157
|
+
locked: options.locked,
|
|
158
|
+
testRunner: (_b = (_a = table.testRunner) !== null && _a !== void 0 ? _a : options.testRunner) !== null && _b !== void 0 ? _b : "cargo",
|
|
159
|
+
affectedTests: (_d = (_c = table.affectedTests) !== null && _c !== void 0 ? _c : options.affectedTests) !== null && _d !== void 0 ? _d : false,
|
|
160
|
+
featureUnification: (_e = table.featureUnification) !== null && _e !== void 0 ? _e : options.featureUnification,
|
|
161
|
+
namePrefix: table.namePrefix,
|
|
162
|
+
tags: table.tags,
|
|
163
|
+
implicitDependencies: table.implicitDependencies,
|
|
164
|
+
envInputs: union(options.envInputs, table.envInputs),
|
|
165
|
+
runtimeInputs: union(options.runtimeInputs, table.runtimeInputs),
|
|
166
|
+
fileInputs: table.fileInputs,
|
|
167
|
+
};
|
|
168
|
+
const runnerProblem = affectedTestsRunnerProblem(workspace.rootManifest, table, options);
|
|
169
|
+
if (runnerProblem !== undefined) {
|
|
170
|
+
problems.push(runnerProblem);
|
|
171
|
+
}
|
|
172
|
+
workspaces.set(workspace, settings);
|
|
173
|
+
for (const pkg of workspace.members) {
|
|
174
|
+
const own = readPackageTable(pkg, discovery.workspaceRoot, problems);
|
|
175
|
+
crates.set(pkg.manifest_path, {
|
|
176
|
+
workspace: settings,
|
|
177
|
+
name: own.name,
|
|
178
|
+
tags: union(settings.tags, own.tags),
|
|
179
|
+
implicitDependencies: union(settings.implicitDependencies, own.implicitDependencies),
|
|
180
|
+
envInputs: union(settings.envInputs, own.envInputs),
|
|
181
|
+
runtimeInputs: union(settings.runtimeInputs, own.runtimeInputs),
|
|
182
|
+
fileInputs: [...settings.fileInputs, ...own.fileInputs],
|
|
183
|
+
artifacts: own.artifacts,
|
|
184
|
+
targets: [...table.targets, ...own.targets],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
workspaceProjects.set(workspace, {
|
|
188
|
+
workspace: settings,
|
|
189
|
+
name: table.project.name,
|
|
190
|
+
tags: union(settings.tags, table.project.tags),
|
|
191
|
+
implicitDependencies: [],
|
|
192
|
+
envInputs: [],
|
|
193
|
+
runtimeInputs: [],
|
|
194
|
+
fileInputs: [],
|
|
195
|
+
targets: table.project.targets,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (problems.length > 0) {
|
|
199
|
+
throw new Error(problems.join("\n"));
|
|
200
|
+
}
|
|
201
|
+
return new GraphSettings(options, workspaces, crates, workspaceProjects);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The error for a workspace that turns on the selection of affected tests
|
|
205
|
+
* without the nextest runner (`REQ-AFFECTED-TESTS`, `DES-DIAGNOSTICS`): it
|
|
206
|
+
* names both options, where each of their values comes from, and what to
|
|
207
|
+
* change. `undefined` where the workspace does not select or uses nextest.
|
|
208
|
+
*/
|
|
209
|
+
// @mara implements REQ-AFFECTED-TESTS
|
|
210
|
+
// @mara implements DES-DIAGNOSTICS
|
|
211
|
+
function affectedTestsRunnerProblem(rootManifest, table, options) {
|
|
212
|
+
var _a, _b, _c, _d;
|
|
213
|
+
const affectedTests = (_b = (_a = table.affectedTests) !== null && _a !== void 0 ? _a : options.affectedTests) !== null && _b !== void 0 ? _b : false;
|
|
214
|
+
const testRunner = (_d = (_c = table.testRunner) !== null && _c !== void 0 ? _c : options.testRunner) !== null && _d !== void 0 ? _d : "cargo";
|
|
215
|
+
if (!affectedTests || testRunner === "nextest") {
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
const from = (key) => table[key] !== undefined
|
|
219
|
+
? `[workspace.metadata.nx] in ${rootManifest}`
|
|
220
|
+
: options[key] !== undefined
|
|
221
|
+
? "the options of the plugin's entry in nx.json"
|
|
222
|
+
: "the default";
|
|
223
|
+
return `${rootManifest}: affectedTests is true (from ${from("affectedTests")}), but testRunner is "${testRunner}" (from ${from("testRunner")}): the selection of affected tests runs only with the nextest runner. Set testRunner = "nextest" under [workspace.metadata.nx] in ${rootManifest}, or in the options of the plugin's entry in nx.json, or remove affectedTests.`;
|
|
224
|
+
}
|
|
225
|
+
const testRunners = ["cargo", "nextest"];
|
|
226
|
+
const featureUnifications = ["hakari", "cargo", "workspace-build"];
|
|
227
|
+
const artifactKinds = ["napi", "wasm"];
|
|
228
|
+
function readWorkspaceTable(workspace, rootIsCrate, problems) {
|
|
229
|
+
const manifest = workspace.rootManifest;
|
|
230
|
+
const value = nxTable(workspace.report.metadata, manifest, "[workspace.metadata]", problems);
|
|
231
|
+
const reader = new TableReader(manifest, "[workspace.metadata.nx]", value, problems);
|
|
232
|
+
reader.unknownKeys("workspace");
|
|
233
|
+
const project = reader.table("project");
|
|
234
|
+
if (project !== undefined && rootIsCrate) {
|
|
235
|
+
problems.push(`${manifest}: [workspace.metadata.nx.project] configures the workspace project, but this root manifest defines a crate, which is the workspace project. Move its settings to [package.metadata.nx] in ${manifest}.`);
|
|
236
|
+
}
|
|
237
|
+
const projectReader = new TableReader(manifest, "[workspace.metadata.nx.project]", project !== null && project !== void 0 ? project : {}, problems);
|
|
238
|
+
projectReader.unknownKeys("project");
|
|
239
|
+
return Object.assign(Object.assign({ testRunner: reader.oneOf("testRunner", testRunners), affectedTests: reader.boolean("affectedTests"), featureUnification: reader.oneOf("featureUnification", featureUnifications), namePrefix: reader.string("namePrefix", { nonEmpty: false }) }, readShared(reader, manifest)), { project: {
|
|
240
|
+
name: projectReader.string("name", { nonEmpty: true }),
|
|
241
|
+
tags: projectReader.strings("tags", "tags"),
|
|
242
|
+
targets: projectReader.targets(),
|
|
243
|
+
} });
|
|
244
|
+
}
|
|
245
|
+
function readPackageTable(pkg, repositoryRoot, problems) {
|
|
246
|
+
const manifest = (0, node_path_1.relative)(repositoryRoot, pkg.manifest_path);
|
|
247
|
+
const value = nxTable(pkg.metadata, manifest, "[package.metadata]", problems);
|
|
248
|
+
const reader = new TableReader(manifest, "[package.metadata.nx]", value, problems);
|
|
249
|
+
reader.unknownKeys("package");
|
|
250
|
+
const artifacts = reader.strings("artifacts", `kinds of artifact, "napi" or "wasm"`);
|
|
251
|
+
const unknownKinds = artifacts.filter((kind) => !artifactKinds.includes(kind));
|
|
252
|
+
if (unknownKinds.length > 0) {
|
|
253
|
+
problems.push(`${manifest}: "artifacts" in [package.metadata.nx] names ${list(unknownKinds.map(quote))}, but the kinds of artifact are "napi" and "wasm"; an empty list means none.`);
|
|
254
|
+
}
|
|
255
|
+
return Object.assign({ name: reader.string("name", { nonEmpty: true }), artifacts: reader.has("artifacts") ? artifacts : undefined }, readShared(reader, manifest));
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The `fileInputs` of a crate that another crate's inputs name by its
|
|
259
|
+
* folder, beside an edge, such as a path dependency without a project: those
|
|
260
|
+
* of its workspace's table and of its own, each with its manifest, as
|
|
261
|
+
* {@link readSettings} reads them for a project (`DES-INPUTS`). Only that key
|
|
262
|
+
* is read.
|
|
263
|
+
*
|
|
264
|
+
* @param report The `cargo metadata` report of the crate's workspace.
|
|
265
|
+
* @param problems Where a value of the wrong type is reported.
|
|
266
|
+
*/
|
|
267
|
+
// @mara implements DES-INPUTS
|
|
268
|
+
function readCrateFileInputs(pkg, report, repositoryRoot, problems) {
|
|
269
|
+
return readCrateTables(pkg, report, repositoryRoot, problems, (reader, manifest) => reader.strings("fileInputs", "glob patterns").map((pattern) => ({ pattern, manifest }))).flat();
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* The variables and commands that a crate adds to its key with `envInputs`
|
|
273
|
+
* and `runtimeInputs` in its workspace's table and in its own, each once, for
|
|
274
|
+
* a crate that another crate's inputs name by its folder in place of an
|
|
275
|
+
* edge, which would have brought them in the crate's named input
|
|
276
|
+
* (`DES-INPUTS`, "Added variables and commands"). Only those keys are read,
|
|
277
|
+
* as {@link readSettings} reads them for a project; the plugin options'
|
|
278
|
+
* additions reach every crate of the entry already.
|
|
279
|
+
*
|
|
280
|
+
* @param report The `cargo metadata` report of the crate's workspace.
|
|
281
|
+
* @param problems Where a value of the wrong type is reported.
|
|
282
|
+
*/
|
|
283
|
+
// @mara implements DES-INPUTS
|
|
284
|
+
function readCrateAddedInputs(pkg, report, repositoryRoot, problems) {
|
|
285
|
+
const tables = readCrateTables(pkg, report, repositoryRoot, problems, (reader) => ({
|
|
286
|
+
envInputs: reader.strings("envInputs", "the names of environment variables"),
|
|
287
|
+
runtimeInputs: reader.strings("runtimeInputs", "commands"),
|
|
288
|
+
}));
|
|
289
|
+
return {
|
|
290
|
+
envInputs: union(...tables.map((table) => table.envInputs)),
|
|
291
|
+
runtimeInputs: union(...tables.map((table) => table.runtimeInputs)),
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
// Reads the workspace table of the crate's workspace and then the crate's
|
|
295
|
+
// own table, each with a reader of `read`.
|
|
296
|
+
function readCrateTables(pkg, report, repositoryRoot, problems, read) {
|
|
297
|
+
const readTable = (metadata, manifestPath, table) => {
|
|
298
|
+
const manifest = (0, node_path_1.relative)(repositoryRoot, manifestPath);
|
|
299
|
+
const parent = table === "[package.metadata.nx]" ? "[package.metadata]" : "[workspace.metadata]";
|
|
300
|
+
const value = nxTable(metadata, manifest, parent, problems);
|
|
301
|
+
return read(new TableReader(manifest, table, value, problems), manifest);
|
|
302
|
+
};
|
|
303
|
+
return [
|
|
304
|
+
readTable(report.metadata, (0, node_path_1.join)(report.workspace_root, "Cargo.toml"), "[workspace.metadata.nx]"),
|
|
305
|
+
readTable(pkg.metadata, pkg.manifest_path, "[package.metadata.nx]"),
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
function readShared(reader, manifest) {
|
|
309
|
+
return {
|
|
310
|
+
tags: reader.strings("tags", "tags"),
|
|
311
|
+
targets: reader.targets(),
|
|
312
|
+
implicitDependencies: reader.implicitDependencies(),
|
|
313
|
+
envInputs: reader.strings("envInputs", "the names of environment variables"),
|
|
314
|
+
runtimeInputs: reader.strings("runtimeInputs", "commands"),
|
|
315
|
+
fileInputs: reader
|
|
316
|
+
.strings("fileInputs", "glob patterns")
|
|
317
|
+
.map((pattern) => ({ pattern, manifest })),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
// The `nx` table inside a `metadata` value of the report, or an empty one.
|
|
321
|
+
function nxTable(metadata, manifest, parent, problems) {
|
|
322
|
+
const value = isTable(metadata) ? metadata.nx : undefined;
|
|
323
|
+
if (value === undefined || value === null) {
|
|
324
|
+
return {};
|
|
325
|
+
}
|
|
326
|
+
if (!isTable(value)) {
|
|
327
|
+
problems.push(`${manifest}: "nx" in ${parent} has to be a table, not ${JSON.stringify(value)}.`);
|
|
328
|
+
return {};
|
|
329
|
+
}
|
|
330
|
+
return value;
|
|
331
|
+
}
|
|
332
|
+
/** Reads the values of one table or of the plugin options, collecting what is wrong. */
|
|
333
|
+
class TableReader {
|
|
334
|
+
constructor(file, label, value, problems) {
|
|
335
|
+
this.file = file;
|
|
336
|
+
this.label = label;
|
|
337
|
+
this.value = value;
|
|
338
|
+
this.problems = problems;
|
|
339
|
+
}
|
|
340
|
+
has(key) {
|
|
341
|
+
return this.value[key] !== undefined;
|
|
342
|
+
}
|
|
343
|
+
/** Reports each key that `place` does not accept. */
|
|
344
|
+
unknownKeys(place) {
|
|
345
|
+
const known = keysOf[place];
|
|
346
|
+
for (const key of Object.keys(this.value)) {
|
|
347
|
+
if (known.includes(key)) {
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
const similar = known.find((candidate) => candidate.toLowerCase() === key.toLowerCase());
|
|
351
|
+
const elsewhere = placesOf[key];
|
|
352
|
+
this.problems.push([
|
|
353
|
+
`${this.file}: nx-rust does not know the key ${quote(key)} in ${this.label}.`,
|
|
354
|
+
similar === undefined ? undefined : `Did you mean ${quote(similar)}?`,
|
|
355
|
+
similar === undefined && key === "affectedTests" && place === "package"
|
|
356
|
+
? `A crate opts out of the selection of affected tests with affectedTests = false under [package.metadata.nx.targets.test.options].`
|
|
357
|
+
: similar === undefined && elsewhere !== undefined
|
|
358
|
+
? `${quote(key)} can be set in ${elsewhere}.`
|
|
359
|
+
: undefined,
|
|
360
|
+
`The keys it knows there are ${list(known.map(quote))}.`,
|
|
361
|
+
]
|
|
362
|
+
.filter((sentence) => sentence !== undefined)
|
|
363
|
+
.join(" "));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
string(key, { nonEmpty }) {
|
|
367
|
+
const value = this.value[key];
|
|
368
|
+
if (value === undefined) {
|
|
369
|
+
return undefined;
|
|
370
|
+
}
|
|
371
|
+
if (typeof value !== "string" || (nonEmpty && value.trim() === "")) {
|
|
372
|
+
this.invalid(key, nonEmpty ? "a string that is not empty" : "a string");
|
|
373
|
+
return undefined;
|
|
374
|
+
}
|
|
375
|
+
return value;
|
|
376
|
+
}
|
|
377
|
+
boolean(key) {
|
|
378
|
+
const value = this.value[key];
|
|
379
|
+
if (value === undefined || typeof value === "boolean") {
|
|
380
|
+
return value;
|
|
381
|
+
}
|
|
382
|
+
this.invalid(key, "true or false");
|
|
383
|
+
return undefined;
|
|
384
|
+
}
|
|
385
|
+
oneOf(key, values) {
|
|
386
|
+
const value = this.value[key];
|
|
387
|
+
if (value === undefined || values.includes(value)) {
|
|
388
|
+
return value;
|
|
389
|
+
}
|
|
390
|
+
this.invalid(key, list(values.map(quote), "or"));
|
|
391
|
+
return undefined;
|
|
392
|
+
}
|
|
393
|
+
/** A list of strings that are not empty; an empty list where the key is not set. */
|
|
394
|
+
strings(key, what) {
|
|
395
|
+
const value = this.value[key];
|
|
396
|
+
if (value === undefined) {
|
|
397
|
+
return [];
|
|
398
|
+
}
|
|
399
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || item === "")) {
|
|
400
|
+
this.invalid(key, `a list of ${what}, each a string that is not empty`);
|
|
401
|
+
return [];
|
|
402
|
+
}
|
|
403
|
+
return value;
|
|
404
|
+
}
|
|
405
|
+
table(key) {
|
|
406
|
+
const value = this.value[key];
|
|
407
|
+
if (value === undefined || isTable(value)) {
|
|
408
|
+
return value;
|
|
409
|
+
}
|
|
410
|
+
this.invalid(key, "a table");
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
413
|
+
/** `implicitDependencies`, which only adds: an entry starting with `!` is an error. */
|
|
414
|
+
implicitDependencies() {
|
|
415
|
+
const entries = this.strings("implicitDependencies", "project names");
|
|
416
|
+
const negated = entries.filter((entry) => entry.startsWith("!"));
|
|
417
|
+
if (negated.length > 0) {
|
|
418
|
+
this.problems.push(`${this.file}: "implicitDependencies" in ${this.label} has ${negated.length === 1 ? "the entry" : "the entries"} ${list(negated.map(quote))}, but the key only adds dependencies, so an entry starting with "!" is an error, whatever it names. Remove ${negated.length === 1 ? "it" : "them"}; nx-rust keeps the edge of every Cargo dependency.`);
|
|
419
|
+
}
|
|
420
|
+
return entries.filter((entry) => !entry.startsWith("!"));
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* The `targets.<name>` tables, each a table shaped like an Nx target whose
|
|
424
|
+
* fields have the types that Nx gives them ({@link targetFieldProblems}).
|
|
425
|
+
* A table with a field of another type is reported and left out.
|
|
426
|
+
*/
|
|
427
|
+
targets() {
|
|
428
|
+
var _a;
|
|
429
|
+
const targets = (_a = this.table("targets")) !== null && _a !== void 0 ? _a : {};
|
|
430
|
+
const tables = [];
|
|
431
|
+
for (const [name, target] of Object.entries(targets)) {
|
|
432
|
+
if (!isTable(target)) {
|
|
433
|
+
this.problems.push(`${this.file}: ${targetHeader(this.label, name)} has to be a table shaped like an Nx target, not ${JSON.stringify(target)}.`);
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
const header = targetHeader(this.label, name);
|
|
437
|
+
const problems = (0, target_fields_1.targetFieldProblems)(target, (field) => `${this.file}: ${quote(field)} in ${header}`);
|
|
438
|
+
if (problems.length > 0) {
|
|
439
|
+
this.problems.push(...problems);
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
tables.push({
|
|
443
|
+
name,
|
|
444
|
+
target: target,
|
|
445
|
+
manifest: this.file,
|
|
446
|
+
table: this.label,
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
return tables;
|
|
450
|
+
}
|
|
451
|
+
invalid(key, expected) {
|
|
452
|
+
this.problems.push(`${this.file}: ${quote(key)} in ${this.label} has to be ${expected}, not ${JSON.stringify(this.value[key])}.`);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
/** The header of a target table in messages, such as `[package.metadata.nx.targets.test]`. */
|
|
456
|
+
function targetHeader(table, target, ...path) {
|
|
457
|
+
return `${table.slice(0, -1)}.targets.${[target, ...path].map(tomlKey).join(".")}]`;
|
|
458
|
+
}
|
|
459
|
+
// A key as TOML writes it in a dotted header: bare where it can be.
|
|
460
|
+
function tomlKey(key) {
|
|
461
|
+
return /^[A-Za-z0-9_-]+$/.test(key) ? key : JSON.stringify(key);
|
|
462
|
+
}
|
|
463
|
+
function isTable(value) {
|
|
464
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
465
|
+
}
|
|
466
|
+
// The values of every list, each once, in the order they first appear.
|
|
467
|
+
function union(...lists) {
|
|
468
|
+
return [...new Set(lists.flat())];
|
|
469
|
+
}
|
|
470
|
+
function quote(value) {
|
|
471
|
+
return JSON.stringify(value);
|
|
472
|
+
}
|
|
473
|
+
// `a`, `a and b`, `a, b and c`
|
|
474
|
+
function list(items, conjunction = "and") {
|
|
475
|
+
return items.length <= 1
|
|
476
|
+
? items.join("")
|
|
477
|
+
: `${items.slice(0, -1).join(", ")} ${conjunction} ${items[items.length - 1]}`;
|
|
478
|
+
}
|
|
479
|
+
//# sourceMappingURL=settings.js.map
|