@ykdz/template 0.0.1 → 0.0.2
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/dist/cli.js +66 -89
- package/dist/declarations.js +1 -1
- package/dist/devcontainer.d.ts +17 -0
- package/dist/devcontainer.d.ts.map +1 -0
- package/dist/devcontainer.js +23 -0
- package/dist/generation-context.d.ts +24 -0
- package/dist/generation-context.d.ts.map +1 -0
- package/dist/generation-context.js +12 -0
- package/dist/hono-api.d.ts +1 -0
- package/dist/hono-api.d.ts.map +1 -1
- package/dist/hono-api.js +55 -53
- package/dist/module-graph.d.ts +45 -0
- package/dist/module-graph.d.ts.map +1 -0
- package/dist/module-graph.js +187 -0
- package/dist/next-step-instructions.d.ts +22 -0
- package/dist/next-step-instructions.d.ts.map +1 -0
- package/dist/next-step-instructions.js +99 -0
- package/dist/project-github.d.ts +36 -0
- package/dist/project-github.d.ts.map +1 -0
- package/dist/project-github.js +96 -0
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +0 -3
- package/dist/rust-bin.d.ts +7 -1
- package/dist/rust-bin.d.ts.map +1 -1
- package/dist/rust-bin.js +70 -36
- package/dist/toolchain-resolution.d.ts +35 -0
- package/dist/toolchain-resolution.d.ts.map +1 -0
- package/dist/toolchain-resolution.js +192 -0
- package/dist/ts-lib.d.ts +7 -1
- package/dist/ts-lib.d.ts.map +1 -1
- package/dist/ts-lib.js +87 -54
- package/dist/vue-app.d.ts +1 -0
- package/dist/vue-app.d.ts.map +1 -1
- package/dist/vue-app.js +70 -68
- package/dist/vue-hono-app.d.ts +3 -0
- package/dist/vue-hono-app.d.ts.map +1 -1
- package/dist/vue-hono-app.js +111 -107
- package/package.json +2 -1
- package/templates/rust-bin/.github/dependabot.yml +4 -0
- package/templates/rust-bin/.github/workflows/check.yml +6 -1
- package/dist/post-commands.d.ts +0 -40
- package/dist/post-commands.d.ts.map +0 -1
- package/dist/post-commands.js +0 -154
package/dist/post-commands.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
const postCommandPlanBrand = Symbol("PostCommandPlan");
|
|
4
|
-
const packageManagerPin = "pnpm@10.0.0";
|
|
5
|
-
const nodeReadyCommands = [
|
|
6
|
-
{
|
|
7
|
-
id: "node-enable-corepack",
|
|
8
|
-
label: "Enable Corepack",
|
|
9
|
-
command: "corepack",
|
|
10
|
-
args: ["enable"]
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
id: "node-refresh-package-manager-pin",
|
|
14
|
-
label: "Refresh Package Manager Pin and Install Dependencies",
|
|
15
|
-
command: "corepack",
|
|
16
|
-
args: ["use", packageManagerPin]
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: "node-run-fix",
|
|
20
|
-
label: "Run Fix Command",
|
|
21
|
-
command: "pnpm",
|
|
22
|
-
args: ["run", "fix"]
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
const vueReadyCommand = {
|
|
26
|
-
id: "vue-install-playwright-browsers",
|
|
27
|
-
label: "Install Playwright browser assets",
|
|
28
|
-
command: "pnpm",
|
|
29
|
-
args: ["exec", "playwright", "install", "chromium"]
|
|
30
|
-
};
|
|
31
|
-
const vueHonoReadyCommand = {
|
|
32
|
-
id: "vue-hono-install-playwright-browsers",
|
|
33
|
-
label: "Install Playwright browser assets for web workspace",
|
|
34
|
-
command: "pnpm",
|
|
35
|
-
args: ["--filter", "./apps/web", "exec", "playwright", "install", "chromium"]
|
|
36
|
-
};
|
|
37
|
-
function postCommandsForPreset(options) {
|
|
38
|
-
if (options.preset !== "ts-lib" &&
|
|
39
|
-
options.preset !== "hono-api" &&
|
|
40
|
-
options.preset !== "vue-app" &&
|
|
41
|
-
options.preset !== "vue-hono-app") {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
const commands = [...nodeReadyCommands];
|
|
45
|
-
if (options.preset === "vue-app") {
|
|
46
|
-
commands.push(vueReadyCommand);
|
|
47
|
-
}
|
|
48
|
-
if (options.preset === "vue-hono-app") {
|
|
49
|
-
commands.push(vueHonoReadyCommand);
|
|
50
|
-
}
|
|
51
|
-
return commands.map((command) => ({
|
|
52
|
-
...command,
|
|
53
|
-
cwd: options.targetDir
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
export function planPostCommands(options) {
|
|
57
|
-
const targetDir = path.resolve(options.targetDir);
|
|
58
|
-
const commands = postCommandsForPreset({
|
|
59
|
-
preset: options.preset,
|
|
60
|
-
targetDir
|
|
61
|
-
}).map((command) => Object.freeze(command));
|
|
62
|
-
return Object.freeze({
|
|
63
|
-
preset: options.preset,
|
|
64
|
-
targetDir,
|
|
65
|
-
commands: Object.freeze(commands),
|
|
66
|
-
[postCommandPlanBrand]: true
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
async function defaultExecutor(command) {
|
|
70
|
-
return await new Promise((resolve, reject) => {
|
|
71
|
-
const child = spawn(command.command, [...command.args], {
|
|
72
|
-
cwd: command.cwd,
|
|
73
|
-
stdio: "ignore"
|
|
74
|
-
});
|
|
75
|
-
child.once("error", reject);
|
|
76
|
-
child.once("close", (exitCode) => {
|
|
77
|
-
resolve({ exitCode: exitCode ?? 1 });
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
function isWithinDirectory(parentDir, childPath) {
|
|
82
|
-
const relativePath = path.relative(path.resolve(parentDir), path.resolve(childPath));
|
|
83
|
-
return (relativePath === "" ||
|
|
84
|
-
(!relativePath.startsWith("..") && !path.isAbsolute(relativePath)));
|
|
85
|
-
}
|
|
86
|
-
function sameCommand(left, right) {
|
|
87
|
-
return (left.id === right.id &&
|
|
88
|
-
left.label === right.label &&
|
|
89
|
-
left.command === right.command &&
|
|
90
|
-
left.args.length === right.args.length &&
|
|
91
|
-
left.args.every((arg, index) => arg === right.args[index]) &&
|
|
92
|
-
path.resolve(left.cwd) === path.resolve(right.cwd));
|
|
93
|
-
}
|
|
94
|
-
function validatePostCommandPlan(plan) {
|
|
95
|
-
const expectedCommands = postCommandsForPreset({
|
|
96
|
-
preset: plan.preset,
|
|
97
|
-
targetDir: path.resolve(plan.targetDir)
|
|
98
|
-
});
|
|
99
|
-
const expectedCommandIds = new Set(expectedCommands.map((command) => command.id));
|
|
100
|
-
for (const command of plan.commands) {
|
|
101
|
-
if (!isWithinDirectory(plan.targetDir, command.cwd)) {
|
|
102
|
-
throw new Error(`Post Command cwd must stay within the target directory: ${command.id}`);
|
|
103
|
-
}
|
|
104
|
-
if (!expectedCommandIds.has(command.id)) {
|
|
105
|
-
throw new Error(`Unplanned Post Command: ${command.id}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (plan.commands.length !== expectedCommands.length) {
|
|
109
|
-
throw new Error("Post Command plan must match the complete planned sequence");
|
|
110
|
-
}
|
|
111
|
-
for (const [index, command] of plan.commands.entries()) {
|
|
112
|
-
const expectedCommand = expectedCommands[index];
|
|
113
|
-
if (!expectedCommand || command.id !== expectedCommand.id) {
|
|
114
|
-
throw new Error("Post Command plan must match the complete planned sequence");
|
|
115
|
-
}
|
|
116
|
-
if (!sameCommand(command, expectedCommand)) {
|
|
117
|
-
throw new Error(`Post Command does not match the planned template command: ${command.id}`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export async function runPostCommands(options) {
|
|
122
|
-
const executor = options.executor ?? defaultExecutor;
|
|
123
|
-
const results = [];
|
|
124
|
-
validatePostCommandPlan(options.plan);
|
|
125
|
-
for (const command of options.plan.commands) {
|
|
126
|
-
try {
|
|
127
|
-
const result = await executor(command);
|
|
128
|
-
if (result.exitCode !== 0) {
|
|
129
|
-
results.push({
|
|
130
|
-
command,
|
|
131
|
-
status: "failed",
|
|
132
|
-
exitCode: result.exitCode,
|
|
133
|
-
error: `Post Command failed with exit code ${result.exitCode}: ${command.id}`
|
|
134
|
-
});
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
results.push({ command, status: "run", exitCode: 0 });
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
const exitCode = error instanceof Error && "exitCode" in error && typeof error.exitCode === "number"
|
|
141
|
-
? error.exitCode
|
|
142
|
-
: null;
|
|
143
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
144
|
-
results.push({
|
|
145
|
-
command,
|
|
146
|
-
status: "failed",
|
|
147
|
-
exitCode,
|
|
148
|
-
error: `Post Command failed: ${command.id}: ${message}`
|
|
149
|
-
});
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return results;
|
|
154
|
-
}
|