create-fuzionx 0.1.38 → 0.1.39
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/fx.js +13 -9
- package/index.js +25 -21
- package/package.json +1 -1
- package/templates/common/package.json.tpl +2 -2
- package/templates/spa/meta.json +1 -1
package/fx.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* fx make:controller User → 로컬 @fuzionx/framework CLI 위임
|
|
9
9
|
* fx dev → 로컬 @fuzionx/framework CLI 위임
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { spawnSync } from 'node:child_process';
|
|
12
12
|
import { existsSync } from 'node:fs';
|
|
13
13
|
import path from 'node:path';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
@@ -31,14 +31,18 @@ const localBin = path.resolve('node_modules', '.bin', 'fx');
|
|
|
31
31
|
const localCli = path.resolve('node_modules', '@fuzionx', 'framework', 'bin', 'fx.js');
|
|
32
32
|
|
|
33
33
|
if (existsSync(localBin) || existsSync(localCli)) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
// spawnSync 배열 방식 — 쉘 인젝션 방지
|
|
35
|
+
const useLocalBin = existsSync(localBin);
|
|
36
|
+
const bin = useLocalBin ? localBin : process.execPath;
|
|
37
|
+
const spawnArgs = useLocalBin
|
|
38
|
+
? process.argv.slice(2)
|
|
39
|
+
: [localCli, ...process.argv.slice(2)];
|
|
40
|
+
const result = spawnSync(bin, spawnArgs, {
|
|
41
|
+
stdio: 'inherit',
|
|
42
|
+
cwd: process.cwd(),
|
|
43
|
+
});
|
|
44
|
+
if (result.status !== 0) {
|
|
45
|
+
process.exit(result.status ?? 1);
|
|
42
46
|
}
|
|
43
47
|
} else if (!command || command === 'help') {
|
|
44
48
|
console.log(`
|
package/index.js
CHANGED
|
@@ -157,15 +157,18 @@ async function createApp(name, targetDir, type = 'spa') {
|
|
|
157
157
|
return dir;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
// ── CLI 엔트리 ──
|
|
160
|
+
// ── CLI 엔트리 (direct 실행 시만 동작) ──
|
|
161
161
|
|
|
162
|
-
const
|
|
163
|
-
const name = allArgs.find(a => !a.startsWith('--'));
|
|
164
|
-
const typeFlag = allArgs.find(a => a.startsWith('--type='));
|
|
165
|
-
const type = typeFlag?.split('=')[1] || 'spa';
|
|
162
|
+
const isDirectEntry = process.argv[1]?.includes('create-fuzionx') || process.argv[1]?.endsWith('index.js');
|
|
166
163
|
|
|
167
|
-
if (
|
|
168
|
-
|
|
164
|
+
if (isDirectEntry) {
|
|
165
|
+
const allArgs = process.argv.slice(2);
|
|
166
|
+
const name = allArgs.find(a => !a.startsWith('--'));
|
|
167
|
+
const typeFlag = allArgs.find(a => a.startsWith('--type='));
|
|
168
|
+
const type = typeFlag?.split('=')[1] || 'spa';
|
|
169
|
+
|
|
170
|
+
if (!name) {
|
|
171
|
+
console.error(`
|
|
169
172
|
Usage: npx create-fuzionx <app-name> [--type=ssr|spa]
|
|
170
173
|
|
|
171
174
|
Examples:
|
|
@@ -173,19 +176,19 @@ if (!name) {
|
|
|
173
176
|
npx create-fuzionx my-app --type=ssr # MPA (SSR)
|
|
174
177
|
npx create-fuzionx my-app --type=spa # SPA (Vue.js 3 + SSR)
|
|
175
178
|
`);
|
|
176
|
-
|
|
177
|
-
}
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
178
181
|
|
|
179
|
-
const validTypes = ['ssr', 'spa'];
|
|
180
|
-
if (!validTypes.includes(type)) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
182
|
+
const validTypes = ['ssr', 'spa'];
|
|
183
|
+
if (!validTypes.includes(type)) {
|
|
184
|
+
console.error(`❌ Unknown type: ${type}. Available: ${validTypes.join(', ')}`);
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
184
187
|
|
|
185
|
-
try {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
try {
|
|
189
|
+
const dir = await createApp(name, null, type);
|
|
190
|
+
const nextCmd = type === 'spa' ? 'npx fx dev:spa' : 'npx fx dev';
|
|
191
|
+
console.log(`
|
|
189
192
|
✅ Created ${name} at ${dir} (type: ${type})
|
|
190
193
|
|
|
191
194
|
Next steps:
|
|
@@ -196,7 +199,8 @@ try {
|
|
|
196
199
|
` : ''}npx fx db:sync --apply
|
|
197
200
|
${nextCmd}
|
|
198
201
|
`);
|
|
199
|
-
} catch (err) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
+
} catch (err) {
|
|
203
|
+
console.error(`❌ Failed to create app: ${err.message}`);
|
|
204
|
+
process.exit(1);
|
|
205
|
+
}
|
|
202
206
|
}
|
package/package.json
CHANGED
package/templates/spa/meta.json
CHANGED