@venizia/vulcan 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venizia/vulcan",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
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.2",
48
- "@venizia/vulcan-okf": "0.3.2",
47
+ "@venizia/vulcan-atlas": "0.3.3",
48
+ "@venizia/vulcan-okf": "0.3.3",
49
49
  "zod": "^4.5.4"
50
50
  },
51
51
  "devDependencies": {
@@ -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
- // The side is known only once the package is read, so its folder is asked after the install.
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 });
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
- const rest = resolveNames({
269
- fields: appFields({ side: located.preset.side }),
270
- args: opts.args,
271
- interactive,
272
- ask: askWithPrompt,
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
- names = rest.names;
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 =
@@ -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
- /** Any command, under the same skip rule as `runBun`; a skipped one counts as done. */
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
- stdio: ['inherit', 'inherit', 'inherit'],
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 child.exited;
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({ cwd: opts.cwd, command: [bunExecutable(), ...opts.args], label: opts.label });
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
@@ -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', `${opts.spec.packageName}@${opts.spec.range}`],
23
- label: `bun add ${opts.spec.packageName}@${opts.spec.range}`,
28
+ args: ['add', preset],
29
+ label: `bun add ${preset}`,
30
+ quiet: true,
24
31
  });
25
32
  };
26
33