@zukhruf/git-hooks 0.8.19 → 0.8.21

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 (65) hide show
  1. package/dist/build.d.ts +1 -1
  2. package/dist/build.d.ts.map +1 -1
  3. package/dist/build.js +44 -46
  4. package/dist/build.js.map +1 -1
  5. package/dist/codegen.d.ts.map +1 -1
  6. package/dist/codegen.js +41 -8
  7. package/dist/codegen.js.map +1 -1
  8. package/dist/commit.d.ts +30 -2
  9. package/dist/commit.d.ts.map +1 -1
  10. package/dist/commit.js +261 -22
  11. package/dist/commit.js.map +1 -1
  12. package/dist/git.d.ts +3 -0
  13. package/dist/git.d.ts.map +1 -0
  14. package/dist/git.js +20 -0
  15. package/dist/git.js.map +1 -0
  16. package/dist/index.d.ts +2 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/npm/lockfile.d.ts +14 -0
  20. package/dist/npm/lockfile.d.ts.map +1 -0
  21. package/dist/npm/lockfile.js +77 -0
  22. package/dist/npm/lockfile.js.map +1 -0
  23. package/dist/push.d.ts +14 -7
  24. package/dist/push.d.ts.map +1 -1
  25. package/dist/push.js +26 -82
  26. package/dist/push.js.map +1 -1
  27. package/dist/ref-update.d.ts +1 -1
  28. package/dist/ref-update.d.ts.map +1 -1
  29. package/dist/scripts/commit-msg.d.ts.map +1 -1
  30. package/dist/scripts/commit-msg.js +9 -15
  31. package/dist/scripts/commit-msg.js.map +1 -1
  32. package/dist/scripts/host.d.ts +10 -0
  33. package/dist/scripts/host.d.ts.map +1 -0
  34. package/dist/scripts/host.js +37 -0
  35. package/dist/scripts/host.js.map +1 -0
  36. package/dist/scripts/pre-commit.d.ts.map +1 -1
  37. package/dist/scripts/pre-commit.js +35 -13
  38. package/dist/scripts/pre-commit.js.map +1 -1
  39. package/dist/scripts/pre-push.d.ts.map +1 -1
  40. package/dist/scripts/pre-push.js +24 -24
  41. package/dist/scripts/pre-push.js.map +1 -1
  42. package/dist/snapshot/drift.d.ts +0 -2
  43. package/dist/snapshot/drift.d.ts.map +1 -1
  44. package/dist/snapshot/drift.js +5 -57
  45. package/dist/snapshot/drift.js.map +1 -1
  46. package/dist/snapshot/installs.d.ts +1 -0
  47. package/dist/snapshot/installs.d.ts.map +1 -1
  48. package/dist/snapshot/installs.js +85 -29
  49. package/dist/snapshot/installs.js.map +1 -1
  50. package/dist/snapshot/snapshot.d.ts +21 -0
  51. package/dist/snapshot/snapshot.d.ts.map +1 -0
  52. package/dist/snapshot/snapshot.js +52 -0
  53. package/dist/snapshot/snapshot.js.map +1 -0
  54. package/dist/snapshot/snapshots.d.ts +30 -0
  55. package/dist/snapshot/snapshots.d.ts.map +1 -0
  56. package/dist/snapshot/snapshots.js +181 -0
  57. package/dist/snapshot/snapshots.js.map +1 -0
  58. package/dist/sync.d.ts.map +1 -1
  59. package/dist/sync.js +16 -16
  60. package/dist/sync.js.map +1 -1
  61. package/dist/tree.d.ts +24 -0
  62. package/dist/tree.d.ts.map +1 -0
  63. package/dist/tree.js +96 -0
  64. package/dist/tree.js.map +1 -0
  65. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"pre-push.d.ts","sourceRoot":"","sources":["../../src/scripts/pre-push.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOvC,wBAAsB,OAAO,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BzE"}
1
+ {"version":3,"file":"pre-push.d.ts","sourceRoot":"","sources":["../../src/scripts/pre-push.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOvC,wBAAsB,OAAO,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BzE"}
@@ -1,36 +1,36 @@
1
- import { text } from 'node:stream/consumers';
1
+ import { gitIn } from "../git.js";
2
2
  import { Push } from "../push.js";
3
- // What a repo's `.husky/pre-push.ts` calls. Git runs the hook at the root of
4
- // the work tree, with the name and the URL of the remote as arguments and one
5
- // ref update on each line of the standard input. This is the one module that
6
- // prints and reads the arguments, the input and the environment, as a script
7
- // may.
3
+ import { Snapshots } from "../snapshot/snapshots.js";
4
+ import { Host } from "./host.js";
5
+ // What a repo's `.husky/pre-push.ts` calls. Git gives the hook the name and
6
+ // the URL of the remote as arguments, and one ref update on each line of the
7
+ // standard input. The snapshots that the steps open are deleted after the
8
+ // last step, also when a step fails or throws.
8
9
  export async function prePush(steps) {
10
+ const host = new Host();
9
11
  let current = '';
10
- const print = (name, message) => {
11
- const [first = '', ...rest] = message.split('\n');
12
- console.error(`${name.padEnd(9)} ${first}`);
13
- for (const line of rest)
14
- console.error(`${' '.repeat(10)}${line}`);
15
- };
16
- const [name = '', url = ''] = process.argv.slice(2);
12
+ const [name = '', url = ''] = host.arguments;
13
+ await using snapshots = new Snapshots({
14
+ hook: 'pre-push',
15
+ root: host.root,
16
+ git: gitIn(host.root, host.hookEnvironment),
17
+ toolEnvironment: await host.toolEnvironment(),
18
+ notice: (message) => host.print(current, message),
19
+ clock: globalThis,
20
+ });
17
21
  const push = await Push.read({
18
- root: process.cwd(),
19
- environment: process.env,
22
+ root: host.root,
23
+ environment: host.hookEnvironment,
24
+ snapshots,
20
25
  remote: { name, url },
21
- input: await text(process.stdin),
22
- notice: (message) => print(current, message),
23
- clock: globalThis,
26
+ input: await host.input(),
24
27
  });
25
28
  for (const step of steps) {
26
29
  current = step.name;
27
30
  const outcome = await step.run(push);
28
- print(step.name, outcome.message);
29
- if (outcome.kind === 'fail') {
30
- console.error('✖ push stopped by the pre-push hook');
31
- process.exitCode = 1;
32
- return;
33
- }
31
+ host.print(step.name, outcome.message);
32
+ if (outcome.kind === 'fail')
33
+ return host.stop('push stopped by the pre-push hook');
34
34
  }
35
35
  }
36
36
  //# sourceMappingURL=pre-push.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pre-push.js","sourceRoot":"","sources":["../../src/scripts/pre-push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlC,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,OAAO;AACP,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,KAA4B;IACxD,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE;QAC9C,MAAM,CAAC,KAAK,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClD,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;QAC5C,KAAK,MAAM,IAAI,IAAI,IAAI;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC;IACF,MAAM,CAAC,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;QAC3B,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;QACnB,WAAW,EAAE,OAAO,CAAC,GAAG;QACxB,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE;QACrB,KAAK,EAA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QAChB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC;QAC3C,eAAe,EAAE,MAAM,IAAI,CAAC,eAAe,EAAE;QAC7C,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;QACjD,KAAK,EAAE,UAAU;KAClB,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;QAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,eAAe;QACjC,SAAS;QACT,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE;QACrB,KAAK,EAAE,MAAM,IAAI,CAAC,KAAK,EAAE;KAC1B,CAAC,CAAC;IACH,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;QACpB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;YACzB,OAAO,IAAI,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
@@ -1,4 +1,2 @@
1
1
  export declare function hasInstallDrift(lockfile: string, hiddenLockfile: string): Promise<boolean>;
2
- export declare function linkTargets(lockfile: string): Promise<string[]>;
3
- export declare function withInstallScripts(lockfile: string): Promise<string[]>;
4
2
  //# sourceMappingURL=drift.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../../src/snapshot/drift.ts"],"names":[],"mappings":"AAcA,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC,CAmBlB;AAsBD,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQrE;AAsBD,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQ5E"}
1
+ {"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../../src/snapshot/drift.ts"],"names":[],"mappings":"AASA,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC,CAoBlB"}
@@ -1,20 +1,22 @@
1
1
  import { readFile } from 'node:fs/promises';
2
+ import { Lockfile } from "../npm/lockfile.js";
2
3
  // Whether the installed packages differ from the lockfile of a commit. npm's
3
4
  // hidden lockfile, node_modules/.package-lock.json, lists what is installed.
4
5
  // Each difference in the third-party packages is drift: a missing package, a
5
6
  // different version, or an extra package, which would build here and fail in
6
7
  // CI. Links are not compared: a workspace link points into the snapshot.
7
8
  export async function hasInstallDrift(lockfile, hiddenLockfile) {
8
- const wanted = await packagesOf(lockfile);
9
- let installed;
9
+ const wanted = Lockfile.parse(await readFile(lockfile, 'utf8')).thirdParty();
10
+ let hidden;
10
11
  try {
11
- installed = await packagesOf(hiddenLockfile);
12
+ hidden = await readFile(hiddenLockfile, 'utf8');
12
13
  }
13
14
  catch (error) {
14
15
  if (Error.isError(error) && 'code' in error && error.code === 'ENOENT')
15
16
  return true;
16
17
  throw error;
17
18
  }
19
+ const installed = Lockfile.parse(hidden).thirdParty();
18
20
  for (const [path, entry] of wanted) {
19
21
  const have = installed.get(path);
20
22
  if (have === undefined) {
@@ -30,58 +32,4 @@ export async function hasInstallDrift(lockfile, hiddenLockfile) {
30
32
  return true;
31
33
  return false;
32
34
  }
33
- // The third-party packages of a lockfile: the entries in a node_modules
34
- // folder that are not links.
35
- async function packagesOf(path) {
36
- const entries = new Map();
37
- for (const [key, value] of await lockPackages(path)) {
38
- if (!key.includes('node_modules/'))
39
- continue;
40
- const entry = {
41
- version: field(value, 'version'),
42
- link: field(value, 'link') === true,
43
- optional: field(value, 'optional') === true,
44
- hasInstallScript: field(value, 'hasInstallScript') === true,
45
- };
46
- if (!entry.link)
47
- entries.set(key, entry);
48
- }
49
- return entries;
50
- }
51
- // The folders that the links of a lockfile point to, relative to the folder
52
- // of the lockfile: the workspace packages, and each folder that a `file:`
53
- // dependency names.
54
- export async function linkTargets(lockfile) {
55
- const targets = new Set();
56
- for (const [, value] of await lockPackages(lockfile)) {
57
- const resolved = field(value, 'resolved');
58
- if (field(value, 'link') === true && typeof resolved === 'string')
59
- targets.add(resolved);
60
- }
61
- return [...targets];
62
- }
63
- async function lockPackages(path) {
64
- const lockfile = JSON.parse(await readFile(path, 'utf8'));
65
- const packages = typeof lockfile === 'object' && lockfile !== null && 'packages' in lockfile
66
- ? lockfile.packages
67
- : undefined;
68
- if (typeof packages !== 'object' || packages === null)
69
- throw new TypeError(`${path} has no "packages"; npm 7 or later writes it`);
70
- return Object.entries(packages);
71
- }
72
- function field(value, name) {
73
- return typeof value === 'object' && value !== null && name in value
74
- ? Reflect.get(value, name)
75
- : undefined;
76
- }
77
- // The third-party packages that the lockfile marks with an install script.
78
- // The root and the workspace packages have the mark too, but their scripts
79
- // must not run in the state folder.
80
- export async function withInstallScripts(lockfile) {
81
- const names = new Set();
82
- for (const [key, entry] of await packagesOf(lockfile))
83
- if (entry.hasInstallScript)
84
- names.add(key.slice(key.lastIndexOf('node_modules/') + 'node_modules/'.length));
85
- return [...names];
86
- }
87
35
  //# sourceMappingURL=drift.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drift.js","sourceRoot":"","sources":["../../src/snapshot/drift.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAS5C,6EAA6E;AAC7E,6EAA6E;AAC7E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,UAAU,eAAe,CACnC,QAAgB,EAChB,cAAsB;IAEtB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IAC7E,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;YACpE,OAAO,IAAI,CAAC;QACd,MAAM,KAAK,CAAC;IACd,CAAC;IACD,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;IACtD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,gEAAgE;YAChE,IAAI,CAAC,KAAK,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAC;QACnC,CAAC;aAAM,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;IACzD,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE;QAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IACxE,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,3 +1,4 @@
1
+ export declare function leaseInstall(folder: string): Disposable;
1
2
  export declare function installFor(state: string, snapshot: string, environment: NodeJS.ProcessEnv, installing: () => void, clock: {
2
3
  readonly Date: {
3
4
  now(): number;
@@ -1 +1 @@
1
- {"version":3,"file":"installs.d.ts","sourceRoot":"","sources":["../../src/snapshot/installs.ts"],"names":[],"mappings":"AA+BA,wBAAsB,UAAU,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,CAAC,UAAU,EAC9B,UAAU,EAAE,MAAM,IAAI,EACtB,KAAK,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE;QAAE,GAAG,IAAI,MAAM,CAAA;KAAE,CAAA;CAAE,GAC1C,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
1
+ {"version":3,"file":"installs.d.ts","sourceRoot":"","sources":["../../src/snapshot/installs.ts"],"names":[],"mappings":"AAkCA,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CASvD;AAOD,wBAAsB,UAAU,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,CAAC,UAAU,EAC9B,UAAU,EAAE,MAAM,IAAI,EACtB,KAAK,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE;QAAE,GAAG,IAAI,MAAM,CAAA;KAAE,CAAA;CAAE,GAC1C,OAAO,CAAC,MAAM,CAAC,CAcjB"}
@@ -1,25 +1,41 @@
1
1
  import { execFile } from 'node:child_process';
2
- import { hash } from 'node:crypto';
3
- import { existsSync } from 'node:fs';
4
- import { copyFile, cp, mkdir, readFile, readdir, rm, stat, utimes, writeFile, } from 'node:fs/promises';
2
+ import { hash, randomUUID } from 'node:crypto';
3
+ import { existsSync, mkdirSync, rmSync } from 'node:fs';
4
+ import { cp, mkdir, readFile, readdir, rm, stat, utimes, writeFile, } from 'node:fs/promises';
5
5
  import { basename, isAbsolute, join, normalize, sep } from 'node:path';
6
6
  import { promisify } from 'node:util';
7
- import { linkTargets, withInstallScripts } from "./drift.js";
7
+ import { FileLock } from '@zukhruf/fs';
8
+ import { Lockfile } from "../npm/lockfile.js";
8
9
  import { workspaceFolders } from "./workspaces.js";
9
10
  const execFileAsync = promisify(execFile);
10
11
  // The installs that the hook keeps: the ones that it used last.
11
12
  const kept = 2;
12
13
  // Written last, so a folder without it is an install that did not end.
13
14
  const marker = 'installed';
15
+ // One locked file in it for each snapshot that links to the install.
16
+ const leases = 'leases';
17
+ // Marks the install at `folder` as in use until the lease is disposed. The
18
+ // kernel holds the lock of the lease file, so a hook that dies lets it go.
19
+ // Take it under the lock of the installs, so no prune runs between the
20
+ // install and the lease.
21
+ export function leaseInstall(folder) {
22
+ mkdirSync(join(folder, leases), { recursive: true });
23
+ const path = join(folder, leases, `${randomUUID()}.lock`);
24
+ const lease = new DisposableStack();
25
+ const lock = lease.use(FileLock.open(path));
26
+ if (!lock.tryLock())
27
+ throw new Error(`another process holds the new lease ${path}`);
28
+ lease.defer(() => rmSync(path, { force: true }));
29
+ return lease;
30
+ }
14
31
  // An install of the lockfile of the snapshot in a folder of the state folder,
15
- // named by the hash of the lockfile. A second push with the same lockfile
16
- // uses the same install, with the linked folders of the snapshot. `installing`
17
- // runs before a new install, because a full install takes some time.
32
+ // named by the hash of the lockfile and the .npmrc. A second snapshot with the
33
+ // same two files uses the same install, with the linked folders of the
34
+ // snapshot. `installing` runs before a new install, because a full install
35
+ // takes some time. npm gets `environment`: the tool environment.
18
36
  export async function installFor(state, snapshot, environment, installing, clock) {
19
- const lockfile = await readFile(join(snapshot, 'package-lock.json'));
20
- const lockfileHash = hash('sha256', lockfile);
21
37
  const installs = join(state, 'installs');
22
- const folder = join(installs, lockfileHash.slice(0, 16));
38
+ const folder = join(installs, (await installKey(snapshot)).slice(0, 16));
23
39
  if (existsSync(join(folder, marker))) {
24
40
  const now = new Date(clock.Date.now());
25
41
  await utimes(join(folder, marker), now, now);
@@ -33,6 +49,22 @@ export async function installFor(state, snapshot, environment, installing, clock
33
49
  await prune(installs);
34
50
  return folder;
35
51
  }
52
+ // The sha256 of the lockfile and the .npmrc, with a NUL between them: a
53
+ // lockfile is JSON, which holds no NUL, so no two pairs of files give the
54
+ // same bytes. A snapshot without .npmrc hashes it as empty.
55
+ async function installKey(snapshot) {
56
+ const lockfile = await readFile(join(snapshot, 'package-lock.json'));
57
+ let npmrc;
58
+ try {
59
+ npmrc = await readFile(join(snapshot, '.npmrc'));
60
+ }
61
+ catch (error) {
62
+ if (!Error.isError(error) || !('code' in error) || error.code !== 'ENOENT')
63
+ throw error;
64
+ npmrc = Buffer.alloc(0);
65
+ }
66
+ return hash('sha256', Buffer.concat([lockfile, Buffer.from([0]), npmrc]));
67
+ }
36
68
  // `npm ci --ignore-scripts`, and then `npm rebuild` with only the
37
69
  // third-party packages that have install scripts, such as esbuild. The
38
70
  // scripts of the repo and of its workspace packages, such as `prepare`,
@@ -40,38 +72,46 @@ export async function installFor(state, snapshot, environment, installing, clock
40
72
  // names, `npm rebuild` runs them too. npm 12 runs only the dependency
41
73
  // scripts that `allowScripts` in the copied package.json approves.
42
74
  async function install(snapshot, folder, environment) {
43
- await mkdir(folder, { recursive: true });
44
- for (const file of ['package.json', 'package-lock.json', '.npmrc'])
45
- if (existsSync(join(snapshot, file)))
46
- await copyFile(join(snapshot, file), join(folder, file));
47
- for (const workspace of await workspaceFolders(snapshot)) {
48
- await mkdir(join(folder, workspace), { recursive: true });
49
- await copyFile(join(snapshot, workspace, 'package.json'), join(folder, workspace, 'package.json'));
50
- }
51
- await copyLinkedFolders(snapshot, folder);
75
+ // The full tree of the commit, as a clean checkout has it: each file that
76
+ // npm reads, such as the patch files of `patchedDependencies`, a
77
+ // `.npm-extension.mjs`, the workspace manifests and the folders of `file:`
78
+ // dependencies. A link keeps its text, so it points into the install.
79
+ await cp(snapshot, folder, {
80
+ recursive: true,
81
+ verbatimSymlinks: true,
82
+ filter: (source) => !['.git', 'node_modules'].includes(basename(source)),
83
+ });
52
84
  await npm(folder, environment, 'ci', '--ignore-scripts', '--no-audit', '--no-fund');
53
- const names = await withInstallScripts(join(folder, 'package-lock.json'));
85
+ const names = Lockfile.parse(await readFile(join(folder, 'package-lock.json'), 'utf8')).withInstallScripts();
54
86
  if (names.length > 0)
55
87
  await npm(folder, environment, 'rebuild', ...names);
56
88
  await writeFile(join(folder, marker), '');
57
89
  }
58
90
  // Copies each folder of the snapshot that a `file:` dependency links to into
59
- // the install. A package of the install that depends on it resolves it from
60
- // its real path in the install, so a link from the snapshot does not reach it.
61
- // The lockfile, which names the install, does not change when the files of the
62
- // folder change, so each snapshot copies the folder again. The copy keeps the
63
- // node_modules that npm installed in the folder. A folder in node_modules is
64
- // npm's, and a folder outside the repo is not in the snapshot: neither is
65
- // copied.
91
+ // the install that the snapshot uses again. A package of the install that
92
+ // depends on it resolves it from its real path in the install, so a link from
93
+ // the snapshot does not reach it. The lockfile, which names the install, does
94
+ // not change when the files of the folder change, so each snapshot copies the
95
+ // folder again. The copy keeps the node_modules that npm installed in the
96
+ // folder. A folder in node_modules is npm's, a folder outside the repo is not
97
+ // in the snapshot, and a workspace package links to its folder in the
98
+ // snapshot: none of them is copied. A folder that the lockfile names and the
99
+ // commit does not have, such as a workspace that .gitignore names, is not
100
+ // copied either (#4193).
66
101
  async function copyLinkedFolders(snapshot, folder) {
67
102
  const workspaces = new Set((await workspaceFolders(snapshot)).map(normalize));
68
- for (const target of await linkTargets(join(snapshot, 'package-lock.json'))) {
103
+ const lockfile = Lockfile.parse(await readFile(join(snapshot, 'package-lock.json'), 'utf8'));
104
+ for (const target of lockfile.linkTargets()) {
69
105
  const path = normalize(target);
70
106
  if (workspaces.has(path) ||
71
107
  path.startsWith('..') ||
72
108
  isAbsolute(path) ||
73
109
  path.split(sep).includes('node_modules'))
74
110
  continue;
111
+ // The copy first empties the folder of the install, so the source is
112
+ // checked before.
113
+ if (!existsSync(join(snapshot, path)))
114
+ continue;
75
115
  const destination = join(folder, path);
76
116
  await mkdir(destination, { recursive: true });
77
117
  for (const name of await readdir(destination))
@@ -108,7 +148,23 @@ async function prune(installs) {
108
148
  })));
109
149
  used.sort((left, right) => right.at - left.at);
110
150
  for (const [index, { name, at }] of used.entries())
111
- if (index >= kept || at < 0)
151
+ if ((index >= kept || at < 0) && !(await isLeased(join(installs, name))))
112
152
  await rm(join(installs, name), { recursive: true, force: true });
113
153
  }
154
+ // Whether a live snapshot links to the install. Only an install that the
155
+ // prune would delete is checked: the install that this process uses is the
156
+ // one it used last, which the prune keeps. That matters, because reading a
157
+ // lease file that this process holds would drop its lock (FileLock).
158
+ async function isLeased(folder) {
159
+ let names;
160
+ try {
161
+ names = await readdir(join(folder, leases));
162
+ }
163
+ catch (error) {
164
+ if (Error.isError(error) && 'code' in error && error.code === 'ENOENT')
165
+ return false;
166
+ throw error;
167
+ }
168
+ return names.some((name) => FileLock.check(join(folder, leases, name)) === 'locked');
169
+ }
114
170
  //# sourceMappingURL=installs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"installs.js","sourceRoot":"","sources":["../../src/snapshot/installs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACL,QAAQ,EACR,EAAE,EACF,KAAK,EACL,QAAQ,EACR,OAAO,EACP,EAAE,EACF,IAAI,EACJ,MAAM,EACN,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,gEAAgE;AAChE,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,u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
5
+ readonly stderr: string;
6
+ }
7
+ export interface RunOptions {
8
+ readonly env?: Readonly<Record<string, string>>;
9
+ }
10
+ export declare class Snapshot {
11
+ #private;
12
+ readonly folder: string;
13
+ constructor(clone: Clone);
14
+ run(command: string, args: readonly string[], options?: RunOptions): Promise<ProcessResult>;
15
+ }
16
+ export declare class PackagedSnapshot extends Snapshot {
17
+ readonly nxCacheDirectory: string;
18
+ constructor(clone: Clone);
19
+ bin(name: string, args: readonly string[], options?: RunOptions): Promise<ProcessResult>;
20
+ }
21
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/snapshot/snapshot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAI5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAKD,qBAAa,QAAQ;;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGZ,KAAK,EAAE,KAAK;IAUlB,GAAG,CACP,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,aAAa,CAAC;CAiB1B;AAID,qBAAa,gBAAiB,SAAQ,QAAQ;IAE5C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;gBAEtB,KAAK,EAAE,KAAK;IAOxB,GAAG,CACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,aAAa,CAAC;CAW1B"}
@@ -0,0 +1,52 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { join } from 'node:path';
3
+ import { text } from 'node:stream/consumers';
4
+ // A commit checked out in a temporary folder, where a step runs its tools.
5
+ // Git there sees a clean checkout of the commit. Each command gets the tool
6
+ // environment, with NX_DAEMON=false and the nx cache of the state folder.
7
+ export class Snapshot {
8
+ folder;
9
+ #environment;
10
+ constructor(clone) {
11
+ this.folder = clone.folder;
12
+ this.#environment = clone.environment;
13
+ }
14
+ // Runs a command from the PATH, or a file at an absolute path, in the
15
+ // snapshot. An exit code other than 0 is a result, not an error. A command
16
+ // that cannot start throws the error of Node. No shell runs, except for a
17
+ // .cmd file on Windows, which only a shell runs; its arguments then get no
18
+ // quotes.
19
+ async run(command, args, options = {}) {
20
+ const child = spawn(command, args, {
21
+ cwd: this.folder,
22
+ env: { ...this.#environment, ...options.env },
23
+ stdio: ['ignore', 'pipe', 'pipe'],
24
+ shell: process.platform === 'win32' && command.endsWith('.cmd'),
25
+ });
26
+ const [stdout, stderr, status] = await Promise.all([
27
+ text(child.stdout),
28
+ text(child.stderr),
29
+ new Promise((resolve, reject) => {
30
+ child.once('error', reject);
31
+ child.once('close', resolve);
32
+ }),
33
+ ]);
34
+ return { status, stdout, stderr };
35
+ }
36
+ }
37
+ // A snapshot with a node_modules: the packages of the commit's own lockfile,
38
+ // and each workspace package from its folder in the snapshot.
39
+ export class PackagedSnapshot extends Snapshot {
40
+ // The nx cache of the state folder, where nx writes the summary of its run.
41
+ nxCacheDirectory;
42
+ constructor(clone) {
43
+ super(clone);
44
+ this.nxCacheDirectory = clone.nxCacheDirectory;
45
+ }
46
+ // Runs `node_modules/.bin/<name>` of the snapshot, as `run` does. On
47
+ // Windows, npm writes `<name>.cmd` there.
48
+ bin(name, args, options = {}) {
49
+ return this.run(join(this.folder, 'node_modules/.bin', process.platform === 'win32' ? `${name}.cmd` : name), args, options);
50
+ }
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AAE,MAAM,EAAE,EAAE;gBAC7C,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBAC5B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/B,CAAC,CAAC;SACH,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC;CACF;AAED,6EAA6E;AAC7E,8DAA8D;AAC9D,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IAC5C,4EAA4E;IACnE,gBAAgB,CAAS;IAElC,YAAY,KAAY;QACtB,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACjD,CAAC;IAED,qEAAqE;IACrE,0CAA0C;IAC1C,GAAG,CACD,IAAY,EACZ,IAAuB,EACvB,UAAsB,EAAE;QAExB,OAAO,IAAI,CAAC,GAAG,CACb,IAAI,CACF,IAAI,CAAC,MAAM,EACX,mBAAmB,EACnB,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CACpD,EACD,IAAI,EACJ,OAAO,CACR,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import { type WallClock } from '@zukhruf/async';
2
+ import { type Git } from '../git.ts';
3
+ export declare class MissingLockfileError extends Error {
4
+ constructor(commit: string);
5
+ }
6
+ export interface Clone {
7
+ readonly folder: string;
8
+ readonly environment: NodeJS.ProcessEnv;
9
+ readonly nxCacheDirectory: string;
10
+ }
11
+ export type HookKind = 'pre-commit' | 'pre-push';
12
+ interface SnapshotsOptions {
13
+ readonly hook: HookKind;
14
+ readonly root: string;
15
+ readonly git: Git;
16
+ readonly toolEnvironment: NodeJS.ProcessEnv;
17
+ readonly notice: (message: string) => void;
18
+ readonly clock: WallClock;
19
+ }
20
+ export declare function stateFolder(git: Git): Promise<string>;
21
+ export declare class Snapshots implements AsyncDisposable {
22
+ #private;
23
+ readonly toolEnvironment: NodeJS.ProcessEnv;
24
+ constructor({ hook, root, git, toolEnvironment, notice, clock, }: SnapshotsOptions);
25
+ open(commit: string, name: string, packages: boolean): Promise<Clone>;
26
+ openPrivate(commit: string, name: string): Promise<Clone & AsyncDisposable>;
27
+ [Symbol.asyncDispose](): Promise<void>;
28
+ }
29
+ export {};
30
+ //# sourceMappingURL=snapshots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshots.d.ts","sourceRoot":"","sources":["../../src/snapshot/snapshots.ts"],"names":[],"mappings":"AAKA,OAAO,EAAS,KAAK,SAAS,EAAQ,MAAM,gBAAgB,CAAC;AAG7D,OAAO,EAAE,KAAK,GAAG,EAAS,MAAM,WAAW,CAAC;AAK5C,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,MAAM,EAAE,MAAM;CAI3B;AAGD,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AAmBD,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAEjD,UAAU,gBAAgB;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAExB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAElB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,UAAU,CAAC;IAE5C,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAG3C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAKD,wBAAsB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAS3D;AA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