@smoothbricks/nx-plugin 0.4.26 → 0.4.27
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/README.md +994 -117
- package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-bound-failures.js +31 -0
- package/dist/bin/smoo-nx-cargo-hash.js +28 -3
- package/dist/bin/smoo-nx-exec.js +15 -73
- package/dist/bin/smoo-nx-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-failures.js +3 -0
- package/dist/bin/smoo-nx-nextest-extract.js +3 -2
- package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-walks.js +34 -0
- package/dist/bounded-test-policy.d.ts +7 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +101 -40
- package/dist/build-state-output-policy.d.ts +25 -0
- package/dist/build-state-output-policy.d.ts.map +1 -0
- package/dist/build-state-output-policy.js +64 -0
- package/dist/cargo-closure-input.d.ts +3 -2
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +16 -15
- package/dist/cargo-dev-profile.d.ts +37 -0
- package/dist/cargo-dev-profile.d.ts.map +1 -0
- package/dist/cargo-dev-profile.js +108 -0
- package/dist/cargo-source-hash.d.ts +43 -6
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +309 -73
- package/dist/cargo-toolchain-policy.d.ts +4 -0
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +5 -0
- package/dist/cargo-workspace.d.ts +101 -5
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +291 -10
- package/dist/cross-check-policy.d.ts +21 -3
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +24 -6
- package/dist/disk-command-policy.d.ts +7 -0
- package/dist/disk-command-policy.d.ts.map +1 -0
- package/dist/disk-command-policy.js +98 -0
- package/dist/ensure-built-receipt.d.ts +25 -0
- package/dist/ensure-built-receipt.d.ts.map +1 -0
- package/dist/ensure-built-receipt.js +261 -0
- package/dist/ensure-built-witness.d.ts +57 -0
- package/dist/ensure-built-witness.d.ts.map +1 -0
- package/dist/ensure-built-witness.js +412 -0
- package/dist/ensure-built.d.ts +207 -12
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +576 -202
- package/dist/eslint-file-set.d.ts +7 -0
- package/dist/eslint-file-set.d.ts.map +1 -0
- package/dist/eslint-file-set.js +12 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-pool.js +379 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/disk-lease.js +91 -0
- package/dist/executors/bounded-exec/executor.d.ts +45 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +447 -52
- package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/gateway-lease.js +143 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
- package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
- package/dist/executors/bounded-exec/progress.d.ts +35 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress.js +79 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp.js +1528 -0
- package/dist/executors/bounded-exec/schema.d.ts +29 -11
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +162 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
- package/dist/executors/bounded-exec/verdict.js +318 -0
- package/dist/executors/shard-timings/executor.d.ts +14 -0
- package/dist/executors/shard-timings/executor.d.ts.map +1 -0
- package/dist/executors/shard-timings/executor.js +25 -0
- package/dist/executors/shard-timings/schema.d.ts +4 -0
- package/dist/executors/shard-timings/schema.d.ts.map +1 -0
- package/dist/executors/shard-timings/schema.js +1 -0
- package/dist/failure-summary.d.ts +5 -0
- package/dist/failure-summary.d.ts.map +1 -0
- package/dist/failure-summary.js +118 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +6 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +370 -138
- package/dist/managed-files/ci-workflow.d.ts +13 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +44 -13
- package/dist/managed-files/files.d.ts +7 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +62 -8
- package/dist/managed-files/json-edit.d.ts +21 -0
- package/dist/managed-files/json-edit.d.ts.map +1 -0
- package/dist/managed-files/json-edit.js +295 -0
- package/dist/managed-files/managed-format.d.ts +33 -1
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +82 -2
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
- package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/managed-files/publish-workflow.js +231 -48
- package/dist/managed-files/tree.d.ts +5 -0
- package/dist/managed-files/tree.d.ts.map +1 -1
- package/dist/managed-files/tree.js +5 -3
- package/dist/manifest-hash.d.ts.map +1 -1
- package/dist/manifest-hash.js +2 -5
- package/dist/nextest-code-bound.d.ts +62 -0
- package/dist/nextest-code-bound.d.ts.map +1 -0
- package/dist/nextest-code-bound.js +154 -0
- package/dist/nextest-extraction.d.ts +24 -8
- package/dist/nextest-extraction.d.ts.map +1 -1
- package/dist/nextest-extraction.js +42 -7
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +3 -5
- package/dist/release-config-policy.d.ts.map +1 -1
- package/dist/release-config-policy.js +3 -5
- package/dist/runtime-input.d.ts +14 -0
- package/dist/runtime-input.d.ts.map +1 -0
- package/dist/runtime-input.js +15 -0
- package/dist/rust-tokens.d.ts +11 -0
- package/dist/rust-tokens.d.ts.map +1 -0
- package/dist/rust-tokens.js +81 -0
- package/dist/task-results.d.ts +6 -0
- package/dist/task-results.d.ts.map +1 -0
- package/dist/task-results.js +61 -0
- package/dist/test-program.d.ts +54 -0
- package/dist/test-program.d.ts.map +1 -0
- package/dist/test-program.js +292 -0
- package/dist/test-timings.d.ts +71 -0
- package/dist/test-timings.d.ts.map +1 -0
- package/dist/test-timings.js +393 -0
- package/dist/test-walk-policy.d.ts +103 -0
- package/dist/test-walk-policy.d.ts.map +1 -0
- package/dist/test-walk-policy.js +657 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +824 -0
- package/dist/type-guards.d.ts +3 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/type-guards.js +4 -0
- package/dist/typecheck-test-policy.d.ts +8 -5
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +113 -100
- package/dist/workspace-config-policy.d.ts +8 -0
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +175 -63
- package/dist/workspace-index.d.ts +12 -0
- package/dist/workspace-index.d.ts.map +1 -0
- package/dist/workspace-index.js +17 -0
- package/dist/workspace-manifest.d.ts +37 -0
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/executors.json +5 -0
- package/loader.js +13 -11
- package/managed/raw/envrc +33 -67
- package/managed/raw/git-format-staged.yml +30 -35
- package/managed/raw/patches/nx@23.2.1.patch +3484 -0
- package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
- package/managed/raw/tooling/direnv/developer-links.ts +569 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
- package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
- package/managed/raw/tooling/direnv/repo-path +14 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +962 -148
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
- package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
- package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
- package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
- package/managed/templates/github/actions/cache-nx/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
- package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
- package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
- package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
- package/managed/templates/github/workflows/managed-files.yml +1 -2
- package/nextest.toml +8 -41
- package/package.json +74 -12
- package/runtime-input.sh +81 -0
- package/src/__tests__/counted-cargo.ts +33 -14
- package/src/__tests__/fixture-nx-env.ts +111 -46
- package/src/__tests__/progress-clock.ts +43 -0
- package/src/__tests__/runtime-input.ts +23 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
- package/src/bin/smoo-nx-bound-failures.ts +33 -0
- package/src/bin/smoo-nx-cargo-hash.ts +28 -3
- package/src/bin/smoo-nx-exec.ts +16 -74
- package/src/bin/smoo-nx-failures.ts +4 -0
- package/src/bin/smoo-nx-nextest-extract.ts +3 -2
- package/src/bin/smoo-nx-test-walks.ts +42 -0
- package/src/bounded-test-policy.test.ts +268 -21
- package/src/bounded-test-policy.ts +114 -42
- package/src/build-state-output-policy.test.ts +115 -0
- package/src/build-state-output-policy.ts +90 -0
- package/src/bun-bootstrap.test.ts +57 -3
- package/src/bun-file-packages.test.ts +47 -0
- package/src/cargo-closure-input.test.ts +138 -66
- package/src/cargo-closure-input.ts +17 -15
- package/src/cargo-dev-profile.ts +137 -0
- package/src/cargo-resolve-cache.test.ts +70 -1
- package/src/cargo-source-hash.test.ts +193 -97
- package/src/cargo-source-hash.ts +345 -68
- package/src/cargo-toolchain-policy.ts +6 -0
- package/src/cargo-workspace.test.ts +320 -0
- package/src/cargo-workspace.ts +336 -10
- package/src/cross-check-policy.test.ts +59 -1
- package/src/cross-check-policy.ts +25 -6
- package/src/disk-command-policy.test.ts +61 -0
- package/src/disk-command-policy.ts +107 -0
- package/src/ensure-built-receipt.test.ts +184 -0
- package/src/ensure-built-receipt.ts +263 -0
- package/src/ensure-built-witness.test.ts +344 -0
- package/src/ensure-built-witness.ts +252 -0
- package/src/ensure-built.test.ts +1036 -578
- package/src/ensure-built.ts +820 -224
- package/src/eslint-file-set.ts +9 -0
- package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
- package/src/executors/bounded-exec/cpu-pool.ts +417 -0
- package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
- package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
- package/src/executors/bounded-exec/disk-lease.ts +139 -0
- package/src/executors/bounded-exec/executor-host.test.ts +778 -0
- package/src/executors/bounded-exec/executor.test.ts +1116 -63
- package/src/executors/bounded-exec/executor.ts +565 -67
- package/src/executors/bounded-exec/gateway-lease.ts +176 -0
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
- package/src/executors/bounded-exec/progress.test.ts +79 -0
- package/src/executors/bounded-exec/progress.ts +118 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
- package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
- package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
- package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
- package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
- package/src/executors/bounded-exec/ram-temp.ts +1918 -0
- package/src/executors/bounded-exec/schema.json +11 -5
- package/src/executors/bounded-exec/schema.ts +27 -11
- package/src/executors/bounded-exec/verdict.test.ts +440 -0
- package/src/executors/bounded-exec/verdict.ts +433 -0
- package/src/executors/shard-timings/executor.ts +36 -0
- package/src/executors/shard-timings/schema.json +21 -0
- package/src/executors/shard-timings/schema.ts +4 -0
- package/src/failure-summary.ts +119 -0
- package/src/generators/bounded-test-targets/generator.test.ts +4 -4
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/create-package/generator.test.ts +6 -0
- package/src/generators/create-package/generator.ts +6 -2
- package/src/host-controller-wiring.test.ts +31 -0
- package/src/index.test.ts +909 -295
- package/src/index.ts +441 -143
- package/src/linked-snapshots.nx.test.ts +172 -0
- package/src/managed-files/ci-workflow.ts +54 -13
- package/src/managed-files/files.ts +65 -9
- package/src/managed-files/forgejo-artifact.test.ts +395 -0
- package/src/managed-files/generator.test.ts +60 -1
- package/src/managed-files/json-edit.test.ts +216 -0
- package/src/managed-files/json-edit.ts +290 -0
- package/src/managed-files/managed-format-json.test.ts +308 -0
- package/src/managed-files/managed-format.ts +90 -2
- package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
- package/src/managed-files/publish-workflow.ts +285 -67
- package/src/managed-files/repo-path.test.ts +129 -0
- package/src/managed-files/trace-db-artifact.test.ts +7 -0
- package/src/managed-files/tree.ts +11 -3
- package/src/manifest-hash.ts +2 -6
- package/src/nextest-code-bound.test.ts +155 -0
- package/src/nextest-code-bound.ts +195 -0
- package/src/nextest-extraction.test.ts +37 -5
- package/src/nextest-extraction.ts +51 -9
- package/src/nextest-partitions.test.ts +427 -82
- package/src/nx-cache-bound.test.ts +5 -10
- package/src/nx-cache-restore-mtime.test.ts +170 -0
- package/src/nx-daemon-claim.test.ts +277 -0
- package/src/nx-daemon-idle-cpu.test.ts +81 -0
- package/src/nx-daemon-idle-policy.test.ts +51 -0
- package/src/nx-daemon-ignore-files.test.ts +210 -0
- package/src/nx-daemon-root-normalization.test.ts +105 -0
- package/src/nx-daemon-validity.test.ts +925 -0
- package/src/nx-dot-input-policy.test.ts +353 -0
- package/src/nx-failure-life-cycles.test.ts +207 -0
- package/src/nx-files-archive-racy.test.ts +97 -0
- package/src/nx-foreign-workspace-env.test.ts +329 -0
- package/src/nx-incomplete-run-summary.test.ts +70 -0
- package/src/nx-plugin-load-errors.test.ts +120 -0
- package/src/nx-project-resolution-cache.test.ts +176 -0
- package/src/nx-raw-inputs.test.ts +166 -0
- package/src/nx-resident-graph-workers.test.ts +7 -16
- package/src/nx-run-information.test.ts +118 -0
- package/src/nx-skipped-task-exit.test.ts +180 -0
- package/src/nx-state-location.test.ts +63 -0
- package/src/nx-store-resolution.test.ts +26 -25
- package/src/nx-task-graph-cycles.test.ts +148 -0
- package/src/nx-task-output-lease.test.ts +414 -0
- package/src/nx-use-local.test.ts +103 -0
- package/src/package-target-policy.ts +3 -6
- package/src/release-config-policy.ts +3 -6
- package/src/runtime-input.test.ts +215 -0
- package/src/runtime-input.ts +17 -0
- package/src/rust-tokens.ts +78 -0
- package/src/serial-group-wiring.test.ts +326 -0
- package/src/task-history-namespace.test.ts +87 -89
- package/src/task-results.test.ts +226 -0
- package/src/task-results.ts +75 -0
- package/src/test-program.test.ts +303 -0
- package/src/test-program.ts +341 -0
- package/src/test-timings.test.ts +240 -0
- package/src/test-timings.ts +311 -0
- package/src/test-walk-policy.test.ts +585 -0
- package/src/test-walk-policy.ts +731 -0
- package/src/testing.test.ts +509 -0
- package/src/testing.ts +922 -0
- package/src/type-guards.ts +4 -0
- package/src/typecheck-test-policy.test.ts +496 -11
- package/src/typecheck-test-policy.ts +137 -103
- package/src/workspace-config-policy.test.ts +212 -13
- package/src/workspace-config-policy.ts +101 -73
- package/src/workspace-index.ts +18 -0
- package/src/workspace-manifest.ts +41 -0
- package/test-timings.json +85 -30
- package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
- package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { NonEmptyArray, PackageCargoCredentialsConfig, PackagePrivateNpmConfig, PackageRemoteCacheConfig, PackageSmooGithub, PackageSmooGithubEnvironments, PackageSourceCheckoutConfig } from '../workspace-manifest.js';
|
|
2
|
+
export declare const githubActionPins: Readonly<Record<'checkout' | 'nxSetShas' | 'cacheSave' | 'uploadArtifact' | 'downloadArtifact', {
|
|
3
|
+
readonly ref: string;
|
|
4
|
+
readonly version: string;
|
|
5
|
+
}>>;
|
|
2
6
|
export declare enum CiWorkflowStepKind {
|
|
3
7
|
Checkout = "checkout",
|
|
4
8
|
SourceCheckouts = "source-checkouts",
|
|
@@ -231,5 +235,14 @@ export declare function deployStepSecretEnvLines(config: DeployStepSecretConfig)
|
|
|
231
235
|
* never uses.
|
|
232
236
|
*/
|
|
233
237
|
export declare function cloudflareCredentialEnvLines(deploySecrets: Record<string, string> | undefined): string[];
|
|
238
|
+
/**
|
|
239
|
+
* Every package's lmao trace sink, with its WAL sidecars: a run killed before a
|
|
240
|
+
* checkpoint leaves its committed frames in `-wal`, and without them the
|
|
241
|
+
* uploaded database reads `no such table: spans`. lmao's
|
|
242
|
+
* `TRACE_DB_DIRECTORY`/`TRACE_DB_FILENAME` own the path; the plugin cannot
|
|
243
|
+
* import them at runtime (lmao is not a runtime dependency), so a test pins
|
|
244
|
+
* this glob to them.
|
|
245
|
+
*/
|
|
246
|
+
export declare const TRACE_DB_ARTIFACT_GLOB = "packages/*/.cache/lmao/trace-results.db*";
|
|
234
247
|
export declare function artifactStepLines(provider: PackageSmooGithub['actionsProvider'], name: string, kind: 'upload' | 'download', inputs: readonly string[], condition?: string): string[];
|
|
235
248
|
//# sourceMappingURL=ci-workflow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ci-workflow.d.ts","sourceRoot":"","sources":["../../src/managed-files/ci-workflow.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,aAAa,EACb,6BAA6B,EAE7B,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAGlC,oBAAY,kBAAkB;IAC5B,QAAQ,aAAa;IACrB,eAAe,qBAAqB;IACpC,WAAW,iBAAiB;IAC5B,gBAAgB,sBAAsB;IACtC,SAAS,gBAAgB;IACzB,cAAc,qBAAqB;IACnC,KAAK,UAAU;IACf,YAAY,kBAAkB;IAC9B,IAAI,SAAS;IACb,SAAS,eA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,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,GAAG,wBAAwB,CAgB/F;AA+BD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,6BAA6B,GAAG,SAAS,GAAG,MAAM,CASpG;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,6BAA6B,GAAG,MAAM,EAAE,CAyG9G;AAqCD,6EAA6E;AAC7E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,6BAA6B,GAAG,6BAA6B,CAkC9G;AAqGD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,UAIjC,CAAC;AA6BF,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEhE;AAQD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,EAAE,CAGjF;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAAG,MAAM,EAAE,CAMxG;AAmRD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,6CAA6C,CAAC;AAEjF,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,EAC9C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,GAAG,UAAU,EAC3B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,SAAS,SAAc,GACtB,MAAM,EAAE,CAkBV"}
|
|
@@ -3,6 +3,28 @@ import { parse as parseYaml } from 'yaml';
|
|
|
3
3
|
import { cargoCrossTestArchiveFile, cargoCrossTestArchiveTargetName, cargoCrossTestTargetName, } from '../cross-check-policy.js';
|
|
4
4
|
import { PRODUCTION_PUSH_DEPLOY_TAG } from '../deploy-policy.js';
|
|
5
5
|
import { renderRunsOnLine } from './github-runs-on.js';
|
|
6
|
+
export const githubActionPins = {
|
|
7
|
+
checkout: {
|
|
8
|
+
ref: 'actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd',
|
|
9
|
+
version: 'v6.0.2',
|
|
10
|
+
},
|
|
11
|
+
nxSetShas: {
|
|
12
|
+
ref: 'nrwl/nx-set-shas@afb73a62d26e41464e9254689e1fd6122ee683c1',
|
|
13
|
+
version: 'v5.0.1',
|
|
14
|
+
},
|
|
15
|
+
cacheSave: {
|
|
16
|
+
ref: 'actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae',
|
|
17
|
+
version: 'v5.0.5',
|
|
18
|
+
},
|
|
19
|
+
uploadArtifact: {
|
|
20
|
+
ref: 'actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a',
|
|
21
|
+
version: 'v7.0.1',
|
|
22
|
+
},
|
|
23
|
+
downloadArtifact: {
|
|
24
|
+
ref: 'actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c',
|
|
25
|
+
version: 'v8.0.1',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
6
28
|
export var CiWorkflowStepKind;
|
|
7
29
|
(function (CiWorkflowStepKind) {
|
|
8
30
|
CiWorkflowStepKind["Checkout"] = "checkout";
|
|
@@ -215,10 +237,11 @@ function yamlLinesForStep(step, options) {
|
|
|
215
237
|
case CiWorkflowStepKind.Checkout:
|
|
216
238
|
return [
|
|
217
239
|
` - name: ${step.name}`,
|
|
218
|
-
|
|
240
|
+
` uses: ${githubActionPins.checkout.ref} # ${githubActionPins.checkout.version}`,
|
|
219
241
|
' with:',
|
|
220
|
-
'
|
|
242
|
+
' # Full history includes blobs needed by nx affected after checkout credentials are removed.',
|
|
221
243
|
' fetch-depth: 0',
|
|
244
|
+
' persist-credentials: false',
|
|
222
245
|
];
|
|
223
246
|
case CiWorkflowStepKind.SourceCheckouts:
|
|
224
247
|
return sourceCheckoutsStepLines(step, options.sourceCheckouts ?? []);
|
|
@@ -232,7 +255,7 @@ function yamlLinesForStep(step, options) {
|
|
|
232
255
|
return [
|
|
233
256
|
` - name: ${step.name}`,
|
|
234
257
|
" if: github.server_url == 'https://github.com' || endsWith(github.api_url, '/api/v3')",
|
|
235
|
-
|
|
258
|
+
` uses: ${githubActionPins.nxSetShas.ref} # ${githubActionPins.nxSetShas.version}`,
|
|
236
259
|
' with:',
|
|
237
260
|
' workflow-id: ci.yml',
|
|
238
261
|
];
|
|
@@ -352,7 +375,7 @@ function yamlLinesForStep(step, options) {
|
|
|
352
375
|
" ${{ steps.setup.outputs.host-runner != 'true' && github.event_name == 'push' && github.ref ==",
|
|
353
376
|
" format('refs/heads/{0}', github.event.repository.default_branch) && steps.nx-cache.outputs.cache-hit != 'true'",
|
|
354
377
|
' }}',
|
|
355
|
-
|
|
378
|
+
` uses: ${githubActionPins.cacheSave.ref} # ${githubActionPins.cacheSave.version}`,
|
|
356
379
|
' with:',
|
|
357
380
|
' path: |',
|
|
358
381
|
' .nx/cache',
|
|
@@ -362,7 +385,7 @@ function yamlLinesForStep(step, options) {
|
|
|
362
385
|
case CiWorkflowStepKind.UploadTraceDbs:
|
|
363
386
|
return artifactStepLines(options.actionsProvider, step.name, 'upload', [
|
|
364
387
|
'name: trace-results-${{ github.run_id }}',
|
|
365
|
-
|
|
388
|
+
`path: ${TRACE_DB_ARTIFACT_GLOB}`,
|
|
366
389
|
'if-no-files-found: ignore',
|
|
367
390
|
'retention-days: 14',
|
|
368
391
|
'include-hidden-files: true',
|
|
@@ -1020,7 +1043,7 @@ function darwinCrossTestTargetNames(options) {
|
|
|
1020
1043
|
* step carries exactly these archives, and upload-artifact roots an artifact at
|
|
1021
1044
|
* the least common ancestor of the files it uploaded.
|
|
1022
1045
|
*
|
|
1023
|
-
* One cargo workspace's triples all share
|
|
1046
|
+
* One cargo workspace's triples all share `.cache/nextest` and travel together.
|
|
1024
1047
|
* Two workspaces that each declare a darwin triple do not: their common
|
|
1025
1048
|
* ancestor is above the directory the runner targets read from, so the pair is
|
|
1026
1049
|
* refused here instead of restoring both archives one directory too high.
|
|
@@ -1087,17 +1110,25 @@ ${renderOptionalLines(deployStepSecretEnvLines(options))} # prettier-igno
|
|
|
1087
1110
|
|
|
1088
1111
|
${renderCiWorkflowSteps(followUpCleanupStep(numbers), options)}`;
|
|
1089
1112
|
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Every package's lmao trace sink, with its WAL sidecars: a run killed before a
|
|
1115
|
+
* checkpoint leaves its committed frames in `-wal`, and without them the
|
|
1116
|
+
* uploaded database reads `no such table: spans`. lmao's
|
|
1117
|
+
* `TRACE_DB_DIRECTORY`/`TRACE_DB_FILENAME` own the path; the plugin cannot
|
|
1118
|
+
* import them at runtime (lmao is not a runtime dependency), so a test pins
|
|
1119
|
+
* this glob to them.
|
|
1120
|
+
*/
|
|
1121
|
+
export const TRACE_DB_ARTIFACT_GLOB = 'packages/*/.cache/lmao/trace-results.db*';
|
|
1090
1122
|
export function artifactStepLines(provider, name, kind, inputs, condition = 'success()') {
|
|
1091
|
-
//
|
|
1092
|
-
// Forgejo
|
|
1093
|
-
// Forgejo 15 supports v4 artifacts; its pinned clients remove the GHES gate.
|
|
1123
|
+
// Local adapters keep both providers in GitHub's workflow grammar while
|
|
1124
|
+
// Forgejo runs its exact pinned clients without the GitHub GHES rejection.
|
|
1094
1125
|
const action = provider === 'forgejo'
|
|
1095
1126
|
? kind === 'upload'
|
|
1096
|
-
? '
|
|
1097
|
-
: '
|
|
1127
|
+
? './.github/actions/forgejo-upload-artifact'
|
|
1128
|
+
: './.github/actions/forgejo-download-artifact'
|
|
1098
1129
|
: kind === 'upload'
|
|
1099
|
-
?
|
|
1100
|
-
:
|
|
1130
|
+
? `${githubActionPins.uploadArtifact.ref} # ${githubActionPins.uploadArtifact.version}`
|
|
1131
|
+
: `${githubActionPins.downloadArtifact.ref} # ${githubActionPins.downloadArtifact.version}`;
|
|
1101
1132
|
return [
|
|
1102
1133
|
` - name: ${name}`,
|
|
1103
1134
|
` if: ${condition}`,
|
|
@@ -46,6 +46,12 @@ export declare const managedTtscPatch: {
|
|
|
46
46
|
readonly key: 'ttsc@0.30.4';
|
|
47
47
|
readonly path: 'patches/ttsc@0.30.4.patch';
|
|
48
48
|
};
|
|
49
|
+
/** Maintained Nx 23.2.1 repairs, applied as an ordinary Bun patchedDependency over the registry release. */
|
|
50
|
+
export declare const managedNxPatch: {
|
|
51
|
+
readonly version: '23.2.1';
|
|
52
|
+
readonly key: 'nx@23.2.1';
|
|
53
|
+
readonly path: 'patches/nx@23.2.1.patch';
|
|
54
|
+
};
|
|
49
55
|
export declare const managedFileTargetsForTest: {
|
|
50
56
|
target: string;
|
|
51
57
|
executable: boolean | undefined;
|
|
@@ -55,5 +61,5 @@ export declare function managedFileTargetsForContext(context: ManagedFileContext
|
|
|
55
61
|
/** Render all packaged templates before staging any workspace changes. */
|
|
56
62
|
export declare function renderManagedFiles(context: ManagedFileContext): ManagedFile[];
|
|
57
63
|
/** Renders a generated workflow through its real managed-file descriptor, so the context wiring is covered. */
|
|
58
|
-
export declare function renderManagedWorkflowForTest(source: 'ci-workflow' | 'publish-workflow' | 'pr-preview-cleanup-workflow', context: ManagedFileContext): string;
|
|
64
|
+
export declare function renderManagedWorkflowForTest(source: 'ci-workflow' | 'publish-workflow' | 'pr-preview-cleanup-workflow' | 'pr-stage-sweep-workflow', context: ManagedFileContext): string;
|
|
59
65
|
//# sourceMappingURL=files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/managed-files/files.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,kBAAkB,EAAmD,MAAM,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|
|
4
4
|
import { privateNpmReadTokenJobEnv, renderCiWorkflowYaml } from './ci-workflow.js';
|
|
5
5
|
import { renderRunsOnLine } from './github-runs-on.js';
|
|
6
|
-
import { renderPrPreviewCleanupWorkflowYaml } from './pr-preview-cleanup-workflow.js';
|
|
6
|
+
import { renderPrPreviewCleanupWorkflowYaml, renderPrStageSweepWorkflowYaml } from './pr-preview-cleanup-workflow.js';
|
|
7
7
|
import { renderPublishWorkflowYaml } from './publish-workflow.js';
|
|
8
8
|
/** Temporary upstream compiler repairs distributed to smoo-managed Bun workspaces. */
|
|
9
9
|
export const managedTtscPatch = {
|
|
@@ -11,12 +11,23 @@ export const managedTtscPatch = {
|
|
|
11
11
|
key: 'ttsc@0.30.4',
|
|
12
12
|
path: 'patches/ttsc@0.30.4.patch',
|
|
13
13
|
};
|
|
14
|
+
/** Maintained Nx 23.2.1 repairs, applied as an ordinary Bun patchedDependency over the registry release. */
|
|
15
|
+
export const managedNxPatch = {
|
|
16
|
+
version: '23.2.1',
|
|
17
|
+
key: 'nx@23.2.1',
|
|
18
|
+
path: 'patches/nx@23.2.1.patch',
|
|
19
|
+
};
|
|
14
20
|
const managedFiles = [
|
|
15
21
|
{
|
|
16
22
|
kind: 'raw',
|
|
17
23
|
source: managedTtscPatch.path,
|
|
18
24
|
target: managedTtscPatch.path,
|
|
19
25
|
},
|
|
26
|
+
{
|
|
27
|
+
kind: 'raw',
|
|
28
|
+
source: managedNxPatch.path,
|
|
29
|
+
target: managedNxPatch.path,
|
|
30
|
+
},
|
|
20
31
|
{
|
|
21
32
|
kind: 'raw',
|
|
22
33
|
source: 'envrc',
|
|
@@ -51,6 +62,11 @@ const managedFiles = [
|
|
|
51
62
|
source: 'tooling/direnv/developer-links.ts',
|
|
52
63
|
target: 'tooling/direnv/developer-links.ts',
|
|
53
64
|
},
|
|
65
|
+
{
|
|
66
|
+
kind: 'raw',
|
|
67
|
+
source: 'tooling/direnv/linked-snapshots.ts',
|
|
68
|
+
target: 'tooling/direnv/linked-snapshots.ts',
|
|
69
|
+
},
|
|
54
70
|
{
|
|
55
71
|
kind: 'raw',
|
|
56
72
|
source: 'tooling/direnv/secret-references.ts',
|
|
@@ -69,14 +85,18 @@ const managedFiles = [
|
|
|
69
85
|
},
|
|
70
86
|
{
|
|
71
87
|
kind: 'raw',
|
|
72
|
-
source: 'tooling/direnv/
|
|
73
|
-
target: 'tooling/direnv/
|
|
88
|
+
source: 'tooling/direnv/nx-socket-dir.sh',
|
|
89
|
+
target: 'tooling/direnv/nx-socket-dir.sh',
|
|
74
90
|
},
|
|
75
91
|
{
|
|
76
92
|
kind: 'raw',
|
|
77
|
-
source: 'tooling/direnv/
|
|
78
|
-
target: 'tooling/direnv/
|
|
79
|
-
|
|
93
|
+
source: 'tooling/direnv/ttsc-env.sh',
|
|
94
|
+
target: 'tooling/direnv/ttsc-env.sh',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
kind: 'raw',
|
|
98
|
+
source: 'tooling/direnv/apple-developer.sh',
|
|
99
|
+
target: 'tooling/direnv/apple-developer.sh',
|
|
80
100
|
},
|
|
81
101
|
{
|
|
82
102
|
kind: 'raw',
|
|
@@ -129,6 +149,12 @@ const managedFiles = [
|
|
|
129
149
|
target: '.github/workflows/pr-preview-cleanup.yml',
|
|
130
150
|
cloudflareDeployOnly: true,
|
|
131
151
|
},
|
|
152
|
+
{
|
|
153
|
+
kind: 'generated',
|
|
154
|
+
source: 'pr-stage-sweep-workflow',
|
|
155
|
+
target: '.github/workflows/pr-stage-sweep.yml',
|
|
156
|
+
cloudflareDeployOnly: true,
|
|
157
|
+
},
|
|
132
158
|
{
|
|
133
159
|
kind: 'generated',
|
|
134
160
|
source: 'publish-workflow',
|
|
@@ -170,6 +196,31 @@ const managedFiles = [
|
|
|
170
196
|
source: 'github/actions/cache-nx/action.yml',
|
|
171
197
|
target: '.github/actions/cache-nx/action.yml',
|
|
172
198
|
},
|
|
199
|
+
{
|
|
200
|
+
kind: 'template',
|
|
201
|
+
source: 'github/actions/forgejo-upload-artifact/action.yml',
|
|
202
|
+
target: '.github/actions/forgejo-upload-artifact/action.yml',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
kind: 'template',
|
|
206
|
+
source: 'github/actions/forgejo-upload-artifact/index.cjs',
|
|
207
|
+
target: '.github/actions/forgejo-upload-artifact/index.cjs',
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
kind: 'template',
|
|
211
|
+
source: 'github/actions/forgejo-download-artifact/action.yml',
|
|
212
|
+
target: '.github/actions/forgejo-download-artifact/action.yml',
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
kind: 'template',
|
|
216
|
+
source: 'github/actions/forgejo-download-artifact/index.cjs',
|
|
217
|
+
target: '.github/actions/forgejo-download-artifact/index.cjs',
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
kind: 'template',
|
|
221
|
+
source: 'github/actions/forgejo-artifact.cjs',
|
|
222
|
+
target: '.github/actions/forgejo-artifact.cjs',
|
|
223
|
+
},
|
|
173
224
|
];
|
|
174
225
|
export const managedFileTargetsForTest = managedFiles.map(({ target, executable }) => ({ target, executable }));
|
|
175
226
|
/**
|
|
@@ -250,8 +301,11 @@ function getManagedContent(file, context) {
|
|
|
250
301
|
deploySecrets: context.ciDeploySecrets,
|
|
251
302
|
});
|
|
252
303
|
}
|
|
253
|
-
if (file.source === 'pr-preview-cleanup-workflow') {
|
|
254
|
-
|
|
304
|
+
if (file.source === 'pr-preview-cleanup-workflow' || file.source === 'pr-stage-sweep-workflow') {
|
|
305
|
+
const render = file.source === 'pr-preview-cleanup-workflow'
|
|
306
|
+
? renderPrPreviewCleanupWorkflowYaml
|
|
307
|
+
: renderPrStageSweepWorkflowYaml;
|
|
308
|
+
return render({
|
|
255
309
|
runsOn: context.ciRunsOn,
|
|
256
310
|
privateNpm: context.privateNpm,
|
|
257
311
|
sourceCheckouts: context.sourceCheckouts,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `text` edited to parse as `after`, with every byte the difference does not touch left alone.
|
|
3
|
+
*
|
|
4
|
+
* A managed file that people also write (a tsconfig explaining why it extends what it extends) cannot be
|
|
5
|
+
* regenerated from its parsed value: serializing drops every comment. The generator owns a handful of fields, so it
|
|
6
|
+
* edits those, and the rest of the file is the author's.
|
|
7
|
+
*
|
|
8
|
+
* - A scalar or an object that changed is replaced where it stands; an array that only grew gains its new elements
|
|
9
|
+
* at the end, one that only shrank loses those elements, and any other array is replaced whole (comments inside
|
|
10
|
+
* it go with it: no generator step reorders an array it owns).
|
|
11
|
+
* - A comment that trails an element on its own line belongs to that element: removing the element removes the
|
|
12
|
+
* comment with it, and an element added after it goes after the comment, never between the two. A comment on a
|
|
13
|
+
* line of its own stays wherever it is, including above a key that was removed.
|
|
14
|
+
* - Inserted values are written compactly on a line of their own; their layout is the caller's formatter's to
|
|
15
|
+
* decide, not this function's.
|
|
16
|
+
*
|
|
17
|
+
* The result is checked: text that does not parse to exactly `after` is a fault in this function, not something to
|
|
18
|
+
* write.
|
|
19
|
+
*/
|
|
20
|
+
export declare function editJsonText(text: string, after: unknown): string;
|
|
21
|
+
//# sourceMappingURL=json-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-edit.d.ts","sourceRoot":"","sources":["../../src/managed-files/json-edit.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAejE"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { applyEdits, parse, parseTree } from 'jsonc-parser';
|
|
3
|
+
import { isRecord } from '../type-guards.js';
|
|
4
|
+
/**
|
|
5
|
+
* `text` edited to parse as `after`, with every byte the difference does not touch left alone.
|
|
6
|
+
*
|
|
7
|
+
* A managed file that people also write (a tsconfig explaining why it extends what it extends) cannot be
|
|
8
|
+
* regenerated from its parsed value: serializing drops every comment. The generator owns a handful of fields, so it
|
|
9
|
+
* edits those, and the rest of the file is the author's.
|
|
10
|
+
*
|
|
11
|
+
* - A scalar or an object that changed is replaced where it stands; an array that only grew gains its new elements
|
|
12
|
+
* at the end, one that only shrank loses those elements, and any other array is replaced whole (comments inside
|
|
13
|
+
* it go with it: no generator step reorders an array it owns).
|
|
14
|
+
* - A comment that trails an element on its own line belongs to that element: removing the element removes the
|
|
15
|
+
* comment with it, and an element added after it goes after the comment, never between the two. A comment on a
|
|
16
|
+
* line of its own stays wherever it is, including above a key that was removed.
|
|
17
|
+
* - Inserted values are written compactly on a line of their own; their layout is the caller's formatter's to
|
|
18
|
+
* decide, not this function's.
|
|
19
|
+
*
|
|
20
|
+
* The result is checked: text that does not parse to exactly `after` is a fault in this function, not something to
|
|
21
|
+
* write.
|
|
22
|
+
*/
|
|
23
|
+
export function editJsonText(text, after) {
|
|
24
|
+
// What the document means, not how a caller built it: a key set to undefined is no key.
|
|
25
|
+
const target = JSON.parse(JSON.stringify(after));
|
|
26
|
+
let edited = text;
|
|
27
|
+
for (const change of changesBetween(parseDocument(text), target, [])) {
|
|
28
|
+
edited = applyEdits(edited, editsFor(edited, change));
|
|
29
|
+
// A repeated key is every one of its properties: one removal leaves the other still in the document.
|
|
30
|
+
while (change.kind === 'remove' && typeof change.path.at(-1) === 'string' && isPresent(edited, change.path)) {
|
|
31
|
+
edited = applyEdits(edited, editsFor(edited, change));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!isDeepStrictEqual(parseDocument(edited), target)) {
|
|
35
|
+
throw new Error('the edited JSON text does not parse to the document the policy produced, so it is not written');
|
|
36
|
+
}
|
|
37
|
+
return edited;
|
|
38
|
+
}
|
|
39
|
+
/** Whether `text` still has a member at `path`. */
|
|
40
|
+
function isPresent(text, path) {
|
|
41
|
+
const root = parseTree(text, undefined, { allowTrailingComma: true });
|
|
42
|
+
return root !== undefined && memberAt(root, path) !== undefined;
|
|
43
|
+
}
|
|
44
|
+
function parseDocument(text) {
|
|
45
|
+
const errors = [];
|
|
46
|
+
const document = parse(text, errors, { allowTrailingComma: true });
|
|
47
|
+
const [first] = errors;
|
|
48
|
+
if (first !== undefined)
|
|
49
|
+
throw new Error(`not valid JSON/JSONC (error ${first.error} at offset ${first.offset})`);
|
|
50
|
+
return document;
|
|
51
|
+
}
|
|
52
|
+
function* changesBetween(before, after, path) {
|
|
53
|
+
if (isRecord(before) && isRecord(after)) {
|
|
54
|
+
for (const key of Object.keys(before)) {
|
|
55
|
+
if (!Object.hasOwn(after, key))
|
|
56
|
+
yield { kind: 'remove', path: [...path, key] };
|
|
57
|
+
}
|
|
58
|
+
for (const [key, value] of Object.entries(after)) {
|
|
59
|
+
if (Object.hasOwn(before, key))
|
|
60
|
+
yield* changesBetween(before[key], value, [...path, key]);
|
|
61
|
+
else
|
|
62
|
+
yield { kind: 'add-key', path, key, value };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (Array.isArray(before) && Array.isArray(after)) {
|
|
66
|
+
yield* arrayChanges(before, after, path);
|
|
67
|
+
}
|
|
68
|
+
else if (!isDeepStrictEqual(before, after)) {
|
|
69
|
+
yield { kind: 'replace', path, value: after };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function* arrayChanges(before, after, path) {
|
|
73
|
+
if (isDeepStrictEqual(before, after))
|
|
74
|
+
return;
|
|
75
|
+
if (before.every((element, index) => isDeepStrictEqual(element, after[index]))) {
|
|
76
|
+
for (const element of after.slice(before.length))
|
|
77
|
+
yield { kind: 'append', path, value: element };
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const removed = removedIndexes(before, after);
|
|
81
|
+
if (removed !== null) {
|
|
82
|
+
// Last first, so an index still names the element it did when the changes were derived.
|
|
83
|
+
for (const index of [...removed].reverse())
|
|
84
|
+
yield { kind: 'remove', path: [...path, index] };
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
yield { kind: 'replace', path, value: after };
|
|
88
|
+
}
|
|
89
|
+
/** The indexes of `before` that `after` leaves out, when `after` is `before` with only removals; else null. */
|
|
90
|
+
function removedIndexes(before, after) {
|
|
91
|
+
const removed = [];
|
|
92
|
+
let kept = 0;
|
|
93
|
+
before.forEach((element, index) => {
|
|
94
|
+
if (kept < after.length && isDeepStrictEqual(element, after[kept]))
|
|
95
|
+
kept += 1;
|
|
96
|
+
else
|
|
97
|
+
removed.push(index);
|
|
98
|
+
});
|
|
99
|
+
return kept === after.length ? removed : null;
|
|
100
|
+
}
|
|
101
|
+
/** The edits that make `change` to `text`, found by walking the text's own syntax tree. */
|
|
102
|
+
function editsFor(text, change) {
|
|
103
|
+
const root = parseTree(text, undefined, { allowTrailingComma: true });
|
|
104
|
+
const member = root === undefined ? undefined : memberAt(root, change.path);
|
|
105
|
+
if (member === undefined)
|
|
106
|
+
throw new Error(`no ${JSON.stringify(change.path)} in the JSON text to edit`);
|
|
107
|
+
switch (change.kind) {
|
|
108
|
+
case 'replace': {
|
|
109
|
+
const value = valueNodeOf(member);
|
|
110
|
+
return [{ offset: value.offset, length: value.length, content: JSON.stringify(change.value) }];
|
|
111
|
+
}
|
|
112
|
+
case 'remove':
|
|
113
|
+
return removal(text, member);
|
|
114
|
+
case 'add-key':
|
|
115
|
+
return insertion(text, valueNodeOf(member), `${JSON.stringify(change.key)}: ${JSON.stringify(change.value)}`);
|
|
116
|
+
case 'append':
|
|
117
|
+
return insertion(text, valueNodeOf(member), JSON.stringify(change.value));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** The node a path names: the property for a key, the element for an index, the root for no path. */
|
|
121
|
+
function memberAt(root, path) {
|
|
122
|
+
let member = root;
|
|
123
|
+
for (const segment of path) {
|
|
124
|
+
if (member === undefined)
|
|
125
|
+
return undefined;
|
|
126
|
+
const container = valueNodeOf(member);
|
|
127
|
+
member = typeof segment === 'number' ? container.children?.[segment] : lastProperty(container, segment);
|
|
128
|
+
}
|
|
129
|
+
return member;
|
|
130
|
+
}
|
|
131
|
+
/** The value a member holds: a property's value, or an element itself. */
|
|
132
|
+
function valueNodeOf(member) {
|
|
133
|
+
return member.type === 'property' ? (member.children?.[1] ?? member) : member;
|
|
134
|
+
}
|
|
135
|
+
/** The last property of an object with this key: a parser keeps the last of duplicate keys, so that is the one that means something. */
|
|
136
|
+
function lastProperty(object, key) {
|
|
137
|
+
if (object.type !== 'object')
|
|
138
|
+
return undefined;
|
|
139
|
+
const properties = object.children ?? [];
|
|
140
|
+
for (let index = properties.length - 1; index >= 0; index--) {
|
|
141
|
+
const property = properties[index];
|
|
142
|
+
if (property?.children?.[0]?.value === key)
|
|
143
|
+
return property;
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
/** The edits that add `entry` after the last member of `container`, or inside it when it is empty. */
|
|
148
|
+
function insertion(text, container, entry) {
|
|
149
|
+
if (container.type !== 'object' && container.type !== 'array')
|
|
150
|
+
throw new Error('only an object or an array can gain a member');
|
|
151
|
+
const last = container.children?.at(-1);
|
|
152
|
+
if (last === undefined)
|
|
153
|
+
return [{ offset: container.offset + 1, length: 0, content: entry }];
|
|
154
|
+
const lastEnd = last.offset + last.length;
|
|
155
|
+
const closer = container.offset + container.length - 1;
|
|
156
|
+
const separator = separatorAfter(text, lastEnd, closer);
|
|
157
|
+
// After the comments on the last member's line, and after its separator when that is on a later line.
|
|
158
|
+
const at = Math.max(sameLineEnd(text, lastEnd, closer), separator === null ? 0 : separator + 1);
|
|
159
|
+
// A trailing comma the author wrote stays, one comma further along.
|
|
160
|
+
const added = `\n${entry}${separator === null ? '' : ','}`;
|
|
161
|
+
if (separator !== null)
|
|
162
|
+
return [{ offset: at, length: 0, content: added }];
|
|
163
|
+
// No separator yet: it goes straight after the member, ahead of its comments.
|
|
164
|
+
return at === lastEnd
|
|
165
|
+
? [{ offset: lastEnd, length: 0, content: `,${added}` }]
|
|
166
|
+
: [
|
|
167
|
+
{ offset: lastEnd, length: 0, content: ',' },
|
|
168
|
+
{ offset: at, length: 0, content: added },
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The edits that delete a member of an object or array: its text, its separator, and the comments that trail it on
|
|
173
|
+
* its line, plus the whole line when it has the line to itself. The member before a last one loses its separator so
|
|
174
|
+
* no comma is left dangling.
|
|
175
|
+
*/
|
|
176
|
+
function removal(text, member) {
|
|
177
|
+
const container = member.parent;
|
|
178
|
+
const siblings = container?.children;
|
|
179
|
+
if (container === undefined || siblings === undefined)
|
|
180
|
+
throw new Error('a JSON value with no container cannot be removed');
|
|
181
|
+
const index = siblings.indexOf(member);
|
|
182
|
+
const previous = siblings[index - 1];
|
|
183
|
+
const memberEnd = member.offset + member.length;
|
|
184
|
+
const limit = siblings[index + 1]?.offset ?? container.offset + container.length - 1;
|
|
185
|
+
const separator = separatorAfter(text, memberEnd, limit);
|
|
186
|
+
const { from, to } = wholeLines(text, member.offset, sameLineEnd(text, memberEnd, limit));
|
|
187
|
+
const edits = [{ offset: from, length: to - from, content: '' }];
|
|
188
|
+
// A separator on a later line (a leading-comma style) is not part of the member's line.
|
|
189
|
+
if (separator !== null && separator >= to)
|
|
190
|
+
edits.push({ offset: separator, length: 1, content: '' });
|
|
191
|
+
if (separator === null && previous !== undefined) {
|
|
192
|
+
const own = separatorAfter(text, previous.offset + previous.length, member.offset);
|
|
193
|
+
if (own !== null)
|
|
194
|
+
edits.push({ offset: own, length: 1, content: '' });
|
|
195
|
+
}
|
|
196
|
+
return edits;
|
|
197
|
+
}
|
|
198
|
+
/** The span `start`..`end` widened to its whole lines, when nothing else is on them. */
|
|
199
|
+
function wholeLines(text, start, end) {
|
|
200
|
+
let from = start;
|
|
201
|
+
while (from > 0 && isHorizontalSpace(text[from - 1]))
|
|
202
|
+
from -= 1;
|
|
203
|
+
let to = end;
|
|
204
|
+
while (to < text.length && isHorizontalSpace(text[to]))
|
|
205
|
+
to += 1;
|
|
206
|
+
const alone = from === 0 || isLineBreak(text[from - 1]);
|
|
207
|
+
const lineBreak = text.startsWith('\r\n', to) ? 2 : isLineBreak(text[to]) ? 1 : 0;
|
|
208
|
+
return alone && lineBreak > 0 ? { from, to: to + lineBreak } : { from: start, to: end };
|
|
209
|
+
}
|
|
210
|
+
/** The offset of the separating comma in `text[from, limit)`, skipping comments; null when there is none. */
|
|
211
|
+
function separatorAfter(text, from, limit) {
|
|
212
|
+
let index = from;
|
|
213
|
+
while (index < limit) {
|
|
214
|
+
const char = text[index];
|
|
215
|
+
if (char === ',')
|
|
216
|
+
return index;
|
|
217
|
+
if (text.startsWith('//', index))
|
|
218
|
+
index = lineEnd(text, index, limit);
|
|
219
|
+
else if (text.startsWith('/*', index))
|
|
220
|
+
index = blockEnd(text, index, limit);
|
|
221
|
+
else if (isHorizontalSpace(char) || isLineBreak(char))
|
|
222
|
+
index += 1;
|
|
223
|
+
else
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The end of what trails a member on its line: its comma if that is on the line, and the comments after it. A comment
|
|
230
|
+
* after the comma with a value behind it on the line leads that value, so it is not the member's to take.
|
|
231
|
+
*/
|
|
232
|
+
function sameLineEnd(text, from, limit) {
|
|
233
|
+
let end = from;
|
|
234
|
+
let index = from;
|
|
235
|
+
let sawComma = false;
|
|
236
|
+
while (index < limit) {
|
|
237
|
+
const char = text[index];
|
|
238
|
+
if (isHorizontalSpace(char)) {
|
|
239
|
+
index += 1;
|
|
240
|
+
}
|
|
241
|
+
else if (char === ',' && !sawComma) {
|
|
242
|
+
sawComma = true;
|
|
243
|
+
index += 1;
|
|
244
|
+
end = index;
|
|
245
|
+
}
|
|
246
|
+
else if (text.startsWith('/*', index)) {
|
|
247
|
+
const close = blockEnd(text, index, limit);
|
|
248
|
+
if (sawComma && !onlyTriviaToLineEnd(text, close, limit))
|
|
249
|
+
break;
|
|
250
|
+
index = end = close;
|
|
251
|
+
}
|
|
252
|
+
else if (text.startsWith('//', index)) {
|
|
253
|
+
return lineEnd(text, index, limit);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return end;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Whether nothing but whitespace and comments is left on the line from `from`. `limit` is where the next member
|
|
263
|
+
* starts, or the container's closer: reaching a member on the line is not "nothing left".
|
|
264
|
+
*/
|
|
265
|
+
function onlyTriviaToLineEnd(text, from, limit) {
|
|
266
|
+
let index = from;
|
|
267
|
+
while (index < limit) {
|
|
268
|
+
const char = text[index];
|
|
269
|
+
if (isHorizontalSpace(char))
|
|
270
|
+
index += 1;
|
|
271
|
+
else if (text.startsWith('/*', index))
|
|
272
|
+
index = blockEnd(text, index, limit);
|
|
273
|
+
else
|
|
274
|
+
return text.startsWith('//', index) || isLineBreak(char);
|
|
275
|
+
}
|
|
276
|
+
const atLimit = text[limit];
|
|
277
|
+
return atLimit === '}' || atLimit === ']' || atLimit === undefined;
|
|
278
|
+
}
|
|
279
|
+
/** Where a `//` comment ends: at the line break, which jsonc-parser takes as `\n` or `\r`. */
|
|
280
|
+
function lineEnd(text, from, limit) {
|
|
281
|
+
let index = from;
|
|
282
|
+
while (index < limit && !isLineBreak(text[index]))
|
|
283
|
+
index += 1;
|
|
284
|
+
return index;
|
|
285
|
+
}
|
|
286
|
+
function blockEnd(text, from, limit) {
|
|
287
|
+
const close = text.indexOf('*/', from + 2);
|
|
288
|
+
return close === -1 ? limit : Math.min(close + 2, limit);
|
|
289
|
+
}
|
|
290
|
+
function isHorizontalSpace(char) {
|
|
291
|
+
return char === ' ' || char === '\t';
|
|
292
|
+
}
|
|
293
|
+
function isLineBreak(char) {
|
|
294
|
+
return char === '\n' || char === '\r';
|
|
295
|
+
}
|