@ykdz/template 0.0.1 → 0.0.3
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/src/cli.d.ts.map +1 -0
- package/dist/{cli.js → src/cli.js} +126 -128
- package/dist/{declarations.d.ts → src/declarations.d.ts} +1 -2
- package/dist/src/declarations.d.ts.map +1 -0
- package/dist/{declarations.js → src/declarations.js} +2 -109
- package/dist/src/dependency-catalog.d.ts +10 -0
- package/dist/src/dependency-catalog.d.ts.map +1 -0
- package/dist/src/dependency-catalog.js +63 -0
- package/dist/src/devcontainer.d.ts +18 -0
- package/dist/src/devcontainer.d.ts.map +1 -0
- package/dist/src/devcontainer.js +24 -0
- package/dist/src/editor-customization.d.ts +13 -0
- package/dist/src/editor-customization.d.ts.map +1 -0
- package/dist/src/editor-customization.js +101 -0
- package/dist/src/generation-context.d.ts +24 -0
- package/dist/src/generation-context.d.ts.map +1 -0
- package/dist/src/generation-context.js +12 -0
- package/dist/src/module-graph.d.ts +31 -0
- package/dist/src/module-graph.d.ts.map +1 -0
- package/dist/src/module-graph.js +48 -0
- package/dist/src/next-step-instructions.d.ts +21 -0
- package/dist/src/next-step-instructions.d.ts.map +1 -0
- package/dist/src/next-step-instructions.js +89 -0
- package/dist/src/package-addition.d.ts.map +1 -0
- package/dist/src/package-addition.js +188 -0
- package/dist/src/preset-projection.d.ts +66 -0
- package/dist/src/preset-projection.d.ts.map +1 -0
- package/dist/src/preset-projection.js +7 -0
- package/dist/src/project-github.d.ts +29 -0
- package/dist/src/project-github.d.ts.map +1 -0
- package/dist/src/project-github.js +63 -0
- package/dist/src/renderer.d.ts.map +1 -0
- package/dist/{renderer.js → src/renderer.js} +0 -3
- package/dist/src/runtime-paths.d.ts +2 -0
- package/dist/src/runtime-paths.d.ts.map +1 -0
- package/dist/src/runtime-paths.js +11 -0
- package/dist/src/toolchain-resolution.d.ts +35 -0
- package/dist/src/toolchain-resolution.d.ts.map +1 -0
- package/dist/src/toolchain-resolution.js +192 -0
- package/dist/templates/hono-api/projection.d.ts +7 -0
- package/dist/templates/hono-api/projection.d.ts.map +1 -0
- package/dist/templates/hono-api/projection.js +377 -0
- package/dist/templates/projection-plans.d.ts +8 -0
- package/dist/templates/projection-plans.d.ts.map +1 -0
- package/dist/templates/projection-plans.js +94 -0
- package/dist/templates/registry.d.ts +8 -0
- package/dist/templates/registry.d.ts.map +1 -0
- package/dist/templates/registry.js +42 -0
- package/dist/templates/rust-bin/projection.d.ts +10 -0
- package/dist/templates/rust-bin/projection.d.ts.map +1 -0
- package/dist/templates/rust-bin/projection.js +282 -0
- package/dist/templates/ts-lib/projection.d.ts +7 -0
- package/dist/templates/ts-lib/projection.d.ts.map +1 -0
- package/dist/templates/ts-lib/projection.js +372 -0
- package/dist/templates/vue-app/projection.d.ts +7 -0
- package/dist/templates/vue-app/projection.d.ts.map +1 -0
- package/dist/templates/vue-app/projection.js +594 -0
- package/dist/templates/vue-hono-app/projection.d.ts +9 -0
- package/dist/templates/vue-hono-app/projection.d.ts.map +1 -0
- package/dist/templates/vue-hono-app/projection.js +589 -0
- package/package.json +30 -24
- package/pnpm-workspace.yaml +34 -0
- package/templates/hono-api/projection.ts +453 -0
- package/templates/projection-plans.ts +135 -0
- package/templates/registry.ts +59 -0
- package/templates/rust-bin/.github/dependabot.yml +4 -0
- package/templates/rust-bin/.github/workflows/check.yml +6 -1
- package/templates/rust-bin/projection.ts +346 -0
- package/templates/ts-lib/projection.ts +454 -0
- package/templates/vue-app/projection.ts +687 -0
- package/templates/vue-app/test/e2e/app.spec.ts +4 -1
- package/templates/vue-hono-app/projection.ts +669 -0
- package/templates/vue-hono-app/web/test/e2e/app.spec.ts +4 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/declarations.d.ts.map +0 -1
- package/dist/hono-api.d.ts +0 -2
- package/dist/hono-api.d.ts.map +0 -1
- package/dist/hono-api.js +0 -208
- package/dist/package-addition.d.ts.map +0 -1
- package/dist/package-addition.js +0 -560
- 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/renderer.d.ts.map +0 -1
- package/dist/rust-bin.d.ts +0 -2
- package/dist/rust-bin.d.ts.map +0 -1
- package/dist/rust-bin.js +0 -174
- package/dist/ts-lib.d.ts +0 -2
- package/dist/ts-lib.d.ts.map +0 -1
- package/dist/ts-lib.js +0 -181
- package/dist/vue-app.d.ts +0 -2
- package/dist/vue-app.d.ts.map +0 -1
- package/dist/vue-app.js +0 -299
- package/dist/vue-hono-app.d.ts +0 -4
- package/dist/vue-hono-app.d.ts.map +0 -1
- package/dist/vue-hono-app.js +0 -436
- package/templates/shared/oxc/package.json +0 -18
- package/templates/shared/oxc/tsconfig.json +0 -11
- /package/dist/{cli.d.ts → src/cli.d.ts} +0 -0
- /package/dist/{package-addition.d.ts → src/package-addition.d.ts} +0 -0
- /package/dist/{renderer.d.ts → src/renderer.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-github.d.ts","sourceRoot":"","sources":["../../src/project-github.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9E,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,uBAAuB,EAAE,OAAO,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,YAAY,EAAE,gBAAgB,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,OAAO,GAAG,gBAAgB,CAAC;AAErE,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC;IACnC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACpE,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;CACpC,CAAC;AAaF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,2BAA2B,GACnC,MAAM,CAmDR;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,2BAA2B,GAClC,MAAM,CAYR"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const defaultCiCapability = {
|
|
2
|
+
workflowName: "Check",
|
|
3
|
+
jobName: "check",
|
|
4
|
+
runner: "ubuntu-latest",
|
|
5
|
+
};
|
|
6
|
+
const pnpmTaskLayer = {
|
|
7
|
+
installCommand: "pnpm install",
|
|
8
|
+
checkCommand: "pnpm run check",
|
|
9
|
+
};
|
|
10
|
+
export function projectCheckWorkflow(options) {
|
|
11
|
+
const capability = options.capability ?? defaultCiCapability;
|
|
12
|
+
const environmentPreparation = {
|
|
13
|
+
nodeFromPackageMetadata: true,
|
|
14
|
+
rustToolchain: false,
|
|
15
|
+
...options.environmentPreparation,
|
|
16
|
+
};
|
|
17
|
+
const taskLayer = options.taskLayer ?? pnpmTaskLayer;
|
|
18
|
+
const lines = [
|
|
19
|
+
`name: ${capability.workflowName}`,
|
|
20
|
+
"",
|
|
21
|
+
"on:",
|
|
22
|
+
" pull_request:",
|
|
23
|
+
" push:",
|
|
24
|
+
" branches:",
|
|
25
|
+
" - main",
|
|
26
|
+
"",
|
|
27
|
+
"jobs:",
|
|
28
|
+
` ${capability.jobName}:`,
|
|
29
|
+
` runs-on: ${capability.runner}`,
|
|
30
|
+
" steps:",
|
|
31
|
+
" - uses: actions/checkout@v6",
|
|
32
|
+
];
|
|
33
|
+
if (environmentPreparation.nodeFromPackageMetadata) {
|
|
34
|
+
lines.push(" - uses: actions/setup-node@v6", " with:", " node-version-file: package.json", " - run: corepack enable");
|
|
35
|
+
}
|
|
36
|
+
if (environmentPreparation.rustToolchain) {
|
|
37
|
+
lines.push(" - uses: dtolnay/rust-toolchain@stable", " with:", " components: rustfmt, clippy", " - uses: Swatinem/rust-cache@v2");
|
|
38
|
+
}
|
|
39
|
+
lines.push(` - run: ${taskLayer.installCommand}`);
|
|
40
|
+
lines.push(...options.checkPlan.environmentNeeds.map((need) => ` - run: ${renderCiEnvironmentNeedCommand(need)}`));
|
|
41
|
+
lines.push(` - run: ${taskLayer.checkCommand}`, "");
|
|
42
|
+
return lines.join("\n");
|
|
43
|
+
}
|
|
44
|
+
export function projectDependabotConfig(policy) {
|
|
45
|
+
return [
|
|
46
|
+
"version: 2",
|
|
47
|
+
"updates:",
|
|
48
|
+
...policy.ecosystems.flatMap((ecosystem) => [
|
|
49
|
+
` - package-ecosystem: ${ecosystem}`,
|
|
50
|
+
" directory: /",
|
|
51
|
+
" schedule:",
|
|
52
|
+
` interval: ${policy.interval}`,
|
|
53
|
+
]),
|
|
54
|
+
"",
|
|
55
|
+
].join("\n");
|
|
56
|
+
}
|
|
57
|
+
function renderCiEnvironmentNeedCommand(need) {
|
|
58
|
+
if (need.kind === "playwright-browser-assets" &&
|
|
59
|
+
need.owner.path === "apps/web") {
|
|
60
|
+
return `pnpm --filter ./apps/web exec playwright install --with-deps ${need.browser}`;
|
|
61
|
+
}
|
|
62
|
+
return `pnpm exec playwright install --with-deps ${need.browser}`;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../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CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAC;AAmfF,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkChF;AAiCD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBnF"}
|
|
@@ -169,9 +169,6 @@ function assertFoundationTextPath(relativePath) {
|
|
|
169
169
|
["Cargo.toml", "Cargo.lock", "rustfmt.toml"].includes(normalizedPath)) {
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
if (normalizedPath === "scripts/check") {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
172
|
if (/^\.github\/workflows\/[A-Za-z0-9._-]+\.ya?ml$/.test(normalizedPath)) {
|
|
176
173
|
return;
|
|
177
174
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-paths.d.ts","sourceRoot":"","sources":["../../src/runtime-paths.ts"],"names":[],"mappings":"AAGA,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,GAAG,QAAQ,EAAE,MAAM,EAAE,GACpB,MAAM,CASR"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export function packageTemplateRoot(moduleDir, ...segments) {
|
|
4
|
+
const candidates = [
|
|
5
|
+
path.join(moduleDir, "..", "..", "templates", ...segments),
|
|
6
|
+
path.join(moduleDir, "..", "templates", ...segments),
|
|
7
|
+
path.join(moduleDir, "..", "..", "..", "templates", ...segments),
|
|
8
|
+
];
|
|
9
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
10
|
+
return found ?? candidates[0];
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type ToolchainResolutionSource = "online" | "bundled-fallback";
|
|
2
|
+
export type NodeLtsMajor = {
|
|
3
|
+
readonly kind: "NodeLtsMajor";
|
|
4
|
+
readonly value: string;
|
|
5
|
+
};
|
|
6
|
+
export type PackageManagerPin = {
|
|
7
|
+
readonly kind: "PackageManagerPin";
|
|
8
|
+
readonly value: `pnpm@${string}`;
|
|
9
|
+
};
|
|
10
|
+
export type ResolvedToolchainVersions = {
|
|
11
|
+
readonly nodeLtsMajor: NodeLtsMajor;
|
|
12
|
+
readonly packageManagerPin: PackageManagerPin;
|
|
13
|
+
readonly source: ToolchainResolutionSource;
|
|
14
|
+
readonly diagnostics: string[];
|
|
15
|
+
};
|
|
16
|
+
export type ResolveToolchainVersionsOptions = {
|
|
17
|
+
readonly source?: ToolchainResolutionSource | "auto";
|
|
18
|
+
readonly fetchJson?: (url: string) => Promise<unknown>;
|
|
19
|
+
readonly nodeReleaseIndexUrl?: string;
|
|
20
|
+
readonly pnpmRegistryUrl?: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const nodeReleaseIndexUrl = "https://nodejs.org/dist/index.json";
|
|
23
|
+
export declare const pnpmRegistryUrl = "https://registry.npmjs.org/pnpm";
|
|
24
|
+
type OnlineToolchainResolutionContractOptions = {
|
|
25
|
+
readonly fetchJson?: (url: string) => Promise<unknown>;
|
|
26
|
+
};
|
|
27
|
+
export type OnlineToolchainResolutionContractResult = {
|
|
28
|
+
readonly nodeLtsMajor: NodeLtsMajor;
|
|
29
|
+
readonly packageManagerPin: PackageManagerPin;
|
|
30
|
+
readonly diagnostics: string[];
|
|
31
|
+
};
|
|
32
|
+
export declare function resolveToolchainVersions(options?: ResolveToolchainVersionsOptions): Promise<ResolvedToolchainVersions>;
|
|
33
|
+
export declare function checkOnlineToolchainResolutionContract(options?: OnlineToolchainResolutionContractOptions): Promise<OnlineToolchainResolutionContractResult>;
|
|
34
|
+
export {};
|
|
35
|
+
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;CACxD,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;CAChC,CAAC;AAmBF,wBAAsB,wBAAwB,CAC5C,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,yBAAyB,CAAC,CAiCpC;AAED,wBAAsB,sCAAsC,CAC1D,OAAO,GAAE,wCAA6C,GACrD,OAAO,CAAC,uCAAuC,CAAC,CAwBlD"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
export const nodeReleaseIndexUrl = "https://nodejs.org/dist/index.json";
|
|
2
|
+
export const pnpmRegistryUrl = "https://registry.npmjs.org/pnpm";
|
|
3
|
+
const bundledFallbackToolchain = {
|
|
4
|
+
nodeLtsMajor: nodeLtsMajor("24"),
|
|
5
|
+
packageManagerPin: packageManagerPin("10.0.0"),
|
|
6
|
+
};
|
|
7
|
+
export async function resolveToolchainVersions(options = {}) {
|
|
8
|
+
const source = options.source ?? "online";
|
|
9
|
+
if (source === "bundled-fallback") {
|
|
10
|
+
return fallbackResult([]);
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const fetchJson = options.fetchJson ?? fetchOfficialJson;
|
|
14
|
+
const nodeReleases = parseNodeReleaseIndex(await fetchJson(options.nodeReleaseIndexUrl ?? nodeReleaseIndexUrl));
|
|
15
|
+
const nodeMajor = latestLtsMajor(nodeReleases);
|
|
16
|
+
const pnpmMetadata = parsePnpmRegistryMetadata(await fetchJson(options.pnpmRegistryUrl ?? pnpmRegistryUrl));
|
|
17
|
+
const pnpmVersion = latestCompatiblePnpmVersion(pnpmMetadata, Number(nodeMajor.value));
|
|
18
|
+
return {
|
|
19
|
+
nodeLtsMajor: nodeMajor,
|
|
20
|
+
packageManagerPin: packageManagerPin(pnpmVersion),
|
|
21
|
+
source: "online",
|
|
22
|
+
diagnostics: [],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
27
|
+
return fallbackResult([
|
|
28
|
+
`Using bundled fallback toolchain metadata because online resolution failed: ${message}`,
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function checkOnlineToolchainResolutionContract(options = {}) {
|
|
33
|
+
const fetchJson = options.fetchJson ?? fetchOfficialJson;
|
|
34
|
+
const nodeMajor = await contractPhase("Node source parsing", async () => {
|
|
35
|
+
const nodeReleases = parseNodeReleaseIndex(await fetchJson(nodeReleaseIndexUrl));
|
|
36
|
+
return latestLtsMajor(nodeReleases);
|
|
37
|
+
});
|
|
38
|
+
const pnpmMetadata = await contractPhase("pnpm source parsing", async () => parsePnpmRegistryMetadata(await fetchJson(pnpmRegistryUrl)));
|
|
39
|
+
const pnpmVersion = await contractPhase("compatibility selection", async () => latestCompatiblePnpmVersion(pnpmMetadata, Number(nodeMajor.value)));
|
|
40
|
+
return {
|
|
41
|
+
nodeLtsMajor: nodeMajor,
|
|
42
|
+
packageManagerPin: packageManagerPin(pnpmVersion),
|
|
43
|
+
diagnostics: [
|
|
44
|
+
`Node source parsing succeeded; latest LTS major is ${nodeMajor.value}.`,
|
|
45
|
+
`pnpm source parsing succeeded; latest compatible pnpm release is ${pnpmVersion}.`,
|
|
46
|
+
`Compatibility selection succeeded for pnpm@${pnpmVersion} on Node ${nodeMajor.value}.`,
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function contractPhase(phase, operation) {
|
|
51
|
+
try {
|
|
52
|
+
return await operation();
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
56
|
+
throw new Error(`Online toolchain resolution contract failed during ${phase}: ${message}`, error instanceof Error ? { cause: error } : undefined);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function fallbackResult(diagnostics) {
|
|
60
|
+
return {
|
|
61
|
+
nodeLtsMajor: bundledFallbackToolchain.nodeLtsMajor,
|
|
62
|
+
packageManagerPin: bundledFallbackToolchain.packageManagerPin,
|
|
63
|
+
source: "bundled-fallback",
|
|
64
|
+
diagnostics,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function nodeLtsMajor(value) {
|
|
68
|
+
if (!/^\d+$/.test(value)) {
|
|
69
|
+
throw new Error(`Invalid Node LTS major: ${value}`);
|
|
70
|
+
}
|
|
71
|
+
return { kind: "NodeLtsMajor", value };
|
|
72
|
+
}
|
|
73
|
+
function packageManagerPin(version) {
|
|
74
|
+
if (!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(version)) {
|
|
75
|
+
throw new Error(`Invalid pnpm version: ${version}`);
|
|
76
|
+
}
|
|
77
|
+
return { kind: "PackageManagerPin", value: `pnpm@${version}` };
|
|
78
|
+
}
|
|
79
|
+
async function fetchOfficialJson(url) {
|
|
80
|
+
const response = await fetch(url, {
|
|
81
|
+
headers: { accept: "application/json" },
|
|
82
|
+
});
|
|
83
|
+
if (!response.ok) {
|
|
84
|
+
throw new Error(`GET ${url} failed with HTTP ${response.status}`);
|
|
85
|
+
}
|
|
86
|
+
return response.json();
|
|
87
|
+
}
|
|
88
|
+
function parseNodeReleaseIndex(value) {
|
|
89
|
+
if (!Array.isArray(value)) {
|
|
90
|
+
throw new Error("Node release index was not an array");
|
|
91
|
+
}
|
|
92
|
+
return value.map((entry) => {
|
|
93
|
+
if (!isRecord(entry)) {
|
|
94
|
+
throw new Error("Node release entry was not an object");
|
|
95
|
+
}
|
|
96
|
+
const version = entry.version;
|
|
97
|
+
const lts = entry.lts;
|
|
98
|
+
if (typeof version !== "string" ||
|
|
99
|
+
(typeof lts !== "string" && typeof lts !== "boolean")) {
|
|
100
|
+
throw new Error("Node release entry is missing version or lts");
|
|
101
|
+
}
|
|
102
|
+
return { version, lts };
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function latestLtsMajor(releases) {
|
|
106
|
+
const majors = releases
|
|
107
|
+
.filter((release) => release.lts !== false)
|
|
108
|
+
.map((release) => release.version.match(/^v(\d+)\./)?.[1])
|
|
109
|
+
.filter((major) => major !== undefined)
|
|
110
|
+
.map(Number);
|
|
111
|
+
if (majors.length === 0) {
|
|
112
|
+
throw new Error("Node release index did not contain any LTS releases");
|
|
113
|
+
}
|
|
114
|
+
return nodeLtsMajor(String(Math.max(...majors)));
|
|
115
|
+
}
|
|
116
|
+
function parsePnpmRegistryMetadata(value) {
|
|
117
|
+
if (!isRecord(value) || !isRecord(value.versions)) {
|
|
118
|
+
throw new Error("pnpm registry metadata is missing versions");
|
|
119
|
+
}
|
|
120
|
+
const versions = {};
|
|
121
|
+
for (const [version, metadata] of Object.entries(value.versions)) {
|
|
122
|
+
if (!isRecord(metadata)) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
versions[version] = {
|
|
126
|
+
engines: isRecord(metadata.engines)
|
|
127
|
+
? {
|
|
128
|
+
node: typeof metadata.engines.node === "string"
|
|
129
|
+
? metadata.engines.node
|
|
130
|
+
: undefined,
|
|
131
|
+
}
|
|
132
|
+
: undefined,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return { versions };
|
|
136
|
+
}
|
|
137
|
+
function latestCompatiblePnpmVersion(metadata, nodeMajor) {
|
|
138
|
+
const candidates = Object.entries(metadata.versions)
|
|
139
|
+
.filter(([version]) => /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(version))
|
|
140
|
+
.filter(([, packageMetadata]) => nodeSatisfiesRange(nodeMajor, packageMetadata.engines?.node))
|
|
141
|
+
.map(([version]) => version)
|
|
142
|
+
.sort(compareSemver);
|
|
143
|
+
const latest = candidates.at(-1);
|
|
144
|
+
if (!latest) {
|
|
145
|
+
throw new Error(`pnpm registry metadata did not contain a release compatible with Node ${nodeMajor}`);
|
|
146
|
+
}
|
|
147
|
+
return latest;
|
|
148
|
+
}
|
|
149
|
+
function nodeSatisfiesRange(nodeMajor, range) {
|
|
150
|
+
if (!range) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
return range
|
|
154
|
+
.split(/\s+/)
|
|
155
|
+
.filter(Boolean)
|
|
156
|
+
.every((comparator) => nodeSatisfiesComparator(nodeMajor, comparator));
|
|
157
|
+
}
|
|
158
|
+
function nodeSatisfiesComparator(nodeMajor, comparator) {
|
|
159
|
+
const match = comparator.match(/^(>=|>|<=|<|=)?(\d+)(?:\.\d+){0,2}$/);
|
|
160
|
+
if (!match) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
const operator = match[1] ?? "=";
|
|
164
|
+
const major = Number(match[2]);
|
|
165
|
+
if (operator === ">=") {
|
|
166
|
+
return nodeMajor >= major;
|
|
167
|
+
}
|
|
168
|
+
if (operator === ">") {
|
|
169
|
+
return nodeMajor > major;
|
|
170
|
+
}
|
|
171
|
+
if (operator === "<=") {
|
|
172
|
+
return nodeMajor <= major;
|
|
173
|
+
}
|
|
174
|
+
if (operator === "<") {
|
|
175
|
+
return nodeMajor < major;
|
|
176
|
+
}
|
|
177
|
+
return nodeMajor === major;
|
|
178
|
+
}
|
|
179
|
+
function compareSemver(left, right) {
|
|
180
|
+
const leftParts = left.split(/[.-]/).slice(0, 3).map(Number);
|
|
181
|
+
const rightParts = right.split(/[.-]/).slice(0, 3).map(Number);
|
|
182
|
+
for (let index = 0; index < 3; index += 1) {
|
|
183
|
+
const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
|
|
184
|
+
if (difference !== 0) {
|
|
185
|
+
return difference;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return left.localeCompare(right);
|
|
189
|
+
}
|
|
190
|
+
function isRecord(value) {
|
|
191
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
192
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BuiltInPreset, ProjectBlueprint } from "../../src/declarations.js";
|
|
2
|
+
import type { PresetProjection } from "../../src/preset-projection.js";
|
|
3
|
+
export declare const honoApiPresetMetadata: BuiltInPreset;
|
|
4
|
+
export declare function honoApiBlueprint(): ProjectBlueprint;
|
|
5
|
+
export declare function projectHonoApiPackageScripts(): Record<string, string>;
|
|
6
|
+
export declare const honoApiPresetProjection: PresetProjection;
|
|
7
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../templates/hono-api/projection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAUnC,OAAO,KAAK,EAGV,gBAAgB,EAEjB,MAAM,gCAAgC,CAAC;AAexC,eAAO,MAAM,qBAAqB,EAAE,aAiBnC,CAAC;AAOF,wBAAgB,gBAAgB,IAAI,gBAAgB,CAQnD;AAED,wBAAgB,4BAA4B,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAarE;AAoUD,eAAO,MAAM,uBAAuB,EAAE,gBA4CrC,CAAC"}
|