@asterflow/cli 2.0.1 → 2.1.0
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/dist/cjs/index.cjs +369 -254
- package/dist/mjs/index.js +373 -258
- package/dist/types/generators/packageJson.d.ts +1 -1
- package/dist/types/helpers/npmVersion.d.ts +19 -0
- package/dist/types/registry/adapters.d.ts +2 -0
- package/dist/types/registry/plugins.d.ts +0 -1
- package/package.json +2 -2
- package/templates/tsdown.config.ts +8 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,30 +1,131 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
3
|
+
var Fe = Object.create;
|
|
4
|
+
var K = Object.defineProperty;
|
|
5
|
+
var Me = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var _e = Object.getOwnPropertyNames;
|
|
7
|
+
var Le = Object.getPrototypeOf, Ge = Object.prototype.hasOwnProperty;
|
|
8
|
+
var Ve = (e, t, n, s) => {
|
|
9
9
|
if (t && typeof t == "object" || typeof t == "function")
|
|
10
|
-
for (let
|
|
11
|
-
!
|
|
10
|
+
for (let o of _e(t))
|
|
11
|
+
!Ge.call(e, o) && o !== n && K(e, o, { get: () => t[o], enumerable: !(s = Me(t, o)) || s.enumerable });
|
|
12
12
|
return e;
|
|
13
13
|
};
|
|
14
|
-
var
|
|
15
|
-
t || !e || !e.__esModule ?
|
|
14
|
+
var C = (e, t, n) => (n = e != null ? Fe(Le(e)) : {}, Ve(
|
|
15
|
+
t || !e || !e.__esModule ? K(n, "default", { value: e, enumerable: !0 }) : n,
|
|
16
16
|
e
|
|
17
17
|
));
|
|
18
18
|
// packages/cli/src/index.ts
|
|
19
|
-
var
|
|
19
|
+
var Se = C(require("yargs"), 1), De = require("yargs/helpers");
|
|
20
20
|
// packages/cli/src/commands/add.ts
|
|
21
|
-
var
|
|
21
|
+
var ae = require("child_process"), le = require("fs"), O = require("fs/promises"), F = require("path"), ce = require("util");
|
|
22
|
+
// packages/cli/package.json
|
|
23
|
+
var U = {
|
|
24
|
+
name: "@asterflow/cli",
|
|
25
|
+
version: "2.1.0",
|
|
26
|
+
description: "CLI for scaffolding AsterFlow projects, adding plugins, and generating the static fs-routing manifest.",
|
|
27
|
+
keywords: [
|
|
28
|
+
"asterflow",
|
|
29
|
+
"cli",
|
|
30
|
+
"scaffolding",
|
|
31
|
+
"generator"
|
|
32
|
+
],
|
|
33
|
+
main: "dist/cjs/index.cjs",
|
|
34
|
+
module: "dist/mjs/index.js",
|
|
35
|
+
types: "dist/types/index.d.ts",
|
|
36
|
+
typings: "dist/types/index.d.ts",
|
|
37
|
+
type: "module",
|
|
38
|
+
license: "MIT",
|
|
39
|
+
author: "Ashu11-A",
|
|
40
|
+
repository: {
|
|
41
|
+
type: "git",
|
|
42
|
+
url: "git+https://github.com/AsterFlow/AsterFlow.git"
|
|
43
|
+
},
|
|
44
|
+
bugs: {
|
|
45
|
+
url: "https://github.com/AsterFlow/AsterFlow/issues"
|
|
46
|
+
},
|
|
47
|
+
homepage: "https://github.com/AsterFlow/AsterFlow",
|
|
48
|
+
bin: {
|
|
49
|
+
asterflow: "dist/cjs/index.cjs"
|
|
50
|
+
},
|
|
51
|
+
exports: {
|
|
52
|
+
".": {
|
|
53
|
+
types: "./dist/types/index.d.ts",
|
|
54
|
+
import: "./dist/mjs/index.js",
|
|
55
|
+
require: "./dist/cjs/index.cjs"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
engines: {
|
|
59
|
+
node: ">=20"
|
|
60
|
+
},
|
|
61
|
+
scripts: {
|
|
62
|
+
dev: "bun run src/index.ts"
|
|
63
|
+
},
|
|
64
|
+
dependencies: {
|
|
65
|
+
"@asterflow/fs": "workspace:../../plugins/fs",
|
|
66
|
+
"@clack/prompts": "^0.9.1",
|
|
67
|
+
chalk: "^4.1.2",
|
|
68
|
+
"ci-info": "^4.1.0",
|
|
69
|
+
"validate-npm-package-name": "^6.0.0",
|
|
70
|
+
yargs: "^18.0.0"
|
|
71
|
+
},
|
|
72
|
+
devDependencies: {
|
|
73
|
+
"@types/validate-npm-package-name": "^4.0.2",
|
|
74
|
+
"@types/yargs": "^17.0.33"
|
|
75
|
+
},
|
|
76
|
+
peerDependencies: {
|
|
77
|
+
typescript: "^5.8.3"
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
// packages/cli/src/helpers/npmVersion.ts
|
|
81
|
+
var Z = "https://registry.npmjs.org", ee = 5e3, [Q, X] = U.version.split(".").map(Number);
|
|
82
|
+
async function Be(e) {
|
|
83
|
+
let t = new AbortController(), n = setTimeout(() => t.abort(), ee);
|
|
84
|
+
try {
|
|
85
|
+
let s = await fetch(`${Z}/${encodeURIComponent(e)}`, {
|
|
86
|
+
signal: t.signal,
|
|
87
|
+
headers: { Accept: "application/vnd.npm.install-v1+json" }
|
|
88
|
+
});
|
|
89
|
+
if (!s.ok) return [];
|
|
90
|
+
let o = await s.json();
|
|
91
|
+
return Object.keys(o.versions ?? {});
|
|
92
|
+
} catch {
|
|
93
|
+
return [];
|
|
94
|
+
} finally {
|
|
95
|
+
clearTimeout(n);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function P(e) {
|
|
99
|
+
let t = await Be(e), n = -1;
|
|
100
|
+
for (let o of t) {
|
|
101
|
+
let f = /^(\d+)\.(\d+)\.(\d+)$/.exec(o);
|
|
102
|
+
if (!f) continue;
|
|
103
|
+
let [, p, c, d] = f;
|
|
104
|
+
Number(p) !== Q || Number(c) !== X || (n = Math.max(n, Number(d)));
|
|
105
|
+
}
|
|
106
|
+
return `^${n >= 0 ? `${Q}.${X}.${n}` : U.version}`;
|
|
107
|
+
}
|
|
108
|
+
async function te(e, t) {
|
|
109
|
+
let n = new AbortController(), s = setTimeout(() => n.abort(), ee);
|
|
110
|
+
try {
|
|
111
|
+
let o = await fetch(`${Z}/${encodeURIComponent(e)}`, {
|
|
112
|
+
signal: n.signal,
|
|
113
|
+
headers: { Accept: "application/vnd.npm.install-v1+json" }
|
|
114
|
+
});
|
|
115
|
+
if (!o.ok) return `^${t}`;
|
|
116
|
+
let p = (await o.json())["dist-tags"]?.latest;
|
|
117
|
+
return p ? `^${p}` : `^${t}`;
|
|
118
|
+
} catch {
|
|
119
|
+
return `^${t}`;
|
|
120
|
+
} finally {
|
|
121
|
+
clearTimeout(s);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
22
124
|
// packages/cli/src/registry/plugins.ts
|
|
23
125
|
var b = {
|
|
24
126
|
fs: {
|
|
25
127
|
id: "fs",
|
|
26
128
|
packageName: "@asterflow/fs",
|
|
27
|
-
version: "^1.0.7",
|
|
28
129
|
description: "File system-based routing - routes are discovered from a routes/ directory.",
|
|
29
130
|
importName: "fsRoutingPlugin",
|
|
30
131
|
useSnippet: ".use(fsRoutingPlugin, { routes })",
|
|
@@ -33,174 +134,184 @@ var b = {
|
|
|
33
134
|
multipart: {
|
|
34
135
|
id: "multipart",
|
|
35
136
|
packageName: "@asterflow/multipart",
|
|
36
|
-
version: "^1.0.0",
|
|
37
137
|
description: "multipart/form-data parsing (file uploads), with per-route type-safe field criteria.",
|
|
38
138
|
importName: "multipartPlugin",
|
|
39
139
|
useSnippet: ".use(multipartPlugin, { limits: { fileSize: 10 * 1024 * 1024 } })",
|
|
40
140
|
usageNote: "Build upload routes with Method.create(Method.POST).multipart({...}).handler(...) - see src/routes/upload.ts for a working example."
|
|
41
141
|
}
|
|
42
|
-
},
|
|
142
|
+
}, st = Object.keys(b);
|
|
43
143
|
// packages/cli/src/utils/log.ts
|
|
44
|
-
var
|
|
45
|
-
info: (e) => console.log(
|
|
46
|
-
success: (e) => console.log(
|
|
47
|
-
warn: (e) => console.log(
|
|
48
|
-
error: (e) => console.error(
|
|
49
|
-
step: (e) => console.log(
|
|
144
|
+
var R = C(require("chalk"), 1), m = {
|
|
145
|
+
info: (e) => console.log(R.default.cyan(e)),
|
|
146
|
+
success: (e) => console.log(R.default.green(e)),
|
|
147
|
+
warn: (e) => console.log(R.default.yellow(e)),
|
|
148
|
+
error: (e) => console.error(R.default.red(e)),
|
|
149
|
+
step: (e) => console.log(R.default.gray(` ${e}`))
|
|
50
150
|
};
|
|
51
151
|
// packages/cli/src/utils/packageManager.ts
|
|
52
|
-
var
|
|
152
|
+
var ne = require("fs"), re = require("path"), We = {
|
|
53
153
|
"bun.lock": "bun",
|
|
54
154
|
"bun.lockb": "bun",
|
|
55
155
|
"pnpm-lock.yaml": "pnpm",
|
|
56
156
|
"yarn.lock": "yarn",
|
|
57
157
|
"package-lock.json": "npm"
|
|
58
158
|
};
|
|
59
|
-
function
|
|
60
|
-
for (let [t,
|
|
61
|
-
if ((0,
|
|
159
|
+
function B(e) {
|
|
160
|
+
for (let [t, n] of Object.entries(We))
|
|
161
|
+
if ((0, ne.existsSync)((0, re.join)(e, t))) return n;
|
|
62
162
|
return "bun";
|
|
63
163
|
}
|
|
64
|
-
function
|
|
65
|
-
return e ??
|
|
164
|
+
function ie(e, t) {
|
|
165
|
+
return e ?? B(t);
|
|
66
166
|
}
|
|
67
|
-
function
|
|
167
|
+
function se(e) {
|
|
68
168
|
return e === "yarn" ? "yarn" : `${e} install`;
|
|
69
169
|
}
|
|
70
|
-
function
|
|
71
|
-
let
|
|
170
|
+
function oe(e, t) {
|
|
171
|
+
let n = t.join(" ");
|
|
72
172
|
switch (e) {
|
|
73
173
|
case "bun":
|
|
74
|
-
return `bun add ${
|
|
174
|
+
return `bun add ${n}`;
|
|
75
175
|
case "pnpm":
|
|
76
|
-
return `pnpm add ${
|
|
176
|
+
return `pnpm add ${n}`;
|
|
77
177
|
case "yarn":
|
|
78
|
-
return `yarn add ${
|
|
178
|
+
return `yarn add ${n}`;
|
|
79
179
|
case "npm":
|
|
80
|
-
return `npm install ${
|
|
180
|
+
return `npm install ${n}`;
|
|
81
181
|
}
|
|
82
182
|
}
|
|
83
183
|
// packages/cli/src/commands/add.ts
|
|
84
|
-
var
|
|
85
|
-
async function
|
|
86
|
-
let
|
|
87
|
-
if (
|
|
88
|
-
|
|
184
|
+
var Ye = (0, ce.promisify)(ae.exec);
|
|
185
|
+
async function pe({ names: e, directory: t }) {
|
|
186
|
+
let n = (0, F.resolve)(t ?? "."), s = (0, F.join)(n, "package.json"), o = e.split(",").map((a) => a.trim()).filter(Boolean);
|
|
187
|
+
if (o.length === 0) {
|
|
188
|
+
m.error("No plugin names given. Usage: asterflow add fs,multipart"), process.exitCode = 1;
|
|
89
189
|
return;
|
|
90
190
|
}
|
|
91
|
-
let
|
|
92
|
-
if (
|
|
93
|
-
|
|
191
|
+
let f = o.filter((a) => !b[a]);
|
|
192
|
+
if (f.length > 0) {
|
|
193
|
+
m.error(`Unknown plugin${f.length > 1 ? "s" : ""}: ${f.join(", ")}`), m.step(`Available plugins: ${Object.keys(b).join(", ")}`), process.exitCode = 1;
|
|
94
194
|
return;
|
|
95
195
|
}
|
|
96
|
-
if (!(0,
|
|
97
|
-
|
|
196
|
+
if (!(0, le.existsSync)(s)) {
|
|
197
|
+
m.error(`No package.json found at ${s}. Run this from an AsterFlow project (or \`asterflow init\` first).`), process.exitCode = 1;
|
|
98
198
|
return;
|
|
99
199
|
}
|
|
100
|
-
let
|
|
101
|
-
|
|
102
|
-
let
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
200
|
+
let p = o.map((a) => b[a]), c = await (0, O.readFile)(s, "utf-8"), d = JSON.parse(c);
|
|
201
|
+
d.dependencies ??= {};
|
|
202
|
+
let k = p.filter((a) => d.dependencies[a.packageName]), g = p.filter((a) => !d.dependencies[a.packageName]), j = await Promise.all(g.map((a) => P(a.packageName)));
|
|
203
|
+
if (g.forEach((a, h) => {
|
|
204
|
+
d.dependencies[a.packageName] = j[h];
|
|
205
|
+
}), d.dependencies = Object.fromEntries(Object.entries(d.dependencies).sort(([a], [h]) => a.localeCompare(h))), g.length > 0) {
|
|
206
|
+
await (0, O.writeFile)(s, `${JSON.stringify(d, null, 2)}
|
|
207
|
+
`), m.success(`Added to package.json: ${g.map((w) => w.packageName).join(", ")}`);
|
|
208
|
+
let a = B(n), h = oe(a, g.map((w) => w.packageName));
|
|
209
|
+
m.info(`Installing (${h})...`);
|
|
109
210
|
try {
|
|
110
|
-
await
|
|
111
|
-
} catch (
|
|
112
|
-
|
|
211
|
+
await Ye(h, { cwd: n }), m.success("Dependencies installed.");
|
|
212
|
+
} catch (w) {
|
|
213
|
+
m.error(`Install failed - run manually: ${h}`), m.step(w instanceof Error ? w.message : String(w));
|
|
113
214
|
}
|
|
114
215
|
}
|
|
115
|
-
|
|
116
|
-
for (let a of
|
|
117
|
-
|
|
216
|
+
k.length > 0 && m.warn(`Already present, skipped: ${k.map((a) => a.packageName).join(", ")}`), m.info("Wire it up:");
|
|
217
|
+
for (let a of p)
|
|
218
|
+
m.step(`import { ${a.importName} } from '${a.packageName}'`), m.step(`app${a.useSnippet}`), m.step(a.usageNote);
|
|
118
219
|
}
|
|
119
220
|
// packages/cli/src/commands/generate.ts
|
|
120
|
-
var
|
|
121
|
-
var
|
|
122
|
-
async function
|
|
123
|
-
let
|
|
221
|
+
var me = require("@asterflow/fs"), ue = require("fs"), E = require("path");
|
|
222
|
+
var Je = "src/routes", de = "src/routes.gen.ts";
|
|
223
|
+
async function ge({ directory: e, out: t, watch: n }) {
|
|
224
|
+
let s = (0, E.resolve)(e ?? Je), o = (0, E.resolve)(t ?? de), f = async () => {
|
|
124
225
|
try {
|
|
125
|
-
await (0,
|
|
126
|
-
} catch (
|
|
127
|
-
|
|
226
|
+
await (0, me.generateRouteManifest)({ routesDir: s, outFile: o }), m.success(`Generated ${(0, E.join)(t ?? de)}`);
|
|
227
|
+
} catch (c) {
|
|
228
|
+
m.error(c instanceof Error ? c.message : String(c)), n || (process.exitCode = 1);
|
|
128
229
|
}
|
|
129
230
|
};
|
|
130
|
-
if (await
|
|
131
|
-
|
|
132
|
-
let
|
|
133
|
-
(0,
|
|
134
|
-
clearTimeout(
|
|
231
|
+
if (await f(), !n) return;
|
|
232
|
+
m.info(`Watching ${s} for changes...`);
|
|
233
|
+
let p;
|
|
234
|
+
(0, ue.watch)(s, { recursive: !0 }, () => {
|
|
235
|
+
clearTimeout(p), p = setTimeout(f, 100);
|
|
135
236
|
});
|
|
136
237
|
}
|
|
137
238
|
// packages/cli/src/commands/init.ts
|
|
138
|
-
var i =
|
|
239
|
+
var i = C(require("@clack/prompts"), 1), z = C(require("ci-info"), 1), Re = require("child_process"), x = require("fs/promises"), u = require("path"), Ee = require("util");
|
|
139
240
|
// packages/cli/src/generators/appEntry.ts
|
|
140
|
-
function
|
|
141
|
-
let
|
|
241
|
+
function fe({ adapter: e, plugins: t, stub: n }) {
|
|
242
|
+
let s = t.some((c) => c.id === "fs"), o = [
|
|
142
243
|
"import { AsterFlow } from 'asterflow'",
|
|
143
244
|
"import { adapters } from '@asterflow/adapter'",
|
|
144
245
|
...e.imports,
|
|
145
|
-
...t.map((
|
|
146
|
-
...
|
|
147
|
-
],
|
|
148
|
-
...t.map((
|
|
149
|
-
...!
|
|
246
|
+
...t.map((c) => `import { ${c.importName} } from '${c.packageName}'`),
|
|
247
|
+
...s ? ["import routes from './routes.gen'"] : []
|
|
248
|
+
], f = [
|
|
249
|
+
...t.map((c) => c.useSnippet.replace(/^\./, "")),
|
|
250
|
+
...!s && n ? [`method('get', {
|
|
150
251
|
path: '/',
|
|
151
252
|
handler({ response }) {
|
|
152
253
|
return response.success({ message: 'Hello from AsterFlow!' })
|
|
153
254
|
}
|
|
154
255
|
})`] : [],
|
|
155
256
|
`listen${e.listenCall}`
|
|
156
|
-
],
|
|
257
|
+
], p = e.preamble ? `${e.preamble}
|
|
157
258
|
` : "";
|
|
158
|
-
return `${
|
|
259
|
+
return `${o.join(`
|
|
159
260
|
`)}
|
|
160
|
-
${
|
|
161
|
-
.${
|
|
261
|
+
${p}export default new AsterFlow({ driver: ${e.driverExpression} })
|
|
262
|
+
.${f.join(`
|
|
162
263
|
.`)}
|
|
163
264
|
`;
|
|
164
265
|
}
|
|
165
266
|
// packages/cli/src/generators/packageJson.ts
|
|
166
|
-
function
|
|
167
|
-
let
|
|
168
|
-
asterflow
|
|
169
|
-
"@asterflow/adapter"
|
|
267
|
+
async function ye({ name: e, adapter: t, plugins: n }) {
|
|
268
|
+
let s = n.some((v) => v.id === "fs"), [o, f, p, c, d, k] = await Promise.all([
|
|
269
|
+
P("asterflow"),
|
|
270
|
+
P("@asterflow/adapter"),
|
|
271
|
+
s ? P("@asterflow/cli") : Promise.resolve(null),
|
|
272
|
+
s ? P("@asterflow/router") : Promise.resolve(null),
|
|
273
|
+
te("tsdown", "0.23.0"),
|
|
274
|
+
Promise.all(n.map((v) => P(v.packageName)))
|
|
275
|
+
]), g = {
|
|
276
|
+
asterflow: o,
|
|
277
|
+
"@asterflow/adapter": f,
|
|
170
278
|
zod: "^3.25.67"
|
|
171
279
|
};
|
|
172
|
-
t.dependency && (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
dev: "bun run src/index.ts",
|
|
177
|
-
|
|
178
|
-
|
|
280
|
+
t.dependency && (g[t.dependency] = "latest"), s && c && (g["@asterflow/router"] = c), n.forEach((v, A) => {
|
|
281
|
+
g[v.packageName] = k[A];
|
|
282
|
+
});
|
|
283
|
+
let j = Object.fromEntries(Object.entries(g).sort(([v], [A]) => v.localeCompare(A))), a = {
|
|
284
|
+
...s ? { predev: "asterflow generate", dev: "bun run src/index.ts", prebuild: "asterflow generate" } : { dev: "bun run src/index.ts" },
|
|
285
|
+
build: "tsdown",
|
|
286
|
+
start: `${t.runCommand} dist/index.mjs`
|
|
287
|
+
}, h = {
|
|
179
288
|
typescript: "^5.8.3",
|
|
180
|
-
"@types/bun": "latest"
|
|
289
|
+
"@types/bun": "latest",
|
|
290
|
+
"@types/node": "latest",
|
|
291
|
+
tsdown: d
|
|
181
292
|
};
|
|
182
|
-
return
|
|
293
|
+
return s && p && (h["@asterflow/cli"] = p), `${JSON.stringify({
|
|
183
294
|
name: e,
|
|
184
295
|
version: "0.1.0",
|
|
185
296
|
type: "module",
|
|
186
297
|
private: !0,
|
|
187
|
-
scripts:
|
|
188
|
-
dependencies:
|
|
189
|
-
devDependencies:
|
|
298
|
+
scripts: a,
|
|
299
|
+
dependencies: j,
|
|
300
|
+
devDependencies: h
|
|
190
301
|
}, null, 2)}
|
|
191
302
|
`;
|
|
192
303
|
}
|
|
193
304
|
// packages/cli/src/helpers/copyTemplate.ts
|
|
194
|
-
var
|
|
195
|
-
async function
|
|
196
|
-
return (0,
|
|
305
|
+
var M = require("fs/promises"), W = require("path"), qe = (0, W.join)(__dirname, "..", "..", "templates");
|
|
306
|
+
async function Y(e) {
|
|
307
|
+
return (0, M.readFile)((0, W.join)(qe, e), "utf-8");
|
|
197
308
|
}
|
|
198
|
-
async function
|
|
199
|
-
let
|
|
200
|
-
await (0,
|
|
309
|
+
async function _(e, t) {
|
|
310
|
+
let n = await Y(e);
|
|
311
|
+
await (0, M.writeFile)(t, n);
|
|
201
312
|
}
|
|
202
313
|
// packages/cli/src/registry/templates.ts
|
|
203
|
-
var
|
|
314
|
+
var he = {
|
|
204
315
|
hello: {
|
|
205
316
|
id: "hello",
|
|
206
317
|
path: "/",
|
|
@@ -214,55 +325,55 @@ var ce = {
|
|
|
214
325
|
plugin: "multipart",
|
|
215
326
|
summary: "File upload handled by @asterflow/multipart."
|
|
216
327
|
}
|
|
217
|
-
},
|
|
218
|
-
function
|
|
328
|
+
}, T = Object.keys(he);
|
|
329
|
+
function L(e) {
|
|
219
330
|
let t = new Set(e);
|
|
220
|
-
return
|
|
331
|
+
return T.map((n) => he[n]).filter((n) => !n.plugin || t.has(n.plugin));
|
|
221
332
|
}
|
|
222
|
-
function
|
|
333
|
+
function we(e) {
|
|
223
334
|
let t = e.path.replace(/^\/+|\/+$/g, "");
|
|
224
335
|
return t.length === 0 ? "index.ts" : `${t}/index.ts`;
|
|
225
336
|
}
|
|
226
337
|
// packages/cli/src/generators/routes.ts
|
|
227
|
-
async function
|
|
338
|
+
async function be({ pluginIds: e, templateIds: t }) {
|
|
228
339
|
if (!e.includes("fs")) return [];
|
|
229
|
-
let
|
|
230
|
-
return Promise.all(
|
|
231
|
-
fileName:
|
|
232
|
-
content: await
|
|
340
|
+
let n = L(e).filter((s) => t.includes(s.id));
|
|
341
|
+
return Promise.all(n.map(async (s) => ({
|
|
342
|
+
fileName: we(s),
|
|
343
|
+
content: await Y(s.source)
|
|
233
344
|
})));
|
|
234
345
|
}
|
|
235
346
|
// packages/cli/src/helpers/git.ts
|
|
236
|
-
var
|
|
237
|
-
function
|
|
347
|
+
var I = require("child_process"), xe = require("fs"), ke = require("path");
|
|
348
|
+
function ze(e) {
|
|
238
349
|
try {
|
|
239
|
-
return (0,
|
|
350
|
+
return (0, I.execSync)("git rev-parse --is-inside-work-tree", { cwd: e, stdio: "ignore" }), !0;
|
|
240
351
|
} catch {
|
|
241
352
|
return !1;
|
|
242
353
|
}
|
|
243
354
|
}
|
|
244
|
-
function
|
|
355
|
+
function He(e) {
|
|
245
356
|
try {
|
|
246
|
-
return (0,
|
|
357
|
+
return (0, I.execSync)("git config init.defaultBranch", { cwd: e, stdio: "ignore" }), !0;
|
|
247
358
|
} catch {
|
|
248
359
|
return !1;
|
|
249
360
|
}
|
|
250
361
|
}
|
|
251
|
-
function
|
|
362
|
+
function ve(e) {
|
|
252
363
|
let t = !1;
|
|
253
364
|
try {
|
|
254
|
-
return (0,
|
|
365
|
+
return (0, I.execSync)("git --version", { stdio: "ignore" }), ze(e) ? !1 : ((0, I.execSync)("git init", { cwd: e, stdio: "ignore" }), t = !0, He(e) || (0, I.execSync)("git checkout -b main", { cwd: e, stdio: "ignore" }), (0, I.execSync)("git add -A", { cwd: e, stdio: "ignore" }), (0, I.execSync)('git commit -m "Initial commit from create-asterflow-app"', { cwd: e, stdio: "ignore" }), !0);
|
|
255
366
|
} catch {
|
|
256
367
|
if (t)
|
|
257
368
|
try {
|
|
258
|
-
(0,
|
|
369
|
+
(0, xe.rmSync)((0, ke.join)(e, ".git"), { recursive: !0, force: !0 });
|
|
259
370
|
} catch {
|
|
260
371
|
}
|
|
261
372
|
return !1;
|
|
262
373
|
}
|
|
263
374
|
}
|
|
264
375
|
// packages/cli/src/helpers/isFolderEmpty.ts
|
|
265
|
-
var
|
|
376
|
+
var G = require("fs"), je = require("path"), J = C(require("chalk"), 1), Ke = new Set([
|
|
266
377
|
".DS_Store",
|
|
267
378
|
".git",
|
|
268
379
|
".gitattributes",
|
|
@@ -277,36 +388,36 @@ var F = require("fs"), ye = require("path"), W = $(require("chalk"), 1), Ue = n
|
|
|
277
388
|
"LICENSE",
|
|
278
389
|
"Thumbs.db"
|
|
279
390
|
]);
|
|
280
|
-
function
|
|
281
|
-
let
|
|
282
|
-
if (
|
|
283
|
-
console.log(`The directory ${
|
|
284
|
-
for (let
|
|
285
|
-
let
|
|
286
|
-
console.log(` ${
|
|
391
|
+
function $e(e, t) {
|
|
392
|
+
let n = (0, G.readdirSync)(e).filter((s) => !Ke.has(s) && !s.endsWith(".iml"));
|
|
393
|
+
if (n.length === 0) return !0;
|
|
394
|
+
console.log(`The directory ${J.default.green(t)} contains files that could conflict:`), console.log();
|
|
395
|
+
for (let s of n) {
|
|
396
|
+
let o = (0, G.lstatSync)((0, je.join)(e, s)).isDirectory();
|
|
397
|
+
console.log(` ${J.default.cyan(s)}${o ? "/" : ""}`);
|
|
287
398
|
}
|
|
288
399
|
return console.log(), console.log("Either try using a new directory name, or remove the files listed above."), console.log(), !1;
|
|
289
400
|
}
|
|
290
401
|
// packages/cli/src/helpers/isWriteable.ts
|
|
291
|
-
var
|
|
292
|
-
async function
|
|
402
|
+
var Pe = require("fs"), Ie = require("fs/promises");
|
|
403
|
+
async function Ae(e) {
|
|
293
404
|
try {
|
|
294
|
-
return await (0,
|
|
405
|
+
return await (0, Ie.access)(e, Pe.constants.W_OK), !0;
|
|
295
406
|
} catch {
|
|
296
407
|
return !1;
|
|
297
408
|
}
|
|
298
409
|
}
|
|
299
410
|
// packages/cli/src/helpers/validateProjectName.ts
|
|
300
|
-
var
|
|
301
|
-
function
|
|
302
|
-
let t = (0,
|
|
411
|
+
var Ce = C(require("validate-npm-package-name"), 1);
|
|
412
|
+
function q(e) {
|
|
413
|
+
let t = (0, Ce.default)(e);
|
|
303
414
|
return t.validForNewPackages ? { valid: !0 } : {
|
|
304
415
|
valid: !1,
|
|
305
416
|
problems: [...t.errors ?? [], ...t.warnings ?? []]
|
|
306
417
|
};
|
|
307
418
|
}
|
|
308
419
|
// packages/cli/src/registry/adapters.ts
|
|
309
|
-
var
|
|
420
|
+
var N = {
|
|
310
421
|
bun: {
|
|
311
422
|
id: "bun",
|
|
312
423
|
label: "Bun (native Bun.serve)",
|
|
@@ -314,6 +425,7 @@ var S = {
|
|
|
314
425
|
imports: [],
|
|
315
426
|
driverExpression: "adapters.bun",
|
|
316
427
|
preamble: null,
|
|
428
|
+
runCommand: "bun",
|
|
317
429
|
listenCall: `({ port: 3333 }, (err) => {
|
|
318
430
|
if (err) {
|
|
319
431
|
console.error(err)
|
|
@@ -329,6 +441,7 @@ var S = {
|
|
|
329
441
|
imports: [],
|
|
330
442
|
driverExpression: "adapters.node",
|
|
331
443
|
preamble: null,
|
|
444
|
+
runCommand: "node",
|
|
332
445
|
listenCall: `({ port: 3333 }, (err) => {
|
|
333
446
|
if (err) {
|
|
334
447
|
console.error(err)
|
|
@@ -344,6 +457,7 @@ var S = {
|
|
|
344
457
|
imports: ["import express from 'express'"],
|
|
345
458
|
driverExpression: "adapters.express",
|
|
346
459
|
preamble: "const server = express()",
|
|
460
|
+
runCommand: "node",
|
|
347
461
|
listenCall: `(server, 3333, () => {
|
|
348
462
|
console.log('Server listening on http://localhost:3333')
|
|
349
463
|
})`
|
|
@@ -355,6 +469,7 @@ var S = {
|
|
|
355
469
|
imports: ["import fastify from 'fastify'"],
|
|
356
470
|
driverExpression: "adapters.fastify",
|
|
357
471
|
preamble: "const server = fastify()",
|
|
472
|
+
runCommand: "node",
|
|
358
473
|
listenCall: `(server, { port: 3333 }, (err) => {
|
|
359
474
|
if (err) {
|
|
360
475
|
console.error(err)
|
|
@@ -363,191 +478,191 @@ var S = {
|
|
|
363
478
|
console.log('Server listening on http://localhost:3333')
|
|
364
479
|
})`
|
|
365
480
|
}
|
|
366
|
-
},
|
|
481
|
+
}, S = Object.keys(N);
|
|
367
482
|
// packages/cli/src/commands/init.ts
|
|
368
|
-
var
|
|
483
|
+
var Qe = (0, Ee.promisify)(Re.exec), $ = {
|
|
369
484
|
adapter: "bun",
|
|
370
485
|
plugins: ["fs", "multipart"],
|
|
371
486
|
install: !0,
|
|
372
487
|
git: !0
|
|
373
488
|
};
|
|
374
|
-
async function
|
|
489
|
+
async function Te(e) {
|
|
375
490
|
i.intro("Create a new AsterFlow project");
|
|
376
|
-
let t = (0,
|
|
377
|
-
if (!await
|
|
491
|
+
let t = (0, u.resolve)(e.directory ?? "."), n = (0, u.basename)(t) === "." ? "my-asterflow-app" : (0, u.basename)(t);
|
|
492
|
+
if (!await Ae((0, u.dirname)(t))) {
|
|
378
493
|
i.cancel(`The path ${t} is not writable. Check folder permissions and try again.`), process.exitCode = 1;
|
|
379
494
|
return;
|
|
380
495
|
}
|
|
381
|
-
if (await (0,
|
|
496
|
+
if (await (0, x.mkdir)(t, { recursive: !0 }), !$e(t, (0, u.basename)(t))) {
|
|
382
497
|
process.exitCode = 1;
|
|
383
498
|
return;
|
|
384
499
|
}
|
|
385
|
-
let
|
|
500
|
+
let s = process.argv.some((r) => r.startsWith("--")), o = z.default.isCI || !!e.yes || s, f = s && !e.yes && !z.default.isCI;
|
|
386
501
|
if (e.name) {
|
|
387
|
-
let
|
|
388
|
-
if (!
|
|
502
|
+
let r = q(e.name);
|
|
503
|
+
if (!r.valid) {
|
|
389
504
|
i.cancel(`Invalid project name "${e.name}":
|
|
390
|
-
${
|
|
505
|
+
${r.problems.map((l) => ` - ${l}`).join(`
|
|
391
506
|
`)}`), process.exitCode = 1;
|
|
392
507
|
return;
|
|
393
508
|
}
|
|
394
509
|
}
|
|
395
|
-
let
|
|
396
|
-
if (
|
|
397
|
-
if (
|
|
398
|
-
|
|
510
|
+
let p = e.name;
|
|
511
|
+
if (p === void 0)
|
|
512
|
+
if (o)
|
|
513
|
+
p = n;
|
|
399
514
|
else {
|
|
400
|
-
let
|
|
515
|
+
let r = await i.text({
|
|
401
516
|
message: "Project name",
|
|
402
|
-
placeholder:
|
|
403
|
-
defaultValue:
|
|
404
|
-
validate: (
|
|
405
|
-
let
|
|
406
|
-
return
|
|
517
|
+
placeholder: n,
|
|
518
|
+
defaultValue: n,
|
|
519
|
+
validate: (l) => {
|
|
520
|
+
let y = q(l || n);
|
|
521
|
+
return y.valid ? void 0 : `Invalid project name: ${y.problems[0]}`;
|
|
407
522
|
}
|
|
408
523
|
});
|
|
409
|
-
if (i.isCancel(
|
|
410
|
-
|
|
524
|
+
if (i.isCancel(r)) return i.cancel("Cancelled.");
|
|
525
|
+
p = r;
|
|
411
526
|
}
|
|
412
|
-
if (e.adapter && !
|
|
413
|
-
i.cancel(`Unknown adapter "${e.adapter}". Available: ${
|
|
527
|
+
if (e.adapter && !N[e.adapter]) {
|
|
528
|
+
i.cancel(`Unknown adapter "${e.adapter}". Available: ${S.join(", ")}`), process.exitCode = 1;
|
|
414
529
|
return;
|
|
415
530
|
}
|
|
416
|
-
let
|
|
417
|
-
if (!
|
|
418
|
-
if (
|
|
419
|
-
|
|
531
|
+
let c = e.adapter;
|
|
532
|
+
if (!c)
|
|
533
|
+
if (o)
|
|
534
|
+
c = $.adapter;
|
|
420
535
|
else {
|
|
421
|
-
let
|
|
536
|
+
let r = await i.select({
|
|
422
537
|
message: "Which adapter do you want to use?",
|
|
423
|
-
options: Object.values(
|
|
424
|
-
initialValue:
|
|
538
|
+
options: Object.values(N).map((l) => ({ value: l.id, label: l.label })),
|
|
539
|
+
initialValue: $.adapter
|
|
425
540
|
});
|
|
426
|
-
if (i.isCancel(
|
|
427
|
-
|
|
541
|
+
if (i.isCancel(r)) return i.cancel("Cancelled.");
|
|
542
|
+
c = r;
|
|
428
543
|
}
|
|
429
|
-
let
|
|
544
|
+
let d;
|
|
430
545
|
if (e.plugins !== void 0) {
|
|
431
|
-
|
|
432
|
-
let
|
|
433
|
-
if (
|
|
434
|
-
i.cancel(`Unknown plugin${
|
|
546
|
+
d = e.plugins.split(",").map((l) => l.trim()).filter(Boolean);
|
|
547
|
+
let r = d.filter((l) => !b[l]);
|
|
548
|
+
if (r.length > 0) {
|
|
549
|
+
i.cancel(`Unknown plugin${r.length > 1 ? "s" : ""}: ${r.join(", ")}. Available: ${Object.keys(b).join(", ")}`), process.exitCode = 1;
|
|
435
550
|
return;
|
|
436
551
|
}
|
|
437
|
-
} else if (
|
|
438
|
-
|
|
552
|
+
} else if (o)
|
|
553
|
+
d = $.plugins;
|
|
439
554
|
else {
|
|
440
|
-
let
|
|
555
|
+
let r = await i.multiselect({
|
|
441
556
|
message: "Which plugins do you want to install? (space to select, enter to confirm)",
|
|
442
|
-
options: Object.values(b).map((
|
|
443
|
-
initialValues:
|
|
557
|
+
options: Object.values(b).map((l) => ({ value: l.id, label: l.packageName, hint: l.description })),
|
|
558
|
+
initialValues: $.plugins,
|
|
444
559
|
required: !1
|
|
445
560
|
});
|
|
446
|
-
if (i.isCancel(
|
|
447
|
-
|
|
561
|
+
if (i.isCancel(r)) return i.cancel("Cancelled.");
|
|
562
|
+
d = r;
|
|
448
563
|
}
|
|
449
|
-
|
|
450
|
-
let
|
|
564
|
+
d.length === 0 && (d = $.plugins);
|
|
565
|
+
let k = L(d), g;
|
|
451
566
|
if (e.routes !== void 0) {
|
|
452
|
-
let
|
|
453
|
-
|
|
454
|
-
let
|
|
455
|
-
if (
|
|
456
|
-
i.cancel(`Unknown route template${
|
|
567
|
+
let r = e.routes.split(",").map((y) => y.trim()).filter(Boolean);
|
|
568
|
+
g = r.includes("none") ? [] : r;
|
|
569
|
+
let l = g.filter((y) => !k.some((Oe) => Oe.id === y));
|
|
570
|
+
if (l.length > 0) {
|
|
571
|
+
i.cancel(`Unknown route template${l.length > 1 ? "s" : ""}: ${l.join(", ")}. Available: ${k.map((y) => y.id).join(", ")}`), process.exitCode = 1;
|
|
457
572
|
return;
|
|
458
573
|
}
|
|
459
|
-
} else if (
|
|
460
|
-
|
|
574
|
+
} else if (o)
|
|
575
|
+
g = k.map((r) => r.id);
|
|
461
576
|
else {
|
|
462
|
-
let
|
|
577
|
+
let r = await i.multiselect({
|
|
463
578
|
message: "Which example routes do you want to scaffold? (space to select, enter to confirm)",
|
|
464
|
-
options:
|
|
465
|
-
initialValues:
|
|
579
|
+
options: k.map((l) => ({ value: l.id, label: l.path, hint: l.summary })),
|
|
580
|
+
initialValues: k.map((l) => l.id),
|
|
466
581
|
required: !1
|
|
467
582
|
});
|
|
468
|
-
if (i.isCancel(
|
|
469
|
-
|
|
583
|
+
if (i.isCancel(r)) return i.cancel("Cancelled.");
|
|
584
|
+
g = r;
|
|
470
585
|
}
|
|
471
|
-
let
|
|
472
|
-
if (
|
|
473
|
-
if (
|
|
474
|
-
|
|
586
|
+
let j = e.install;
|
|
587
|
+
if (j === void 0)
|
|
588
|
+
if (o)
|
|
589
|
+
j = $.install;
|
|
475
590
|
else {
|
|
476
|
-
let
|
|
477
|
-
if (i.isCancel(
|
|
478
|
-
|
|
591
|
+
let r = await i.confirm({ message: "Install dependencies now?", initialValue: $.install });
|
|
592
|
+
if (i.isCancel(r)) return i.cancel("Cancelled.");
|
|
593
|
+
j = r;
|
|
479
594
|
}
|
|
480
|
-
let
|
|
481
|
-
if (
|
|
482
|
-
if (
|
|
483
|
-
|
|
595
|
+
let a = e.git;
|
|
596
|
+
if (a === void 0)
|
|
597
|
+
if (o)
|
|
598
|
+
a = $.git;
|
|
484
599
|
else {
|
|
485
|
-
let
|
|
486
|
-
if (i.isCancel(
|
|
487
|
-
|
|
600
|
+
let r = await i.confirm({ message: "Initialize a git repository?", initialValue: $.git });
|
|
601
|
+
if (i.isCancel(r)) return i.cancel("Cancelled.");
|
|
602
|
+
a = r;
|
|
488
603
|
}
|
|
489
|
-
|
|
604
|
+
f && Xe({
|
|
490
605
|
adapter: e.adapter === void 0,
|
|
491
606
|
plugins: e.plugins === void 0,
|
|
492
607
|
routes: e.routes === void 0,
|
|
493
608
|
install: e.install === void 0,
|
|
494
609
|
git: e.git === void 0
|
|
495
|
-
}, { adapterId:
|
|
496
|
-
let
|
|
497
|
-
|
|
498
|
-
let
|
|
499
|
-
await (0,
|
|
610
|
+
}, { adapterId: c, pluginIds: d, templateIds: g, install: j, git: a });
|
|
611
|
+
let h = N[c], w = d.map((r) => b[r]), v = i.spinner();
|
|
612
|
+
v.start("Scaffolding project");
|
|
613
|
+
let A = (0, u.join)(t, "src");
|
|
614
|
+
await (0, x.mkdir)(A, { recursive: !0 }), await (0, x.writeFile)((0, u.join)(t, "package.json"), await ye({ name: p, adapter: h, plugins: w })), await _("tsconfig.json", (0, u.join)(t, "tsconfig.json")), await _("tsdown.config.ts", (0, u.join)(t, "tsdown.config.ts")), await (0, x.writeFile)((0, u.join)(A, "index.ts"), fe({ adapter: h, plugins: w, stub: g.length > 0 })), await _("gitignore", (0, u.join)(t, ".gitignore")), w.some((r) => r.id === "fs") && await (0, x.appendFile)((0, u.join)(t, ".gitignore"), `src/routes.gen.ts
|
|
500
615
|
`);
|
|
501
|
-
let
|
|
502
|
-
if (
|
|
503
|
-
let
|
|
504
|
-
await (0,
|
|
505
|
-
for (let
|
|
506
|
-
let
|
|
507
|
-
await (0,
|
|
616
|
+
let H = await be({ pluginIds: d, templateIds: g });
|
|
617
|
+
if (H.length > 0) {
|
|
618
|
+
let r = (0, u.join)(A, "routes");
|
|
619
|
+
await (0, x.mkdir)(r, { recursive: !0 });
|
|
620
|
+
for (let l of H) {
|
|
621
|
+
let y = (0, u.join)(r, l.fileName);
|
|
622
|
+
await (0, x.mkdir)((0, u.dirname)(y), { recursive: !0 }), await (0, x.writeFile)(y, l.content);
|
|
508
623
|
}
|
|
509
624
|
}
|
|
510
|
-
|
|
511
|
-
let
|
|
512
|
-
if (
|
|
513
|
-
let
|
|
514
|
-
|
|
625
|
+
v.stop("Project scaffolded");
|
|
626
|
+
let V = ie(e.packageManager, t);
|
|
627
|
+
if (j) {
|
|
628
|
+
let r = se(V), l = i.spinner();
|
|
629
|
+
l.start(`Installing dependencies (${r})`);
|
|
515
630
|
try {
|
|
516
|
-
await
|
|
517
|
-
} catch (
|
|
518
|
-
|
|
631
|
+
await Qe(r, { cwd: t }), l.stop("Dependencies installed");
|
|
632
|
+
} catch (y) {
|
|
633
|
+
l.stop("Failed to install dependencies"), i.log.error(y instanceof Error ? y.message : String(y));
|
|
519
634
|
}
|
|
520
635
|
}
|
|
521
|
-
|
|
522
|
-
for (let
|
|
523
|
-
i.log.info(`${
|
|
524
|
-
|
|
636
|
+
a && ve(t) && i.log.success("Initialized a git repository.");
|
|
637
|
+
for (let r of w)
|
|
638
|
+
i.log.info(`${r.packageName}: ${r.usageNote}`);
|
|
639
|
+
Ze({ name: p, targetDir: t, packageManager: V, useYarn: V === "yarn" });
|
|
525
640
|
}
|
|
526
|
-
function
|
|
527
|
-
let
|
|
528
|
-
e.adapter &&
|
|
641
|
+
function Xe(e, t) {
|
|
642
|
+
let n = [];
|
|
643
|
+
e.adapter && n.push(` --adapter <id> ${t.adapterId} (available: ${S.join(", ")})`), e.plugins && n.push(` --plugins <ids> ${t.pluginIds.length > 0 ? t.pluginIds.join(",") : "none"} (available: ${Object.keys(b).join(", ")})`), e.routes && n.push(` --routes <ids> ${t.templateIds.length > 0 ? t.templateIds.join(",") : "none"} (available: ${T.join(", ")})`), e.install && n.push(` --no-install skip installing dependencies (default: ${t.install ? "installs" : "skips"})`), e.git && n.push(` --no-git skip git init (default: ${t.git ? "inits" : "skips"})`), n.length !== 0 && i.note(n.join(`
|
|
529
644
|
`), "Using defaults for unprovided options");
|
|
530
645
|
}
|
|
531
|
-
function
|
|
532
|
-
let
|
|
646
|
+
function Ze({ name: e, targetDir: t, packageManager: n, useYarn: s }) {
|
|
647
|
+
let o = `${n} ${s ? "" : "run "}dev`;
|
|
533
648
|
i.note(`cd ${t}
|
|
534
|
-
${
|
|
649
|
+
${o}`, "Next steps"), i.outro(`Success! Created ${e} at ${t}`);
|
|
535
650
|
}
|
|
536
651
|
// packages/cli/src/commands/list.ts
|
|
537
|
-
var
|
|
538
|
-
function
|
|
539
|
-
console.log(
|
|
652
|
+
var D = C(require("chalk"), 1);
|
|
653
|
+
function Ne() {
|
|
654
|
+
console.log(D.default.bold(`
|
|
540
655
|
Available AsterFlow plugins:
|
|
541
656
|
`));
|
|
542
657
|
for (let e of Object.values(b))
|
|
543
|
-
console.log(` ${
|
|
658
|
+
console.log(` ${D.default.cyan(e.id.padEnd(12))} ${D.default.gray(e.packageName)}`), console.log(` ${" ".repeat(12)} ${e.description}
|
|
544
659
|
`);
|
|
545
|
-
console.log(
|
|
660
|
+
console.log(D.default.gray(`Install with: asterflow add <name>[,<name>...]
|
|
546
661
|
`));
|
|
547
662
|
}
|
|
548
663
|
// packages/cli/src/index.ts
|
|
549
664
|
(async () => {
|
|
550
|
-
await (0,
|
|
665
|
+
await (0, Se.default)((0, De.hideBin)(process.argv)).scriptName("asterflow").command(
|
|
551
666
|
"init [directory]",
|
|
552
667
|
"Scaffold a new AsterFlow project",
|
|
553
668
|
(e) => e.positional("directory", {
|
|
@@ -558,13 +673,13 @@ Available AsterFlow plugins:
|
|
|
558
673
|
describe: "Project name (defaults to the directory name)"
|
|
559
674
|
}).option("adapter", {
|
|
560
675
|
type: "string",
|
|
561
|
-
describe: `Adapter to use (${
|
|
676
|
+
describe: `Adapter to use (${S.join(", ")})`
|
|
562
677
|
}).option("plugins", {
|
|
563
678
|
type: "string",
|
|
564
679
|
describe: "Comma-separated plugin ids, e.g. fs,multipart"
|
|
565
680
|
}).option("routes", {
|
|
566
681
|
type: "string",
|
|
567
|
-
describe: `Comma-separated route template ids to scaffold, or "none" (${
|
|
682
|
+
describe: `Comma-separated route template ids to scaffold, or "none" (${T.join(", ")})`
|
|
568
683
|
}).option("install", {
|
|
569
684
|
type: "boolean",
|
|
570
685
|
describe: "Install dependencies (default: yes)"
|
|
@@ -580,7 +695,7 @@ Available AsterFlow plugins:
|
|
|
580
695
|
}),
|
|
581
696
|
async (e) => {
|
|
582
697
|
let t = e.useNpm ? "npm" : e.usePnpm ? "pnpm" : e.useYarn ? "yarn" : e.useBun ? "bun" : void 0;
|
|
583
|
-
await
|
|
698
|
+
await Te({
|
|
584
699
|
directory: e.directory,
|
|
585
700
|
name: e.name,
|
|
586
701
|
adapter: e.adapter,
|
|
@@ -605,14 +720,14 @@ Available AsterFlow plugins:
|
|
|
605
720
|
describe: "Project directory (defaults to the current directory)"
|
|
606
721
|
}),
|
|
607
722
|
async (e) => {
|
|
608
|
-
await
|
|
723
|
+
await pe({ names: e.names, directory: e.directory });
|
|
609
724
|
}
|
|
610
725
|
).command(
|
|
611
726
|
"list",
|
|
612
727
|
"List available plugins",
|
|
613
728
|
() => {
|
|
614
729
|
},
|
|
615
|
-
() =>
|
|
730
|
+
() => Ne()
|
|
616
731
|
).command(
|
|
617
732
|
"generate [directory]",
|
|
618
733
|
"Generate the static route manifest consumed by @asterflow/fs (fs-routing)",
|
|
@@ -629,7 +744,7 @@ Available AsterFlow plugins:
|
|
|
629
744
|
describe: "Regenerate whenever a file under the routes directory changes"
|
|
630
745
|
}),
|
|
631
746
|
async (e) => {
|
|
632
|
-
await
|
|
747
|
+
await ge({ directory: e.directory, out: e.out, watch: e.watch });
|
|
633
748
|
}
|
|
634
749
|
).demandCommand(1, "Specify a command: init, add, list or generate").strict().help().alias("help", "h").parse();
|
|
635
750
|
})().catch((e) => {
|