@ethlete/cli 2.0.1-next.0 → 2.1.0-next.10
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 +107 -0
- package/README.md +173 -6
- 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 +38 -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 +12 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +96 -10
- package/src/index.js.map +1 -1
- package/src/lib/api/api-command.d.ts +5 -0
- package/src/lib/api/api-command.js +27 -0
- package/src/lib/api/api-command.js.map +1 -0
- package/src/lib/api/auth-hint.d.ts +16 -0
- package/src/lib/api/auth-hint.js +59 -0
- package/src/lib/api/auth-hint.js.map +1 -0
- package/src/lib/api/clear.d.ts +36 -0
- package/src/lib/api/clear.js +121 -0
- package/src/lib/api/clear.js.map +1 -0
- package/src/lib/api/clone.d.ts +12 -0
- package/src/lib/api/clone.js +24 -0
- package/src/lib/api/clone.js.map +1 -0
- package/src/lib/api/compose.d.ts +46 -0
- package/src/lib/api/compose.js +101 -0
- package/src/lib/api/compose.js.map +1 -0
- package/src/lib/api/definition.d.ts +37 -0
- package/src/lib/api/definition.js +33 -0
- package/src/lib/api/definition.js.map +1 -0
- package/src/lib/api/git.d.ts +25 -0
- package/src/lib/api/git.js +71 -0
- package/src/lib/api/git.js.map +1 -0
- package/src/lib/api/help.d.ts +11 -0
- package/src/lib/api/help.js +72 -0
- package/src/lib/api/help.js.map +1 -0
- package/src/lib/api/index.d.ts +15 -0
- package/src/lib/api/index.js +19 -0
- package/src/lib/api/index.js.map +1 -0
- package/src/lib/api/load-definitions.d.ts +16 -0
- package/src/lib/api/load-definitions.js +22 -0
- package/src/lib/api/load-definitions.js.map +1 -0
- package/src/lib/api/ports.d.ts +13 -0
- package/src/lib/api/ports.js +98 -0
- package/src/lib/api/ports.js.map +1 -0
- package/src/lib/api/resolve-checkout.d.ts +45 -0
- package/src/lib/api/resolve-checkout.js +91 -0
- package/src/lib/api/resolve-checkout.js.map +1 -0
- package/src/lib/api/run.d.ts +10 -0
- package/src/lib/api/run.js +332 -0
- package/src/lib/api/run.js.map +1 -0
- package/src/lib/api/setup.d.ts +15 -0
- package/src/lib/api/setup.js +41 -0
- package/src/lib/api/setup.js.map +1 -0
- package/src/lib/api/state.d.ts +20 -0
- package/src/lib/api/state.js +33 -0
- package/src/lib/api/state.js.map +1 -0
- package/src/lib/api/suggest.d.ts +7 -0
- package/src/lib/api/suggest.js +35 -0
- package/src/lib/api/suggest.js.map +1 -0
- package/src/lib/auth/auth-command.d.ts +11 -0
- package/src/lib/auth/auth-command.js +165 -0
- package/src/lib/auth/auth-command.js.map +1 -0
- package/src/lib/auth/composer-auth.d.ts +30 -0
- package/src/lib/auth/composer-auth.js +70 -0
- package/src/lib/auth/composer-auth.js.map +1 -0
- package/src/lib/auth/composer-repositories.d.ts +5 -0
- package/src/lib/auth/composer-repositories.js +33 -0
- package/src/lib/auth/composer-repositories.js.map +1 -0
- package/src/lib/auth/gitlab-token.d.ts +43 -0
- package/src/lib/auth/gitlab-token.js +72 -0
- package/src/lib/auth/gitlab-token.js.map +1 -0
- package/src/lib/auth/index.d.ts +4 -0
- package/src/lib/auth/index.js +8 -0
- package/src/lib/auth/index.js.map +1 -0
- package/src/lib/config/diagnose.d.ts +7 -0
- package/src/lib/config/diagnose.js +112 -0
- package/src/lib/config/diagnose.js.map +1 -0
- package/src/lib/config/index.d.ts +2 -0
- package/src/lib/config/index.js +6 -0
- package/src/lib/config/index.js.map +1 -0
- package/src/lib/config/local-config.d.ts +46 -0
- package/src/lib/config/local-config.js +57 -0
- package/src/lib/config/local-config.js.map +1 -0
- 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 +192 -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/doctor/doctor-command.d.ts +7 -0
- package/src/lib/doctor/doctor-command.js +62 -0
- package/src/lib/doctor/doctor-command.js.map +1 -0
- package/src/lib/doctor/index.d.ts +1 -0
- package/src/lib/doctor/index.js +5 -0
- package/src/lib/doctor/index.js.map +1 -0
- package/src/lib/index.d.ts +7 -0
- package/src/lib/index.js +7 -0
- package/src/lib/index.js.map +1 -1
- package/src/lib/invocation.d.ts +9 -0
- package/src/lib/invocation.js +47 -0
- package/src/lib/invocation.js.map +1 -0
- package/src/lib/release.js +21 -3
- package/src/lib/release.js.map +1 -1
- package/src/lib/update/ai.d.ts +30 -0
- package/src/lib/update/ai.js +44 -0
- package/src/lib/update/ai.js.map +1 -0
- package/src/lib/update/args.d.ts +21 -0
- package/src/lib/update/args.js +89 -0
- package/src/lib/update/args.js.map +1 -0
- package/src/lib/update/index.d.ts +12 -0
- package/src/lib/update/index.js +16 -0
- package/src/lib/update/index.js.map +1 -0
- package/src/lib/update/migration-manifest.d.ts +40 -0
- package/src/lib/update/migration-manifest.js +137 -0
- package/src/lib/update/migration-manifest.js.map +1 -0
- package/src/lib/update/package-manager.d.ts +23 -0
- package/src/lib/update/package-manager.js +47 -0
- package/src/lib/update/package-manager.js.map +1 -0
- package/src/lib/update/packages.d.ts +65 -0
- package/src/lib/update/packages.js +147 -0
- package/src/lib/update/packages.js.map +1 -0
- package/src/lib/update/pending.d.ts +21 -0
- package/src/lib/update/pending.js +41 -0
- package/src/lib/update/pending.js.map +1 -0
- package/src/lib/update/plan.d.ts +51 -0
- package/src/lib/update/plan.js +101 -0
- package/src/lib/update/plan.js.map +1 -0
- package/src/lib/update/registry.d.ts +31 -0
- package/src/lib/update/registry.js +54 -0
- package/src/lib/update/registry.js.map +1 -0
- package/src/lib/update/run-migrations.d.ts +44 -0
- package/src/lib/update/run-migrations.js +73 -0
- package/src/lib/update/run-migrations.js.map +1 -0
- package/src/lib/update/semver.d.ts +19 -0
- package/src/lib/update/semver.js +79 -0
- package/src/lib/update/semver.js.map +1 -0
- package/src/lib/update/tasks.d.ts +58 -0
- package/src/lib/update/tasks.js +174 -0
- package/src/lib/update/tasks.js.map +1 -0
- package/src/lib/update/update-command.d.ts +12 -0
- package/src/lib/update/update-command.js +304 -0
- package/src/lib/update/update-command.js.map +1 -0
- package/src/lib/utils.d.ts +14 -0
- package/src/lib/utils.js +14 -1
- package/src/lib/utils.js.map +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** The `package.json` field a package points at its own migration manifest with. */
|
|
2
|
+
export declare const MIGRATIONS_MANIFEST_KEY = "ethlete";
|
|
3
|
+
export declare const MIGRATION_KINDS: readonly ["auto", "manual", "assisted"];
|
|
4
|
+
export type MigrationKind = (typeof MIGRATION_KINDS)[number];
|
|
5
|
+
export type Migration = {
|
|
6
|
+
/** Unique inside its package, and stable: it names the migration in every report. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** The version the change landed in. The migration is pending for an update that crosses it. */
|
|
9
|
+
version: string;
|
|
10
|
+
kind: MigrationKind;
|
|
11
|
+
description: string;
|
|
12
|
+
/** `auto` only: the Nx generator that rewrites the code, as `@ethlete/core:migrate-x`. */
|
|
13
|
+
generator?: string;
|
|
14
|
+
/** `auto` only: flags handed to the generator, for example `{ skipFormat: true }`. */
|
|
15
|
+
options?: Record<string, string | number | boolean>;
|
|
16
|
+
/** Markdown next to the manifest: the recommendation for `manual`, the prompt for `assisted`. */
|
|
17
|
+
instructions?: string;
|
|
18
|
+
/** Path on the docs site, for example `/components/button`. */
|
|
19
|
+
docs?: string;
|
|
20
|
+
};
|
|
21
|
+
export type PackageMigrations = {
|
|
22
|
+
packageName: string;
|
|
23
|
+
migrations: Migration[];
|
|
24
|
+
/** Where the manifest was read from, so an instructions path can be resolved against it. */
|
|
25
|
+
manifestPath?: string;
|
|
26
|
+
problems: string[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The migrations an installed package ships, read from the manifest its `package.json` points at.
|
|
30
|
+
* A package that declares none is not a problem — most versions need no migration.
|
|
31
|
+
*/
|
|
32
|
+
export declare const readPackageMigrations: (options: {
|
|
33
|
+
root: string;
|
|
34
|
+
packageName: string;
|
|
35
|
+
}) => PackageMigrations;
|
|
36
|
+
/** The absolute path of a migration's instructions file, or `undefined` when it names none. */
|
|
37
|
+
export declare const instructionsPath: (options: {
|
|
38
|
+
manifestPath?: string;
|
|
39
|
+
migration: Migration;
|
|
40
|
+
}) => string | undefined;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.instructionsPath = exports.readPackageMigrations = exports.MIGRATION_KINDS = exports.MIGRATIONS_MANIFEST_KEY = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const semver_1 = require("./semver");
|
|
7
|
+
/** The `package.json` field a package points at its own migration manifest with. */
|
|
8
|
+
exports.MIGRATIONS_MANIFEST_KEY = 'ethlete';
|
|
9
|
+
exports.MIGRATION_KINDS = ['auto', 'manual', 'assisted'];
|
|
10
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
11
|
+
const readJson = (path) => {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
|
|
14
|
+
}
|
|
15
|
+
catch (_a) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const readString = (record, key) => {
|
|
20
|
+
const value = record[key];
|
|
21
|
+
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
22
|
+
};
|
|
23
|
+
const readOptions = (value) => {
|
|
24
|
+
if (!isRecord(value))
|
|
25
|
+
return undefined;
|
|
26
|
+
const options = {};
|
|
27
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
28
|
+
if (typeof entry === 'string' || typeof entry === 'number' || typeof entry === 'boolean')
|
|
29
|
+
options[key] = entry;
|
|
30
|
+
}
|
|
31
|
+
return options;
|
|
32
|
+
};
|
|
33
|
+
const parseEntry = (options) => {
|
|
34
|
+
const { value, origin, index } = options;
|
|
35
|
+
const at = `${origin} entry ${index}`;
|
|
36
|
+
if (!isRecord(value))
|
|
37
|
+
return { problem: `${at} is not an object.` };
|
|
38
|
+
const name = readString(value, 'name');
|
|
39
|
+
const version = readString(value, 'version');
|
|
40
|
+
const kind = readString(value, 'kind');
|
|
41
|
+
const description = readString(value, 'description');
|
|
42
|
+
if (!name)
|
|
43
|
+
return { problem: `${at} has no "name".` };
|
|
44
|
+
if (!version)
|
|
45
|
+
return { problem: `${origin} "${name}" has no "version".` };
|
|
46
|
+
if (!(0, semver_1.isValidVersion)(version))
|
|
47
|
+
return { problem: `${origin} "${name}" has an invalid version "${version}".` };
|
|
48
|
+
if (!kind)
|
|
49
|
+
return { problem: `${origin} "${name}" has no "kind".` };
|
|
50
|
+
if (!exports.MIGRATION_KINDS.includes(kind)) {
|
|
51
|
+
return { problem: `${origin} "${name}" has kind "${kind}" — use one of ${exports.MIGRATION_KINDS.join(', ')}.` };
|
|
52
|
+
}
|
|
53
|
+
if (!description)
|
|
54
|
+
return { problem: `${origin} "${name}" has no "description".` };
|
|
55
|
+
const generator = readString(value, 'generator');
|
|
56
|
+
const instructions = readString(value, 'instructions');
|
|
57
|
+
if (kind === 'auto' && !generator)
|
|
58
|
+
return { problem: `${origin} "${name}" is auto but names no "generator".` };
|
|
59
|
+
if (kind === 'assisted' && !instructions) {
|
|
60
|
+
return { problem: `${origin} "${name}" is assisted but names no "instructions" file.` };
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
migration: {
|
|
64
|
+
name,
|
|
65
|
+
version,
|
|
66
|
+
kind: kind,
|
|
67
|
+
description,
|
|
68
|
+
generator,
|
|
69
|
+
options: readOptions(value['options']),
|
|
70
|
+
instructions,
|
|
71
|
+
docs: readString(value, 'docs'),
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const parseManifest = (options) => {
|
|
76
|
+
const { source, origin, packageName } = options;
|
|
77
|
+
if (!isRecord(source))
|
|
78
|
+
return { packageName, migrations: [], problems: [`${origin} is not a JSON object.`] };
|
|
79
|
+
const entries = source['migrations'];
|
|
80
|
+
if (!Array.isArray(entries))
|
|
81
|
+
return { packageName, migrations: [], problems: [`${origin} has no "migrations" array.`] };
|
|
82
|
+
const migrations = [];
|
|
83
|
+
const problems = [];
|
|
84
|
+
const seen = new Set();
|
|
85
|
+
entries.forEach((value, index) => {
|
|
86
|
+
const parsed = parseEntry({ value, origin, index });
|
|
87
|
+
if (parsed.problem !== undefined) {
|
|
88
|
+
problems.push(parsed.problem);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const { migration } = parsed;
|
|
92
|
+
if (seen.has(migration.name)) {
|
|
93
|
+
problems.push(`${origin} declares "${migration.name}" twice.`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
seen.add(migration.name);
|
|
97
|
+
migrations.push(migration);
|
|
98
|
+
});
|
|
99
|
+
return { packageName, migrations, problems };
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* The migrations an installed package ships, read from the manifest its `package.json` points at.
|
|
103
|
+
* A package that declares none is not a problem — most versions need no migration.
|
|
104
|
+
*/
|
|
105
|
+
const readPackageMigrations = (options) => {
|
|
106
|
+
const { root, packageName } = options;
|
|
107
|
+
const packageJsonPath = (0, path_1.join)(root, 'node_modules', ...packageName.split('/'), 'package.json');
|
|
108
|
+
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
109
|
+
return { packageName, migrations: [], problems: [`${packageName} is not installed.`] };
|
|
110
|
+
}
|
|
111
|
+
const packageJson = readJson(packageJsonPath);
|
|
112
|
+
const field = isRecord(packageJson) ? packageJson[exports.MIGRATIONS_MANIFEST_KEY] : undefined;
|
|
113
|
+
const declared = isRecord(field) ? field['migrations'] : undefined;
|
|
114
|
+
if (typeof declared !== 'string')
|
|
115
|
+
return { packageName, migrations: [], problems: [] };
|
|
116
|
+
const manifestPath = (0, path_1.resolve)((0, path_1.dirname)(packageJsonPath), declared);
|
|
117
|
+
if (!(0, fs_1.existsSync)(manifestPath)) {
|
|
118
|
+
return {
|
|
119
|
+
packageName,
|
|
120
|
+
migrations: [],
|
|
121
|
+
problems: [`${packageName} points "${exports.MIGRATIONS_MANIFEST_KEY}.migrations" at ${manifestPath}, which is missing.`],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return Object.assign(Object.assign({}, parseManifest({ source: readJson(manifestPath), origin: `${packageName} migrations.json`, packageName })), { manifestPath });
|
|
125
|
+
};
|
|
126
|
+
exports.readPackageMigrations = readPackageMigrations;
|
|
127
|
+
/** The absolute path of a migration's instructions file, or `undefined` when it names none. */
|
|
128
|
+
const instructionsPath = (options) => {
|
|
129
|
+
const { manifestPath, migration } = options;
|
|
130
|
+
if (!migration.instructions)
|
|
131
|
+
return undefined;
|
|
132
|
+
if ((0, path_1.isAbsolute)(migration.instructions))
|
|
133
|
+
return migration.instructions;
|
|
134
|
+
return manifestPath ? (0, path_1.resolve)((0, path_1.dirname)(manifestPath), migration.instructions) : undefined;
|
|
135
|
+
};
|
|
136
|
+
exports.instructionsPath = instructionsPath;
|
|
137
|
+
//# sourceMappingURL=migration-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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EAAE;IAC3F,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE5C,IAAI,CAAC,SAAS,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IAE9C,IAAI,IAAA,iBAAU,EAAC,SAAS,CAAC,YAAY,CAAC;QAAE,OAAO,SAAS,CAAC,YAAY,CAAC;IAEtE,OAAO,YAAY,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,YAAY,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3F,CAAC,CAAC;AARW,QAAA,gBAAgB,oBAQ3B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Manifest } from './packages';
|
|
2
|
+
export type PackageManagerName = 'yarn' | 'pnpm' | 'bun' | 'npm';
|
|
3
|
+
export type PackageManager = {
|
|
4
|
+
name: PackageManagerName;
|
|
5
|
+
/** The command that installs what `package.json` declares. */
|
|
6
|
+
install: string[];
|
|
7
|
+
/** How this manager runs a binary from `node_modules`, for example `yarn nx`. */
|
|
8
|
+
run: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The package manager this repo uses: what `packageManager` declares, else the lockfile that is there,
|
|
12
|
+
* else npm. `et update` runs the install itself, so it has to be the same one the repo already uses.
|
|
13
|
+
*/
|
|
14
|
+
export declare const detectPackageManager: (options: {
|
|
15
|
+
root: string;
|
|
16
|
+
manifest?: Manifest;
|
|
17
|
+
env?: NodeJS.ProcessEnv;
|
|
18
|
+
}) => PackageManager;
|
|
19
|
+
/** The command that runs an `nx` from this repo, for example `yarn nx generate …`. */
|
|
20
|
+
export declare const nxCommand: (options: {
|
|
21
|
+
manager: PackageManager;
|
|
22
|
+
args: readonly string[];
|
|
23
|
+
}) => string[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nxCommand = exports.detectPackageManager = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const MANAGERS = {
|
|
7
|
+
yarn: { name: 'yarn', install: ['yarn', 'install'], run: ['yarn'] },
|
|
8
|
+
pnpm: { name: 'pnpm', install: ['pnpm', 'install'], run: ['pnpm', 'exec'] },
|
|
9
|
+
bun: { name: 'bun', install: ['bun', 'install'], run: ['bunx'] },
|
|
10
|
+
npm: { name: 'npm', install: ['npm', 'install'], run: ['npx'] },
|
|
11
|
+
};
|
|
12
|
+
const LOCKFILES = [
|
|
13
|
+
['yarn.lock', 'yarn'],
|
|
14
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
15
|
+
['bun.lockb', 'bun'],
|
|
16
|
+
['bun.lock', 'bun'],
|
|
17
|
+
['package-lock.json', 'npm'],
|
|
18
|
+
];
|
|
19
|
+
const declaredName = (manifest, userAgent) => {
|
|
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
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 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 the same one the repo already uses.
|
|
29
|
+
*/
|
|
30
|
+
const detectPackageManager = (options) => {
|
|
31
|
+
var _a;
|
|
32
|
+
const { root, manifest, env = process.env } = options;
|
|
33
|
+
const declared = declaredName(manifest, env['npm_config_user_agent']);
|
|
34
|
+
if (declared)
|
|
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'];
|
|
38
|
+
};
|
|
39
|
+
exports.detectPackageManager = detectPackageManager;
|
|
40
|
+
/** The command that runs an `nx` from this repo, for example `yarn nx generate …`. */
|
|
41
|
+
const nxCommand = (options) => [
|
|
42
|
+
...options.manager.run,
|
|
43
|
+
'nx',
|
|
44
|
+
...options.args,
|
|
45
|
+
];
|
|
46
|
+
exports.nxCommand = nxCommand;
|
|
47
|
+
//# sourceMappingURL=package-manager.js.map
|
|
@@ -0,0 +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,C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0,0 +1,65 @@
|
|
|
1
|
+
export declare const ETHLETE_SCOPE = "@ethlete/";
|
|
2
|
+
export declare const ROOT_MANIFEST = "package.json";
|
|
3
|
+
export declare const DEPENDENCY_FIELDS: readonly ["dependencies", "devDependencies", "peerDependencies"];
|
|
4
|
+
export type DependencyField = (typeof DEPENDENCY_FIELDS)[number];
|
|
5
|
+
export type Manifest = Partial<Record<DependencyField, Record<string, string>>> & {
|
|
6
|
+
packageManager?: string;
|
|
7
|
+
};
|
|
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;
|
|
12
|
+
field: DependencyField;
|
|
13
|
+
range: string;
|
|
14
|
+
/** The version the range points at, or `undefined` for a range no single version can be read from. */
|
|
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[];
|
|
21
|
+
/** The version in `node_modules`, which is what the migrations of an update run against. */
|
|
22
|
+
installedVersion?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const manifestPath: (root: string) => string;
|
|
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[];
|
|
31
|
+
/** The version of `packageName` in `node_modules`, which is the one the running code came from. */
|
|
32
|
+
export declare const installedVersion: (root: string, packageName: string) => string | undefined;
|
|
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. */
|
|
39
|
+
export declare const declaredEthletePackages: (options: {
|
|
40
|
+
root: string;
|
|
41
|
+
manifests?: readonly string[];
|
|
42
|
+
}) => DeclaredPackage[];
|
|
43
|
+
export type RangeWrite = {
|
|
44
|
+
name: string;
|
|
45
|
+
manifestPath: string;
|
|
46
|
+
field: DependencyField;
|
|
47
|
+
range: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
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.
|
|
53
|
+
*/
|
|
54
|
+
export declare const writeRanges: (options: {
|
|
55
|
+
root: string;
|
|
56
|
+
writes: readonly RangeWrite[];
|
|
57
|
+
}) => string[];
|
|
58
|
+
/**
|
|
59
|
+
* The range that carries `version` while keeping how the declared one was written, for example `^`.
|
|
60
|
+
* `undefined` for a range this cannot rewrite safely, such as `workspace:*` or `>=5 <6`.
|
|
61
|
+
*/
|
|
62
|
+
export declare const rangeFor: (options: {
|
|
63
|
+
current: string;
|
|
64
|
+
version: string;
|
|
65
|
+
}) => string | undefined;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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 fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const semver_1 = require("./semver");
|
|
7
|
+
exports.ETHLETE_SCOPE = '@ethlete/';
|
|
8
|
+
exports.ROOT_MANIFEST = 'package.json';
|
|
9
|
+
exports.DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies'];
|
|
10
|
+
const SKIPPED_DIRECTORIES = new Set(['coverage', 'dist', 'node_modules', 'tmp']);
|
|
11
|
+
const readJson = (path) => {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
|
|
14
|
+
}
|
|
15
|
+
catch (_a) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
20
|
+
const manifestPath = (root) => (0, path_1.join)(root, exports.ROOT_MANIFEST);
|
|
21
|
+
exports.manifestPath = manifestPath;
|
|
22
|
+
const readManifest = (root, relativePath = exports.ROOT_MANIFEST) => {
|
|
23
|
+
const parsed = readJson((0, path_1.join)(root, relativePath));
|
|
24
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
25
|
+
};
|
|
26
|
+
exports.readManifest = readManifest;
|
|
27
|
+
/**
|
|
28
|
+
* Every `package.json` in the repo, root first. An Nx repo keeps a manifest per buildable library, and
|
|
29
|
+
* those pin `@ethlete/*` too, so an update that only rewrites the root leaves the rest behind.
|
|
30
|
+
*/
|
|
31
|
+
const findManifests = (root) => {
|
|
32
|
+
const found = [];
|
|
33
|
+
const walk = (directory) => {
|
|
34
|
+
let entries;
|
|
35
|
+
try {
|
|
36
|
+
entries = (0, fs_1.readdirSync)(directory, { withFileTypes: true });
|
|
37
|
+
}
|
|
38
|
+
catch (_a) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
if (entry.isDirectory()) {
|
|
43
|
+
if (entry.name.startsWith('.') || SKIPPED_DIRECTORIES.has(entry.name))
|
|
44
|
+
continue;
|
|
45
|
+
walk((0, path_1.join)(directory, entry.name));
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (entry.name !== exports.ROOT_MANIFEST)
|
|
49
|
+
continue;
|
|
50
|
+
found.push((0, path_1.relative)(root, (0, path_1.join)(directory, entry.name)).split(path_1.sep).join('/'));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
walk(root);
|
|
54
|
+
return found.sort((left, right) => {
|
|
55
|
+
if (left === exports.ROOT_MANIFEST)
|
|
56
|
+
return -1;
|
|
57
|
+
if (right === exports.ROOT_MANIFEST)
|
|
58
|
+
return 1;
|
|
59
|
+
return left.localeCompare(right);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.findManifests = findManifests;
|
|
63
|
+
/** The version of `packageName` in `node_modules`, which is the one the running code came from. */
|
|
64
|
+
const installedVersion = (root, packageName) => {
|
|
65
|
+
const path = (0, path_1.join)(root, 'node_modules', ...packageName.split('/'), exports.ROOT_MANIFEST);
|
|
66
|
+
if (!(0, fs_1.existsSync)(path))
|
|
67
|
+
return undefined;
|
|
68
|
+
const parsed = readJson(path);
|
|
69
|
+
return isRecord(parsed) && typeof parsed['version'] === 'string' ? parsed['version'] : undefined;
|
|
70
|
+
};
|
|
71
|
+
exports.installedVersion = installedVersion;
|
|
72
|
+
/**
|
|
73
|
+
* The version an update starts from when nothing is installed: the newest one any manifest declares, so
|
|
74
|
+
* a library manifest that lags behind the root does not read as the current version.
|
|
75
|
+
*/
|
|
76
|
+
const newestDeclaredVersion = (sites) => sites.reduce((newest, site) => {
|
|
77
|
+
if (site.declaredVersion === undefined)
|
|
78
|
+
return newest;
|
|
79
|
+
return newest === undefined || (0, semver_1.compareVersions)(site.declaredVersion, newest) > 0 ? site.declaredVersion : newest;
|
|
80
|
+
}, undefined);
|
|
81
|
+
exports.newestDeclaredVersion = newestDeclaredVersion;
|
|
82
|
+
/** Every `@ethlete/*` dependency the repo declares, gathered across all of its manifests. */
|
|
83
|
+
const declaredEthletePackages = (options) => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
const { root, manifests = (0, exports.findManifests)(root) } = options;
|
|
86
|
+
const byName = new Map();
|
|
87
|
+
for (const relativePath of manifests) {
|
|
88
|
+
const manifest = (0, exports.readManifest)(root, relativePath);
|
|
89
|
+
if (!manifest)
|
|
90
|
+
continue;
|
|
91
|
+
for (const field of exports.DEPENDENCY_FIELDS) {
|
|
92
|
+
for (const [name, range] of Object.entries((_a = manifest[field]) !== null && _a !== void 0 ? _a : {})) {
|
|
93
|
+
if (!name.startsWith(exports.ETHLETE_SCOPE))
|
|
94
|
+
continue;
|
|
95
|
+
const entry = (_b = byName.get(name)) !== null && _b !== void 0 ? _b : {
|
|
96
|
+
name,
|
|
97
|
+
sites: [],
|
|
98
|
+
installedVersion: (0, exports.installedVersion)(root, name),
|
|
99
|
+
};
|
|
100
|
+
entry.sites.push({ manifestPath: relativePath, field, range, declaredVersion: (0, semver_1.versionOfRange)(range) });
|
|
101
|
+
byName.set(name, entry);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return [...byName.values()];
|
|
106
|
+
};
|
|
107
|
+
exports.declaredEthletePackages = declaredEthletePackages;
|
|
108
|
+
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 : ' '; };
|
|
109
|
+
/**
|
|
110
|
+
* Writes new ranges into the manifests they came from, keeping each file's indentation. A whole file is
|
|
111
|
+
* re-serialised, so a comment or a key order the parser cannot represent would not survive -
|
|
112
|
+
* `package.json` holds neither.
|
|
113
|
+
*/
|
|
114
|
+
const writeRanges = (options) => {
|
|
115
|
+
const { root, writes } = options;
|
|
116
|
+
const written = [];
|
|
117
|
+
for (const relativePath of new Set(writes.map((write) => write.manifestPath))) {
|
|
118
|
+
const path = (0, path_1.join)(root, relativePath);
|
|
119
|
+
const source = (0, fs_1.readFileSync)(path, 'utf8');
|
|
120
|
+
const parsed = JSON.parse(source);
|
|
121
|
+
if (!isRecord(parsed))
|
|
122
|
+
throw new Error(`${path} is not a JSON object.`);
|
|
123
|
+
for (const write of writes.filter((candidate) => candidate.manifestPath === relativePath)) {
|
|
124
|
+
const field = parsed[write.field];
|
|
125
|
+
if (!isRecord(field))
|
|
126
|
+
continue;
|
|
127
|
+
field[write.name] = write.range;
|
|
128
|
+
}
|
|
129
|
+
const indent = detectIndent(source);
|
|
130
|
+
const trailingNewline = source.endsWith('\n') ? '\n' : '';
|
|
131
|
+
(0, fs_1.writeFileSync)(path, `${JSON.stringify(parsed, null, indent)}${trailingNewline}`, 'utf8');
|
|
132
|
+
written.push(relativePath);
|
|
133
|
+
}
|
|
134
|
+
return written;
|
|
135
|
+
};
|
|
136
|
+
exports.writeRanges = writeRanges;
|
|
137
|
+
/**
|
|
138
|
+
* The range that carries `version` while keeping how the declared one was written, for example `^`.
|
|
139
|
+
* `undefined` for a range this cannot rewrite safely, such as `workspace:*` or `>=5 <6`.
|
|
140
|
+
*/
|
|
141
|
+
const rangeFor = (options) => {
|
|
142
|
+
const { current, version } = options;
|
|
143
|
+
const prefix = (0, semver_1.rangePrefix)(current);
|
|
144
|
+
return prefix === undefined ? undefined : `${prefix}${version}`;
|
|
145
|
+
};
|
|
146
|
+
exports.rangeFor = rangeFor;
|
|
147
|
+
//# sourceMappingURL=packages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packages.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/update/packages.ts"],"names":[],"mappings":";;;AAAA,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,QA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,EAAE,CAAC;AAClE,CAAC,CAAC;AALW,QAAA,QAAQ,YAKnB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const PENDING_FILE: string;
|
|
2
|
+
export type PendingPackage = {
|
|
3
|
+
name: string;
|
|
4
|
+
/** The version that was installed before the update, which the migrations run from. */
|
|
5
|
+
from: string | null;
|
|
6
|
+
to: string;
|
|
7
|
+
};
|
|
8
|
+
export type PendingUpdate = {
|
|
9
|
+
startedAt: string;
|
|
10
|
+
packages: PendingPackage[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Records what an update moved, before the install replaces the versions the migrations run from. An
|
|
14
|
+
* install or a codemod that fails leaves this file behind, so `et update --continue` can pick it up.
|
|
15
|
+
*/
|
|
16
|
+
export declare const writePendingUpdate: (options: {
|
|
17
|
+
root: string;
|
|
18
|
+
pending: PendingUpdate;
|
|
19
|
+
}) => void;
|
|
20
|
+
export declare const readPendingUpdate: (root: string) => PendingUpdate | undefined;
|
|
21
|
+
export declare const clearPendingUpdate: (root: string) => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearPendingUpdate = exports.readPendingUpdate = exports.writePendingUpdate = exports.PENDING_FILE = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const tasks_1 = require("./tasks");
|
|
7
|
+
exports.PENDING_FILE = (0, path_1.join)(tasks_1.UPDATE_DIR, 'pending.json');
|
|
8
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
+
/**
|
|
10
|
+
* Records what an update moved, before the install replaces the versions the migrations run from. An
|
|
11
|
+
* install or a codemod that fails leaves this file behind, so `et update --continue` can pick it up.
|
|
12
|
+
*/
|
|
13
|
+
const writePendingUpdate = (options) => {
|
|
14
|
+
const { root, pending } = options;
|
|
15
|
+
(0, fs_1.mkdirSync)((0, path_1.join)(root, tasks_1.UPDATE_DIR), { recursive: true });
|
|
16
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(root, exports.PENDING_FILE), `${JSON.stringify(pending, null, 2)}\n`, 'utf8');
|
|
17
|
+
};
|
|
18
|
+
exports.writePendingUpdate = writePendingUpdate;
|
|
19
|
+
const readPendingUpdate = (root) => {
|
|
20
|
+
const path = (0, path_1.join)(root, exports.PENDING_FILE);
|
|
21
|
+
if (!(0, fs_1.existsSync)(path))
|
|
22
|
+
return undefined;
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
|
|
26
|
+
}
|
|
27
|
+
catch (_a) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
if (!isRecord(parsed) || !Array.isArray(parsed['packages']))
|
|
31
|
+
return undefined;
|
|
32
|
+
const packages = parsed['packages'].filter((entry) => isRecord(entry) && typeof entry['name'] === 'string' && typeof entry['to'] === 'string');
|
|
33
|
+
return {
|
|
34
|
+
startedAt: typeof parsed['startedAt'] === 'string' ? parsed['startedAt'] : 'an earlier run',
|
|
35
|
+
packages: packages.map((entry) => { var _a; return ({ name: entry.name, from: (_a = entry.from) !== null && _a !== void 0 ? _a : null, to: entry.to }); }),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
exports.readPendingUpdate = readPendingUpdate;
|
|
39
|
+
const clearPendingUpdate = (root) => (0, fs_1.rmSync)((0, path_1.join)(root, exports.PENDING_FILE), { force: true });
|
|
40
|
+
exports.clearPendingUpdate = clearPendingUpdate;
|
|
41
|
+
//# sourceMappingURL=pending.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/update/pending.ts"],"names":[],"mappings":";;;AAAA,2BAAgF;AAChF,+BAA4B;AAC5B,mCAAqC;AAExB,QAAA,YAAY,GAAG,IAAA,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,CAAC,UAAU,CAAC,CAAC,MAAM,CACxC,CAAC,KAAK,EAA2B,EAAE,CACjC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,QAAQ,CAC1F,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,gBAAgB;QAC3F,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,MAAA,KAAK,CAAC,IAAI,mCAAI,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA,EAAA,CAAC;KAClG,CAAC;AACJ,CAAC,CAAC;AAxBW,QAAA,iBAAiB,qBAwB5B;AAEK,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,WAAM,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,oBAAY,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAAzF,QAAA,kBAAkB,sBAAuE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DeclaredPackage, DeclaredSite, RangeWrite } from './packages';
|
|
2
|
+
import { Migration, PackageMigrations } from './migration-manifest';
|
|
3
|
+
import { RegistryPackage } from './registry';
|
|
4
|
+
export type UpdatedPackage = {
|
|
5
|
+
name: string;
|
|
6
|
+
/** The installed version the migrations run from, or `undefined` when nothing is installed. */
|
|
7
|
+
from?: string;
|
|
8
|
+
to: string;
|
|
9
|
+
};
|
|
10
|
+
export type PackageUpdate = UpdatedPackage & {
|
|
11
|
+
/** The dist tag the target came from, absent when the caller named a version. */
|
|
12
|
+
tag?: string;
|
|
13
|
+
/** Every range to rewrite, one per manifest and field that declares the package. */
|
|
14
|
+
writes: RangeWrite[];
|
|
15
|
+
/** The sites whose declared range no single version can be written into. */
|
|
16
|
+
unwritable: DeclaredSite[];
|
|
17
|
+
};
|
|
18
|
+
export type TargetChoice = {
|
|
19
|
+
update: PackageUpdate;
|
|
20
|
+
} | {
|
|
21
|
+
problem: string;
|
|
22
|
+
} | {
|
|
23
|
+
upToDate: true;
|
|
24
|
+
};
|
|
25
|
+
export type TargetRequest = {
|
|
26
|
+
/** A version the caller named with `--to`. */
|
|
27
|
+
version?: string;
|
|
28
|
+
/** A dist tag the caller named with `--tag`. */
|
|
29
|
+
tag?: string;
|
|
30
|
+
};
|
|
31
|
+
/** The version an update moves a package to, from the registry's dist tags or the caller's request. */
|
|
32
|
+
export declare const chooseTarget: (options: {
|
|
33
|
+
declared: DeclaredPackage;
|
|
34
|
+
registry: RegistryPackage;
|
|
35
|
+
request?: TargetRequest;
|
|
36
|
+
}) => TargetChoice;
|
|
37
|
+
export declare const isDowngrade: (update: PackageUpdate) => boolean;
|
|
38
|
+
export type PendingMigration = {
|
|
39
|
+
packageName: string;
|
|
40
|
+
migration: Migration;
|
|
41
|
+
/** Where the instructions of this migration live, when it names any. */
|
|
42
|
+
manifestPath?: string;
|
|
43
|
+
};
|
|
44
|
+
/** The migrations of one package that an update from `from` to `to` crosses. */
|
|
45
|
+
export declare const pendingMigrations: (options: {
|
|
46
|
+
packageMigrations: PackageMigrations;
|
|
47
|
+
from: string;
|
|
48
|
+
to: string;
|
|
49
|
+
}) => PendingMigration[];
|
|
50
|
+
/** Oldest version first, and inside one version the package that others build on first. */
|
|
51
|
+
export declare const orderMigrations: (pending: readonly PendingMigration[]) => PendingMigration[];
|