create-fuzionx 0.1.29 → 0.1.31
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 +20 -13
- package/index.js +25 -13
- package/package.json +1 -1
- package/templates/.gitignore.tpl +1 -0
- package/templates/package.json.tpl +5 -1
package/fx.js
CHANGED
|
@@ -48,19 +48,26 @@ if (existsSync(localBin) || existsSync(localCli)) {
|
|
|
48
48
|
fx new <name> 새 프로젝트 스캐폴딩
|
|
49
49
|
|
|
50
50
|
프로젝트 내 명령어 (@fuzionx/framework 필요):
|
|
51
|
-
fx make:
|
|
52
|
-
fx make:
|
|
53
|
-
fx make:service <Name>
|
|
54
|
-
fx make:
|
|
55
|
-
fx make:
|
|
56
|
-
fx make:
|
|
57
|
-
fx make:
|
|
58
|
-
fx make:
|
|
59
|
-
fx
|
|
60
|
-
fx
|
|
61
|
-
fx
|
|
62
|
-
fx
|
|
63
|
-
fx
|
|
51
|
+
fx make:app --type=ssr|spa Create app (fixed name: app/ssr or app/spa)
|
|
52
|
+
fx make:controller <Name> --app= Create controller (app-specific)
|
|
53
|
+
fx make:service <Name> --app= Create service (app-specific)
|
|
54
|
+
fx make:model <Name> Create model (database/models)
|
|
55
|
+
fx make:middleware <Name> --app= Create middleware (app-specific)
|
|
56
|
+
fx make:job <Name> Create job (shared/jobs)
|
|
57
|
+
fx make:task <Name> Create task (shared/jobs)
|
|
58
|
+
fx make:ws <Name> --app= Create WsHandler (app-specific)
|
|
59
|
+
fx make:event <Name> Create event handler (shared/events)
|
|
60
|
+
fx make:worker <Name> Create worker (shared/workers)
|
|
61
|
+
fx make:test <Name> Create test
|
|
62
|
+
fx dev Start dev server (--watch)
|
|
63
|
+
fx dev:spa Start dev server + Vite HMR
|
|
64
|
+
fx build:spa Build SPA for production
|
|
65
|
+
fx stop Stop server (graceful)
|
|
66
|
+
fx restart Restart server (graceful)
|
|
67
|
+
fx test Run tests
|
|
68
|
+
fx routes Print route table
|
|
69
|
+
fx config Print fuzionx.yaml
|
|
70
|
+
fx db:sync Sync models → DB (--apply)
|
|
64
71
|
`);
|
|
65
72
|
} else {
|
|
66
73
|
console.error(`❌ @fuzionx/framework가 설치되지 않았습니다.`);
|
package/index.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
6
|
* npx create-fuzionx my-app
|
|
7
|
-
* npx create-fuzionx my-app
|
|
7
|
+
* npx create-fuzionx my-app --type=spa
|
|
8
|
+
* npx create-fuzionx my-app --type=ssr
|
|
8
9
|
*/
|
|
9
10
|
import { promises as fs } from 'node:fs';
|
|
10
11
|
import path from 'node:path';
|
|
@@ -74,8 +75,9 @@ const APP_DIRS = [
|
|
|
74
75
|
|
|
75
76
|
// ── createApp ──
|
|
76
77
|
|
|
77
|
-
async function createApp(name, targetDir) {
|
|
78
|
+
async function createApp(name, targetDir, type = 'spa') {
|
|
78
79
|
const dir = targetDir || path.resolve(name);
|
|
80
|
+
const appName = type; // 앱 이름은 타입에 따라 고정
|
|
79
81
|
const vars = {
|
|
80
82
|
name,
|
|
81
83
|
dbName: name.replace(/-/g, '_'),
|
|
@@ -102,7 +104,8 @@ async function createApp(name, targetDir) {
|
|
|
102
104
|
// fuzionx 앱 — .tpl 파일 (치환 필요)
|
|
103
105
|
for (const { tpl, dest } of FUZIONX_TPL_FILES) {
|
|
104
106
|
const content = await loadTemplate(tpl, vars);
|
|
105
|
-
const
|
|
107
|
+
const actualDest = dest.replace('app/fuzionx/', `app/${appName}/`);
|
|
108
|
+
const fullPath = path.join(dir, actualDest);
|
|
106
109
|
await fs.mkdir(path.dirname(fullPath), { recursive: true });
|
|
107
110
|
await fs.writeFile(fullPath, content);
|
|
108
111
|
}
|
|
@@ -111,11 +114,11 @@ async function createApp(name, targetDir) {
|
|
|
111
114
|
const fuzionxSrc = path.join(TPL_DIR, 'fuzionx');
|
|
112
115
|
await copyDirRecursive(
|
|
113
116
|
path.join(fuzionxSrc, 'controllers'),
|
|
114
|
-
path.join(dir,
|
|
117
|
+
path.join(dir, `app/${appName}/controllers`),
|
|
115
118
|
);
|
|
116
119
|
await copyDirRecursive(
|
|
117
120
|
path.join(fuzionxSrc, 'views'),
|
|
118
|
-
path.join(dir,
|
|
121
|
+
path.join(dir, `app/${appName}/views`),
|
|
119
122
|
);
|
|
120
123
|
|
|
121
124
|
// tester 앱 — 전체 복사
|
|
@@ -147,30 +150,39 @@ async function createApp(name, targetDir) {
|
|
|
147
150
|
|
|
148
151
|
// ── CLI 엔트리 ──
|
|
149
152
|
|
|
150
|
-
const
|
|
151
|
-
const
|
|
153
|
+
const allArgs = process.argv.slice(2);
|
|
154
|
+
const name = allArgs.find(a => !a.startsWith('--'));
|
|
155
|
+
const typeFlag = allArgs.find(a => a.startsWith('--type='));
|
|
156
|
+
const type = typeFlag?.split('=')[1] || 'spa';
|
|
152
157
|
|
|
153
158
|
if (!name) {
|
|
154
159
|
console.error(`
|
|
155
|
-
Usage: npx create-fuzionx <app-name> [
|
|
160
|
+
Usage: npx create-fuzionx <app-name> [--type=ssr|spa]
|
|
156
161
|
|
|
157
162
|
Examples:
|
|
158
|
-
npx create-fuzionx my-app
|
|
159
|
-
npx create-fuzionx my-app
|
|
163
|
+
npx create-fuzionx my-app # default: spa
|
|
164
|
+
npx create-fuzionx my-app --type=ssr # MPA (SSR)
|
|
165
|
+
npx create-fuzionx my-app --type=spa # SPA (Vue.js 3 + SSR)
|
|
160
166
|
`);
|
|
161
167
|
process.exit(1);
|
|
162
168
|
}
|
|
163
169
|
|
|
170
|
+
const validTypes = ['ssr', 'spa'];
|
|
171
|
+
if (!validTypes.includes(type)) {
|
|
172
|
+
console.error(`❌ Unknown type: ${type}. Available: ${validTypes.join(', ')}`);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
|
|
164
176
|
try {
|
|
165
|
-
const dir = await createApp(name,
|
|
177
|
+
const dir = await createApp(name, null, type);
|
|
166
178
|
console.log(`
|
|
167
|
-
✅ Created ${name} at ${dir}
|
|
179
|
+
✅ Created ${name} at ${dir} (type: ${type})
|
|
168
180
|
|
|
169
181
|
Next steps:
|
|
170
182
|
|
|
171
183
|
cd ${name}
|
|
172
184
|
npm install
|
|
173
|
-
npx fx dev
|
|
185
|
+
npx fx dev${type === 'spa' ? ':spa' : ''}
|
|
174
186
|
`);
|
|
175
187
|
} catch (err) {
|
|
176
188
|
console.error(`❌ Failed to create app: ${err.message}`);
|
package/package.json
CHANGED
package/templates/.gitignore.tpl
CHANGED
|
@@ -4,13 +4,17 @@
|
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "fx dev",
|
|
7
|
+
"dev:spa": "fx dev:spa",
|
|
8
|
+
"build:spa": "fx build:spa",
|
|
7
9
|
"test": "vitest run"
|
|
8
10
|
},
|
|
9
11
|
"dependencies": {
|
|
10
|
-
"@fuzionx/framework": "^0.1.
|
|
12
|
+
"@fuzionx/framework": "^0.1.31",
|
|
13
|
+
"@fuzionx/client": "^0.1.30",
|
|
11
14
|
"joi": "^18.1.1"
|
|
12
15
|
},
|
|
13
16
|
"devDependencies": {
|
|
17
|
+
"concurrently": "^9.0.0",
|
|
14
18
|
"vitest": "^3.0.0"
|
|
15
19
|
}
|
|
16
20
|
}
|