@d-zero/create-frontend 5.0.0-beta.11 → 5.0.0-beta.12

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.0.0-beta.12](https://github.com/d-zero-dev/frontend-env/compare/v5.0.0-beta.11...v5.0.0-beta.12) (2025-10-20)
7
+
8
+ ### Features
9
+
10
+ - **create-frontend:** add volta and node installation support ([29e4fff](https://github.com/d-zero-dev/frontend-env/commit/29e4fff6af41be56397ba25f699e946a1f16c10a))
11
+
6
12
  # [5.0.0-beta.11](https://github.com/d-zero-dev/frontend-env/compare/v5.0.0-beta.10...v5.0.0-beta.11) (2025-10-20)
7
13
 
8
14
  ### Features
package/command.js CHANGED
@@ -4,23 +4,12 @@ import { spawn } from 'node:child_process';
4
4
  *
5
5
  * @param {string} commandName
6
6
  * @param {string[]} args
7
- * @param {string} cwd
8
- * @returns {Promise<number>}
7
+ * @param {import("node:child_process").SpawnOptionsWithoutStdio} options
8
+ * @returns {Promise<string>}
9
9
  */
10
- export async function command(commandName, args, cwd = process.cwd()) {
10
+ export async function command(commandName, args, options) {
11
11
  return new Promise((resolve, reject) => {
12
- const child = spawn(commandName, args, {
13
- cwd,
14
- stdio: 'inherit',
15
- });
16
-
17
- child.on('exit', (code) => {
18
- if (code === 0) {
19
- resolve(code);
20
- return;
21
- }
22
- reject(code);
23
- });
12
+ const child = spawn(commandName, args, options);
24
13
 
25
14
  child.on('error', (error) => {
26
15
  reject(error);
@@ -29,5 +18,31 @@ export async function command(commandName, args, cwd = process.cwd()) {
29
18
  process.on('SIGINT', () => {
30
19
  child.kill('SIGINT');
31
20
  });
21
+
22
+ if (child.stdout) {
23
+ let returnValue = '';
24
+
25
+ child.stdout.on('data', (data) => {
26
+ returnValue += data.toString();
27
+ });
28
+
29
+ child.stdout.on('end', () => {
30
+ resolve(returnValue.trim());
31
+ });
32
+
33
+ return;
34
+ }
35
+
36
+ child.on('exit', (code) => {
37
+ if (code !== 0) {
38
+ reject(
39
+ new Error(
40
+ `Command "${commandName} ${args.join(' ')}" exited with code ${code}`,
41
+ ),
42
+ );
43
+ return;
44
+ }
45
+ resolve('');
46
+ });
32
47
  });
33
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/create-frontend",
3
- "version": "5.0.0-beta.11",
3
+ "version": "5.0.0-beta.12",
4
4
  "description": "Create a new frontend project from a scaffolding template",
5
5
  "repository": "https://github.com/d-zero-dev/frontend-env.git",
6
6
  "author": "D-ZERO Co., Ltd.",
@@ -13,7 +13,7 @@
13
13
  "create-dzero-frontend": "./index.js"
14
14
  },
15
15
  "dependencies": {
16
- "@d-zero/scaffold": "5.0.0-beta.11",
16
+ "@d-zero/scaffold": "5.0.0-beta.12",
17
17
  "glob": "11.0.3",
18
18
  "i18n-js": "4.5.1",
19
19
  "ignore": "7.0.5",
@@ -22,7 +22,8 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/glob": "9.0.0",
25
+ "@types/node": "24.8.1",
25
26
  "execa": "9.6.0"
26
27
  },
27
- "gitHead": "be7194ca289ccc884cb4f83e8f8d0b3d81742e0a"
28
+ "gitHead": "de95a02067c4c0154eef5217d612b3caf6e8581d"
28
29
  }
package/plopfile.js CHANGED
@@ -10,6 +10,7 @@ import { command } from './command.js';
10
10
  import { copyLibraries } from './libraries.js';
11
11
  import { t } from './locale.js';
12
12
  import { readFileSafe } from './read-file-safe.js';
13
+ import { voltaInstallNode } from './volta-install-node.js';
13
14
 
14
15
  const cli = meow(
15
16
  `
@@ -248,13 +249,13 @@ function answerToConfig(answers) {
248
249
  * @param dest
249
250
  */
250
251
  async function installDependencies(dest) {
251
- await command('volta', ['setup']).catch((error) => {
252
- // eslint-disable-next-line no-console
253
- console.error(error);
252
+ await voltaInstallNode();
253
+ await command('yarn', ['install'], {
254
+ cwd: path.resolve(process.cwd(), dest),
255
+ stdio: 'inherit',
256
+ }).catch(() => {
257
+ throw new Error('Failed to install dependencies');
254
258
  });
255
- await command('yarn', ['install'], path.resolve(process.cwd(), dest)).catch(
256
- () => new Error('Failed to install dependencies'),
257
- );
258
259
  }
259
260
 
260
261
  /**
@@ -0,0 +1,24 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+
4
+ import { command } from './command.js';
5
+
6
+ /**
7
+ *
8
+ */
9
+ export async function voltaInstallNode() {
10
+ const node = await command('nod', ['-v']).catch(() => null);
11
+ if (node) {
12
+ return;
13
+ }
14
+ const pkg = await readFile(path.join(import.meta.dirname, 'package.json'), 'utf8');
15
+ const pkgJson = JSON.parse(pkg);
16
+ const nodeVersion = pkgJson.devDependencies['@types/node'].split('.')[0];
17
+ const volta = await command('volta', ['-v']).catch(() => null);
18
+ if (volta) {
19
+ await command('volta', ['setup'], { stdio: 'inherit' });
20
+ await command('volta', ['install', `node@${nodeVersion}`], { stdio: 'inherit' });
21
+ return;
22
+ }
23
+ throw new Error('command not found: "node" or "volta"');
24
+ }