@smoothbricks/nx-plugin 0.5.1 → 0.5.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.
Files changed (53) hide show
  1. package/README.md +55 -11
  2. package/dist/bin/smoo-nx-test-clocks.js +2 -2
  3. package/dist/bin/smoo-nx-test-walks.js +6 -9
  4. package/dist/cargo-closure-input.d.ts.map +1 -1
  5. package/dist/cargo-closure-input.js +25 -15
  6. package/dist/ensure-built-witness.d.ts +33 -5
  7. package/dist/ensure-built-witness.d.ts.map +1 -1
  8. package/dist/ensure-built-witness.js +84 -18
  9. package/dist/ensure-built.d.ts.map +1 -1
  10. package/dist/ensure-built.js +19 -5
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +4 -0
  13. package/dist/owned-installation.d.ts +6 -5
  14. package/dist/owned-installation.d.ts.map +1 -1
  15. package/dist/owned-installation.js +324 -201
  16. package/dist/test-walk-policy.d.ts +8 -0
  17. package/dist/test-walk-policy.d.ts.map +1 -1
  18. package/dist/test-walk-policy.js +34 -0
  19. package/dist/workspace-manifest.d.ts +5 -5
  20. package/dist/workspace-manifest.d.ts.map +1 -1
  21. package/managed/raw/patches/nx@23.2.1.patch +14 -3
  22. package/managed/raw/tooling/direnv/developer-links.ts +37 -10
  23. package/managed/raw/tooling/direnv/linked-snapshots.ts +31 -4
  24. package/managed/raw/tooling/direnv/setup-environment.ts +2 -0
  25. package/managed/raw/tooling/git-hooks/pre-push.sh +34 -11
  26. package/package.json +3 -3
  27. package/runtime-input.sh +21 -9
  28. package/src/__tests__/cargo-closure-filesets.ts +94 -0
  29. package/src/__tests__/owned-installation.ts +5 -6
  30. package/src/bin/smoo-nx-test-clocks.ts +2 -2
  31. package/src/bin/smoo-nx-test-walks.ts +6 -9
  32. package/src/cargo-closure-filesets.test.ts +63 -0
  33. package/src/cargo-closure-input.test.ts +1 -1
  34. package/src/cargo-closure-input.ts +23 -15
  35. package/src/cargo-closure-key.test.ts +1 -1
  36. package/src/cargo-resolve-cache.test.ts +1 -1
  37. package/src/cross-check-policy.test.ts +53 -12
  38. package/src/ensure-built-witness.test.ts +53 -2
  39. package/src/ensure-built-witness.ts +103 -18
  40. package/src/ensure-built.test.ts +40 -5
  41. package/src/ensure-built.ts +28 -6
  42. package/src/index.ts +4 -0
  43. package/src/linked-snapshots.nx.test.ts +1 -1
  44. package/src/nextest-partitions.test.ts +1 -1
  45. package/src/nx-daemon-validity.test.ts +51 -0
  46. package/src/owned-installation.test.ts +105 -0
  47. package/src/owned-installation.ts +335 -93
  48. package/src/runtime-input.test.ts +22 -1
  49. package/src/task-results.test.ts +1 -1
  50. package/src/test-walk-policy.test.ts +35 -0
  51. package/src/test-walk-policy.ts +32 -0
  52. package/src/workspace-manifest.ts +5 -5
  53. package/test-timings.json +94 -92
@@ -5,7 +5,7 @@ import { createRequire } from 'node:module';
5
5
  import { dirname, isAbsolute, join, resolve } from 'node:path';
6
6
  import { inspect } from 'node:util';
7
7
  import { boundedReceiptRuntimes } from './ensure-built-receipt.js';
8
- import { censusStart, graphInstallationIdentity, movedNodes, nodeStamp, nodesUnchanged, readArtifactWitness, readGraphWitness, recordedStamp, reusableGraph, snapshotsEqual, workspaceSnapshot, writeWitness, } from './ensure-built-witness.js';
8
+ import { censusStart, graphInstallationIdentity, installationIdentityOf, movedNodes, nodeStamp, nodesUnchanged, provenInstallationCensus, readArtifactWitness, readGraphWitness, recordedInstallationCensus, recordedStamp, reusableGraph, snapshotsEqual, workspaceSnapshot, writeWitness, } from './ensure-built-witness.js';
9
9
  import { graphInputContractIdentity } from './graph-input-contract.js';
10
10
  import { managedAssetsRoot } from './managed-assets.js';
11
11
  import { readProducerReceipt } from './producer-receipts.js';
@@ -637,7 +637,11 @@ async function currentProjectGraph(workspaceRoot, nxJson, requireNx, forceGraphR
637
637
  await daemonClient.updateWorkspaceContext(created, updated, deleted);
638
638
  }
639
639
  performance.measure('ensureBuilt:inputs', 'ensureBuilt:inputs:start');
640
- const installation = graphInstallationIdentity(workspaceRoot, nxJson, packageResolution.readModulePackageJson, expandOutputs, graphInputContractIdentity(workspaceRoot, nxJson, before));
640
+ // The witness's census is a hash source: a file whose proven stamp has not moved since it was read is not read again.
641
+ const recorded = witness === null ? undefined : recordedInstallationCensus(witness.installation, witness.installationUnproven);
642
+ const localInputs = graphInputContractIdentity(workspaceRoot, nxJson, before);
643
+ const census = provenInstallationCensus(workspaceRoot, nxJson, packageResolution.readModulePackageJson, expandOutputs, localInputs, undefined, recorded);
644
+ const installation = census === null ? null : installationIdentityOf(census, localInputs);
641
645
  const cached = nodesUnchanged(before.nodes)
642
646
  ? reusableGraph(witness, workspaceRoot, environment, installation, before)
643
647
  : null;
@@ -645,12 +649,22 @@ async function currentProjectGraph(workspaceRoot, nxJson, requireNx, forceGraphR
645
649
  return cached;
646
650
  const { projectGraph } = await daemonClient.getProjectGraphAndSourceMaps();
647
651
  const after = workspaceSnapshot(workspaceRoot, new WorkspaceContext(workspaceRoot, data), before);
648
- const finalInstallation = graphInstallationIdentity(workspaceRoot, nxJson, packageResolution.readModulePackageJson, expandOutputs, graphInputContractIdentity(workspaceRoot, nxJson, after));
652
+ const finalInputs = graphInputContractIdentity(workspaceRoot, nxJson, after);
653
+ const finalCensus = provenInstallationCensus(workspaceRoot, nxJson, packageResolution.readModulePackageJson, expandOutputs, finalInputs, undefined, census ?? recorded);
654
+ const finalInstallation = finalCensus === null ? null : installationIdentityOf(finalCensus, finalInputs);
649
655
  // `after` re-hashed every node whose stamp does not prove it (its ctime alone moved, or `before` read it in the tick
650
656
  // it changed in), and snapshotsEqual compares those hashes.
651
657
  const stableGeneration = snapshotsEqual(before, after) && movedNodes(before.nodes, () => true) === null;
652
- if (installation !== null && installation === finalInstallation && stableGeneration) {
653
- const next = { version: 1, workspaceRoot, environment, installation, snapshot: after, projectGraph };
658
+ if (installation !== null && finalCensus !== null && installation === finalInstallation && stableGeneration) {
659
+ const next = {
660
+ version: 2,
661
+ workspaceRoot,
662
+ environment,
663
+ installation,
664
+ installationUnproven: finalCensus.unproven,
665
+ snapshot: after,
666
+ projectGraph,
667
+ };
654
668
  writeWitness(witnessPath, next);
655
669
  }
656
670
  // A write during the await cannot authorize a saved graph. Feed the final
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAkBlC,OAAO,EAKL,yBAAyB,EAiB1B,MAAM,sBAAsB,CAAC;AAsB9B,OAAO,EACL,KAAK,uBAAuB,EAG7B,MAAM,wBAAwB,CAAC;AAahC,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,gEAAgE;AAChE,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAmyBlD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,UAAsB,GAC9B,MAAM,EAAE,CAKV;AAkID,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC;AAeF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,uBAAuB,CAIxE,CAAC;AACF,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,CAAC,uBAAuB,CAI1E,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAkBlC,OAAO,EAKL,yBAAyB,EAiB1B,MAAM,sBAAsB,CAAC;AAsB9B,OAAO,EACL,KAAK,uBAAuB,EAG7B,MAAM,wBAAwB,CAAC;AAchC,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,gEAAgE;AAChE,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAmyBlD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,UAAsB,GAC9B,MAAM,EAAE,CAKV;AAkID,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC;AAeF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,uBAAuB,CAOxE,CAAC;AACF,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,CAAC,uBAAuB,CAI1E,CAAC"}
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ import { runtimeInput, shellWord } from './runtime-input.js';
20
20
  import { isNonSourceDirectory } from './source-directories.js';
21
21
  import { postTasksExecution as postTaskResults, preTasksExecution as preTaskResults } from './task-results.js';
22
22
  import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite } from './test-timings.js';
23
+ import { assertUpstreamBasePrecondition } from './test-walk-policy.js';
23
24
  import { isBuildOutputTargetName, isTestRunnerTargetName, PLATFORM_TARGET_GLOBS, RELEASE_CONFIGURATION, } from './workspace-config-policy.js';
24
25
  import { globIndexedFiles } from './workspace-index.js';
25
26
  export { CARGO_TEST_COMPILE_TARGET };
@@ -841,6 +842,9 @@ function isBuildOutputPackageJson(packageJsonPath) {
841
842
  * (`run-cpu-pool.ts`), and closes it when the run ends.
842
843
  */
843
844
  export const preTasksExecution = async (options, context) => {
845
+ // Before any task is hashed: a workspace that declares the test-walk check
846
+ // must be able to name its upstream base, or the run fails with that reason.
847
+ assertUpstreamBasePrecondition(context.workspaceRoot);
844
848
  preTaskResults(options, context);
845
849
  await preProducerReceipts(options, context);
846
850
  await serveRunCpuPool(context);
@@ -1,4 +1,4 @@
1
- /** One test file's installation: made on first use and shared by its fixtures, retired by the file's `afterAll`. */
1
+ /** One test file's installation: taken on first use and shared by its fixtures, retired by the file's `afterAll`. */
2
2
  export interface TestFileInstallation {
3
3
  /** The `node_modules` a fixture workspace links. */
4
4
  readonly nodeModules: () => Promise<string>;
@@ -6,9 +6,10 @@ export interface TestFileInstallation {
6
6
  readonly retire: () => Promise<void>;
7
7
  }
8
8
  /**
9
- * The installation one test file owns: a copy of the closure `censusRoot` (the workspace whose Nx, plugin and
10
- * TypeScript the fixtures stand for) resolves, made in the empty directory `makeRoot` creates on first use. Call once
11
- * per file, at module scope: Bun runs many test files in one process, and each must own its copy.
9
+ * The installation one test file owns: the copy of the closure `censusRoot` (the workspace whose Nx, plugin and
10
+ * TypeScript the fixtures stand for) resolves, kept as `name` in `censusRoot`'s tool cache and proved on first use.
11
+ * Call once per file, at module scope, with a name no other file uses: Bun runs many test files in one process, and
12
+ * each must own its copy. Two runs of one file at once share it, and a copy one of them makes again fails the other.
12
13
  */
13
- export declare function ownedInstallation(censusRoot: string, makeRoot: () => Promise<string>): TestFileInstallation;
14
+ export declare function ownedInstallation(censusRoot: string, name: string): TestFileInstallation;
14
15
  //# sourceMappingURL=owned-installation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"owned-installation.d.ts","sourceRoot":"","sources":["../src/owned-installation.ts"],"names":[],"mappings":"AAqJA,oHAAoH;AACpH,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,oBAAoB,CAW3G"}
1
+ {"version":3,"file":"owned-installation.d.ts","sourceRoot":"","sources":["../src/owned-installation.ts"],"names":[],"mappings":"AAsYA,qHAAqH;AACrH,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAWxF"}