@ykdz/template 0.0.3 → 0.0.5
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/README.md +1 -1
- package/dist/src/cli.d.ts +0 -1
- package/dist/src/cli.js +26 -2
- package/dist/src/declarations.d.ts +38 -3
- package/dist/src/declarations.js +75 -36
- package/dist/src/dependency-catalog.d.ts +9 -1
- package/dist/src/dependency-catalog.js +69 -0
- package/dist/src/devcontainer.d.ts +49 -9
- package/dist/src/devcontainer.js +192 -14
- package/dist/src/editor-customization.d.ts +0 -1
- package/dist/src/editor-customization.js +54 -47
- package/dist/src/generation-context.d.ts +0 -1
- package/dist/src/generation-context.js +4 -1
- package/dist/src/module-graph.d.ts +8 -5
- package/dist/src/module-graph.js +20 -2
- package/dist/src/next-step-instructions.d.ts +0 -1
- package/dist/src/next-step-instructions.js +35 -0
- package/dist/src/package-addition-support.d.ts +5 -0
- package/dist/src/package-addition-support.js +4 -0
- package/dist/src/package-addition.d.ts +2 -1
- package/dist/src/package-addition.js +557 -55
- package/dist/src/package-linking.d.ts +55 -0
- package/dist/src/package-linking.js +116 -0
- package/dist/src/preset-projection.d.ts +4 -2
- package/dist/src/project-github.d.ts +3 -2
- package/dist/src/project-github.js +24 -6
- package/dist/src/renderer.d.ts +16 -2
- package/dist/src/renderer.js +96 -12
- package/dist/src/runtime-paths.d.ts +0 -1
- package/dist/src/template-boundary-check.d.ts +34 -0
- package/dist/src/template-boundary-check.js +448 -0
- package/dist/src/toolchain-resolution.d.ts +0 -1
- package/dist/templates/hono-api/projection.d.ts +2 -3
- package/dist/templates/hono-api/projection.js +258 -76
- package/dist/templates/projection-plans.d.ts +0 -1
- package/dist/templates/registry.d.ts +0 -1
- package/dist/templates/registry.js +5 -2
- package/dist/templates/rust-bin/projection.d.ts +2 -3
- package/dist/templates/rust-bin/projection.js +171 -53
- package/dist/templates/ts-lib/projection.d.ts +2 -3
- package/dist/templates/ts-lib/projection.js +251 -87
- package/dist/templates/vue-app/projection.d.ts +2 -3
- package/dist/templates/vue-app/projection.js +266 -94
- package/dist/templates/vue-hono-app/projection.d.ts +0 -1
- package/dist/templates/vue-hono-app/projection.js +232 -108
- package/package.json +10 -5
- package/pnpm-workspace.yaml +1 -0
- package/templates/hono-api/.github/dependabot.yml +13 -0
- package/templates/hono-api/src/server.ts +1 -1
- package/templates/hono-api/test/app.test.ts +1 -1
- package/templates/rust-bin/.github/dependabot.yml +18 -1
- package/templates/rust-bin/rust-toolchain.toml +3 -0
- package/templates/rust-bin/rustfmt.toml +2 -0
- package/templates/shared/devcontainer/browser-test.Dockerfile +2 -0
- package/templates/shared/devcontainer/node-pnpm.Dockerfile +6 -0
- package/templates/shared/devcontainer/rust.Dockerfile +16 -0
- package/templates/shared/editor-customization/capabilities.json +56 -0
- package/templates/ts-lib/.github/dependabot.yml +13 -0
- package/templates/ts-lib/src/index.ts +5 -1
- package/templates/ts-lib/src/name-schema.ts +3 -0
- package/templates/vue-app/.github/dependabot.yml +13 -0
- package/templates/vue-app/.github/workflows/check.yml +1 -1
- package/templates/vue-app/src/App.vue +1 -1
- package/templates/vue-app/test/app.test.ts +1 -1
- package/templates/vue-hono-app/.github/dependabot.yml +13 -0
- package/templates/vue-hono-app/web/src/App.vue +2 -2
- package/templates/vue-hono-app/web/test/app.test.ts +1 -1
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/declarations.d.ts.map +0 -1
- package/dist/src/dependency-catalog.d.ts.map +0 -1
- package/dist/src/devcontainer.d.ts.map +0 -1
- package/dist/src/editor-customization.d.ts.map +0 -1
- package/dist/src/generation-context.d.ts.map +0 -1
- package/dist/src/module-graph.d.ts.map +0 -1
- package/dist/src/next-step-instructions.d.ts.map +0 -1
- package/dist/src/package-addition.d.ts.map +0 -1
- package/dist/src/preset-projection.d.ts.map +0 -1
- package/dist/src/project-github.d.ts.map +0 -1
- package/dist/src/renderer.d.ts.map +0 -1
- package/dist/src/runtime-paths.d.ts.map +0 -1
- package/dist/src/toolchain-resolution.d.ts.map +0 -1
- package/dist/templates/hono-api/projection.d.ts.map +0 -1
- package/dist/templates/projection-plans.d.ts.map +0 -1
- package/dist/templates/registry.d.ts.map +0 -1
- package/dist/templates/rust-bin/projection.d.ts.map +0 -1
- package/dist/templates/ts-lib/projection.d.ts.map +0 -1
- package/dist/templates/vue-app/projection.d.ts.map +0 -1
- package/dist/templates/vue-hono-app/projection.d.ts.map +0 -1
- package/templates/hono-api/projection.ts +0 -453
- package/templates/projection-plans.ts +0 -135
- package/templates/registry.ts +0 -59
- package/templates/rust-bin/projection.ts +0 -346
- package/templates/ts-lib/projection.ts +0 -454
- package/templates/vue-app/projection.ts +0 -687
- package/templates/vue-hono-app/projection.ts +0 -669
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
|
-
import type {
|
|
6
|
-
BuiltInPreset,
|
|
7
|
-
ProjectBlueprint,
|
|
8
|
-
} from "../../src/declarations.js";
|
|
9
|
-
import { devcontainerNodeFeature } from "../../src/devcontainer.js";
|
|
10
|
-
import { editorCustomizationForCapabilities } from "../../src/editor-customization.js";
|
|
11
|
-
import type { GenerationContext } from "../../src/generation-context.js";
|
|
12
|
-
import {
|
|
13
|
-
type CheckPlan,
|
|
14
|
-
type ComponentOwner,
|
|
15
|
-
type FixPlan,
|
|
16
|
-
renderFixCommand,
|
|
17
|
-
renderRootCheckCommand,
|
|
18
|
-
} from "../../src/module-graph.js";
|
|
19
|
-
import type {
|
|
20
|
-
PresetProjection,
|
|
21
|
-
PresetProjectionPlan,
|
|
22
|
-
} from "../../src/preset-projection.js";
|
|
23
|
-
import {
|
|
24
|
-
projectCheckWorkflow,
|
|
25
|
-
projectDependabotConfig,
|
|
26
|
-
type DependencyMaintenancePolicy,
|
|
27
|
-
} from "../../src/project-github.js";
|
|
28
|
-
import { renderNewProject, type RenderOperation } from "../../src/renderer.js";
|
|
29
|
-
|
|
30
|
-
const generatedBy = {
|
|
31
|
-
packageName: "@ykdz/template",
|
|
32
|
-
version: "0.0.0",
|
|
33
|
-
command: "template init --preset rust-bin",
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const rustBinPresetMetadata: BuiltInPreset = {
|
|
37
|
-
name: "rust-bin",
|
|
38
|
-
title: "Rust binary",
|
|
39
|
-
description:
|
|
40
|
-
"Single-package Rust native binary with rustfmt, clippy, and cargo tests.",
|
|
41
|
-
generation: "supported",
|
|
42
|
-
supportedPackageManagers: ["pnpm"],
|
|
43
|
-
supportedProjectKinds: ["single-package"],
|
|
44
|
-
features: [
|
|
45
|
-
"root-check",
|
|
46
|
-
"fix-command",
|
|
47
|
-
"devcontainer",
|
|
48
|
-
"github-actions",
|
|
49
|
-
"dependabot",
|
|
50
|
-
"rustfmt-clippy",
|
|
51
|
-
"cargo-test",
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const dependencyMaintenancePolicy: DependencyMaintenancePolicy = {
|
|
56
|
-
ecosystems: ["npm", "cargo", "github-actions"],
|
|
57
|
-
interval: "weekly",
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const rustPackageBoundary: ComponentOwner = {
|
|
61
|
-
kind: "package-boundary",
|
|
62
|
-
path: ".",
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
function cargoPackageNameFromProjectName(projectName: string): string {
|
|
66
|
-
const slug = projectName
|
|
67
|
-
.normalize("NFKD")
|
|
68
|
-
.replace(/[\u0300-\u036f]/g, "")
|
|
69
|
-
.toLowerCase()
|
|
70
|
-
.replace(/[^a-z0-9]+/g, "-")
|
|
71
|
-
.replace(/^-+|-+$/g, "");
|
|
72
|
-
|
|
73
|
-
return slug || "rust-bin";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function planRustBinChecks(): CheckPlan {
|
|
77
|
-
return {
|
|
78
|
-
components: [
|
|
79
|
-
{ kind: "rustfmt-check", owner: rustPackageBoundary },
|
|
80
|
-
{ kind: "cargo-clippy", owner: rustPackageBoundary },
|
|
81
|
-
{ kind: "cargo-test", owner: rustPackageBoundary },
|
|
82
|
-
],
|
|
83
|
-
environmentNeeds: [],
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function planRustBinFixes(): FixPlan {
|
|
88
|
-
return {
|
|
89
|
-
components: [{ kind: "rustfmt-write", owner: rustPackageBoundary }],
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function rustBinBlueprint(): ProjectBlueprint {
|
|
94
|
-
return {
|
|
95
|
-
schemaVersion: 1,
|
|
96
|
-
preset: "rust-bin",
|
|
97
|
-
packageManager: "pnpm",
|
|
98
|
-
projectKind: "single-package",
|
|
99
|
-
features: [...rustBinPresetMetadata.features],
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function projectRustBinPackageScripts(): Record<string, string> {
|
|
104
|
-
return {
|
|
105
|
-
check: renderRootCheckCommand(planRustBinChecks()),
|
|
106
|
-
fix: renderFixCommand(planRustBinFixes()),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function cargoToml(projectName: string): string {
|
|
111
|
-
return [
|
|
112
|
-
"[package]",
|
|
113
|
-
`name = "${projectName}"`,
|
|
114
|
-
'version = "0.1.0"',
|
|
115
|
-
'edition = "2024"',
|
|
116
|
-
"",
|
|
117
|
-
"[dependencies]",
|
|
118
|
-
"",
|
|
119
|
-
"[lints]",
|
|
120
|
-
"workspace = true",
|
|
121
|
-
"",
|
|
122
|
-
"[workspace]",
|
|
123
|
-
'members = ["."]',
|
|
124
|
-
'resolver = "3"',
|
|
125
|
-
"",
|
|
126
|
-
"[workspace.lints.rust]",
|
|
127
|
-
'unsafe_code = "forbid"',
|
|
128
|
-
"",
|
|
129
|
-
"[workspace.lints.clippy]",
|
|
130
|
-
'all = "deny"',
|
|
131
|
-
'pedantic = "deny"',
|
|
132
|
-
'nursery = "deny"',
|
|
133
|
-
"",
|
|
134
|
-
"[profile.release]",
|
|
135
|
-
'strip = "symbols"',
|
|
136
|
-
'lto = "thin"',
|
|
137
|
-
"codegen-units = 1",
|
|
138
|
-
"",
|
|
139
|
-
].join("\n");
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function cargoLock(projectName: string): string {
|
|
143
|
-
return [
|
|
144
|
-
"# This file is automatically @generated by Cargo.",
|
|
145
|
-
"# It is not intended for manual editing.",
|
|
146
|
-
"version = 4",
|
|
147
|
-
"",
|
|
148
|
-
"[[package]]",
|
|
149
|
-
`name = "${projectName}"`,
|
|
150
|
-
'version = "0.1.0"',
|
|
151
|
-
"",
|
|
152
|
-
].join("\n");
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function packageJson(
|
|
156
|
-
context: GenerationContext,
|
|
157
|
-
projectName: string,
|
|
158
|
-
packageScripts: Record<string, string>,
|
|
159
|
-
): Record<string, unknown> {
|
|
160
|
-
return {
|
|
161
|
-
name: projectName,
|
|
162
|
-
version: "0.0.0",
|
|
163
|
-
private: true,
|
|
164
|
-
scripts: packageScripts,
|
|
165
|
-
engines: {
|
|
166
|
-
node: context.toolchain.nodeLtsMajor.value,
|
|
167
|
-
},
|
|
168
|
-
packageManager: context.toolchain.packageManagerPin.value,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function generationRecord(context: GenerationContext): Record<string, unknown> {
|
|
173
|
-
return {
|
|
174
|
-
...generatedBy,
|
|
175
|
-
toolchain: {
|
|
176
|
-
nodeLtsMajor: context.toolchain.nodeLtsMajor.value,
|
|
177
|
-
packageManagerPin: context.toolchain.packageManagerPin.value,
|
|
178
|
-
source: context.toolchain.source,
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function operationsForRustBin(
|
|
184
|
-
context: GenerationContext,
|
|
185
|
-
projectName: string,
|
|
186
|
-
packageScripts: Record<string, string>,
|
|
187
|
-
checkPlan: CheckPlan,
|
|
188
|
-
): RenderOperation[] {
|
|
189
|
-
const editorCustomization = editorCustomizationForCapabilities([
|
|
190
|
-
"rust-tooling",
|
|
191
|
-
]);
|
|
192
|
-
|
|
193
|
-
return [
|
|
194
|
-
{
|
|
195
|
-
kind: "writeJson",
|
|
196
|
-
to: "package.json",
|
|
197
|
-
value: packageJson(context, projectName, packageScripts),
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
kind: "writeText",
|
|
201
|
-
to: "pnpm-workspace.yaml",
|
|
202
|
-
text: ["packages:", " - .", ""].join("\n"),
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
kind: "writeText",
|
|
206
|
-
to: "Cargo.toml",
|
|
207
|
-
text: cargoToml(projectName),
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
kind: "writeText",
|
|
211
|
-
to: "Cargo.lock",
|
|
212
|
-
text: cargoLock(projectName),
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
kind: "writeText",
|
|
216
|
-
to: "rustfmt.toml",
|
|
217
|
-
text: ['edition = "2024"', "max_width = 100", ""].join("\n"),
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
kind: "writeText",
|
|
221
|
-
to: ".gitignore",
|
|
222
|
-
text: ["target", ".env", ""].join("\n"),
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
kind: "copyFile",
|
|
226
|
-
from: "src/main.rs",
|
|
227
|
-
to: "src/main.rs",
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
kind: "writeJson",
|
|
231
|
-
to: ".project-kit/blueprint.json",
|
|
232
|
-
value: rustBinBlueprint(),
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
kind: "writeJson",
|
|
236
|
-
to: ".project-kit/generated-by.json",
|
|
237
|
-
value: generationRecord(context),
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
kind: "writeJson",
|
|
241
|
-
to: ".devcontainer/devcontainer.json",
|
|
242
|
-
value: {
|
|
243
|
-
name: `${projectName} Rust development`,
|
|
244
|
-
image: "mcr.microsoft.com/devcontainers/rust:1",
|
|
245
|
-
features: devcontainerNodeFeature({
|
|
246
|
-
nodeVersion: context.toolchain.nodeLtsMajor.value,
|
|
247
|
-
packageManagerPin: context.toolchain.packageManagerPin.value,
|
|
248
|
-
}),
|
|
249
|
-
mounts: [
|
|
250
|
-
"source=${localWorkspaceFolderBasename}-cargo-registry,target=/usr/local/cargo/registry,type=volume",
|
|
251
|
-
"source=${localWorkspaceFolderBasename}-cargo-git,target=/usr/local/cargo/git,type=volume",
|
|
252
|
-
"source=${localWorkspaceFolderBasename}-target,target=${containerWorkspaceFolder}/target,type=volume",
|
|
253
|
-
],
|
|
254
|
-
customizations: {
|
|
255
|
-
vscode: {
|
|
256
|
-
extensions: editorCustomization.extensions,
|
|
257
|
-
settings: editorCustomization.settings,
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
kind: "writeJson",
|
|
264
|
-
to: ".vscode/extensions.json",
|
|
265
|
-
value: {
|
|
266
|
-
recommendations: editorCustomization.extensions,
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
kind: "writeJson",
|
|
271
|
-
to: ".vscode/settings.json",
|
|
272
|
-
value: editorCustomization.settings,
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
kind: "writeText",
|
|
276
|
-
to: ".github/workflows/check.yml",
|
|
277
|
-
text: projectCheckWorkflow({
|
|
278
|
-
checkPlan,
|
|
279
|
-
environmentPreparation: { rustToolchain: true },
|
|
280
|
-
}),
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
kind: "writeText",
|
|
284
|
-
to: ".github/dependabot.yml",
|
|
285
|
-
text: projectDependabotConfig(dependencyMaintenancePolicy),
|
|
286
|
-
},
|
|
287
|
-
];
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function templateSourceRoot(): string {
|
|
291
|
-
const projectionDir = path.dirname(fileURLToPath(import.meta.url));
|
|
292
|
-
const publishedTemplateRoot = path.join(
|
|
293
|
-
projectionDir,
|
|
294
|
-
"..",
|
|
295
|
-
"..",
|
|
296
|
-
"..",
|
|
297
|
-
"templates",
|
|
298
|
-
"rust-bin",
|
|
299
|
-
);
|
|
300
|
-
|
|
301
|
-
return existsSync(path.join(publishedTemplateRoot, "src", "main.rs"))
|
|
302
|
-
? publishedTemplateRoot
|
|
303
|
-
: projectionDir;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export const rustBinPresetProjection: PresetProjection = {
|
|
307
|
-
metadata: rustBinPresetMetadata,
|
|
308
|
-
blueprint: rustBinBlueprint,
|
|
309
|
-
project(context: GenerationContext): PresetProjectionPlan {
|
|
310
|
-
const checkPlan = planRustBinChecks();
|
|
311
|
-
const fixPlan = planRustBinFixes();
|
|
312
|
-
const packageScripts = projectRustBinPackageScripts();
|
|
313
|
-
const projectName = cargoPackageNameFromProjectName(
|
|
314
|
-
context.projectName.value,
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
return {
|
|
318
|
-
sourceRoot: templateSourceRoot(),
|
|
319
|
-
operations: operationsForRustBin(
|
|
320
|
-
context,
|
|
321
|
-
projectName,
|
|
322
|
-
packageScripts,
|
|
323
|
-
checkPlan,
|
|
324
|
-
),
|
|
325
|
-
checkPlan,
|
|
326
|
-
fixPlan,
|
|
327
|
-
dependencyMaintenancePolicy,
|
|
328
|
-
packageScripts,
|
|
329
|
-
capabilities: {
|
|
330
|
-
rootCheck: true,
|
|
331
|
-
fixCommand: true,
|
|
332
|
-
githubActions: true,
|
|
333
|
-
dependabot: true,
|
|
334
|
-
devcontainer: true,
|
|
335
|
-
},
|
|
336
|
-
};
|
|
337
|
-
},
|
|
338
|
-
async render({ targetDir, plan }): Promise<void> {
|
|
339
|
-
await renderNewProject({
|
|
340
|
-
sourceRoot: plan.sourceRoot,
|
|
341
|
-
sourceRoots: plan.sourceRoots,
|
|
342
|
-
targetRoot: targetDir,
|
|
343
|
-
operations: [...plan.operations],
|
|
344
|
-
});
|
|
345
|
-
},
|
|
346
|
-
};
|