@_linked/cli 1.47.0 → 1.47.1
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/CHANGELOG.md +6 -0
- package/README.md +0 -4
- package/lib/esm/localize/delocalize.d.ts.map +1 -1
- package/lib/esm/localize/delocalize.js +1 -2
- package/lib/esm/localize/delocalize.js.map +1 -1
- package/lib/esm/localize/list.d.ts.map +1 -1
- package/lib/esm/localize/list.js +1 -2
- package/lib/esm/localize/list.js.map +1 -1
- package/lib/esm/localize/localize.d.ts +0 -5
- package/lib/esm/localize/localize.d.ts.map +1 -1
- package/lib/esm/localize/localize.js +1 -14
- package/lib/esm/localize/localize.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.47.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#268](https://github.com/linked-fw/cli/pull/268) [`f4db679`](https://github.com/linked-fw/cli/commit/f4db679591afc51ba5f4a8313d37580c18ee62d9) Thanks [@flyon](https://github.com/flyon)! - `linked localize`, `--list` and `delocalize` no longer warn about a leftover `local-packages.json`. The file was never read by the workspace-based localize; delete it if one is still around. `docs/localize.md` drops its one-time migration section.
|
|
8
|
+
|
|
3
9
|
## 1.47.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -295,10 +295,6 @@ directory whose `package.json` has `workspaces`. It also writes git hooks into t
|
|
|
295
295
|
`script`, `call` and `build-all` report a range a checkout misses, a second copy of a localized
|
|
296
296
|
package, a nested copy of `@_linked/core`/`react`/`server-utils`, and a checkout that is gone.
|
|
297
297
|
|
|
298
|
-
`--relink` and `--ensure` are deprecated no-ops that exit 0; `local-packages.json` is no longer
|
|
299
|
-
read. Localize used to be the separate `@_linked/localize` package (binary `linked-localize`),
|
|
300
|
-
which is being retired; `linked localize` replaces it.
|
|
301
|
-
|
|
302
298
|
### Registry / dev utilities
|
|
303
299
|
|
|
304
300
|
```bash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delocalize.d.ts","sourceRoot":"","sources":["../../../src/localize/delocalize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delocalize.d.ts","sourceRoot":"","sources":["../../../src/localize/delocalize.ts"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,UAAU,CAAC;AAEnC,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAC,EACxC,IAAI,EAAE,IAAI,GACT,MAAM,CAmCR"}
|
|
@@ -26,10 +26,9 @@ import fs from 'node:fs';
|
|
|
26
26
|
import path from 'node:path';
|
|
27
27
|
import { EXIT_INSTALL_FAILED, EXIT_REFUSED, EXIT_WARNED } from './errors.js';
|
|
28
28
|
import { checkoutRepoRoot, existsOrLink, isInside, isSymlink, moveEntry, } from './fsops.js';
|
|
29
|
-
import { INSTALL_ARGS, LOCKFILE,
|
|
29
|
+
import { INSTALL_ARGS, LOCKFILE, reportError, restoreSetAside, tail, } from './localize.js';
|
|
30
30
|
import { LOCAL_DIR, PARKED_DIR, localMembers, parkedMembers } from './members.js';
|
|
31
31
|
export function delocalize(names, opts, deps) {
|
|
32
|
-
legacyManifestHint(deps);
|
|
33
32
|
try {
|
|
34
33
|
restoreSetAside(deps);
|
|
35
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delocalize.js","sourceRoot":"","sources":["../../../src/localize/delocalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAC,m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AK,IAAI,CAAC,CAAC;IACnD,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC","sourcesContent":["/**\n * `delocalize` -- go back to the registry copy WITHOUT losing work.\n *\n * A checkout is parked: moved to `.packages-local.parked/<dir>`, outside the\n * `packages-local/*` glob, so npm installs the registry copy again and\n * `linked localize <name>` (or `--parked`) takes it back as it was. With no\n * names, every checkout is parked.\n *\n * Then the install that swaps the links for registry copies:\n *\n * - no checkout left, `package-lock.json` tracked by git, and it and\n * `package.json` unchanged from HEAD: `npm ci`, which installs exactly the\n * committed lockfile;\n * - otherwise (some checkouts left -- `npm ci` refuses a lockfile that lists\n * members it does not -- an untracked lockfile, or a manifest being\n * changed): `npm install`, then `npm rebuild <names>` -- an install that\n * replaces a link with the registry copy leaves that package's bin without\n * its execute bit (measured), and a rebuild relinks it.\n *\n * `--purge` deletes the checkout instead of parking it. It fails closed:\n * unless `--force`, it refuses (exit 6) when the checkout is not a git\n * repository, when any git call fails, and on uncommitted changes, commits\n * that no remote has (on any branch or a detached HEAD), or a stash.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {EXIT_INSTALL_FAILED, EXIT_REFUSED, EXIT_WARNED} from './errors.js';\nimport {\n checkoutRepoRoot,\n existsOrLink,\n isInside,\n isSymlink,\n moveEntry,\n} from './fsops.js';\nimport {\n INSTALL_ARGS,\n LOCKFILE,\n legacyManifestHint,\n reportError,\n restoreSetAside,\n tail,\n} from './localize.js';\nimport {LOCAL_DIR, PARKED_DIR, localMembers, parkedMembers} from './members.js';\nimport type {Member} from './members.js';\nimport type {Deps} from './run.js';\n\nexport function delocalize(\n names: string[],\n opts: {purge?: boolean; force?: boolean},\n deps: Deps,\n): number {\n legacyManifestHint(deps);\n try {\n restoreSetAside(deps);\n } catch (e) {\n return reportError(e, deps);\n }\n const members = localMembers(deps.appRoot);\n let code = 0;\n const targets: Member[] = [];\n for (const name of names.length ? names : members.map((m) => m.name)) {\n const member = findMember(name, members);\n if (member) {\n targets.push(member);\n continue;\n }\n const parked = findMember(name, parkedMembers(deps.appRoot));\n deps.warn(\n parked\n ? `[localize] ${parked.name} is already parked in ${parked.dir}.`\n : `[localize] ${name} is not localized -- nothing in ${LOCAL_DIR}/ is named that.`,\n );\n code = Math.max(code, EXIT_WARNED);\n }\n\n const done: string[] = [];\n for (const member of targets) {\n if (opts.purge) {\n // A purge that is refused is a guard refusing: nothing is deleted.\n if (purge(member, opts, deps) === 'done') done.push(member.name);\n else code = Math.max(code, EXIT_REFUSED);\n } else if (park(member, deps) === 'done') done.push(member.name);\n else code = Math.max(code, EXIT_WARNED);\n }\n if (!done.length) return code;\n return Math.max(code, reinstall(done, deps));\n}\n\nfunction park(member: Member, deps: Deps): 'done' | 'refused' {\n const to = `${PARKED_DIR}/${path.basename(member.dir)}`;\n if (existsOrLink(path.join(deps.appRoot, to))) {\n deps.warn(\n `[localize] ${member.name}: ${to} already exists, so ${member.dir} was not parked. Move ` +\n `one of them out of the way.`,\n );\n return 'refused';\n }\n moveEntry(path.join(deps.appRoot, member.dir), path.join(deps.appRoot, to));\n deps.log(\n `[localize] parked ${member.name}: ${member.dir} -> ${to} (\\`linked localize ${member.name}\\` takes it back)`,\n );\n return 'done';\n}\n\nfunction purge(\n member: Member,\n opts: {force?: boolean},\n deps: Deps,\n): 'done' | 'refused' {\n const entry = path.join(deps.appRoot, member.dir);\n const repo = checkoutRepoRoot(entry, deps.appRoot);\n const refusal = repo\n ? purgeRefusal(repo, deps)\n : 'it is not a git checkout (no .git), so nothing says its work is saved elsewhere';\n if (refusal && !opts.force) {\n deps.warn(\n `[localize] ${member.dir}: not deleting -- ${refusal}. Pass --force to delete it anyway.`,\n );\n return 'refused';\n }\n if (refusal)\n deps.warn(`[localize] --force: deleting ${member.dir} although ${refusal}`);\n\n if (isSymlink(entry)) {\n // A package inside a cloned monorepo: the clone goes too, unless another\n // checkout or parked checkout still links into it.\n fs.unlinkSync(entry);\n if (repo && !linkedFromElsewhere(repo, deps)) {\n fs.rmSync(repo, {recursive: true, force: true});\n deps.log(\n `[localize] removed ${member.dir} and ${path.relative(deps.appRoot, repo)}`,\n );\n return 'done';\n }\n } else {\n fs.rmSync(entry, {recursive: true, force: true});\n }\n deps.log(`[localize] removed ${member.dir}`);\n return 'done';\n}\n\n/** Does any remaining checkout, here or parked, live inside `repo`? */\nfunction linkedFromElsewhere(repo: string, deps: Deps): boolean {\n return [...localMembers(deps.appRoot), ...parkedMembers(deps.appRoot)].some(\n (m) => {\n try {\n return isInside(fs.realpathSync(path.join(deps.appRoot, m.dir)), repo);\n } catch {\n return false;\n }\n },\n );\n}\n\n/** The install after parking or purging: see the module header. */\nfunction reinstall(names: string[], deps: Deps): number {\n const why = ciRefusal(deps);\n const ci = why === null;\n const args = ci ? ['ci', '--no-audit', '--no-fund'] : INSTALL_ARGS;\n const reason = ci ? `the committed ${LOCKFILE}, unchanged` : why;\n deps.log(`[localize] npm ${args.join(' ')} (app root; ${reason})`);\n const r = deps.run('npm', args, {cwd: deps.appRoot});\n if (r.status !== 0) {\n deps.error(\n `[localize] npm ${args[0]} failed at the app root; node_modules may still link the ` +\n `checkout${names.length === 1 ? '' : 's'}. Fix the cause and run \\`npm install\\`.\\n` +\n tail(r.stderr || r.stdout),\n );\n return EXIT_INSTALL_FAILED;\n }\n if (ci) return 0;\n const rebuild = deps.run('npm', ['rebuild', ...names], {cwd: deps.appRoot});\n if (rebuild.status !== 0) {\n deps.warn(\n `[localize] npm rebuild ${names.join(' ')} failed; a registry copy's bin may not be ` +\n `executable until it runs.\\n${tail(rebuild.stderr || rebuild.stdout)}`,\n );\n return EXIT_WARNED;\n }\n return 0;\n}\n\n/**\n * Why the reinstall cannot be `npm ci`, or null when it can: no checkout is\n * left, git tracks the lockfile, and neither it nor `package.json` differs\n * from HEAD. A git call that fails counts as a reason: `npm install` is the\n * safe choice.\n */\nfunction ciRefusal(deps: Deps): string | null {\n if (localMembers(deps.appRoot).length)\n return `checkouts remain in ${LOCAL_DIR}/`;\n const git = (args: string[]) =>\n deps.run('git', args, {cwd: deps.appRoot}).status === 0;\n if (!git(['ls-files', '--error-unmatch', '--', LOCKFILE]))\n return `${LOCKFILE} is not tracked by git`;\n if (!git(['diff', '--quiet', 'HEAD', '--', 'package.json', LOCKFILE]))\n return `package.json or ${LOCKFILE} differs from HEAD`;\n return null;\n}\n\n/**\n * @returns the reason a purge must be refused, or null. Fails closed: a git\n * call that fails is a reason, since a check that cannot look must not let\n * a delete through.\n */\nfunction purgeRefusal(repo: string, deps: Deps): string | null {\n const checks: {args: string[]; what: (n: number) => string}[] = [\n {\n args: ['status', '--porcelain'],\n what: (n) => `${n} uncommitted change${n === 1 ? '' : 's'}`,\n },\n {\n // HEAD (a detached one has no branch) and every local branch, against every remote.\n args: ['log', '--oneline', 'HEAD', '--branches', '--not', '--remotes'],\n what: (n) => `${n} commit${n === 1 ? '' : 's'} no remote has`,\n },\n {\n args: ['stash', 'list'],\n what: (n) => `${n} stash entr${n === 1 ? 'y' : 'ies'}`,\n },\n ];\n for (const {args, what} of checks) {\n const r = deps.run('git', args, {cwd: repo});\n if (r.status !== 0) {\n const why =\n (r.stderr || r.stdout).trim().split('\\n')[0] || `exit ${r.status}`;\n return `\\`git ${args.join(' ')}\\` failed (${why}), so its work cannot be checked`;\n }\n const n = r.stdout.split('\\n').filter((l) => l.trim()).length;\n if (n) return `it has ${what(n)}`;\n }\n return null;\n}\n\n/** By full name, or by the part after the scope when that is unambiguous. */\nfunction findMember(name: string, members: Member[]): Member | undefined {\n const exact = members.find((m) => m.name === name);\n if (exact) return exact;\n const short = members.filter((m) => m.name.split('/').pop() === name);\n return short.length === 1 ? short[0] : undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"delocalize.js","sourceRoot":"","sources":["../../../src/localize/delocalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAC,mBAAmB,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAC3E,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,eAAe,EACf,IAAI,GACL,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAIhF,MAAM,UAAU,UAAU,CACxB,KAAe,EACf,IAAwC,EACxC,IAAU;IAEV,IAAI,CAAC;QACH,eAAe,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC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,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,6EAA6E;AAC7E,SAAS,UAAU,CAAC,IAAY,EAAE,OAAiB;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACnD,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC","sourcesContent":["/**\n * `delocalize` -- go back to the registry copy WITHOUT losing work.\n *\n * A checkout is parked: moved to `.packages-local.parked/<dir>`, outside the\n * `packages-local/*` glob, so npm installs the registry copy again and\n * `linked localize <name>` (or `--parked`) takes it back as it was. With no\n * names, every checkout is parked.\n *\n * Then the install that swaps the links for registry copies:\n *\n * - no checkout left, `package-lock.json` tracked by git, and it and\n * `package.json` unchanged from HEAD: `npm ci`, which installs exactly the\n * committed lockfile;\n * - otherwise (some checkouts left -- `npm ci` refuses a lockfile that lists\n * members it does not -- an untracked lockfile, or a manifest being\n * changed): `npm install`, then `npm rebuild <names>` -- an install that\n * replaces a link with the registry copy leaves that package's bin without\n * its execute bit (measured), and a rebuild relinks it.\n *\n * `--purge` deletes the checkout instead of parking it. It fails closed:\n * unless `--force`, it refuses (exit 6) when the checkout is not a git\n * repository, when any git call fails, and on uncommitted changes, commits\n * that no remote has (on any branch or a detached HEAD), or a stash.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {EXIT_INSTALL_FAILED, EXIT_REFUSED, EXIT_WARNED} from './errors.js';\nimport {\n checkoutRepoRoot,\n existsOrLink,\n isInside,\n isSymlink,\n moveEntry,\n} from './fsops.js';\nimport {\n INSTALL_ARGS,\n LOCKFILE,\n reportError,\n restoreSetAside,\n tail,\n} from './localize.js';\nimport {LOCAL_DIR, PARKED_DIR, localMembers, parkedMembers} from './members.js';\nimport type {Member} from './members.js';\nimport type {Deps} from './run.js';\n\nexport function delocalize(\n names: string[],\n opts: {purge?: boolean; force?: boolean},\n deps: Deps,\n): number {\n try {\n restoreSetAside(deps);\n } catch (e) {\n return reportError(e, deps);\n }\n const members = localMembers(deps.appRoot);\n let code = 0;\n const targets: Member[] = [];\n for (const name of names.length ? names : members.map((m) => m.name)) {\n const member = findMember(name, members);\n if (member) {\n targets.push(member);\n continue;\n }\n const parked = findMember(name, parkedMembers(deps.appRoot));\n deps.warn(\n parked\n ? `[localize] ${parked.name} is already parked in ${parked.dir}.`\n : `[localize] ${name} is not localized -- nothing in ${LOCAL_DIR}/ is named that.`,\n );\n code = Math.max(code, EXIT_WARNED);\n }\n\n const done: string[] = [];\n for (const member of targets) {\n if (opts.purge) {\n // A purge that is refused is a guard refusing: nothing is deleted.\n if (purge(member, opts, deps) === 'done') done.push(member.name);\n else code = Math.max(code, EXIT_REFUSED);\n } else if (park(member, deps) === 'done') done.push(member.name);\n else code = Math.max(code, EXIT_WARNED);\n }\n if (!done.length) return code;\n return Math.max(code, reinstall(done, deps));\n}\n\nfunction park(member: Member, deps: Deps): 'done' | 'refused' {\n const to = `${PARKED_DIR}/${path.basename(member.dir)}`;\n if (existsOrLink(path.join(deps.appRoot, to))) {\n deps.warn(\n `[localize] ${member.name}: ${to} already exists, so ${member.dir} was not parked. Move ` +\n `one of them out of the way.`,\n );\n return 'refused';\n }\n moveEntry(path.join(deps.appRoot, member.dir), path.join(deps.appRoot, to));\n deps.log(\n `[localize] parked ${member.name}: ${member.dir} -> ${to} (\\`linked localize ${member.name}\\` takes it back)`,\n );\n return 'done';\n}\n\nfunction purge(\n member: Member,\n opts: {force?: boolean},\n deps: Deps,\n): 'done' | 'refused' {\n const entry = path.join(deps.appRoot, member.dir);\n const repo = checkoutRepoRoot(entry, deps.appRoot);\n const refusal = repo\n ? purgeRefusal(repo, deps)\n : 'it is not a git checkout (no .git), so nothing says its work is saved elsewhere';\n if (refusal && !opts.force) {\n deps.warn(\n `[localize] ${member.dir}: not deleting -- ${refusal}. Pass --force to delete it anyway.`,\n );\n return 'refused';\n }\n if (refusal)\n deps.warn(`[localize] --force: deleting ${member.dir} although ${refusal}`);\n\n if (isSymlink(entry)) {\n // A package inside a cloned monorepo: the clone goes too, unless another\n // checkout or parked checkout still links into it.\n fs.unlinkSync(entry);\n if (repo && !linkedFromElsewhere(repo, deps)) {\n fs.rmSync(repo, {recursive: true, force: true});\n deps.log(\n `[localize] removed ${member.dir} and ${path.relative(deps.appRoot, repo)}`,\n );\n return 'done';\n }\n } else {\n fs.rmSync(entry, {recursive: true, force: true});\n }\n deps.log(`[localize] removed ${member.dir}`);\n return 'done';\n}\n\n/** Does any remaining checkout, here or parked, live inside `repo`? */\nfunction linkedFromElsewhere(repo: string, deps: Deps): boolean {\n return [...localMembers(deps.appRoot), ...parkedMembers(deps.appRoot)].some(\n (m) => {\n try {\n return isInside(fs.realpathSync(path.join(deps.appRoot, m.dir)), repo);\n } catch {\n return false;\n }\n },\n );\n}\n\n/** The install after parking or purging: see the module header. */\nfunction reinstall(names: string[], deps: Deps): number {\n const why = ciRefusal(deps);\n const ci = why === null;\n const args = ci ? ['ci', '--no-audit', '--no-fund'] : INSTALL_ARGS;\n const reason = ci ? `the committed ${LOCKFILE}, unchanged` : why;\n deps.log(`[localize] npm ${args.join(' ')} (app root; ${reason})`);\n const r = deps.run('npm', args, {cwd: deps.appRoot});\n if (r.status !== 0) {\n deps.error(\n `[localize] npm ${args[0]} failed at the app root; node_modules may still link the ` +\n `checkout${names.length === 1 ? '' : 's'}. Fix the cause and run \\`npm install\\`.\\n` +\n tail(r.stderr || r.stdout),\n );\n return EXIT_INSTALL_FAILED;\n }\n if (ci) return 0;\n const rebuild = deps.run('npm', ['rebuild', ...names], {cwd: deps.appRoot});\n if (rebuild.status !== 0) {\n deps.warn(\n `[localize] npm rebuild ${names.join(' ')} failed; a registry copy's bin may not be ` +\n `executable until it runs.\\n${tail(rebuild.stderr || rebuild.stdout)}`,\n );\n return EXIT_WARNED;\n }\n return 0;\n}\n\n/**\n * Why the reinstall cannot be `npm ci`, or null when it can: no checkout is\n * left, git tracks the lockfile, and neither it nor `package.json` differs\n * from HEAD. A git call that fails counts as a reason: `npm install` is the\n * safe choice.\n */\nfunction ciRefusal(deps: Deps): string | null {\n if (localMembers(deps.appRoot).length)\n return `checkouts remain in ${LOCAL_DIR}/`;\n const git = (args: string[]) =>\n deps.run('git', args, {cwd: deps.appRoot}).status === 0;\n if (!git(['ls-files', '--error-unmatch', '--', LOCKFILE]))\n return `${LOCKFILE} is not tracked by git`;\n if (!git(['diff', '--quiet', 'HEAD', '--', 'package.json', LOCKFILE]))\n return `package.json or ${LOCKFILE} differs from HEAD`;\n return null;\n}\n\n/**\n * @returns the reason a purge must be refused, or null. Fails closed: a git\n * call that fails is a reason, since a check that cannot look must not let\n * a delete through.\n */\nfunction purgeRefusal(repo: string, deps: Deps): string | null {\n const checks: {args: string[]; what: (n: number) => string}[] = [\n {\n args: ['status', '--porcelain'],\n what: (n) => `${n} uncommitted change${n === 1 ? '' : 's'}`,\n },\n {\n // HEAD (a detached one has no branch) and every local branch, against every remote.\n args: ['log', '--oneline', 'HEAD', '--branches', '--not', '--remotes'],\n what: (n) => `${n} commit${n === 1 ? '' : 's'} no remote has`,\n },\n {\n args: ['stash', 'list'],\n what: (n) => `${n} stash entr${n === 1 ? 'y' : 'ies'}`,\n },\n ];\n for (const {args, what} of checks) {\n const r = deps.run('git', args, {cwd: repo});\n if (r.status !== 0) {\n const why =\n (r.stderr || r.stdout).trim().split('\\n')[0] || `exit ${r.status}`;\n return `\\`git ${args.join(' ')}\\` failed (${why}), so its work cannot be checked`;\n }\n const n = r.stdout.split('\\n').filter((l) => l.trim()).length;\n if (n) return `it has ${what(n)}`;\n }\n return null;\n}\n\n/** By full name, or by the part after the scope when that is unambiguous. */\nfunction findMember(name: string, members: Member[]): Member | undefined {\n const exact = members.find((m) => m.name === name);\n if (exact) return exact;\n const short = members.filter((m) => m.name.split('/').pop() === name);\n return short.length === 1 ? short[0] : undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/localize/list.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/localize/list.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAQtC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,UAAU,CAAC;AAEnC,2BAA2B;AAC3B,MAAM,WAAW,OAAQ,SAAQ,MAAM;IACrC,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG;IAAC,IAAI,EAAE,OAAO,EAAE,CAAC;IAAC,KAAK,EAAE,KAAK,EAAE,CAAA;CAAC,CAarE;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAsChE"}
|
package/lib/esm/localize/list.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
import { describeDrift, driftProblems } from './drift.js';
|
|
16
16
|
import { EXIT_DRIFT } from './errors.js';
|
|
17
|
-
import { currentBranch,
|
|
17
|
+
import { currentBranch, reportError, restoreSetAside, } from './localize.js';
|
|
18
18
|
import { localMembers, parkedMembers } from './members.js';
|
|
19
19
|
export function collect(deps) {
|
|
20
20
|
const row = (m, state) => (Object.assign(Object.assign({}, m), { state, branch: currentBranch(path.join(deps.appRoot, m.dir), deps) }));
|
|
@@ -27,7 +27,6 @@ export function collect(deps) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
export function list(opts, deps) {
|
|
30
|
-
legacyManifestHint(deps);
|
|
31
30
|
try {
|
|
32
31
|
restoreSetAside(deps);
|
|
33
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/localize/list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAExD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/localize/list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAExD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,aAAa,EACb,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAUzD,MAAM,UAAU,OAAO,CAAC,IAAU;IAChC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,KAAuB,EAAW,EAAE,CAAC,iCACxD,CAAC,KACJ,KAAK,EACL,MAAM,EAAE,aAAa,CA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C,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAClD,IAAI,KAAK,CAAC,QAAQ,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC7D,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAChE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/**\n * `--list` -- what is localized, what is parked, and the drift (drift.ts).\n *\n * The record is the directories: every checkout in `packages-local/` is a\n * workspace member, every one in `.packages-local.parked/` is parked. A row\n * per checkout -- name, directory, branch, version -- then one line per drift.\n *\n * `--check` is for CI and scripts: it prints only the drift (nothing when\n * there is none) and exits 1 when there is any. (The lock-at-rest hook reports\n * drift itself, with `hooks/drift.cjs`.) It writes nothing, except that\n * checkouts an interrupted set-up left in `packages-local/.setup-aside/` are\n * moved back first, as `localize` and `delocalize` do.\n */\nimport path from 'node:path';\n\nimport {describeDrift, driftProblems} from './drift.js';\nimport type {Drift} from './drift.js';\nimport {EXIT_DRIFT} from './errors.js';\nimport {\n currentBranch,\n reportError,\n restoreSetAside,\n} from './localize.js';\nimport {localMembers, parkedMembers} from './members.js';\nimport type {Member} from './members.js';\nimport type {Deps} from './run.js';\n\n/** One row of `--list`. */\nexport interface ListRow extends Member {\n state: 'localized' | 'parked';\n branch: string;\n}\n\nexport function collect(deps: Deps): {rows: ListRow[]; drift: Drift[]} {\n const row = (m: Member, state: ListRow['state']): ListRow => ({\n ...m,\n state,\n branch: currentBranch(path.join(deps.appRoot, m.dir), deps),\n });\n return {\n rows: [\n ...localMembers(deps.appRoot).map((m) => row(m, 'localized')),\n ...parkedMembers(deps.appRoot).map((m) => row(m, 'parked')),\n ],\n drift: driftProblems(deps.appRoot),\n };\n}\n\nexport function list(opts: {check?: boolean}, deps: Deps): number {\n try {\n restoreSetAside(deps);\n } catch (e) {\n return reportError(e, deps);\n }\n if (opts.check) {\n const drift = driftProblems(deps.appRoot);\n for (const d of drift) deps.warn(`[localize] drift: ${describeDrift(d)}`);\n return drift.length ? EXIT_DRIFT : 0;\n }\n\n const {rows, drift} = collect(deps);\n if (!rows.length && !drift.length) return 0; // nothing localized, nothing to say\n\n if (rows.length) {\n const nameW = Math.max(...rows.map((r) => r.name.length)) + 2;\n const dirW = Math.max(...rows.map((r) => r.dir.length)) + 2;\n const branchW = Math.max(...rows.map((r) => r.branch.length)) + 2;\n for (const r of rows) {\n deps.log(\n r.name.padEnd(nameW) +\n r.dir.padEnd(dirW) +\n r.branch.padEnd(branchW) +\n (r.version || '—') +\n (r.state === 'parked' ? ' (parked)' : ''),\n );\n }\n }\n for (const d of drift) deps.log(`drift: ${describeDrift(d)}`);\n\n const count = (s: ListRow['state']) =>\n rows.filter((r) => r.state === s).length;\n const parts = [`${count('localized')} localized`];\n if (count('parked')) parts.push(`${count('parked')} parked`);\n parts.push(drift.length ? `${drift.length} drift` : 'no drift');\n deps.log(parts.join(' · '));\n return 0;\n}\n"]}
|
|
@@ -50,11 +50,6 @@ export declare function unpark(member: Member, deps: Deps): Prepared;
|
|
|
50
50
|
* has an entry of the same name.
|
|
51
51
|
*/
|
|
52
52
|
export declare function restoreSetAside(deps: Pick<Deps, 'appRoot' | 'log'>): void;
|
|
53
|
-
/**
|
|
54
|
-
* One line when an app still has the retired record. It is ignored: the
|
|
55
|
-
* record now is the directories in `packages-local/`.
|
|
56
|
-
*/
|
|
57
|
-
export declare function legacyManifestHint(deps: Pick<Deps, 'appRoot' | 'warn'>): void;
|
|
58
53
|
export declare function reportError(e: unknown, deps: Pick<Deps, 'error'>): number;
|
|
59
54
|
/**
|
|
60
55
|
* The checked-out branch, or `HEAD` when detached. `symbolic-ref` first,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize.d.ts","sourceRoot":"","sources":["../../../src/localize/localize.ts"],"names":[],"mappings":"AA2DA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAC,IAAI,EAAY,MAAM,UAAU,CAAC;AAG9C,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAIpD,oDAAoD;AACpD,eAAO,MAAM,YAAY,UAAyC,CAAC;AAUnE,mDAAmD;AACnD,eAAO,MAAM,QAAQ,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"localize.d.ts","sourceRoot":"","sources":["../../../src/localize/localize.ts"],"names":[],"mappings":"AA2DA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAC,IAAI,EAAY,MAAM,UAAU,CAAC;AAG9C,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAIpD,oDAAoD;AACpD,eAAO,MAAM,YAAY,UAAyC,CAAC;AAUnE,mDAAmD;AACnD,eAAO,MAAM,QAAQ,sBAAsB,CAAC;AAE5C,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wCAAwC;AACxC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,kGAAkG;IAClG,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,8FAA8F;AAC9F,MAAM,MAAM,OAAO,GAAG,CACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,IAAI,KACP,QAAQ,GAAG,IAAI,CAAC;AAErB;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,IAAI,GACT,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,GACf,MAAM,CAkDR;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,EAAE,EACpB,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,EACpC,IAAI,EAAE,IAAI,EACV,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAiCR;AAuGD,+FAA+F;AAC/F,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,CAuB3D;AAyGD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,GAAG,KAAK,CAAC,GAAG,IAAI,CA8BzE;AAwHD,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,MAAM,CAMzE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,GACtB,MAAM,CAUR;AAED,2FAA2F;AAC3F,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,CAEvD"}
|
|
@@ -46,7 +46,7 @@ import { describeDrift, driftProblems } from './drift.js';
|
|
|
46
46
|
import { EXIT_INSTALL_FAILED, EXIT_REFUSED, EXIT_USAGE, EXIT_WARNED, LocalizeError, } from './errors.js';
|
|
47
47
|
import { existsOrLink, moveEntry, readJson } from './fsops.js';
|
|
48
48
|
import { installGitHooks } from './git-hooks.js';
|
|
49
|
-
import { LOCAL_DIR, localMembers, parkedMembers
|
|
49
|
+
import { LOCAL_DIR, localMembers, parkedMembers } from './members.js';
|
|
50
50
|
import { setupLockfileByEdit } from './setup-lockfile.js';
|
|
51
51
|
import { checkoutNameFor, resolvePackage } from './resolve.js';
|
|
52
52
|
import { linkDirectory } from '../utils/platform.js';
|
|
@@ -68,8 +68,6 @@ const REPOS_DIR = `${LOCAL_DIR}/.repos`;
|
|
|
68
68
|
const SETUP_ASIDE_DIR = `${LOCAL_DIR}/.setup-aside`;
|
|
69
69
|
/** The app's lockfile, kept clean of checkouts. */
|
|
70
70
|
export const LOCKFILE = 'package-lock.json';
|
|
71
|
-
/** What an app recorded checkouts in before they were workspace members. */
|
|
72
|
-
const LEGACY_MANIFEST = 'local-packages.json';
|
|
73
71
|
/**
|
|
74
72
|
* @param names full npm package names
|
|
75
73
|
* @returns the process exit code: the highest of the per-name codes and the
|
|
@@ -84,7 +82,6 @@ export function localize(names, opts, deps) {
|
|
|
84
82
|
*/
|
|
85
83
|
export function runLocalize(names, opts, deps, prepare) {
|
|
86
84
|
var _a, _b;
|
|
87
|
-
legacyManifestHint(deps);
|
|
88
85
|
let setupLock;
|
|
89
86
|
try {
|
|
90
87
|
restoreSetAside(deps);
|
|
@@ -436,16 +433,6 @@ function reportHooks(hooks, deps) {
|
|
|
436
433
|
`repository. They act only in a work tree whose ${LOCAL_DIR}/ has checkouts.`);
|
|
437
434
|
}
|
|
438
435
|
}
|
|
439
|
-
/**
|
|
440
|
-
* One line when an app still has the retired record. It is ignored: the
|
|
441
|
-
* record now is the directories in `packages-local/`.
|
|
442
|
-
*/
|
|
443
|
-
export function legacyManifestHint(deps) {
|
|
444
|
-
if (!fs.existsSync(path.join(deps.appRoot, LEGACY_MANIFEST)))
|
|
445
|
-
return;
|
|
446
|
-
deps.warn(`[localize] ${LEGACY_MANIFEST} is no longer read: every directory in ${LOCAL_DIR}/ is ` +
|
|
447
|
-
`localized, ${PARKED_DIR}/ holds parked ones. Delete the file.`);
|
|
448
|
-
}
|
|
449
436
|
/**
|
|
450
437
|
* Run the build for one new checkout. `opts.build` wins, including `''` for
|
|
451
438
|
* no build; otherwise the cli builds itself and everything else gets
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize.js","sourceRoot":"","sources":["../../../src/localize/localize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAC,oBAAoB,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACxD,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAChF,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAEnD,qEAAqE;AACrE,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,kGAAkG;AAClG,MAAM,WAAW,GAAG,cAAc,CAAC;AACnC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAC1C,oDAAoD;AACpD,MAAM,CAAC,MAAM,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CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC1C,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,IAAI,CAAC,MAAc,EAAE,KAAK,GAAG,EAAE;IAC7C,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * `localize` -- turn an npm-installed dependency into an editable git checkout\n * that npm itself links.\n *\n * A checkout in `packages-local/` is a workspace member: the app's\n * `workspaces` holds `\"packages-local/*\"`, so `npm install` links\n * `node_modules/<name>` to it and dedupes everything below it like any other\n * member. The committed `package-lock.json` is put back after every install by\n * `hooks/lock-at-rest.cjs`, so the working tree stays clean.\n *\n * One run, for every name at once:\n *\n * 1. refuse an `overrides` key naming a package being localized or already\n * in `packages-local/` (npm fails with `EOVERRIDE` on a member's name);\n * nothing is changed then;\n * 2. the one-time app setup (app-setup.ts), reported line by line so the\n * developer commits it; when it changed `package.json`, the lockfile\n * that goes with it is made now, before anything is cloned, and written\n * back after the install (`captureSetupLockfile`);\n * 3. per name: a parked checkout (`linked delocalize`) moves back; an\n * existing directory is refused with an `--adopt` hint; anything else is\n * resolved through the registry's `repository` (or `--repo`) and cloned;\n * 4. the git hooks (git-hooks.ts), or the lines to add under\n * `core.hooksPath`;\n * 5. ONE `npm install` at the app root -- a checkout's dependencies arrive\n * with it, so it comes before any build;\n * 6. build each new checkout: `--build`, else `linked build`, else for the\n * cli its own `npm run build` (the cli is what `linked build` runs, and a\n * fresh cli checkout has no `lib/` yet). The cli builds first and then\n * gets its bin linked (`npm rebuild`), since the others' `linked build`\n * runs it. A failing build warns: a package whose build is broken is\n * usually what you localized it to fix.\n *\n * `adopt` (adopt.ts) replaces step 3 with \"the checkout is already there\", and\n * `--parked` with \"every parked checkout\". Steps 1, 2 and 4-6 are `runLocalize`.\n *\n * A package inside a monorepo (`--subdir`, or a registry `repository.directory`)\n * is cloned whole into `packages-local/.repos/<checkout>` -- a dot directory,\n * which the `packages-local/*` glob skips -- and `packages-local/<checkout>` is\n * a link to the package inside it. npm follows the link like a directory.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {conflictingOverrides, ensureAppSetup} from './app-setup.js';\nimport type {SetupChange} from './app-setup.js';\nimport {describeDrift, driftProblems} from './drift.js';\nimport {\n EXIT_INSTALL_FAILED,\n EXIT_REFUSED,\n EXIT_USAGE,\n EXIT_WARNED,\n LocalizeError,\n} from './errors.js';\nimport {existsOrLink, moveEntry, readJson} from './fsops.js';\nimport {installGitHooks} from './git-hooks.js';\nimport type {HookInstall} from './git-hooks.js';\nimport {LOCAL_DIR, localMembers, parkedMembers, PARKED_DIR} from './members.js';\nimport {setupLockfileByEdit} from './setup-lockfile.js';\nimport type {Member} from './members.js';\nimport {checkoutNameFor, resolvePackage} from './resolve.js';\nimport type {Deps, RunResult} from './run.js';\nimport {linkDirectory} from '../utils/platform.js';\n\n/** What a new checkout is built with when `--build` does not say. */\nexport const DEFAULT_BUILD_COMMAND = 'linked build';\n/** The cli builds itself: `linked build` IS the cli, and a fresh checkout of it has no `lib/`. */\nconst CLI_PACKAGE = '@_linked/cli';\nconst CLI_BUILD_COMMAND = 'npm run build';\n/** The one install a run makes, at the app root. */\nexport const INSTALL_ARGS = ['install', '--no-audit', '--no-fund'];\n/** Where a cloned monorepo lives, inside `packages-local/` but outside its glob. */\nconst REPOS_DIR = `${LOCAL_DIR}/.repos`;\n/**\n * Where the set-up's lockfile run puts the checkouts while npm makes it:\n * inside the gitignored `packages-local/`, outside its glob (npm skips dot\n * directories). A run interrupted there leaves them in it; the next\n * `localize`, `delocalize` or `--list` moves them back (`restoreSetAside`).\n */\nconst SETUP_ASIDE_DIR = `${LOCAL_DIR}/.setup-aside`;\n/** The app's lockfile, kept clean of checkouts. */\nexport const LOCKFILE = 'package-lock.json';\n/** What an app recorded checkouts in before they were workspace members. */\nconst LEGACY_MANIFEST = 'local-packages.json';\n\nexport interface LocalizeOptions {\n /** Where checkouts live. Only `packages-local` is accepted: the workspace glob names it. */\n dir?: string;\n repo?: string;\n subdir?: string;\n /** Run in each new checkout after the install. Absent: the default; empty: no build. */\n build?: string;\n}\n\n/** A checkout ready for the install. */\nexport interface Prepared {\n name: string;\n /** App-relative, `/`-separated: `packages-local/_linked-core`. */\n dir: string;\n /** Build it after the install: a new clone or an adopted checkout, not a returning parked one. */\n build: boolean;\n}\n\n/** How one name becomes a checkout in `packages-local/`; null when there is nothing to do. */\nexport type Prepare = (\n name: string,\n opts: LocalizeOptions,\n deps: Deps,\n) => Prepared | null;\n\n/**\n * @param names full npm package names\n * @returns the process exit code: the highest of the per-name codes and the\n * install's, since a failure on name 2 does not undo name 1.\n */\nexport function localize(\n names: string[],\n opts: LocalizeOptions,\n deps: Deps,\n): number {\n return runLocalize(names, opts, deps, prepareClone);\n}\n\n/**\n * The run `localize`, `adopt` and `--parked` share: everything except how a\n * name becomes a checkout. See the module header for the steps.\n */\nexport function runLocalize(\n names: string[],\n opts: LocalizeOptions,\n deps: Deps,\n prepare: Prepare,\n): number {\n legacyManifestHint(deps);\n let setupLock: string | undefined;\n try {\n restoreSetAside(deps);\n checkDir(opts.dir);\n // The checkouts already there count too: the one install below covers them all.\n const localized = new Set([\n ...names,\n ...localMembers(deps.appRoot).map((m) => m.name),\n ]);\n const conflicts = conflictingOverrides(deps.appRoot, [...localized]);\n if (conflicts.length) {\n throw new LocalizeError(\n `package.json \"overrides\" names a localized package: ${conflicts\n .map((k) => `\"${k}\"`)\n .join(', ')}.\\n` +\n `npm refuses an override on a workspace member's name (EOVERRIDE), and a nested one ` +\n `would replace the checkout. Remove ${conflicts.length === 1 ? 'that key' : 'those keys'} ` +\n `from \"overrides\", then run this again. Nothing was changed.`,\n EXIT_REFUSED,\n );\n }\n const workspacesBefore = readJson(\n path.join(deps.appRoot, 'package.json'),\n )?.workspaces;\n const changes = ensureAppSetup(deps.appRoot);\n reportSetup(changes, deps);\n if (changes.some((c) => c.file === 'package.json'))\n setupLock =\n captureSetupLockfile(changes, workspacesBefore, deps) ?? undefined;\n } catch (e) {\n return reportError(e, deps);\n }\n\n let code = 0;\n const prepared: Prepared[] = [];\n for (const name of names) {\n try {\n const p = prepare(name, opts, deps);\n if (p) prepared.push(p);\n } catch (e) {\n code = Math.max(code, reportError(e, deps));\n }\n }\n if (!prepared.length) {\n // Nothing was installed: the work tree holds the set-up's lockfile as captured.\n if (setupLock !== undefined) commitHint(deps);\n return code;\n }\n return Math.max(code, installAndBuild(prepared, opts, deps, setupLock));\n}\n\n/**\n * Steps 4-6: git hooks, one root install, then the builds. `setupLock` is the\n * lockfile the set-up captured (see `captureSetupLockfile`), written back\n * over what the install left.\n */\nexport function installAndBuild(\n prepared: Prepared[],\n opts: Pick<LocalizeOptions, 'build'>,\n deps: Deps,\n setupLock?: string,\n): number {\n reportHooks(installGitHooks(deps.appRoot), deps);\n\n deps.log(`[localize] npm ${INSTALL_ARGS.join(' ')} (app root)`);\n const install = deps.run('npm', INSTALL_ARGS, {cwd: deps.appRoot});\n if (setupLock !== undefined) restoreSetupLockfile(setupLock, deps);\n if (install.status !== 0) {\n deps.error(\n `[localize] npm install failed at the app root. The checkout${prepared.length === 1 ? ' stays' : 's stay'} ` +\n `in ${LOCAL_DIR}/; fix the cause and run \\`npm install\\`.\\n` +\n tail(install.stderr || install.stdout),\n );\n return EXIT_INSTALL_FAILED;\n }\n\n let code = 0;\n // The cli first: the other builds run `linked build`, which is the cli.\n const ordered = [\n ...prepared.filter((p) => p.name === CLI_PACKAGE),\n ...prepared.filter((p) => p.name !== CLI_PACKAGE),\n ];\n for (const p of ordered) {\n const pkgDir = path.join(deps.appRoot, p.dir);\n const built = p.build ? runBuild(p, pkgDir, opts, deps) : 'skipped';\n if (built === 'failed') code = EXIT_WARNED;\n if (built === 'ok' && p.name === CLI_PACKAGE) linkCliBin(deps);\n deps.log(\n `[localize] ${p.name} -> ${p.dir} (branch ${currentBranch(pkgDir, deps)})`,\n );\n }\n for (const d of driftProblems(deps.appRoot))\n deps.warn(`[localize] drift: ${describeDrift(d)}`);\n return code;\n}\n\n/**\n * npm links a package's bin only when its target exists, and a fresh cli\n * checkout has no `lib/` at install time: without this, `node_modules/.bin/linked`\n * is missing after the build, and `npx linked` would fetch the unrelated npm\n * package named `linked`. `--ignore-scripts`: only the bin links are wanted.\n */\nfunction linkCliBin(deps: Deps): void {\n const r = deps.run('npm', ['rebuild', CLI_PACKAGE, '--ignore-scripts'], {\n cwd: deps.appRoot,\n });\n if (r.status !== 0) {\n deps.warn(\n `[localize] npm rebuild ${CLI_PACKAGE} failed, so \\`linked\\` may not be on the app's ` +\n `bin path. Run it yourself.\\n` +\n tail(r.stderr || r.stdout),\n );\n }\n}\n\n/** Step 3 for `localize`: take back a parked checkout, else clone. */\nfunction prepareClone(\n name: string,\n opts: LocalizeOptions,\n deps: Deps,\n): Prepared | null {\n const parked = parkedMembers(deps.appRoot).find((m) => m.name === name);\n if (parked) return unpark(parked, deps);\n\n const member = localMembers(deps.appRoot).find((m) => m.name === name);\n if (member) {\n throw new LocalizeError(\n `${name} is already in ${member.dir}. To install and build it as it is:\\n` +\n ` linked localize ${name} --adopt`,\n EXIT_REFUSED,\n );\n }\n\n const relDir = `${LOCAL_DIR}/${checkoutNameFor(name)}`;\n const target = path.join(deps.appRoot, relDir);\n if (existsOrLink(target)) {\n throw new LocalizeError(\n `${relDir} already exists. localize never clones over a directory. If it is ${name}'s ` +\n `checkout, install and build it as it is:\\n linked localize ${name} --adopt`,\n EXIT_REFUSED,\n );\n }\n\n const resolved = resolvePackage(\n name,\n deps,\n opts.repo ? {repo: opts.repo, subdir: opts.subdir} : undefined,\n );\n\n // A monorepo is cloned whole outside the glob; the member is a link to the package.\n const relClone = resolved.subdir\n ? `${REPOS_DIR}/${checkoutNameFor(name)}`\n : relDir;\n const clone = path.join(deps.appRoot, relClone);\n if (existsOrLink(clone)) {\n throw new LocalizeError(\n `${relClone} already exists. Remove it, or move it out of the way, and run this again.`,\n EXIT_REFUSED,\n );\n }\n fs.mkdirSync(path.dirname(clone), {recursive: true});\n deps.log(`[localize] cloning ${resolved.repo} -> ${relClone}`);\n const r = deps.run('git', ['clone', '--', resolved.repo, clone]);\n if (r.status !== 0) {\n throw new LocalizeError(\n `git clone ${resolved.repo} failed:\\n${(r.stderr || r.stdout).trim()}`,\n EXIT_REFUSED,\n );\n }\n\n const pkgDir = resolved.subdir ? path.join(clone, resolved.subdir) : clone;\n const relPkg = resolved.subdir ? `${relClone}/${resolved.subdir}` : relClone;\n // A clone that is not the package must not stay: in packages-local/ it\n // would be a workspace member under the wrong name.\n const declared = readJson(path.join(pkgDir, 'package.json'))?.name;\n if (declared !== name) {\n fs.rmSync(clone, {recursive: true, force: true});\n const where = resolved.subdir\n ? `The registry's repository.directory for \"${name}\" points at the wrong place.`\n : `${resolved.repo} looks like a monorepo. Say where the package lives:\\n` +\n ` linked localize ${name} --repo ${resolved.repo} --subdir <path-inside-the-repo>`;\n throw new LocalizeError(\n (declared\n ? `${relPkg} declares itself as \"${declared}\", not \"${name}\".\\n`\n : `${relPkg} has no package.json naming it, so it is not the package \"${name}\".\\n`) +\n `${where}\\nThe clone was removed.`,\n EXIT_REFUSED,\n );\n }\n\n if (resolved.subdir) {\n linkDirectory(pkgDir, target);\n deps.log(`[localize] ${relDir} -> ${relPkg}`);\n }\n return {name, dir: relDir, build: true};\n}\n\n/** Move a parked checkout back into `packages-local/`. No clone, no build: it is as it was. */\nexport function unpark(member: Member, deps: Deps): Prepared {\n const entry = path.basename(member.dir);\n const relDir = `${LOCAL_DIR}/${entry}`;\n const to = path.join(deps.appRoot, relDir);\n if (existsOrLink(to)) {\n throw new LocalizeError(\n `${member.name} is parked in ${member.dir}, but ${relDir} already exists. Move one of ` +\n `them out of the way and run this again.`,\n EXIT_REFUSED,\n );\n }\n // npm refuses two workspace members of one name, so the install would fail.\n const same = localMembers(deps.appRoot).find((m) => m.name === member.name);\n if (same) {\n throw new LocalizeError(\n `${member.name} is parked in ${member.dir}, but ${same.dir} is ${member.name} already. ` +\n `Keep one: delete or move the other out of the way, and run this again.`,\n EXIT_REFUSED,\n );\n }\n moveEntry(path.join(deps.appRoot, member.dir), to);\n deps.log(`[localize] ${member.dir} -> ${relDir}`);\n return {name: member.name, dir: relDir, build: false};\n}\n\n/** `--dir` is kept for scripts that pass the default; anything else is not a workspace member. */\nfunction checkDir(dir: string | undefined): void {\n if (dir === undefined || dir.replace(/\\/+$/, '') === LOCAL_DIR) return;\n throw new LocalizeError(\n `--dir ${dir}: checkouts live in ${LOCAL_DIR}/, the directory the app's ` +\n `\"workspaces\" glob and the lock-at-rest hook name. Move them there.`,\n EXIT_USAGE,\n );\n}\n\nfunction reportSetup(changes: SetupChange[], deps: Deps): void {\n if (!changes.length) return;\n deps.log(`[localize] set up this app for checkouts (commit these):`);\n for (const c of changes) deps.log(` ${c.file}: ${c.what}`);\n}\n\n/** What `captureSetupLockfile` runs: the lockfile for the new `package.json`, nothing installed. */\nconst SETUP_LOCK_ARGS = [\n 'install',\n '--package-lock-only',\n '--ignore-scripts',\n '--no-audit',\n '--no-fund',\n];\n\n/**\n * The set-up changed `package.json`, so the lockfile must change with it\n * (the root entry's `workspaces`) -- and it must be a lockfile with no\n * checkout in it, which the install below cannot give: it lists them, and\n * lock-at-rest leaves it so while `package.json` differs from HEAD. So,\n * before anything is cloned, make that lockfile, keep it, and write it back\n * after the install. When the root entry already has `workspaces` and\n * `hasInstallScript`, it is an edit of that entry (setup-lockfile.ts: exact,\n * offline); otherwise npm makes the lockfile alone, with checkouts already in\n * `packages-local/` (an adopted one) moved into `SETUP_ASIDE_DIR` for that\n * one call.\n *\n * @returns the lockfile to write back, or null when it could not be made (the\n * manual steps are printed instead).\n */\nfunction captureSetupLockfile(\n changes: SetupChange[],\n workspacesBefore: unknown,\n deps: Deps,\n): string | null {\n const lockfile = path.join(deps.appRoot, LOCKFILE);\n const edited = editedSetupLockfile(lockfile, workspacesBefore, deps);\n if (edited !== null) return edited;\n const moveAside = localMembers(deps.appRoot).length > 0;\n deps.log(\n `[localize] npm ${SETUP_LOCK_ARGS.join(' ')} (the set-up's lockfile)`,\n );\n if (moveAside) setAside(deps);\n let r: RunResult;\n try {\n r = deps.run('npm', SETUP_LOCK_ARGS, {cwd: deps.appRoot});\n } finally {\n if (moveAside) moveBack(deps);\n }\n let text: string | null = null;\n try {\n text = fs.readFileSync(lockfile, 'utf8');\n } catch {\n /* none written */\n }\n if (r.status !== 0 || text === null) {\n manualSetupSteps(\n changes,\n r.status !== 0\n ? `npm could not write it:\\n${tail(r.stderr || r.stdout)}`\n : `npm wrote no ${LOCKFILE}`,\n deps,\n );\n return null;\n }\n return text;\n}\n\n/**\n * Every entry of `packages-local/` but the dot directories, moved into\n * `SETUP_ASIDE_DIR` as it is (a link keeps its text and works again once back).\n */\nfunction setAside(deps: Pick<Deps, 'appRoot'>): void {\n const local = path.join(deps.appRoot, LOCAL_DIR);\n const aside = path.join(deps.appRoot, SETUP_ASIDE_DIR);\n fs.mkdirSync(aside, {recursive: true});\n for (const entry of fs.readdirSync(local)) {\n if (entry.startsWith('.')) continue;\n fs.renameSync(path.join(local, entry), path.join(aside, entry));\n }\n}\n\n/** Everything in `SETUP_ASIDE_DIR` back into `packages-local/`; the directory goes. */\nfunction moveBack(deps: Pick<Deps, 'appRoot'>): number {\n const local = path.join(deps.appRoot, LOCAL_DIR);\n const aside = path.join(deps.appRoot, SETUP_ASIDE_DIR);\n const entries = fs.readdirSync(aside);\n for (const entry of entries)\n fs.renameSync(path.join(aside, entry), path.join(local, entry));\n fs.rmdirSync(aside);\n return entries.length;\n}\n\n/**\n * A set-up run that was interrupted while the checkouts were in\n * `SETUP_ASIDE_DIR` left them there, where npm does not see them: move them\n * back, saying so. Refuses, moving nothing, when `packages-local/` already\n * has an entry of the same name.\n */\nexport function restoreSetAside(deps: Pick<Deps, 'appRoot' | 'log'>): void {\n const aside = path.join(deps.appRoot, SETUP_ASIDE_DIR);\n if (!existsOrLink(aside)) return;\n let entries: string[];\n try {\n entries = fs.readdirSync(aside);\n } catch {\n throw new LocalizeError(\n `${SETUP_ASIDE_DIR} is not a directory. Remove it and run this again.`,\n EXIT_REFUSED,\n );\n }\n const clashes = entries.filter((e) =>\n existsOrLink(path.join(deps.appRoot, LOCAL_DIR, e)),\n );\n if (clashes.length) {\n throw new LocalizeError(\n `${SETUP_ASIDE_DIR}/ holds checkouts an interrupted set-up left there, but ` +\n `${clashes.map((e) => `${LOCAL_DIR}/${e}`).join(', ')} now exist${clashes.length === 1 ? 's' : ''} ` +\n `too. Keep one of each, move the other out of ${LOCAL_DIR}/, and run this again. ` +\n `Nothing was moved.`,\n EXIT_REFUSED,\n );\n }\n const n = moveBack(deps);\n if (n)\n deps.log(\n `[localize] moved ${n} checkout${n === 1 ? '' : 's'} back from ${SETUP_ASIDE_DIR}/ into ` +\n `${LOCAL_DIR}/, where an interrupted set-up left ${n === 1 ? 'it' : 'them'}.`,\n );\n}\n\n/** The set-up's lockfile as an edit of the root entry, written now; null when npm must make it. */\nfunction editedSetupLockfile(\n lockfile: string,\n workspacesBefore: unknown,\n deps: Deps,\n): string | null {\n let current: string;\n try {\n current = fs.readFileSync(lockfile, 'utf8');\n } catch {\n return null;\n }\n const text = setupLockfileByEdit(\n current,\n readJson(path.join(deps.appRoot, 'package.json')),\n workspacesBefore,\n );\n if (text === null) return null;\n fs.writeFileSync(lockfile, text);\n deps.log(\n `[localize] ${LOCKFILE}: the root entry's \"workspaces\" now matches package.json (the set-up's lockfile)`,\n );\n return text;\n}\n\n/** Put the captured set-up lockfile back after the install rewrote it. */\nfunction restoreSetupLockfile(text: string, deps: Deps): void {\n fs.writeFileSync(path.join(deps.appRoot, LOCKFILE), text);\n deps.log(\n `[localize] ${LOCKFILE}: put back the set-up's lockfile, which lists no checkout (any ` +\n `lock-at-rest warning above was about the one the install wrote).`,\n );\n commitHint(deps);\n}\n\nfunction commitHint(deps: Deps): void {\n deps.log(\n `[localize] commit the set-up now -- package.json, ${LOCKFILE}, .gitignore:\\n` +\n ` git add package.json ${LOCKFILE} .gitignore && git commit -m \"chore: set up linked localize\"`,\n );\n}\n\n/** The set-up's lockfile could not be made in one step: how to make it by hand. */\nfunction manualSetupSteps(\n changes: SetupChange[],\n why: string,\n deps: Deps,\n): void {\n const files = [...new Set([...changes.map((c) => c.file), LOCKFILE])];\n deps.warn(\n `[localize] could not make the set-up's ${LOCKFILE} in one step: ${why}\\n` +\n `Commit the set-up with a lockfile from an install with no checkout present:\\n` +\n ` npx linked delocalize\\n` +\n ` npm install\\n` +\n ` git add ${files.join(' ')} && git commit -m \"chore: set up linked localize\"\\n` +\n ` npx linked localize --parked`,\n );\n}\n\n/** Tell the developer what `installGitHooks` did not do. */\nfunction reportHooks(hooks: HookInstall, deps: Deps): void {\n for (const file of hooks.skipped) {\n deps.warn(\n `[localize] ${path.relative(deps.appRoot, file)} is not ours, so it was left alone. Without ` +\n `the localize hook there, run \\`npm install\\` yourself after a pull or branch switch that ` +\n `changes dependencies.`,\n );\n }\n if (hooks.hooksPath !== null) {\n deps.warn(\n `[localize] core.hooksPath is set (${hooks.hooksPath}), so no git hooks were written. Add ` +\n `each line below to the hook named before it, an \\`sh\\` script (not, say, a Python hook ` +\n `the pre-commit framework writes); they do nothing where the cli is not installed:`,\n );\n for (const m of hooks.manual) deps.warn(` ${m.file}:\\n ${m.line}`);\n }\n if (hooks.sharedWithWorktrees) {\n deps.warn(\n `[localize] this is a linked worktree: git hooks are shared by every worktree of the ` +\n `repository. They act only in a work tree whose ${LOCAL_DIR}/ has checkouts.`,\n );\n }\n}\n\n/**\n * One line when an app still has the retired record. It is ignored: the\n * record now is the directories in `packages-local/`.\n */\nexport function legacyManifestHint(deps: Pick<Deps, 'appRoot' | 'warn'>): void {\n if (!fs.existsSync(path.join(deps.appRoot, LEGACY_MANIFEST))) return;\n deps.warn(\n `[localize] ${LEGACY_MANIFEST} is no longer read: every directory in ${LOCAL_DIR}/ is ` +\n `localized, ${PARKED_DIR}/ holds parked ones. Delete the file.`,\n );\n}\n\n/**\n * Run the build for one new checkout. `opts.build` wins, including `''` for\n * no build; otherwise the cli builds itself and everything else gets\n * `linked build`.\n */\nfunction runBuild(\n p: Prepared,\n pkgDir: string,\n opts: Pick<LocalizeOptions, 'build'>,\n deps: Deps,\n): 'skipped' | 'ok' | 'failed' {\n const cmd = buildCommandFor(p.name, opts);\n if (!cmd) return 'skipped';\n deps.log(`[localize] ${p.dir}: ${cmd}`);\n const r = deps.run(cmd, [], {cwd: pkgDir, shell: true});\n if (r.status !== 0) {\n deps.warn(\n `[localize] ${p.dir}: \\`${cmd}\\` failed. It is installed and linked anyway -- a package ` +\n `whose build is broken is usually what you localized it to fix.\\n` +\n tail(r.stderr || r.stdout),\n );\n return 'failed';\n }\n return 'ok';\n}\n\nfunction buildCommandFor(\n name: string,\n opts: Pick<LocalizeOptions, 'build'>,\n): string {\n if (opts.build !== undefined) return opts.build;\n return name === CLI_PACKAGE ? CLI_BUILD_COMMAND : DEFAULT_BUILD_COMMAND;\n}\n\nexport function reportError(e: unknown, deps: Pick<Deps, 'error'>): number {\n if (e instanceof LocalizeError) {\n deps.error(`[localize] ${e.message}`);\n return e.code;\n }\n throw e;\n}\n\n/**\n * The checked-out branch, or `HEAD` when detached. `symbolic-ref` first,\n * because it also names the branch of a repository with no commits yet --\n * `rev-parse --abbrev-ref` fails there, and `create-package` adopts a fresh\n * `git init` before its first commit.\n */\nexport function currentBranch(\n checkout: string,\n deps: Pick<Deps, 'run'>,\n): string {\n const sym = deps.run('git', ['symbolic-ref', '--short', '-q', 'HEAD'], {\n cwd: checkout,\n });\n if (sym.status === 0 && sym.stdout.trim()) return sym.stdout.trim();\n const r = deps.run('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {\n cwd: checkout,\n });\n const b = r.stdout.trim();\n return r.status === 0 && b ? b : 'HEAD';\n}\n\n/** The last lines of a subprocess's output: enough to see the error, not the whole log. */\nexport function tail(output: string, lines = 20): string {\n return output.trim().split('\\n').slice(-lines).join('\\n');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localize.js","sourceRoot":"","sources":["../../../src/localize/localize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAC,oBAAoB,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACxD,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAEnD,qEAAqE;AACrE,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,kGAAkG;AAClG,MAAM,WAAW,GAAG,cAAc,CAAC;AACnC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAC1C,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;AACnE,oFAAoF;AACpF,MAAM,SAAS,GAAG,GAAG,SAAS,SAAS,CAAC;AACxC;;;;;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cAAc,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QACtC,OAAO,CAAC,CAAC,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,CAAC,CAAC;AACV,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAgB,EAChB,IAAuB;IAEvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;QACrE,GAAG,EAAE,QAAQ;KACd,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;QAAE,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACpE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE;QAC/D,GAAG,EAAE,QAAQ;KACd,CAAC,CAAC;IACH,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC1B,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC1C,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,IAAI,CAAC,MAAc,EAAE,KAAK,GAAG,EAAE;IAC7C,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * `localize` -- turn an npm-installed dependency into an editable git checkout\n * that npm itself links.\n *\n * A checkout in `packages-local/` is a workspace member: the app's\n * `workspaces` holds `\"packages-local/*\"`, so `npm install` links\n * `node_modules/<name>` to it and dedupes everything below it like any other\n * member. The committed `package-lock.json` is put back after every install by\n * `hooks/lock-at-rest.cjs`, so the working tree stays clean.\n *\n * One run, for every name at once:\n *\n * 1. refuse an `overrides` key naming a package being localized or already\n * in `packages-local/` (npm fails with `EOVERRIDE` on a member's name);\n * nothing is changed then;\n * 2. the one-time app setup (app-setup.ts), reported line by line so the\n * developer commits it; when it changed `package.json`, the lockfile\n * that goes with it is made now, before anything is cloned, and written\n * back after the install (`captureSetupLockfile`);\n * 3. per name: a parked checkout (`linked delocalize`) moves back; an\n * existing directory is refused with an `--adopt` hint; anything else is\n * resolved through the registry's `repository` (or `--repo`) and cloned;\n * 4. the git hooks (git-hooks.ts), or the lines to add under\n * `core.hooksPath`;\n * 5. ONE `npm install` at the app root -- a checkout's dependencies arrive\n * with it, so it comes before any build;\n * 6. build each new checkout: `--build`, else `linked build`, else for the\n * cli its own `npm run build` (the cli is what `linked build` runs, and a\n * fresh cli checkout has no `lib/` yet). The cli builds first and then\n * gets its bin linked (`npm rebuild`), since the others' `linked build`\n * runs it. A failing build warns: a package whose build is broken is\n * usually what you localized it to fix.\n *\n * `adopt` (adopt.ts) replaces step 3 with \"the checkout is already there\", and\n * `--parked` with \"every parked checkout\". Steps 1, 2 and 4-6 are `runLocalize`.\n *\n * A package inside a monorepo (`--subdir`, or a registry `repository.directory`)\n * is cloned whole into `packages-local/.repos/<checkout>` -- a dot directory,\n * which the `packages-local/*` glob skips -- and `packages-local/<checkout>` is\n * a link to the package inside it. npm follows the link like a directory.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {conflictingOverrides, ensureAppSetup} from './app-setup.js';\nimport type {SetupChange} from './app-setup.js';\nimport {describeDrift, driftProblems} from './drift.js';\nimport {\n EXIT_INSTALL_FAILED,\n EXIT_REFUSED,\n EXIT_USAGE,\n EXIT_WARNED,\n LocalizeError,\n} from './errors.js';\nimport {existsOrLink, moveEntry, readJson} from './fsops.js';\nimport {installGitHooks} from './git-hooks.js';\nimport type {HookInstall} from './git-hooks.js';\nimport {LOCAL_DIR, localMembers, parkedMembers} from './members.js';\nimport {setupLockfileByEdit} from './setup-lockfile.js';\nimport type {Member} from './members.js';\nimport {checkoutNameFor, resolvePackage} from './resolve.js';\nimport type {Deps, RunResult} from './run.js';\nimport {linkDirectory} from '../utils/platform.js';\n\n/** What a new checkout is built with when `--build` does not say. */\nexport const DEFAULT_BUILD_COMMAND = 'linked build';\n/** The cli builds itself: `linked build` IS the cli, and a fresh checkout of it has no `lib/`. */\nconst CLI_PACKAGE = '@_linked/cli';\nconst CLI_BUILD_COMMAND = 'npm run build';\n/** The one install a run makes, at the app root. */\nexport const INSTALL_ARGS = ['install', '--no-audit', '--no-fund'];\n/** Where a cloned monorepo lives, inside `packages-local/` but outside its glob. */\nconst REPOS_DIR = `${LOCAL_DIR}/.repos`;\n/**\n * Where the set-up's lockfile run puts the checkouts while npm makes it:\n * inside the gitignored `packages-local/`, outside its glob (npm skips dot\n * directories). A run interrupted there leaves them in it; the next\n * `localize`, `delocalize` or `--list` moves them back (`restoreSetAside`).\n */\nconst SETUP_ASIDE_DIR = `${LOCAL_DIR}/.setup-aside`;\n/** The app's lockfile, kept clean of checkouts. */\nexport const LOCKFILE = 'package-lock.json';\n\nexport interface LocalizeOptions {\n /** Where checkouts live. Only `packages-local` is accepted: the workspace glob names it. */\n dir?: string;\n repo?: string;\n subdir?: string;\n /** Run in each new checkout after the install. Absent: the default; empty: no build. */\n build?: string;\n}\n\n/** A checkout ready for the install. */\nexport interface Prepared {\n name: string;\n /** App-relative, `/`-separated: `packages-local/_linked-core`. */\n dir: string;\n /** Build it after the install: a new clone or an adopted checkout, not a returning parked one. */\n build: boolean;\n}\n\n/** How one name becomes a checkout in `packages-local/`; null when there is nothing to do. */\nexport type Prepare = (\n name: string,\n opts: LocalizeOptions,\n deps: Deps,\n) => Prepared | null;\n\n/**\n * @param names full npm package names\n * @returns the process exit code: the highest of the per-name codes and the\n * install's, since a failure on name 2 does not undo name 1.\n */\nexport function localize(\n names: string[],\n opts: LocalizeOptions,\n deps: Deps,\n): number {\n return runLocalize(names, opts, deps, prepareClone);\n}\n\n/**\n * The run `localize`, `adopt` and `--parked` share: everything except how a\n * name becomes a checkout. See the module header for the steps.\n */\nexport function runLocalize(\n names: string[],\n opts: LocalizeOptions,\n deps: Deps,\n prepare: Prepare,\n): number {\n let setupLock: string | undefined;\n try {\n restoreSetAside(deps);\n checkDir(opts.dir);\n // The checkouts already there count too: the one install below covers them all.\n const localized = new Set([\n ...names,\n ...localMembers(deps.appRoot).map((m) => m.name),\n ]);\n const conflicts = conflictingOverrides(deps.appRoot, [...localized]);\n if (conflicts.length) {\n throw new LocalizeError(\n `package.json \"overrides\" names a localized package: ${conflicts\n .map((k) => `\"${k}\"`)\n .join(', ')}.\\n` +\n `npm refuses an override on a workspace member's name (EOVERRIDE), and a nested one ` +\n `would replace the checkout. Remove ${conflicts.length === 1 ? 'that key' : 'those keys'} ` +\n `from \"overrides\", then run this again. Nothing was changed.`,\n EXIT_REFUSED,\n );\n }\n const workspacesBefore = readJson(\n path.join(deps.appRoot, 'package.json'),\n )?.workspaces;\n const changes = ensureAppSetup(deps.appRoot);\n reportSetup(changes, deps);\n if (changes.some((c) => c.file === 'package.json'))\n setupLock =\n captureSetupLockfile(changes, workspacesBefore, deps) ?? undefined;\n } catch (e) {\n return reportError(e, deps);\n }\n\n let code = 0;\n const prepared: Prepared[] = [];\n for (const name of names) {\n try {\n const p = prepare(name, opts, deps);\n if (p) prepared.push(p);\n } catch (e) {\n code = Math.max(code, reportError(e, deps));\n }\n }\n if (!prepared.length) {\n // Nothing was installed: the work tree holds the set-up's lockfile as captured.\n if (setupLock !== undefined) commitHint(deps);\n return code;\n }\n return Math.max(code, installAndBuild(prepared, opts, deps, setupLock));\n}\n\n/**\n * Steps 4-6: git hooks, one root install, then the builds. `setupLock` is the\n * lockfile the set-up captured (see `captureSetupLockfile`), written back\n * over what the install left.\n */\nexport function installAndBuild(\n prepared: Prepared[],\n opts: Pick<LocalizeOptions, 'build'>,\n deps: Deps,\n setupLock?: string,\n): number {\n reportHooks(installGitHooks(deps.appRoot), deps);\n\n deps.log(`[localize] npm ${INSTALL_ARGS.join(' ')} (app root)`);\n const install = deps.run('npm', INSTALL_ARGS, {cwd: deps.appRoot});\n if (setupLock !== undefined) restoreSetupLockfile(setupLock, deps);\n if (install.status !== 0) {\n deps.error(\n `[localize] npm install failed at the app root. The checkout${prepared.length === 1 ? ' stays' : 's stay'} ` +\n `in ${LOCAL_DIR}/; fix the cause and run \\`npm install\\`.\\n` +\n tail(install.stderr || install.stdout),\n );\n return EXIT_INSTALL_FAILED;\n }\n\n let code = 0;\n // The cli first: the other builds run `linked build`, which is the cli.\n const ordered = [\n ...prepared.filter((p) => p.name === CLI_PACKAGE),\n ...prepared.filter((p) => p.name !== CLI_PACKAGE),\n ];\n for (const p of ordered) {\n const pkgDir = path.join(deps.appRoot, p.dir);\n const built = p.build ? runBuild(p, pkgDir, opts, deps) : 'skipped';\n if (built === 'failed') code = EXIT_WARNED;\n if (built === 'ok' && p.name === CLI_PACKAGE) linkCliBin(deps);\n deps.log(\n `[localize] ${p.name} -> ${p.dir} (branch ${currentBranch(pkgDir, deps)})`,\n );\n }\n for (const d of driftProblems(deps.appRoot))\n deps.warn(`[localize] drift: ${describeDrift(d)}`);\n return code;\n}\n\n/**\n * npm links a package's bin only when its target exists, and a fresh cli\n * checkout has no `lib/` at install time: without this, `node_modules/.bin/linked`\n * is missing after the build, and `npx linked` would fetch the unrelated npm\n * package named `linked`. `--ignore-scripts`: only the bin links are wanted.\n */\nfunction linkCliBin(deps: Deps): void {\n const r = deps.run('npm', ['rebuild', CLI_PACKAGE, '--ignore-scripts'], {\n cwd: deps.appRoot,\n });\n if (r.status !== 0) {\n deps.warn(\n `[localize] npm rebuild ${CLI_PACKAGE} failed, so \\`linked\\` may not be on the app's ` +\n `bin path. Run it yourself.\\n` +\n tail(r.stderr || r.stdout),\n );\n }\n}\n\n/** Step 3 for `localize`: take back a parked checkout, else clone. */\nfunction prepareClone(\n name: string,\n opts: LocalizeOptions,\n deps: Deps,\n): Prepared | null {\n const parked = parkedMembers(deps.appRoot).find((m) => m.name === name);\n if (parked) return unpark(parked, deps);\n\n const member = localMembers(deps.appRoot).find((m) => m.name === name);\n if (member) {\n throw new LocalizeError(\n `${name} is already in ${member.dir}. To install and build it as it is:\\n` +\n ` linked localize ${name} --adopt`,\n EXIT_REFUSED,\n );\n }\n\n const relDir = `${LOCAL_DIR}/${checkoutNameFor(name)}`;\n const target = path.join(deps.appRoot, relDir);\n if (existsOrLink(target)) {\n throw new LocalizeError(\n `${relDir} already exists. localize never clones over a directory. If it is ${name}'s ` +\n `checkout, install and build it as it is:\\n linked localize ${name} --adopt`,\n EXIT_REFUSED,\n );\n }\n\n const resolved = resolvePackage(\n name,\n deps,\n opts.repo ? {repo: opts.repo, subdir: opts.subdir} : undefined,\n );\n\n // A monorepo is cloned whole outside the glob; the member is a link to the package.\n const relClone = resolved.subdir\n ? `${REPOS_DIR}/${checkoutNameFor(name)}`\n : relDir;\n const clone = path.join(deps.appRoot, relClone);\n if (existsOrLink(clone)) {\n throw new LocalizeError(\n `${relClone} already exists. Remove it, or move it out of the way, and run this again.`,\n EXIT_REFUSED,\n );\n }\n fs.mkdirSync(path.dirname(clone), {recursive: true});\n deps.log(`[localize] cloning ${resolved.repo} -> ${relClone}`);\n const r = deps.run('git', ['clone', '--', resolved.repo, clone]);\n if (r.status !== 0) {\n throw new LocalizeError(\n `git clone ${resolved.repo} failed:\\n${(r.stderr || r.stdout).trim()}`,\n EXIT_REFUSED,\n );\n }\n\n const pkgDir = resolved.subdir ? path.join(clone, resolved.subdir) : clone;\n const relPkg = resolved.subdir ? `${relClone}/${resolved.subdir}` : relClone;\n // A clone that is not the package must not stay: in packages-local/ it\n // would be a workspace member under the wrong name.\n const declared = readJson(path.join(pkgDir, 'package.json'))?.name;\n if (declared !== name) {\n fs.rmSync(clone, {recursive: true, force: true});\n const where = resolved.subdir\n ? `The registry's repository.directory for \"${name}\" points at the wrong place.`\n : `${resolved.repo} looks like a monorepo. Say where the package lives:\\n` +\n ` linked localize ${name} --repo ${resolved.repo} --subdir <path-inside-the-repo>`;\n throw new LocalizeError(\n (declared\n ? `${relPkg} declares itself as \"${declared}\", not \"${name}\".\\n`\n : `${relPkg} has no package.json naming it, so it is not the package \"${name}\".\\n`) +\n `${where}\\nThe clone was removed.`,\n EXIT_REFUSED,\n );\n }\n\n if (resolved.subdir) {\n linkDirectory(pkgDir, target);\n deps.log(`[localize] ${relDir} -> ${relPkg}`);\n }\n return {name, dir: relDir, build: true};\n}\n\n/** Move a parked checkout back into `packages-local/`. No clone, no build: it is as it was. */\nexport function unpark(member: Member, deps: Deps): Prepared {\n const entry = path.basename(member.dir);\n const relDir = `${LOCAL_DIR}/${entry}`;\n const to = path.join(deps.appRoot, relDir);\n if (existsOrLink(to)) {\n throw new LocalizeError(\n `${member.name} is parked in ${member.dir}, but ${relDir} already exists. Move one of ` +\n `them out of the way and run this again.`,\n EXIT_REFUSED,\n );\n }\n // npm refuses two workspace members of one name, so the install would fail.\n const same = localMembers(deps.appRoot).find((m) => m.name === member.name);\n if (same) {\n throw new LocalizeError(\n `${member.name} is parked in ${member.dir}, but ${same.dir} is ${member.name} already. ` +\n `Keep one: delete or move the other out of the way, and run this again.`,\n EXIT_REFUSED,\n );\n }\n moveEntry(path.join(deps.appRoot, member.dir), to);\n deps.log(`[localize] ${member.dir} -> ${relDir}`);\n return {name: member.name, dir: relDir, build: false};\n}\n\n/** `--dir` is kept for scripts that pass the default; anything else is not a workspace member. */\nfunction checkDir(dir: string | undefined): void {\n if (dir === undefined || dir.replace(/\\/+$/, '') === LOCAL_DIR) return;\n throw new LocalizeError(\n `--dir ${dir}: checkouts live in ${LOCAL_DIR}/, the directory the app's ` +\n `\"workspaces\" glob and the lock-at-rest hook name. Move them there.`,\n EXIT_USAGE,\n );\n}\n\nfunction reportSetup(changes: SetupChange[], deps: Deps): void {\n if (!changes.length) return;\n deps.log(`[localize] set up this app for checkouts (commit these):`);\n for (const c of changes) deps.log(` ${c.file}: ${c.what}`);\n}\n\n/** What `captureSetupLockfile` runs: the lockfile for the new `package.json`, nothing installed. */\nconst SETUP_LOCK_ARGS = [\n 'install',\n '--package-lock-only',\n '--ignore-scripts',\n '--no-audit',\n '--no-fund',\n];\n\n/**\n * The set-up changed `package.json`, so the lockfile must change with it\n * (the root entry's `workspaces`) -- and it must be a lockfile with no\n * checkout in it, which the install below cannot give: it lists them, and\n * lock-at-rest leaves it so while `package.json` differs from HEAD. So,\n * before anything is cloned, make that lockfile, keep it, and write it back\n * after the install. When the root entry already has `workspaces` and\n * `hasInstallScript`, it is an edit of that entry (setup-lockfile.ts: exact,\n * offline); otherwise npm makes the lockfile alone, with checkouts already in\n * `packages-local/` (an adopted one) moved into `SETUP_ASIDE_DIR` for that\n * one call.\n *\n * @returns the lockfile to write back, or null when it could not be made (the\n * manual steps are printed instead).\n */\nfunction captureSetupLockfile(\n changes: SetupChange[],\n workspacesBefore: unknown,\n deps: Deps,\n): string | null {\n const lockfile = path.join(deps.appRoot, LOCKFILE);\n const edited = editedSetupLockfile(lockfile, workspacesBefore, deps);\n if (edited !== null) return edited;\n const moveAside = localMembers(deps.appRoot).length > 0;\n deps.log(\n `[localize] npm ${SETUP_LOCK_ARGS.join(' ')} (the set-up's lockfile)`,\n );\n if (moveAside) setAside(deps);\n let r: RunResult;\n try {\n r = deps.run('npm', SETUP_LOCK_ARGS, {cwd: deps.appRoot});\n } finally {\n if (moveAside) moveBack(deps);\n }\n let text: string | null = null;\n try {\n text = fs.readFileSync(lockfile, 'utf8');\n } catch {\n /* none written */\n }\n if (r.status !== 0 || text === null) {\n manualSetupSteps(\n changes,\n r.status !== 0\n ? `npm could not write it:\\n${tail(r.stderr || r.stdout)}`\n : `npm wrote no ${LOCKFILE}`,\n deps,\n );\n return null;\n }\n return text;\n}\n\n/**\n * Every entry of `packages-local/` but the dot directories, moved into\n * `SETUP_ASIDE_DIR` as it is (a link keeps its text and works again once back).\n */\nfunction setAside(deps: Pick<Deps, 'appRoot'>): void {\n const local = path.join(deps.appRoot, LOCAL_DIR);\n const aside = path.join(deps.appRoot, SETUP_ASIDE_DIR);\n fs.mkdirSync(aside, {recursive: true});\n for (const entry of fs.readdirSync(local)) {\n if (entry.startsWith('.')) continue;\n fs.renameSync(path.join(local, entry), path.join(aside, entry));\n }\n}\n\n/** Everything in `SETUP_ASIDE_DIR` back into `packages-local/`; the directory goes. */\nfunction moveBack(deps: Pick<Deps, 'appRoot'>): number {\n const local = path.join(deps.appRoot, LOCAL_DIR);\n const aside = path.join(deps.appRoot, SETUP_ASIDE_DIR);\n const entries = fs.readdirSync(aside);\n for (const entry of entries)\n fs.renameSync(path.join(aside, entry), path.join(local, entry));\n fs.rmdirSync(aside);\n return entries.length;\n}\n\n/**\n * A set-up run that was interrupted while the checkouts were in\n * `SETUP_ASIDE_DIR` left them there, where npm does not see them: move them\n * back, saying so. Refuses, moving nothing, when `packages-local/` already\n * has an entry of the same name.\n */\nexport function restoreSetAside(deps: Pick<Deps, 'appRoot' | 'log'>): void {\n const aside = path.join(deps.appRoot, SETUP_ASIDE_DIR);\n if (!existsOrLink(aside)) return;\n let entries: string[];\n try {\n entries = fs.readdirSync(aside);\n } catch {\n throw new LocalizeError(\n `${SETUP_ASIDE_DIR} is not a directory. Remove it and run this again.`,\n EXIT_REFUSED,\n );\n }\n const clashes = entries.filter((e) =>\n existsOrLink(path.join(deps.appRoot, LOCAL_DIR, e)),\n );\n if (clashes.length) {\n throw new LocalizeError(\n `${SETUP_ASIDE_DIR}/ holds checkouts an interrupted set-up left there, but ` +\n `${clashes.map((e) => `${LOCAL_DIR}/${e}`).join(', ')} now exist${clashes.length === 1 ? 's' : ''} ` +\n `too. Keep one of each, move the other out of ${LOCAL_DIR}/, and run this again. ` +\n `Nothing was moved.`,\n EXIT_REFUSED,\n );\n }\n const n = moveBack(deps);\n if (n)\n deps.log(\n `[localize] moved ${n} checkout${n === 1 ? '' : 's'} back from ${SETUP_ASIDE_DIR}/ into ` +\n `${LOCAL_DIR}/, where an interrupted set-up left ${n === 1 ? 'it' : 'them'}.`,\n );\n}\n\n/** The set-up's lockfile as an edit of the root entry, written now; null when npm must make it. */\nfunction editedSetupLockfile(\n lockfile: string,\n workspacesBefore: unknown,\n deps: Deps,\n): string | null {\n let current: string;\n try {\n current = fs.readFileSync(lockfile, 'utf8');\n } catch {\n return null;\n }\n const text = setupLockfileByEdit(\n current,\n readJson(path.join(deps.appRoot, 'package.json')),\n workspacesBefore,\n );\n if (text === null) return null;\n fs.writeFileSync(lockfile, text);\n deps.log(\n `[localize] ${LOCKFILE}: the root entry's \"workspaces\" now matches package.json (the set-up's lockfile)`,\n );\n return text;\n}\n\n/** Put the captured set-up lockfile back after the install rewrote it. */\nfunction restoreSetupLockfile(text: string, deps: Deps): void {\n fs.writeFileSync(path.join(deps.appRoot, LOCKFILE), text);\n deps.log(\n `[localize] ${LOCKFILE}: put back the set-up's lockfile, which lists no checkout (any ` +\n `lock-at-rest warning above was about the one the install wrote).`,\n );\n commitHint(deps);\n}\n\nfunction commitHint(deps: Deps): void {\n deps.log(\n `[localize] commit the set-up now -- package.json, ${LOCKFILE}, .gitignore:\\n` +\n ` git add package.json ${LOCKFILE} .gitignore && git commit -m \"chore: set up linked localize\"`,\n );\n}\n\n/** The set-up's lockfile could not be made in one step: how to make it by hand. */\nfunction manualSetupSteps(\n changes: SetupChange[],\n why: string,\n deps: Deps,\n): void {\n const files = [...new Set([...changes.map((c) => c.file), LOCKFILE])];\n deps.warn(\n `[localize] could not make the set-up's ${LOCKFILE} in one step: ${why}\\n` +\n `Commit the set-up with a lockfile from an install with no checkout present:\\n` +\n ` npx linked delocalize\\n` +\n ` npm install\\n` +\n ` git add ${files.join(' ')} && git commit -m \"chore: set up linked localize\"\\n` +\n ` npx linked localize --parked`,\n );\n}\n\n/** Tell the developer what `installGitHooks` did not do. */\nfunction reportHooks(hooks: HookInstall, deps: Deps): void {\n for (const file of hooks.skipped) {\n deps.warn(\n `[localize] ${path.relative(deps.appRoot, file)} is not ours, so it was left alone. Without ` +\n `the localize hook there, run \\`npm install\\` yourself after a pull or branch switch that ` +\n `changes dependencies.`,\n );\n }\n if (hooks.hooksPath !== null) {\n deps.warn(\n `[localize] core.hooksPath is set (${hooks.hooksPath}), so no git hooks were written. Add ` +\n `each line below to the hook named before it, an \\`sh\\` script (not, say, a Python hook ` +\n `the pre-commit framework writes); they do nothing where the cli is not installed:`,\n );\n for (const m of hooks.manual) deps.warn(` ${m.file}:\\n ${m.line}`);\n }\n if (hooks.sharedWithWorktrees) {\n deps.warn(\n `[localize] this is a linked worktree: git hooks are shared by every worktree of the ` +\n `repository. They act only in a work tree whose ${LOCAL_DIR}/ has checkouts.`,\n );\n }\n}\n\n/**\n * Run the build for one new checkout. `opts.build` wins, including `''` for\n * no build; otherwise the cli builds itself and everything else gets\n * `linked build`.\n */\nfunction runBuild(\n p: Prepared,\n pkgDir: string,\n opts: Pick<LocalizeOptions, 'build'>,\n deps: Deps,\n): 'skipped' | 'ok' | 'failed' {\n const cmd = buildCommandFor(p.name, opts);\n if (!cmd) return 'skipped';\n deps.log(`[localize] ${p.dir}: ${cmd}`);\n const r = deps.run(cmd, [], {cwd: pkgDir, shell: true});\n if (r.status !== 0) {\n deps.warn(\n `[localize] ${p.dir}: \\`${cmd}\\` failed. It is installed and linked anyway -- a package ` +\n `whose build is broken is usually what you localized it to fix.\\n` +\n tail(r.stderr || r.stdout),\n );\n return 'failed';\n }\n return 'ok';\n}\n\nfunction buildCommandFor(\n name: string,\n opts: Pick<LocalizeOptions, 'build'>,\n): string {\n if (opts.build !== undefined) return opts.build;\n return name === CLI_PACKAGE ? CLI_BUILD_COMMAND : DEFAULT_BUILD_COMMAND;\n}\n\nexport function reportError(e: unknown, deps: Pick<Deps, 'error'>): number {\n if (e instanceof LocalizeError) {\n deps.error(`[localize] ${e.message}`);\n return e.code;\n }\n throw e;\n}\n\n/**\n * The checked-out branch, or `HEAD` when detached. `symbolic-ref` first,\n * because it also names the branch of a repository with no commits yet --\n * `rev-parse --abbrev-ref` fails there, and `create-package` adopts a fresh\n * `git init` before its first commit.\n */\nexport function currentBranch(\n checkout: string,\n deps: Pick<Deps, 'run'>,\n): string {\n const sym = deps.run('git', ['symbolic-ref', '--short', '-q', 'HEAD'], {\n cwd: checkout,\n });\n if (sym.status === 0 && sym.stdout.trim()) return sym.stdout.trim();\n const r = deps.run('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {\n cwd: checkout,\n });\n const b = r.stdout.trim();\n return r.status === 0 && b ? b : 'HEAD';\n}\n\n/** The last lines of a subprocess's output: enough to see the error, not the whole log. */\nexport function tail(output: string, lines = 20): string {\n return output.trim().split('\\n').slice(-lines).join('\\n');\n}\n"]}
|