@ethlete/cli 2.1.0-next.8 → 3.0.0-next.16
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 +93 -0
- package/README.md +22 -7
- package/design/define-call.ts +92 -0
- package/design/web/env.d.ts +11 -0
- package/design/web/frame.html +17 -0
- package/design/web/frame.ts +44 -0
- package/design/web/host.css +494 -0
- package/design/web/host.ts +445 -0
- package/design/web/index.html +11 -0
- package/package.json +13 -2
- package/src/index.d.ts +1 -0
- package/src/index.js +32 -4
- package/src/index.js.map +1 -1
- package/src/lib/api/clear.js +13 -3
- package/src/lib/api/clear.js.map +1 -1
- package/src/lib/api/compose.js +5 -1
- package/src/lib/api/compose.js.map +1 -1
- package/src/lib/api/git.d.ts +11 -4
- package/src/lib/api/git.js +35 -8
- package/src/lib/api/git.js.map +1 -1
- package/src/lib/api/load-definitions.js +10 -1
- package/src/lib/api/load-definitions.js.map +1 -1
- package/src/lib/api/ports.js +12 -3
- package/src/lib/api/ports.js.map +1 -1
- package/src/lib/api/run.js +8 -3
- package/src/lib/api/run.js.map +1 -1
- package/src/lib/api/setup.js +1 -1
- package/src/lib/api/setup.js.map +1 -1
- package/src/lib/api/state.js +7 -5
- package/src/lib/api/state.js.map +1 -1
- package/src/lib/auth/composer-auth.js +3 -2
- package/src/lib/auth/composer-auth.js.map +1 -1
- package/src/lib/auth/gitlab-token.js +1 -1
- package/src/lib/auth/gitlab-token.js.map +1 -1
- package/src/lib/config/diagnose.js +15 -9
- package/src/lib/config/diagnose.js.map +1 -1
- package/src/lib/config/local-config.d.ts +1 -1
- package/src/lib/design/calls-tsconfig.d.ts +6 -0
- package/src/lib/design/calls-tsconfig.js +37 -0
- package/src/lib/design/calls-tsconfig.js.map +1 -0
- package/src/lib/design/check.d.ts +11 -0
- package/src/lib/design/check.js +203 -0
- package/src/lib/design/check.js.map +1 -0
- package/src/lib/design/design-command.d.ts +10 -0
- package/src/lib/design/design-command.js +32 -0
- package/src/lib/design/design-command.js.map +1 -0
- package/src/lib/design/index.d.ts +5 -0
- package/src/lib/design/index.js +9 -0
- package/src/lib/design/index.js.map +1 -0
- package/src/lib/design/paths.d.ts +24 -0
- package/src/lib/design/paths.js +31 -0
- package/src/lib/design/paths.js.map +1 -0
- package/src/lib/design/serve.d.ts +7 -0
- package/src/lib/design/serve.js +144 -0
- package/src/lib/design/serve.js.map +1 -0
- package/src/lib/design/vite-paths.d.ts +7 -0
- package/src/lib/design/vite-paths.js +15 -0
- package/src/lib/design/vite-paths.js.map +1 -0
- package/src/lib/doctor/doctor-command.js +18 -4
- package/src/lib/doctor/doctor-command.js.map +1 -1
- package/src/lib/index.d.ts +1 -0
- package/src/lib/index.js +1 -0
- package/src/lib/index.js.map +1 -1
- package/src/lib/release.d.ts +38 -1
- package/src/lib/release.js +153 -28
- package/src/lib/release.js.map +1 -1
- package/src/lib/update/agent-rules-sync.d.ts +37 -0
- package/src/lib/update/agent-rules-sync.js +40 -0
- package/src/lib/update/agent-rules-sync.js.map +1 -0
- package/src/lib/update/agent-setup.d.ts +33 -0
- package/src/lib/update/agent-setup.js +124 -0
- package/src/lib/update/agent-setup.js.map +1 -0
- package/src/lib/update/ai.d.ts +37 -8
- package/src/lib/update/ai.js +193 -24
- package/src/lib/update/ai.js.map +1 -1
- package/src/lib/update/args.d.ts +2 -0
- package/src/lib/update/args.js +22 -2
- package/src/lib/update/args.js.map +1 -1
- package/src/lib/update/available-migrations.d.ts +10 -0
- package/src/lib/update/available-migrations.js +23 -0
- package/src/lib/update/available-migrations.js.map +1 -0
- package/src/lib/update/commits.d.ts +63 -0
- package/src/lib/update/commits.js +146 -0
- package/src/lib/update/commits.js.map +1 -0
- package/src/lib/update/gitignore.d.ts +8 -0
- package/src/lib/update/gitignore.js +22 -0
- package/src/lib/update/gitignore.js.map +1 -0
- package/src/lib/update/index.d.ts +6 -0
- package/src/lib/update/index.js +6 -0
- package/src/lib/update/index.js.map +1 -1
- package/src/lib/update/migration-manifest.d.ts +10 -0
- package/src/lib/update/migration-manifest.js +15 -3
- package/src/lib/update/migration-manifest.js.map +1 -1
- package/src/lib/update/migration-record.d.ts +24 -0
- package/src/lib/update/migration-record.js +48 -0
- package/src/lib/update/migration-record.js.map +1 -0
- package/src/lib/update/migrations-command.d.ts +14 -0
- package/src/lib/update/migrations-command.js +212 -0
- package/src/lib/update/migrations-command.js.map +1 -0
- package/src/lib/update/package-manager.d.ts +20 -1
- package/src/lib/update/package-manager.js +34 -15
- package/src/lib/update/package-manager.js.map +1 -1
- package/src/lib/update/packages.d.ts +28 -8
- package/src/lib/update/packages.js +117 -36
- package/src/lib/update/packages.js.map +1 -1
- package/src/lib/update/pending.d.ts +16 -0
- package/src/lib/update/pending.js +21 -5
- package/src/lib/update/pending.js.map +1 -1
- package/src/lib/update/plan.d.ts +33 -8
- package/src/lib/update/plan.js +76 -7
- package/src/lib/update/plan.js.map +1 -1
- package/src/lib/update/registry.d.ts +32 -4
- package/src/lib/update/registry.js +145 -8
- package/src/lib/update/registry.js.map +1 -1
- package/src/lib/update/run-migrations.d.ts +2 -0
- package/src/lib/update/run-migrations.js +20 -15
- package/src/lib/update/run-migrations.js.map +1 -1
- package/src/lib/update/scan.d.ts +14 -0
- package/src/lib/update/scan.js +57 -0
- package/src/lib/update/scan.js.map +1 -0
- package/src/lib/update/semver.js +2 -1
- package/src/lib/update/semver.js.map +1 -1
- package/src/lib/update/tasks.d.ts +18 -1
- package/src/lib/update/tasks.js +114 -43
- package/src/lib/update/tasks.js.map +1 -1
- package/src/lib/update/update-command.d.ts +7 -0
- package/src/lib/update/update-command.js +300 -73
- package/src/lib/update/update-command.js.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nxCommand = exports.detectPackageManager = void 0;
|
|
3
|
+
exports.spawnPackageManager = exports.nxCommand = exports.installEnv = exports.detectPackageManager = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
4
5
|
const fs_1 = require("fs");
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const MANAGERS = {
|
|
@@ -16,27 +17,32 @@ const LOCKFILES = [
|
|
|
16
17
|
['bun.lock', 'bun'],
|
|
17
18
|
['package-lock.json', 'npm'],
|
|
18
19
|
];
|
|
19
|
-
const
|
|
20
|
-
var _a;
|
|
21
|
-
const declared = (_a = manifest === null || manifest === void 0 ? void 0 : manifest.packageManager) !== null && _a !== void 0 ? _a : userAgent;
|
|
22
|
-
return declared
|
|
23
|
-
? Object.keys(MANAGERS).find((name) => declared.startsWith(name))
|
|
24
|
-
: undefined;
|
|
25
|
-
};
|
|
20
|
+
const managerNamed = (declared) => declared ? Object.keys(MANAGERS).find((name) => declared.startsWith(name)) : undefined;
|
|
26
21
|
/**
|
|
27
22
|
* The package manager this repo uses: what `packageManager` declares, else the lockfile that is there,
|
|
28
|
-
* else npm. `et update` runs the install itself, so it has to be
|
|
23
|
+
* else the one running this command, else npm. `et update` runs the install itself, so it has to be
|
|
24
|
+
* the same one the repo already uses.
|
|
29
25
|
*/
|
|
30
26
|
const detectPackageManager = (options) => {
|
|
31
|
-
var _a;
|
|
27
|
+
var _a, _b, _c, _d;
|
|
32
28
|
const { root, manifest, env = process.env } = options;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
return MANAGERS[declared];
|
|
36
|
-
const found = LOCKFILES.find(([fileName]) => (0, fs_1.existsSync)((0, path_1.join)(root, fileName)));
|
|
37
|
-
return MANAGERS[(_a = found === null || found === void 0 ? void 0 : found[1]) !== null && _a !== void 0 ? _a : 'npm'];
|
|
29
|
+
const found = (_a = LOCKFILES.find(([fileName]) => (0, fs_1.existsSync)((0, path_1.join)(root, fileName)))) === null || _a === void 0 ? void 0 : _a[1];
|
|
30
|
+
return MANAGERS[(_d = (_c = (_b = managerNamed(manifest === null || manifest === void 0 ? void 0 : manifest.packageManager)) !== null && _b !== void 0 ? _b : found) !== null && _c !== void 0 ? _c : managerNamed(env['npm_config_user_agent'])) !== null && _d !== void 0 ? _d : 'npm'];
|
|
38
31
|
};
|
|
39
32
|
exports.detectPackageManager = detectPackageManager;
|
|
33
|
+
const INJECTED_REGISTRY = /^npm_config_(@[^:]+:)?registry$/i;
|
|
34
|
+
/**
|
|
35
|
+
* The environment for the install `et update` spawns. Inside a package manager script, yarn 1 exports
|
|
36
|
+
* its own default registry as `npm_config_registry`, which the child install would read over the
|
|
37
|
+
* repo's `.npmrc` and `.yarnrc`. Dropping it lets the child read the repo's config, as it does when
|
|
38
|
+
* `et` runs outside a script.
|
|
39
|
+
*/
|
|
40
|
+
const installEnv = (env = process.env) => {
|
|
41
|
+
if (env['npm_lifecycle_event'] === undefined)
|
|
42
|
+
return env;
|
|
43
|
+
return Object.fromEntries(Object.entries(env).filter(([key]) => !INJECTED_REGISTRY.test(key)));
|
|
44
|
+
};
|
|
45
|
+
exports.installEnv = installEnv;
|
|
40
46
|
/** The command that runs an `nx` from this repo, for example `yarn nx generate …`. */
|
|
41
47
|
const nxCommand = (options) => [
|
|
42
48
|
...options.manager.run,
|
|
@@ -44,4 +50,17 @@ const nxCommand = (options) => [
|
|
|
44
50
|
...options.args,
|
|
45
51
|
];
|
|
46
52
|
exports.nxCommand = nxCommand;
|
|
53
|
+
const CMD_SAFE_ARGUMENT = /^[\w@:/\\.=,+-]+$/;
|
|
54
|
+
const cmdQuoted = (argument) => CMD_SAFE_ARGUMENT.test(argument) ? argument : `"${argument.replace(/"/g, '""')}"`;
|
|
55
|
+
/**
|
|
56
|
+
* Runs a package manager command such as `yarn install`. On Windows the managers are `.cmd` shims,
|
|
57
|
+
* which Node spawns only through a shell (CVE-2024-27980), so the command runs as one quoted line there.
|
|
58
|
+
*/
|
|
59
|
+
const spawnPackageManager = (options) => {
|
|
60
|
+
const { binary, args, spawn, platform = process.platform } = options;
|
|
61
|
+
if (platform !== 'win32')
|
|
62
|
+
return (0, child_process_1.spawnSync)(binary, args, spawn);
|
|
63
|
+
return (0, child_process_1.spawnSync)([binary, ...args].map(cmdQuoted).join(' '), Object.assign(Object.assign({}, spawn), { shell: true }));
|
|
64
|
+
};
|
|
65
|
+
exports.spawnPackageManager = spawnPackageManager;
|
|
47
66
|
//# sourceMappingURL=package-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/update/package-manager.ts"],"names":[],"mappings":";;;AAAA,2BAAgC;AAChC,+BAA4B;AAa5B,MAAM,QAAQ,GAA+C;IAC3D,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE;IACnE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;IAC3E,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE;IAChE,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE;CAChE,CAAC;AAEF,MAAM,SAAS,GAAmC;IAChD,CAAC,WAAW,EAAE,MAAM,CAAC;IACrB,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC1B,CAAC,WAAW,EAAE,KAAK,CAAC;IACpB,CAAC,UAAU,EAAE,KAAK,CAAC;IACnB,CAAC,mBAAmB,EAAE,KAAK,CAAC;CAC7B,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"package-manager.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib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iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AAEpF;;;GAGG;AACI,MAAM,mBAAmB,GAAG,CAAC,OAKnC,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC;IAErE,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,IAAA,yBAAS,EAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAEhE,OAAO,IAAA,yBAAS,EAAC,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,kCAAO,KAAK,KAAE,KAAK,EAAE,IAAI,IAAG,CAAC;AAC1F,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B"}
|
|
@@ -1,40 +1,60 @@
|
|
|
1
1
|
export declare const ETHLETE_SCOPE = "@ethlete/";
|
|
2
|
+
export declare const ROOT_MANIFEST = "package.json";
|
|
2
3
|
export declare const DEPENDENCY_FIELDS: readonly ["dependencies", "devDependencies", "peerDependencies"];
|
|
3
4
|
export type DependencyField = (typeof DEPENDENCY_FIELDS)[number];
|
|
4
5
|
export type Manifest = Partial<Record<DependencyField, Record<string, string>>> & {
|
|
5
6
|
packageManager?: string;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
/** One place a manifest declares a package: which file, which field, and the range written there. */
|
|
9
|
+
export type DeclaredSite = {
|
|
10
|
+
/** Relative to the root, with `/` separators. `package.json` for the root manifest. */
|
|
11
|
+
manifestPath: string;
|
|
9
12
|
field: DependencyField;
|
|
10
13
|
range: string;
|
|
11
14
|
/** The version the range points at, or `undefined` for a range no single version can be read from. */
|
|
12
15
|
declaredVersion?: string;
|
|
16
|
+
};
|
|
17
|
+
export type DeclaredPackage = {
|
|
18
|
+
name: string;
|
|
19
|
+
/** Every field of every manifest in the repo that declares this package. */
|
|
20
|
+
sites: DeclaredSite[];
|
|
13
21
|
/** The version in `node_modules`, which is what the migrations of an update run against. */
|
|
14
22
|
installedVersion?: string;
|
|
15
23
|
};
|
|
16
24
|
export declare const manifestPath: (root: string) => string;
|
|
17
|
-
export declare const readManifest: (root: string) => Manifest | undefined;
|
|
25
|
+
export declare const readManifest: (root: string, relativePath?: string) => Manifest | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Every `package.json` in the repo, root first. An Nx repo keeps a manifest per buildable library, and
|
|
28
|
+
* those pin `@ethlete/*` too, so an update that only rewrites the root leaves the rest behind.
|
|
29
|
+
*/
|
|
30
|
+
export declare const findManifests: (root: string) => string[];
|
|
18
31
|
/** The version of `packageName` in `node_modules`, which is the one the running code came from. */
|
|
19
32
|
export declare const installedVersion: (root: string, packageName: string) => string | undefined;
|
|
20
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* The version an update starts from when nothing is installed: the newest one any manifest declares, so
|
|
35
|
+
* a library manifest that lags behind the root does not read as the current version.
|
|
36
|
+
*/
|
|
37
|
+
export declare const newestDeclaredVersion: (sites: readonly DeclaredSite[]) => string | undefined;
|
|
38
|
+
/** Every `@ethlete/*` dependency the repo declares, gathered across all of its manifests. */
|
|
21
39
|
export declare const declaredEthletePackages: (options: {
|
|
22
40
|
root: string;
|
|
23
|
-
|
|
41
|
+
manifests?: readonly string[];
|
|
24
42
|
}) => DeclaredPackage[];
|
|
25
43
|
export type RangeWrite = {
|
|
26
44
|
name: string;
|
|
45
|
+
manifestPath: string;
|
|
27
46
|
field: DependencyField;
|
|
28
47
|
range: string;
|
|
29
48
|
};
|
|
30
49
|
/**
|
|
31
|
-
* Writes new ranges into the
|
|
32
|
-
* comment or a key order the parser cannot represent would not survive -
|
|
50
|
+
* Writes new ranges into the manifests they came from, keeping each file's indentation. A whole file is
|
|
51
|
+
* re-serialised, so a comment or a key order the parser cannot represent would not survive -
|
|
52
|
+
* `package.json` holds neither.
|
|
33
53
|
*/
|
|
34
54
|
export declare const writeRanges: (options: {
|
|
35
55
|
root: string;
|
|
36
56
|
writes: readonly RangeWrite[];
|
|
37
|
-
}) =>
|
|
57
|
+
}) => string[];
|
|
38
58
|
/**
|
|
39
59
|
* The range that carries `version` while keeping how the declared one was written, for example `^`.
|
|
40
60
|
* `undefined` for a range this cannot rewrite safely, such as `workspace:*` or `>=5 <6`.
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rangeFor = exports.writeRanges = exports.declaredEthletePackages = exports.installedVersion = exports.readManifest = exports.manifestPath = exports.DEPENDENCY_FIELDS = exports.ETHLETE_SCOPE = void 0;
|
|
3
|
+
exports.rangeFor = exports.writeRanges = exports.declaredEthletePackages = exports.newestDeclaredVersion = exports.installedVersion = exports.findManifests = exports.readManifest = exports.manifestPath = exports.DEPENDENCY_FIELDS = exports.ROOT_MANIFEST = exports.ETHLETE_SCOPE = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
4
5
|
const fs_1 = require("fs");
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const semver_1 = require("./semver");
|
|
7
8
|
exports.ETHLETE_SCOPE = '@ethlete/';
|
|
9
|
+
exports.ROOT_MANIFEST = 'package.json';
|
|
8
10
|
exports.DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies'];
|
|
11
|
+
const SKIPPED_DIRECTORIES = new Set(['coverage', 'dist', 'node_modules', 'tmp']);
|
|
9
12
|
const readJson = (path) => {
|
|
10
13
|
try {
|
|
11
14
|
return JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
|
|
@@ -15,64 +18,142 @@ const readJson = (path) => {
|
|
|
15
18
|
}
|
|
16
19
|
};
|
|
17
20
|
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
18
|
-
const manifestPath = (root) => (0, path_1.join)(root,
|
|
21
|
+
const manifestPath = (root) => (0, path_1.join)(root, exports.ROOT_MANIFEST);
|
|
19
22
|
exports.manifestPath = manifestPath;
|
|
20
|
-
const readManifest = (root) => {
|
|
21
|
-
const parsed = readJson((0,
|
|
23
|
+
const readManifest = (root, relativePath = exports.ROOT_MANIFEST) => {
|
|
24
|
+
const parsed = readJson((0, path_1.join)(root, relativePath));
|
|
22
25
|
return isRecord(parsed) ? parsed : undefined;
|
|
23
26
|
};
|
|
24
27
|
exports.readManifest = readManifest;
|
|
28
|
+
const sortRootFirst = (paths) => paths.sort((left, right) => {
|
|
29
|
+
if (left === exports.ROOT_MANIFEST)
|
|
30
|
+
return -1;
|
|
31
|
+
if (right === exports.ROOT_MANIFEST)
|
|
32
|
+
return 1;
|
|
33
|
+
return left.localeCompare(right);
|
|
34
|
+
});
|
|
35
|
+
/** The manifests git tracks or would track, or `undefined` when the root is not a git checkout. */
|
|
36
|
+
const trackedManifests = (root) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const result = (0, child_process_1.spawnSync)('git', ['ls-files', '--cached', '--others', '--exclude-standard', '--', `*${exports.ROOT_MANIFEST}`], { cwd: root, encoding: 'utf8' });
|
|
39
|
+
if (result.error || result.status !== 0)
|
|
40
|
+
return undefined;
|
|
41
|
+
const paths = [...new Set(((_a = result.stdout) !== null && _a !== void 0 ? _a : '').split('\n').filter((line) => line.length > 0))];
|
|
42
|
+
return paths.filter((path) => {
|
|
43
|
+
const parts = path.split('/');
|
|
44
|
+
const directories = parts.slice(0, -1);
|
|
45
|
+
return (parts[parts.length - 1] === exports.ROOT_MANIFEST &&
|
|
46
|
+
!directories.some((part) => part.startsWith('.') || SKIPPED_DIRECTORIES.has(part)) &&
|
|
47
|
+
(0, fs_1.existsSync)((0, path_1.join)(root, path)));
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Every `package.json` in the repo, root first. An Nx repo keeps a manifest per buildable library, and
|
|
52
|
+
* those pin `@ethlete/*` too, so an update that only rewrites the root leaves the rest behind.
|
|
53
|
+
*/
|
|
54
|
+
const findManifests = (root) => {
|
|
55
|
+
const tracked = trackedManifests(root);
|
|
56
|
+
if (tracked && tracked.length > 0)
|
|
57
|
+
return sortRootFirst(tracked);
|
|
58
|
+
const found = [];
|
|
59
|
+
const walk = (directory) => {
|
|
60
|
+
let entries;
|
|
61
|
+
try {
|
|
62
|
+
entries = (0, fs_1.readdirSync)(directory, { withFileTypes: true });
|
|
63
|
+
}
|
|
64
|
+
catch (_a) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
if (entry.isDirectory()) {
|
|
69
|
+
if (entry.name.startsWith('.') || SKIPPED_DIRECTORIES.has(entry.name))
|
|
70
|
+
continue;
|
|
71
|
+
walk((0, path_1.join)(directory, entry.name));
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (entry.name !== exports.ROOT_MANIFEST)
|
|
75
|
+
continue;
|
|
76
|
+
found.push((0, path_1.relative)(root, (0, path_1.join)(directory, entry.name)).split(path_1.sep).join('/'));
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
walk(root);
|
|
80
|
+
return sortRootFirst(found);
|
|
81
|
+
};
|
|
82
|
+
exports.findManifests = findManifests;
|
|
25
83
|
/** The version of `packageName` in `node_modules`, which is the one the running code came from. */
|
|
26
84
|
const installedVersion = (root, packageName) => {
|
|
27
|
-
const path = (0, path_1.join)(root, 'node_modules', ...packageName.split('/'),
|
|
85
|
+
const path = (0, path_1.join)(root, 'node_modules', ...packageName.split('/'), exports.ROOT_MANIFEST);
|
|
28
86
|
if (!(0, fs_1.existsSync)(path))
|
|
29
87
|
return undefined;
|
|
30
88
|
const parsed = readJson(path);
|
|
31
89
|
return isRecord(parsed) && typeof parsed['version'] === 'string' ? parsed['version'] : undefined;
|
|
32
90
|
};
|
|
33
91
|
exports.installedVersion = installedVersion;
|
|
34
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* The version an update starts from when nothing is installed: the newest one any manifest declares, so
|
|
94
|
+
* a library manifest that lags behind the root does not read as the current version.
|
|
95
|
+
*/
|
|
96
|
+
const newestDeclaredVersion = (sites) => sites.reduce((newest, site) => {
|
|
97
|
+
if (site.declaredVersion === undefined)
|
|
98
|
+
return newest;
|
|
99
|
+
return newest === undefined || (0, semver_1.compareVersions)(site.declaredVersion, newest) > 0 ? site.declaredVersion : newest;
|
|
100
|
+
}, undefined);
|
|
101
|
+
exports.newestDeclaredVersion = newestDeclaredVersion;
|
|
102
|
+
/** Every `@ethlete/*` dependency the repo declares, gathered across all of its manifests. */
|
|
35
103
|
const declaredEthletePackages = (options) => {
|
|
36
|
-
var _a;
|
|
37
|
-
const { root,
|
|
38
|
-
const
|
|
39
|
-
for (const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
104
|
+
var _a, _b;
|
|
105
|
+
const { root, manifests = (0, exports.findManifests)(root) } = options;
|
|
106
|
+
const byName = new Map();
|
|
107
|
+
for (const relativePath of manifests) {
|
|
108
|
+
const manifest = (0, exports.readManifest)(root, relativePath);
|
|
109
|
+
if (!manifest)
|
|
110
|
+
continue;
|
|
111
|
+
for (const field of exports.DEPENDENCY_FIELDS) {
|
|
112
|
+
for (const [name, range] of Object.entries((_a = manifest[field]) !== null && _a !== void 0 ? _a : {})) {
|
|
113
|
+
if (!name.startsWith(exports.ETHLETE_SCOPE))
|
|
114
|
+
continue;
|
|
115
|
+
const entry = (_b = byName.get(name)) !== null && _b !== void 0 ? _b : {
|
|
116
|
+
name,
|
|
117
|
+
sites: [],
|
|
118
|
+
installedVersion: (0, exports.installedVersion)(root, name),
|
|
119
|
+
};
|
|
120
|
+
entry.sites.push({ manifestPath: relativePath, field, range, declaredVersion: (0, semver_1.versionOfRange)(range) });
|
|
121
|
+
byName.set(name, entry);
|
|
122
|
+
}
|
|
50
123
|
}
|
|
51
124
|
}
|
|
52
|
-
return
|
|
125
|
+
return [...byName.values()];
|
|
53
126
|
};
|
|
54
127
|
exports.declaredEthletePackages = declaredEthletePackages;
|
|
55
128
|
const detectIndent = (source) => { var _a, _b; return (_b = (_a = /\n([ \t]+)"/.exec(source)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : ' '; };
|
|
56
129
|
/**
|
|
57
|
-
* Writes new ranges into the
|
|
58
|
-
* comment or a key order the parser cannot represent would not survive -
|
|
130
|
+
* Writes new ranges into the manifests they came from, keeping each file's indentation. A whole file is
|
|
131
|
+
* re-serialised, so a comment or a key order the parser cannot represent would not survive -
|
|
132
|
+
* `package.json` holds neither.
|
|
59
133
|
*/
|
|
60
134
|
const writeRanges = (options) => {
|
|
61
135
|
const { root, writes } = options;
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
136
|
+
const written = [];
|
|
137
|
+
for (const relativePath of new Set(writes.map((write) => write.manifestPath))) {
|
|
138
|
+
const path = (0, path_1.join)(root, relativePath);
|
|
139
|
+
const source = (0, fs_1.readFileSync)(path, 'utf8');
|
|
140
|
+
const parsed = JSON.parse(source);
|
|
141
|
+
if (!isRecord(parsed))
|
|
142
|
+
throw new Error(`${path} is not a JSON object.`);
|
|
143
|
+
for (const write of writes.filter((candidate) => candidate.manifestPath === relativePath)) {
|
|
144
|
+
const field = parsed[write.field];
|
|
145
|
+
if (!isRecord(field))
|
|
146
|
+
continue;
|
|
147
|
+
field[write.name] = write.range;
|
|
148
|
+
}
|
|
149
|
+
const indent = detectIndent(source);
|
|
150
|
+
const newline = source.includes('\r\n') ? '\r\n' : '\n';
|
|
151
|
+
const trailingNewline = source.endsWith('\n') ? newline : '';
|
|
152
|
+
const serialized = JSON.stringify(parsed, null, indent).replace(/\n/g, newline);
|
|
153
|
+
(0, fs_1.writeFileSync)(path, `${serialized}${trailingNewline}`, 'utf8');
|
|
154
|
+
written.push(relativePath);
|
|
72
155
|
}
|
|
73
|
-
|
|
74
|
-
const trailingNewline = source.endsWith('\n') ? '\n' : '';
|
|
75
|
-
(0, fs_1.writeFileSync)(path, `${JSON.stringify(parsed, null, indent)}${trailingNewline}`, 'utf8');
|
|
156
|
+
return written;
|
|
76
157
|
};
|
|
77
158
|
exports.writeRanges = writeRanges;
|
|
78
159
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packages.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/update/packages.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"packages.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/update/packages.ts"],"names":[],"mappings":";;;AAAA,iDAA0C;AAC1C,2BAAkF;AAClF,+BAA2C;AAC3C,qCAAwE;AAE3D,QAAA,aAAa,GAAG,WAAW,CAAC;AAE5B,QAAA,aAAa,GAAG,cAAc,CAAC;AAE/B,QAAA,iBAAiB,GAAG,CAAC,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,CAAU,CAAC;AA0BlG,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAW,EAAE;IACzC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAA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CAAC,CAAC;IAEpC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC;AAClE,CAAC,CAAC;AALW,QAAA,QAAQ,YAKnB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CommitState } from './commits';
|
|
1
2
|
export declare const PENDING_FILE: string;
|
|
2
3
|
export type PendingPackage = {
|
|
3
4
|
name: string;
|
|
@@ -5,9 +6,19 @@ export type PendingPackage = {
|
|
|
5
6
|
from: string | null;
|
|
6
7
|
to: string;
|
|
7
8
|
};
|
|
9
|
+
/** A codemod that already applied, so `--continue` does not run it a second time. */
|
|
10
|
+
export type FinishedMigration = {
|
|
11
|
+
packageName: string;
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
8
14
|
export type PendingUpdate = {
|
|
9
15
|
startedAt: string;
|
|
10
16
|
packages: PendingPackage[];
|
|
17
|
+
finished?: FinishedMigration[];
|
|
18
|
+
/** The `--from` versions of the run, so `--continue` migrates from the same place. */
|
|
19
|
+
from?: Record<string, string>;
|
|
20
|
+
/** Absent when the run commits nothing: `--no-commit`, or no git checkout. */
|
|
21
|
+
commits?: CommitState;
|
|
11
22
|
};
|
|
12
23
|
/**
|
|
13
24
|
* Records what an update moved, before the install replaces the versions the migrations run from. An
|
|
@@ -18,4 +29,9 @@ export declare const writePendingUpdate: (options: {
|
|
|
18
29
|
pending: PendingUpdate;
|
|
19
30
|
}) => void;
|
|
20
31
|
export declare const readPendingUpdate: (root: string) => PendingUpdate | undefined;
|
|
32
|
+
export declare const isFinished: (options: {
|
|
33
|
+
finished: readonly FinishedMigration[];
|
|
34
|
+
packageName: string;
|
|
35
|
+
name: string;
|
|
36
|
+
}) => boolean;
|
|
21
37
|
export declare const clearPendingUpdate: (root: string) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clearPendingUpdate = exports.readPendingUpdate = exports.writePendingUpdate = exports.PENDING_FILE = void 0;
|
|
3
|
+
exports.clearPendingUpdate = exports.isFinished = exports.readPendingUpdate = exports.writePendingUpdate = exports.PENDING_FILE = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const tasks_1 = require("./tasks");
|
|
@@ -16,6 +16,18 @@ const writePendingUpdate = (options) => {
|
|
|
16
16
|
(0, fs_1.writeFileSync)((0, path_1.join)(root, exports.PENDING_FILE), `${JSON.stringify(pending, null, 2)}\n`, 'utf8');
|
|
17
17
|
};
|
|
18
18
|
exports.writePendingUpdate = writePendingUpdate;
|
|
19
|
+
const readStringRecord = (value) => isRecord(value)
|
|
20
|
+
? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === 'string'))
|
|
21
|
+
: undefined;
|
|
22
|
+
const readCommits = (value) => {
|
|
23
|
+
if (!isRecord(value))
|
|
24
|
+
return undefined;
|
|
25
|
+
const baseline = readStringRecord(value['baseline']);
|
|
26
|
+
const snapshot = readStringRecord(value['snapshot']);
|
|
27
|
+
if (!baseline || !snapshot)
|
|
28
|
+
return undefined;
|
|
29
|
+
return { baseline, snapshot, bumped: value['bumped'] === true };
|
|
30
|
+
};
|
|
19
31
|
const readPendingUpdate = (root) => {
|
|
20
32
|
const path = (0, path_1.join)(root, exports.PENDING_FILE);
|
|
21
33
|
if (!(0, fs_1.existsSync)(path))
|
|
@@ -30,12 +42,16 @@ const readPendingUpdate = (root) => {
|
|
|
30
42
|
if (!isRecord(parsed) || !Array.isArray(parsed['packages']))
|
|
31
43
|
return undefined;
|
|
32
44
|
const packages = parsed['packages'].filter((entry) => isRecord(entry) && typeof entry['name'] === 'string' && typeof entry['to'] === 'string');
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
const finished = Array.isArray(parsed['finished'])
|
|
46
|
+
? parsed['finished'].filter((entry) => isRecord(entry) && typeof entry['packageName'] === 'string' && typeof entry['name'] === 'string')
|
|
47
|
+
: [];
|
|
48
|
+
const from = readStringRecord(parsed['from']);
|
|
49
|
+
const commits = readCommits(parsed['commits']);
|
|
50
|
+
return Object.assign(Object.assign({ startedAt: typeof parsed['startedAt'] === 'string' ? parsed['startedAt'] : 'an earlier run', packages: packages.map((entry) => { var _a; return ({ name: entry.name, from: (_a = entry.from) !== null && _a !== void 0 ? _a : null, to: entry.to }); }), finished: finished.map((entry) => ({ packageName: entry.packageName, name: entry.name })) }, (from ? { from } : {})), (commits ? { commits } : {}));
|
|
37
51
|
};
|
|
38
52
|
exports.readPendingUpdate = readPendingUpdate;
|
|
53
|
+
const isFinished = (options) => options.finished.some((entry) => entry.packageName === options.packageName && entry.name === options.name);
|
|
54
|
+
exports.isFinished = isFinished;
|
|
39
55
|
const clearPendingUpdate = (root) => (0, fs_1.rmSync)((0, path_1.join)(root, exports.PENDING_FILE), { force: true });
|
|
40
56
|
exports.clearPendingUpdate = clearPendingUpdate;
|
|
41
57
|
//# sourceMappingURL=pending.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/update/pending.ts"],"names":[],"mappings":";;;AAAA,2BAAgF;AAChF,+BAA4B;
|
|
1
|
+
{"version":3,"file":"pending.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/update/pending.ts"],"names":[],"mappings":";;;AAAA,2BAAgF;AAChF,+BAA4B;AAE5B,mCAAqC;AAExB,QAAA,YAAY,GAAG,IAAA,WAAI,EAAC,kBAAU,EAAE,cAAc,CAAC,CAAC;AAyB7D,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAA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,6 @@
|
|
|
1
|
-
import { DeclaredPackage,
|
|
1
|
+
import { DeclaredPackage, DeclaredSite, RangeWrite } from './packages';
|
|
2
2
|
import { Migration, PackageMigrations } from './migration-manifest';
|
|
3
|
+
import { MigrationRecord } from './migration-record';
|
|
3
4
|
import { RegistryPackage } from './registry';
|
|
4
5
|
export type UpdatedPackage = {
|
|
5
6
|
name: string;
|
|
@@ -8,13 +9,12 @@ export type UpdatedPackage = {
|
|
|
8
9
|
to: string;
|
|
9
10
|
};
|
|
10
11
|
export type PackageUpdate = UpdatedPackage & {
|
|
11
|
-
field: DependencyField;
|
|
12
|
-
/** The range the manifest declares now. */
|
|
13
|
-
declaredRange: string;
|
|
14
12
|
/** The dist tag the target came from, absent when the caller named a version. */
|
|
15
13
|
tag?: string;
|
|
16
|
-
/**
|
|
17
|
-
|
|
14
|
+
/** Every range to rewrite, one per manifest and field that declares the package. */
|
|
15
|
+
writes: RangeWrite[];
|
|
16
|
+
/** The sites whose declared range no single version can be written into. */
|
|
17
|
+
unwritable: DeclaredSite[];
|
|
18
18
|
};
|
|
19
19
|
export type TargetChoice = {
|
|
20
20
|
update: PackageUpdate;
|
|
@@ -35,6 +35,18 @@ export declare const chooseTarget: (options: {
|
|
|
35
35
|
registry: RegistryPackage;
|
|
36
36
|
request?: TargetRequest;
|
|
37
37
|
}) => TargetChoice;
|
|
38
|
+
export type NewerMajor = {
|
|
39
|
+
name: string;
|
|
40
|
+
tag: string;
|
|
41
|
+
version: string;
|
|
42
|
+
};
|
|
43
|
+
export declare const newerMajorOnTag: (options: {
|
|
44
|
+
name: string;
|
|
45
|
+
version: string;
|
|
46
|
+
distTags: Record<string, string>;
|
|
47
|
+
}) => NewerMajor | undefined;
|
|
48
|
+
export declare const MIGRATING_FROM_V4_URL = "https://ethlete-sdk-docs-next.web.app/migrating-from-v4";
|
|
49
|
+
export declare const newerMajorLine: (newer: NewerMajor) => string;
|
|
38
50
|
export declare const isDowngrade: (update: PackageUpdate) => boolean;
|
|
39
51
|
export type PendingMigration = {
|
|
40
52
|
packageName: string;
|
|
@@ -42,11 +54,24 @@ export type PendingMigration = {
|
|
|
42
54
|
/** Where the instructions of this migration live, when it names any. */
|
|
43
55
|
manifestPath?: string;
|
|
44
56
|
};
|
|
45
|
-
/** The migrations of one package that an update from `from` to `to` crosses. */
|
|
57
|
+
/** The required migrations of one package that an update from `from` to `to` crosses. */
|
|
46
58
|
export declare const pendingMigrations: (options: {
|
|
47
59
|
packageMigrations: PackageMigrations;
|
|
48
60
|
from: string;
|
|
49
61
|
to: string;
|
|
50
62
|
}) => PendingMigration[];
|
|
63
|
+
/**
|
|
64
|
+
* The recommended and optional migrations of one package that the installed version has reached and the
|
|
65
|
+
* record holds no run of.
|
|
66
|
+
*/
|
|
67
|
+
export declare const availableMigrations: (options: {
|
|
68
|
+
packageMigrations: PackageMigrations;
|
|
69
|
+
installed: string;
|
|
70
|
+
record: MigrationRecord;
|
|
71
|
+
}) => PendingMigration[];
|
|
72
|
+
/** The sentence that points at the migrations `et update` did not run, or `undefined` when there are none. */
|
|
73
|
+
export declare const availableMigrationsLine: (available: readonly PendingMigration[]) => string | undefined;
|
|
51
74
|
/** Oldest version first, and inside one version the package that others build on first. */
|
|
52
|
-
export declare const orderMigrations: (pending: readonly
|
|
75
|
+
export declare const orderMigrations: <T extends PendingMigration>(pending: readonly T[]) => T[];
|
|
76
|
+
/** Recommended before optional, and inside one level in the order `et update` runs migrations. */
|
|
77
|
+
export declare const orderAvailableMigrations: <T extends PendingMigration>(available: readonly T[]) => T[];
|