@easy-web/cli 0.0.0-stage → 0.0.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/README.md +67 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +218 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-GMXLQJ4E.js +60 -0
- package/dist/chunk-GMXLQJ4E.js.map +1 -0
- package/dist/chunk-TCE4BQ7M.js +31 -0
- package/dist/chunk-TCE4BQ7M.js.map +1 -0
- package/dist/config-FKY2BS4K.js +13 -0
- package/dist/config-FKY2BS4K.js.map +1 -0
- package/dist/run-KXSV4EFL.js +405 -0
- package/dist/run-KXSV4EFL.js.map +1 -0
- package/package.json +44 -4
package/README.md
CHANGED
|
@@ -1,3 +1,68 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @easy-web/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Private Phase-1 create-only CLI. Generation is offline by default; installation is explicit.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
easy-web create --config ./create.json --json
|
|
7
|
+
# Equivalent explicit offline form:
|
|
8
|
+
easy-web create --config ./create.json --no-install
|
|
9
|
+
# Opt in to dependency resolution through pnpm's ambient registry configuration:
|
|
10
|
+
easy-web create --config ./create.json --install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"target": "./new-site",
|
|
16
|
+
"recipes": {
|
|
17
|
+
"shell": { "siteName": "Example Site", "defaultLocale": "en", "noIndex": false },
|
|
18
|
+
"auth": {}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Shell is always selected; omit `auth` or `cms` to exclude them. Recipe options are
|
|
24
|
+
parsed with the package-owned schemas. CMS options use `composition`, `backend`,
|
|
25
|
+
`mediaRoots` and optional `uiLocale`; selecting CMS currently fails before generation
|
|
26
|
+
because both shell and CMS contribute `astro.config.mjs`. Multi-recipe JS config
|
|
27
|
+
merging is not supported in Phase 1. Package dependencies, devDependencies and
|
|
28
|
+
scripts merge additively in resolver order; the later value wins a key collision.
|
|
29
|
+
|
|
30
|
+
Targets must have an existing parent and be nonexistent or empty, including hidden
|
|
31
|
+
and ignored content. Linked paths/junctions and unsafe output paths are rejected.
|
|
32
|
+
An existing clean Git root/worktree with an empty committed HEAD tree and index
|
|
33
|
+
uses a new task branch/worktree; its returned `target` differs from the input, and
|
|
34
|
+
the caller HEAD/index/files are preserved. Fresh targets use isolated staging,
|
|
35
|
+
exclusive publication and one initial commit. Git identity must already be
|
|
36
|
+
available; the CLI never changes Git configuration.
|
|
37
|
+
|
|
38
|
+
Validation checks exact recipe output sets, JSON/JS syntax, package schemas,
|
|
39
|
+
recipe validators, dependency sources and an additions-only allow-listed index.
|
|
40
|
+
Dependency values must be registry-compatible version ranges; URL, Git, local-file
|
|
41
|
+
and workspace sources are rejected before target writes.
|
|
42
|
+
|
|
43
|
+
With no flag or `--no-install`, the CLI does not invoke a package manager or make a
|
|
44
|
+
network request. It commits a deterministic Phase-1 `pnpm-lock.yaml` placeholder
|
|
45
|
+
containing lockfile version/settings and importer specifiers, but no resolved package
|
|
46
|
+
snapshots. This is deliberately not represented as a fully resolved lockfile: run
|
|
47
|
+
`pnpm install` separately before typechecking or building. Missing offline artifacts
|
|
48
|
+
cannot occur with this self-contained placeholder approach, so the reserved exit-4
|
|
49
|
+
scenario is unreachable in Phase 1; a future bundled-metadata resolver must fail with
|
|
50
|
+
exit 4 before writes when its verified artifact is absent.
|
|
51
|
+
|
|
52
|
+
With `--install`, the same source validation and committed generation happen first,
|
|
53
|
+
then the CLI runs `pnpm install` in the returned target. It passes no registry flag or
|
|
54
|
+
hardcoded URL, so pnpm honors the user's ambient `.npmrc`/proxy configuration. The
|
|
55
|
+
install may complete/update the placeholder lockfile after the creation commit.
|
|
56
|
+
Generated-site type/build/E2E checks remain outside this command. Auth files
|
|
57
|
+
are generated as declared; wiring the auth mount and React integration is not
|
|
58
|
+
performed by this composer. Graph JSON and Mermaid are returned in diagnostics,
|
|
59
|
+
not extra generated files. Retain the returned task worktree until human review.
|
|
60
|
+
|
|
61
|
+
Decision, Git rollback boundary and deferred roadmap: ADR 0019 in the websites meta-repo
|
|
62
|
+
(`docs/decisions/0019-create-only-easy-web-cli.md`). Operator summary with a real
|
|
63
|
+
resolved graph diagram: `docs/architecture/create-cli-phase-1.md` there. To undo a
|
|
64
|
+
successful run, remove the returned task worktree and delete its branch; the CLI never
|
|
65
|
+
resets or rewrites history.
|
|
66
|
+
|
|
67
|
+
Exit codes: 0 success, 3 invalid config/target/composition, 4 generation/Git/staging
|
|
68
|
+
failure. `--json` emits versioned diagnostics on stderr and a result on stdout.
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CreateError,
|
|
4
|
+
causeMessage
|
|
5
|
+
} from "./chunk-TCE4BQ7M.js";
|
|
6
|
+
|
|
7
|
+
// src/bin.ts
|
|
8
|
+
import { readFileSync } from "fs";
|
|
9
|
+
|
|
10
|
+
// ../../node_modules/.pnpm/mri@1.2.0/node_modules/mri/lib/index.mjs
|
|
11
|
+
function toArr(any) {
|
|
12
|
+
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
13
|
+
}
|
|
14
|
+
function toVal(out, key, val, opts) {
|
|
15
|
+
var x, old = out[key], nxt = !!~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : !!~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
16
|
+
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
17
|
+
}
|
|
18
|
+
function lib_default(args, opts) {
|
|
19
|
+
args = args || [];
|
|
20
|
+
opts = opts || {};
|
|
21
|
+
var k, arr, arg, name, val, out = { _: [] };
|
|
22
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
23
|
+
const alibi = opts.alias !== void 0;
|
|
24
|
+
const strict = opts.unknown !== void 0;
|
|
25
|
+
const defaults = opts.default !== void 0;
|
|
26
|
+
opts.alias = opts.alias || {};
|
|
27
|
+
opts.string = toArr(opts.string);
|
|
28
|
+
opts.boolean = toArr(opts.boolean);
|
|
29
|
+
if (alibi) {
|
|
30
|
+
for (k in opts.alias) {
|
|
31
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
32
|
+
for (i = 0; i < arr.length; i++) {
|
|
33
|
+
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (i = opts.boolean.length; i-- > 0; ) {
|
|
38
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
39
|
+
for (j = arr.length; j-- > 0; ) opts.boolean.push(arr[j]);
|
|
40
|
+
}
|
|
41
|
+
for (i = opts.string.length; i-- > 0; ) {
|
|
42
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
43
|
+
for (j = arr.length; j-- > 0; ) opts.string.push(arr[j]);
|
|
44
|
+
}
|
|
45
|
+
if (defaults) {
|
|
46
|
+
for (k in opts.default) {
|
|
47
|
+
name = typeof opts.default[k];
|
|
48
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
49
|
+
if (opts[name] !== void 0) {
|
|
50
|
+
opts[name].push(k);
|
|
51
|
+
for (i = 0; i < arr.length; i++) {
|
|
52
|
+
opts[name].push(arr[i]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
58
|
+
for (i = 0; i < len; i++) {
|
|
59
|
+
arg = args[i];
|
|
60
|
+
if (arg === "--") {
|
|
61
|
+
out._ = out._.concat(args.slice(++i));
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
for (j = 0; j < arg.length; j++) {
|
|
65
|
+
if (arg.charCodeAt(j) !== 45) break;
|
|
66
|
+
}
|
|
67
|
+
if (j === 0) {
|
|
68
|
+
out._.push(arg);
|
|
69
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
70
|
+
name = arg.substring(j + 3);
|
|
71
|
+
if (strict && !~keys.indexOf(name)) {
|
|
72
|
+
return opts.unknown(arg);
|
|
73
|
+
}
|
|
74
|
+
out[name] = false;
|
|
75
|
+
} else {
|
|
76
|
+
for (idx = j + 1; idx < arg.length; idx++) {
|
|
77
|
+
if (arg.charCodeAt(idx) === 61) break;
|
|
78
|
+
}
|
|
79
|
+
name = arg.substring(j, idx);
|
|
80
|
+
val = arg.substring(++idx) || (i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i]);
|
|
81
|
+
arr = j === 2 ? [name] : name;
|
|
82
|
+
for (idx = 0; idx < arr.length; idx++) {
|
|
83
|
+
name = arr[idx];
|
|
84
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
|
|
85
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (defaults) {
|
|
90
|
+
for (k in opts.default) {
|
|
91
|
+
if (out[k] === void 0) {
|
|
92
|
+
out[k] = opts.default[k];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (alibi) {
|
|
97
|
+
for (k in out) {
|
|
98
|
+
arr = opts.alias[k] || [];
|
|
99
|
+
while (arr.length > 0) {
|
|
100
|
+
out[arr.shift()] = out[k];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/bin.ts
|
|
108
|
+
var INVALID_INPUT_EXIT_CODE = 3;
|
|
109
|
+
var CREATE_FAILED_EXIT_CODE = 4;
|
|
110
|
+
var HELP = `easy-web - create easy-web sites
|
|
111
|
+
|
|
112
|
+
Usage:
|
|
113
|
+
easy-web create --config <file.json> [--install | --no-install] [--json]
|
|
114
|
+
easy-web --help
|
|
115
|
+
easy-web --version
|
|
116
|
+
|
|
117
|
+
Commands:
|
|
118
|
+
create Generate an empty-target site and one Git commit
|
|
119
|
+
|
|
120
|
+
Options:
|
|
121
|
+
--config JSON configuration (target and recipe options)
|
|
122
|
+
--json Emit machine-readable diagnostics
|
|
123
|
+
--install Run pnpm install after the generated commit (default: false)
|
|
124
|
+
--no-install Explicit alias for the offline default
|
|
125
|
+
-h, --help Show this help message
|
|
126
|
+
-v, --version Show the CLI version`;
|
|
127
|
+
function getVersion() {
|
|
128
|
+
const manifest = JSON.parse(
|
|
129
|
+
readFileSync(new URL("../package.json", import.meta.url), "utf8")
|
|
130
|
+
);
|
|
131
|
+
return manifest.version;
|
|
132
|
+
}
|
|
133
|
+
function writeDiagnostic(diagnostic, json) {
|
|
134
|
+
const output = json ? JSON.stringify(diagnostic) : [diagnostic.message, diagnostic.cause && `Cause: ${diagnostic.cause}`].filter(Boolean).join("\n");
|
|
135
|
+
process.stderr.write(`${output}
|
|
136
|
+
`);
|
|
137
|
+
}
|
|
138
|
+
function fail(diagnostic, json, exitCode) {
|
|
139
|
+
writeDiagnostic(diagnostic, json);
|
|
140
|
+
process.exit(exitCode);
|
|
141
|
+
}
|
|
142
|
+
async function main() {
|
|
143
|
+
const rawArguments = process.argv.slice(2);
|
|
144
|
+
const knownOptions = /* @__PURE__ */ new Set(["--help", "-h", "--version", "-v", "--json", "--config", "--install", "--no-install"]);
|
|
145
|
+
const unknownFlag = rawArguments.find(
|
|
146
|
+
(argument) => argument.startsWith("-") && !knownOptions.has(argument)
|
|
147
|
+
);
|
|
148
|
+
const argv = lib_default(rawArguments, {
|
|
149
|
+
boolean: ["help", "version", "json", "install"],
|
|
150
|
+
string: ["config"],
|
|
151
|
+
alias: { h: "help", v: "version" }
|
|
152
|
+
});
|
|
153
|
+
const json = argv.json === true;
|
|
154
|
+
if (unknownFlag) {
|
|
155
|
+
fail(
|
|
156
|
+
{
|
|
157
|
+
schemaVersion: 1,
|
|
158
|
+
level: "error",
|
|
159
|
+
code: "INVALID_INPUT",
|
|
160
|
+
message: `Unknown option: ${unknownFlag}`
|
|
161
|
+
},
|
|
162
|
+
json,
|
|
163
|
+
INVALID_INPUT_EXIT_CODE
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
if (argv.help) {
|
|
167
|
+
process.stdout.write(`${HELP}
|
|
168
|
+
`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (argv.version) {
|
|
172
|
+
process.stdout.write(`${getVersion()}
|
|
173
|
+
`);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const [command, ...extraArguments] = argv._;
|
|
177
|
+
if (!command) {
|
|
178
|
+
process.stdout.write(`${HELP}
|
|
179
|
+
`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (command !== "create" || extraArguments.length > 0) {
|
|
183
|
+
fail(
|
|
184
|
+
{
|
|
185
|
+
schemaVersion: 1,
|
|
186
|
+
level: "error",
|
|
187
|
+
code: "INVALID_INPUT",
|
|
188
|
+
message: command === "create" ? `Unexpected argument: ${String(extraArguments[0])}` : `Unknown command: ${String(command)}`,
|
|
189
|
+
command: String(command)
|
|
190
|
+
},
|
|
191
|
+
json,
|
|
192
|
+
INVALID_INPUT_EXIT_CODE
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
if (typeof argv.config !== "string" || !argv.config) {
|
|
197
|
+
throw new CreateError("INVALID_INPUT", "create requires --config <file.json>");
|
|
198
|
+
}
|
|
199
|
+
const { readCreateConfig } = await import("./config-FKY2BS4K.js");
|
|
200
|
+
const { createSite } = await import("./run-KXSV4EFL.js");
|
|
201
|
+
const result = await createSite(await readCreateConfig(argv.config), void 0, { install: argv.install === true });
|
|
202
|
+
process.stdout.write(json ? `${JSON.stringify({ schemaVersion: 1, ...result })}
|
|
203
|
+
` : `Created ${result.target}
|
|
204
|
+
Commit: ${result.commit}
|
|
205
|
+
Branch: ${result.branch}
|
|
206
|
+
${result.graphJson}
|
|
207
|
+
${result.graphMermaid}`);
|
|
208
|
+
} catch (error) {
|
|
209
|
+
const diagnostic = error instanceof CreateError ? error : new CreateError("CREATE_FAILED", "Site creation failed", { cause: error });
|
|
210
|
+
fail(
|
|
211
|
+
{ schemaVersion: 1, level: "error", code: diagnostic.code, message: diagnostic.message, cause: causeMessage(diagnostic), command: "create" },
|
|
212
|
+
json,
|
|
213
|
+
diagnostic.code === "INVALID_INPUT" ? INVALID_INPUT_EXIT_CODE : CREATE_FAILED_EXIT_CODE
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
await main();
|
|
218
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bin.ts","../../../node_modules/.pnpm/mri@1.2.0/node_modules/mri/lib/index.mjs"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport mri from 'mri';\nimport { causeMessage, CreateError } from './create/errors.js';\n\nconst INVALID_INPUT_EXIT_CODE = 3;\nconst CREATE_FAILED_EXIT_CODE = 4;\n\nconst HELP = `easy-web - create easy-web sites\n\nUsage:\n easy-web create --config <file.json> [--install | --no-install] [--json]\n easy-web --help\n easy-web --version\n\nCommands:\n create Generate an empty-target site and one Git commit\n\nOptions:\n --config JSON configuration (target and recipe options)\n --json Emit machine-readable diagnostics\n --install Run pnpm install after the generated commit (default: false)\n --no-install Explicit alias for the offline default\n -h, --help Show this help message\n -v, --version Show the CLI version`;\n\ninterface Diagnostic {\n schemaVersion: 1;\n level: 'error';\n code: 'INVALID_INPUT' | 'CREATE_FAILED';\n message: string;\n cause?: string;\n command?: string;\n}\n\ninterface PackageManifest {\n version: string;\n}\n\nfunction getVersion(): string {\n const manifest = JSON.parse(\n readFileSync(new URL('../package.json', import.meta.url), 'utf8'),\n ) as PackageManifest;\n return manifest.version;\n}\n\nfunction writeDiagnostic(diagnostic: Diagnostic, json: boolean): void {\n const output = json\n ? JSON.stringify(diagnostic)\n : [diagnostic.message, diagnostic.cause && `Cause: ${diagnostic.cause}`].filter(Boolean).join('\\n');\n process.stderr.write(`${output}\\n`);\n}\n\nfunction fail(diagnostic: Diagnostic, json: boolean, exitCode: number): never {\n writeDiagnostic(diagnostic, json);\n process.exit(exitCode);\n}\n\nasync function main(): Promise<void> {\n const rawArguments = process.argv.slice(2);\n const knownOptions = new Set(['--help', '-h', '--version', '-v', '--json', '--config', '--install', '--no-install']);\n const unknownFlag = rawArguments.find(\n (argument) => argument.startsWith('-') && !knownOptions.has(argument),\n );\n const argv = mri(rawArguments, {\n boolean: ['help', 'version', 'json', 'install'],\n string: ['config'],\n alias: { h: 'help', v: 'version' },\n });\n const json = argv.json === true;\n\n if (unknownFlag) {\n fail(\n {\n schemaVersion: 1,\n level: 'error',\n code: 'INVALID_INPUT',\n message: `Unknown option: ${unknownFlag}`,\n },\n json,\n INVALID_INPUT_EXIT_CODE,\n );\n }\n\n if (argv.help) {\n process.stdout.write(`${HELP}\\n`);\n return;\n }\n\n if (argv.version) {\n process.stdout.write(`${getVersion()}\\n`);\n return;\n }\n\n const [command, ...extraArguments] = argv._;\n if (!command) {\n process.stdout.write(`${HELP}\\n`);\n return;\n }\n\n if (command !== 'create' || extraArguments.length > 0) {\n fail(\n {\n schemaVersion: 1,\n level: 'error',\n code: 'INVALID_INPUT',\n message:\n command === 'create'\n ? `Unexpected argument: ${String(extraArguments[0])}`\n : `Unknown command: ${String(command)}`,\n command: String(command),\n },\n json,\n INVALID_INPUT_EXIT_CODE,\n );\n }\n\n try {\n if (typeof argv.config !== 'string' || !argv.config) {\n throw new CreateError('INVALID_INPUT', 'create requires --config <file.json>');\n }\n const { readCreateConfig } = await import('./create/config.js');\n const { createSite } = await import('./create/run.js');\n const result = await createSite(await readCreateConfig(argv.config), undefined, { install: argv.install === true });\n process.stdout.write(json\n ? `${JSON.stringify({ schemaVersion: 1, ...result })}\\n`\n : `Created ${result.target}\\nCommit: ${result.commit}\\nBranch: ${result.branch}\\n${result.graphJson}\\n${result.graphMermaid}`);\n } catch (error) {\n const diagnostic = error instanceof CreateError ? error\n : new CreateError('CREATE_FAILED', 'Site creation failed', { cause: error });\n fail({ schemaVersion: 1, level: 'error', code: diagnostic.code, message: diagnostic.message, cause: causeMessage(diagnostic), command: 'create' },\n json, diagnostic.code === 'INVALID_INPUT' ? INVALID_INPUT_EXIT_CODE : CREATE_FAILED_EXIT_CODE);\n }\n}\n\nawait main();\n","function toArr(any) {\n\treturn any == null ? [] : Array.isArray(any) ? any : [any];\n}\n\nfunction toVal(out, key, val, opts) {\n\tvar x, old=out[key], nxt=(\n\t\t!!~opts.string.indexOf(key) ? (val == null || val === true ? '' : String(val))\n\t\t: typeof val === 'boolean' ? val\n\t\t: !!~opts.boolean.indexOf(key) ? (val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val),!!val))\n\t\t: (x = +val,x * 0 === 0) ? x : val\n\t);\n\tout[key] = old == null ? nxt : (Array.isArray(old) ? old.concat(nxt) : [old, nxt]);\n}\n\nexport default function (args, opts) {\n\targs = args || [];\n\topts = opts || {};\n\n\tvar k, arr, arg, name, val, out={ _:[] };\n\tvar i=0, j=0, idx=0, len=args.length;\n\n\tconst alibi = opts.alias !== void 0;\n\tconst strict = opts.unknown !== void 0;\n\tconst defaults = opts.default !== void 0;\n\n\topts.alias = opts.alias || {};\n\topts.string = toArr(opts.string);\n\topts.boolean = toArr(opts.boolean);\n\n\tif (alibi) {\n\t\tfor (k in opts.alias) {\n\t\t\tarr = opts.alias[k] = toArr(opts.alias[k]);\n\t\t\tfor (i=0; i < arr.length; i++) {\n\t\t\t\t(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (i=opts.boolean.length; i-- > 0;) {\n\t\tarr = opts.alias[opts.boolean[i]] || [];\n\t\tfor (j=arr.length; j-- > 0;) opts.boolean.push(arr[j]);\n\t}\n\n\tfor (i=opts.string.length; i-- > 0;) {\n\t\tarr = opts.alias[opts.string[i]] || [];\n\t\tfor (j=arr.length; j-- > 0;) opts.string.push(arr[j]);\n\t}\n\n\tif (defaults) {\n\t\tfor (k in opts.default) {\n\t\t\tname = typeof opts.default[k];\n\t\t\tarr = opts.alias[k] = opts.alias[k] || [];\n\t\t\tif (opts[name] !== void 0) {\n\t\t\t\topts[name].push(k);\n\t\t\t\tfor (i=0; i < arr.length; i++) {\n\t\t\t\t\topts[name].push(arr[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst keys = strict ? Object.keys(opts.alias) : [];\n\n\tfor (i=0; i < len; i++) {\n\t\targ = args[i];\n\n\t\tif (arg === '--') {\n\t\t\tout._ = out._.concat(args.slice(++i));\n\t\t\tbreak;\n\t\t}\n\n\t\tfor (j=0; j < arg.length; j++) {\n\t\t\tif (arg.charCodeAt(j) !== 45) break; // \"-\"\n\t\t}\n\n\t\tif (j === 0) {\n\t\t\tout._.push(arg);\n\t\t} else if (arg.substring(j, j + 3) === 'no-') {\n\t\t\tname = arg.substring(j + 3);\n\t\t\tif (strict && !~keys.indexOf(name)) {\n\t\t\t\treturn opts.unknown(arg);\n\t\t\t}\n\t\t\tout[name] = false;\n\t\t} else {\n\t\t\tfor (idx=j+1; idx < arg.length; idx++) {\n\t\t\t\tif (arg.charCodeAt(idx) === 61) break; // \"=\"\n\t\t\t}\n\n\t\t\tname = arg.substring(j, idx);\n\t\t\tval = arg.substring(++idx) || (i+1 === len || (''+args[i+1]).charCodeAt(0) === 45 || args[++i]);\n\t\t\tarr = (j === 2 ? [name] : name);\n\n\t\t\tfor (idx=0; idx < arr.length; idx++) {\n\t\t\t\tname = arr[idx];\n\t\t\t\tif (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);\n\t\t\t\ttoVal(out, name, (idx + 1 < arr.length) || val, opts);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (defaults) {\n\t\tfor (k in opts.default) {\n\t\t\tif (out[k] === void 0) {\n\t\t\t\tout[k] = opts.default[k];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (alibi) {\n\t\tfor (k in out) {\n\t\t\tarr = opts.alias[k] || [];\n\t\t\twhile (arr.length > 0) {\n\t\t\t\tout[arr.shift()] = out[k];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn out;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,oBAAoB;;;ACA7B,SAAS,MAAM,KAAK;AACnB,SAAO,OAAO,OAAO,CAAC,IAAI,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC1D;AAEA,SAAS,MAAM,KAAK,KAAK,KAAK,MAAM;AACnC,MAAI,GAAG,MAAI,IAAI,GAAG,GAAG,MACpB,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,GAAG,IAAK,OAAO,QAAQ,QAAQ,OAAO,KAAK,OAAO,GAAG,IAC1E,OAAO,QAAQ,YAAY,MAC3B,CAAC,CAAC,CAAC,KAAK,QAAQ,QAAQ,GAAG,IAAK,QAAQ,UAAU,QAAQ,QAAQ,WAAW,IAAI,EAAE,MAAM,IAAI,CAAC,KAAI,IAAI,MAAM,KAAK,IAAI,GAAG,GAAE,CAAC,CAAC,QAC3H,IAAI,CAAC,KAAI,IAAI,MAAM,KAAK,IAAI;AAEhC,MAAI,GAAG,IAAI,OAAO,OAAO,MAAO,MAAM,QAAQ,GAAG,IAAI,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,GAAG;AACjF;AAEe,SAAR,YAAkB,MAAM,MAAM;AACpC,SAAO,QAAQ,CAAC;AAChB,SAAO,QAAQ,CAAC;AAEhB,MAAI,GAAG,KAAK,KAAK,MAAM,KAAK,MAAI,EAAE,GAAE,CAAC,EAAE;AACvC,MAAI,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C/E;AACA,UAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,sBAAoB;AAC9D,UAAM,EAAE,WAAW,IAAI,MAAM,OAAO,mBAAiB;AACrD,UAAM,SAAS,MAAM,WAAW,MAAM,iBAAiB,KAAK,MAAM,GAAG,QAAW,EAAE,SAAS,KAAK,YAAY,KAAK,CAAC;AAClH,YAAQ,OAAO,MAAM,OACjB,GAAG,KAAK,UAAU,EAAE,eAAe,GAAG,GAAG,OAAO,CAAC,CAAC;AAAA,IAClD,WAAW,OAAO,MAAM;AAAA,UAAa,OAAO,MAAM;AAAA,UAAa,OAAO,MAAM;AAAA,EAAK,OAAO,SAAS;AAAA,EAAK,OAAO,YAAY,EAAE;AAAA,EACjI,SAAS,OAAO;AACd,UAAM,aAAa,iBAAiB,cAAc,QAC9C,IAAI,YAAY,iBAAiB,wBAAwB,EAAE,OAAO,MAAM,CAAC;AAC7E;AAAA,MAAK,EAAE,eAAe,GAAG,OAAO,SAAS,MAAM,WAAW,MAAM,SAAS,WAAW,SAAS,OAAO,aAAa,UAAU,GAAG,SAAS,SAAS;AAAA,MAC9I;AAAA,MAAM,WAAW,SAAS,kBAAkB,0BAA0B;AAAA,IAAuB;AAAA,EACjG;AACF;AAEA,MAAM,KAAK;","names":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CreateError,
|
|
4
|
+
invalid
|
|
5
|
+
} from "./chunk-TCE4BQ7M.js";
|
|
6
|
+
|
|
7
|
+
// src/create/config.ts
|
|
8
|
+
import { readFile } from "fs/promises";
|
|
9
|
+
import { z } from "astro/zod";
|
|
10
|
+
import { shellRecipe } from "@easy-web/core/recipes";
|
|
11
|
+
import { authRecipe } from "@easy-web/auth/recipe";
|
|
12
|
+
import { cmsMediaRecipe } from "@easy-web/cms-adapters";
|
|
13
|
+
var configSchema = z.strictObject({
|
|
14
|
+
target: z.string().trim().min(1),
|
|
15
|
+
recipes: z.strictObject({
|
|
16
|
+
shell: shellRecipe.optionsSchema.default(() => shellRecipe.optionsSchema.parse({})),
|
|
17
|
+
auth: authRecipe.optionsSchema.optional(),
|
|
18
|
+
cms: cmsMediaRecipe.optionsSchema.optional()
|
|
19
|
+
}).default(() => ({ shell: shellRecipe.optionsSchema.parse({}) }))
|
|
20
|
+
}).readonly();
|
|
21
|
+
function select(recipe, options) {
|
|
22
|
+
return {
|
|
23
|
+
options,
|
|
24
|
+
recipe: {
|
|
25
|
+
...recipe,
|
|
26
|
+
generate: (context) => recipe.generate({ ...context, options }),
|
|
27
|
+
validators: recipe.validators.map((validator) => ({
|
|
28
|
+
...validator,
|
|
29
|
+
validate: (context) => validator.validate({ ...context, options })
|
|
30
|
+
}))
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function selectionsFor(config) {
|
|
35
|
+
return [
|
|
36
|
+
select(shellRecipe, config.recipes.shell),
|
|
37
|
+
...config.recipes.cms ? [select(cmsMediaRecipe, config.recipes.cms)] : [],
|
|
38
|
+
...config.recipes.auth ? [select(authRecipe, config.recipes.auth)] : []
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
function parseCreateConfig(value) {
|
|
42
|
+
const parsed = configSchema.safeParse(value);
|
|
43
|
+
if (!parsed.success) invalid(`Invalid create config: ${parsed.error.message}`);
|
|
44
|
+
return parsed.data;
|
|
45
|
+
}
|
|
46
|
+
async function readCreateConfig(path) {
|
|
47
|
+
try {
|
|
48
|
+
return parseCreateConfig(JSON.parse(await readFile(path, "utf8")));
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (error instanceof CreateError) throw error;
|
|
51
|
+
throw new CreateError("INVALID_INPUT", `Cannot read create config: ${path}`, { cause: error });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
selectionsFor,
|
|
57
|
+
parseCreateConfig,
|
|
58
|
+
readCreateConfig
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=chunk-GMXLQJ4E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create/config.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { z } from 'astro/zod';\nimport { shellRecipe } from '@easy-web/core/recipes';\nimport { authRecipe } from '@easy-web/auth/recipe';\nimport { cmsMediaRecipe } from '@easy-web/cms-adapters';\nimport type { RecipeMetadata } from '@easy-web/core/recipes';\nimport { CreateError, invalid } from './errors.js';\n\nconst configSchema = z.strictObject({\n target: z.string().trim().min(1),\n recipes: z.strictObject({\n shell: shellRecipe.optionsSchema.default(() => shellRecipe.optionsSchema.parse({})),\n auth: authRecipe.optionsSchema.optional(),\n cms: cmsMediaRecipe.optionsSchema.optional(),\n }).default(() => ({ shell: shellRecipe.optionsSchema.parse({}) })),\n}).readonly();\n\nexport type CreateConfig = z.infer<typeof configSchema>;\n\nexport interface RecipeSelection {\n readonly recipe: RecipeMetadata;\n readonly options: unknown;\n}\n\n// Capture each recipe's typed options at admission; the composer sees one uniform hook type.\nfunction select<Options>(recipe: RecipeMetadata<Options>, options: Options): RecipeSelection {\n return {\n options,\n recipe: {\n ...recipe,\n generate: (context) => recipe.generate({ ...context, options }),\n validators: recipe.validators.map((validator) => ({\n ...validator,\n validate: (context) => validator.validate({ ...context, options }),\n })),\n },\n };\n}\n\nexport function selectionsFor(config: CreateConfig): readonly RecipeSelection[] {\n return [\n select(shellRecipe, config.recipes.shell),\n ...(config.recipes.cms ? [select(cmsMediaRecipe, config.recipes.cms)] : []),\n ...(config.recipes.auth ? [select(authRecipe, config.recipes.auth)] : []),\n ];\n}\n\nexport function parseCreateConfig(value: unknown): CreateConfig {\n const parsed = configSchema.safeParse(value);\n if (!parsed.success) invalid(`Invalid create config: ${parsed.error.message}`);\n return parsed.data;\n}\n\nexport async function readCreateConfig(path: string): Promise<CreateConfig> {\n try {\n return parseCreateConfig(JSON.parse(await readFile(path, 'utf8')));\n } catch (error) {\n if (error instanceof CreateError)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AkB,OAA8B;AAC5D,QAAM,SAAS,aAAa,UAAU,KAAK;AAC3C,MAAI,CAAC,OAAO,QAAS,SAAQ,0BAA0B,OAAO,MAAM,OAAO,EAAE;AAC7E,SAAO,OAAO;AAClB;AAEA,eAAsB,iBAAiB,MAAqC;AACxE,MAAI;AACA,WAAO,kBAAkB,KAAK,MAAM,MAAM,SAAS,MAAM,MAAM,CAAC,CAAC;AAAA,EACrE,SAAS,OAAO;AACZ,QAAI,iBAAiB,YAAa,OAAM;AACxC,UAAM,IAAI,YAAY,iBAAiB,8BAA8B,IAAI,IAAI,EAAE,OAAO,MAAM,CAAC;AAAA,EACjG;AACJ;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/create/errors.ts
|
|
4
|
+
var CreateError = class extends Error {
|
|
5
|
+
constructor(code, message, options) {
|
|
6
|
+
super(message, options);
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.name = "CreateError";
|
|
9
|
+
}
|
|
10
|
+
code;
|
|
11
|
+
};
|
|
12
|
+
function causeMessage(error) {
|
|
13
|
+
const messages = [];
|
|
14
|
+
let cause = error.cause;
|
|
15
|
+
while (cause !== void 0) {
|
|
16
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
17
|
+
if (message) messages.push(message);
|
|
18
|
+
cause = cause instanceof Error ? cause.cause : void 0;
|
|
19
|
+
}
|
|
20
|
+
return messages.length ? messages.join(": ") : void 0;
|
|
21
|
+
}
|
|
22
|
+
function invalid(message) {
|
|
23
|
+
throw new CreateError("INVALID_INPUT", message);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
CreateError,
|
|
28
|
+
causeMessage,
|
|
29
|
+
invalid
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=chunk-TCE4BQ7M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create/errors.ts"],"sourcesContent":["export class CreateError extends Error {\n constructor(\n readonly code: 'INVALID_INPUT' | 'CREATE_FAILED',\n message: string,\n options?: ErrorOptions,\n ) {\n super(message, options);\n this.name = 'CreateError';\n }\n}\n\nexport function causeMessage(error: Error): string | undefined {\n const messages: string[] = [];\n let cause = error.cause;\n while (cause !== undefined) {\n const message = cause instanceof Error ? cause.message : String(cause);\n if (message) messages.push(message);\n cause = cause instanceof Error ? cause.cause : undefined;\n }\n return messages.length ? messages.join(': ') : undefined;\n}\n\nexport function invalid(message: string): never {\n throw new CreateError('INVALID_INPUT', message);\n}\n"],"mappings":";;;AAAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACnC,YACa,MACT,SACA,SACF;AACE,UAAM,SAAS,OAAO;AAJb;AAKT,SAAK,OAAO;AAAA,EAChB;AAAA,EANa;AAOjB;AAEO,SAAS,aAAa,OAAkC;AAC3D,QAAM,WAAqB,CAAC;AAC5B,MAAI,QAAQ,MAAM;AAClB,SAAO,UAAU,QAAW;AACxB,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,QAAI,QAAS,UAAS,KAAK,OAAO;AAClC,YAAQ,iBAAiB,QAAQ,MAAM,QAAQ;AAAA,EACnD;AACA,SAAO,SAAS,SAAS,SAAS,KAAK,IAAI,IAAI;AACnD;AAEO,SAAS,QAAQ,SAAwB;AAC5C,QAAM,IAAI,YAAY,iBAAiB,OAAO;AAClD;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
parseCreateConfig,
|
|
4
|
+
readCreateConfig,
|
|
5
|
+
selectionsFor
|
|
6
|
+
} from "./chunk-GMXLQJ4E.js";
|
|
7
|
+
import "./chunk-TCE4BQ7M.js";
|
|
8
|
+
export {
|
|
9
|
+
parseCreateConfig,
|
|
10
|
+
readCreateConfig,
|
|
11
|
+
selectionsFor
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=config-FKY2BS4K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
selectionsFor
|
|
4
|
+
} from "./chunk-GMXLQJ4E.js";
|
|
5
|
+
import {
|
|
6
|
+
CreateError,
|
|
7
|
+
invalid
|
|
8
|
+
} from "./chunk-TCE4BQ7M.js";
|
|
9
|
+
|
|
10
|
+
// src/create/run.ts
|
|
11
|
+
import { randomUUID } from "crypto";
|
|
12
|
+
import { cp, link, mkdir as mkdir2, mkdtemp, readdir as readdir3, rm, rmdir } from "fs/promises";
|
|
13
|
+
import { dirname as dirname3, join as join2 } from "path";
|
|
14
|
+
|
|
15
|
+
// src/create/compose.ts
|
|
16
|
+
import { z } from "astro/zod";
|
|
17
|
+
import {
|
|
18
|
+
resolveCapabilityGraph,
|
|
19
|
+
toCapabilityGraphDocument,
|
|
20
|
+
serializeCapabilityGraphJson,
|
|
21
|
+
serializeCapabilityGraphMermaid
|
|
22
|
+
} from "@easy-web/core/recipes";
|
|
23
|
+
function outputPath(contribution) {
|
|
24
|
+
const { target } = contribution;
|
|
25
|
+
return contribution.kind === "route" && target.startsWith("/") ? target === "/" ? "src/pages/index.astro" : `src/pages${target}.astro` : target;
|
|
26
|
+
}
|
|
27
|
+
function safeOutputPath(path) {
|
|
28
|
+
const segments = path.split("/");
|
|
29
|
+
if (!path || segments.some((segment) => !segment || segment === "." || segment === ".." || /^\.git$/i.test(segment) || /[\\:*?"<>|]/.test(segment) || [...segment].some((character) => character.charCodeAt(0) < 32) || /[. ]$/.test(segment) || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(segment))) {
|
|
30
|
+
invalid(`Unsafe generated path: ${path}`);
|
|
31
|
+
}
|
|
32
|
+
return path;
|
|
33
|
+
}
|
|
34
|
+
var packageFragmentSchema = z.object({
|
|
35
|
+
dependencies: z.record(z.string(), z.string()).optional(),
|
|
36
|
+
devDependencies: z.record(z.string(), z.string()).optional(),
|
|
37
|
+
scripts: z.record(z.string(), z.string()).optional()
|
|
38
|
+
}).catchall(z.json());
|
|
39
|
+
function mergePackageFragments(fragments) {
|
|
40
|
+
let merged = {};
|
|
41
|
+
for (const fragment of fragments) {
|
|
42
|
+
const parsed = packageFragmentSchema.safeParse(JSON.parse(fragment));
|
|
43
|
+
if (!parsed.success) invalid(`Invalid package.json fragment: ${parsed.error.message}`);
|
|
44
|
+
const previous = packageFragmentSchema.parse(merged);
|
|
45
|
+
merged = { ...merged, ...parsed.data };
|
|
46
|
+
for (const key of ["dependencies", "devDependencies", "scripts"]) {
|
|
47
|
+
if (previous[key] || parsed.data[key]) merged[key] = { ...previous[key], ...parsed.data[key] };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return `${JSON.stringify(merged, null, 2)}
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
async function composeRecipes(selections) {
|
|
54
|
+
const resolved = resolveCapabilityGraph(selections.map(({ recipe }) => recipe));
|
|
55
|
+
if (!resolved.ok) invalid(`Recipe resolution failed: ${JSON.stringify(resolved.error)}`);
|
|
56
|
+
const graph = resolved.value;
|
|
57
|
+
const owners = /* @__PURE__ */ new Map();
|
|
58
|
+
for (const { recipe } of selections) {
|
|
59
|
+
for (const contribution of recipe.outputContributions) {
|
|
60
|
+
const path = safeOutputPath(outputPath(contribution));
|
|
61
|
+
const key = path.toLowerCase();
|
|
62
|
+
if (owners.has(key) && path !== "package.json") {
|
|
63
|
+
if (path === "astro.config.mjs" && contribution.kind === "configuration") {
|
|
64
|
+
invalid("multi-recipe astro.config.mjs merge not yet supported in Phase 1 \u2014 select recipes individually or wait for a future composer");
|
|
65
|
+
}
|
|
66
|
+
invalid(`Shared output is not mergeable: ${path}`);
|
|
67
|
+
}
|
|
68
|
+
owners.set(key, path);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const files = /* @__PURE__ */ new Map();
|
|
72
|
+
const fragments = [];
|
|
73
|
+
for (const node of graph.recipes) {
|
|
74
|
+
const selection = selections.find(({ recipe: recipe2 }) => recipe2.id === node.id);
|
|
75
|
+
if (!selection) invalid(`Missing selected recipe: ${node.id}`);
|
|
76
|
+
const { recipe } = selection;
|
|
77
|
+
const options = recipe.optionsSchema.parse(selection.options);
|
|
78
|
+
const context = { options, capabilities: graph.capabilities.map(({ id }) => id), contributions: recipe.outputContributions };
|
|
79
|
+
for (const validator of recipe.validators.filter(({ phase }) => phase === "options")) {
|
|
80
|
+
const issues = await validator.validate(context);
|
|
81
|
+
if (issues.length) invalid(`Recipe validation failed: ${JSON.stringify(issues)}`);
|
|
82
|
+
}
|
|
83
|
+
const output2 = await recipe.generate(context);
|
|
84
|
+
const declared = recipe.outputContributions.map(outputPath).sort();
|
|
85
|
+
const generated = output2.files.map(({ path }) => safeOutputPath(path)).sort();
|
|
86
|
+
if (new Set(generated).size !== generated.length || JSON.stringify(declared) !== JSON.stringify(generated)) {
|
|
87
|
+
invalid(`Generated files differ from declared contributions: ${recipe.id}`);
|
|
88
|
+
}
|
|
89
|
+
for (const file of output2.files) {
|
|
90
|
+
if (file.path === "package.json") fragments.push(String(file.content));
|
|
91
|
+
else files.set(file.path, file);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (fragments.length) files.set("package.json", { path: "package.json", content: mergePackageFragments(fragments) });
|
|
95
|
+
const output = { files: [...files.values()].sort((a, b) => a.path.localeCompare(b.path, "en")) };
|
|
96
|
+
for (const { recipe, options } of selections) {
|
|
97
|
+
for (const validator of recipe.validators.filter(({ phase }) => phase === "output")) {
|
|
98
|
+
const issues = await validator.validate({ options, capabilities: graph.capabilities.map(({ id }) => id), contributions: recipe.outputContributions, output });
|
|
99
|
+
if (issues.length) invalid(`Recipe validation failed: ${JSON.stringify(issues)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const document = toCapabilityGraphDocument(graph);
|
|
103
|
+
if (!document.ok) invalid(`Graph serialization failed: ${document.error.code}`);
|
|
104
|
+
return { ...output, graphJson: serializeCapabilityGraphJson(document.value), graphMermaid: serializeCapabilityGraphMermaid(document.value) };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/create/git.ts
|
|
108
|
+
import { execFile } from "child_process";
|
|
109
|
+
import { promisify } from "util";
|
|
110
|
+
var execute = promisify(execFile);
|
|
111
|
+
async function git(cwd, args) {
|
|
112
|
+
const env = { ...process.env, GIT_MASTER: "1", GIT_TERMINAL_PROMPT: "0" };
|
|
113
|
+
for (const key of Object.keys(env)) {
|
|
114
|
+
if (key.startsWith("GIT_") && !["GIT_MASTER", "GIT_TERMINAL_PROMPT", "GIT_AUTHOR_NAME", "GIT_AUTHOR_EMAIL", "GIT_COMMITTER_NAME", "GIT_COMMITTER_EMAIL"].includes(key)) delete env[key];
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const result = await execute("git", ["-c", "core.hooksPath=", "-c", "commit.gpgSign=false", ...args], {
|
|
118
|
+
cwd,
|
|
119
|
+
env,
|
|
120
|
+
timeout: 3e4,
|
|
121
|
+
maxBuffer: 4 * 1024 * 1024
|
|
122
|
+
});
|
|
123
|
+
return result.stdout.trimEnd();
|
|
124
|
+
} catch (error) {
|
|
125
|
+
throw new CreateError("CREATE_FAILED", `Git operation failed: ${args[0]}`, { cause: error });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// src/create/target.ts
|
|
130
|
+
import { lstat, readdir, realpath } from "fs/promises";
|
|
131
|
+
import { dirname, parse, resolve } from "path";
|
|
132
|
+
import { execFile as execFile2 } from "child_process";
|
|
133
|
+
import { promisify as promisify2 } from "util";
|
|
134
|
+
async function statOrMissing(path) {
|
|
135
|
+
try {
|
|
136
|
+
return await lstat(path);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async function checkAncestors(path) {
|
|
143
|
+
if (process.platform === "win32") {
|
|
144
|
+
const result = await promisify2(execFile2)(
|
|
145
|
+
"powershell.exe",
|
|
146
|
+
[
|
|
147
|
+
"-NoProfile",
|
|
148
|
+
"-NonInteractive",
|
|
149
|
+
"-Command",
|
|
150
|
+
"Set-StrictMode -Version Latest; $ErrorActionPreference='Stop'; $path=$env:EASY_WEB_CHECK_PATH; while ($path) { if (Test-Path -LiteralPath $path) { $item=Get-Item -Force -LiteralPath $path; if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { 'reparse'; break } }; $path=[IO.Path]::GetDirectoryName($path) }"
|
|
151
|
+
],
|
|
152
|
+
{ env: { ...process.env, EASY_WEB_CHECK_PATH: path }, timeout: 15e3 }
|
|
153
|
+
);
|
|
154
|
+
if (result.stdout.trim() === "reparse") invalid(`Reparse-point target ancestor: ${path}`);
|
|
155
|
+
}
|
|
156
|
+
let current = path;
|
|
157
|
+
while (true) {
|
|
158
|
+
const stat = await statOrMissing(current);
|
|
159
|
+
if (stat && (!stat.isDirectory() || stat.isSymbolicLink())) invalid(`Unsafe target ancestor: ${current}`);
|
|
160
|
+
if (current === parse(current).root) break;
|
|
161
|
+
current = dirname(current);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function planTarget(input) {
|
|
165
|
+
const path = resolve(input);
|
|
166
|
+
await checkAncestors(path);
|
|
167
|
+
const stat = await statOrMissing(path);
|
|
168
|
+
if (!stat) {
|
|
169
|
+
if (!await statOrMissing(dirname(path))) invalid("Target parent directory must exist");
|
|
170
|
+
return { path, stat, gitRoot: false };
|
|
171
|
+
}
|
|
172
|
+
const entries = await readdir(path);
|
|
173
|
+
if (!entries.length) return { path, stat, gitRoot: false };
|
|
174
|
+
if (entries.length !== 1 || entries[0] !== ".git") invalid(`Target is not empty (including hidden/ignored files): ${path}`);
|
|
175
|
+
const metadata = await lstat(resolve(path, ".git"));
|
|
176
|
+
if (metadata.isSymbolicLink()) invalid("Git metadata must not be a link");
|
|
177
|
+
const root = await git(path, ["rev-parse", "--show-toplevel"]);
|
|
178
|
+
if (await realpath(root) !== await realpath(path)) invalid("Target must be a Git root or worktree");
|
|
179
|
+
const head = await git(path, ["rev-parse", "--verify", "HEAD"]);
|
|
180
|
+
if (await git(path, ["ls-tree", "-r", "--name-only", head]) || await git(path, ["ls-files", "--stage"]) || await git(path, ["status", "--porcelain", "--untracked-files=all", "--ignored"])) {
|
|
181
|
+
invalid("Target Git HEAD tree, index and worktree must be empty and clean");
|
|
182
|
+
}
|
|
183
|
+
return { path, stat, gitRoot: true, head };
|
|
184
|
+
}
|
|
185
|
+
async function checkTargetRace(plan) {
|
|
186
|
+
const current = await planTarget(plan.path);
|
|
187
|
+
if (current.stat?.ino !== plan.stat?.ino || current.stat?.dev !== plan.stat?.dev || current.gitRoot !== plan.gitRoot || current.head !== plan.head) {
|
|
188
|
+
invalid("Target changed after planning");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/create/stage.ts
|
|
193
|
+
import { execFile as execFile3 } from "child_process";
|
|
194
|
+
import { promisify as promisify3 } from "util";
|
|
195
|
+
import { mkdir, readdir as readdir2, writeFile, lstat as lstat2 } from "fs/promises";
|
|
196
|
+
import { dirname as dirname2, join } from "path";
|
|
197
|
+
var execute2 = promisify3(execFile3);
|
|
198
|
+
async function listFiles(root, prefix = "") {
|
|
199
|
+
const files = [];
|
|
200
|
+
for (const name of await readdir2(join(root, prefix))) {
|
|
201
|
+
if (!prefix && name === ".git") continue;
|
|
202
|
+
const path = prefix ? `${prefix}/${name}` : name;
|
|
203
|
+
const stat = await lstat2(join(root, path));
|
|
204
|
+
if (stat.isSymbolicLink()) invalid(`Staging contains a link: ${path}`);
|
|
205
|
+
if (stat.isDirectory()) files.push(...await listFiles(root, path));
|
|
206
|
+
else if (stat.isFile()) files.push(path);
|
|
207
|
+
else invalid(`Staging contains a special file: ${path}`);
|
|
208
|
+
}
|
|
209
|
+
return files.sort();
|
|
210
|
+
}
|
|
211
|
+
async function writeAndValidate(root, site) {
|
|
212
|
+
for (const file of site.files) {
|
|
213
|
+
const path = join(root, safeOutputPath(file.path));
|
|
214
|
+
await mkdir(dirname2(path), { recursive: true });
|
|
215
|
+
await writeFile(path, file.content, { flag: "wx" });
|
|
216
|
+
if (file.path.endsWith(".json")) JSON.parse(String(file.content));
|
|
217
|
+
if (/\.(?:mjs|cjs|js)$/.test(file.path)) {
|
|
218
|
+
await execute2(process.execPath, ["--check", path], { timeout: 3e4 });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const expected = site.files.map(({ path }) => path).sort();
|
|
222
|
+
if (JSON.stringify(await listFiles(root)) !== JSON.stringify(expected)) invalid("Staging tree differs from the output allow-list");
|
|
223
|
+
await git(root, ["add", "--", ...expected]);
|
|
224
|
+
const staged = (await git(root, ["diff", "--cached", "--name-status", "--no-renames", "-z"])).split("\0").filter(Boolean);
|
|
225
|
+
const paths = [];
|
|
226
|
+
for (let index = 0; index < staged.length; index += 2) {
|
|
227
|
+
if (staged[index] !== "A") invalid("Staged diff must contain additions only");
|
|
228
|
+
const path = staged[index + 1];
|
|
229
|
+
if (path) paths.push(path);
|
|
230
|
+
}
|
|
231
|
+
if (JSON.stringify(paths.sort()) !== JSON.stringify(expected)) invalid("Git index differs from the output allow-list");
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// src/create/install.ts
|
|
235
|
+
import { execFile as execFile4 } from "child_process";
|
|
236
|
+
import { promisify as promisify4 } from "util";
|
|
237
|
+
var execute3 = promisify4(execFile4);
|
|
238
|
+
var dependencyRange = /^(?:[~^]?\d+(?:\.\d+){0,2}(?:-[0-9A-Za-z.-]+)?|[<>=*xX| .\d~^-]+)$/;
|
|
239
|
+
function quote(value) {
|
|
240
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
241
|
+
}
|
|
242
|
+
function packageManifest(site) {
|
|
243
|
+
const file = site.files.find(({ path }) => path === "package.json");
|
|
244
|
+
if (!file) invalid("Generated site has no package.json");
|
|
245
|
+
return JSON.parse(String(file.content));
|
|
246
|
+
}
|
|
247
|
+
function dependencyGroups(manifest) {
|
|
248
|
+
return [
|
|
249
|
+
["dependencies", manifest.dependencies ?? {}],
|
|
250
|
+
["devDependencies", manifest.devDependencies ?? {}],
|
|
251
|
+
["optionalDependencies", manifest.optionalDependencies ?? {}]
|
|
252
|
+
];
|
|
253
|
+
}
|
|
254
|
+
function validateDependencySources(site) {
|
|
255
|
+
for (const [group, dependencies] of dependencyGroups(packageManifest(site))) {
|
|
256
|
+
for (const [name, source] of Object.entries(dependencies)) {
|
|
257
|
+
if (!dependencyRange.test(source)) {
|
|
258
|
+
invalid(`Unsupported ${group} source for ${name}: ${source}`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function createPlaceholderLockfile(site) {
|
|
264
|
+
const manifest = packageManifest(site);
|
|
265
|
+
const lines = [
|
|
266
|
+
"lockfileVersion: '9.0'",
|
|
267
|
+
"",
|
|
268
|
+
"settings:",
|
|
269
|
+
" autoInstallPeers: true",
|
|
270
|
+
" excludeLinksFromLockfile: false",
|
|
271
|
+
"",
|
|
272
|
+
"importers:",
|
|
273
|
+
"",
|
|
274
|
+
" .:"
|
|
275
|
+
];
|
|
276
|
+
for (const [group, dependencies] of dependencyGroups(manifest)) {
|
|
277
|
+
const entries = Object.entries(dependencies).sort(([left], [right]) => left.localeCompare(right, "en"));
|
|
278
|
+
if (!entries.length) continue;
|
|
279
|
+
lines.push(` ${group}:`);
|
|
280
|
+
for (const [name, specifier] of entries) {
|
|
281
|
+
lines.push(` ${quote(name)}:`, ` specifier: ${quote(specifier)}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return { path: "pnpm-lock.yaml", content: `${lines.join("\n")}
|
|
285
|
+
` };
|
|
286
|
+
}
|
|
287
|
+
function withPlaceholderLockfile(site) {
|
|
288
|
+
validateDependencySources(site);
|
|
289
|
+
return { ...site, files: [...site.files, createPlaceholderLockfile(site)].sort((a, b) => a.path.localeCompare(b.path, "en")) };
|
|
290
|
+
}
|
|
291
|
+
var defaultRunner = async (cwd, command, args) => {
|
|
292
|
+
await execute3(command, [...args], { cwd, shell: process.platform === "win32" });
|
|
293
|
+
};
|
|
294
|
+
async function installDependencies(target, options = {}) {
|
|
295
|
+
if (options.install !== true) return;
|
|
296
|
+
const command = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
|
|
297
|
+
try {
|
|
298
|
+
await (options.runner ?? defaultRunner)(target, command, ["install"]);
|
|
299
|
+
} catch (error) {
|
|
300
|
+
throw new CreateError("CREATE_FAILED", "Dependency installation failed", { cause: error });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/create/run.ts
|
|
305
|
+
async function createSite(config, selections = selectionsFor(config), installOptions = {}) {
|
|
306
|
+
const plan = await planTarget(config.target);
|
|
307
|
+
const staging = await mkdtemp(join2(dirname3(plan.path), ".easy-web-create-"));
|
|
308
|
+
const branch = `easy-web-create-${randomUUID()}`;
|
|
309
|
+
const root = join2(staging, "site");
|
|
310
|
+
let worktree = false;
|
|
311
|
+
let retained = false;
|
|
312
|
+
let ownedTarget = false;
|
|
313
|
+
let ownedMetadata = false;
|
|
314
|
+
const published = [];
|
|
315
|
+
const directories = [];
|
|
316
|
+
let result;
|
|
317
|
+
try {
|
|
318
|
+
const site = withPlaceholderLockfile(await composeRecipes(selections));
|
|
319
|
+
await checkTargetRace(plan);
|
|
320
|
+
if (plan.gitRoot) {
|
|
321
|
+
await git(plan.path, ["worktree", "add", "-b", branch, root, plan.head ?? "HEAD"]);
|
|
322
|
+
worktree = true;
|
|
323
|
+
} else {
|
|
324
|
+
await mkdir2(root);
|
|
325
|
+
await git(root, ["init", "--initial-branch=main", "--template="]);
|
|
326
|
+
}
|
|
327
|
+
await writeAndValidate(root, site);
|
|
328
|
+
await checkTargetRace(plan);
|
|
329
|
+
if (!plan.gitRoot) {
|
|
330
|
+
if (!plan.stat) {
|
|
331
|
+
await mkdir2(plan.path);
|
|
332
|
+
ownedTarget = true;
|
|
333
|
+
}
|
|
334
|
+
await mkdir2(join2(plan.path, ".git"));
|
|
335
|
+
ownedMetadata = true;
|
|
336
|
+
await checkAncestors(plan.path);
|
|
337
|
+
for (const file of site.files) {
|
|
338
|
+
const destination = join2(plan.path, file.path);
|
|
339
|
+
const parents = [];
|
|
340
|
+
let parent = dirname3(destination);
|
|
341
|
+
while (parent !== plan.path) {
|
|
342
|
+
parents.unshift(parent);
|
|
343
|
+
parent = dirname3(parent);
|
|
344
|
+
}
|
|
345
|
+
for (const directory of parents) {
|
|
346
|
+
if (!directories.includes(directory)) {
|
|
347
|
+
await mkdir2(directory);
|
|
348
|
+
directories.push(directory);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
await link(join2(root, file.path), destination);
|
|
352
|
+
published.push(destination);
|
|
353
|
+
}
|
|
354
|
+
const entries = await listFiles(plan.path);
|
|
355
|
+
const expected = site.files.map(({ path }) => path).sort();
|
|
356
|
+
if (JSON.stringify(entries) !== JSON.stringify(expected)) throw new CreateError("INVALID_INPUT", "Target became occupied during publication");
|
|
357
|
+
}
|
|
358
|
+
if (!plan.gitRoot) {
|
|
359
|
+
for (const entry of await readdir3(join2(root, ".git"))) {
|
|
360
|
+
await cp(join2(root, ".git", entry), join2(plan.path, ".git", entry), { recursive: true, force: false, errorOnExist: true });
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const commitRoot = plan.gitRoot ? root : plan.path;
|
|
364
|
+
await git(commitRoot, ["commit", "-m", "Create easy-web site"]);
|
|
365
|
+
const commit = await git(commitRoot, ["rev-parse", "HEAD"]);
|
|
366
|
+
retained = plan.gitRoot;
|
|
367
|
+
result = { target: plan.gitRoot ? root : plan.path, commit, branch: plan.gitRoot ? branch : "main", graphJson: site.graphJson, graphMermaid: site.graphMermaid };
|
|
368
|
+
} catch (error) {
|
|
369
|
+
const original = error instanceof CreateError ? error : new CreateError("CREATE_FAILED", "Site generation/staging failed", { cause: error });
|
|
370
|
+
const cleanupErrors = [];
|
|
371
|
+
const cleanup = async (operation) => {
|
|
372
|
+
try {
|
|
373
|
+
await operation();
|
|
374
|
+
} catch (cleanupError) {
|
|
375
|
+
cleanupErrors.push(cleanupError);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
for (const path of published.reverse()) await cleanup(() => rm(path));
|
|
379
|
+
for (const path of directories.reverse()) await cleanup(() => rmdir(path));
|
|
380
|
+
if (ownedMetadata) await cleanup(() => rm(join2(plan.path, ".git"), { recursive: true }));
|
|
381
|
+
if (ownedTarget) await cleanup(() => rmdir(plan.path));
|
|
382
|
+
if (cleanupErrors.length) Object.defineProperty(original, "cleanupErrors", { value: cleanupErrors });
|
|
383
|
+
throw original;
|
|
384
|
+
} finally {
|
|
385
|
+
if (!retained) {
|
|
386
|
+
if (worktree) {
|
|
387
|
+
const tracked = (await git(root, ["ls-files", "-z"])).split("\0").filter(Boolean);
|
|
388
|
+
if (tracked.length) await git(root, ["rm", "--cached", "--", ...tracked]);
|
|
389
|
+
for (const entry of await readdir3(root)) {
|
|
390
|
+
if (entry !== ".git") await rm(join2(root, entry), { recursive: true });
|
|
391
|
+
}
|
|
392
|
+
await git(plan.path, ["worktree", "remove", root]);
|
|
393
|
+
await git(plan.path, ["branch", "-d", branch]);
|
|
394
|
+
}
|
|
395
|
+
await rm(staging, { recursive: true });
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (!result) throw new CreateError("CREATE_FAILED", "Site creation produced no result");
|
|
399
|
+
await installDependencies(result.target, installOptions);
|
|
400
|
+
return result;
|
|
401
|
+
}
|
|
402
|
+
export {
|
|
403
|
+
createSite
|
|
404
|
+
};
|
|
405
|
+
//# sourceMappingURL=run-KXSV4EFL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create/run.ts","../src/create/compose.ts","../src/create/git.ts","../src/create/target.ts","../src/create/stage.ts","../src/create/install.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { cp, link, mkdir, mkdtemp, readdir, rm, rmdir } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport type { CreateConfig, RecipeSelection } from './config.js';\nimport { selectionsFor } from './config.js';\nimport { composeRecipes } from './compose.js';\nimport { CreateError } from './errors.js';\nimport { git } from './git.js';\nimport { checkAncestors, checkTargetRace, planTarget } from './target.js';\nimport { listFiles, writeAndValidate } from './stage.js';\nimport { installDependencies, withPlaceholderLockfile } from './install.js';\nimport type { InstallOptions } from './install.js';\n\nexport async function createSite(config: CreateConfig, selections: readonly RecipeSelection[] = selectionsFor(config), installOptions: InstallOptions = {}) {\n const plan = await planTarget(config.target);\n const staging = await mkdtemp(join(dirname(plan.path), '.easy-web-create-'));\n const branch = `easy-web-create-${randomUUID()}`;\n const root = join(staging, 'site');\n let worktree = false;\n let retained = false;\n let ownedTarget = false;\n let ownedMetadata = false;\n const published: string[] = [];\n const directories: string[] = [];\n let result: { target: string; commit: string; branch: string; graphJson: string; graphMermaid: string } | undefined;\n try {\n const site = withPlaceholderLockfile(await composeRecipes(selections));\n await checkTargetRace(plan);\n if (plan.gitRoot) {\n await git(plan.path, ['worktree', 'add', '-b', branch, root, plan.head ?? 'HEAD']);\n worktree = true;\n } else {\n await mkdir(root);\n await git(root, ['init', '--initial-branch=main', '--template=']);\n }\n await writeAndValidate(root, site);\n await checkTargetRace(plan);\n if (!plan.gitRoot) {\n if (!plan.stat) { await mkdir(plan.path); ownedTarget = true; }\n await mkdir(join(plan.path, '.git'));\n ownedMetadata = true;\n await checkAncestors(plan.path);\n // Hard links publish each allow-listed file exclusively; existing paths are never overwritten.\n for (const file of site.files) {\n const destination = join(plan.path, file.path);\n const parents: string[] = [];\n let parent = dirname(destination);\n while (parent !== plan.path) { parents.unshift(parent); parent = dirname(parent); }\n for (const directory of parents) {\n if (!directories.includes(directory)) { await mkdir(directory); directories.push(directory); }\n }\n await link(join(root, file.path), destination);\n published.push(destination);\n }\n const entries = await listFiles(plan.path);\n const expected = site.files.map(({ path }) => path).sort();\n if (JSON.stringify(entries) !== JSON.stringify(expected)) throw new CreateError('INVALID_INPUT', 'Target became occupied during publication');\n }\n if (!plan.gitRoot) {\n for (const entry of await readdir(join(root, '.git'))) {\n await cp(join(root, '.git', entry), join(plan.path, '.git', entry), { recursive: true, force: false, errorOnExist: true });\n }\n }\n const commitRoot = plan.gitRoot ? root : plan.path;\n await git(commitRoot, ['commit', '-m', 'Create easy-web site']);\n const commit = await git(commitRoot, ['rev-parse', 'HEAD']);\n retained = plan.gitRoot;\n result = { target: plan.gitRoot ? root : plan.path, commit, branch: plan.gitRoot ? branch : 'main', graphJson: site.graphJson, graphMermaid: site.graphMermaid };\n } catch (error) {\n const original = error instanceof CreateError\n ? error\n : new CreateError('CREATE_FAILED', 'Site generation/staging failed', { cause: error });\n const cleanupErrors: unknown[] = [];\n const cleanup = async (operation: () => Promise<unknown>): Promise<void> => {\n try { await operation(); } catch (cleanupError) { cleanupErrors.push(cleanupError); }\n };\n for (const path of published.reverse()) await cleanup(() => rm(path));\n for (const path of directories.reverse()) await cleanup(() => rmdir(path));\n if (ownedMetadata) await cleanup(() => rm(join(plan.path, '.git'), { recursive: true }));\n if (ownedTarget) await cleanup(() => rmdir(plan.path));\n if (cleanupErrors.length) Object.defineProperty(original, 'cleanupErrors', { value: cleanupErrors });\n throw original;\n } finally {\n if (!retained) {\n if (worktree) {\n const tracked = (await git(root, ['ls-files', '-z'])).split('\\0').filter(Boolean);\n if (tracked.length) await git(root, ['rm', '--cached', '--', ...tracked]);\n for (const entry of await readdir(root)) {\n if (entry !== '.git') await rm(join(root, entry), { recursive: true });\n }\n await git(plan.path, ['worktree', 'remove', root]);\n await git(plan.path, ['branch', '-d', branch]);\n }\n await rm(staging, { recursive: true });\n }\n }\n if (!result) throw new CreateError('CREATE_FAILED', 'Site creation produced no result');\n await installDependencies(result.target, installOptions);\n return result;\n}\n","import { z } from 'astro/zod';\nimport {\n resolveCapabilityGraph, toCapabilityGraphDocument,\n serializeCapabilityGraphJson, serializeCapabilityGraphMermaid,\n} from '@easy-web/core/recipes';\nimport type { RecipeGeneratedFile, RecipeOutputContribution } from '@easy-web/core/recipes';\nimport type { RecipeSelection } from './config.js';\nimport { invalid } from './errors.js';\n\nexport function outputPath(contribution: RecipeOutputContribution): string {\n const { target } = contribution;\n return contribution.kind === 'route' && target.startsWith('/')\n ? target === '/' ? 'src/pages/index.astro' : `src/pages${target}.astro`\n : target;\n}\n\nexport function safeOutputPath(path: string): string {\n const segments = path.split('/');\n if (!path || segments.some((segment) => !segment || segment === '.' || segment === '..'\n || /^\\.git$/i.test(segment) || /[\\\\:*?\"<>|]/.test(segment)\n || [...segment].some((character) => character.charCodeAt(0) < 32)\n || /[. ]$/.test(segment) || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\\.|$)/i.test(segment))) {\n invalid(`Unsafe generated path: ${path}`);\n }\n return path;\n}\n\nconst packageFragmentSchema = z.object({\n dependencies: z.record(z.string(), z.string()).optional(),\n devDependencies: z.record(z.string(), z.string()).optional(),\n scripts: z.record(z.string(), z.string()).optional(),\n}).catchall(z.json());\n\nexport function mergePackageFragments(fragments: readonly string[]): string {\n // Accumulator retains every top-level field and merges the three map-valued fields.\n let merged: Record<string, z.infer<ReturnType<typeof z.json>>> = {};\n for (const fragment of fragments) {\n const parsed = packageFragmentSchema.safeParse(JSON.parse(fragment));\n if (!parsed.success) invalid(`Invalid package.json fragment: ${parsed.error.message}`);\n const previous = packageFragmentSchema.parse(merged);\n merged = { ...merged, ...parsed.data };\n for (const key of ['dependencies', 'devDependencies', 'scripts'] as const) {\n if (previous[key] || parsed.data[key]) merged[key] = { ...previous[key], ...parsed.data[key] };\n }\n }\n return `${JSON.stringify(merged, null, 2)}\\n`;\n}\n\nexport interface ComposedSite {\n readonly files: readonly RecipeGeneratedFile[];\n readonly graphJson: string;\n readonly graphMermaid: string;\n}\n\nexport async function composeRecipes(selections: readonly RecipeSelection[]): Promise<ComposedSite> {\n const resolved = resolveCapabilityGraph(selections.map(({ recipe }) => recipe));\n if (!resolved.ok) invalid(`Recipe resolution failed: ${JSON.stringify(resolved.error)}`);\n const graph = resolved.value;\n const owners = new Map<string, string>();\n for (const { recipe } of selections) {\n for (const contribution of recipe.outputContributions) {\n const path = safeOutputPath(outputPath(contribution));\n const key = path.toLowerCase();\n if (owners.has(key) && path !== 'package.json') {\n if (path === 'astro.config.mjs' && contribution.kind === 'configuration') {\n invalid('multi-recipe astro.config.mjs merge not yet supported in Phase 1 — select recipes individually or wait for a future composer');\n }\n invalid(`Shared output is not mergeable: ${path}`);\n }\n owners.set(key, path);\n }\n }\n const files = new Map<string, RecipeGeneratedFile>();\n const fragments: string[] = [];\n for (const node of graph.recipes) {\n const selection = selections.find(({ recipe }) => recipe.id === node.id);\n if (!selection) invalid(`Missing selected recipe: ${node.id}`);\n const { recipe } = selection;\n const options = recipe.optionsSchema.parse(selection.options);\n const context = { options, capabilities: graph.capabilities.map(({ id }) => id), contributions: recipe.outputContributions };\n for (const validator of recipe.validators.filter(({ phase }) => phase === 'options')) {\n const issues = await validator.validate(context);\n if (issues.length) invalid(`Recipe validation failed: ${JSON.stringify(issues)}`);\n }\n const output = await recipe.generate(context);\n const declared = recipe.outputContributions.map(outputPath).sort();\n const generated = output.files.map(({ path }) => safeOutputPath(path)).sort();\n if (new Set(generated).size !== generated.length || JSON.stringify(declared) !== JSON.stringify(generated)) {\n invalid(`Generated files differ from declared contributions: ${recipe.id}`);\n }\n for (const file of output.files) {\n if (file.path === 'package.json') fragments.push(String(file.content));\n else files.set(file.path, file);\n }\n }\n if (fragments.length) files.set('package.json', { path: 'package.json', content: mergePackageFragments(fragments) });\n const output = { files: [...files.values()].sort((a, b) => a.path.localeCompare(b.path, 'en')) };\n for (const { recipe, options } of selections) {\n for (const validator of recipe.validators.filter(({ phase }) => phase === 'output')) {\n const issues = await validator.validate({ options, capabilities: graph.capabilities.map(({ id }) => id), contributions: recipe.outputContributions, output });\n if (issues.length) invalid(`Recipe validation failed: ${JSON.stringify(issues)}`);\n }\n }\n const document = toCapabilityGraphDocument(graph);\n if (!document.ok) invalid(`Graph serialization failed: ${document.error.code}`);\n return { ...output, graphJson: serializeCapabilityGraphJson(document.value), graphMermaid: serializeCapabilityGraphMermaid(document.value) };\n}\n","import { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\nimport { CreateError } from './errors.js';\n\nconst execute = promisify(execFile);\n\nexport async function git(cwd: string, args: readonly string[]): Promise<string> {\n const env: NodeJS.ProcessEnv = { ...process.env, GIT_MASTER: '1', GIT_TERMINAL_PROMPT: '0' };\n // Ambient Git overrides must not redirect operations into the invoker's repository.\n for (const key of Object.keys(env)) {\n if (key.startsWith('GIT_') && !['GIT_MASTER', 'GIT_TERMINAL_PROMPT', 'GIT_AUTHOR_NAME', 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_NAME', 'GIT_COMMITTER_EMAIL'].includes(key)) delete env[key];\n }\n try {\n const result = await execute('git', ['-c', 'core.hooksPath=', '-c', 'commit.gpgSign=false', ...args], {\n cwd, env, timeout: 30_000, maxBuffer: 4 * 1024 * 1024,\n });\n return result.stdout.trimEnd();\n } catch (error) {\n throw new CreateError('CREATE_FAILED', `Git operation failed: ${args[0]}`, { cause: error });\n }\n}\n","import { lstat, readdir, realpath } from 'node:fs/promises';\nimport { dirname, parse, resolve } from 'node:path';\nimport type { Stats } from 'node:fs';\nimport { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\nimport { git } from './git.js';\nimport { invalid } from './errors.js';\n\nexport async function statOrMissing(path: string): Promise<Stats | undefined> {\n try {\n return await lstat(path);\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nexport async function checkAncestors(path: string): Promise<void> {\n if (process.platform === 'win32') {\n const result = await promisify(execFile)('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',\n \"Set-StrictMode -Version Latest; $ErrorActionPreference='Stop'; $path=$env:EASY_WEB_CHECK_PATH; while ($path) { if (Test-Path -LiteralPath $path) { $item=Get-Item -Force -LiteralPath $path; if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { 'reparse'; break } }; $path=[IO.Path]::GetDirectoryName($path) }\"],\n { env: { ...process.env, EASY_WEB_CHECK_PATH: path }, timeout: 15_000 });\n if (result.stdout.trim() === 'reparse') invalid(`Reparse-point target ancestor: ${path}`);\n }\n let current = path;\n while (true) {\n const stat = await statOrMissing(current);\n if (stat && (!stat.isDirectory() || stat.isSymbolicLink())) invalid(`Unsafe target ancestor: ${current}`);\n if (current === parse(current).root) break;\n current = dirname(current);\n }\n}\n\nexport interface TargetPlan {\n readonly path: string;\n readonly stat: Stats | undefined;\n readonly gitRoot: boolean;\n readonly head?: string;\n}\n\nexport async function planTarget(input: string): Promise<TargetPlan> {\n const path = resolve(input);\n await checkAncestors(path);\n const stat = await statOrMissing(path);\n if (!stat) {\n if (!(await statOrMissing(dirname(path)))) invalid('Target parent directory must exist');\n return { path, stat, gitRoot: false };\n }\n const entries = await readdir(path);\n if (!entries.length) return { path, stat, gitRoot: false };\n if (entries.length !== 1 || entries[0] !== '.git') invalid(`Target is not empty (including hidden/ignored files): ${path}`);\n const metadata = await lstat(resolve(path, '.git'));\n if (metadata.isSymbolicLink()) invalid('Git metadata must not be a link');\n const root = await git(path, ['rev-parse', '--show-toplevel']);\n if (await realpath(root) !== await realpath(path)) invalid('Target must be a Git root or worktree');\n const head = await git(path, ['rev-parse', '--verify', 'HEAD']);\n if (await git(path, ['ls-tree', '-r', '--name-only', head])\n || await git(path, ['ls-files', '--stage'])\n || await git(path, ['status', '--porcelain', '--untracked-files=all', '--ignored'])) {\n invalid('Target Git HEAD tree, index and worktree must be empty and clean');\n }\n return { path, stat, gitRoot: true, head };\n}\n\nexport async function checkTargetRace(plan: TargetPlan): Promise<void> {\n const current = await planTarget(plan.path);\n if (current.stat?.ino !== plan.stat?.ino || current.stat?.dev !== plan.stat?.dev\n || current.gitRoot !== plan.gitRoot || current.head !== plan.head) {\n invalid('Target changed after planning');\n }\n}\n","import { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\nimport { mkdir, readdir, writeFile, lstat } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport type { ComposedSite } from './compose.js';\nimport { safeOutputPath } from './compose.js';\nimport { invalid } from './errors.js';\nimport { git } from './git.js';\n\nconst execute = promisify(execFile);\n\nexport async function listFiles(root: string, prefix = ''): Promise<readonly string[]> {\n const files: string[] = [];\n for (const name of await readdir(join(root, prefix))) {\n if (!prefix && name === '.git') continue;\n const path = prefix ? `${prefix}/${name}` : name;\n const stat = await lstat(join(root, path));\n if (stat.isSymbolicLink()) invalid(`Staging contains a link: ${path}`);\n if (stat.isDirectory()) files.push(...await listFiles(root, path));\n else if (stat.isFile()) files.push(path);\n else invalid(`Staging contains a special file: ${path}`);\n }\n return files.sort();\n}\n\nexport async function writeAndValidate(root: string, site: ComposedSite): Promise<void> {\n for (const file of site.files) {\n const path = join(root, safeOutputPath(file.path));\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, file.content, { flag: 'wx' });\n if (file.path.endsWith('.json')) JSON.parse(String(file.content));\n if (/\\.(?:mjs|cjs|js)$/.test(file.path)) {\n await execute(process.execPath, ['--check', path], { timeout: 30_000 });\n }\n }\n const expected = site.files.map(({ path }) => path).sort();\n if (JSON.stringify(await listFiles(root)) !== JSON.stringify(expected)) invalid('Staging tree differs from the output allow-list');\n await git(root, ['add', '--', ...expected]);\n const staged = (await git(root, ['diff', '--cached', '--name-status', '--no-renames', '-z'])).split('\\0').filter(Boolean);\n const paths: string[] = [];\n for (let index = 0; index < staged.length; index += 2) {\n if (staged[index] !== 'A') invalid('Staged diff must contain additions only');\n const path = staged[index + 1];\n if (path) paths.push(path);\n }\n if (JSON.stringify(paths.sort()) !== JSON.stringify(expected)) invalid('Git index differs from the output allow-list');\n}\n","import { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\nimport type { RecipeGeneratedFile } from '@easy-web/core/recipes';\nimport type { ComposedSite } from './compose.js';\nimport { CreateError, invalid } from './errors.js';\n\nconst execute = promisify(execFile);\nconst dependencyRange = /^(?:[~^]?\\d+(?:\\.\\d+){0,2}(?:-[0-9A-Za-z.-]+)?|[<>=*xX| .\\d~^-]+)$/;\n\ninterface PackageManifest {\n readonly dependencies?: Readonly<Record<string, string>>;\n readonly devDependencies?: Readonly<Record<string, string>>;\n readonly optionalDependencies?: Readonly<Record<string, string>>;\n}\n\nexport type InstallRunner = (cwd: string, command: string, args: readonly string[]) => Promise<void>;\n\nexport interface InstallOptions {\n readonly install?: boolean;\n readonly runner?: InstallRunner;\n}\n\nfunction quote(value: string): string {\n return `'${value.replaceAll(\"'\", \"''\")}'`;\n}\n\nfunction packageManifest(site: ComposedSite): PackageManifest {\n const file = site.files.find(({ path }) => path === 'package.json');\n if (!file) invalid('Generated site has no package.json');\n return JSON.parse(String(file.content)) as PackageManifest;\n}\n\nfunction dependencyGroups(manifest: PackageManifest): readonly [string, Readonly<Record<string, string>>][] {\n return [\n ['dependencies', manifest.dependencies ?? {}],\n ['devDependencies', manifest.devDependencies ?? {}],\n ['optionalDependencies', manifest.optionalDependencies ?? {}],\n ];\n}\n\nexport function validateDependencySources(site: ComposedSite): void {\n for (const [group, dependencies] of dependencyGroups(packageManifest(site))) {\n for (const [name, source] of Object.entries(dependencies)) {\n if (!dependencyRange.test(source)) {\n invalid(`Unsupported ${group} source for ${name}: ${source}`);\n }\n }\n }\n}\n\nexport function createPlaceholderLockfile(site: ComposedSite): RecipeGeneratedFile {\n const manifest = packageManifest(site);\n const lines = [\n \"lockfileVersion: '9.0'\",\n '',\n 'settings:',\n ' autoInstallPeers: true',\n ' excludeLinksFromLockfile: false',\n '',\n 'importers:',\n '',\n ' .:',\n ];\n for (const [group, dependencies] of dependencyGroups(manifest)) {\n const entries = Object.entries(dependencies).sort(([left], [right]) => left.localeCompare(right, 'en'));\n if (!entries.length) continue;\n lines.push(` ${group}:`);\n for (const [name, specifier] of entries) {\n lines.push(` ${quote(name)}:`, ` specifier: ${quote(specifier)}`);\n }\n }\n return { path: 'pnpm-lock.yaml', content: `${lines.join('\\n')}\\n` };\n}\n\nexport function withPlaceholderLockfile(site: ComposedSite): ComposedSite {\n validateDependencySources(site);\n return { ...site, files: [...site.files, createPlaceholderLockfile(site)].sort((a, b) => a.path.localeCompare(b.path, 'en')) };\n}\n\nconst defaultRunner: InstallRunner = async (cwd, command, args) => {\n await execute(command, [...args], { cwd, shell: process.platform === 'win32' });\n};\n\nexport async function installDependencies(target: string, options: InstallOptions = {}): Promise<void> {\n if (options.install !== true) return;\n const command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';\n try {\n await (options.runner ?? defaultRunner)(target, command, ['install']);\n } catch (error) {\n throw new CreateError('CREATE_FAILED', 'Dependency installation failed', { cause: error });\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,IAAI,MAAM,SAAAA,QAAO,SAAS,WAAAC,UAAS,IAAI,aAAa;AAC7D,SAAS,WAAAC,UAAS,QAAAC,aAAY;;;ACF9B,SAAS,SAAS;AAClB;AAAA,EACI;AAAA,EAAwB;AAAA,EACxB;AAAA,EAA8B;AAAA,OAC3B;AAKA,SAAS,WAAW,cAAgD;AACvE,QAAM,EAAE,OAAO,IAAI;AACnB,SAAO,aAAa,SAAS,WAAW,OAAO,WAAW,GAAG,IACvD,WAAW,MAAM,0BAA0B,YAAY,MAAM,WAC7D;AACV;AAEO,SAAS,eAAe,MAAsB;AACjD,QAAM,WAAW,KAAK,MAAM,GAAG;AAC/B,MAAI,CAAC,QAAQ,SAAS,KAAK,CAAC,YAAY,CAAC,WAAW,YAAY,OAAO,YAAY,QAC5E,WAAW,KAAK,OAAO,KAAK,cAAc,KAAK,OAAO,KACtD,CAAC,GAAG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MAAM,KAAK,IAAI,CAAC;AACrD,QAAI,cAAc,OAAQ,QAAO,eAAe,UAAU,iBAAiB,EAAE,OAAO,cAAc,CAAC;AACnG,UAAM;AAAA,EACV,UAAE;AACE,QAAI,CAAC,UAAU;AACX,UAAI,UAAU;AACV,cAAM,WAAW,MAAM,IAAI,MAAM,CAAC,YAAY,IAAI,CAAC,GAAG,MAAM,IAAI,EAAE,OAAO,OAAO;AAChF,YAAI,QAAQ,OAAQ,OAAM,IAAI,MAAM,CAAC,MAAM,YAAY,MAAM,GAAG,OAAO,CAAC;AACxE,mBAAW,SAAS,MAAMG,SAAQ,IAAI,GAAG;AACrC,cAAI,UAAU,OAAQ,OAAM,GAAGH,MAAK,MAAM,KAAK,GAAG,EAAE,WAAW,KAAK,CAAC;AAAA,QACzE;AACA,cAAM,IAAI,KAAK,MAAM,CAAC,YAAY,UAAU,IAAI,CAAC;AACjD,cAAM,IAAI,KAAK,MAAM,CAAC,UAAU,MAAM,MAAM,CAAC;AAAA,MACjD;AACA,YAAM,GAAG,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,IACzC;AAAA,EACJ;AACA,MAAI,CAAC,OAAQ,OAAM,IAAI,YAAY,iBAAiB,kCAAkC;AACtF,QAAM,oBAAoB,OAAO,QAAQ,cAAc;AACvD,SAAO;AACX;","names":["mkdir","readdir","dirname","join","recipe","output","execFile","promisify","promisify","execFile","execFile","promisify","readdir","lstat","dirname","execute","promisify","execFile","readdir","lstat","dirname","execFile","promisify","execute","promisify","execFile","join","dirname","mkdir","readdir"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-web/cli",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Create-only command-line interface for generating easy-web sites.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=24"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"easy-web": "./dist/bin.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"lint": "eslint src"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"mri": "^1.2.0",
|
|
24
|
+
"@easy-web/core": "workspace:*",
|
|
25
|
+
"@easy-web/auth": "workspace:*",
|
|
26
|
+
"@easy-web/cms-adapters": "workspace:*",
|
|
27
|
+
"astro": "^7.3.5"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^24.0.0",
|
|
31
|
+
"execa": "^9.6.1",
|
|
32
|
+
"tsup": "^8.0.0",
|
|
33
|
+
"typescript": "^5.5.0",
|
|
34
|
+
"vitest": "^3.2.4"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"provenance": true
|
|
38
|
+
},
|
|
39
|
+
"packageManager": "pnpm@10.34.4",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/achimismaili/easy-web.git",
|
|
43
|
+
"directory": "packages/easy-web-cli"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT"
|
|
46
|
+
}
|