@cosmicdrift/kumiko-cli 0.370.0 → 0.371.0
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/package.json +8 -8
- package/src/changes.json +6 -0
- package/src/commands/codemod.ts +80 -0
- package/src/commands/index.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.371.0",
|
|
4
4
|
"description": "CLI for Kumiko apps. `bunx @cosmicdrift/kumiko-cli new app <name>` scaffolds a runnable workspace; `add feature <name>` mounts a feature; `check` runs boot validation plus the guard suites with the step list derived from kumiko.json; `agent lint`, `project` and `consumer` operate on an existing app; `handbuch build` renders the HTML handbuch.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cosmicdrift/kumiko-dev-server": "0.
|
|
40
|
-
"@cosmicdrift/kumiko-guards": "0.
|
|
41
|
-
"@cosmicdrift/kumiko-repo-manifest": "0.
|
|
42
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
39
|
+
"@cosmicdrift/kumiko-dev-server": "0.371.0",
|
|
40
|
+
"@cosmicdrift/kumiko-guards": "0.371.0",
|
|
41
|
+
"@cosmicdrift/kumiko-repo-manifest": "0.371.0",
|
|
42
|
+
"@cosmicdrift/kumiko-testing": "0.371.0",
|
|
43
43
|
"marked": "^18.0.3",
|
|
44
44
|
"zod": "^4.4.3"
|
|
45
45
|
},
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@cosmicdrift/kumiko-bundled-features": "0.
|
|
68
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
69
|
-
"@cosmicdrift/kumiko-headless": "0.
|
|
67
|
+
"@cosmicdrift/kumiko-bundled-features": "0.371.0",
|
|
68
|
+
"@cosmicdrift/kumiko-framework": "0.371.0",
|
|
69
|
+
"@cosmicdrift/kumiko-headless": "0.371.0",
|
|
70
70
|
"sharp": "^0.35.5"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
package/src/changes.json
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.371.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "kumiko codemod lists and runs codemods",
|
|
6
|
+
"detail": "kumiko codemod lists the codemods without a name. kumiko codemod <name> runs one against the current directory as a dry run and applies it with --write."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.370.0",
|
|
4
10
|
"type": "improvement",
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { CliCommand, CliCommandContext } from "./types";
|
|
2
|
+
|
|
3
|
+
// The shipped codemods that share the `<dir...> [--check | --dry-run | --write]` CLI of codemod-support.
|
|
4
|
+
const CODEMODS = ["feature-factory", "import-extensions", "s3-imports"] as const;
|
|
5
|
+
type CodemodName = (typeof CODEMODS)[number];
|
|
6
|
+
|
|
7
|
+
function isCodemodName(value: string | undefined): value is CodemodName {
|
|
8
|
+
return CODEMODS.some((known) => known === value);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const MODE_FLAGS = ["--write", "--check", "--dry-run"] as const;
|
|
12
|
+
|
|
13
|
+
function printList(ctx: CliCommandContext): void {
|
|
14
|
+
ctx.out.log("");
|
|
15
|
+
ctx.out.log(" Codemods (kumiko codemod <name> [dir...] [--write | --check]):");
|
|
16
|
+
for (const name of CODEMODS) ctx.out.log(` ${name}`);
|
|
17
|
+
ctx.out.log("");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function runCodemod(ctx: CliCommandContext): Promise<number> {
|
|
21
|
+
const name = ctx.argv[0];
|
|
22
|
+
if (name === undefined) {
|
|
23
|
+
printList(ctx);
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
if (!isCodemodName(name)) {
|
|
27
|
+
ctx.out.err(` unknown codemod "${name}".`);
|
|
28
|
+
printList(ctx);
|
|
29
|
+
return 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const rest = ctx.argv.slice(1);
|
|
33
|
+
const dirs = rest.filter((arg) => !arg.startsWith("--"));
|
|
34
|
+
const flags = rest.filter((arg) => arg.startsWith("--"));
|
|
35
|
+
// Unlike the bare script, which writes without a flag, the command previews unless asked.
|
|
36
|
+
const modeFlags = flags.some((flag) => MODE_FLAGS.some((mode) => mode === flag))
|
|
37
|
+
? flags
|
|
38
|
+
: [...flags, "--dry-run"];
|
|
39
|
+
|
|
40
|
+
const { resolveCodemodScript } = await import("@cosmicdrift/kumiko-framework/upgrade-cli");
|
|
41
|
+
const scriptField = `scripts/codemod/${name}.ts`;
|
|
42
|
+
// The project's own install wins; the framework next to this CLI is the fallback.
|
|
43
|
+
const script =
|
|
44
|
+
resolveCodemodScript(ctx.cwd, scriptField) ??
|
|
45
|
+
resolveCodemodScript(import.meta.dir, scriptField);
|
|
46
|
+
if (script === null) {
|
|
47
|
+
ctx.out.err(
|
|
48
|
+
" Codemod script not found. Install @cosmicdrift/kumiko-framework in this project.",
|
|
49
|
+
);
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const proc = Bun.spawn({
|
|
54
|
+
cmd: ["bun", script, ...(dirs.length > 0 ? dirs : ["."]), ...modeFlags],
|
|
55
|
+
cwd: ctx.cwd,
|
|
56
|
+
stdout: "pipe",
|
|
57
|
+
stderr: "pipe",
|
|
58
|
+
});
|
|
59
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
60
|
+
new Response(proc.stdout).text(),
|
|
61
|
+
new Response(proc.stderr).text(),
|
|
62
|
+
proc.exited,
|
|
63
|
+
]);
|
|
64
|
+
for (const line of stdout.split("\n").filter((l) => l !== "")) ctx.out.log(line);
|
|
65
|
+
for (const line of stderr.split("\n").filter((l) => l !== "")) ctx.out.err(line);
|
|
66
|
+
return exitCode;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const codemodCommand: CliCommand = {
|
|
70
|
+
id: "codemod",
|
|
71
|
+
description: "Run a framework codemod over your sources (preview unless --write)",
|
|
72
|
+
help: [
|
|
73
|
+
"Usage: kumiko codemod [name] [dir...] [--write | --check]",
|
|
74
|
+
"",
|
|
75
|
+
"Without a name, lists the codemods. With a name, runs it over each dir (default: cwd).",
|
|
76
|
+
"Previews by default; --write rewrites the files, --check exits 1 while sites are left.",
|
|
77
|
+
"`kumiko-upgrade --apply` runs the codemods a release requires; use this one for the rest.",
|
|
78
|
+
].join("\n"),
|
|
79
|
+
run: runCodemod,
|
|
80
|
+
};
|
package/src/commands/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { agentCommand } from "./agent";
|
|
2
2
|
import { checkCommand } from "./check";
|
|
3
|
+
import { codemodCommand } from "./codemod";
|
|
3
4
|
import { consumerCommand } from "./consumer";
|
|
4
5
|
import { handbuchCommand } from "./handbuch";
|
|
5
6
|
import { opsCommand } from "./ops";
|
|
@@ -10,6 +11,7 @@ import type { CliCommand } from "./types";
|
|
|
10
11
|
|
|
11
12
|
export const APP_COMMANDS: ReadonlyArray<CliCommand> = [
|
|
12
13
|
checkCommand,
|
|
14
|
+
codemodCommand,
|
|
13
15
|
syncManagedCommand,
|
|
14
16
|
portsCommand,
|
|
15
17
|
agentCommand,
|
|
@@ -35,6 +37,7 @@ export type { CliCommand, CliCommandContext } from "./types";
|
|
|
35
37
|
export {
|
|
36
38
|
agentCommand,
|
|
37
39
|
checkCommand,
|
|
40
|
+
codemodCommand,
|
|
38
41
|
consumerCommand,
|
|
39
42
|
handbuchCommand,
|
|
40
43
|
opsCommand,
|