@openelement/create 1.0.0-alpha.6 → 1.0.0-alpha.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openelement/create",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.7",
4
4
  "type": "module",
5
5
  "main": "./src/cli.js",
6
6
  "types": "./src/cli.d.ts",
package/src/cli.d.ts CHANGED
@@ -1 +1 @@
1
- #!/usr/bin/env -S deno run --allow-read --allow-write
1
+ export {}
package/src/cli.js CHANGED
@@ -1,82 +1,76 @@
1
1
  #!/usr/bin/env -S deno run --allow-read --allow-write
2
+ import { buildTemplates, resolveVersions, validateProjectName } from "./template-builder.js";
3
+ import { createInstallCommand } from "./install-command.js";
4
+ //#region src/cli.ts
2
5
  /**
3
- * @openelement/create - Minimal project scaffold for openElement framework.
4
- *
5
- * The install command this CLI documents is built by ./install-command.ts
6
- * (#1414): usage output, the guides and the homepage all render that one
7
- * string, so the documented command cannot drift from the shipped flags.
8
- *
9
- * openElement Architecture: Keep It Simple, Stupid.
10
- * One template, zero prompts, instant start.
11
- *
12
- * L9: every failure mode exits 1 with one actionable message — never a
13
- * runtime stack trace.
14
- */ import { buildTemplates, resolveVersions, validateProjectName } from './template-builder.js';
15
- import { createInstallCommand } from './install-command.js';
6
+ * @openelement/create - Minimal project scaffold for openElement framework.
7
+ *
8
+ * The install command this CLI documents is built by ./install-command.ts
9
+ * (#1414): usage output, the guides and the homepage all render that one
10
+ * string, so the documented command cannot drift from the shipped flags.
11
+ *
12
+ * openElement Architecture: Keep It Simple, Stupid.
13
+ * One template, zero prompts, instant start.
14
+ *
15
+ * L9: every failure mode exits 1 with one actionable message — never a
16
+ * runtime stack trace.
17
+ */
16
18
  function errorMessage(error) {
17
- return error instanceof Error ? error.message : String(error);
19
+ return error instanceof Error ? error.message : String(error);
18
20
  }
19
21
  function fail(message) {
20
- console.error(`error: ${message}`);
21
- Deno.exit(1);
22
+ console.error(`error: ${message}`);
23
+ Deno.exit(1);
22
24
  }
23
25
  function joinPosix(...parts) {
24
- return parts.join('/').replace(/\/{2,}/g, '/');
26
+ return parts.join("/").replace(/\/{2,}/g, "/");
25
27
  }
26
28
  function dirnameOf(path) {
27
- const normalized = path.replace(/\\+/g, '/');
28
- const idx = normalized.lastIndexOf('/');
29
- if (idx <= 0) return '.';
30
- return path.slice(0, idx);
29
+ const idx = path.replace(/\\+/g, "/").lastIndexOf("/");
30
+ if (idx <= 0) return ".";
31
+ return path.slice(0, idx);
31
32
  }
32
33
  async function main() {
33
- const name = Deno.args[0];
34
- if (!name || name === '--help' || name === '-h') {
35
- console.log(`Usage (Alpha): ${createInstallCommand()}`);
36
- console.log('(a versionless install resolves the stable 0.43 line)');
37
- Deno.exit(name ? 0 : 1);
38
- }
39
- const invalid = validateProjectName(name);
40
- if (invalid) fail(`Invalid project name "${name}". ${invalid}`);
41
- const cwd = Deno.cwd().replace(/\/+$/, '');
42
- const targetDir = `${cwd}/${name}`;
43
- const relativeTarget = name;
44
- if (!relativeTarget || relativeTarget.includes('..') || relativeTarget.includes('/') || relativeTarget.includes('\\') || /^[a-zA-Z]:/.test(relativeTarget) || relativeTarget.startsWith('/')) {
45
- fail(`Refusing to create project outside the current directory: ${name}`);
46
- }
47
- try {
48
- await Deno.stat(targetDir);
49
- fail(`Directory "${name}" already exists. Choose a different name or remove the existing directory.`);
50
- } catch (error) {
51
- if (!(error instanceof Deno.errors.NotFound)) {
52
- throw new Error(`Could not inspect target directory "${name}": ${errorMessage(error)}`);
53
- }
54
- }
55
- const v = resolveVersions();
56
- try {
57
- await Deno.mkdir(targetDir, {
58
- recursive: true
59
- });
60
- const TPL = await buildTemplates(v, name);
61
- for (const [path, content] of Object.entries(TPL)){
62
- const fullPath = joinPosix(targetDir, path);
63
- await Deno.mkdir(dirnameOf(fullPath), {
64
- recursive: true
65
- });
66
- await Deno.writeTextFile(fullPath, content);
67
- console.info(` created ${path}`);
68
- }
69
- } catch (error) {
70
- const detail = error instanceof Deno.errors.PermissionDenied ? `Permission denied. Check write permissions for ${targetDir}.` : errorMessage(error);
71
- throw new Error(`Failed to write project files in "${name}": ${detail} ` + 'Remove the partially created directory before retrying.');
72
- }
73
- console.info(`\nopenElement project created at ./${relativeTarget}/`);
74
- console.info(`\n cd ${relativeTarget}`);
75
- console.info(' deno task dev');
76
- console.info(' See README.md for all tasks (check/build/start/preview)');
34
+ const name = Deno.args[0];
35
+ if (!name || name === "--help" || name === "-h") {
36
+ console.log(`Usage (Alpha): ${createInstallCommand()}`);
37
+ console.log("(a versionless install resolves the stable 0.43 line)");
38
+ Deno.exit(name ? 0 : 1);
39
+ }
40
+ const invalid = validateProjectName(name);
41
+ if (invalid) fail(`Invalid project name "${name}". ${invalid}`);
42
+ const targetDir = `${Deno.cwd().replace(/\/+$/, "")}/${name}`;
43
+ const relativeTarget = name;
44
+ if (!relativeTarget || relativeTarget.includes("..") || relativeTarget.includes("/") || relativeTarget.includes("\\") || /^[a-zA-Z]:/.test(relativeTarget) || relativeTarget.startsWith("/")) fail(`Refusing to create project outside the current directory: ${name}`);
45
+ try {
46
+ await Deno.stat(targetDir);
47
+ fail(`Directory "${name}" already exists. Choose a different name or remove the existing directory.`);
48
+ } catch (error) {
49
+ if (!(error instanceof Deno.errors.NotFound)) throw new Error(`Could not inspect target directory "${name}": ${errorMessage(error)}`);
50
+ }
51
+ const v = resolveVersions();
52
+ try {
53
+ await Deno.mkdir(targetDir, { recursive: true });
54
+ const TPL = await buildTemplates(v, name);
55
+ for (const [path, content] of Object.entries(TPL)) {
56
+ const fullPath = joinPosix(targetDir, path);
57
+ await Deno.mkdir(dirnameOf(fullPath), { recursive: true });
58
+ await Deno.writeTextFile(fullPath, content);
59
+ console.info(` created ${path}`);
60
+ }
61
+ } catch (error) {
62
+ const detail = error instanceof Deno.errors.PermissionDenied ? `Permission denied. Check write permissions for ${targetDir}.` : errorMessage(error);
63
+ throw new Error(`Failed to write project files in "${name}": ${detail} Remove the partially created directory before retrying.`);
64
+ }
65
+ console.info(`\nopenElement project created at ./${relativeTarget}/`);
66
+ console.info(`\n cd ${relativeTarget}`);
67
+ console.info(" deno task dev");
68
+ console.info(" See README.md for all tasks (check/build/start/preview)");
77
69
  }
78
70
  try {
79
- await main();
71
+ await main();
80
72
  } catch (error) {
81
- fail(errorMessage(error));
73
+ fail(errorMessage(error));
82
74
  }
75
+ //#endregion
76
+ export {};
@@ -1,3 +1,4 @@
1
+ //#region src/install-command.d.ts
1
2
  /**
2
3
  * The canonical install command — the ONE source every documented copy of it
3
4
  * derives from (#1414 item 5).
@@ -11,8 +12,11 @@
11
12
  *
12
13
  * This module is deliberately side-effect free (no top-level CLI execution, no
13
14
  * Deno APIs): it is imported by the site build as well as by the CLI itself.
14
- */ /** The npm specifier the generator is published under. */ export declare const CREATE_PACKAGE_SPECIFIER: 'npm:@openelement/create';
15
- /** The dist-tag the documented install resolves; the exact version is registry truth. */ export declare const CREATE_INSTALL_TAG: 'alpha';
15
+ */
16
+ /** The npm specifier the generator is published under. */
17
+ export declare const CREATE_PACKAGE_SPECIFIER = "npm:@openelement/create";
18
+ /** The dist-tag the documented install resolves; the exact version is registry truth. */
19
+ export declare const CREATE_INSTALL_TAG = "alpha";
16
20
  /**
17
21
  * Deno permissions the bootstrap needs. Owner ruling 2026-09-21: the
18
22
  * documented command uses bare `-A` — the consumer scaffolds their own
@@ -20,14 +24,18 @@
20
24
  * narrowed the `check-no-allow-all` tripwire to an exact-line exemption for
21
25
  * this command). `--minimum-dependency-age 0` is a functional footnote kept
22
26
  * in prose where needed, not part of the documented shape.
23
- */ export declare const CREATE_INSTALL_PERMISSIONS: readonly string[];
24
- /** Placeholder the usage text and the docs use in place of a project name. */ export declare const CREATE_PROJECT_PLACEHOLDER: '<project-name>';
27
+ */
28
+ export declare const CREATE_INSTALL_PERMISSIONS: readonly string[];
29
+ /** Placeholder the usage text and the docs use in place of a project name. */
30
+ export declare const CREATE_PROJECT_PLACEHOLDER = "<project-name>";
25
31
  /**
26
32
  * Build the canonical install command for `projectName`.
27
33
  *
28
34
  * `projectName` defaults to the placeholder so callers that document the
29
35
  * command shape (usage output) and callers that show a concrete example share
30
36
  * one builder and therefore one flag list.
31
- */ export declare function createInstallCommand(projectName?: string, options?: {
37
+ */
38
+ export declare function createInstallCommand(projectName?: string, options?: {
32
39
  tag?: string;
33
40
  }): string;
41
+ //#endregion
@@ -1,36 +1,43 @@
1
+ //#region src/install-command.ts
1
2
  /**
2
- * The canonical install command — the ONE source every documented copy of it
3
- * derives from (#1414 item 5).
4
- *
5
- * The command is data about this CLI, so it lives beside the CLI: `cli.ts`
6
- * prints it in its usage output, the site's documentation generator inlines it
7
- * into the guides and the homepage, and the install-command gate
8
- * (the site's install-command generator --check) fails when any curated copy
9
- * in the repository differs from this string. There is no second spelling to
10
- * drift.
11
- *
12
- * This module is deliberately side-effect free (no top-level CLI execution, no
13
- * Deno APIs): it is imported by the site build as well as by the CLI itself.
14
- */ /** The npm specifier the generator is published under. */ export const CREATE_PACKAGE_SPECIFIER = 'npm:@openelement/create';
15
- /** The dist-tag the documented install resolves; the exact version is registry truth. */ export const CREATE_INSTALL_TAG = 'alpha';
3
+ * The canonical install command — the ONE source every documented copy of it
4
+ * derives from (#1414 item 5).
5
+ *
6
+ * The command is data about this CLI, so it lives beside the CLI: `cli.ts`
7
+ * prints it in its usage output, the site's documentation generator inlines it
8
+ * into the guides and the homepage, and the install-command gate
9
+ * (the site's install-command generator --check) fails when any curated copy
10
+ * in the repository differs from this string. There is no second spelling to
11
+ * drift.
12
+ *
13
+ * This module is deliberately side-effect free (no top-level CLI execution, no
14
+ * Deno APIs): it is imported by the site build as well as by the CLI itself.
15
+ */
16
+ /** The npm specifier the generator is published under. */
17
+ const CREATE_PACKAGE_SPECIFIER = "npm:@openelement/create";
18
+ /** The dist-tag the documented install resolves; the exact version is registry truth. */
19
+ const CREATE_INSTALL_TAG = "alpha";
16
20
  /**
17
- * Deno permissions the bootstrap needs. Owner ruling 2026-09-21: the
18
- * documented command uses bare `-A` — the consumer scaffolds their own
19
- * project, and the scoped-permission form reads as noise (the same ruling
20
- * narrowed the `check-no-allow-all` tripwire to an exact-line exemption for
21
- * this command). `--minimum-dependency-age 0` is a functional footnote kept
22
- * in prose where needed, not part of the documented shape.
23
- */ export const CREATE_INSTALL_PERMISSIONS = [
24
- String.fromCharCode(45, 65)
25
- ];
26
- /** Placeholder the usage text and the docs use in place of a project name. */ export const CREATE_PROJECT_PLACEHOLDER = '<project-name>';
21
+ * Deno permissions the bootstrap needs. Owner ruling 2026-09-21: the
22
+ * documented command uses bare `-A` — the consumer scaffolds their own
23
+ * project, and the scoped-permission form reads as noise (the same ruling
24
+ * narrowed the `check-no-allow-all` tripwire to an exact-line exemption for
25
+ * this command). `--minimum-dependency-age 0` is a functional footnote kept
26
+ * in prose where needed, not part of the documented shape.
27
+ */
28
+ const CREATE_INSTALL_PERMISSIONS = [String.fromCharCode(45, 65)];
29
+ /** Placeholder the usage text and the docs use in place of a project name. */
30
+ const CREATE_PROJECT_PLACEHOLDER = "<project-name>";
27
31
  /**
28
- * Build the canonical install command for `projectName`.
29
- *
30
- * `projectName` defaults to the placeholder so callers that document the
31
- * command shape (usage output) and callers that show a concrete example share
32
- * one builder and therefore one flag list.
33
- */ export function createInstallCommand(projectName = CREATE_PROJECT_PLACEHOLDER, options = {}) {
34
- const tag = options.tag ?? CREATE_INSTALL_TAG;
35
- return `deno run ${CREATE_INSTALL_PERMISSIONS.join(' ')} ${CREATE_PACKAGE_SPECIFIER}@${tag} ${projectName}`;
32
+ * Build the canonical install command for `projectName`.
33
+ *
34
+ * `projectName` defaults to the placeholder so callers that document the
35
+ * command shape (usage output) and callers that show a concrete example share
36
+ * one builder and therefore one flag list.
37
+ */
38
+ function createInstallCommand(projectName = CREATE_PROJECT_PLACEHOLDER, options = {}) {
39
+ const tag = options.tag ?? "alpha";
40
+ return `deno run ${CREATE_INSTALL_PERMISSIONS.join(" ")} ${CREATE_PACKAGE_SPECIFIER}@${tag} ${projectName}`;
36
41
  }
42
+ //#endregion
43
+ export { CREATE_INSTALL_PERMISSIONS, CREATE_INSTALL_TAG, CREATE_PACKAGE_SPECIFIER, CREATE_PROJECT_PLACEHOLDER, createInstallCommand };
@@ -1,204 +1,89 @@
1
- import { CREATE_VERSION, VITE_STARTER_PIN } from './version.js';
2
- // npm package-name ceiling (validate-npm-package-name); a generated project
3
- // directory must stay a legal package name so `npm init`-style flows and
4
- // registry publication are never blocked by the scaffold itself (L11).
1
+ import { CREATE_VERSION, VITE_STARTER_PIN } from "./version.js";
2
+ //#region src/template-builder.ts
5
3
  const MAX_PROJECT_NAME_LENGTH = 214;
6
4
  const PROJECT_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
7
5
  /**
8
- * L11: validate the scaffold target name before any filesystem work. Returns
9
- * an actionable message when the name is unsafe, `null` when it is a legal
10
- * npm-style package name that cannot escape the current directory.
11
- */ export function validateProjectName(name) {
12
- if (name.length === 0) return 'Project name must not be empty.';
13
- if (name.length > MAX_PROJECT_NAME_LENGTH) {
14
- return `Project name must be at most ${MAX_PROJECT_NAME_LENGTH} characters (npm package-name limit).`;
15
- }
16
- if (name.includes('..')) {
17
- return 'Project name must not contain ".." (path traversal is not allowed).';
18
- }
19
- if (name !== name.toLowerCase()) {
20
- return 'Project name must be lowercase (npm package names cannot contain uppercase letters).';
21
- }
22
- if (!PROJECT_NAME_PATTERN.test(name)) {
23
- return 'Project name must start with a lowercase letter or number and may only contain ' + 'lowercase letters, numbers, dots, underscores, and hyphens.';
24
- }
25
- return null;
6
+ * L11: validate the scaffold target name before any filesystem work. Returns
7
+ * an actionable message when the name is unsafe, `null` when it is a legal
8
+ * npm-style package name that cannot escape the current directory.
9
+ */
10
+ function validateProjectName(name) {
11
+ if (name.length === 0) return "Project name must not be empty.";
12
+ if (name.length > MAX_PROJECT_NAME_LENGTH) return `Project name must be at most ${MAX_PROJECT_NAME_LENGTH} characters (npm package-name limit).`;
13
+ if (name.includes("..")) return "Project name must not contain \"..\" (path traversal is not allowed).";
14
+ if (name !== name.toLowerCase()) return "Project name must be lowercase (npm package names cannot contain uppercase letters).";
15
+ if (!PROJECT_NAME_PATTERN.test(name)) return "Project name must start with a lowercase letter or number and may only contain lowercase letters, numbers, dots, underscores, and hyphens.";
16
+ return null;
26
17
  }
27
18
  /**
28
- * The published starter relies on the support-package same-version release
29
- * invariant. Package-graph and release-prepare gates verify that invariant;
30
- * Create deliberately has no runtime registry fallback or mixed-version mode.
31
- * Caller-supplied versions are validated by `buildTemplates` below.
32
- */ export function resolveVersions() {
33
- return {
34
- router: CREATE_VERSION,
35
- element: CREATE_VERSION
36
- };
19
+ * The published starter relies on the support-package same-version release
20
+ * invariant. Package-graph and release-prepare gates verify that invariant;
21
+ * Create deliberately has no runtime registry fallback or mixed-version mode.
22
+ * Caller-supplied versions are validated by `buildTemplates` below.
23
+ */
24
+ function resolveVersions() {
25
+ return {
26
+ router: CREATE_VERSION,
27
+ element: CREATE_VERSION
28
+ };
37
29
  }
38
- export function assertUnifiedProductVersions(versions) {
39
- const observed = [
40
- ...new Set(Object.values(versions))
41
- ];
42
- if (observed.length !== 1) {
43
- throw new Error(`Create requires the support-package same-version release invariant; observed ${observed.join(', ')}`);
44
- }
45
- return versions;
30
+ function assertUnifiedProductVersions(versions) {
31
+ const observed = [...new Set(Object.values(versions))];
32
+ if (observed.length !== 1) throw new Error(`Create requires the support-package same-version release invariant; observed ${observed.join(", ")}`);
33
+ return versions;
46
34
  }
47
- // [sourceTemplate, targetRelativePath] pairs. The starter manifest is stored
48
- // as deno.json.tmpl so deno does not treat the templates/ directory as a
49
- // nested workspace config; it is renamed to deno.json when written.
50
35
  const TEMPLATE_FILES = [
51
- // npm tarballs omit dotfiles even when a directory is included. Keep the
52
- // template non-hidden and write the expected dotfile into generated apps.
53
- [
54
- 'gitignore.tmpl',
55
- '.gitignore'
56
- ],
57
- [
58
- 'README.tmpl',
59
- 'README.md'
60
- ],
61
- [
62
- 'public/openelement-mark.svg',
63
- 'public/openelement-mark.svg'
64
- ],
65
- [
66
- 'deno.json.tmpl',
67
- 'deno.json'
68
- ],
69
- // package.json carries no runtime npm dependencies: framework consumption
70
- // resolves through the deno.json import map, and packed first-party
71
- // modules carry no bare @std/* specifiers, so no @jsr registry bridge is
72
- // generated. npm is the only public registry.
73
- [
74
- 'package.json.tmpl',
75
- 'package.json'
76
- ],
77
- [
78
- 'vite.config.ts.tmpl',
79
- 'vite.config.ts'
80
- ],
81
- // #1411: framework options live in openelement.config.ts; the starter ships
82
- // it near-empty, so every option comes from a file convention until the user
83
- // overrides one.
84
- [
85
- 'openelement.config.ts.tmpl',
86
- 'openelement.config.ts'
87
- ],
88
- [
89
- 'app/styles/tokens.css',
90
- 'app/styles/tokens.css'
91
- ],
92
- // alpha.4: the structural document-head convention. The config file carries
93
- // the structured `head` channel (title/description/favicon/scripts); this
94
- // module carries what a URL list cannot express (meta tags, preloads).
95
- [
96
- 'app/head.tsx.tmpl',
97
- 'app/head.tsx'
98
- ],
99
- [
100
- 'app/islands/app-shell.tsx.tmpl',
101
- 'app/islands/app-shell.tsx'
102
- ],
103
- [
104
- 'app/components/page-styles.ts.tmpl',
105
- 'app/components/page-styles.ts'
106
- ],
107
- [
108
- 'app/components/page-home.tsx.tmpl',
109
- 'app/components/page-home.tsx'
110
- ],
111
- [
112
- 'app/components/page-freshness.tsx.tmpl',
113
- 'app/components/page-freshness.tsx'
114
- ],
115
- [
116
- 'app/components/page-404.tsx.tmpl',
117
- 'app/components/page-404.tsx'
118
- ],
119
- [
120
- 'app/components/page-contact.tsx.tmpl',
121
- 'app/components/page-contact.tsx'
122
- ],
123
- [
124
- 'app/components/page-blog-index.tsx.tmpl',
125
- 'app/components/page-blog-index.tsx'
126
- ],
127
- [
128
- 'app/components/page-blog-welcome.tsx.tmpl',
129
- 'app/components/page-blog-welcome.tsx'
130
- ],
131
- [
132
- 'app/routes/404.tsx.tmpl',
133
- 'app/routes/404.tsx'
134
- ],
135
- [
136
- 'app/routes/index.tsx.tmpl',
137
- 'app/routes/index.tsx'
138
- ],
139
- [
140
- 'app/routes/freshness.tsx.tmpl',
141
- 'app/routes/freshness.tsx'
142
- ],
143
- [
144
- 'app/routes/contact.tsx.tmpl',
145
- 'app/routes/contact.tsx'
146
- ],
147
- [
148
- 'app/routes/blog/index.tsx.tmpl',
149
- 'app/routes/blog/index.tsx'
150
- ],
151
- [
152
- 'app/routes/blog/welcome.tsx.tmpl',
153
- 'app/routes/blog/welcome.tsx'
154
- ],
155
- [
156
- 'app/routes/api/health.ts.tmpl',
157
- 'app/routes/api/health.ts'
158
- ],
159
- [
160
- 'app/islands/my-counter.tsx.tmpl',
161
- 'app/islands/my-counter.tsx'
162
- ],
163
- [
164
- 'app/islands/only-ticker.tsx.tmpl',
165
- 'app/islands/only-ticker.tsx'
166
- ]
36
+ ["gitignore.tmpl", ".gitignore"],
37
+ ["README.tmpl", "README.md"],
38
+ ["public/openelement-mark.svg", "public/openelement-mark.svg"],
39
+ ["deno.json.tmpl", "deno.json"],
40
+ ["package.json.tmpl", "package.json"],
41
+ ["vite.config.ts.tmpl", "vite.config.ts"],
42
+ ["openelement.config.ts.tmpl", "openelement.config.ts"],
43
+ ["app/styles/tokens.css", "app/styles/tokens.css"],
44
+ ["app/head.tsx.tmpl", "app/head.tsx"],
45
+ ["app/islands/app-shell.tsx.tmpl", "app/islands/app-shell.tsx"],
46
+ ["app/components/page-styles.ts.tmpl", "app/components/page-styles.ts"],
47
+ ["app/components/page-home.tsx.tmpl", "app/components/page-home.tsx"],
48
+ ["app/components/page-freshness.tsx.tmpl", "app/components/page-freshness.tsx"],
49
+ ["app/components/page-404.tsx.tmpl", "app/components/page-404.tsx"],
50
+ ["app/components/page-contact.tsx.tmpl", "app/components/page-contact.tsx"],
51
+ ["app/components/page-blog-index.tsx.tmpl", "app/components/page-blog-index.tsx"],
52
+ ["app/components/page-blog-welcome.tsx.tmpl", "app/components/page-blog-welcome.tsx"],
53
+ ["app/routes/404.tsx.tmpl", "app/routes/404.tsx"],
54
+ ["app/routes/index.tsx.tmpl", "app/routes/index.tsx"],
55
+ ["app/routes/freshness.tsx.tmpl", "app/routes/freshness.tsx"],
56
+ ["app/routes/contact.tsx.tmpl", "app/routes/contact.tsx"],
57
+ ["app/routes/blog/index.tsx.tmpl", "app/routes/blog/index.tsx"],
58
+ ["app/routes/blog/welcome.tsx.tmpl", "app/routes/blog/welcome.tsx"],
59
+ ["app/routes/api/health.ts.tmpl", "app/routes/api/health.ts"],
60
+ ["app/islands/my-counter.tsx.tmpl", "app/islands/my-counter.tsx"],
61
+ ["app/islands/only-ticker.tsx.tmpl", "app/islands/only-ticker.tsx"]
167
62
  ];
168
63
  function versionTokens(v) {
169
- return {
170
- ['$' + '{v.router}']: v.router,
171
- ['$' + '{v.element}']: v.element
172
- };
64
+ return {
65
+ ["${v.router}"]: v.router,
66
+ ["${v.element}"]: v.element
67
+ };
173
68
  }
174
- export async function buildTemplates(v, projectName) {
175
- assertUnifiedProductVersions(v);
176
- const invalid = validateProjectName(projectName);
177
- if (invalid) throw new Error(`Invalid project name "${projectName}". ${invalid}`);
178
- const templatesBase = new URL('../templates/', import.meta.url);
179
- // The starter's Vite pin comes from the workspace-anchored VITE_STARTER_PIN
180
- // (deps:vite-check), not from the product release version.
181
- const tokens = {
182
- ...versionTokens(v),
183
- ['$' + '{v.vite}']: VITE_STARTER_PIN,
184
- ['$' + '{name}']: projectName
185
- };
186
- const entries = await Promise.all(TEMPLATE_FILES.map(async ([source, target])=>{
187
- let content = await Deno.readTextFile(new URL(source, templatesBase));
188
- for (const [token, value] of Object.entries(tokens)){
189
- if (content.includes(token)) content = content.split(token).join(value);
190
- }
191
- if (content.includes('${v.') || content.includes('${name}')) {
192
- throw new Error(`Unresolved scaffold token in starter template: ${source}`);
193
- }
194
- return [
195
- target,
196
- content
197
- ];
198
- }));
199
- // Code-unit comparison (not localeCompare): deterministic across host
200
- // locales and matches the test's toSorted() expectation, including
201
- // uppercase targets like README.md.
202
- entries.sort(([a], [b])=>a < b ? -1 : a > b ? 1 : 0);
203
- return Object.fromEntries(entries);
69
+ async function buildTemplates(v, projectName) {
70
+ assertUnifiedProductVersions(v);
71
+ const invalid = validateProjectName(projectName);
72
+ if (invalid) throw new Error(`Invalid project name "${projectName}". ${invalid}`);
73
+ const templatesBase = new URL("../templates/", import.meta.url);
74
+ const tokens = {
75
+ ...versionTokens(v),
76
+ ["${v.vite}"]: VITE_STARTER_PIN,
77
+ ["${name}"]: projectName
78
+ };
79
+ const entries = await Promise.all(TEMPLATE_FILES.map(async ([source, target]) => {
80
+ let content = await Deno.readTextFile(new URL(source, templatesBase));
81
+ for (const [token, value] of Object.entries(tokens)) if (content.includes(token)) content = content.split(token).join(value);
82
+ if (content.includes("${v.") || content.includes("${name}")) throw new Error(`Unresolved scaffold token in starter template: ${source}`);
83
+ return [target, content];
84
+ }));
85
+ entries.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
86
+ return Object.fromEntries(entries);
204
87
  }
88
+ //#endregion
89
+ export { assertUnifiedProductVersions, buildTemplates, resolveVersions, validateProjectName };
package/src/version.js CHANGED
@@ -1,7 +1,12 @@
1
- /** The published CLI version, embedded so packed npm installs are self-contained. */ export const CREATE_VERSION = '1.0.0-alpha.6';
1
+ //#region src/version.ts
2
+ /** The published CLI version, embedded so packed npm installs are self-contained. */
3
+ const CREATE_VERSION = "1.0.0-alpha.7";
2
4
  /**
3
- * The Vite dev release stamped into the generated starter's import map and
4
- * dev task. Embedded for the same reason as CREATE_VERSION (packed npm
5
- * installs are self-contained); the repository's Vite-pin check anchors this
6
- * copy to the canonical dev pin.
7
- */ export const VITE_STARTER_PIN = '8.0.16';
5
+ * The Vite dev release stamped into the generated starter's import map and
6
+ * dev task. Embedded for the same reason as CREATE_VERSION (packed npm
7
+ * installs are self-contained); the repository's Vite-pin check anchors this
8
+ * copy to the canonical dev pin.
9
+ */
10
+ const VITE_STARTER_PIN = "8.0.16";
11
+ //#endregion
12
+ export { CREATE_VERSION, VITE_STARTER_PIN };