@lablup/ui-common-cli 0.2.0-alpha.15
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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +28 -0
- package/bin/ui-common.mjs +12 -0
- package/cli/agents.mjs +335 -0
- package/cli/diff.mjs +125 -0
- package/cli/lab-peer.mjs +226 -0
- package/cli/main.mjs +97 -0
- package/cli/passthrough.mjs +153 -0
- package/cli/paths.mjs +290 -0
- package/cli/report.mjs +157 -0
- package/cli/resolve.mjs +257 -0
- package/cli/rewrite.mjs +133 -0
- package/cli/semver.mjs +278 -0
- package/cli/shadow.mjs +161 -0
- package/cli/sync-astryx.mjs +417 -0
- package/cli/upgrade.mjs +776 -0
- package/codemods/0.2/components.mjs +903 -0
- package/codemods/0.2/elements.mjs +745 -0
- package/codemods/0.2/index.mjs +68 -0
- package/codemods/0.2/legacy-classes.json +292 -0
- package/codemods/0.2/local-modules.mjs +510 -0
- package/codemods/0.2/map.mjs +178 -0
- package/codemods/0.2/package-json.mjs +333 -0
- package/codemods/0.2/scan.mjs +397 -0
- package/codemods/0.2/stylesheets.mjs +479 -0
- package/codemods/0.2/theme.mjs +325 -0
- package/codemods/lib/jsx.mjs +352 -0
- package/codemods/lib/todo.mjs +151 -0
- package/codemods/registry.mjs +95 -0
- package/codemods/upstream.mjs +155 -0
- package/migration/0.1-to-0.2.json +629 -0
- package/package.json +50 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ui-common sync-astryx <version>`: the maintainer's Astryx bump, inside the
|
|
3
|
+
* ui-common repository.
|
|
4
|
+
*
|
|
5
|
+
* 1. Move the exact pins (core, theme-neutral and the cli devDependency in the
|
|
6
|
+
* root package.json, the cli in packages/cli's; lab with --lab), and the
|
|
7
|
+
* core version README and pnpm-workspace.yaml override lab's core peer to.
|
|
8
|
+
* 2. Install, regenerate the export mirror and the built Lablup theme.
|
|
9
|
+
* 3. Run Astryx's codemods on ui-common's own src/ (dry run, then applied).
|
|
10
|
+
* 4. Run the tests, which include the export and theme drift checks.
|
|
11
|
+
* 5. Record the Astryx codemods consumers need for this bump under the next
|
|
12
|
+
* ui-common version: packages/cli/codemods/<version>/upstream.json. `ui-common upgrade`
|
|
13
|
+
* runs them for consumers, with the import specifiers swapped.
|
|
14
|
+
*
|
|
15
|
+
* `--dry-run` changes nothing: it prints the plan, runs Astryx's codemods on
|
|
16
|
+
* src/ in dry-run mode against the installed CLI, and shows what would be
|
|
17
|
+
* recorded.
|
|
18
|
+
*
|
|
19
|
+
* The codemods run before the tests (the order in the design note had them
|
|
20
|
+
* after): a rename Astryx ships a codemod for would otherwise fail the tests
|
|
21
|
+
* before the codemod could fix it.
|
|
22
|
+
*/
|
|
23
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
24
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
25
|
+
import { dirname, join } from "node:path";
|
|
26
|
+
|
|
27
|
+
import { syncLabOverrideDocs } from "./lab-peer.mjs";
|
|
28
|
+
import { findProjectDir, readJson } from "./paths.mjs";
|
|
29
|
+
import { compare, nextBreaking, parse } from "./semver.mjs";
|
|
30
|
+
|
|
31
|
+
/** Exact pins in the root package.json (@lablup/ui-common), by field. */
|
|
32
|
+
const PINNED = /** @type {const} */ ([
|
|
33
|
+
["dependencies", "@astryxdesign/core"],
|
|
34
|
+
["dependencies", "@astryxdesign/theme-neutral"],
|
|
35
|
+
// The root's own scripts (theme:build, check:integration) run it.
|
|
36
|
+
["devDependencies", "@astryxdesign/cli"],
|
|
37
|
+
]);
|
|
38
|
+
/** The CLI package, which carries the Astryx CLI as a dependency. */
|
|
39
|
+
export const CLI_PACKAGE_DIR = join("packages", "cli");
|
|
40
|
+
const CLI_PINNED = /** @type {const} */ ([["dependencies", "@astryxdesign/cli"]]);
|
|
41
|
+
const LAB = "@astryxdesign/lab";
|
|
42
|
+
|
|
43
|
+
export const SYNC_HELP = `Usage: ui-common sync-astryx <version> [--lab <version>] [--as <version>] [--dry-run]
|
|
44
|
+
|
|
45
|
+
Maintainers only, inside the @lablup/ui-common repository. Moves the Astryx
|
|
46
|
+
pin set to <version>, regenerates the export mirror and the Lablup theme, runs
|
|
47
|
+
Astryx's codemods on src/, runs the tests, and records the Astryx codemods
|
|
48
|
+
consumers need under the next ui-common version
|
|
49
|
+
(packages/cli/codemods/<as>/upstream.json). Run it from the repository root
|
|
50
|
+
or anywhere under it.
|
|
51
|
+
|
|
52
|
+
--lab <version> Also move the @astryxdesign/lab canary pin (dev + peer).
|
|
53
|
+
--as <version> The ui-common version to record the codemods under.
|
|
54
|
+
Default: the next prerelease (or minor) after package.json's.
|
|
55
|
+
--dry-run Change nothing; print the plan and a dry run of Astryx's
|
|
56
|
+
codemods on src/.
|
|
57
|
+
|
|
58
|
+
Exit codes: 0 done, 1 a step failed (the tree is left as it was at that step),
|
|
59
|
+
2 bad arguments or not run inside the ui-common repository.
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The repository root at or above `cwd`: the @lablup/ui-common package with
|
|
64
|
+
* its scripts and the CLI package beside it. A directory inside the
|
|
65
|
+
* repository (packages/cli) finds it too.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} cwd
|
|
68
|
+
* @returns {string | null} the repository root, or null outside it
|
|
69
|
+
*/
|
|
70
|
+
export function findUiCommonRepo(cwd) {
|
|
71
|
+
for (let dir = findProjectDir(cwd); dir;) {
|
|
72
|
+
if (isUiCommonRepo(dir)) return dir;
|
|
73
|
+
const parent = dirname(dir);
|
|
74
|
+
if (parent === dir) return null;
|
|
75
|
+
dir = findProjectDir(parent);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** @param {string} dir */
|
|
81
|
+
function isUiCommonRepo(dir) {
|
|
82
|
+
try {
|
|
83
|
+
const pkg = readJson(join(dir, "package.json"));
|
|
84
|
+
if (pkg.name !== "@lablup/ui-common") return false;
|
|
85
|
+
} catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
// A consumer's node_modules copy has the name but not the repository.
|
|
89
|
+
return (
|
|
90
|
+
existsSync(join(dir, "scripts/gen-exports.mjs")) &&
|
|
91
|
+
existsSync(join(dir, "exports.exclude.json")) &&
|
|
92
|
+
existsSync(join(dir, CLI_PACKAGE_DIR, "package.json"))
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {string} repo
|
|
98
|
+
* @param {string} from
|
|
99
|
+
* @param {string} to
|
|
100
|
+
* @returns {{codemods: Array<{id: string, version: string, title: string}>, optional: string[]} | null}
|
|
101
|
+
*/
|
|
102
|
+
function listAstryxCodemods(repo, from, to) {
|
|
103
|
+
const result = spawnSync("pnpm", ["exec", "astryx", "upgrade", "--list", "--json"], {
|
|
104
|
+
cwd: repo,
|
|
105
|
+
encoding: "utf8",
|
|
106
|
+
});
|
|
107
|
+
if (result.status !== 0) return null;
|
|
108
|
+
const listed =
|
|
109
|
+
/** @type {{data: Array<{name: string, title: string, version: string, optional: boolean}>}} */ (
|
|
110
|
+
JSON.parse(result.stdout)
|
|
111
|
+
).data;
|
|
112
|
+
const inRange = listed.filter(
|
|
113
|
+
(c) => compare(c.version, from) > 0 && compare(c.version, to) <= 0,
|
|
114
|
+
);
|
|
115
|
+
return {
|
|
116
|
+
codemods: inRange
|
|
117
|
+
.filter((c) => !c.optional)
|
|
118
|
+
.map((c) => ({ id: c.name, version: c.version, title: c.title })),
|
|
119
|
+
optional: inRange.filter((c) => c.optional).map((c) => c.name),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param {string} repo
|
|
125
|
+
* @param {string} version ui-common version to record under
|
|
126
|
+
* @param {{from: string, to: string}} astryx
|
|
127
|
+
* @param {{codemods: Array<{id: string, version: string, title: string}>, optional: string[]}} listed
|
|
128
|
+
*/
|
|
129
|
+
export function upstreamManifest(repo, version, astryx, listed) {
|
|
130
|
+
const file = join(repo, CLI_PACKAGE_DIR, "codemods", version, "upstream.json");
|
|
131
|
+
/** @type {any} */
|
|
132
|
+
let manifest = {
|
|
133
|
+
$comment:
|
|
134
|
+
"Written by `ui-common sync-astryx`. Astryx codemods consumers need when they upgrade across this ui-common version; `ui-common upgrade` runs them with @lablup/ui-common specifiers swapped for Astryx's.",
|
|
135
|
+
astryx,
|
|
136
|
+
codemods: listed.codemods,
|
|
137
|
+
optional: listed.optional,
|
|
138
|
+
};
|
|
139
|
+
if (existsSync(file)) {
|
|
140
|
+
// Two bumps before one release: keep one range and the union of codemods.
|
|
141
|
+
const previous = readJson(file);
|
|
142
|
+
const ids = new Set(previous.codemods.map((/** @type {any} */ c) => c.id));
|
|
143
|
+
manifest = {
|
|
144
|
+
...manifest,
|
|
145
|
+
astryx: { from: previous.astryx.from, to: astryx.to },
|
|
146
|
+
codemods: [
|
|
147
|
+
...previous.codemods,
|
|
148
|
+
...listed.codemods.filter((c) => !ids.has(c.id)),
|
|
149
|
+
],
|
|
150
|
+
optional: [...new Set([...(previous.optional ?? []), ...listed.optional])],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return { file, manifest };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The files that name the core version lab's core peer is overridden to:
|
|
158
|
+
* README's consumer recipes and this repository's own peer rule. They move
|
|
159
|
+
* with the core pin (test/cli/lab-peer.test.ts fails when README lags).
|
|
160
|
+
*
|
|
161
|
+
* @param {string} repo
|
|
162
|
+
* @param {string} pin the new @astryxdesign/core pin
|
|
163
|
+
* @returns {Array<{name: string, file: string, after: string}>}
|
|
164
|
+
*/
|
|
165
|
+
export function labOverrideEdits(repo, pin) {
|
|
166
|
+
const edits = [];
|
|
167
|
+
for (const name of ["README.md", "pnpm-workspace.yaml"]) {
|
|
168
|
+
const file = join(repo, name);
|
|
169
|
+
if (!existsSync(file)) continue;
|
|
170
|
+
const before = readFileSync(file, "utf8");
|
|
171
|
+
const after = syncLabOverrideDocs(before, pin);
|
|
172
|
+
if (after !== before) edits.push({ name, file, after });
|
|
173
|
+
}
|
|
174
|
+
return edits;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @param {string[]} argv arguments after `sync-astryx`
|
|
179
|
+
*/
|
|
180
|
+
export async function syncAstryxCommand(argv) {
|
|
181
|
+
/** @type {string|undefined} */
|
|
182
|
+
let target;
|
|
183
|
+
/** @type {string|undefined} */
|
|
184
|
+
let lab;
|
|
185
|
+
/** @type {string|undefined} */
|
|
186
|
+
let as;
|
|
187
|
+
let dryRun = false;
|
|
188
|
+
for (let i = 0; i < argv.length; i++) {
|
|
189
|
+
const arg = argv[i];
|
|
190
|
+
if (arg === "--dry-run") dryRun = true;
|
|
191
|
+
else if (arg === "--lab") lab = argv[++i];
|
|
192
|
+
else if (arg.startsWith("--lab=")) lab = arg.slice(6);
|
|
193
|
+
else if (arg === "--as") as = argv[++i];
|
|
194
|
+
else if (arg.startsWith("--as=")) as = arg.slice(5);
|
|
195
|
+
else if (arg === "-h" || arg === "--help") {
|
|
196
|
+
process.stdout.write(SYNC_HELP);
|
|
197
|
+
return 0;
|
|
198
|
+
} else if (arg.startsWith("-")) {
|
|
199
|
+
process.stderr.write(
|
|
200
|
+
`ui-common sync-astryx: unknown option "${arg}"\n${SYNC_HELP}`,
|
|
201
|
+
);
|
|
202
|
+
return 2;
|
|
203
|
+
} else if (!target) target = arg;
|
|
204
|
+
else {
|
|
205
|
+
process.stderr.write(`ui-common sync-astryx: unexpected argument "${arg}"\n`);
|
|
206
|
+
return 2;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (!target || !parse(target)) {
|
|
210
|
+
process.stderr.write(
|
|
211
|
+
`ui-common sync-astryx: give the Astryx version to move to.\n${SYNC_HELP}`,
|
|
212
|
+
);
|
|
213
|
+
return 2;
|
|
214
|
+
}
|
|
215
|
+
for (const [flag, value] of /** @type {const} */ ([
|
|
216
|
+
["--lab", lab],
|
|
217
|
+
["--as", as],
|
|
218
|
+
])) {
|
|
219
|
+
if (value !== undefined && !parse(value)) {
|
|
220
|
+
process.stderr.write(
|
|
221
|
+
`ui-common sync-astryx: ${flag} "${value}" is not a version.\n`,
|
|
222
|
+
);
|
|
223
|
+
return 2;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const repo = findUiCommonRepo(process.cwd());
|
|
228
|
+
if (!repo) {
|
|
229
|
+
process.stderr.write(
|
|
230
|
+
"ui-common sync-astryx: run this inside the @lablup/ui-common repository. It edits ui-common's own pins and generated files; a consumer upgrades with `ui-common upgrade`.\n",
|
|
231
|
+
);
|
|
232
|
+
return 2;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const pkgFile = join(repo, "package.json");
|
|
236
|
+
const pkg = JSON.parse(readFileSync(pkgFile, "utf8"));
|
|
237
|
+
const cliPkgFile = join(repo, CLI_PACKAGE_DIR, "package.json");
|
|
238
|
+
const cliPkg = JSON.parse(readFileSync(cliPkgFile, "utf8"));
|
|
239
|
+
const current = pkg.dependencies?.["@astryxdesign/core"];
|
|
240
|
+
if (!current || !parse(current)) {
|
|
241
|
+
process.stderr.write(
|
|
242
|
+
`ui-common sync-astryx: package.json pins @astryxdesign/core as "${current}"; expected an exact version.\n`,
|
|
243
|
+
);
|
|
244
|
+
return 1;
|
|
245
|
+
}
|
|
246
|
+
const recordAs = as ?? nextBreaking(pkg.version);
|
|
247
|
+
const out = (/** @type {string} */ line) => process.stdout.write(`${line}\n`);
|
|
248
|
+
|
|
249
|
+
out(
|
|
250
|
+
`ui-common sync-astryx: Astryx ${current} → ${target}${lab ? `, lab → ${lab}` : ""}${dryRun ? " (dry run)" : ""}`,
|
|
251
|
+
);
|
|
252
|
+
out(` repository: ${repo}`);
|
|
253
|
+
const edits = [];
|
|
254
|
+
for (const [field, name] of PINNED) {
|
|
255
|
+
const from = pkg[field]?.[name];
|
|
256
|
+
if (from !== target) edits.push(`${field}["${name}"]: ${from} → ${target}`);
|
|
257
|
+
}
|
|
258
|
+
if (lab) {
|
|
259
|
+
for (const field of ["devDependencies", "peerDependencies"]) {
|
|
260
|
+
const from = pkg[field]?.[LAB];
|
|
261
|
+
if (from !== lab) edits.push(`${field}["${LAB}"]: ${from} → ${lab}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
out(
|
|
265
|
+
edits.length > 0
|
|
266
|
+
? ` package.json: ${edits.join("; ")}`
|
|
267
|
+
: " package.json: pins already at the target",
|
|
268
|
+
);
|
|
269
|
+
const cliEdits = [];
|
|
270
|
+
for (const [field, name] of CLI_PINNED) {
|
|
271
|
+
const from = cliPkg[field]?.[name];
|
|
272
|
+
if (from !== target) cliEdits.push(`${field}["${name}"]: ${from} → ${target}`);
|
|
273
|
+
}
|
|
274
|
+
out(
|
|
275
|
+
cliEdits.length > 0
|
|
276
|
+
? ` ${CLI_PACKAGE_DIR}/package.json: ${cliEdits.join("; ")}`
|
|
277
|
+
: ` ${CLI_PACKAGE_DIR}/package.json: pins already at the target`,
|
|
278
|
+
);
|
|
279
|
+
for (const edit of labOverrideEdits(repo, target)) {
|
|
280
|
+
out(` ${edit.name}: lab's core override → ${target}`);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** @param {string} title @param {string} cmd @param {string[]} args */
|
|
284
|
+
const step = (title, cmd, args) => {
|
|
285
|
+
out(`\n▸ ${title}: ${cmd} ${args.join(" ")}`);
|
|
286
|
+
if (dryRun) return true;
|
|
287
|
+
try {
|
|
288
|
+
execFileSync(cmd, args, { cwd: repo, stdio: "inherit" });
|
|
289
|
+
return true;
|
|
290
|
+
} catch {
|
|
291
|
+
process.stderr.write(
|
|
292
|
+
`ui-common sync-astryx: "${title}" failed. The tree is left as it is; fix and re-run.\n`,
|
|
293
|
+
);
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
if (dryRun) {
|
|
299
|
+
out("\nWould run: pnpm install; pnpm run gen:exports; pnpm run theme:build;");
|
|
300
|
+
out(
|
|
301
|
+
` pnpm exec astryx upgrade --from ${current} --path src (dry run, then --apply); pnpm run test`,
|
|
302
|
+
);
|
|
303
|
+
out(
|
|
304
|
+
`\n▸ Astryx codemods on src/ (dry run, installed CLI): pnpm exec astryx upgrade --from ${current} --path src`,
|
|
305
|
+
);
|
|
306
|
+
const dry = spawnSync(
|
|
307
|
+
"pnpm",
|
|
308
|
+
["exec", "astryx", "upgrade", "--from", current, "--path", "src"],
|
|
309
|
+
{
|
|
310
|
+
cwd: repo,
|
|
311
|
+
encoding: "utf8",
|
|
312
|
+
},
|
|
313
|
+
);
|
|
314
|
+
out((dry.stdout + dry.stderr).trim());
|
|
315
|
+
if (compare(target, current) <= 0) {
|
|
316
|
+
out(
|
|
317
|
+
`\nNothing would be recorded: ${target} is not newer than the pinned ${current}.`,
|
|
318
|
+
);
|
|
319
|
+
return 0;
|
|
320
|
+
}
|
|
321
|
+
const listed = listAstryxCodemods(repo, current, target);
|
|
322
|
+
if (!listed) {
|
|
323
|
+
out("\nCould not list Astryx codemods with the installed CLI.");
|
|
324
|
+
return 0;
|
|
325
|
+
}
|
|
326
|
+
const { file, manifest } = upstreamManifest(
|
|
327
|
+
repo,
|
|
328
|
+
recordAs,
|
|
329
|
+
{ from: current, to: target },
|
|
330
|
+
listed,
|
|
331
|
+
);
|
|
332
|
+
out(
|
|
333
|
+
`\nWould record ${manifest.codemods.length} codemod(s) in ${file.slice(repo.length + 1)} (as listed by the installed CLI; the new CLI may add more):`,
|
|
334
|
+
);
|
|
335
|
+
for (const c of manifest.codemods) out(` - ${c.version} ${c.id}: ${c.title}`);
|
|
336
|
+
return 0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Pins.
|
|
340
|
+
for (const [field, name] of PINNED) {
|
|
341
|
+
pkg[field] = { ...pkg[field], [name]: target };
|
|
342
|
+
}
|
|
343
|
+
for (const [field, name] of CLI_PINNED) {
|
|
344
|
+
cliPkg[field] = { ...cliPkg[field], [name]: target };
|
|
345
|
+
}
|
|
346
|
+
if (lab) {
|
|
347
|
+
pkg.devDependencies = { ...pkg.devDependencies, [LAB]: lab };
|
|
348
|
+
pkg.peerDependencies = { ...pkg.peerDependencies, [LAB]: lab };
|
|
349
|
+
}
|
|
350
|
+
writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
351
|
+
writeFileSync(cliPkgFile, `${JSON.stringify(cliPkg, null, 2)}\n`);
|
|
352
|
+
out(` package.json and ${CLI_PACKAGE_DIR}/package.json written`);
|
|
353
|
+
for (const edit of labOverrideEdits(repo, target)) {
|
|
354
|
+
writeFileSync(edit.file, edit.after);
|
|
355
|
+
out(` ${edit.name}: lab's core override moved to ${target}`);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (!step("Install", "pnpm", ["install"])) return 1;
|
|
359
|
+
if (!step("Regenerate the export mirror", "pnpm", ["run", "gen:exports"])) return 1;
|
|
360
|
+
if (!step("Rebuild the Lablup theme", "pnpm", ["run", "theme:build"])) return 1;
|
|
361
|
+
if (
|
|
362
|
+
!step("Astryx codemods on src/ (dry run)", "pnpm", [
|
|
363
|
+
"exec",
|
|
364
|
+
"astryx",
|
|
365
|
+
"upgrade",
|
|
366
|
+
"--from",
|
|
367
|
+
current,
|
|
368
|
+
"--path",
|
|
369
|
+
"src",
|
|
370
|
+
])
|
|
371
|
+
)
|
|
372
|
+
return 1;
|
|
373
|
+
if (
|
|
374
|
+
!step("Astryx codemods on src/", "pnpm", [
|
|
375
|
+
"exec",
|
|
376
|
+
"astryx",
|
|
377
|
+
"upgrade",
|
|
378
|
+
"--from",
|
|
379
|
+
current,
|
|
380
|
+
"--path",
|
|
381
|
+
"src",
|
|
382
|
+
"--apply",
|
|
383
|
+
])
|
|
384
|
+
)
|
|
385
|
+
return 1;
|
|
386
|
+
if (!step("Tests and drift checks", "pnpm", ["run", "test"])) return 1;
|
|
387
|
+
|
|
388
|
+
if (compare(target, current) > 0) {
|
|
389
|
+
const listed = listAstryxCodemods(repo, current, target);
|
|
390
|
+
if (!listed) {
|
|
391
|
+
process.stderr.write(
|
|
392
|
+
"ui-common sync-astryx: could not list Astryx codemods with the new CLI.\n",
|
|
393
|
+
);
|
|
394
|
+
return 1;
|
|
395
|
+
}
|
|
396
|
+
const { file, manifest } = upstreamManifest(
|
|
397
|
+
repo,
|
|
398
|
+
recordAs,
|
|
399
|
+
{ from: current, to: target },
|
|
400
|
+
listed,
|
|
401
|
+
);
|
|
402
|
+
mkdirSync(join(file, ".."), { recursive: true });
|
|
403
|
+
writeFileSync(file, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
404
|
+
out(
|
|
405
|
+
`\nRecorded ${manifest.codemods.length} Astryx codemod(s) for consumers in ${file.slice(repo.length + 1)}.`,
|
|
406
|
+
);
|
|
407
|
+
out(
|
|
408
|
+
`Release it as ${recordAs} (or re-run with --as <version>), so \`ui-common upgrade\` runs them for consumers crossing it.`,
|
|
409
|
+
);
|
|
410
|
+
} else {
|
|
411
|
+
out(`\nNo upstream codemods recorded: ${target} is not newer than ${current}.`);
|
|
412
|
+
}
|
|
413
|
+
out(
|
|
414
|
+
"\nNext: read the gen:exports diff, note new and removed subpaths in CHANGELOG.md, run `pnpm run verify`.",
|
|
415
|
+
);
|
|
416
|
+
return 0;
|
|
417
|
+
}
|