@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,63 @@
|
|
|
1
|
+
/** A package entry of `Cargo.lock`, a `[[package]]` table, as far as the digest reads it. */
|
|
2
|
+
export interface LockfileEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
/** Where the package comes from; absent for a path package, members included. */
|
|
6
|
+
source?: string;
|
|
7
|
+
/** The checksum of a registry package. */
|
|
8
|
+
checksum?: string;
|
|
9
|
+
/** The entry that `[replace]` puts in this one's place, as the lockfile names it. */
|
|
10
|
+
replace?: string;
|
|
11
|
+
/** The entries this one depends on, as the lockfile writes them: `name`, `name version` or `name version (source)`. */
|
|
12
|
+
dependencies: string[];
|
|
13
|
+
}
|
|
14
|
+
/** A package by the name and version that its manifest gives it. */
|
|
15
|
+
export interface PackageVersion {
|
|
16
|
+
name: string;
|
|
17
|
+
version: string;
|
|
18
|
+
}
|
|
19
|
+
/** The package entries of a `Cargo.lock`, without `[[patch.unused]]`. */
|
|
20
|
+
export interface Lockfile {
|
|
21
|
+
entries: LockfileEntry[];
|
|
22
|
+
}
|
|
23
|
+
/** A `Cargo.lock` that the digest cannot read, or a package that it does not lock. */
|
|
24
|
+
export declare class LockfileError extends Error {
|
|
25
|
+
constructor(message: string);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reads the package entries of a `Cargo.lock`: the `[[package]]` tables,
|
|
29
|
+
* not the `[[patch.unused]]` ones. A lockfile of the first format keeps the
|
|
30
|
+
* checksums in its `[metadata]` table, under keys such as
|
|
31
|
+
* `checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)`;
|
|
32
|
+
* they are read as the entries' own.
|
|
33
|
+
*
|
|
34
|
+
* @throws {LockfileError} When the text is no TOML or an entry lacks its name or version.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseLockfile(text: string): Lockfile;
|
|
37
|
+
/**
|
|
38
|
+
* The digest of a member's external dependencies (`DES-LOCKFILE-HASHING`,
|
|
39
|
+
* "Digest"): a SHA-256, in hexadecimal, over the entries that the member's
|
|
40
|
+
* entry reaches in the lockfile's graph.
|
|
41
|
+
*
|
|
42
|
+
* The walk starts at the entry without a source that has the member's name
|
|
43
|
+
* and version, takes every dependency that an entry lists, passes through
|
|
44
|
+
* path packages and follows `replace = …` to the entry it names. Each
|
|
45
|
+
* reachable entry gives one line: its name, version, source, checksum and
|
|
46
|
+
* `replace` value, then its dependency strings as the lockfile writes them,
|
|
47
|
+
* in byte order, all joined by tab characters, with an empty field for a
|
|
48
|
+
* value the entry lacks. The digest is the SHA-256 of these lines in byte
|
|
49
|
+
* order, each ended by a line feed, in UTF-8.
|
|
50
|
+
*
|
|
51
|
+
* @throws {LockfileError} When the lockfile has no entry for the member, or
|
|
52
|
+
* a dependency string or `replace` value names no entry or several.
|
|
53
|
+
*/
|
|
54
|
+
export declare function memberDigest(lockfile: Lockfile, member: PackageVersion): string;
|
|
55
|
+
/**
|
|
56
|
+
* The entries that a member's entry reaches in the lockfile's graph, its own
|
|
57
|
+
* first: the walk of {@link memberDigest}, which takes every dependency that
|
|
58
|
+
* an entry lists, whatever its platform or the features that bring it,
|
|
59
|
+
* passes through path packages and follows `replace = …`.
|
|
60
|
+
*
|
|
61
|
+
* @throws {LockfileError} As {@link memberDigest} does.
|
|
62
|
+
*/
|
|
63
|
+
export declare function reachedEntries(lockfile: Lockfile, member: PackageVersion): LockfileEntry[];
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LockfileError = void 0;
|
|
4
|
+
exports.parseLockfile = parseLockfile;
|
|
5
|
+
exports.memberDigest = memberDigest;
|
|
6
|
+
exports.reachedEntries = reachedEntries;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
const smol_toml_1 = require("smol-toml");
|
|
9
|
+
/** A `Cargo.lock` that the digest cannot read, or a package that it does not lock. */
|
|
10
|
+
class LockfileError extends Error {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "LockfileError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.LockfileError = LockfileError;
|
|
17
|
+
/**
|
|
18
|
+
* Reads the package entries of a `Cargo.lock`: the `[[package]]` tables,
|
|
19
|
+
* not the `[[patch.unused]]` ones. A lockfile of the first format keeps the
|
|
20
|
+
* checksums in its `[metadata]` table, under keys such as
|
|
21
|
+
* `checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)`;
|
|
22
|
+
* they are read as the entries' own.
|
|
23
|
+
*
|
|
24
|
+
* @throws {LockfileError} When the text is no TOML or an entry lacks its name or version.
|
|
25
|
+
*/
|
|
26
|
+
function parseLockfile(text) {
|
|
27
|
+
let document;
|
|
28
|
+
try {
|
|
29
|
+
document = (0, smol_toml_1.parse)(text);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw new LockfileError(`it is no valid TOML: ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
const packages = Array.isArray(document.package) ? document.package : [];
|
|
35
|
+
const metadata = isRecord(document.metadata) ? document.metadata : {};
|
|
36
|
+
const entries = packages.map((value, index) => {
|
|
37
|
+
const table = isRecord(value) ? value : {};
|
|
38
|
+
const name = table.name;
|
|
39
|
+
const version = table.version;
|
|
40
|
+
if (typeof name !== "string" || typeof version !== "string") {
|
|
41
|
+
throw new LockfileError(`its package entry number ${index + 1} has no name or no version`);
|
|
42
|
+
}
|
|
43
|
+
const source = typeof table.source === "string" ? table.source : undefined;
|
|
44
|
+
const ownChecksum = typeof table.checksum === "string" ? table.checksum : undefined;
|
|
45
|
+
const listedChecksum = source === undefined ? undefined : metadata[`checksum ${name} ${version} (${source})`];
|
|
46
|
+
const checksum = ownChecksum !== null && ownChecksum !== void 0 ? ownChecksum : (typeof listedChecksum === "string" ? listedChecksum : undefined);
|
|
47
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({ name,
|
|
48
|
+
version }, (source === undefined ? {} : { source })), (checksum === undefined ? {} : { checksum })), (typeof table.replace === "string" ? { replace: table.replace } : {})), { dependencies: Array.isArray(table.dependencies)
|
|
49
|
+
? table.dependencies.filter((dependency) => typeof dependency === "string")
|
|
50
|
+
: [] });
|
|
51
|
+
});
|
|
52
|
+
return { entries };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The digest of a member's external dependencies (`DES-LOCKFILE-HASHING`,
|
|
56
|
+
* "Digest"): a SHA-256, in hexadecimal, over the entries that the member's
|
|
57
|
+
* entry reaches in the lockfile's graph.
|
|
58
|
+
*
|
|
59
|
+
* The walk starts at the entry without a source that has the member's name
|
|
60
|
+
* and version, takes every dependency that an entry lists, passes through
|
|
61
|
+
* path packages and follows `replace = …` to the entry it names. Each
|
|
62
|
+
* reachable entry gives one line: its name, version, source, checksum and
|
|
63
|
+
* `replace` value, then its dependency strings as the lockfile writes them,
|
|
64
|
+
* in byte order, all joined by tab characters, with an empty field for a
|
|
65
|
+
* value the entry lacks. The digest is the SHA-256 of these lines in byte
|
|
66
|
+
* order, each ended by a line feed, in UTF-8.
|
|
67
|
+
*
|
|
68
|
+
* @throws {LockfileError} When the lockfile has no entry for the member, or
|
|
69
|
+
* a dependency string or `replace` value names no entry or several.
|
|
70
|
+
*/
|
|
71
|
+
// @mara implements DES-LOCKFILE-HASHING
|
|
72
|
+
function memberDigest(lockfile, member) {
|
|
73
|
+
const reached = reachedEntries(lockfile, member);
|
|
74
|
+
const lines = [...reached].map((entry) => {
|
|
75
|
+
var _a, _b, _c;
|
|
76
|
+
return [
|
|
77
|
+
entry.name,
|
|
78
|
+
entry.version,
|
|
79
|
+
(_a = entry.source) !== null && _a !== void 0 ? _a : "",
|
|
80
|
+
(_b = entry.checksum) !== null && _b !== void 0 ? _b : "",
|
|
81
|
+
(_c = entry.replace) !== null && _c !== void 0 ? _c : "",
|
|
82
|
+
...sortedBytewise(entry.dependencies),
|
|
83
|
+
].join("\t");
|
|
84
|
+
});
|
|
85
|
+
const hash = (0, node_crypto_1.createHash)("sha256");
|
|
86
|
+
for (const line of sortedBytewise(lines)) {
|
|
87
|
+
hash.update(`${line}\n`, "utf8");
|
|
88
|
+
}
|
|
89
|
+
return hash.digest("hex");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The entries that a member's entry reaches in the lockfile's graph, its own
|
|
93
|
+
* first: the walk of {@link memberDigest}, which takes every dependency that
|
|
94
|
+
* an entry lists, whatever its platform or the features that bring it,
|
|
95
|
+
* passes through path packages and follows `replace = …`.
|
|
96
|
+
*
|
|
97
|
+
* @throws {LockfileError} As {@link memberDigest} does.
|
|
98
|
+
*/
|
|
99
|
+
function reachedEntries(lockfile, member) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
const byName = new Map();
|
|
102
|
+
for (const entry of lockfile.entries) {
|
|
103
|
+
byName.set(entry.name, [...((_a = byName.get(entry.name)) !== null && _a !== void 0 ? _a : []), entry]);
|
|
104
|
+
}
|
|
105
|
+
const start = ((_b = byName.get(member.name)) !== null && _b !== void 0 ? _b : []).find((entry) => entry.version === member.version && entry.source === undefined);
|
|
106
|
+
if (start === undefined) {
|
|
107
|
+
throw new LockfileError(`it has no entry for the package ${member.name} ${member.version}`);
|
|
108
|
+
}
|
|
109
|
+
const reached = new Set([start]);
|
|
110
|
+
const queue = [start];
|
|
111
|
+
while (queue.length > 0) {
|
|
112
|
+
const entry = queue.shift();
|
|
113
|
+
const references = [
|
|
114
|
+
...entry.dependencies,
|
|
115
|
+
...(entry.replace === undefined ? [] : [entry.replace]),
|
|
116
|
+
];
|
|
117
|
+
for (const reference of references) {
|
|
118
|
+
const target = resolveReference(byName, reference, entry);
|
|
119
|
+
if (!reached.has(target)) {
|
|
120
|
+
reached.add(target);
|
|
121
|
+
queue.push(target);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return [...reached];
|
|
126
|
+
}
|
|
127
|
+
// The entry that a dependency string or `replace` value of `from` names. A
|
|
128
|
+
// reference without a source that two entries share by name and version
|
|
129
|
+
// means the entry without a source, as cargo writes a path package.
|
|
130
|
+
function resolveReference(byName, reference, from) {
|
|
131
|
+
var _a;
|
|
132
|
+
const match = /^(\S+)(?: (\S+))?(?: \((.+)\))?$/.exec(reference);
|
|
133
|
+
if (match === null) {
|
|
134
|
+
throw new LockfileError(`the entry ${from.name} ${from.version} names "${reference}", which is no package reference`);
|
|
135
|
+
}
|
|
136
|
+
const [, name, version, source] = match;
|
|
137
|
+
let candidates = ((_a = byName.get(name)) !== null && _a !== void 0 ? _a : []).filter((entry) => (version === undefined || entry.version === version) &&
|
|
138
|
+
(source === undefined || entry.source === source));
|
|
139
|
+
if (candidates.length > 1 && version !== undefined && source === undefined) {
|
|
140
|
+
candidates = candidates.filter((entry) => entry.source === undefined);
|
|
141
|
+
}
|
|
142
|
+
if (candidates.length !== 1) {
|
|
143
|
+
throw new LockfileError(`the entry ${from.name} ${from.version} names "${reference}", which ${candidates.length === 0 ? "matches no entry" : "matches several entries"}`);
|
|
144
|
+
}
|
|
145
|
+
return candidates[0];
|
|
146
|
+
}
|
|
147
|
+
// The strings sorted by their UTF-8 bytes.
|
|
148
|
+
function sortedBytewise(strings) {
|
|
149
|
+
return strings
|
|
150
|
+
.map((string) => ({ string, bytes: Buffer.from(string, "utf8") }))
|
|
151
|
+
.sort((a, b) => Buffer.compare(a.bytes, b.bytes))
|
|
152
|
+
.map(({ string }) => string);
|
|
153
|
+
}
|
|
154
|
+
function isRecord(value) {
|
|
155
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=lockfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lockfile.js","sourceRoot":"","sources":["../../../../nx-rust/src/cargo/lockfile.ts"],"names":[],"mappings":";;;AA6CA,sCAoCC;AAoBD,oCAiBC;AAUD,wCA4BC;AA5JD,6CAAyC;AACzC,yCAAkC;AA2BlC,sFAAsF;AACtF,MAAa,aAAc,S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AI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;SACjE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAChD,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The report of `cargo metadata --format-version 1 --no-deps`, as far as the
|
|
3
|
+
* plugin reads it. Paths are absolute. Cargo describes the format in
|
|
4
|
+
* https://doc.rust-lang.org/cargo/commands/cargo-metadata.html#json-format.
|
|
5
|
+
*/
|
|
6
|
+
export interface CargoMetadata {
|
|
7
|
+
/** The members of the workspace, which are all its packages without dependency resolution. */
|
|
8
|
+
packages: CargoPackage[];
|
|
9
|
+
/** The ids of the members. */
|
|
10
|
+
workspace_members: string[];
|
|
11
|
+
/** The folder of the workspace's root manifest. */
|
|
12
|
+
workspace_root: string;
|
|
13
|
+
/** Cargo's artifact directory. */
|
|
14
|
+
target_directory: string;
|
|
15
|
+
/** Cargo's build directory, reported by recent versions of Cargo. */
|
|
16
|
+
build_directory?: string;
|
|
17
|
+
/** `[workspace.metadata]`, or `null`. */
|
|
18
|
+
metadata: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** A package in a {@link CargoMetadata} report. */
|
|
21
|
+
export interface CargoPackage {
|
|
22
|
+
/** Cargo's package id, which `workspace_members` refers to. */
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
/** The package's version, such as `0.1.0`. */
|
|
26
|
+
version: string;
|
|
27
|
+
/** The path of the package's `Cargo.toml`. */
|
|
28
|
+
manifest_path: string;
|
|
29
|
+
/** The dependencies as the manifest declares them, unresolved. */
|
|
30
|
+
dependencies: CargoDependency[];
|
|
31
|
+
/** The package's Cargo targets: its library, binaries, examples, tests, benches and build script. */
|
|
32
|
+
targets: CargoTarget[];
|
|
33
|
+
/**
|
|
34
|
+
* The package's features, each with what it turns on: other features of
|
|
35
|
+
* the package, `dep:<name>` and `<dependency>/<feature>` entries. Cargo
|
|
36
|
+
* lists the implicit feature of an optional dependency too.
|
|
37
|
+
*/
|
|
38
|
+
features?: Record<string, string[]>;
|
|
39
|
+
/** `[package.metadata]`, or `null`. */
|
|
40
|
+
metadata: unknown;
|
|
41
|
+
/**
|
|
42
|
+
* The registries that the package may be published to, from its `publish`
|
|
43
|
+
* key: `null` without the key, `[]` for `publish = false` and for a crate
|
|
44
|
+
* without a version.
|
|
45
|
+
*/
|
|
46
|
+
publish?: string[] | null;
|
|
47
|
+
}
|
|
48
|
+
/** A Cargo target of a {@link CargoPackage}. */
|
|
49
|
+
export interface CargoTarget {
|
|
50
|
+
name: string;
|
|
51
|
+
/**
|
|
52
|
+
* What the target is: `bin`, `example`, `test`, `bench` or `custom-build`,
|
|
53
|
+
* or the crate types of a library, such as `lib`, `rlib` or `cdylib`.
|
|
54
|
+
*/
|
|
55
|
+
kind: string[];
|
|
56
|
+
/** The features that cargo needs on to build the target, from its `required-features`. */
|
|
57
|
+
"required-features"?: string[];
|
|
58
|
+
/**
|
|
59
|
+
* Whether `cargo test` builds and runs the target, from its `test` flag:
|
|
60
|
+
* on by default for libraries, binaries and tests, off for examples and
|
|
61
|
+
* benches. Cargo 1.91 and later report it for every target.
|
|
62
|
+
*/
|
|
63
|
+
test?: boolean;
|
|
64
|
+
/** The absolute path of the target's root source file, which cargo always reports. */
|
|
65
|
+
src_path?: string;
|
|
66
|
+
}
|
|
67
|
+
/** A declared dependency of a {@link CargoPackage}. */
|
|
68
|
+
export interface CargoDependency {
|
|
69
|
+
/** The name of the package depended on. */
|
|
70
|
+
name: string;
|
|
71
|
+
/** `null` for a normal dependency. */
|
|
72
|
+
kind: "dev" | "build" | null;
|
|
73
|
+
/** The version requirement as Cargo writes it, such as `^0.1`; `*` where none is given. */
|
|
74
|
+
req: string;
|
|
75
|
+
/**
|
|
76
|
+
* Where the dependency comes from, such as
|
|
77
|
+
* `registry+https://github.com/rust-lang/crates.io-index` or
|
|
78
|
+
* `git+https://example.com/repo.git?branch=main`; `null` for a path dependency.
|
|
79
|
+
*/
|
|
80
|
+
source: string | null;
|
|
81
|
+
/** The folder of a path dependency; absent for any other dependency. */
|
|
82
|
+
path?: string;
|
|
83
|
+
/** Whether the dependency is optional, so that a feature turns it on. */
|
|
84
|
+
optional?: boolean;
|
|
85
|
+
/** Whether the entry keeps the dependency's default features. */
|
|
86
|
+
uses_default_features?: boolean;
|
|
87
|
+
/** The features that the entry turns on in the dependency. */
|
|
88
|
+
features?: string[];
|
|
89
|
+
/** The name under which the manifest lists the dependency, where it renames it. */
|
|
90
|
+
rename?: string | null;
|
|
91
|
+
/** The platform that the dependency is limited to, such as `cfg(windows)`; `null` for none. */
|
|
92
|
+
target?: string | null;
|
|
93
|
+
/**
|
|
94
|
+
* The index URL of the registry that the entry names with `registry`,
|
|
95
|
+
* crates.io's for `registry = "crates-io"`, and `null` for an entry
|
|
96
|
+
* without the key, also where the entry inherits it from
|
|
97
|
+
* `[workspace.dependencies]` (`EVD-CARGO-PUBLISH-REGISTRIES`).
|
|
98
|
+
*/
|
|
99
|
+
registry?: string | null;
|
|
100
|
+
}
|
|
101
|
+
/** The arguments after `cargo` that request the report for `manifest`. */
|
|
102
|
+
export declare function metadataArguments(manifest: string): string[];
|
|
103
|
+
/**
|
|
104
|
+
* Requests the report of the workspace that `manifest` belongs to. With
|
|
105
|
+
* `--no-deps`, Cargo needs no network and neither creates nor changes
|
|
106
|
+
* `Cargo.lock`.
|
|
107
|
+
*
|
|
108
|
+
* @param manifest The absolute path of a `Cargo.toml`.
|
|
109
|
+
* @param cwd The folder cargo starts in.
|
|
110
|
+
* @throws {CargoError} When cargo cannot be started or fails.
|
|
111
|
+
* @throws {SyntaxError} When cargo's output is no report.
|
|
112
|
+
* @throws {UnsupportedCargoError} When the report comes from a Cargo older than 1.91.
|
|
113
|
+
*/
|
|
114
|
+
export declare function requestMetadata(manifest: string, cwd: string): Promise<CargoMetadata>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.metadataArguments = metadataArguments;
|
|
4
|
+
exports.requestMetadata = requestMetadata;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const cargo_version_1 = require("../compatibility/cargo-version");
|
|
7
|
+
const run_cargo_1 = require("./run-cargo");
|
|
8
|
+
/** The arguments after `cargo` that request the report for `manifest`. */
|
|
9
|
+
function metadataArguments(manifest) {
|
|
10
|
+
return ["metadata", "--format-version", "1", "--no-deps", "--manifest-path", manifest];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Requests the report of the workspace that `manifest` belongs to. With
|
|
14
|
+
* `--no-deps`, Cargo needs no network and neither creates nor changes
|
|
15
|
+
* `Cargo.lock`.
|
|
16
|
+
*
|
|
17
|
+
* @param manifest The absolute path of a `Cargo.toml`.
|
|
18
|
+
* @param cwd The folder cargo starts in.
|
|
19
|
+
* @throws {CargoError} When cargo cannot be started or fails.
|
|
20
|
+
* @throws {SyntaxError} When cargo's output is no report.
|
|
21
|
+
* @throws {UnsupportedCargoError} When the report comes from a Cargo older than 1.91.
|
|
22
|
+
*/
|
|
23
|
+
// @mara implements DES-METADATA-REPORT
|
|
24
|
+
function requestMetadata(manifest, cwd) {
|
|
25
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const output = yield (0, run_cargo_1.runCargoForGraph)(metadataArguments(manifest), cwd);
|
|
27
|
+
const report = JSON.parse(output);
|
|
28
|
+
if (typeof (report === null || report === void 0 ? void 0 : report.workspace_root) !== "string" ||
|
|
29
|
+
!Array.isArray(report.packages) ||
|
|
30
|
+
!Array.isArray(report.workspace_members)) {
|
|
31
|
+
throw new SyntaxError("the output has no workspace_root, packages or workspace_members");
|
|
32
|
+
}
|
|
33
|
+
yield (0, cargo_version_1.checkCargoReport)(report, cwd);
|
|
34
|
+
return report;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../../nx-rust/src/cargo/metadata.ts"],"names":[],"mappings":";;AA4GA,8CAEC;AAcD,0CAYC;;AAxID,kEAAkE;AAClE,2CAA+C;AA0G/C,0EAA0E;AAC1E,SAAgB,iBAAiB,CAAC,QAAgB;IAChD,OAAO,CAAC,UAAU,EAAE,kBAAkB,EAAE,GAAG,EAAE,WAAW,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AACzF,CAAC;AAED;;;;;;;;;;GAUG;AACH,uCAAuC;AACvC,SAAsB,eAAe,CAAC,QAAgB,EAAE,GAAW;;QACjE,MAAM,MAAM,GAAG,MAAM,IAAA,4BAAgB,EAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;QACxE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAkB,CAAC;QACnD,IACE,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAA,KAAK,QAAQ;YAC1C,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC/B,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,EACxC,CAAC;YACD,MAAM,IAAI,WAAW,CAAC,iEAAiE,CAAC,CAAC;QAC3F,CAAC;QACD,MAAM,IAAA,gCAAgB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CargoMetadata, CargoPackage } from "./metadata";
|
|
2
|
+
/** Cargo could not report the members of a workspace, such as with their package ID specifications. */
|
|
3
|
+
export declare class PackageSpecReportError extends Error {
|
|
4
|
+
/** What cargo wrote to standard error. */
|
|
5
|
+
readonly stderr: string;
|
|
6
|
+
constructor(message: string,
|
|
7
|
+
/** What cargo wrote to standard error. */
|
|
8
|
+
stderr: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The package ID specification of each member of the Cargo workspace whose
|
|
12
|
+
* root folder is `workspaceRoot`, by package name, as cargo gives it to a
|
|
13
|
+
* command that starts there with `env` (`DES-INVOCATION`): the `id` of the
|
|
14
|
+
* member in the `cargo metadata --format-version 1 --no-deps` report, which
|
|
15
|
+
* is what `cargo pkgid` prints for the member's manifest, such as
|
|
16
|
+
* `path+file:///repo/rust/crates/core#core-lib@0.1.0`.
|
|
17
|
+
*
|
|
18
|
+
* The report lists the members only, whose package names cargo keeps
|
|
19
|
+
* distinct, so the name identifies the entry. Cargo starts in the folder
|
|
20
|
+
* without `--manifest-path`, as the task's own command does: the
|
|
21
|
+
* specification holds the path through which cargo reached the workspace,
|
|
22
|
+
* and a specification asked through another path, such as a symbolic link,
|
|
23
|
+
* matches no package there (`EVD-CARGO-PACKAGE-SPECS`). With `--no-deps`
|
|
24
|
+
* cargo needs no network and neither needs nor writes `Cargo.lock`, which
|
|
25
|
+
* `cargo pkgid` needs.
|
|
26
|
+
*
|
|
27
|
+
* @param env The whole environment of the task's command, also where rustup
|
|
28
|
+
* may install a toolchain for it, as for the command itself.
|
|
29
|
+
* @throws {PackageSpecReportError} When cargo cannot be started, fails or
|
|
30
|
+
* prints no report.
|
|
31
|
+
*/
|
|
32
|
+
export declare function memberSpecs(workspaceRoot: string, env: NodeJS.ProcessEnv): Map<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* The members of the Cargo workspace whose root folder is `workspaceRoot`,
|
|
35
|
+
* by package name, from the same report as {@link memberSpecs}: each with
|
|
36
|
+
* its `id`, the package ID specification, and the targets, features and
|
|
37
|
+
* dependencies that the report lists. A group of several crates reads from
|
|
38
|
+
* it which of each crate's targets its cargo command builds (`DES-BATCH`).
|
|
39
|
+
*
|
|
40
|
+
* @throws {PackageSpecReportError} When cargo cannot be started, fails or
|
|
41
|
+
* prints no report.
|
|
42
|
+
*/
|
|
43
|
+
export declare function memberPackages(workspaceRoot: string, env: NodeJS.ProcessEnv): Map<string, CargoPackage>;
|
|
44
|
+
/**
|
|
45
|
+
* The `cargo metadata --format-version 1 --no-deps` report of the Cargo
|
|
46
|
+
* workspace whose root folder is `workspaceRoot`, from a cargo started in
|
|
47
|
+
* that folder with `env`, as a task's own command starts there
|
|
48
|
+
* (`DES-INVOCATION`). With `--no-deps` cargo needs no network and neither
|
|
49
|
+
* needs nor writes `Cargo.lock`.
|
|
50
|
+
*
|
|
51
|
+
* @throws {PackageSpecReportError} When cargo cannot be started, fails or
|
|
52
|
+
* prints no report with packages.
|
|
53
|
+
*/
|
|
54
|
+
export declare function workspaceReport(workspaceRoot: string, env: NodeJS.ProcessEnv): CargoMetadata;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PackageSpecReportError = void 0;
|
|
4
|
+
exports.memberSpecs = memberSpecs;
|
|
5
|
+
exports.memberPackages = memberPackages;
|
|
6
|
+
exports.workspaceReport = workspaceReport;
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
/** Cargo could not report the members of a workspace, such as with their package ID specifications. */
|
|
9
|
+
class PackageSpecReportError extends Error {
|
|
10
|
+
constructor(message,
|
|
11
|
+
/** What cargo wrote to standard error. */
|
|
12
|
+
stderr) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.stderr = stderr;
|
|
15
|
+
this.name = "PackageSpecReportError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.PackageSpecReportError = PackageSpecReportError;
|
|
19
|
+
/**
|
|
20
|
+
* The package ID specification of each member of the Cargo workspace whose
|
|
21
|
+
* root folder is `workspaceRoot`, by package name, as cargo gives it to a
|
|
22
|
+
* command that starts there with `env` (`DES-INVOCATION`): the `id` of the
|
|
23
|
+
* member in the `cargo metadata --format-version 1 --no-deps` report, which
|
|
24
|
+
* is what `cargo pkgid` prints for the member's manifest, such as
|
|
25
|
+
* `path+file:///repo/rust/crates/core#core-lib@0.1.0`.
|
|
26
|
+
*
|
|
27
|
+
* The report lists the members only, whose package names cargo keeps
|
|
28
|
+
* distinct, so the name identifies the entry. Cargo starts in the folder
|
|
29
|
+
* without `--manifest-path`, as the task's own command does: the
|
|
30
|
+
* specification holds the path through which cargo reached the workspace,
|
|
31
|
+
* and a specification asked through another path, such as a symbolic link,
|
|
32
|
+
* matches no package there (`EVD-CARGO-PACKAGE-SPECS`). With `--no-deps`
|
|
33
|
+
* cargo needs no network and neither needs nor writes `Cargo.lock`, which
|
|
34
|
+
* `cargo pkgid` needs.
|
|
35
|
+
*
|
|
36
|
+
* @param env The whole environment of the task's command, also where rustup
|
|
37
|
+
* may install a toolchain for it, as for the command itself.
|
|
38
|
+
* @throws {PackageSpecReportError} When cargo cannot be started, fails or
|
|
39
|
+
* prints no report.
|
|
40
|
+
*/
|
|
41
|
+
// @mara implements DES-INVOCATION
|
|
42
|
+
function memberSpecs(workspaceRoot, env) {
|
|
43
|
+
const specs = new Map();
|
|
44
|
+
for (const pkg of workspaceReport(workspaceRoot, env).packages) {
|
|
45
|
+
if (typeof (pkg === null || pkg === void 0 ? void 0 : pkg.name) === "string" && typeof pkg.id === "string") {
|
|
46
|
+
specs.set(pkg.name, pkg.id);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return specs;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The members of the Cargo workspace whose root folder is `workspaceRoot`,
|
|
53
|
+
* by package name, from the same report as {@link memberSpecs}: each with
|
|
54
|
+
* its `id`, the package ID specification, and the targets, features and
|
|
55
|
+
* dependencies that the report lists. A group of several crates reads from
|
|
56
|
+
* it which of each crate's targets its cargo command builds (`DES-BATCH`).
|
|
57
|
+
*
|
|
58
|
+
* @throws {PackageSpecReportError} When cargo cannot be started, fails or
|
|
59
|
+
* prints no report.
|
|
60
|
+
*/
|
|
61
|
+
// @mara implements DES-INVOCATION
|
|
62
|
+
function memberPackages(workspaceRoot, env) {
|
|
63
|
+
const members = new Map();
|
|
64
|
+
for (const pkg of workspaceReport(workspaceRoot, env).packages) {
|
|
65
|
+
if (typeof (pkg === null || pkg === void 0 ? void 0 : pkg.name) === "string" && typeof pkg.id === "string") {
|
|
66
|
+
members.set(pkg.name, pkg);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return members;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The `cargo metadata --format-version 1 --no-deps` report of the Cargo
|
|
73
|
+
* workspace whose root folder is `workspaceRoot`, from a cargo started in
|
|
74
|
+
* that folder with `env`, as a task's own command starts there
|
|
75
|
+
* (`DES-INVOCATION`). With `--no-deps` cargo needs no network and neither
|
|
76
|
+
* needs nor writes `Cargo.lock`.
|
|
77
|
+
*
|
|
78
|
+
* @throws {PackageSpecReportError} When cargo cannot be started, fails or
|
|
79
|
+
* prints no report with packages.
|
|
80
|
+
*/
|
|
81
|
+
function workspaceReport(workspaceRoot, env) {
|
|
82
|
+
const run = (0, node_child_process_1.spawnSync)("cargo", ["metadata", "--format-version", "1", "--no-deps"], {
|
|
83
|
+
cwd: workspaceRoot,
|
|
84
|
+
env,
|
|
85
|
+
encoding: "utf8",
|
|
86
|
+
// The report lists every member with its targets and dependencies.
|
|
87
|
+
maxBuffer: 1024 * 1024 * 1024,
|
|
88
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
89
|
+
});
|
|
90
|
+
if (run.error !== undefined) {
|
|
91
|
+
const code = run.error.code;
|
|
92
|
+
throw new PackageSpecReportError(code === "ENOENT" ? `cargo was not found on PATH (${run.error.message})` : run.error.message, "");
|
|
93
|
+
}
|
|
94
|
+
if (run.status !== 0) {
|
|
95
|
+
throw new PackageSpecReportError(run.signal ? `cargo was stopped by ${run.signal}` : `cargo exited with status ${run.status}`, run.stderr);
|
|
96
|
+
}
|
|
97
|
+
let report;
|
|
98
|
+
try {
|
|
99
|
+
report = JSON.parse(run.stdout);
|
|
100
|
+
}
|
|
101
|
+
catch (_a) {
|
|
102
|
+
report = {};
|
|
103
|
+
}
|
|
104
|
+
if (!Array.isArray(report === null || report === void 0 ? void 0 : report.packages)) {
|
|
105
|
+
throw new PackageSpecReportError("cargo printed no report with packages", run.stderr);
|
|
106
|
+
}
|
|
107
|
+
return report;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=package-specs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-specs.js","sourceRoot":"","sources":["../../../../nx-rust/src/cargo/package-specs.ts"],"names":[],"mappings":";;;AAsCA,kCAQC;AAaD,wCAWC;AAYD,0CAgCC;AAlHD,2DAA+C;AAG/C,uGAAuG;AACvG,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YACE,OAAe;IACf,0CAA0C;IACjC,MAAc;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,WAAM,GAAN,MAAM,CAAQ;QAGvB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AATD,wDASC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,kCAAkC;AAClC,SAAgB,WAAW,CAAC,aAAqB,EAAE,GAAsB;IACvE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,KAAK,MAAM,GAAG,IAAI,eAAe,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC/D,I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AAI,GAAG,CAAC,KAA+B,CAAC,IAAI,CAAC;QACvD,MAAM,IAAI,sBAAsB,CAC9B,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,gCAAgC,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAC5F,EAAE,CACH,CAAC;IACJ,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,sBAAsB,CAC9B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,wBAAwB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,4BAA4B,GAAG,CAAC,MAAM,EAAE,EAC5F,GAAG,CAAC,MAAM,CACX,CAAC;IACJ,CAAC;IACD,IAAI,MAA8B,CAAC;IACnC,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAA2B,CAAC;IAC5D,CAAC;IAAC,WAAM,CAAC;QACP,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,sBAAsB,CAAC,uCAAuC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,MAAuB,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The folders that hold the crates which cargo finds below the folder of a
|
|
3
|
+
* `paths` entry, walked as cargo walks it (`EVD-CARGO-REDIRECTIONS`), by
|
|
4
|
+
* their real paths, in the order of the walk: the folder first, each folder
|
|
5
|
+
* before what lies in it, and the entries of a folder sorted by name.
|
|
6
|
+
*
|
|
7
|
+
* As cargo does, the walk goes to any depth, follows a symbolic link given
|
|
8
|
+
* as `folder` but none below it, and takes every folder that holds a
|
|
9
|
+
* `Cargo.toml`, going on below it: under a crate and under a nested
|
|
10
|
+
* workspace alike. Below `folder` itself it skips the folders whose names
|
|
11
|
+
* start with `.` and those that hold `.git`, and at every level a folder
|
|
12
|
+
* named `target` beside a `Cargo.toml`. A folder it cannot read is skipped,
|
|
13
|
+
* as cargo skips it. It skips nothing else, so it also enters
|
|
14
|
+
* `node_modules` and Cargo's artifact and build directories, where cargo
|
|
15
|
+
* finds crates as well.
|
|
16
|
+
*
|
|
17
|
+
* It also takes a folder whose manifest is a virtual one or one that cargo
|
|
18
|
+
* cannot parse, and every crate of a name that two crates share, where cargo
|
|
19
|
+
* takes one: each such folder only adds a crate that cargo may use
|
|
20
|
+
* (`DES-METADATA-REPORT`). The path dependencies that cargo also takes from
|
|
21
|
+
* each crate it finds are not walked here (`pathsCandidates` in
|
|
22
|
+
* `discovery.ts`).
|
|
23
|
+
*
|
|
24
|
+
* @param folder The folder of the entry, an absolute path.
|
|
25
|
+
* @returns No folder where `folder` does not exist.
|
|
26
|
+
*/
|
|
27
|
+
export declare function cratesBelowPathsFolder(folder: string): string[];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cratesBelowPathsFolder = cratesBelowPathsFolder;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
/**
|
|
7
|
+
* The folders that hold the crates which cargo finds below the folder of a
|
|
8
|
+
* `paths` entry, walked as cargo walks it (`EVD-CARGO-REDIRECTIONS`), by
|
|
9
|
+
* their real paths, in the order of the walk: the folder first, each folder
|
|
10
|
+
* before what lies in it, and the entries of a folder sorted by name.
|
|
11
|
+
*
|
|
12
|
+
* As cargo does, the walk goes to any depth, follows a symbolic link given
|
|
13
|
+
* as `folder` but none below it, and takes every folder that holds a
|
|
14
|
+
* `Cargo.toml`, going on below it: under a crate and under a nested
|
|
15
|
+
* workspace alike. Below `folder` itself it skips the folders whose names
|
|
16
|
+
* start with `.` and those that hold `.git`, and at every level a folder
|
|
17
|
+
* named `target` beside a `Cargo.toml`. A folder it cannot read is skipped,
|
|
18
|
+
* as cargo skips it. It skips nothing else, so it also enters
|
|
19
|
+
* `node_modules` and Cargo's artifact and build directories, where cargo
|
|
20
|
+
* finds crates as well.
|
|
21
|
+
*
|
|
22
|
+
* It also takes a folder whose manifest is a virtual one or one that cargo
|
|
23
|
+
* cannot parse, and every crate of a name that two crates share, where cargo
|
|
24
|
+
* takes one: each such folder only adds a crate that cargo may use
|
|
25
|
+
* (`DES-METADATA-REPORT`). The path dependencies that cargo also takes from
|
|
26
|
+
* each crate it finds are not walked here (`pathsCandidates` in
|
|
27
|
+
* `discovery.ts`).
|
|
28
|
+
*
|
|
29
|
+
* @param folder The folder of the entry, an absolute path.
|
|
30
|
+
* @returns No folder where `folder` does not exist.
|
|
31
|
+
*/
|
|
32
|
+
// @mara implements DES-METADATA-REPORT
|
|
33
|
+
function cratesBelowPathsFolder(folder) {
|
|
34
|
+
let start;
|
|
35
|
+
try {
|
|
36
|
+
start = (0, node_fs_1.realpathSync)(folder);
|
|
37
|
+
}
|
|
38
|
+
catch (_a) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const crates = [];
|
|
42
|
+
const visit = (current) => {
|
|
43
|
+
const name = (0, node_path_1.basename)(current);
|
|
44
|
+
if (current !== start && (name.startsWith(".") || (0, node_fs_1.existsSync)((0, node_path_1.join)(current, ".git")))) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (name === "target" && (0, node_fs_1.existsSync)((0, node_path_1.join)((0, node_path_1.dirname)(current), "Cargo.toml"))) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(current, "Cargo.toml"))) {
|
|
51
|
+
crates.push(current);
|
|
52
|
+
}
|
|
53
|
+
let entries;
|
|
54
|
+
try {
|
|
55
|
+
entries = (0, node_fs_1.readdirSync)(current, { withFileTypes: true });
|
|
56
|
+
}
|
|
57
|
+
catch (_a) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
for (const entry of entries
|
|
61
|
+
.filter((entry) => entry.isDirectory())
|
|
62
|
+
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {
|
|
63
|
+
visit((0, node_path_1.join)(current, entry.name));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
visit(start);
|
|
67
|
+
return crates;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=paths-crates.js.map
|