@venizia/vulcan 0.3.2 → 0.3.4
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 +3 -3
- package/src/create/common/types.ts +2 -0
- package/src/create/init-monorepo.ts +23 -36
- package/src/create/preset.ts +11 -0
- package/src/create/process.ts +34 -4
- package/src/create/scratch.ts +9 -2
- package/src/create/workspace.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/vulcan",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "VULCAN - one setup, one workflow for every project: init, sync, doctor, upgrade, and `vulcan x` for the shipped tools. Bun-only.",
|
|
5
5
|
"homepage": "https://github.com/VENIZIA-AI/vulcan/tree/main/packages/cli",
|
|
6
6
|
"repository": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"test": "NODE_ENV=test bun test --env-file=.env.test"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@venizia/vulcan-atlas": "0.3.
|
|
48
|
-
"@venizia/vulcan-okf": "0.3.
|
|
47
|
+
"@venizia/vulcan-atlas": "0.3.4",
|
|
48
|
+
"@venizia/vulcan-okf": "0.3.4",
|
|
49
49
|
"zod": "^4.5.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -42,6 +42,8 @@ export interface IPreset {
|
|
|
42
42
|
checks: string[];
|
|
43
43
|
/** Paths under the dev port worth opening (`/api/hello`); none means the root. */
|
|
44
44
|
urls: string[];
|
|
45
|
+
/** The app's `package.json` `imports` (Node subpath imports), copied as they are written. */
|
|
46
|
+
imports: Record<string, string>;
|
|
45
47
|
/** The folder holding the files to copy, absolute once the preset is located. */
|
|
46
48
|
files: string;
|
|
47
49
|
atlas: IPresetAtlasSource[];
|
|
@@ -215,21 +215,23 @@ const runCreate = async (opts: {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
let located: ILocatedPreset;
|
|
218
|
-
let names: Record<string, string>;
|
|
219
218
|
|
|
220
219
|
if (isNpm) {
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
220
|
+
// Without a terminal nothing is asked, so a missing flag is refused before the network is used.
|
|
221
|
+
if (!interactive) {
|
|
222
|
+
const early = resolveNames({
|
|
223
|
+
fields: appFields({}),
|
|
224
|
+
args: opts.args,
|
|
225
|
+
interactive,
|
|
226
|
+
ask: askWithPrompt,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
if (!early.ok) {
|
|
230
|
+
return fail({ message: early.error });
|
|
231
|
+
}
|
|
231
232
|
}
|
|
232
233
|
|
|
234
|
+
// The side is known only once the package is read, so the preset is fetched before the rest is asked.
|
|
233
235
|
const installed = await installNpmPreset({ scratch: opts.scratch, spec });
|
|
234
236
|
|
|
235
237
|
if (installed !== ExitCodes.OK) {
|
|
@@ -243,19 +245,6 @@ const runCreate = async (opts: {
|
|
|
243
245
|
}
|
|
244
246
|
|
|
245
247
|
located = result.located;
|
|
246
|
-
|
|
247
|
-
const folder = resolveNames({
|
|
248
|
-
fields: [SIDE_FIELDS[located.preset.side]],
|
|
249
|
-
args: opts.args,
|
|
250
|
-
interactive,
|
|
251
|
-
ask: askWithPrompt,
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
if (!folder.ok) {
|
|
255
|
-
return fail({ message: folder.error });
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
names = { ...early.names, ...folder.names };
|
|
259
248
|
} else {
|
|
260
249
|
const result = locatePreset({ spec, root });
|
|
261
250
|
|
|
@@ -264,22 +253,20 @@ const runCreate = async (opts: {
|
|
|
264
253
|
}
|
|
265
254
|
|
|
266
255
|
located = result.located;
|
|
256
|
+
}
|
|
267
257
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (!rest.ok) {
|
|
276
|
-
return fail({ message: rest.error });
|
|
277
|
-
}
|
|
258
|
+
const rest = resolveNames({
|
|
259
|
+
fields: appFields({ side: located.preset.side }),
|
|
260
|
+
args: opts.args,
|
|
261
|
+
interactive,
|
|
262
|
+
ask: askWithPrompt,
|
|
263
|
+
});
|
|
278
264
|
|
|
279
|
-
|
|
265
|
+
if (!rest.ok) {
|
|
266
|
+
return fail({ message: rest.error });
|
|
280
267
|
}
|
|
281
268
|
|
|
282
|
-
const { folder, app, shared } = names;
|
|
269
|
+
const { folder, app, shared } = rest.names;
|
|
283
270
|
const side = located.preset.side;
|
|
284
271
|
// The flag of the side this preset does not build still counts when given: it names a folder too.
|
|
285
272
|
const otherFlag =
|
package/src/create/preset.ts
CHANGED
|
@@ -29,11 +29,22 @@ const PRESET_SCHEMA = z
|
|
|
29
29
|
scripts: z.record(z.string(), z.string()).default({}),
|
|
30
30
|
checks: z.array(z.string()).default([]),
|
|
31
31
|
urls: z.array(z.string().startsWith('/')).default([]),
|
|
32
|
+
imports: z.record(z.string(), z.string()).default({}),
|
|
32
33
|
files: z.string(),
|
|
33
34
|
atlas: z.array(z.object({ name: z.string(), repo: z.string(), ref: z.string() })).default([]),
|
|
34
35
|
})
|
|
35
36
|
// A check is run as `bun run <check>`; an entry that is not a script could be a bun flag.
|
|
36
37
|
.superRefine((value, context) => {
|
|
38
|
+
for (const key of Object.keys(value.imports)) {
|
|
39
|
+
if (!key.startsWith('#')) {
|
|
40
|
+
context.addIssue({
|
|
41
|
+
code: 'custom',
|
|
42
|
+
path: ['imports', key],
|
|
43
|
+
message: `"${key}" is not a subpath import: a key starts with #`,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
37
48
|
value.checks.forEach((check, index) => {
|
|
38
49
|
if (!Object.hasOwn(value.scripts, check)) {
|
|
39
50
|
context.addIssue({
|
package/src/create/process.ts
CHANGED
|
@@ -7,11 +7,15 @@ export const isInstallSkipped = (): boolean => process.env[CreateConstants.NO_IN
|
|
|
7
7
|
/** The `bun` this process runs, unless a test replaced it. */
|
|
8
8
|
export const bunExecutable = (): string => process.env[CreateConstants.BUN_ENV] ?? process.execPath;
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Any command, under the same skip rule as `runBun`; a skipped one counts as done. A quiet command
|
|
12
|
+
* prints nothing while it runs: its output is kept and written only when it fails.
|
|
13
|
+
*/
|
|
11
14
|
export const runCommand = async (opts: {
|
|
12
15
|
cwd: string;
|
|
13
16
|
command: string[];
|
|
14
17
|
label: string;
|
|
18
|
+
quiet?: boolean;
|
|
15
19
|
}): Promise<number> => {
|
|
16
20
|
if (isInstallSkipped()) {
|
|
17
21
|
process.stderr.write(` skipped ${opts.label} (VULCAN_NO_INSTALL)\n`);
|
|
@@ -19,20 +23,46 @@ export const runCommand = async (opts: {
|
|
|
19
23
|
return ExitCodes.OK;
|
|
20
24
|
}
|
|
21
25
|
|
|
26
|
+
if (opts.quiet !== true) {
|
|
27
|
+
const child = Bun.spawn(opts.command, {
|
|
28
|
+
cwd: opts.cwd,
|
|
29
|
+
stdio: ['inherit', 'inherit', 'inherit'],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return child.exited;
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
const child = Bun.spawn(opts.command, {
|
|
23
36
|
cwd: opts.cwd,
|
|
24
|
-
|
|
37
|
+
stdin: 'ignore',
|
|
38
|
+
stdout: 'pipe',
|
|
39
|
+
stderr: 'pipe',
|
|
25
40
|
});
|
|
41
|
+
const [stdout, stderr, code] = await Promise.all([
|
|
42
|
+
new Response(child.stdout).text(),
|
|
43
|
+
new Response(child.stderr).text(),
|
|
44
|
+
child.exited,
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
if (code !== ExitCodes.OK) {
|
|
48
|
+
process.stderr.write(`${stdout}${stderr}`);
|
|
49
|
+
}
|
|
26
50
|
|
|
27
|
-
return
|
|
51
|
+
return code;
|
|
28
52
|
};
|
|
29
53
|
|
|
30
54
|
export const runBun = async (opts: {
|
|
31
55
|
cwd: string;
|
|
32
56
|
args: string[];
|
|
33
57
|
label: string;
|
|
58
|
+
quiet?: boolean;
|
|
34
59
|
}): Promise<number> =>
|
|
35
|
-
runCommand({
|
|
60
|
+
runCommand({
|
|
61
|
+
cwd: opts.cwd,
|
|
62
|
+
command: [bunExecutable(), ...opts.args],
|
|
63
|
+
label: opts.label,
|
|
64
|
+
quiet: opts.quiet,
|
|
65
|
+
});
|
|
36
66
|
|
|
37
67
|
/**
|
|
38
68
|
* `git init` on the new project. A machine without git (or with one too old for `-b`) still gets a
|
package/src/create/scratch.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { runBun } from './process.ts';
|
|
|
7
7
|
/**
|
|
8
8
|
* An npm preset is read from node_modules, so it is installed into a scratch folder outside the
|
|
9
9
|
* project: every refusal that depends on what the package says happens before anything is written.
|
|
10
|
+
* One line says what is fetched; bun's own output would land between the questions, so it is kept
|
|
11
|
+
* and shown only when the install fails.
|
|
10
12
|
*/
|
|
11
13
|
export const installNpmPreset = async (opts: {
|
|
12
14
|
scratch: string;
|
|
@@ -17,10 +19,15 @@ export const installNpmPreset = async (opts: {
|
|
|
17
19
|
`${JSON.stringify({ name: 'vulcan-preset-scratch', private: true })}\n`,
|
|
18
20
|
);
|
|
19
21
|
|
|
22
|
+
const preset = `${opts.spec.packageName}@${opts.spec.range}`;
|
|
23
|
+
|
|
24
|
+
process.stderr.write(`Fetching preset ${preset} ...\n`);
|
|
25
|
+
|
|
20
26
|
return runBun({
|
|
21
27
|
cwd: opts.scratch,
|
|
22
|
-
args: ['add',
|
|
23
|
-
label: `bun add ${
|
|
28
|
+
args: ['add', preset],
|
|
29
|
+
label: `bun add ${preset}`,
|
|
30
|
+
quiet: true,
|
|
24
31
|
});
|
|
25
32
|
};
|
|
26
33
|
|
package/src/create/workspace.ts
CHANGED
|
@@ -153,6 +153,8 @@ export const renderAppManifest = (opts: {
|
|
|
153
153
|
name: opts.app,
|
|
154
154
|
version: '0.0.0',
|
|
155
155
|
private: true,
|
|
156
|
+
// The preset's own text: no token is replaced here, a path pattern has no use for one.
|
|
157
|
+
...(Object.keys(opts.preset.imports).length === 0 ? {} : { imports: opts.preset.imports }),
|
|
156
158
|
scripts: opts.preset.scripts,
|
|
157
159
|
dependencies: toCatalog({
|
|
158
160
|
dependencies: {
|