@ethlete/cli 2.1.0-next.7 → 2.1.0-next.8
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 +9 -0
- package/README.md +35 -0
- package/package.json +1 -1
- package/src/index.js +11 -0
- package/src/index.js.map +1 -1
- package/src/lib/config/diagnose.js +9 -0
- package/src/lib/config/diagnose.js.map +1 -1
- package/src/lib/config/local-config.d.ts +2 -0
- package/src/lib/config/local-config.js +6 -1
- package/src/lib/config/local-config.js.map +1 -1
- package/src/lib/doctor/doctor-command.d.ts +3 -1
- package/src/lib/doctor/doctor-command.js +5 -5
- 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/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 +45 -0
- package/src/lib/update/packages.js +88 -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 +52 -0
- package/src/lib/update/plan.js +83 -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 +299 -0
- package/src/lib/update/update-command.js.map +1 -0
|
@@ -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":"migration-manifest.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/update/migration-manifest.ts"],"names":[],"mappings":";;;AAAA,2BAA8C;AAC9C,+BAA0D;AAC1D,qCAA0C;AAE1C,oFAAoF;AACvE,QAAA,uBAAuB,GAAG,SAAS,CAAC;AAEpC,QAAA,eAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC;AA6BvE,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,K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AY,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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CAAC;QAC3F,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AAEF;;;GAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,OAIpC,EAAkB,EAAE;;IACnB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;IACtD,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAEtE,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAExC,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE/E,OAAO,QAAQ,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,CAAC,CAAC,mCAAI,KAAK,CAAC,CAAC;AACvC,CAAC,CAAC;AAbW,QAAA,oBAAoB,wBAa/B;AAEF,sFAAsF;AAC/E,MAAM,SAAS,GAAG,CAAC,OAA6D,EAAE,EAAE,CAAC;IAC1F,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG;IACtB,IAAI;IACJ,GAAG,OAAO,CAAC,IAAI;CAChB,CAAC;AAJW,QAAA,SAAS,aAIpB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare const ETHLETE_SCOPE = "@ethlete/";
|
|
2
|
+
export declare const DEPENDENCY_FIELDS: readonly ["dependencies", "devDependencies", "peerDependencies"];
|
|
3
|
+
export type DependencyField = (typeof DEPENDENCY_FIELDS)[number];
|
|
4
|
+
export type Manifest = Partial<Record<DependencyField, Record<string, string>>> & {
|
|
5
|
+
packageManager?: string;
|
|
6
|
+
};
|
|
7
|
+
export type DeclaredPackage = {
|
|
8
|
+
name: string;
|
|
9
|
+
field: DependencyField;
|
|
10
|
+
range: string;
|
|
11
|
+
/** The version the range points at, or `undefined` for a range no single version can be read from. */
|
|
12
|
+
declaredVersion?: string;
|
|
13
|
+
/** The version in `node_modules`, which is what the migrations of an update run against. */
|
|
14
|
+
installedVersion?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const manifestPath: (root: string) => string;
|
|
17
|
+
export declare const readManifest: (root: string) => Manifest | undefined;
|
|
18
|
+
/** The version of `packageName` in `node_modules`, which is the one the running code came from. */
|
|
19
|
+
export declare const installedVersion: (root: string, packageName: string) => string | undefined;
|
|
20
|
+
/** Every `@ethlete/*` dependency the manifest declares, with the version behind its range. */
|
|
21
|
+
export declare const declaredEthletePackages: (options: {
|
|
22
|
+
root: string;
|
|
23
|
+
manifest: Manifest;
|
|
24
|
+
}) => DeclaredPackage[];
|
|
25
|
+
export type RangeWrite = {
|
|
26
|
+
name: string;
|
|
27
|
+
field: DependencyField;
|
|
28
|
+
range: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Writes new ranges into the manifest, keeping its indentation. The whole file is re-serialised, so a
|
|
32
|
+
* comment or a key order the parser cannot represent would not survive - `package.json` holds neither.
|
|
33
|
+
*/
|
|
34
|
+
export declare const writeRanges: (options: {
|
|
35
|
+
root: string;
|
|
36
|
+
writes: readonly RangeWrite[];
|
|
37
|
+
}) => void;
|
|
38
|
+
/**
|
|
39
|
+
* The range that carries `version` while keeping how the declared one was written, for example `^`.
|
|
40
|
+
* `undefined` for a range this cannot rewrite safely, such as `workspace:*` or `>=5 <6`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const rangeFor: (options: {
|
|
43
|
+
current: string;
|
|
44
|
+
version: string;
|
|
45
|
+
}) => string | undefined;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
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;
|
|
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.DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies'];
|
|
9
|
+
const readJson = (path) => {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
|
|
12
|
+
}
|
|
13
|
+
catch (_a) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
18
|
+
const manifestPath = (root) => (0, path_1.join)(root, 'package.json');
|
|
19
|
+
exports.manifestPath = manifestPath;
|
|
20
|
+
const readManifest = (root) => {
|
|
21
|
+
const parsed = readJson((0, exports.manifestPath)(root));
|
|
22
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
23
|
+
};
|
|
24
|
+
exports.readManifest = readManifest;
|
|
25
|
+
/** The version of `packageName` in `node_modules`, which is the one the running code came from. */
|
|
26
|
+
const installedVersion = (root, packageName) => {
|
|
27
|
+
const path = (0, path_1.join)(root, 'node_modules', ...packageName.split('/'), 'package.json');
|
|
28
|
+
if (!(0, fs_1.existsSync)(path))
|
|
29
|
+
return undefined;
|
|
30
|
+
const parsed = readJson(path);
|
|
31
|
+
return isRecord(parsed) && typeof parsed['version'] === 'string' ? parsed['version'] : undefined;
|
|
32
|
+
};
|
|
33
|
+
exports.installedVersion = installedVersion;
|
|
34
|
+
/** Every `@ethlete/*` dependency the manifest declares, with the version behind its range. */
|
|
35
|
+
const declaredEthletePackages = (options) => {
|
|
36
|
+
var _a;
|
|
37
|
+
const { root, manifest } = options;
|
|
38
|
+
const declared = [];
|
|
39
|
+
for (const field of exports.DEPENDENCY_FIELDS) {
|
|
40
|
+
for (const [name, range] of Object.entries((_a = manifest[field]) !== null && _a !== void 0 ? _a : {})) {
|
|
41
|
+
if (!name.startsWith(exports.ETHLETE_SCOPE))
|
|
42
|
+
continue;
|
|
43
|
+
declared.push({
|
|
44
|
+
name,
|
|
45
|
+
field,
|
|
46
|
+
range,
|
|
47
|
+
declaredVersion: (0, semver_1.versionOfRange)(range),
|
|
48
|
+
installedVersion: (0, exports.installedVersion)(root, name),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return declared;
|
|
53
|
+
};
|
|
54
|
+
exports.declaredEthletePackages = declaredEthletePackages;
|
|
55
|
+
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
|
+
/**
|
|
57
|
+
* Writes new ranges into the manifest, keeping its indentation. The whole file is re-serialised, so a
|
|
58
|
+
* comment or a key order the parser cannot represent would not survive - `package.json` holds neither.
|
|
59
|
+
*/
|
|
60
|
+
const writeRanges = (options) => {
|
|
61
|
+
const { root, writes } = options;
|
|
62
|
+
const path = (0, exports.manifestPath)(root);
|
|
63
|
+
const source = (0, fs_1.readFileSync)(path, 'utf8');
|
|
64
|
+
const parsed = JSON.parse(source);
|
|
65
|
+
if (!isRecord(parsed))
|
|
66
|
+
throw new Error(`${path} is not a JSON object.`);
|
|
67
|
+
for (const write of writes) {
|
|
68
|
+
const field = parsed[write.field];
|
|
69
|
+
if (!isRecord(field))
|
|
70
|
+
continue;
|
|
71
|
+
field[write.name] = write.range;
|
|
72
|
+
}
|
|
73
|
+
const indent = detectIndent(source);
|
|
74
|
+
const trailingNewline = source.endsWith('\n') ? '\n' : '';
|
|
75
|
+
(0, fs_1.writeFileSync)(path, `${JSON.stringify(parsed, null, indent)}${trailingNewline}`, 'utf8');
|
|
76
|
+
};
|
|
77
|
+
exports.writeRanges = writeRanges;
|
|
78
|
+
/**
|
|
79
|
+
* The range that carries `version` while keeping how the declared one was written, for example `^`.
|
|
80
|
+
* `undefined` for a range this cannot rewrite safely, such as `workspace:*` or `>=5 <6`.
|
|
81
|
+
*/
|
|
82
|
+
const rangeFor = (options) => {
|
|
83
|
+
const { current, version } = options;
|
|
84
|
+
const prefix = (0, semver_1.rangePrefix)(current);
|
|
85
|
+
return prefix === undefined ? undefined : `${prefix}${version}`;
|
|
86
|
+
};
|
|
87
|
+
exports.rangeFor = rangeFor;
|
|
88
|
+
//# 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,2BAA6D;AAC7D,+BAA4B;AAC5B,qCAAuD;AAE1C,QAAA,aAAa,GAAG,WAAW,CAAC;AAE5B,QAAA,iBAAiB,GAAG,CAAC,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,CAAU,CAAC;AAkBlG,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,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEhE,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC;AAA5D,QAAA,YAAY,gBAAgD;AAElE,MAAM,YAAY,GAAG,CAAC,IAAY,EAAwB,EAAE;IACjE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAA,oBAA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AC;IAE1D,IAAA,kBAAa,EAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,eAAe,EAAE,EAAE,MAAM,CAAC,CAAC;AAC3F,CAAC,CAAC;AApBW,QAAA,WAAW,eAoBtB;AAEF;;;GAGG;AACI,MAAM,QAAQ,GAAG,CAAC,OAA6C,EAAE,EAAE;IACxE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACrC,MAAM,MAAM,GAAG,IAAA,oBAAW,EAAC,OAAO,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"}
|
|
@@ -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,WAAI,EAAC,kBAAU,EAAE,cAAc,CAAC,CAAC;AAc7D,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,CAAC,OAAiD,EAAE,EAAE;IACtF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAElC,IAAA,cAAS,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,kBAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,oBAAY,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3F,CAAC,CAAC;AALW,QAAA,kBAAkB,sBAK7B;AAEK,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAA6B,EAAE;IAC3E,MAAM,IAAI,GAAG,IAAA,WAAI,E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AE,oBAAY,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAAzF,QAAA,kBAAkB,sBAAuE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DeclaredPackage, DependencyField } 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
|
+
field: DependencyField;
|
|
12
|
+
/** The range the manifest declares now. */
|
|
13
|
+
declaredRange: string;
|
|
14
|
+
/** The dist tag the target came from, absent when the caller named a version. */
|
|
15
|
+
tag?: string;
|
|
16
|
+
/** The range to write, or `undefined` when the declared one cannot be rewritten safely. */
|
|
17
|
+
nextRange?: string;
|
|
18
|
+
};
|
|
19
|
+
export type TargetChoice = {
|
|
20
|
+
update: PackageUpdate;
|
|
21
|
+
} | {
|
|
22
|
+
problem: string;
|
|
23
|
+
} | {
|
|
24
|
+
upToDate: true;
|
|
25
|
+
};
|
|
26
|
+
export type TargetRequest = {
|
|
27
|
+
/** A version the caller named with `--to`. */
|
|
28
|
+
version?: string;
|
|
29
|
+
/** A dist tag the caller named with `--tag`. */
|
|
30
|
+
tag?: string;
|
|
31
|
+
};
|
|
32
|
+
/** The version an update moves a package to, from the registry's dist tags or the caller's request. */
|
|
33
|
+
export declare const chooseTarget: (options: {
|
|
34
|
+
declared: DeclaredPackage;
|
|
35
|
+
registry: RegistryPackage;
|
|
36
|
+
request?: TargetRequest;
|
|
37
|
+
}) => TargetChoice;
|
|
38
|
+
export declare const isDowngrade: (update: PackageUpdate) => boolean;
|
|
39
|
+
export type PendingMigration = {
|
|
40
|
+
packageName: string;
|
|
41
|
+
migration: Migration;
|
|
42
|
+
/** Where the instructions of this migration live, when it names any. */
|
|
43
|
+
manifestPath?: string;
|
|
44
|
+
};
|
|
45
|
+
/** The migrations of one package that an update from `from` to `to` crosses. */
|
|
46
|
+
export declare const pendingMigrations: (options: {
|
|
47
|
+
packageMigrations: PackageMigrations;
|
|
48
|
+
from: string;
|
|
49
|
+
to: string;
|
|
50
|
+
}) => PendingMigration[];
|
|
51
|
+
/** Oldest version first, and inside one version the package that others build on first. */
|
|
52
|
+
export declare const orderMigrations: (pending: readonly PendingMigration[]) => PendingMigration[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.orderMigrations = exports.pendingMigrations = exports.isDowngrade = exports.chooseTarget = void 0;
|
|
4
|
+
const packages_1 = require("./packages");
|
|
5
|
+
const registry_1 = require("./registry");
|
|
6
|
+
const semver_1 = require("./semver");
|
|
7
|
+
/**
|
|
8
|
+
* The order two migrations of the same version run in, following the dependency layering: a rewrite in
|
|
9
|
+
* `core` lands before the `components` one that builds on it.
|
|
10
|
+
*/
|
|
11
|
+
const PACKAGE_ORDER = [
|
|
12
|
+
'@ethlete/types',
|
|
13
|
+
'@ethlete/core',
|
|
14
|
+
'@ethlete/query',
|
|
15
|
+
'@ethlete/components',
|
|
16
|
+
'@ethlete/contentful',
|
|
17
|
+
'@ethlete/query-devtools',
|
|
18
|
+
'@ethlete/cdk',
|
|
19
|
+
'@ethlete/eslint-plugin',
|
|
20
|
+
'@ethlete/agent-rules',
|
|
21
|
+
'@ethlete/cli',
|
|
22
|
+
];
|
|
23
|
+
/** The version an update moves a package to, from the registry's dist tags or the caller's request. */
|
|
24
|
+
const chooseTarget = (options) => {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
const { declared, registry, request = {} } = options;
|
|
27
|
+
const current = (_a = declared.installedVersion) !== null && _a !== void 0 ? _a : declared.declaredVersion;
|
|
28
|
+
if (request.version !== undefined) {
|
|
29
|
+
if (!(0, semver_1.isValidVersion)(request.version))
|
|
30
|
+
return { problem: `"${request.version}" is not a version.` };
|
|
31
|
+
if (!registry.versions.includes(request.version)) {
|
|
32
|
+
return { problem: `${declared.name}@${request.version} is not on the registry.` };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const tag = request.version === undefined
|
|
36
|
+
? ((_b = request.tag) !== null && _b !== void 0 ? _b : (0, registry_1.tagForInstalled)({ version: current, distTags: registry.distTags }))
|
|
37
|
+
: undefined;
|
|
38
|
+
const to = (_c = request.version) !== null && _c !== void 0 ? _c : (tag === undefined ? undefined : registry.distTags[tag]);
|
|
39
|
+
if (to === undefined) {
|
|
40
|
+
return { problem: `${declared.name} has no "${tag}" version on the registry.` };
|
|
41
|
+
}
|
|
42
|
+
if (current !== undefined && (0, semver_1.compareVersions)(to, current) === 0)
|
|
43
|
+
return { upToDate: true };
|
|
44
|
+
return {
|
|
45
|
+
update: {
|
|
46
|
+
name: declared.name,
|
|
47
|
+
field: declared.field,
|
|
48
|
+
declaredRange: declared.range,
|
|
49
|
+
from: declared.installedVersion,
|
|
50
|
+
to,
|
|
51
|
+
tag,
|
|
52
|
+
nextRange: (0, packages_1.rangeFor)({ current: declared.range, version: to }),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.chooseTarget = chooseTarget;
|
|
57
|
+
const isDowngrade = (update) => update.from !== undefined && !(0, semver_1.isNewer)(update.to, update.from);
|
|
58
|
+
exports.isDowngrade = isDowngrade;
|
|
59
|
+
/** The migrations of one package that an update from `from` to `to` crosses. */
|
|
60
|
+
const pendingMigrations = (options) => {
|
|
61
|
+
const { packageMigrations, from, to } = options;
|
|
62
|
+
return packageMigrations.migrations
|
|
63
|
+
.filter((migration) => (0, semver_1.isInUpdateRange)({ version: migration.version, after: from, upTo: to }))
|
|
64
|
+
.map((migration) => ({
|
|
65
|
+
packageName: packageMigrations.packageName,
|
|
66
|
+
migration,
|
|
67
|
+
manifestPath: packageMigrations.manifestPath,
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
exports.pendingMigrations = pendingMigrations;
|
|
71
|
+
const packageRank = (name) => {
|
|
72
|
+
const index = PACKAGE_ORDER.indexOf(name);
|
|
73
|
+
return index === -1 ? PACKAGE_ORDER.length : index;
|
|
74
|
+
};
|
|
75
|
+
/** Oldest version first, and inside one version the package that others build on first. */
|
|
76
|
+
const orderMigrations = (pending) => [...pending].sort((left, right) => {
|
|
77
|
+
const byVersion = (0, semver_1.compareVersions)(left.migration.version, right.migration.version);
|
|
78
|
+
if (byVersion !== 0)
|
|
79
|
+
return byVersion;
|
|
80
|
+
return packageRank(left.packageName) - packageRank(right.packageName);
|
|
81
|
+
});
|
|
82
|
+
exports.orderMigrations = orderMigrations;
|
|
83
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/lib/update/plan.ts"],"names":[],"mappings":";;;AAAA,yCAAwE;AAExE,yCAA8D;AAC9D,qCAAqF;AAErF;;;GAGG;AACH,MAAM,aAAa,GAAG;IACpB,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,qBAAqB;IACrB,qBAAqB;IACrB,yBAAyB;IACzB,cAAc;IACd,wBAAwB;IACxB,sBAAsB;IACtB,cAAc;CACf,CAAC;AA4BF,uGAAuG;AAChG,MAAM,YAAY,GAAG,CAAC,OAI5B,EAAgB,EAAE;;IACjB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IACrD,MAAM,OAAO,GAAG,MAAA,QAAQ,CAAC,gBAAgB,mCAAI,QAAQ,CAAC,eAAe,CAAC;IAEtE,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,CAAC,IAAA,uBAAc,EAAC,OAAO,CAAC,OAAO,CAAC;YAAE,OAAO,EA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,IAAI,EAAE,KAAK,EAAE,EAAE;IAChC,MAAM,SAAS,GAAG,IAAA,wBAAe,EAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAEnF,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAEtC,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACxE,CAAC,CAAC,CAAC;AAPQ,QAAA,eAAe,mBAOvB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
2
|
+
export type RegistryPackage = {
|
|
3
|
+
distTags: Record<string, string>;
|
|
4
|
+
versions: string[];
|
|
5
|
+
};
|
|
6
|
+
export type RegistryLookup = {
|
|
7
|
+
ok: true;
|
|
8
|
+
package: RegistryPackage;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
/** The registry npm would use, so a run inside a repo with its own registry reads the same one. */
|
|
14
|
+
export declare const registryUrl: (env?: NodeJS.ProcessEnv) => string;
|
|
15
|
+
export declare const packageUrl: (options: {
|
|
16
|
+
registry: string;
|
|
17
|
+
packageName: string;
|
|
18
|
+
}) => string;
|
|
19
|
+
/** Asks the registry which versions of a package exist and what each dist tag points at. */
|
|
20
|
+
export declare const fetchRegistryPackage: (options: {
|
|
21
|
+
packageName: string;
|
|
22
|
+
registry?: string;
|
|
23
|
+
}) => Promise<RegistryLookup>;
|
|
24
|
+
/**
|
|
25
|
+
* Which dist tag an update follows when the caller names none: the one the installed prerelease belongs
|
|
26
|
+
* to, so a repo on `-next.46` stays on `next` instead of being pulled back to the stable line.
|
|
27
|
+
*/
|
|
28
|
+
export declare const tagForInstalled: (options: {
|
|
29
|
+
version?: string;
|
|
30
|
+
distTags: Record<string, string>;
|
|
31
|
+
}) => string;
|