@_linked/cli 1.46.2 → 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 +113 -0
- package/README.md +44 -36
- package/hooks/drift.cjs +169 -0
- package/hooks/git-hook.cjs +170 -0
- package/hooks/hook-shim.cjs +63 -0
- package/hooks/lock-at-rest.cjs +268 -0
- package/hooks/manifests.cjs +216 -0
- package/hooks/platform.cjs +25 -0
- package/lib/esm/app-release/build-backend.d.ts.map +1 -1
- package/lib/esm/app-release/build-backend.js +2 -1
- package/lib/esm/app-release/build-backend.js.map +1 -1
- package/lib/esm/cli-methods.d.ts.map +1 -1
- package/lib/esm/cli-methods.js +166 -150
- package/lib/esm/cli-methods.js.map +1 -1
- package/lib/esm/cli.js +20 -22
- package/lib/esm/cli.js.map +1 -1
- package/lib/esm/commands/build-app.d.ts.map +1 -1
- package/lib/esm/commands/build-app.js +2 -1
- package/lib/esm/commands/build-app.js.map +1 -1
- package/lib/esm/commands/build-package.d.ts.map +1 -1
- package/lib/esm/commands/build-package.js +6 -2
- package/lib/esm/commands/build-package.js.map +1 -1
- package/lib/esm/commands/localize.d.ts +9 -15
- package/lib/esm/commands/localize.d.ts.map +1 -1
- package/lib/esm/commands/localize.js +43 -74
- package/lib/esm/commands/localize.js.map +1 -1
- package/lib/esm/commands/setup-publish.d.ts.map +1 -1
- package/lib/esm/commands/setup-publish.js +22 -15
- package/lib/esm/commands/setup-publish.js.map +1 -1
- package/lib/esm/commands/start.d.ts +8 -0
- package/lib/esm/commands/start.d.ts.map +1 -1
- package/lib/esm/commands/start.js +20 -8
- package/lib/esm/commands/start.js.map +1 -1
- package/lib/esm/installed-packages.d.ts +5 -13
- package/lib/esm/installed-packages.d.ts.map +1 -1
- package/lib/esm/installed-packages.js +5 -38
- package/lib/esm/installed-packages.js.map +1 -1
- package/lib/esm/lifecycle.d.ts +35 -22
- package/lib/esm/lifecycle.d.ts.map +1 -1
- package/lib/esm/lifecycle.js +62 -36
- package/lib/esm/lifecycle.js.map +1 -1
- package/lib/esm/localize/adopt.d.ts +5 -5
- package/lib/esm/localize/adopt.d.ts.map +1 -1
- package/lib/esm/localize/adopt.js +46 -55
- package/lib/esm/localize/adopt.js.map +1 -1
- package/lib/esm/localize/app-root.d.ts +16 -0
- package/lib/esm/localize/app-root.d.ts.map +1 -0
- package/lib/esm/localize/app-root.js +94 -0
- package/lib/esm/localize/app-root.js.map +1 -0
- package/lib/esm/localize/app-setup.d.ts +21 -0
- package/lib/esm/localize/app-setup.d.ts.map +1 -0
- package/lib/esm/localize/app-setup.js +178 -0
- package/lib/esm/localize/app-setup.js.map +1 -0
- package/lib/esm/localize/delocalize.d.ts.map +1 -1
- package/lib/esm/localize/delocalize.js +168 -104
- package/lib/esm/localize/delocalize.js.map +1 -1
- package/lib/esm/localize/drift-hook.d.ts +18 -0
- package/lib/esm/localize/drift-hook.d.ts.map +1 -0
- package/lib/esm/localize/drift-hook.js +37 -0
- package/lib/esm/localize/drift-hook.js.map +1 -0
- package/lib/esm/localize/drift.d.ts +36 -0
- package/lib/esm/localize/drift.d.ts.map +1 -0
- package/lib/esm/localize/drift.js +34 -0
- package/lib/esm/localize/drift.js.map +1 -0
- package/lib/esm/localize/errors.d.ts +14 -8
- package/lib/esm/localize/errors.d.ts.map +1 -1
- package/lib/esm/localize/errors.js +14 -8
- package/lib/esm/localize/errors.js.map +1 -1
- package/lib/esm/localize/fsops.d.ts +11 -27
- package/lib/esm/localize/fsops.d.ts.map +1 -1
- package/lib/esm/localize/fsops.js +40 -115
- package/lib/esm/localize/fsops.js.map +1 -1
- package/lib/esm/localize/git-hooks.d.ts +33 -0
- package/lib/esm/localize/git-hooks.d.ts.map +1 -0
- package/lib/esm/localize/git-hooks.js +146 -0
- package/lib/esm/localize/git-hooks.js.map +1 -0
- package/lib/esm/localize/hook-module.d.ts +6 -0
- package/lib/esm/localize/hook-module.d.ts.map +1 -0
- package/lib/esm/localize/hook-module.js +37 -0
- package/lib/esm/localize/hook-module.js.map +1 -0
- package/lib/esm/localize/index.d.ts +14 -15
- package/lib/esm/localize/index.d.ts.map +1 -1
- package/lib/esm/localize/index.js +8 -9
- package/lib/esm/localize/index.js.map +1 -1
- package/lib/esm/localize/list.d.ts +6 -10
- package/lib/esm/localize/list.d.ts.map +1 -1
- package/lib/esm/localize/list.js +48 -189
- package/lib/esm/localize/list.js.map +1 -1
- package/lib/esm/localize/localize.d.ts +41 -62
- package/lib/esm/localize/localize.d.ts.map +1 -1
- package/lib/esm/localize/localize.js +398 -285
- package/lib/esm/localize/localize.js.map +1 -1
- package/lib/esm/localize/members.d.ts +13 -0
- package/lib/esm/localize/members.d.ts.map +1 -0
- package/lib/esm/localize/members.js +46 -0
- package/lib/esm/localize/members.js.map +1 -0
- package/lib/esm/localize/resolve.d.ts +1 -2
- package/lib/esm/localize/resolve.d.ts.map +1 -1
- package/lib/esm/localize/resolve.js +3 -5
- package/lib/esm/localize/resolve.js.map +1 -1
- package/lib/esm/localize/run.d.ts +1 -0
- package/lib/esm/localize/run.d.ts.map +1 -1
- package/lib/esm/localize/run.js +11 -6
- package/lib/esm/localize/run.js.map +1 -1
- package/lib/esm/localize/setup-lockfile.d.ts +13 -0
- package/lib/esm/localize/setup-lockfile.d.ts.map +1 -0
- package/lib/esm/localize/setup-lockfile.js +80 -0
- package/lib/esm/localize/setup-lockfile.js.map +1 -0
- package/lib/esm/utils/createPackageLocation.d.ts +4 -13
- package/lib/esm/utils/createPackageLocation.d.ts.map +1 -1
- package/lib/esm/utils/createPackageLocation.js +12 -21
- package/lib/esm/utils/createPackageLocation.js.map +1 -1
- package/lib/esm/utils/packageSetup.d.ts +5 -2
- package/lib/esm/utils/packageSetup.d.ts.map +1 -1
- package/lib/esm/utils/packageSetup.js +9 -3
- package/lib/esm/utils/packageSetup.js.map +1 -1
- package/lib/esm/utils/platform.d.ts +24 -0
- package/lib/esm/utils/platform.d.ts.map +1 -0
- package/lib/esm/utils/platform.js +62 -0
- package/lib/esm/utils/platform.js.map +1 -0
- package/lib/esm/utils/shapeReferences.d.ts.map +1 -1
- package/lib/esm/utils/shapeReferences.js +3 -2
- package/lib/esm/utils/shapeReferences.js.map +1 -1
- package/lib/esm/utils/spawn.d.ts +65 -0
- package/lib/esm/utils/spawn.d.ts.map +1 -0
- package/lib/esm/utils/spawn.js +181 -0
- package/lib/esm/utils/spawn.js.map +1 -0
- package/lib/esm/utils.d.ts.map +1 -1
- package/lib/esm/utils.js +19 -5
- package/lib/esm/utils.js.map +1 -1
- package/lib/esm/vite-config.d.ts +5 -12
- package/lib/esm/vite-config.d.ts.map +1 -1
- package/lib/esm/vite-config.js +41 -33
- package/lib/esm/vite-config.js.map +1 -1
- package/package.json +4 -3
- package/lib/esm/localize/ensure.d.ts +0 -44
- package/lib/esm/localize/ensure.d.ts.map +0 -1
- package/lib/esm/localize/ensure.js +0 -151
- package/lib/esm/localize/ensure.js.map +0 -1
- package/lib/esm/localize/manifest.d.ts +0 -63
- package/lib/esm/localize/manifest.d.ts.map +0 -1
- package/lib/esm/localize/manifest.js +0 -133
- package/lib/esm/localize/manifest.js.map +0 -1
- package/lib/esm/localize/one-copy-hook.d.ts +0 -16
- package/lib/esm/localize/one-copy-hook.d.ts.map +0 -1
- package/lib/esm/localize/one-copy-hook.js +0 -20
- package/lib/esm/localize/one-copy-hook.js.map +0 -1
- package/lib/esm/localize/provided.d.ts +0 -28
- package/lib/esm/localize/provided.d.ts.map +0 -1
- package/lib/esm/localize/provided.js +0 -89
- package/lib/esm/localize/provided.js.map +0 -1
- package/lib/esm/localize/prune.d.ts +0 -182
- package/lib/esm/localize/prune.d.ts.map +0 -1
- package/lib/esm/localize/prune.js +0 -703
- package/lib/esm/localize/prune.js.map +0 -1
- package/lib/esm/localize/relink.d.ts +0 -13
- package/lib/esm/localize/relink.d.ts.map +0 -1
- package/lib/esm/localize/relink.js +0 -181
- package/lib/esm/localize/relink.js.map +0 -1
- package/lib/esm/localized-dedupe.d.ts +0 -26
- package/lib/esm/localized-dedupe.d.ts.map +0 -1
- package/lib/esm/localized-dedupe.js +0 -139
- package/lib/esm/localized-dedupe.js.map +0 -1
- package/lib/esm/utils/relinkHooks.d.ts +0 -19
- package/lib/esm/utils/relinkHooks.d.ts.map +0 -1
- package/lib/esm/utils/relinkHooks.js +0 -74
- package/lib/esm/utils/relinkHooks.js.map +0 -1
package/lib/esm/lifecycle.js
CHANGED
|
@@ -19,10 +19,11 @@ import path from 'path';
|
|
|
19
19
|
import chalk from 'chalk';
|
|
20
20
|
import { getPackageJSON } from './utils.js';
|
|
21
21
|
import { isLinkedPackageJson } from './installed-packages.js';
|
|
22
|
-
import {
|
|
22
|
+
import { LOCAL_DIR, localMembers } from './localize/members.js';
|
|
23
23
|
import { parseWorkspacePatterns, isWorkspacePathNegated } from './workspace-globs.js';
|
|
24
24
|
// Shared with the CSS loader's mode resolution, which must pick the same profiles.
|
|
25
25
|
import { readEnvNamesFromArgv } from './loader-mode.js';
|
|
26
|
+
import { importFile } from './utils/platform.js';
|
|
26
27
|
/**
|
|
27
28
|
* Load the app's environment into `process.env`, then re-apply the original
|
|
28
29
|
* shell env so it always wins on conflict. Idempotent — runs at most once.
|
|
@@ -157,7 +158,7 @@ export function loadBackendStorageConfig() {
|
|
|
157
158
|
// Variable specifier is intentional — we discover the path at
|
|
158
159
|
// runtime by probing the candidate list, so static analysis is
|
|
159
160
|
// impossible.
|
|
160
|
-
return
|
|
161
|
+
return importFile(candidate);
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
console.warn(chalk.yellow('[linked.backend.storage] no linked.backend.storage.{ts,js} found at app root.'));
|
|
@@ -165,13 +166,12 @@ export function loadBackendStorageConfig() {
|
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
168
|
/**
|
|
168
|
-
* Directory holding localized checkouts (`linked localize`).
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* and has to be told about it separately.
|
|
169
|
+
* Directory holding localized checkouts (`linked localize`). An app set up by
|
|
170
|
+
* `linked localize` lists `packages-local/*` in its `workspaces`, so a walk of
|
|
171
|
+
* the globs finds them as workspace members; it is still walked on its own for
|
|
172
|
+
* an app that has not been set up yet (no glob, or no `workspaces` at all).
|
|
173
173
|
*/
|
|
174
|
-
export const LOCAL_PACKAGES_DIR =
|
|
174
|
+
export const LOCAL_PACKAGES_DIR = LOCAL_DIR;
|
|
175
175
|
/**
|
|
176
176
|
* Walk the app's `package.json` `workspaces` field and return every
|
|
177
177
|
* workspace package that declares `"linkedPackage": true`.
|
|
@@ -196,8 +196,10 @@ export function getLincdPackages(rootPath = process.cwd()) {
|
|
|
196
196
|
*
|
|
197
197
|
* Two sources, because the workspace globs are not the whole picture any more:
|
|
198
198
|
*
|
|
199
|
-
* 1. the `workspaces` field (negations honoured — see ./workspace-globs.js)
|
|
200
|
-
*
|
|
199
|
+
* 1. the `workspaces` field (negations honoured — see ./workspace-globs.js),
|
|
200
|
+
* which includes `packages-local/*` in an app set up for localizing;
|
|
201
|
+
* 2. `packages-local/`, the localized checkouts, for an app whose globs do
|
|
202
|
+
* not reach it. A checkout a glob already found is not added twice.
|
|
201
203
|
*
|
|
202
204
|
* Nothing is filtered out here. Callers decide what they can act on and are
|
|
203
205
|
* expected to SAY what they skipped and why.
|
|
@@ -246,8 +248,8 @@ function checkLocalPackagesDir(rootPath, localPackagesDir, res) {
|
|
|
246
248
|
const packagePath = path.join(dir, entry);
|
|
247
249
|
if (!fs.statSync(packagePath).isDirectory())
|
|
248
250
|
continue;
|
|
249
|
-
// A checkout
|
|
250
|
-
// duplicates would be built twice and counted twice.
|
|
251
|
+
// A checkout a glob already picked up (`packages-local/*`) must not
|
|
252
|
+
// appear twice — duplicates would be built twice and counted twice.
|
|
251
253
|
if (already.has(path.resolve(packagePath)))
|
|
252
254
|
continue;
|
|
253
255
|
addPackage(packagePath, 'local-packages-dir', res);
|
|
@@ -356,47 +358,71 @@ function filterPackagesByDependencyTree(allPackages, appRootPath) {
|
|
|
356
358
|
return relevantPackages;
|
|
357
359
|
}
|
|
358
360
|
/**
|
|
359
|
-
* The
|
|
360
|
-
* `
|
|
361
|
-
*
|
|
362
|
-
* malformed entry) loudly, so here a missing or unusable file is simply
|
|
363
|
-
* "nothing localized", and a malformed entry is skipped without a word.
|
|
361
|
+
* The names of the app's localized checkouts — every directory in
|
|
362
|
+
* `packages-local/` with a named `package.json` (localize/members.ts). Nothing
|
|
363
|
+
* there is simply "nothing localized".
|
|
364
364
|
*/
|
|
365
365
|
export function localizedPackageNames(appRootPath) {
|
|
366
|
-
|
|
367
|
-
return Object.keys(readManifest(appRootPath, { warn: () => { } }).entries);
|
|
368
|
-
}
|
|
369
|
-
catch (_a) {
|
|
370
|
-
return [];
|
|
371
|
-
}
|
|
366
|
+
return localMembers(appRootPath).map((member) => member.name);
|
|
372
367
|
}
|
|
373
368
|
/** The package whose `linked` bin the other packages' build scripts run. */
|
|
374
369
|
export const BUILD_TOOL_PACKAGE = '@_linked/cli';
|
|
370
|
+
/** The package names a package's `dependencies` field lists. */
|
|
371
|
+
function declaredDependencies(pkg) {
|
|
372
|
+
var _a;
|
|
373
|
+
return Object.keys(((_a = getPackageJSON(pkg.path, false)) === null || _a === void 0 ? void 0 : _a.dependencies) || {});
|
|
374
|
+
}
|
|
375
375
|
/**
|
|
376
|
-
*
|
|
376
|
+
* Split the build around the build tool (`@_linked/cli`).
|
|
377
377
|
*
|
|
378
378
|
* Every other package's `build` script runs `linked build`, which is THIS
|
|
379
379
|
* package's `lib/`. Built in parallel with them, its `rimraf ./lib` pulled that
|
|
380
380
|
* `lib/` out from under their builds (`ENOENT …/lib/esm/installed-packages.js`),
|
|
381
381
|
* and whatever was built before it ran a stale cli. So when it is in the set it
|
|
382
|
-
* is built
|
|
382
|
+
* is built alone, and the rest only once it has succeeded.
|
|
383
383
|
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
384
|
+
* It cannot be built FIRST, though: a localized `@_linked/core` it depends on
|
|
385
|
+
* must have its `lib/` before the tool's `tsc` runs. So the tool's own
|
|
386
|
+
* dependencies among the packages to build (`pre`, the transitive closure of
|
|
387
|
+
* `dependencies`) go before it, in dependency order. They build with the tool
|
|
388
|
+
* as it was before this run, which is what a fresh checkout's `npm run build`
|
|
389
|
+
* does too.
|
|
390
|
+
*
|
|
391
|
+
* `--from` reads the order as `pre`, then the tool, then `rest`: it resumes
|
|
392
|
+
* inside whichever group holds the package and passes over the groups before
|
|
393
|
+
* it. A name in none of them goes to `rest`, which reports it.
|
|
387
394
|
*/
|
|
388
|
-
export function orderBuildToolFirst(packages, from) {
|
|
395
|
+
export function orderBuildToolFirst(packages, from, dependenciesOf = declaredDependencies) {
|
|
389
396
|
const tool = packages.get(BUILD_TOOL_PACKAGE);
|
|
390
|
-
if (!tool)
|
|
391
|
-
return {
|
|
397
|
+
if (!tool) {
|
|
398
|
+
return { pre: new Map(), rest: packages, start: from ? 'rest' : 'pre', from };
|
|
399
|
+
}
|
|
400
|
+
// Depth-first, dependencies before dependents, so `pre` is in build order.
|
|
401
|
+
// A cycle back to the tool (or within `pre`) is cut where it closes.
|
|
402
|
+
const pre = new Map();
|
|
403
|
+
const visiting = new Set([BUILD_TOOL_PACKAGE]);
|
|
404
|
+
const visit = (pkg) => {
|
|
405
|
+
for (const dep of dependenciesOf(pkg)) {
|
|
406
|
+
const depPkg = packages.get(dep);
|
|
407
|
+
if (!depPkg || visiting.has(dep) || pre.has(dep))
|
|
408
|
+
continue;
|
|
409
|
+
visiting.add(dep);
|
|
410
|
+
visit(depPkg);
|
|
411
|
+
pre.set(dep, depPkg);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
visit(tool);
|
|
392
415
|
const rest = new Map(packages);
|
|
393
416
|
rest.delete(BUILD_TOOL_PACKAGE);
|
|
417
|
+
for (const name of pre.keys())
|
|
418
|
+
rest.delete(name);
|
|
394
419
|
if (!from)
|
|
395
|
-
return { tool,
|
|
396
|
-
if (from
|
|
397
|
-
return {
|
|
398
|
-
|
|
399
|
-
|
|
420
|
+
return { pre, tool, rest, start: 'pre' };
|
|
421
|
+
if (pre.has(from))
|
|
422
|
+
return { pre, tool, rest, start: 'pre', from };
|
|
423
|
+
if (from === BUILD_TOOL_PACKAGE)
|
|
424
|
+
return { pre, tool, rest, start: 'tool' };
|
|
425
|
+
return { pre, tool, rest, start: 'rest', from };
|
|
400
426
|
}
|
|
401
427
|
/**
|
|
402
428
|
* Decide what `build-all` builds.
|
package/lib/esm/lifecycle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/lifecycle.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,sEAAsE;AACtE,uEAAuE;AACvE,2DAA2D;AAC3D,qEAAqE;AACrE,oEAAoE;;;;;;;;;;AAEpE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,sBAAsB,EAAE,sBAAsB,EAAC,MAAM,sBAAsB,CAAC;AACpF,mFAAmF;AACnF,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,gBAA2B,EACZ,EAAE;IACjB,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe;QAAE,OAAO;IACxC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IACvD,MA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I,CAAC,GAAG,CAAC,CAAC;YACpB,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,mBAAmB,GACvB,cAAc;YACd,CAAC,mBAAmB,CAAC,cAAc,CAAC;YACpC;gBACE,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,IAAI,EAAE,CAAC;gBACjD,GAAG,qBAAqB,CAAC,OAAO,CAAC;aAClC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAElC,IAAI,mBAAmB,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,8BAA8B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9D,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;gBAC5B,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;oBAAE,SAAS;gBAC1C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;gBAC9B,OAAO,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,WAAW,EAAE,GAAG,CAAC,WAAW;oBAC5B,MAAM,EAAE,UAAU,cAAc,CAAC,IAAI,IAAI,UAAU,oBAAoB;iBACxE,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,CAAC;AAC1B,CAAC","sourcesContent":["// Lifecycle helpers shared by the Vite-based dev orchestrator.\n//\n// Extracted from cli-methods.ts so the SSR module graph (started from\n// `commands/start.ts`) doesn't have to walk the rest of that file. The\n// the older helpers in cli-methods.ts contain many dynamic\n// `import(<variable>)` calls Vite can't analyze statically and would\n// emit warnings about — even though startWithVite never calls them.\n\nimport fs from 'fs-extra';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {getPackageJSON} from './utils.js';\nimport {isLinkedPackageJson} from './installed-packages.js';\nimport {readManifest} from './localize/manifest.js';\nimport {parseWorkspacePatterns, isWorkspacePathNegated} from './workspace-globs.js';\n// Shared with the CSS loader's mode resolution, which must pick the same profiles.\nimport {readEnvNamesFromArgv} from './loader-mode.js';\nimport type {PackageDetails} from './interfaces.js';\n\n/**\n * Load the app's environment into `process.env`, then re-apply the original\n * shell env so it always wins on conflict. Idempotent — runs at most once.\n *\n * Two sources, tried in this order:\n * 1. `.env` (Node-native `process.loadEnvFile`, no dependency) — a flat file.\n * This is what the app template ships and the only form that will survive.\n * `--env` is not consulted here: a flat `.env` has no profiles, so\n * NODE_ENV comes from the file or the shell.\n * 2. `.env-cmdrc.json` (DEPRECATED, via `env-cmd`) — profile-based; honours\n * `--env a,b` and merges `_main` + the named profiles. Still read when it\n * is the only file present, so no existing app breaks, but it warns.\n *\n * `.env` going first is what makes migrating a one-step job: add the flat file\n * and it takes over. The profile file can then be deleted whenever convenient.\n *\n * If neither file exists we skip silently — CN-hosted apps have their env\n * injected into the child process at spawn time, so there's nothing to read\n * from disk.\n */\nexport const ensureEnvironmentLoaded = async (\n environmentNames?: string[],\n): Promise<void> => {\n if (process.env.ENV_VARS_LOADED) return;\n const cwd = process.cwd();\n const envCmdrcPath = path.join(cwd, '.env-cmdrc.json');\n const dotEnvPath = path.join(cwd, '.env');\n\n // Snapshot the original shell env — it should always take priority over\n // whatever a file sets (so injected/production env wins over dev defaults).\n const shellEnv = {...process.env};\n\n const hasDotEnv = fs.existsSync(dotEnvPath);\n const hasEnvCmdrc = fs.existsSync(envCmdrcPath);\n\n for (const notice of envDeprecationNotices({hasEnvCmdrc, hasDotEnv})) {\n console.warn(chalk.yellow(notice));\n }\n\n if (hasDotEnv) {\n // Native flat-file loader (Node 20.12+). Populates process.env from `.env`.\n process.loadEnvFile(dotEnvPath);\n } else if (hasEnvCmdrc) {\n await loadEnvCmdrc(envCmdrcPath, environmentNames);\n } else {\n console.warn(\n 'No .env or .env-cmdrc.json found in this folder — relying on the ambient environment.',\n );\n }\n\n // Re-apply shell env so it always wins over file values.\n process.env = {...process.env, ...shellEnv};\n process.env.ENV_VARS_LOADED = 'true';\n};\n\n/**\n * What to tell an app about where its environment came from.\n *\n * `.env-cmdrc.json` is still read when it is the only file present, so no app\n * breaks today. But it is the only reason `--env` exists, and both are going\n * away.\n *\n * The case worth shouting about is an app holding both files: `.env` wins, so\n * the profile file and every `--env` name passed with it do nothing. That is\n * the intended migration path, but it is invisible from the outside — values\n * an app still believes it is getting from a profile are simply absent.\n *\n * Pure and exported so the messages can be asserted without a chdir.\n */\nexport const envDeprecationNotices = (sources: {\n hasEnvCmdrc: boolean;\n hasDotEnv: boolean;\n}): string[] => {\n if (!sources.hasEnvCmdrc) return [];\n const notices = [\n '.env-cmdrc.json is deprecated and will be removed in a future major release.',\n ' Move its values into a flat `.env`, and supply anything that differs per ' +\n 'deployment from the environment itself. `--env` goes away with it.',\n ];\n if (sources.hasDotEnv) {\n notices.push(\n ' This app has BOTH files. `.env` wins, so `.env-cmdrc.json` — and any ' +\n '`--env` profile named with it — is being ignored entirely. Delete it once ' +\n 'the flat file is complete.',\n );\n }\n return notices;\n};\n\n/**\n * Legacy loader: reads `.env-cmdrc.json`, merges `_main` plus the profile(s)\n * named by `--env a,b` (default `development`). Kept for CN and existing apps\n * until they migrate to a flat `.env`.\n */\nconst loadEnvCmdrc = async (\n envCmdrcPath: string,\n environmentNames?: string[],\n): Promise<void> => {\n // env-cmd ships ESM; literal specifier is fine for Vite's analyzer.\n const {GetEnvVars} = await import('env-cmd');\n const vars = await GetEnvVars({envFile: {filePath: envCmdrcPath}});\n const environments = Object.keys(vars);\n\n if (environments.includes('_main')) {\n process.env = {...process.env, ...vars._main};\n }\n // Callers that parsed `--env` themselves pass the names in. Commands that\n // have not been converted yet still have their names scraped off argv.\n const requested = environmentNames?.length\n ? environmentNames\n : readEnvNamesFromArgv();\n if (requested.length) {\n requested.forEach((name) => {\n if (environments.includes(name)) {\n console.log('Environment: ' + name);\n process.env = {...process.env, ...vars[name]};\n } else {\n console.warn(\n `Environment ${name} not found in .env-cmdrc.json. Available: ${environments.join(', ')}`,\n );\n }\n });\n } else {\n process.env = {...process.env, ...vars.development};\n console.log('No environment specified, using development');\n }\n};\n\n/**\n * Discover and load the app's storage-config bootstrap file. Tries the\n * canonical `linked.backend.storage.{ts,js}` first, then legacy paths.\n * Returns whatever the file's default export evaluates to, or undefined\n * if no candidate exists.\n */\nexport async function loadBackendStorageConfig(): Promise<any> {\n const cwd = process.cwd();\n const candidates = [\n path.join(cwd, 'linked.backend.storage.ts'),\n path.join(cwd, 'linked.backend.storage.js'),\n path.join(cwd, 'backend-storage-config.ts'),\n path.join(cwd, 'backend-storage-config.js'),\n path.join(cwd, 'scripts', 'backend-storage-config.js'),\n path.join(cwd, 'scripts', 'backend-storage-config.ts'),\n path.join(cwd, 'scripts', 'storage-config.js'),\n ];\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n // Variable specifier is intentional — we discover the path at\n // runtime by probing the candidate list, so static analysis is\n // impossible.\n return import(/* @vite-ignore */ candidate);\n }\n }\n console.warn(\n chalk.yellow(\n '[linked.backend.storage] no linked.backend.storage.{ts,js} found at app root.',\n ),\n );\n return undefined;\n}\n\n/**\n * A local package directory found by {@link discoverLocalPackages}, together\n * with the facts that decide what can be done with it.\n *\n * The facts are recorded rather than filtered on, because the bug this type\n * exists to fix was a SILENT filter: `build-all` discovered only packages\n * carrying `linkedPackage: true` and printed nothing about the rest, so\n * `@_linked/maps` — a shipped dependency that simply never got the flag — was\n * dropped from a green build for as long as nobody counted the names.\n */\nexport interface LocalPackage extends PackageDetails {\n /** Where the walk found it. */\n source: 'workspace' | 'local-packages-dir';\n /** `linkedPackage: true` — see `isLinkedPackageJson`. */\n isLinkedPackage: boolean;\n /** `linkedApp: true` — built by `linked build-app`, not `linked build`. */\n isApp: boolean;\n /** Has a `build` script of its own, which is what `build-all` invokes. */\n hasBuildScript: boolean;\n}\n\n/**\n * Directory holding localized checkouts (`linked localize`). It is\n * deliberately in NO workspace glob — that is the whole point of the design,\n * since npm learning about these checkouts is what made their predecessor\n * under `packages/` a trap — so any walk of `workspaces` alone cannot see it\n * and has to be told about it separately.\n */\nexport const LOCAL_PACKAGES_DIR = 'packages-local';\n\n/**\n * Walk the app's `package.json` `workspaces` field and return every\n * workspace package that declares `\"linkedPackage\": true`.\n *\n * Lives here (not in cli-methods.ts) so consumers like LinkedServer can\n * import it without dragging the rest of the legacy cli-methods flow into\n * Vite's SSR module graph.\n *\n * Kept deliberately narrow: this is the set the dev resolver and the runtime\n * treat as linked packages. Commands that want every *buildable* local\n * package — flag or no flag, workspace or localized checkout — want\n * {@link discoverLocalPackages} instead.\n */\nexport function getLincdPackages(\n rootPath = process.cwd(),\n): PackageDetails[] {\n return discoverLocalPackages(rootPath, {includeLocalPackagesDir: false})\n .filter((pkg) => pkg.isLinkedPackage)\n .map(({path: packagePath, packageName}) => ({path: packagePath, packageName}));\n}\n\n/**\n * Every local package directory this app can see, whether or not it declares\n * `linkedPackage: true`.\n *\n * Two sources, because the workspace globs are not the whole picture any more:\n *\n * 1. the `workspaces` field (negations honoured — see ./workspace-globs.js);\n * 2. `packages-local/`, the localized checkouts, which is in no glob.\n *\n * Nothing is filtered out here. Callers decide what they can act on and are\n * expected to SAY what they skipped and why.\n */\nexport function discoverLocalPackages(\n rootPath = process.cwd(),\n options: {includeLocalPackagesDir?: boolean; localPackagesDir?: string} = {},\n): LocalPackage[] {\n const {includeLocalPackagesDir = true, localPackagesDir = LOCAL_PACKAGES_DIR} =\n options;\n\n let pack = getPackageJSON(rootPath);\n if (!pack || !pack.workspaces) {\n const originalRoot = rootPath;\n for (let i = 0; i <= 3; i++) {\n rootPath = path.join(originalRoot, ...Array(i).fill('..'));\n pack = getPackageJSON(rootPath);\n if (pack && pack.workspaces) break;\n }\n if (!pack || !pack.workspaces) {\n // Standalone apps (scaffolded with `linked create-app`) don't have\n // workspaces — expected. Fall back to the original root so a\n // `packages-local/` beside it is still found.\n rootPath = originalRoot;\n }\n }\n\n const res: LocalPackage[] = [];\n if (pack && pack.workspaces) {\n checkWorkspaces(rootPath, pack.workspaces, res);\n }\n if (includeLocalPackagesDir) {\n checkLocalPackagesDir(rootPath, localPackagesDir, res);\n }\n return res;\n}\n\n/**\n * Add every immediate subdirectory of `packages-local/` that holds a\n * `package.json`. No glob, no negations: the directory has no `workspaces`\n * entry to interpret, its contents are there because a developer localized\n * them on purpose, and each one is a plain checkout.\n */\nfunction checkLocalPackagesDir(\n rootPath: string,\n localPackagesDir: string,\n res: LocalPackage[],\n) {\n const dir = path.join(rootPath, localPackagesDir);\n if (!fs.existsSync(dir)) return;\n const already = new Set(res.map((pkg) => path.resolve(pkg.path)));\n for (const entry of fs.readdirSync(dir)) {\n if (entry.startsWith('.')) continue;\n const packagePath = path.join(dir, entry);\n if (!fs.statSync(packagePath).isDirectory()) continue;\n // A checkout that some glob already picked up must not appear twice —\n // duplicates would be built twice and counted twice.\n if (already.has(path.resolve(packagePath))) continue;\n addPackage(packagePath, 'local-packages-dir', res);\n }\n}\n\nfunction checkWorkspaces(rootPath: string, workspaces: any, res: LocalPackage[]) {\n // Negated entries (\"!packages/core\") are excluded the way npm excludes them\n // — including from the exact-path branch below, which npm also subjects to\n // them. See ./workspace-globs.js.\n const {patterns, negatedPatterns} = parseWorkspacePatterns(workspaces);\n const checkUnlessNegated = (packagePath: string) => {\n const rel = path.relative(rootPath, packagePath).split(path.sep).join('/');\n if (isWorkspacePathNegated(rel, negatedPatterns)) return;\n checkPackagePath(rootPath, packagePath, res);\n };\n patterns.forEach((workspace: string) => {\n const workspacePath = path.join(rootPath, workspace.replace('/*', ''));\n if (workspace.indexOf('/*') !== -1) {\n if (fs.existsSync(workspacePath)) {\n const folders = fs.readdirSync(workspacePath);\n folders.forEach((folder: string) => {\n if (folder !== './' && folder !== '../') {\n checkUnlessNegated(path.join(workspacePath, folder));\n }\n });\n }\n } else {\n checkUnlessNegated(workspacePath);\n }\n });\n}\n\nfunction checkPackagePath(rootPath: string, packagePath: string, res: LocalPackage[]) {\n const packageJsonPath = path.join(packagePath, 'package.json');\n if (!fs.existsSync(packageJsonPath)) return;\n const pack = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n if (pack && pack.workspaces) {\n checkWorkspaces(packagePath, pack.workspaces, res);\n } else if (pack) {\n addPackage(packagePath, 'workspace', res, pack);\n }\n}\n\nfunction addPackage(\n packagePath: string,\n source: LocalPackage['source'],\n res: LocalPackage[],\n packageJson?: any,\n) {\n const pack = packageJson ?? getPackageJSON(packagePath);\n if (!pack || !pack.name) return;\n res.push({\n path: packagePath,\n packageName: pack.name,\n source,\n // The one definition, shared with `linked build-package`.\n isLinkedPackage: isLinkedPackageJson(pack),\n isApp: pack.linkedApp === true,\n hasBuildScript: !!pack.scripts?.build,\n });\n}\n\n/**\n * Filters packages to only include those in the dependency tree of the app root\n */\nfunction filterPackagesByDependencyTree(\n allPackages: Map<string, PackageDetails>,\n appRootPath: string,\n): Map<string, PackageDetails> {\n const appPackageJson = getPackageJSON(appRootPath);\n if (!appPackageJson) {\n return allPackages;\n }\n\n const relevantPackages = new Map<string, PackageDetails>();\n const packagesToCheck = new Set<string>();\n\n // Start with direct dependencies from app root, plus everything localized:\n // a package created locally is linked but cannot be declared until it is\n // published (an unpublished range fails `npm install`), and being localized\n // already says this app is developed against it.\n [\n ...Object.keys(appPackageJson.dependencies || {}),\n ...localizedPackageNames(appRootPath),\n ].forEach((dep) => {\n if (allPackages.has(dep)) {\n packagesToCheck.add(dep);\n }\n });\n\n // Recursively add dependencies\n const processedPackages = new Set<string>();\n\n while (packagesToCheck.size > 0) {\n const packageName = Array.from(packagesToCheck)[0];\n packagesToCheck.delete(packageName);\n\n if (processedPackages.has(packageName)) {\n continue;\n }\n\n processedPackages.add(packageName);\n const packageDetails = allPackages.get(packageName);\n\n if (packageDetails) {\n relevantPackages.set(packageName, packageDetails);\n\n // Get this package's dependencies\n const packageJson = getPackageJSON(packageDetails.path);\n if (packageJson && packageJson.dependencies) {\n Object.keys(packageJson.dependencies).forEach((dep) => {\n if (allPackages.has(dep) && !processedPackages.has(dep)) {\n packagesToCheck.add(dep);\n }\n });\n }\n }\n }\n\n return relevantPackages;\n}\n\n/**\n * The package names recorded in the app's `local-packages.json` — what\n * `linked localize` has linked — read with localize's own reader. Read\n * tolerantly: `linked localize` refuses a malformed file (and warns about a\n * malformed entry) loudly, so here a missing or unusable file is simply\n * \"nothing localized\", and a malformed entry is skipped without a word.\n */\nexport function localizedPackageNames(appRootPath: string): string[] {\n try {\n return Object.keys(readManifest(appRootPath, {warn: () => {}}).entries);\n } catch {\n return [];\n }\n}\n\n/** A package `build-all` found but will not build, and why not. */\nexport interface SkippedPackage {\n packageName: string;\n path: string;\n reason: string;\n}\n\n/** What `build-all` found, and what it decided to do with each package. */\nexport interface BuildAllPlan {\n build: Map<string, PackageDetails>;\n skipped: SkippedPackage[];\n}\n\n/** The package whose `linked` bin the other packages' build scripts run. */\nexport const BUILD_TOOL_PACKAGE = '@_linked/cli';\n\n/** How `build-all` orders the build tool against everything else. */\nexport interface BuildToolOrder {\n /** The build tool, when it is among the packages to build. */\n tool?: PackageDetails;\n /** Whether to build `tool` now, alone, before anything else starts. */\n buildToolFirst: boolean;\n /** Everything else, built afterwards in dependency order. */\n rest: Map<string, PackageDetails>;\n /** The `--from` to apply to `rest`: cleared once it has been reached at the tool. */\n from?: string;\n}\n\n/**\n * Take the build tool (`@_linked/cli`) out of the dependency-ordered build.\n *\n * Every other package's `build` script runs `linked build`, which is THIS\n * package's `lib/`. Built in parallel with them, its `rimraf ./lib` pulled that\n * `lib/` out from under their builds (`ENOENT …/lib/esm/installed-packages.js`),\n * and whatever was built before it ran a stale cli. So when it is in the set it\n * is built first and alone, and the rest only once it has succeeded.\n *\n * `--from` reads the tool as the first package in the order: `--from` the tool\n * builds it and then everything; `--from` anything else resumes past it, so it\n * is not rebuilt.\n */\nexport function orderBuildToolFirst(\n packages: Map<string, PackageDetails>,\n from?: string,\n): BuildToolOrder {\n const tool = packages.get(BUILD_TOOL_PACKAGE);\n if (!tool) return {buildToolFirst: false, rest: packages, from};\n const rest = new Map(packages);\n rest.delete(BUILD_TOOL_PACKAGE);\n if (!from) return {tool, buildToolFirst: true, rest};\n if (from === BUILD_TOOL_PACKAGE) {\n return {tool, buildToolFirst: true, rest, from: undefined};\n }\n return {tool, buildToolFirst: false, rest, from};\n}\n\n/**\n * Decide what `build-all` builds.\n *\n * Every discovered package lands in exactly one of `build` or `skipped`, and\n * `skipped` carries a reason — because the failure mode this replaces was not\n * a narrow scan, it was a SILENT one. `@_linked/maps` is a shipped Create Now\n * dependency that never got `linkedPackage: true`; `build-all` dropped it and\n * printed nothing, so a build covering half the workspace exited 0 and people\n * acted on it. A skip nobody can see is worse than a failure.\n *\n * What counts as buildable is a CAPABILITY, not a declaration: `build-all`\n * invokes each package's own `build` script, so anything with one can be\n * built whether or not it carries the flag. The flag is still reported when\n * it is missing, since the dev resolver and `linked build` do require it.\n */\nexport function planBuildAll(rootPath = './', appRoot?: string): BuildAllPlan {\n const build = new Map<string, PackageDetails>();\n const skipped: SkippedPackage[] = [];\n const buildable: LocalPackage[] = [];\n\n for (const pkg of discoverLocalPackages(rootPath)) {\n const detail = {path: pkg.path, packageName: pkg.packageName};\n // Packages reached through a `../` workspace glob live outside this\n // repository; building them was never in scope for `build-all`.\n if (pkg.path.indexOf('../') !== -1 || pkg.path.indexOf('..\\\\') !== -1) {\n skipped.push({...detail, reason: 'outside this repository'});\n } else if (pkg.isApp) {\n skipped.push({\n ...detail,\n reason: 'is a linked app — build it with `linked build-app`',\n });\n } else if (!pkg.hasBuildScript) {\n skipped.push({...detail, reason: 'has no `build` script'});\n } else {\n buildable.push(pkg);\n build.set(pkg.packageName, detail);\n }\n }\n\n // Narrow to what this app actually depends on, if we are inside one.\n if (appRoot) {\n const appPackageJson = getPackageJSON(appRoot);\n const isAppWithLinkedDeps =\n appPackageJson &&\n !isLinkedPackageJson(appPackageJson) &&\n [\n ...Object.keys(appPackageJson.dependencies || {}),\n ...localizedPackageNames(appRoot),\n ].some((dep) => build.has(dep));\n\n if (isAppWithLinkedDeps) {\n const inTree = filterPackagesByDependencyTree(build, appRoot);\n for (const pkg of buildable) {\n if (inTree.has(pkg.packageName)) continue;\n build.delete(pkg.packageName);\n skipped.push({\n path: pkg.path,\n packageName: pkg.packageName,\n reason: `not in ${appPackageJson.name || 'this app'}'s dependency tree`,\n });\n }\n }\n }\n\n return {build, skipped};\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/lifecycle.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,sEAAsE;AACtE,uEAAuE;AACvE,2DAA2D;AAC3D,qEAAqE;AACrE,oEAAoE;;;;;;;;;;AAEpE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAC,SAAS,EAAE,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAC,sBAAsB,EAAE,sBAAsB,EAAC,MAAM,sBAAsB,CAAC;AACpF,mFAAmF;AACnF,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,gBAA2B,EACZ,EAAE;IACjB,IAAI,OAAO,CAAC,G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uB,IAAE,CAAC;QAC7D,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACpB,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,qEAAqE;IACrE,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,mBAAmB,GACvB,cAAc;YACd,CAAC,mBAAmB,CAAC,cAAc,CAAC;YACpC;gBACE,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,IAAI,EAAE,CAAC;gBACjD,GAAG,qBAAqB,CAAC,OAAO,CAAC;aAClC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAElC,IAAI,mBAAmB,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,8BAA8B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9D,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;gBAC5B,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;oBAAE,SAAS;gBAC1C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;gBAC9B,OAAO,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,WAAW,EAAE,GAAG,CAAC,WAAW;oBAC5B,MAAM,EAAE,UAAU,cAAc,CAAC,IAAI,IAAI,UAAU,oBAAoB;iBACxE,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,CAAC;AAC1B,CAAC","sourcesContent":["// Lifecycle helpers shared by the Vite-based dev orchestrator.\n//\n// Extracted from cli-methods.ts so the SSR module graph (started from\n// `commands/start.ts`) doesn't have to walk the rest of that file. The\n// the older helpers in cli-methods.ts contain many dynamic\n// `import(<variable>)` calls Vite can't analyze statically and would\n// emit warnings about — even though startWithVite never calls them.\n\nimport fs from 'fs-extra';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {getPackageJSON} from './utils.js';\nimport {isLinkedPackageJson} from './installed-packages.js';\nimport {LOCAL_DIR, localMembers} from './localize/members.js';\nimport {parseWorkspacePatterns, isWorkspacePathNegated} from './workspace-globs.js';\n// Shared with the CSS loader's mode resolution, which must pick the same profiles.\nimport {readEnvNamesFromArgv} from './loader-mode.js';\nimport type {PackageDetails} from './interfaces.js';\nimport {importFile} from './utils/platform.js';\n\n/**\n * Load the app's environment into `process.env`, then re-apply the original\n * shell env so it always wins on conflict. Idempotent — runs at most once.\n *\n * Two sources, tried in this order:\n * 1. `.env` (Node-native `process.loadEnvFile`, no dependency) — a flat file.\n * This is what the app template ships and the only form that will survive.\n * `--env` is not consulted here: a flat `.env` has no profiles, so\n * NODE_ENV comes from the file or the shell.\n * 2. `.env-cmdrc.json` (DEPRECATED, via `env-cmd`) — profile-based; honours\n * `--env a,b` and merges `_main` + the named profiles. Still read when it\n * is the only file present, so no existing app breaks, but it warns.\n *\n * `.env` going first is what makes migrating a one-step job: add the flat file\n * and it takes over. The profile file can then be deleted whenever convenient.\n *\n * If neither file exists we skip silently — CN-hosted apps have their env\n * injected into the child process at spawn time, so there's nothing to read\n * from disk.\n */\nexport const ensureEnvironmentLoaded = async (\n environmentNames?: string[],\n): Promise<void> => {\n if (process.env.ENV_VARS_LOADED) return;\n const cwd = process.cwd();\n const envCmdrcPath = path.join(cwd, '.env-cmdrc.json');\n const dotEnvPath = path.join(cwd, '.env');\n\n // Snapshot the original shell env — it should always take priority over\n // whatever a file sets (so injected/production env wins over dev defaults).\n const shellEnv = {...process.env};\n\n const hasDotEnv = fs.existsSync(dotEnvPath);\n const hasEnvCmdrc = fs.existsSync(envCmdrcPath);\n\n for (const notice of envDeprecationNotices({hasEnvCmdrc, hasDotEnv})) {\n console.warn(chalk.yellow(notice));\n }\n\n if (hasDotEnv) {\n // Native flat-file loader (Node 20.12+). Populates process.env from `.env`.\n process.loadEnvFile(dotEnvPath);\n } else if (hasEnvCmdrc) {\n await loadEnvCmdrc(envCmdrcPath, environmentNames);\n } else {\n console.warn(\n 'No .env or .env-cmdrc.json found in this folder — relying on the ambient environment.',\n );\n }\n\n // Re-apply shell env so it always wins over file values.\n process.env = {...process.env, ...shellEnv};\n process.env.ENV_VARS_LOADED = 'true';\n};\n\n/**\n * What to tell an app about where its environment came from.\n *\n * `.env-cmdrc.json` is still read when it is the only file present, so no app\n * breaks today. But it is the only reason `--env` exists, and both are going\n * away.\n *\n * The case worth shouting about is an app holding both files: `.env` wins, so\n * the profile file and every `--env` name passed with it do nothing. That is\n * the intended migration path, but it is invisible from the outside — values\n * an app still believes it is getting from a profile are simply absent.\n *\n * Pure and exported so the messages can be asserted without a chdir.\n */\nexport const envDeprecationNotices = (sources: {\n hasEnvCmdrc: boolean;\n hasDotEnv: boolean;\n}): string[] => {\n if (!sources.hasEnvCmdrc) return [];\n const notices = [\n '.env-cmdrc.json is deprecated and will be removed in a future major release.',\n ' Move its values into a flat `.env`, and supply anything that differs per ' +\n 'deployment from the environment itself. `--env` goes away with it.',\n ];\n if (sources.hasDotEnv) {\n notices.push(\n ' This app has BOTH files. `.env` wins, so `.env-cmdrc.json` — and any ' +\n '`--env` profile named with it — is being ignored entirely. Delete it once ' +\n 'the flat file is complete.',\n );\n }\n return notices;\n};\n\n/**\n * Legacy loader: reads `.env-cmdrc.json`, merges `_main` plus the profile(s)\n * named by `--env a,b` (default `development`). Kept for CN and existing apps\n * until they migrate to a flat `.env`.\n */\nconst loadEnvCmdrc = async (\n envCmdrcPath: string,\n environmentNames?: string[],\n): Promise<void> => {\n // env-cmd ships ESM; literal specifier is fine for Vite's analyzer.\n const {GetEnvVars} = await import('env-cmd');\n const vars = await GetEnvVars({envFile: {filePath: envCmdrcPath}});\n const environments = Object.keys(vars);\n\n if (environments.includes('_main')) {\n process.env = {...process.env, ...vars._main};\n }\n // Callers that parsed `--env` themselves pass the names in. Commands that\n // have not been converted yet still have their names scraped off argv.\n const requested = environmentNames?.length\n ? environmentNames\n : readEnvNamesFromArgv();\n if (requested.length) {\n requested.forEach((name) => {\n if (environments.includes(name)) {\n console.log('Environment: ' + name);\n process.env = {...process.env, ...vars[name]};\n } else {\n console.warn(\n `Environment ${name} not found in .env-cmdrc.json. Available: ${environments.join(', ')}`,\n );\n }\n });\n } else {\n process.env = {...process.env, ...vars.development};\n console.log('No environment specified, using development');\n }\n};\n\n/**\n * Discover and load the app's storage-config bootstrap file. Tries the\n * canonical `linked.backend.storage.{ts,js}` first, then legacy paths.\n * Returns whatever the file's default export evaluates to, or undefined\n * if no candidate exists.\n */\nexport async function loadBackendStorageConfig(): Promise<any> {\n const cwd = process.cwd();\n const candidates = [\n path.join(cwd, 'linked.backend.storage.ts'),\n path.join(cwd, 'linked.backend.storage.js'),\n path.join(cwd, 'backend-storage-config.ts'),\n path.join(cwd, 'backend-storage-config.js'),\n path.join(cwd, 'scripts', 'backend-storage-config.js'),\n path.join(cwd, 'scripts', 'backend-storage-config.ts'),\n path.join(cwd, 'scripts', 'storage-config.js'),\n ];\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n // Variable specifier is intentional — we discover the path at\n // runtime by probing the candidate list, so static analysis is\n // impossible.\n return importFile(candidate);\n }\n }\n console.warn(\n chalk.yellow(\n '[linked.backend.storage] no linked.backend.storage.{ts,js} found at app root.',\n ),\n );\n return undefined;\n}\n\n/**\n * A local package directory found by {@link discoverLocalPackages}, together\n * with the facts that decide what can be done with it.\n *\n * The facts are recorded rather than filtered on, because the bug this type\n * exists to fix was a SILENT filter: `build-all` discovered only packages\n * carrying `linkedPackage: true` and printed nothing about the rest, so\n * `@_linked/maps` — a shipped dependency that simply never got the flag — was\n * dropped from a green build for as long as nobody counted the names.\n */\nexport interface LocalPackage extends PackageDetails {\n /** Where the walk found it. */\n source: 'workspace' | 'local-packages-dir';\n /** `linkedPackage: true` — see `isLinkedPackageJson`. */\n isLinkedPackage: boolean;\n /** `linkedApp: true` — built by `linked build-app`, not `linked build`. */\n isApp: boolean;\n /** Has a `build` script of its own, which is what `build-all` invokes. */\n hasBuildScript: boolean;\n}\n\n/**\n * Directory holding localized checkouts (`linked localize`). An app set up by\n * `linked localize` lists `packages-local/*` in its `workspaces`, so a walk of\n * the globs finds them as workspace members; it is still walked on its own for\n * an app that has not been set up yet (no glob, or no `workspaces` at all).\n */\nexport const LOCAL_PACKAGES_DIR = LOCAL_DIR;\n\n/**\n * Walk the app's `package.json` `workspaces` field and return every\n * workspace package that declares `\"linkedPackage\": true`.\n *\n * Lives here (not in cli-methods.ts) so consumers like LinkedServer can\n * import it without dragging the rest of the legacy cli-methods flow into\n * Vite's SSR module graph.\n *\n * Kept deliberately narrow: this is the set the dev resolver and the runtime\n * treat as linked packages. Commands that want every *buildable* local\n * package — flag or no flag, workspace or localized checkout — want\n * {@link discoverLocalPackages} instead.\n */\nexport function getLincdPackages(\n rootPath = process.cwd(),\n): PackageDetails[] {\n return discoverLocalPackages(rootPath, {includeLocalPackagesDir: false})\n .filter((pkg) => pkg.isLinkedPackage)\n .map(({path: packagePath, packageName}) => ({path: packagePath, packageName}));\n}\n\n/**\n * Every local package directory this app can see, whether or not it declares\n * `linkedPackage: true`.\n *\n * Two sources, because the workspace globs are not the whole picture any more:\n *\n * 1. the `workspaces` field (negations honoured — see ./workspace-globs.js),\n * which includes `packages-local/*` in an app set up for localizing;\n * 2. `packages-local/`, the localized checkouts, for an app whose globs do\n * not reach it. A checkout a glob already found is not added twice.\n *\n * Nothing is filtered out here. Callers decide what they can act on and are\n * expected to SAY what they skipped and why.\n */\nexport function discoverLocalPackages(\n rootPath = process.cwd(),\n options: {includeLocalPackagesDir?: boolean; localPackagesDir?: string} = {},\n): LocalPackage[] {\n const {includeLocalPackagesDir = true, localPackagesDir = LOCAL_PACKAGES_DIR} =\n options;\n\n let pack = getPackageJSON(rootPath);\n if (!pack || !pack.workspaces) {\n const originalRoot = rootPath;\n for (let i = 0; i <= 3; i++) {\n rootPath = path.join(originalRoot, ...Array(i).fill('..'));\n pack = getPackageJSON(rootPath);\n if (pack && pack.workspaces) break;\n }\n if (!pack || !pack.workspaces) {\n // Standalone apps (scaffolded with `linked create-app`) don't have\n // workspaces — expected. Fall back to the original root so a\n // `packages-local/` beside it is still found.\n rootPath = originalRoot;\n }\n }\n\n const res: LocalPackage[] = [];\n if (pack && pack.workspaces) {\n checkWorkspaces(rootPath, pack.workspaces, res);\n }\n if (includeLocalPackagesDir) {\n checkLocalPackagesDir(rootPath, localPackagesDir, res);\n }\n return res;\n}\n\n/**\n * Add every immediate subdirectory of `packages-local/` that holds a\n * `package.json`. No glob, no negations: the directory has no `workspaces`\n * entry to interpret, its contents are there because a developer localized\n * them on purpose, and each one is a plain checkout.\n */\nfunction checkLocalPackagesDir(\n rootPath: string,\n localPackagesDir: string,\n res: LocalPackage[],\n) {\n const dir = path.join(rootPath, localPackagesDir);\n if (!fs.existsSync(dir)) return;\n const already = new Set(res.map((pkg) => path.resolve(pkg.path)));\n for (const entry of fs.readdirSync(dir)) {\n if (entry.startsWith('.')) continue;\n const packagePath = path.join(dir, entry);\n if (!fs.statSync(packagePath).isDirectory()) continue;\n // A checkout a glob already picked up (`packages-local/*`) must not\n // appear twice — duplicates would be built twice and counted twice.\n if (already.has(path.resolve(packagePath))) continue;\n addPackage(packagePath, 'local-packages-dir', res);\n }\n}\n\nfunction checkWorkspaces(rootPath: string, workspaces: any, res: LocalPackage[]) {\n // Negated entries (\"!packages/core\") are excluded the way npm excludes them\n // — including from the exact-path branch below, which npm also subjects to\n // them. See ./workspace-globs.js.\n const {patterns, negatedPatterns} = parseWorkspacePatterns(workspaces);\n const checkUnlessNegated = (packagePath: string) => {\n const rel = path.relative(rootPath, packagePath).split(path.sep).join('/');\n if (isWorkspacePathNegated(rel, negatedPatterns)) return;\n checkPackagePath(rootPath, packagePath, res);\n };\n patterns.forEach((workspace: string) => {\n const workspacePath = path.join(rootPath, workspace.replace('/*', ''));\n if (workspace.indexOf('/*') !== -1) {\n if (fs.existsSync(workspacePath)) {\n const folders = fs.readdirSync(workspacePath);\n folders.forEach((folder: string) => {\n if (folder !== './' && folder !== '../') {\n checkUnlessNegated(path.join(workspacePath, folder));\n }\n });\n }\n } else {\n checkUnlessNegated(workspacePath);\n }\n });\n}\n\nfunction checkPackagePath(rootPath: string, packagePath: string, res: LocalPackage[]) {\n const packageJsonPath = path.join(packagePath, 'package.json');\n if (!fs.existsSync(packageJsonPath)) return;\n const pack = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n if (pack && pack.workspaces) {\n checkWorkspaces(packagePath, pack.workspaces, res);\n } else if (pack) {\n addPackage(packagePath, 'workspace', res, pack);\n }\n}\n\nfunction addPackage(\n packagePath: string,\n source: LocalPackage['source'],\n res: LocalPackage[],\n packageJson?: any,\n) {\n const pack = packageJson ?? getPackageJSON(packagePath);\n if (!pack || !pack.name) return;\n res.push({\n path: packagePath,\n packageName: pack.name,\n source,\n // The one definition, shared with `linked build-package`.\n isLinkedPackage: isLinkedPackageJson(pack),\n isApp: pack.linkedApp === true,\n hasBuildScript: !!pack.scripts?.build,\n });\n}\n\n/**\n * Filters packages to only include those in the dependency tree of the app root\n */\nfunction filterPackagesByDependencyTree(\n allPackages: Map<string, PackageDetails>,\n appRootPath: string,\n): Map<string, PackageDetails> {\n const appPackageJson = getPackageJSON(appRootPath);\n if (!appPackageJson) {\n return allPackages;\n }\n\n const relevantPackages = new Map<string, PackageDetails>();\n const packagesToCheck = new Set<string>();\n\n // Start with direct dependencies from app root, plus everything localized:\n // a package created locally is linked but cannot be declared until it is\n // published (an unpublished range fails `npm install`), and being localized\n // already says this app is developed against it.\n [\n ...Object.keys(appPackageJson.dependencies || {}),\n ...localizedPackageNames(appRootPath),\n ].forEach((dep) => {\n if (allPackages.has(dep)) {\n packagesToCheck.add(dep);\n }\n });\n\n // Recursively add dependencies\n const processedPackages = new Set<string>();\n\n while (packagesToCheck.size > 0) {\n const packageName = Array.from(packagesToCheck)[0];\n packagesToCheck.delete(packageName);\n\n if (processedPackages.has(packageName)) {\n continue;\n }\n\n processedPackages.add(packageName);\n const packageDetails = allPackages.get(packageName);\n\n if (packageDetails) {\n relevantPackages.set(packageName, packageDetails);\n\n // Get this package's dependencies\n const packageJson = getPackageJSON(packageDetails.path);\n if (packageJson && packageJson.dependencies) {\n Object.keys(packageJson.dependencies).forEach((dep) => {\n if (allPackages.has(dep) && !processedPackages.has(dep)) {\n packagesToCheck.add(dep);\n }\n });\n }\n }\n }\n\n return relevantPackages;\n}\n\n/**\n * The names of the app's localized checkouts — every directory in\n * `packages-local/` with a named `package.json` (localize/members.ts). Nothing\n * there is simply \"nothing localized\".\n */\nexport function localizedPackageNames(appRootPath: string): string[] {\n return localMembers(appRootPath).map((member) => member.name);\n}\n\n/** A package `build-all` found but will not build, and why not. */\nexport interface SkippedPackage {\n packageName: string;\n path: string;\n reason: string;\n}\n\n/** What `build-all` found, and what it decided to do with each package. */\nexport interface BuildAllPlan {\n build: Map<string, PackageDetails>;\n skipped: SkippedPackage[];\n}\n\n/** The package whose `linked` bin the other packages' build scripts run. */\nexport const BUILD_TOOL_PACKAGE = '@_linked/cli';\n\n/** Where `build-all` starts: everything in the groups before it is passed over. */\nexport type BuildToolStart = 'pre' | 'tool' | 'rest';\n\n/** How `build-all` orders the build tool against everything else. */\nexport interface BuildToolOrder {\n /**\n * What the build tool depends on, transitively, among the packages to build\n * (a localized `@_linked/core`), in dependency order. Built before it.\n */\n pre: Map<string, PackageDetails>;\n /** The build tool, when it is among the packages to build. */\n tool?: PackageDetails;\n /** Everything else, built afterwards in dependency order. */\n rest: Map<string, PackageDetails>;\n /** The first group to build; the groups before it are passed over (`--from`). */\n start: BuildToolStart;\n /** The `--from` to apply inside `start` (`pre` or `rest`); unset when the build starts at its top. */\n from?: string;\n}\n\n/** The package names a package's `dependencies` field lists. */\nfunction declaredDependencies(pkg: PackageDetails): string[] {\n return Object.keys(getPackageJSON(pkg.path, false)?.dependencies || {});\n}\n\n/**\n * Split the build around the build tool (`@_linked/cli`).\n *\n * Every other package's `build` script runs `linked build`, which is THIS\n * package's `lib/`. Built in parallel with them, its `rimraf ./lib` pulled that\n * `lib/` out from under their builds (`ENOENT …/lib/esm/installed-packages.js`),\n * and whatever was built before it ran a stale cli. So when it is in the set it\n * is built alone, and the rest only once it has succeeded.\n *\n * It cannot be built FIRST, though: a localized `@_linked/core` it depends on\n * must have its `lib/` before the tool's `tsc` runs. So the tool's own\n * dependencies among the packages to build (`pre`, the transitive closure of\n * `dependencies`) go before it, in dependency order. They build with the tool\n * as it was before this run, which is what a fresh checkout's `npm run build`\n * does too.\n *\n * `--from` reads the order as `pre`, then the tool, then `rest`: it resumes\n * inside whichever group holds the package and passes over the groups before\n * it. A name in none of them goes to `rest`, which reports it.\n */\nexport function orderBuildToolFirst(\n packages: Map<string, PackageDetails>,\n from?: string,\n dependenciesOf: (pkg: PackageDetails) => string[] = declaredDependencies,\n): BuildToolOrder {\n const tool = packages.get(BUILD_TOOL_PACKAGE);\n if (!tool) {\n return {pre: new Map(), rest: packages, start: from ? 'rest' : 'pre', from};\n }\n\n // Depth-first, dependencies before dependents, so `pre` is in build order.\n // A cycle back to the tool (or within `pre`) is cut where it closes.\n const pre = new Map<string, PackageDetails>();\n const visiting = new Set<string>([BUILD_TOOL_PACKAGE]);\n const visit = (pkg: PackageDetails) => {\n for (const dep of dependenciesOf(pkg)) {\n const depPkg = packages.get(dep);\n if (!depPkg || visiting.has(dep) || pre.has(dep)) continue;\n visiting.add(dep);\n visit(depPkg);\n pre.set(dep, depPkg);\n }\n };\n visit(tool);\n\n const rest = new Map(packages);\n rest.delete(BUILD_TOOL_PACKAGE);\n for (const name of pre.keys()) rest.delete(name);\n\n if (!from) return {pre, tool, rest, start: 'pre'};\n if (pre.has(from)) return {pre, tool, rest, start: 'pre', from};\n if (from === BUILD_TOOL_PACKAGE) return {pre, tool, rest, start: 'tool'};\n return {pre, tool, rest, start: 'rest', from};\n}\n\n/**\n * Decide what `build-all` builds.\n *\n * Every discovered package lands in exactly one of `build` or `skipped`, and\n * `skipped` carries a reason — because the failure mode this replaces was not\n * a narrow scan, it was a SILENT one. `@_linked/maps` is a shipped Create Now\n * dependency that never got `linkedPackage: true`; `build-all` dropped it and\n * printed nothing, so a build covering half the workspace exited 0 and people\n * acted on it. A skip nobody can see is worse than a failure.\n *\n * What counts as buildable is a CAPABILITY, not a declaration: `build-all`\n * invokes each package's own `build` script, so anything with one can be\n * built whether or not it carries the flag. The flag is still reported when\n * it is missing, since the dev resolver and `linked build` do require it.\n */\nexport function planBuildAll(rootPath = './', appRoot?: string): BuildAllPlan {\n const build = new Map<string, PackageDetails>();\n const skipped: SkippedPackage[] = [];\n const buildable: LocalPackage[] = [];\n\n for (const pkg of discoverLocalPackages(rootPath)) {\n const detail = {path: pkg.path, packageName: pkg.packageName};\n // Packages reached through a `../` workspace glob live outside this\n // repository; building them was never in scope for `build-all`.\n if (pkg.path.indexOf('../') !== -1 || pkg.path.indexOf('..\\\\') !== -1) {\n skipped.push({...detail, reason: 'outside this repository'});\n } else if (pkg.isApp) {\n skipped.push({\n ...detail,\n reason: 'is a linked app — build it with `linked build-app`',\n });\n } else if (!pkg.hasBuildScript) {\n skipped.push({...detail, reason: 'has no `build` script'});\n } else {\n buildable.push(pkg);\n build.set(pkg.packageName, detail);\n }\n }\n\n // Narrow to what this app actually depends on, if we are inside one.\n if (appRoot) {\n const appPackageJson = getPackageJSON(appRoot);\n const isAppWithLinkedDeps =\n appPackageJson &&\n !isLinkedPackageJson(appPackageJson) &&\n [\n ...Object.keys(appPackageJson.dependencies || {}),\n ...localizedPackageNames(appRoot),\n ].some((dep) => build.has(dep));\n\n if (isAppWithLinkedDeps) {\n const inTree = filterPackagesByDependencyTree(build, appRoot);\n for (const pkg of buildable) {\n if (inTree.has(pkg.packageName)) continue;\n build.delete(pkg.packageName);\n skipped.push({\n path: pkg.path,\n packageName: pkg.packageName,\n reason: `not in ${appPackageJson.name || 'this app'}'s dependency tree`,\n });\n }\n }\n }\n\n return {build, skipped};\n}\n\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { LocalizeOptions } from './localize.js';
|
|
2
2
|
import type { Deps } from './run.js';
|
|
3
3
|
/**
|
|
4
|
-
* @param
|
|
5
|
-
* @
|
|
6
|
-
* @param {object} deps `{appRoot, run, log, warn, error}`
|
|
7
|
-
* @returns {number} the process exit code, as `localize` returns it.
|
|
4
|
+
* @param names full npm package names
|
|
5
|
+
* @returns the process exit code, as `localize` returns it.
|
|
8
6
|
*/
|
|
9
|
-
export declare function adopt(names: string[], opts:
|
|
7
|
+
export declare function adopt(names: string[], opts: Pick<LocalizeOptions, 'dir' | 'build'>, deps: Deps): number;
|
|
8
|
+
/** Move every parked checkout back, then one install. No builds: each is as it was. */
|
|
9
|
+
export declare function localizeParked(opts: Pick<LocalizeOptions, 'dir'>, deps: Deps): number;
|
|
10
10
|
//# sourceMappingURL=adopt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adopt.d.ts","sourceRoot":"","sources":["../../../src/localize/adopt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adopt.d.ts","sourceRoot":"","sources":["../../../src/localize/adopt.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,eAAe,EAAW,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,UAAU,CAAC;AAEnC;;;GAGG;AACH,wBAAgB,KAAK,CACnB,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,CAAC,EAC5C,IAAI,EAAE,IAAI,GACT,MAAM,CAER;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,EAClC,IAAI,EAAE,IAAI,GACT,MAAM,CAUR"}
|
|
@@ -1,76 +1,67 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* `--adopt` and `--parked` -- the localize run for checkouts that need no
|
|
3
|
+
* clone.
|
|
4
4
|
*
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* `adopt` takes a checkout that is ALREADY in `packages-local/` -- a package
|
|
6
|
+
* created locally and never published (`create-package --location
|
|
7
|
+
* packages-local`), or a clone put there by hand -- and runs the rest of
|
|
8
|
+
* localize on it: app setup, git hooks, the root `npm install`, its build. No
|
|
9
|
+
* registry lookup, no clone, no pull. It is found by its name among the
|
|
10
|
+
* members, else at `packages-local/<checkoutName>`, so `localize` and `adopt`
|
|
11
|
+
* agree about where a package lives.
|
|
8
12
|
*
|
|
9
|
-
*
|
|
10
|
-
* remote yet;
|
|
11
|
-
* - a clone that was put there by hand.
|
|
12
|
-
*
|
|
13
|
-
* `adopt` takes the checkout as it finds it -- no clone, no pull, no fetch --
|
|
14
|
-
* and runs the same tail as `localize`: install inside it, build, symlink,
|
|
15
|
-
* record. The checkout has to be a git checkout at `<dir>/<checkoutName>`, so
|
|
16
|
-
* that `localize` and `adopt` can never disagree about where a package lives.
|
|
17
|
-
*
|
|
18
|
-
* The recorded `repo` is `--repo` when given, else the checkout's `origin`,
|
|
19
|
-
* else what an earlier run recorded, else absent. Absent is fine: `relink`,
|
|
20
|
-
* `--list` and `remove` never need it.
|
|
13
|
+
* `localizeParked` takes back every checkout `linked delocalize` parked.
|
|
21
14
|
*/
|
|
22
15
|
import fs from 'node:fs';
|
|
23
16
|
import path from 'node:path';
|
|
24
17
|
import { EXIT_REFUSED, LocalizeError } from './errors.js';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
18
|
+
import { checkoutRepoRoot, readJson } from './fsops.js';
|
|
19
|
+
import { runLocalize, unpark } from './localize.js';
|
|
20
|
+
import { LOCAL_DIR, localMembers, parkedMembers } from './members.js';
|
|
21
|
+
import { checkoutNameFor } from './resolve.js';
|
|
28
22
|
/**
|
|
29
|
-
* @param
|
|
30
|
-
* @
|
|
31
|
-
* @param {object} deps `{appRoot, run, log, warn, error}`
|
|
32
|
-
* @returns {number} the process exit code, as `localize` returns it.
|
|
23
|
+
* @param names full npm package names
|
|
24
|
+
* @returns the process exit code, as `localize` returns it.
|
|
33
25
|
*/
|
|
34
26
|
export function adopt(names, opts, deps) {
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
return runLocalize(names, opts, deps, prepareAdopt);
|
|
28
|
+
}
|
|
29
|
+
/** Move every parked checkout back, then one install. No builds: each is as it was. */
|
|
30
|
+
export function localizeParked(opts, deps) {
|
|
31
|
+
const names = parkedMembers(deps.appRoot).map((m) => m.name);
|
|
32
|
+
if (!names.length) {
|
|
33
|
+
deps.log('[localize] nothing is parked.');
|
|
34
|
+
return 0;
|
|
37
35
|
}
|
|
38
|
-
return
|
|
36
|
+
return runLocalize(names, opts, deps, (name) => {
|
|
37
|
+
const parked = parkedMembers(deps.appRoot).find((m) => m.name === name);
|
|
38
|
+
return parked ? unpark(parked, deps) : null;
|
|
39
|
+
});
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
+
function prepareAdopt(name, _opts, deps) {
|
|
41
42
|
var _a, _b;
|
|
42
|
-
const
|
|
43
|
-
const
|
|
43
|
+
const member = localMembers(deps.appRoot).find((m) => m.name === name);
|
|
44
|
+
const relDir = (_a = member === null || member === void 0 ? void 0 : member.dir) !== null && _a !== void 0 ? _a : `${LOCAL_DIR}/${checkoutNameFor(name)}`;
|
|
45
|
+
const pkgDir = path.join(deps.appRoot, relDir);
|
|
44
46
|
if (!fs.existsSync(pkgDir)) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
const parked = parkedMembers(deps.appRoot).some((m) => m.name === name);
|
|
48
|
+
throw new LocalizeError(`there is nothing to adopt at ${relDir}.\n` +
|
|
49
|
+
(parked
|
|
50
|
+
? `${name} is parked. To take it back:\n linked localize ${name}`
|
|
51
|
+
: `adopt installs a checkout that is already there. To clone a published package instead:\n` +
|
|
52
|
+
` linked localize ${name}`), EXIT_REFUSED);
|
|
48
53
|
}
|
|
49
|
-
if (!
|
|
50
|
-
throw new LocalizeError(`${
|
|
51
|
-
|
|
54
|
+
if (!checkoutRepoRoot(pkgDir, deps.appRoot)) {
|
|
55
|
+
throw new LocalizeError(`${relDir} is not a git checkout. Run \`git init\` in it first -- a checkout in ` +
|
|
56
|
+
`${LOCAL_DIR}/ is its own repository, never part of the app's.`, EXIT_REFUSED);
|
|
52
57
|
}
|
|
53
|
-
const declared = (
|
|
58
|
+
const declared = (_b = readJson(path.join(pkgDir, 'package.json'))) === null || _b === void 0 ? void 0 : _b.name;
|
|
54
59
|
if (declared !== name) {
|
|
55
60
|
throw new LocalizeError(declared
|
|
56
|
-
? `${
|
|
57
|
-
: `${
|
|
61
|
+
? `${relDir} declares itself as "${declared}", not "${name}".`
|
|
62
|
+
: `${relDir} has no package.json naming it, so it is not the package "${name}".`, EXIT_REFUSED);
|
|
58
63
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
`with ${relPkg}.`);
|
|
62
|
-
}
|
|
63
|
-
guardForeignLink(name, dir, opts, deps);
|
|
64
|
-
const repo = opts.repo
|
|
65
|
-
? normalizeGitUrl(opts.repo)
|
|
66
|
-
: ((_b = originOf(pkgDir, deps)) !== null && _b !== void 0 ? _b : recorded === null || recorded === void 0 ? void 0 : recorded.repo);
|
|
67
|
-
deps.log(`[localize] adopting ${relPkg}${repo ? ` (${repo})` : ' (no remote)'}`);
|
|
68
|
-
return installLinkAndRecord({ npmName: name, clone: pkgDir, relPkg, pkgDir, repo }, opts, deps);
|
|
69
|
-
}
|
|
70
|
-
/** The checkout's `origin` URL, or undefined when it has none. Read, never fetched. */
|
|
71
|
-
function originOf(pkgDir, deps) {
|
|
72
|
-
const r = deps.run('git', ['remote', 'get-url', 'origin'], { cwd: pkgDir });
|
|
73
|
-
const url = r.stdout.trim();
|
|
74
|
-
return r.status === 0 && url ? normalizeGitUrl(url) : undefined;
|
|
64
|
+
deps.log(`[localize] adopting ${relDir}`);
|
|
65
|
+
return { name, dir: relDir, build: true };
|
|
75
66
|
}
|
|
76
67
|
//# sourceMappingURL=adopt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adopt.js","sourceRoot":"","sources":["../../../src/localize/adopt.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"adopt.js","sourceRoot":"","sources":["../../../src/localize/adopt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AACxD,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAElD,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAG7C;;;GAGG;AACH,MAAM,UAAU,KAAK,CACnB,KAAe,EACf,IAA4C,EAC5C,IAAU;IAEV,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;AACtD,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,cAAc,CAC5B,IAAkC,EAClC,IAAU;IAEV,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,CAAC,KAAK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,mDAAmD,IAAI,EAAE;gBAClE,CAAC,CAAC,0FAA0F;oBAC1F,qBAAqB,IAAI,EAAE,CAAC,EAClC,YAAY,CACb,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,aAAa,CACrB,GAAG,MAAM,wEAAwE;YAC/E,GAAG,SAAS,mDAAmD,EACjE,YAAY,CACb,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAA,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,0CAAE,IAAI,CAAC;IACnE,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,IAAI,aAAa,CACrB,QAAQ;YACN,CAAC,CAAC,GAAG,MAAM,wBAAwB,QAAQ,WAAW,IAAI,IAAI;YAC9D,CAAC,CAAC,GAAG,MAAM,6DAA6D,IAAI,IAAI,EAClF,YAAY,CACb,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAC;IAC1C,OAAO,EAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;AAC1C,CAAC","sourcesContent":["/**\n * `--adopt` and `--parked` -- the localize run for checkouts that need no\n * clone.\n *\n * `adopt` takes a checkout that is ALREADY in `packages-local/` -- a package\n * created locally and never published (`create-package --location\n * packages-local`), or a clone put there by hand -- and runs the rest of\n * localize on it: app setup, git hooks, the root `npm install`, its build. No\n * registry lookup, no clone, no pull. It is found by its name among the\n * members, else at `packages-local/<checkoutName>`, so `localize` and `adopt`\n * agree about where a package lives.\n *\n * `localizeParked` takes back every checkout `linked delocalize` parked.\n */\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {EXIT_REFUSED, LocalizeError} from './errors.js';\nimport {checkoutRepoRoot, readJson} from './fsops.js';\nimport {runLocalize, unpark} from './localize.js';\nimport type {LocalizeOptions, Prepared} from './localize.js';\nimport {LOCAL_DIR, localMembers, parkedMembers} from './members.js';\nimport {checkoutNameFor} from './resolve.js';\nimport type {Deps} from './run.js';\n\n/**\n * @param names full npm package names\n * @returns the process exit code, as `localize` returns it.\n */\nexport function adopt(\n names: string[],\n opts: Pick<LocalizeOptions, 'dir' | 'build'>,\n deps: Deps,\n): number {\n return runLocalize(names, opts, deps, prepareAdopt);\n}\n\n/** Move every parked checkout back, then one install. No builds: each is as it was. */\nexport function localizeParked(\n opts: Pick<LocalizeOptions, 'dir'>,\n deps: Deps,\n): number {\n const names = parkedMembers(deps.appRoot).map((m) => m.name);\n if (!names.length) {\n deps.log('[localize] nothing is parked.');\n return 0;\n }\n return runLocalize(names, opts, deps, (name) => {\n const parked = parkedMembers(deps.appRoot).find((m) => m.name === name);\n return parked ? unpark(parked, deps) : null;\n });\n}\n\nfunction prepareAdopt(\n name: string,\n _opts: LocalizeOptions,\n deps: Deps,\n): Prepared {\n const member = localMembers(deps.appRoot).find((m) => m.name === name);\n const relDir = member?.dir ?? `${LOCAL_DIR}/${checkoutNameFor(name)}`;\n const pkgDir = path.join(deps.appRoot, relDir);\n\n if (!fs.existsSync(pkgDir)) {\n const parked = parkedMembers(deps.appRoot).some((m) => m.name === name);\n throw new LocalizeError(\n `there is nothing to adopt at ${relDir}.\\n` +\n (parked\n ? `${name} is parked. To take it back:\\n linked localize ${name}`\n : `adopt installs a checkout that is already there. To clone a published package instead:\\n` +\n ` linked localize ${name}`),\n EXIT_REFUSED,\n );\n }\n if (!checkoutRepoRoot(pkgDir, deps.appRoot)) {\n throw new LocalizeError(\n `${relDir} is not a git checkout. Run \\`git init\\` in it first -- a checkout in ` +\n `${LOCAL_DIR}/ is its own repository, never part of the app's.`,\n EXIT_REFUSED,\n );\n }\n\n const declared = readJson(path.join(pkgDir, 'package.json'))?.name;\n if (declared !== name) {\n throw new LocalizeError(\n declared\n ? `${relDir} declares itself as \"${declared}\", not \"${name}\".`\n : `${relDir} has no package.json naming it, so it is not the package \"${name}\".`,\n EXIT_REFUSED,\n );\n }\n\n deps.log(`[localize] adopting ${relDir}`);\n return {name, dir: relDir, build: true};\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace root for `start`: the nearest ancestor (or `start` itself)
|
|
3
|
+
* whose `package.json` has `workspaces`, then each higher ancestor with
|
|
4
|
+
* `workspaces` whose globs match the root found so far -- the first one that
|
|
5
|
+
* does not ends the climb. Of that chain, the topmost that is not itself a
|
|
6
|
+
* linked package (`"linkedPackage": true`), else the topmost. Null when there
|
|
7
|
+
* is none.
|
|
8
|
+
*/
|
|
9
|
+
export declare function findWorkspaceRoot(start: string): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* The app root for a command run in `start`: the workspace root above it, or
|
|
12
|
+
* `start` itself for an app that has no `workspaces` yet (localize's set-up
|
|
13
|
+
* adds them).
|
|
14
|
+
*/
|
|
15
|
+
export declare function findAppRoot(start: string): string;
|
|
16
|
+
//# sourceMappingURL=app-root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-root.d.ts","sourceRoot":"","sources":["../../../src/localize/app-root.ts"],"names":[],"mappings":"AAkDA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkB9D;AA0BD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD"}
|