create-edgebase 0.2.8 → 0.3.1

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": "create-edgebase",
3
- "version": "0.2.8",
3
+ "version": "0.3.1",
4
4
  "description": "Bootstrap a new EdgeBase project",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,6 +31,6 @@
31
31
  "node": ">=20.19.0"
32
32
  },
33
33
  "dependencies": {
34
- "@edge-base/cli": "0.2.8"
34
+ "@edge-base/cli": "0.3.1"
35
35
  }
36
36
  }
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawnSync } from 'node:child_process';
4
- import { createRequire } from 'node:module';
5
- import { dirname, join, resolve } from 'node:path';
6
- import process from 'node:process';
7
-
8
- const require = createRequire(import.meta.url);
9
-
10
- function printUsage() {
11
- console.log(`Usage:
12
- npm create edgebase@latest <project-dir>
13
- npm create edgebase@latest <project-dir> -- --no-dev
14
- npm create edgebase@latest <project-dir> -- --open
15
-
16
- What it does:
17
- 1. Scaffolds a new EdgeBase project
18
- 2. Installs local project dependencies
19
- 3. Starts the dev server unless you pass --no-dev
20
- `);
21
- }
22
-
23
- function detectPackageManager() {
24
- const userAgent = process.env.npm_config_user_agent ?? '';
25
-
26
- if (userAgent.startsWith('pnpm/')) {
27
- return {
28
- name: 'pnpm',
29
- command: 'pnpm',
30
- installArgs: ['install'],
31
- runScriptArgs(scriptName, extraArgs = []) {
32
- return ['run', scriptName, ...extraArgs];
33
- },
34
- };
35
- }
36
-
37
- if (userAgent.startsWith('yarn/')) {
38
- return {
39
- name: 'yarn',
40
- command: 'yarn',
41
- installArgs: ['install'],
42
- runScriptArgs(scriptName, extraArgs = []) {
43
- return ['run', scriptName, ...extraArgs];
44
- },
45
- };
46
- }
47
-
48
- if (userAgent.startsWith('bun/')) {
49
- return {
50
- name: 'bun',
51
- command: 'bun',
52
- installArgs: ['install'],
53
- runScriptArgs(scriptName, extraArgs = []) {
54
- return ['run', scriptName, ...extraArgs];
55
- },
56
- };
57
- }
58
-
59
- return {
60
- name: 'npm',
61
- command: 'npm',
62
- installArgs: ['install'],
63
- runScriptArgs(scriptName, extraArgs = []) {
64
- return ['run', scriptName, ...(extraArgs.length > 0 ? ['--', ...extraArgs] : [])];
65
- },
66
- };
67
- }
68
-
69
- function runOrExit(command, args, options = {}) {
70
- const result = spawnSync(command, args, {
71
- stdio: 'inherit',
72
- ...options,
73
- });
74
-
75
- if (result.error) {
76
- throw result.error;
77
- }
78
-
79
- if (typeof result.status === 'number' && result.status !== 0) {
80
- process.exit(result.status);
81
- }
82
- }
83
-
84
- const rawArgs = process.argv.slice(2);
85
- if (rawArgs.includes('--help') || rawArgs.includes('-h')) {
86
- printUsage();
87
- process.exit(0);
88
- }
89
-
90
- const forwardedArgs = [...rawArgs];
91
- const wantsNoDev = forwardedArgs.includes('--no-dev');
92
- const wantsOpen = forwardedArgs.includes('--open');
93
- const scaffoldArgs = wantsNoDev ? forwardedArgs : [...forwardedArgs, '--no-dev'];
94
- const targetDirArg = forwardedArgs.find((arg) => !arg.startsWith('-')) ?? '.';
95
- const projectDir = resolve(process.cwd(), targetDirArg);
96
- const packageManager = detectPackageManager();
97
- const skipInstall = process.env.EDGEBASE_CREATE_SKIP_INSTALL === '1';
98
- const cliPackageJsonPath = require.resolve('@edge-base/cli/package.json');
99
- const cliEntryPath = join(dirname(cliPackageJsonPath), 'dist', 'index.js');
100
-
101
- runOrExit(process.execPath, [cliEntryPath, 'init', ...scaffoldArgs], {
102
- cwd: process.cwd(),
103
- env: {
104
- ...process.env,
105
- EDGEBASE_BOOTSTRAP_WRAPPER: '1',
106
- },
107
- });
108
-
109
- if (!skipInstall) {
110
- console.log();
111
- console.log(`Installing project dependencies with ${packageManager.name}...`);
112
- runOrExit(packageManager.command, packageManager.installArgs, {
113
- cwd: projectDir,
114
- env: process.env,
115
- });
116
- }
117
-
118
- if (!wantsNoDev) {
119
- console.log();
120
- console.log('Starting the EdgeBase dev server...');
121
- runOrExit(packageManager.command, packageManager.runScriptArgs('dev', wantsOpen ? ['--open'] : []), {
122
- cwd: projectDir,
123
- env: process.env,
124
- });
125
- }