@flight-framework/cli 0.3.4 → 0.3.5
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/README.md +544 -544
- package/dist/bin.js +830 -148
- package/dist/bin.js.map +1 -1
- package/dist/index.js +830 -148
- package/dist/index.js.map +1 -1
- package/package.json +53 -53
- package/templates/angular/index.html +13 -13
- package/templates/angular/package.json.template +25 -25
- package/templates/angular/src/app.component.ts +13 -13
- package/templates/angular/src/main.server.ts +11 -11
- package/templates/angular/src/main.ts +4 -4
- package/templates/angular/tsconfig.json +16 -16
- package/templates/base/README.md.template +26 -26
- package/templates/base/_gitignore +25 -25
- package/templates/base/flight.config.ts.template +15 -15
- package/templates/base/styles/global.css +58 -58
- package/templates/htmx/index.html +18 -18
- package/templates/htmx/package.json.template +18 -18
- package/templates/htmx/vite.config.ts +6 -6
- package/templates/lit/index.html +14 -14
- package/templates/lit/package.json.template +21 -21
- package/templates/lit/src/app-root.ts +18 -18
- package/templates/lit/src/entry-client.ts +5 -5
- package/templates/lit/src/entry-server.ts +9 -9
- package/templates/lit/tsconfig.json +18 -18
- package/templates/lit/vite.config.ts +6 -6
- package/templates/preact/index.html +14 -14
- package/templates/preact/package.json.template +22 -22
- package/templates/preact/src/App.tsx +8 -8
- package/templates/preact/src/entry-client.tsx +11 -11
- package/templates/preact/src/entry-server.tsx +6 -6
- package/templates/preact/tsconfig.json +18 -18
- package/templates/preact/vite.config.ts +8 -8
- package/templates/qwik/index.html +14 -14
- package/templates/qwik/package.json.template +20 -20
- package/templates/qwik/src/App.tsx +10 -10
- package/templates/qwik/src/entry-client.tsx +4 -4
- package/templates/qwik/src/entry-server.tsx +9 -9
- package/templates/qwik/tsconfig.json +18 -18
- package/templates/qwik/vite.config.ts +8 -8
- package/templates/react/index.html +13 -13
- package/templates/react/package.json.template +24 -24
- package/templates/react/src/App.tsx +13 -13
- package/templates/react/src/context/RouterContext.tsx +63 -63
- package/templates/react/src/entry-client.tsx +19 -19
- package/templates/react/src/entry-server.tsx +17 -17
- package/templates/react/tsconfig.json +19 -19
- package/templates/react/vite.config.ts +12 -12
- package/templates/solid/index.html +14 -14
- package/templates/solid/package.json.template +21 -21
- package/templates/solid/src/App.tsx +8 -8
- package/templates/solid/src/entry-client.tsx +11 -11
- package/templates/solid/src/entry-server.tsx +6 -6
- package/templates/solid/tsconfig.json +18 -18
- package/templates/solid/vite.config.ts +8 -8
- package/templates/svelte/index.html +14 -14
- package/templates/svelte/package.json.template +21 -21
- package/templates/svelte/src/App.svelte +4 -4
- package/templates/svelte/src/entry-client.ts +7 -7
- package/templates/svelte/src/entry-server.ts +7 -7
- package/templates/svelte/tsconfig.json +17 -17
- package/templates/svelte/vite.config.ts +8 -8
- package/templates/use-cases/api/README.md +41 -41
- package/templates/use-cases/api/package.json.template +14 -14
- package/templates/use-cases/api/src/routes/api/health.get.ts.template +3 -3
- package/templates/use-cases/blog/README.md +47 -47
- package/templates/use-cases/blog/flight.config.ts.template +11 -11
- package/templates/use-cases/blog/package.json.template +15 -15
- package/templates/use-cases/blog/src/routes/blog/[slug].page.tsx.template +23 -23
- package/templates/use-cases/blog/src/routes/index.page.tsx.template +9 -9
- package/templates/use-cases/docs/README.md +49 -49
- package/templates/use-cases/docs/package.json.template +15 -15
- package/templates/use-cases/docs/src/content/index.md.template +16 -16
- package/templates/use-cases/ecommerce/README.md +32 -32
- package/templates/use-cases/ecommerce/package.json.template +16 -16
- package/templates/use-cases/ecommerce/src/routes/index.page.tsx.template +9 -9
- package/templates/use-cases/saas/README.md +34 -34
- package/templates/use-cases/saas/package.json.template +15 -15
- package/templates/use-cases/saas/src/routes/index.page.tsx.template +9 -9
- package/templates/vanilla/index.html +14 -14
- package/templates/vanilla/package.json.template +19 -19
- package/templates/vanilla/src/main.ts +10 -10
- package/templates/vanilla/tsconfig.json +16 -16
- package/templates/vanilla/vite.config.ts +6 -6
- package/templates/vue/index.html +14 -14
- package/templates/vue/package.json.template +21 -21
- package/templates/vue/src/App.vue +6 -6
- package/templates/vue/src/entry-client.ts +12 -12
- package/templates/vue/src/entry-server.ts +8 -8
- package/templates/vue/tsconfig.json +17 -17
- package/templates/vue/vite.config.ts +8 -8
- package/LICENSE +0 -21
package/dist/bin.js
CHANGED
|
@@ -1,24 +1,706 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2
8
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
9
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
10
|
}) : x)(function(x) {
|
|
5
11
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
12
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
13
|
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
35
|
+
var require_picocolors = __commonJS({
|
|
36
|
+
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
37
|
+
"use strict";
|
|
38
|
+
var p = process || {};
|
|
39
|
+
var argv = p.argv || [];
|
|
40
|
+
var env = p.env || {};
|
|
41
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
42
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
43
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
44
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
45
|
+
};
|
|
46
|
+
var replaceClose = (string, close, replace, index) => {
|
|
47
|
+
let result = "", cursor = 0;
|
|
48
|
+
do {
|
|
49
|
+
result += string.substring(cursor, index) + replace;
|
|
50
|
+
cursor = index + close.length;
|
|
51
|
+
index = string.indexOf(close, cursor);
|
|
52
|
+
} while (~index);
|
|
53
|
+
return result + string.substring(cursor);
|
|
54
|
+
};
|
|
55
|
+
var createColors = (enabled = isColorSupported) => {
|
|
56
|
+
let f = enabled ? formatter : () => String;
|
|
57
|
+
return {
|
|
58
|
+
isColorSupported: enabled,
|
|
59
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
60
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
61
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
62
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
63
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
64
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
65
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
66
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
67
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
68
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
69
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
70
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
71
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
72
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
73
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
74
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
75
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
76
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
77
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
78
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
79
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
80
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
81
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
82
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
83
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
84
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
85
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
86
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
87
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
88
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
89
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
90
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
91
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
92
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
93
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
94
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
95
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
96
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
97
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
98
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
99
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
module.exports = createColors();
|
|
103
|
+
module.exports.createColors = createColors;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
|
|
108
|
+
import { EventEmitter } from "events";
|
|
109
|
+
function toArr(any) {
|
|
110
|
+
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
111
|
+
}
|
|
112
|
+
function toVal(out, key, val, opts) {
|
|
113
|
+
var x, old = out[key], nxt = !!~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : !!~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
114
|
+
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
115
|
+
}
|
|
116
|
+
function mri2(args, opts) {
|
|
117
|
+
args = args || [];
|
|
118
|
+
opts = opts || {};
|
|
119
|
+
var k, arr, arg, name, val, out = { _: [] };
|
|
120
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
121
|
+
const alibi = opts.alias !== void 0;
|
|
122
|
+
const strict = opts.unknown !== void 0;
|
|
123
|
+
const defaults = opts.default !== void 0;
|
|
124
|
+
opts.alias = opts.alias || {};
|
|
125
|
+
opts.string = toArr(opts.string);
|
|
126
|
+
opts.boolean = toArr(opts.boolean);
|
|
127
|
+
if (alibi) {
|
|
128
|
+
for (k in opts.alias) {
|
|
129
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
130
|
+
for (i = 0; i < arr.length; i++) {
|
|
131
|
+
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (i = opts.boolean.length; i-- > 0; ) {
|
|
136
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
137
|
+
for (j = arr.length; j-- > 0; ) opts.boolean.push(arr[j]);
|
|
138
|
+
}
|
|
139
|
+
for (i = opts.string.length; i-- > 0; ) {
|
|
140
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
141
|
+
for (j = arr.length; j-- > 0; ) opts.string.push(arr[j]);
|
|
142
|
+
}
|
|
143
|
+
if (defaults) {
|
|
144
|
+
for (k in opts.default) {
|
|
145
|
+
name = typeof opts.default[k];
|
|
146
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
147
|
+
if (opts[name] !== void 0) {
|
|
148
|
+
opts[name].push(k);
|
|
149
|
+
for (i = 0; i < arr.length; i++) {
|
|
150
|
+
opts[name].push(arr[i]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
156
|
+
for (i = 0; i < len; i++) {
|
|
157
|
+
arg = args[i];
|
|
158
|
+
if (arg === "--") {
|
|
159
|
+
out._ = out._.concat(args.slice(++i));
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
for (j = 0; j < arg.length; j++) {
|
|
163
|
+
if (arg.charCodeAt(j) !== 45) break;
|
|
164
|
+
}
|
|
165
|
+
if (j === 0) {
|
|
166
|
+
out._.push(arg);
|
|
167
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
168
|
+
name = arg.substring(j + 3);
|
|
169
|
+
if (strict && !~keys.indexOf(name)) {
|
|
170
|
+
return opts.unknown(arg);
|
|
171
|
+
}
|
|
172
|
+
out[name] = false;
|
|
173
|
+
} else {
|
|
174
|
+
for (idx = j + 1; idx < arg.length; idx++) {
|
|
175
|
+
if (arg.charCodeAt(idx) === 61) break;
|
|
176
|
+
}
|
|
177
|
+
name = arg.substring(j, idx);
|
|
178
|
+
val = arg.substring(++idx) || (i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i]);
|
|
179
|
+
arr = j === 2 ? [name] : name;
|
|
180
|
+
for (idx = 0; idx < arr.length; idx++) {
|
|
181
|
+
name = arr[idx];
|
|
182
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
|
|
183
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (defaults) {
|
|
188
|
+
for (k in opts.default) {
|
|
189
|
+
if (out[k] === void 0) {
|
|
190
|
+
out[k] = opts.default[k];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (alibi) {
|
|
195
|
+
for (k in out) {
|
|
196
|
+
arr = opts.alias[k] || [];
|
|
197
|
+
while (arr.length > 0) {
|
|
198
|
+
out[arr.shift()] = out[k];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
var removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
205
|
+
var findAllBrackets = (v) => {
|
|
206
|
+
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
207
|
+
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
208
|
+
const res = [];
|
|
209
|
+
const parse = (match) => {
|
|
210
|
+
let variadic = false;
|
|
211
|
+
let value = match[1];
|
|
212
|
+
if (value.startsWith("...")) {
|
|
213
|
+
value = value.slice(3);
|
|
214
|
+
variadic = true;
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
required: match[0].startsWith("<"),
|
|
218
|
+
value,
|
|
219
|
+
variadic
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
let angledMatch;
|
|
223
|
+
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
|
|
224
|
+
res.push(parse(angledMatch));
|
|
225
|
+
}
|
|
226
|
+
let squareMatch;
|
|
227
|
+
while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
|
|
228
|
+
res.push(parse(squareMatch));
|
|
229
|
+
}
|
|
230
|
+
return res;
|
|
231
|
+
};
|
|
232
|
+
var getMriOptions = (options) => {
|
|
233
|
+
const result = { alias: {}, boolean: [] };
|
|
234
|
+
for (const [index, option] of options.entries()) {
|
|
235
|
+
if (option.names.length > 1) {
|
|
236
|
+
result.alias[option.names[0]] = option.names.slice(1);
|
|
237
|
+
}
|
|
238
|
+
if (option.isBoolean) {
|
|
239
|
+
if (option.negated) {
|
|
240
|
+
const hasStringTypeOption = options.some((o, i) => {
|
|
241
|
+
return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
|
|
242
|
+
});
|
|
243
|
+
if (!hasStringTypeOption) {
|
|
244
|
+
result.boolean.push(option.names[0]);
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
result.boolean.push(option.names[0]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return result;
|
|
252
|
+
};
|
|
253
|
+
var findLongest = (arr) => {
|
|
254
|
+
return arr.sort((a, b) => {
|
|
255
|
+
return a.length > b.length ? -1 : 1;
|
|
256
|
+
})[0];
|
|
257
|
+
};
|
|
258
|
+
var padRight = (str, length) => {
|
|
259
|
+
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
260
|
+
};
|
|
261
|
+
var camelcase = (input) => {
|
|
262
|
+
return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
263
|
+
return p1 + p2.toUpperCase();
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
var setDotProp = (obj, keys, val) => {
|
|
267
|
+
let i = 0;
|
|
268
|
+
let length = keys.length;
|
|
269
|
+
let t = obj;
|
|
270
|
+
let x;
|
|
271
|
+
for (; i < length; ++i) {
|
|
272
|
+
x = t[keys[i]];
|
|
273
|
+
t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
var setByType = (obj, transforms) => {
|
|
277
|
+
for (const key of Object.keys(transforms)) {
|
|
278
|
+
const transform = transforms[key];
|
|
279
|
+
if (transform.shouldTransform) {
|
|
280
|
+
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
281
|
+
if (typeof transform.transformFunction === "function") {
|
|
282
|
+
obj[key] = obj[key].map(transform.transformFunction);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var getFileName = (input) => {
|
|
288
|
+
const m = /([^\\\/]+)$/.exec(input);
|
|
289
|
+
return m ? m[1] : "";
|
|
290
|
+
};
|
|
291
|
+
var camelcaseOptionName = (name) => {
|
|
292
|
+
return name.split(".").map((v, i) => {
|
|
293
|
+
return i === 0 ? camelcase(v) : v;
|
|
294
|
+
}).join(".");
|
|
295
|
+
};
|
|
296
|
+
var CACError = class extends Error {
|
|
297
|
+
constructor(message) {
|
|
298
|
+
super(message);
|
|
299
|
+
this.name = this.constructor.name;
|
|
300
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
301
|
+
Error.captureStackTrace(this, this.constructor);
|
|
302
|
+
} else {
|
|
303
|
+
this.stack = new Error(message).stack;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
var Option = class {
|
|
308
|
+
constructor(rawName, description, config) {
|
|
309
|
+
this.rawName = rawName;
|
|
310
|
+
this.description = description;
|
|
311
|
+
this.config = Object.assign({}, config);
|
|
312
|
+
rawName = rawName.replace(/\.\*/g, "");
|
|
313
|
+
this.negated = false;
|
|
314
|
+
this.names = removeBrackets(rawName).split(",").map((v) => {
|
|
315
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
316
|
+
if (name.startsWith("no-")) {
|
|
317
|
+
this.negated = true;
|
|
318
|
+
name = name.replace(/^no-/, "");
|
|
319
|
+
}
|
|
320
|
+
return camelcaseOptionName(name);
|
|
321
|
+
}).sort((a, b) => a.length > b.length ? 1 : -1);
|
|
322
|
+
this.name = this.names[this.names.length - 1];
|
|
323
|
+
if (this.negated && this.config.default == null) {
|
|
324
|
+
this.config.default = true;
|
|
325
|
+
}
|
|
326
|
+
if (rawName.includes("<")) {
|
|
327
|
+
this.required = true;
|
|
328
|
+
} else if (rawName.includes("[")) {
|
|
329
|
+
this.required = false;
|
|
330
|
+
} else {
|
|
331
|
+
this.isBoolean = true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
var processArgs = process.argv;
|
|
336
|
+
var platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
337
|
+
var Command = class {
|
|
338
|
+
constructor(rawName, description, config = {}, cli2) {
|
|
339
|
+
this.rawName = rawName;
|
|
340
|
+
this.description = description;
|
|
341
|
+
this.config = config;
|
|
342
|
+
this.cli = cli2;
|
|
343
|
+
this.options = [];
|
|
344
|
+
this.aliasNames = [];
|
|
345
|
+
this.name = removeBrackets(rawName);
|
|
346
|
+
this.args = findAllBrackets(rawName);
|
|
347
|
+
this.examples = [];
|
|
348
|
+
}
|
|
349
|
+
usage(text) {
|
|
350
|
+
this.usageText = text;
|
|
351
|
+
return this;
|
|
352
|
+
}
|
|
353
|
+
allowUnknownOptions() {
|
|
354
|
+
this.config.allowUnknownOptions = true;
|
|
355
|
+
return this;
|
|
356
|
+
}
|
|
357
|
+
ignoreOptionDefaultValue() {
|
|
358
|
+
this.config.ignoreOptionDefaultValue = true;
|
|
359
|
+
return this;
|
|
360
|
+
}
|
|
361
|
+
version(version, customFlags = "-v, --version") {
|
|
362
|
+
this.versionNumber = version;
|
|
363
|
+
this.option(customFlags, "Display version number");
|
|
364
|
+
return this;
|
|
365
|
+
}
|
|
366
|
+
example(example) {
|
|
367
|
+
this.examples.push(example);
|
|
368
|
+
return this;
|
|
369
|
+
}
|
|
370
|
+
option(rawName, description, config) {
|
|
371
|
+
const option = new Option(rawName, description, config);
|
|
372
|
+
this.options.push(option);
|
|
373
|
+
return this;
|
|
374
|
+
}
|
|
375
|
+
alias(name) {
|
|
376
|
+
this.aliasNames.push(name);
|
|
377
|
+
return this;
|
|
378
|
+
}
|
|
379
|
+
action(callback) {
|
|
380
|
+
this.commandAction = callback;
|
|
381
|
+
return this;
|
|
382
|
+
}
|
|
383
|
+
isMatched(name) {
|
|
384
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
385
|
+
}
|
|
386
|
+
get isDefaultCommand() {
|
|
387
|
+
return this.name === "" || this.aliasNames.includes("!");
|
|
388
|
+
}
|
|
389
|
+
get isGlobalCommand() {
|
|
390
|
+
return this instanceof GlobalCommand;
|
|
391
|
+
}
|
|
392
|
+
hasOption(name) {
|
|
393
|
+
name = name.split(".")[0];
|
|
394
|
+
return this.options.find((option) => {
|
|
395
|
+
return option.names.includes(name);
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
outputHelp() {
|
|
399
|
+
const { name, commands } = this.cli;
|
|
400
|
+
const {
|
|
401
|
+
versionNumber,
|
|
402
|
+
options: globalOptions,
|
|
403
|
+
helpCallback
|
|
404
|
+
} = this.cli.globalCommand;
|
|
405
|
+
let sections = [
|
|
406
|
+
{
|
|
407
|
+
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
408
|
+
}
|
|
409
|
+
];
|
|
410
|
+
sections.push({
|
|
411
|
+
title: "Usage",
|
|
412
|
+
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
413
|
+
});
|
|
414
|
+
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
415
|
+
if (showCommands) {
|
|
416
|
+
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
417
|
+
sections.push({
|
|
418
|
+
title: "Commands",
|
|
419
|
+
body: commands.map((command) => {
|
|
420
|
+
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
421
|
+
}).join("\n")
|
|
422
|
+
});
|
|
423
|
+
sections.push({
|
|
424
|
+
title: `For more info, run any command with the \`--help\` flag`,
|
|
425
|
+
body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
|
|
429
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) {
|
|
430
|
+
options = options.filter((option) => option.name !== "version");
|
|
431
|
+
}
|
|
432
|
+
if (options.length > 0) {
|
|
433
|
+
const longestOptionName = findLongest(options.map((option) => option.rawName));
|
|
434
|
+
sections.push({
|
|
435
|
+
title: "Options",
|
|
436
|
+
body: options.map((option) => {
|
|
437
|
+
return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === void 0 ? "" : `(default: ${option.config.default})`}`;
|
|
438
|
+
}).join("\n")
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
if (this.examples.length > 0) {
|
|
442
|
+
sections.push({
|
|
443
|
+
title: "Examples",
|
|
444
|
+
body: this.examples.map((example) => {
|
|
445
|
+
if (typeof example === "function") {
|
|
446
|
+
return example(name);
|
|
447
|
+
}
|
|
448
|
+
return example;
|
|
449
|
+
}).join("\n")
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
if (helpCallback) {
|
|
453
|
+
sections = helpCallback(sections) || sections;
|
|
454
|
+
}
|
|
455
|
+
console.log(sections.map((section) => {
|
|
456
|
+
return section.title ? `${section.title}:
|
|
457
|
+
${section.body}` : section.body;
|
|
458
|
+
}).join("\n\n"));
|
|
459
|
+
}
|
|
460
|
+
outputVersion() {
|
|
461
|
+
const { name } = this.cli;
|
|
462
|
+
const { versionNumber } = this.cli.globalCommand;
|
|
463
|
+
if (versionNumber) {
|
|
464
|
+
console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
checkRequiredArgs() {
|
|
468
|
+
const minimalArgsCount = this.args.filter((arg) => arg.required).length;
|
|
469
|
+
if (this.cli.args.length < minimalArgsCount) {
|
|
470
|
+
throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
checkUnknownOptions() {
|
|
474
|
+
const { options, globalCommand } = this.cli;
|
|
475
|
+
if (!this.config.allowUnknownOptions) {
|
|
476
|
+
for (const name of Object.keys(options)) {
|
|
477
|
+
if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
|
|
478
|
+
throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
checkOptionValue() {
|
|
484
|
+
const { options: parsedOptions, globalCommand } = this.cli;
|
|
485
|
+
const options = [...globalCommand.options, ...this.options];
|
|
486
|
+
for (const option of options) {
|
|
487
|
+
const value = parsedOptions[option.name.split(".")[0]];
|
|
488
|
+
if (option.required) {
|
|
489
|
+
const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
|
|
490
|
+
if (value === true || value === false && !hasNegated) {
|
|
491
|
+
throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
var GlobalCommand = class extends Command {
|
|
498
|
+
constructor(cli2) {
|
|
499
|
+
super("@@global@@", "", {}, cli2);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
var __assign = Object.assign;
|
|
503
|
+
var CAC = class extends EventEmitter {
|
|
504
|
+
constructor(name = "") {
|
|
505
|
+
super();
|
|
506
|
+
this.name = name;
|
|
507
|
+
this.commands = [];
|
|
508
|
+
this.rawArgs = [];
|
|
509
|
+
this.args = [];
|
|
510
|
+
this.options = {};
|
|
511
|
+
this.globalCommand = new GlobalCommand(this);
|
|
512
|
+
this.globalCommand.usage("<command> [options]");
|
|
513
|
+
}
|
|
514
|
+
usage(text) {
|
|
515
|
+
this.globalCommand.usage(text);
|
|
516
|
+
return this;
|
|
517
|
+
}
|
|
518
|
+
command(rawName, description, config) {
|
|
519
|
+
const command = new Command(rawName, description || "", config, this);
|
|
520
|
+
command.globalCommand = this.globalCommand;
|
|
521
|
+
this.commands.push(command);
|
|
522
|
+
return command;
|
|
523
|
+
}
|
|
524
|
+
option(rawName, description, config) {
|
|
525
|
+
this.globalCommand.option(rawName, description, config);
|
|
526
|
+
return this;
|
|
527
|
+
}
|
|
528
|
+
help(callback) {
|
|
529
|
+
this.globalCommand.option("-h, --help", "Display this message");
|
|
530
|
+
this.globalCommand.helpCallback = callback;
|
|
531
|
+
this.showHelpOnExit = true;
|
|
532
|
+
return this;
|
|
533
|
+
}
|
|
534
|
+
version(version, customFlags = "-v, --version") {
|
|
535
|
+
this.globalCommand.version(version, customFlags);
|
|
536
|
+
this.showVersionOnExit = true;
|
|
537
|
+
return this;
|
|
538
|
+
}
|
|
539
|
+
example(example) {
|
|
540
|
+
this.globalCommand.example(example);
|
|
541
|
+
return this;
|
|
542
|
+
}
|
|
543
|
+
outputHelp() {
|
|
544
|
+
if (this.matchedCommand) {
|
|
545
|
+
this.matchedCommand.outputHelp();
|
|
546
|
+
} else {
|
|
547
|
+
this.globalCommand.outputHelp();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
outputVersion() {
|
|
551
|
+
this.globalCommand.outputVersion();
|
|
552
|
+
}
|
|
553
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
554
|
+
this.args = args;
|
|
555
|
+
this.options = options;
|
|
556
|
+
if (matchedCommand) {
|
|
557
|
+
this.matchedCommand = matchedCommand;
|
|
558
|
+
}
|
|
559
|
+
if (matchedCommandName) {
|
|
560
|
+
this.matchedCommandName = matchedCommandName;
|
|
561
|
+
}
|
|
562
|
+
return this;
|
|
563
|
+
}
|
|
564
|
+
unsetMatchedCommand() {
|
|
565
|
+
this.matchedCommand = void 0;
|
|
566
|
+
this.matchedCommandName = void 0;
|
|
567
|
+
}
|
|
568
|
+
parse(argv = processArgs, {
|
|
569
|
+
run: run2 = true
|
|
570
|
+
} = {}) {
|
|
571
|
+
this.rawArgs = argv;
|
|
572
|
+
if (!this.name) {
|
|
573
|
+
this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
574
|
+
}
|
|
575
|
+
let shouldParse = true;
|
|
576
|
+
for (const command of this.commands) {
|
|
577
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
578
|
+
const commandName = parsed.args[0];
|
|
579
|
+
if (command.isMatched(commandName)) {
|
|
580
|
+
shouldParse = false;
|
|
581
|
+
const parsedInfo = __assign(__assign({}, parsed), {
|
|
582
|
+
args: parsed.args.slice(1)
|
|
583
|
+
});
|
|
584
|
+
this.setParsedInfo(parsedInfo, command, commandName);
|
|
585
|
+
this.emit(`command:${commandName}`, command);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
if (shouldParse) {
|
|
589
|
+
for (const command of this.commands) {
|
|
590
|
+
if (command.name === "") {
|
|
591
|
+
shouldParse = false;
|
|
592
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
593
|
+
this.setParsedInfo(parsed, command);
|
|
594
|
+
this.emit(`command:!`, command);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
if (shouldParse) {
|
|
599
|
+
const parsed = this.mri(argv.slice(2));
|
|
600
|
+
this.setParsedInfo(parsed);
|
|
601
|
+
}
|
|
602
|
+
if (this.options.help && this.showHelpOnExit) {
|
|
603
|
+
this.outputHelp();
|
|
604
|
+
run2 = false;
|
|
605
|
+
this.unsetMatchedCommand();
|
|
606
|
+
}
|
|
607
|
+
if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
|
|
608
|
+
this.outputVersion();
|
|
609
|
+
run2 = false;
|
|
610
|
+
this.unsetMatchedCommand();
|
|
611
|
+
}
|
|
612
|
+
const parsedArgv = { args: this.args, options: this.options };
|
|
613
|
+
if (run2) {
|
|
614
|
+
this.runMatchedCommand();
|
|
615
|
+
}
|
|
616
|
+
if (!this.matchedCommand && this.args[0]) {
|
|
617
|
+
this.emit("command:*");
|
|
618
|
+
}
|
|
619
|
+
return parsedArgv;
|
|
620
|
+
}
|
|
621
|
+
mri(argv, command) {
|
|
622
|
+
const cliOptions = [
|
|
623
|
+
...this.globalCommand.options,
|
|
624
|
+
...command ? command.options : []
|
|
625
|
+
];
|
|
626
|
+
const mriOptions = getMriOptions(cliOptions);
|
|
627
|
+
let argsAfterDoubleDashes = [];
|
|
628
|
+
const doubleDashesIndex = argv.indexOf("--");
|
|
629
|
+
if (doubleDashesIndex > -1) {
|
|
630
|
+
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
631
|
+
argv = argv.slice(0, doubleDashesIndex);
|
|
632
|
+
}
|
|
633
|
+
let parsed = mri2(argv, mriOptions);
|
|
634
|
+
parsed = Object.keys(parsed).reduce((res, name) => {
|
|
635
|
+
return __assign(__assign({}, res), {
|
|
636
|
+
[camelcaseOptionName(name)]: parsed[name]
|
|
637
|
+
});
|
|
638
|
+
}, { _: [] });
|
|
639
|
+
const args = parsed._;
|
|
640
|
+
const options = {
|
|
641
|
+
"--": argsAfterDoubleDashes
|
|
642
|
+
};
|
|
643
|
+
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
644
|
+
let transforms = /* @__PURE__ */ Object.create(null);
|
|
645
|
+
for (const cliOption of cliOptions) {
|
|
646
|
+
if (!ignoreDefault && cliOption.config.default !== void 0) {
|
|
647
|
+
for (const name of cliOption.names) {
|
|
648
|
+
options[name] = cliOption.config.default;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
if (Array.isArray(cliOption.config.type)) {
|
|
652
|
+
if (transforms[cliOption.name] === void 0) {
|
|
653
|
+
transforms[cliOption.name] = /* @__PURE__ */ Object.create(null);
|
|
654
|
+
transforms[cliOption.name]["shouldTransform"] = true;
|
|
655
|
+
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
for (const key of Object.keys(parsed)) {
|
|
660
|
+
if (key !== "_") {
|
|
661
|
+
const keys = key.split(".");
|
|
662
|
+
setDotProp(options, keys, parsed[key]);
|
|
663
|
+
setByType(options, transforms);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
args,
|
|
668
|
+
options
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
runMatchedCommand() {
|
|
672
|
+
const { args, options, matchedCommand: command } = this;
|
|
673
|
+
if (!command || !command.commandAction)
|
|
674
|
+
return;
|
|
675
|
+
command.checkUnknownOptions();
|
|
676
|
+
command.checkOptionValue();
|
|
677
|
+
command.checkRequiredArgs();
|
|
678
|
+
const actionArgs = [];
|
|
679
|
+
command.args.forEach((arg, index) => {
|
|
680
|
+
if (arg.variadic) {
|
|
681
|
+
actionArgs.push(args.slice(index));
|
|
682
|
+
} else {
|
|
683
|
+
actionArgs.push(args[index]);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
actionArgs.push(options);
|
|
687
|
+
return command.commandAction.apply(this, actionArgs);
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
var cac = (name = "") => new CAC(name);
|
|
8
691
|
|
|
9
692
|
// src/index.ts
|
|
10
|
-
|
|
11
|
-
import pc7 from "picocolors";
|
|
693
|
+
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
12
694
|
|
|
13
695
|
// src/version.ts
|
|
14
696
|
var VERSION = "0.0.1";
|
|
15
697
|
|
|
16
698
|
// src/commands/create.ts
|
|
699
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
17
700
|
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, copyFileSync, unlinkSync } from "fs";
|
|
18
701
|
import { join, resolve, dirname } from "path";
|
|
19
702
|
import { execSync } from "child_process";
|
|
20
703
|
import { fileURLToPath } from "url";
|
|
21
|
-
import pc from "picocolors";
|
|
22
704
|
import prompts from "prompts";
|
|
23
705
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
24
706
|
var TEMPLATES_DIR = resolve(__dirname, "../../templates");
|
|
@@ -40,7 +722,7 @@ var BUNDLERS = [
|
|
|
40
722
|
];
|
|
41
723
|
async function createCommand(name, options) {
|
|
42
724
|
printLogo();
|
|
43
|
-
console.log(
|
|
725
|
+
console.log(import_picocolors.default.cyan("\n[*] Creating a new Flight project...\n"));
|
|
44
726
|
let projectName = name;
|
|
45
727
|
let uiFramework = options.ui;
|
|
46
728
|
if (!projectName) {
|
|
@@ -58,7 +740,7 @@ async function createCommand(name, options) {
|
|
|
58
740
|
projectName = response.name;
|
|
59
741
|
}
|
|
60
742
|
if (!projectName) {
|
|
61
|
-
console.log(
|
|
743
|
+
console.log(import_picocolors.default.red("Project creation cancelled."));
|
|
62
744
|
return;
|
|
63
745
|
}
|
|
64
746
|
if (options.raw) {
|
|
@@ -87,7 +769,7 @@ async function createCommand(name, options) {
|
|
|
87
769
|
uiFramework = response.ui;
|
|
88
770
|
}
|
|
89
771
|
if (!uiFramework) {
|
|
90
|
-
console.log(
|
|
772
|
+
console.log(import_picocolors.default.red("Project creation cancelled."));
|
|
91
773
|
return;
|
|
92
774
|
}
|
|
93
775
|
let useCase = options.useCase;
|
|
@@ -105,7 +787,7 @@ async function createCommand(name, options) {
|
|
|
105
787
|
bundler = response.bundler;
|
|
106
788
|
}
|
|
107
789
|
if (!bundler) {
|
|
108
|
-
console.log(
|
|
790
|
+
console.log(import_picocolors.default.red("Project creation cancelled."));
|
|
109
791
|
return;
|
|
110
792
|
}
|
|
111
793
|
const projectPath = resolve(process.cwd(), projectName);
|
|
@@ -119,12 +801,12 @@ async function createCommand(name, options) {
|
|
|
119
801
|
initial: false
|
|
120
802
|
});
|
|
121
803
|
if (!response.overwrite) {
|
|
122
|
-
console.log(
|
|
804
|
+
console.log(import_picocolors.default.red("Project creation cancelled."));
|
|
123
805
|
return;
|
|
124
806
|
}
|
|
125
807
|
}
|
|
126
808
|
}
|
|
127
|
-
console.log(
|
|
809
|
+
console.log(import_picocolors.default.dim(`
|
|
128
810
|
Creating project in ${projectPath}...
|
|
129
811
|
`));
|
|
130
812
|
try {
|
|
@@ -133,42 +815,42 @@ Creating project in ${projectPath}...
|
|
|
133
815
|
} else {
|
|
134
816
|
copyTemplate(projectPath, uiFramework, bundler, projectName);
|
|
135
817
|
}
|
|
136
|
-
console.log(
|
|
818
|
+
console.log(import_picocolors.default.green("[OK]") + " Project structure created");
|
|
137
819
|
if (options.git) {
|
|
138
820
|
try {
|
|
139
821
|
execSync("git init", { cwd: projectPath, stdio: "ignore" });
|
|
140
|
-
console.log(
|
|
822
|
+
console.log(import_picocolors.default.green("\u2713") + " Git repository initialized");
|
|
141
823
|
} catch {
|
|
142
|
-
console.log(
|
|
824
|
+
console.log(import_picocolors.default.yellow("[!]") + " Could not initialize git repository");
|
|
143
825
|
}
|
|
144
826
|
}
|
|
145
827
|
if (options.install) {
|
|
146
|
-
console.log(
|
|
828
|
+
console.log(import_picocolors.default.dim("\nInstalling dependencies...\n"));
|
|
147
829
|
try {
|
|
148
830
|
const pm = detectPackageManager();
|
|
149
831
|
execSync(`${pm} install`, { cwd: projectPath, stdio: "inherit" });
|
|
150
|
-
console.log(
|
|
832
|
+
console.log(import_picocolors.default.green("\n\u2713") + " Dependencies installed");
|
|
151
833
|
} catch {
|
|
152
|
-
console.log(
|
|
834
|
+
console.log(import_picocolors.default.yellow("\n[!]") + " Could not install dependencies. Run `npm install` manually.");
|
|
153
835
|
}
|
|
154
836
|
}
|
|
155
837
|
console.log(`
|
|
156
|
-
${
|
|
838
|
+
${import_picocolors.default.green("[OK] Project created successfully!")}
|
|
157
839
|
|
|
158
|
-
${
|
|
840
|
+
${import_picocolors.default.cyan("Next steps:")}
|
|
159
841
|
|
|
160
|
-
${
|
|
161
|
-
${
|
|
842
|
+
${import_picocolors.default.dim("$")} cd ${projectName}
|
|
843
|
+
${import_picocolors.default.dim("$")} ${options.install ? "" : "npm install && "}npm run dev
|
|
162
844
|
|
|
163
|
-
${
|
|
164
|
-
${
|
|
165
|
-
${
|
|
166
|
-
${
|
|
845
|
+
${import_picocolors.default.dim("Your project is 100% yours:")}
|
|
846
|
+
${import_picocolors.default.dim("\u2022")} No telemetry
|
|
847
|
+
${import_picocolors.default.dim("\u2022")} No lock-in
|
|
848
|
+
${import_picocolors.default.dim("\u2022")} Deploy anywhere
|
|
167
849
|
|
|
168
|
-
${
|
|
850
|
+
${import_picocolors.default.cyan("Happy flying!")}
|
|
169
851
|
`);
|
|
170
852
|
} catch (error) {
|
|
171
|
-
console.error(
|
|
853
|
+
console.error(import_picocolors.default.red("Failed to create project:"), error);
|
|
172
854
|
process.exit(1);
|
|
173
855
|
}
|
|
174
856
|
}
|
|
@@ -351,27 +1033,27 @@ if (detectRuntime() === 'node') {
|
|
|
351
1033
|
}
|
|
352
1034
|
}
|
|
353
1035
|
console.log(`
|
|
354
|
-
${
|
|
1036
|
+
${import_picocolors.default.green("[OK] Raw project created!")}
|
|
355
1037
|
|
|
356
|
-
${
|
|
1038
|
+
${import_picocolors.default.bold("ZERO dependencies. ZERO lock-in. 100% Web Standards.")}
|
|
357
1039
|
|
|
358
|
-
${
|
|
1040
|
+
${import_picocolors.default.cyan("Run with any runtime:")}
|
|
359
1041
|
|
|
360
|
-
${
|
|
1042
|
+
${import_picocolors.default.dim("# Bun (fastest)")}
|
|
361
1043
|
bun server.js
|
|
362
1044
|
|
|
363
|
-
${
|
|
1045
|
+
${import_picocolors.default.dim("# Deno")}
|
|
364
1046
|
deno run --allow-net server.js
|
|
365
1047
|
|
|
366
|
-
${
|
|
1048
|
+
${import_picocolors.default.dim("# Node.js 22+")}
|
|
367
1049
|
node server.js
|
|
368
1050
|
|
|
369
|
-
${
|
|
370
|
-
flight add http ${
|
|
371
|
-
flight add db ${
|
|
372
|
-
flight add cache ${
|
|
1051
|
+
${import_picocolors.default.dim("Want to add Flight later? Just run:")}
|
|
1052
|
+
flight add http ${import_picocolors.default.dim("# HTTP server with routing")}
|
|
1053
|
+
flight add db ${import_picocolors.default.dim("# Database abstraction")}
|
|
1054
|
+
flight add cache ${import_picocolors.default.dim("# Caching layer")}
|
|
373
1055
|
|
|
374
|
-
${
|
|
1056
|
+
${import_picocolors.default.dim("Path:")} ${projectPath}
|
|
375
1057
|
`);
|
|
376
1058
|
}
|
|
377
1059
|
function createEmptyProject(projectPath, projectName, options) {
|
|
@@ -401,23 +1083,23 @@ function createEmptyProject(projectPath, projectName, options) {
|
|
|
401
1083
|
}
|
|
402
1084
|
}
|
|
403
1085
|
console.log(`
|
|
404
|
-
${
|
|
1086
|
+
${import_picocolors.default.green("[OK] Empty project created!")}
|
|
405
1087
|
|
|
406
|
-
${
|
|
1088
|
+
${import_picocolors.default.cyan("Your project is a blank canvas.")} Add what you need:
|
|
407
1089
|
|
|
408
|
-
${
|
|
1090
|
+
${import_picocolors.default.dim("# HTTP server")}
|
|
409
1091
|
npm install @flight-framework/http
|
|
410
1092
|
|
|
411
|
-
${
|
|
1093
|
+
${import_picocolors.default.dim("# Database")}
|
|
412
1094
|
npm install @flight-framework/db
|
|
413
1095
|
|
|
414
|
-
${
|
|
1096
|
+
${import_picocolors.default.dim("# Cache")}
|
|
415
1097
|
npm install @flight-framework/cache
|
|
416
1098
|
|
|
417
|
-
${
|
|
1099
|
+
${import_picocolors.default.dim("# Authentication")}
|
|
418
1100
|
npm install @flight-framework/auth
|
|
419
1101
|
|
|
420
|
-
${
|
|
1102
|
+
${import_picocolors.default.dim("Path:")} ${projectPath}
|
|
421
1103
|
`);
|
|
422
1104
|
}
|
|
423
1105
|
function createMinimalProject(projectPath, projectName, options) {
|
|
@@ -478,7 +1160,7 @@ export default { port, fetch: app.fetch };
|
|
|
478
1160
|
}
|
|
479
1161
|
}
|
|
480
1162
|
if (options.install) {
|
|
481
|
-
console.log(
|
|
1163
|
+
console.log(import_picocolors.default.dim("\\nInstalling dependencies...\\n"));
|
|
482
1164
|
try {
|
|
483
1165
|
const pm = detectPackageManager();
|
|
484
1166
|
execSync(`${pm} install`, { cwd: projectPath, stdio: "inherit" });
|
|
@@ -486,32 +1168,32 @@ export default { port, fetch: app.fetch };
|
|
|
486
1168
|
}
|
|
487
1169
|
}
|
|
488
1170
|
console.log(`
|
|
489
|
-
${
|
|
1171
|
+
${import_picocolors.default.green("[OK] Minimal project created!")}
|
|
490
1172
|
|
|
491
|
-
${
|
|
1173
|
+
${import_picocolors.default.cyan("Next steps:")}
|
|
492
1174
|
|
|
493
|
-
${
|
|
494
|
-
${
|
|
1175
|
+
${import_picocolors.default.dim("$")} cd ${projectName}
|
|
1176
|
+
${import_picocolors.default.dim("$")} ${options.install ? "" : "npm install && "}npm run dev
|
|
495
1177
|
|
|
496
|
-
${
|
|
1178
|
+
${import_picocolors.default.dim("Add more features as needed:")}
|
|
497
1179
|
|
|
498
|
-
${
|
|
1180
|
+
${import_picocolors.default.dim("# File-based routing")}
|
|
499
1181
|
npm install @flight-framework/core
|
|
500
1182
|
|
|
501
|
-
${
|
|
1183
|
+
${import_picocolors.default.dim("# Database")}
|
|
502
1184
|
npm install @flight-framework/db pg
|
|
503
1185
|
|
|
504
|
-
${
|
|
1186
|
+
${import_picocolors.default.dim("# Caching")}
|
|
505
1187
|
npm install @flight-framework/cache
|
|
506
1188
|
|
|
507
|
-
${
|
|
1189
|
+
${import_picocolors.default.cyan("Happy flying!")}
|
|
508
1190
|
`);
|
|
509
1191
|
}
|
|
510
1192
|
|
|
511
1193
|
// src/commands/dev.ts
|
|
1194
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
512
1195
|
import { resolve as resolve3, join as join3 } from "path";
|
|
513
1196
|
import { readFileSync as readFileSync3, existsSync as existsSync3 } from "fs";
|
|
514
|
-
import pc2 from "picocolors";
|
|
515
1197
|
import { loadConfig } from "@flight-framework/core/config";
|
|
516
1198
|
|
|
517
1199
|
// src/generators/typegen.ts
|
|
@@ -871,7 +1553,7 @@ function watchAndGenerate(options) {
|
|
|
871
1553
|
async function devCommand(options) {
|
|
872
1554
|
const startTime = Date.now();
|
|
873
1555
|
printLogo();
|
|
874
|
-
console.log(
|
|
1556
|
+
console.log(import_picocolors2.default.cyan("\n Starting Flight development server...\n"));
|
|
875
1557
|
try {
|
|
876
1558
|
const root = resolve3(process.cwd());
|
|
877
1559
|
const config = await loadConfig(root);
|
|
@@ -886,7 +1568,7 @@ async function devCommand(options) {
|
|
|
886
1568
|
includeEnv: false,
|
|
887
1569
|
projectRoot: root
|
|
888
1570
|
});
|
|
889
|
-
console.log(
|
|
1571
|
+
console.log(import_picocolors2.default.green(` Route types generated: ${result.routeCount} routes`));
|
|
890
1572
|
const cleanup = watchAndGenerate({
|
|
891
1573
|
routesDir,
|
|
892
1574
|
outputDir,
|
|
@@ -894,13 +1576,13 @@ async function devCommand(options) {
|
|
|
894
1576
|
includeEnv: false,
|
|
895
1577
|
projectRoot: root,
|
|
896
1578
|
onRegenerate: (watchResult) => {
|
|
897
|
-
console.log(
|
|
1579
|
+
console.log(import_picocolors2.default.blue(` Route types updated: ${watchResult.routeCount} routes`));
|
|
898
1580
|
}
|
|
899
1581
|
});
|
|
900
1582
|
process.on("SIGINT", () => cleanup());
|
|
901
1583
|
process.on("SIGTERM", () => cleanup());
|
|
902
1584
|
} catch (typeError) {
|
|
903
|
-
console.log(
|
|
1585
|
+
console.log(import_picocolors2.default.yellow(` Route type generation skipped: ${typeError}`));
|
|
904
1586
|
}
|
|
905
1587
|
}
|
|
906
1588
|
const port = options.port ? parseInt(options.port, 10) : config.dev.port;
|
|
@@ -946,22 +1628,22 @@ async function devCommand(options) {
|
|
|
946
1628
|
const elapsed = Date.now() - startTime;
|
|
947
1629
|
const isSSR = ssrEnabled && hasSSREntry;
|
|
948
1630
|
console.log(`
|
|
949
|
-
${
|
|
1631
|
+
${import_picocolors2.default.green("\u2713")} Flight dev server ready in ${import_picocolors2.default.bold(elapsed + "ms")}
|
|
950
1632
|
|
|
951
|
-
${
|
|
952
|
-
${host === true || host === "0.0.0.0" ? ` ${
|
|
1633
|
+
${import_picocolors2.default.cyan("\u279C")} Local: ${import_picocolors2.default.cyan(`http://localhost:${port}/`)}
|
|
1634
|
+
${host === true || host === "0.0.0.0" ? ` ${import_picocolors2.default.cyan("\u279C")} Network: ${import_picocolors2.default.cyan(`http://${getNetworkAddress()}:${port}/`)}` : ""}
|
|
953
1635
|
|
|
954
|
-
${isSSR ?
|
|
955
|
-
${flightHttpAvailable ?
|
|
956
|
-
${flightRouterAvailable ?
|
|
1636
|
+
${isSSR ? import_picocolors2.default.green("\u2713") : import_picocolors2.default.yellow("\u25CB")} SSR ${isSSR ? "enabled (streaming)" : "disabled (CSR mode)"}
|
|
1637
|
+
${flightHttpAvailable ? import_picocolors2.default.green("\u2713") : import_picocolors2.default.yellow("\u25CB")} @flight-framework/http ${flightHttpAvailable ? "enabled" : "not installed"}
|
|
1638
|
+
${flightRouterAvailable ? import_picocolors2.default.green("\u2713") : import_picocolors2.default.yellow("\u25CB")} File-based routing ${flightRouterAvailable ? "enabled" : "not available"}
|
|
957
1639
|
|
|
958
|
-
${
|
|
1640
|
+
${import_picocolors2.default.dim("press")} ${import_picocolors2.default.bold("h")} ${import_picocolors2.default.dim("to show help")}
|
|
959
1641
|
`);
|
|
960
1642
|
if (!isSSR) {
|
|
961
1643
|
vite.bindCLIShortcuts({ print: true });
|
|
962
1644
|
}
|
|
963
1645
|
} catch (error) {
|
|
964
|
-
console.error(
|
|
1646
|
+
console.error(import_picocolors2.default.red("\nFailed to start dev server:"), error);
|
|
965
1647
|
process.exit(1);
|
|
966
1648
|
}
|
|
967
1649
|
}
|
|
@@ -982,7 +1664,7 @@ async function startSSRServer(vite, root, port, host) {
|
|
|
982
1664
|
moduleLoader
|
|
983
1665
|
// Use Vite's ssrLoadModule
|
|
984
1666
|
});
|
|
985
|
-
console.log(
|
|
1667
|
+
console.log(import_picocolors2.default.green(` \u2713 Page router loaded: ${pageRouter.routes.filter((r) => r.type === "page").length} pages`));
|
|
986
1668
|
} catch {
|
|
987
1669
|
}
|
|
988
1670
|
const server = createHttpServer(async (req, res) => {
|
|
@@ -1037,7 +1719,7 @@ async function startSSRServer(vite, root, port, host) {
|
|
|
1037
1719
|
}
|
|
1038
1720
|
} catch (e) {
|
|
1039
1721
|
vite.ssrFixStacktrace(e);
|
|
1040
|
-
console.error(
|
|
1722
|
+
console.error(import_picocolors2.default.red("[SSR Error]"), e.stack);
|
|
1041
1723
|
if (!res.headersSent) {
|
|
1042
1724
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
1043
1725
|
res.end(`SSR Error: ${e.message}
|
|
@@ -1048,7 +1730,7 @@ ${e.stack}`);
|
|
|
1048
1730
|
});
|
|
1049
1731
|
const listenHost = host === true ? "0.0.0.0" : host || "localhost";
|
|
1050
1732
|
server.listen(port, listenHost, () => {
|
|
1051
|
-
console.log(
|
|
1733
|
+
console.log(import_picocolors2.default.green(` \u2713 SSR server listening`));
|
|
1052
1734
|
});
|
|
1053
1735
|
}
|
|
1054
1736
|
function flightDevPlugin(root) {
|
|
@@ -1155,9 +1837,9 @@ function getNetworkAddress() {
|
|
|
1155
1837
|
}
|
|
1156
1838
|
|
|
1157
1839
|
// src/commands/build.ts
|
|
1840
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
1158
1841
|
import { resolve as resolve4 } from "path";
|
|
1159
1842
|
import { existsSync as existsSync4 } from "fs";
|
|
1160
|
-
import pc3 from "picocolors";
|
|
1161
1843
|
import { loadConfig as loadConfig2 } from "@flight-framework/core/config";
|
|
1162
1844
|
function findEntryServer(root, srcDir) {
|
|
1163
1845
|
const tsxPath = resolve4(root, srcDir, "entry-server.tsx");
|
|
@@ -1169,7 +1851,7 @@ function findEntryServer(root, srcDir) {
|
|
|
1169
1851
|
async function buildCommand(options) {
|
|
1170
1852
|
const startTime = Date.now();
|
|
1171
1853
|
printLogo();
|
|
1172
|
-
console.log(
|
|
1854
|
+
console.log(import_picocolors3.default.cyan("\n[*] Building Flight project for production...\n"));
|
|
1173
1855
|
try {
|
|
1174
1856
|
const root = resolve4(process.cwd());
|
|
1175
1857
|
const config = await loadConfig2(root);
|
|
@@ -1177,11 +1859,11 @@ async function buildCommand(options) {
|
|
|
1177
1859
|
const sourcemap = options.sourcemap ?? config.build.sourcemap;
|
|
1178
1860
|
const minify = options.minify ?? config.build.minify;
|
|
1179
1861
|
const { build } = await import("vite");
|
|
1180
|
-
console.log(
|
|
1181
|
-
console.log(
|
|
1182
|
-
console.log(
|
|
1862
|
+
console.log(import_picocolors3.default.dim(`Output directory: ${outDir}`));
|
|
1863
|
+
console.log(import_picocolors3.default.dim(`Sourcemaps: ${sourcemap ? "enabled" : "disabled"}`));
|
|
1864
|
+
console.log(import_picocolors3.default.dim(`Minification: ${minify ? "enabled" : "disabled"}
|
|
1183
1865
|
`));
|
|
1184
|
-
console.log(
|
|
1866
|
+
console.log(import_picocolors3.default.cyan("Building client..."));
|
|
1185
1867
|
await build({
|
|
1186
1868
|
root,
|
|
1187
1869
|
mode: "production",
|
|
@@ -1194,9 +1876,9 @@ async function buildCommand(options) {
|
|
|
1194
1876
|
}
|
|
1195
1877
|
}
|
|
1196
1878
|
});
|
|
1197
|
-
console.log(
|
|
1879
|
+
console.log(import_picocolors3.default.green("\u2713") + " Client build complete");
|
|
1198
1880
|
if (config.rendering.default !== "csr") {
|
|
1199
|
-
console.log(
|
|
1881
|
+
console.log(import_picocolors3.default.cyan("\nBuilding server..."));
|
|
1200
1882
|
await build({
|
|
1201
1883
|
root,
|
|
1202
1884
|
mode: "production",
|
|
@@ -1210,40 +1892,40 @@ async function buildCommand(options) {
|
|
|
1210
1892
|
}
|
|
1211
1893
|
}
|
|
1212
1894
|
});
|
|
1213
|
-
console.log(
|
|
1895
|
+
console.log(import_picocolors3.default.green("\u2713") + " Server build complete");
|
|
1214
1896
|
}
|
|
1215
1897
|
if (config.adapter) {
|
|
1216
|
-
console.log(
|
|
1898
|
+
console.log(import_picocolors3.default.cyan(`
|
|
1217
1899
|
Running ${config.adapter.name} adapter...`));
|
|
1218
|
-
console.log(
|
|
1900
|
+
console.log(import_picocolors3.default.green("\u2713") + ` ${config.adapter.name} adapter complete`);
|
|
1219
1901
|
}
|
|
1220
1902
|
const elapsed = Date.now() - startTime;
|
|
1221
1903
|
const elapsedSeconds = (elapsed / 1e3).toFixed(2);
|
|
1222
1904
|
console.log(`
|
|
1223
|
-
${
|
|
1905
|
+
${import_picocolors3.default.green("[OK] Build complete!")} ${import_picocolors3.default.dim(`(${elapsedSeconds}s)`)}
|
|
1224
1906
|
|
|
1225
|
-
${
|
|
1907
|
+
${import_picocolors3.default.cyan("Output:")} ${resolve4(root, outDir)}
|
|
1226
1908
|
|
|
1227
|
-
${
|
|
1228
|
-
${
|
|
1909
|
+
${import_picocolors3.default.dim("To preview the build:")}
|
|
1910
|
+
${import_picocolors3.default.dim("$")} flight preview
|
|
1229
1911
|
|
|
1230
|
-
${
|
|
1231
|
-
${
|
|
1232
|
-
${
|
|
1912
|
+
${import_picocolors3.default.dim("To deploy:")}
|
|
1913
|
+
${import_picocolors3.default.dim("\u2022")} Upload ${outDir}/ to your server
|
|
1914
|
+
${import_picocolors3.default.dim("\u2022")} Or use your configured adapter
|
|
1233
1915
|
`);
|
|
1234
1916
|
} catch (error) {
|
|
1235
|
-
console.error(
|
|
1917
|
+
console.error(import_picocolors3.default.red("\nBuild failed:"), error);
|
|
1236
1918
|
process.exit(1);
|
|
1237
1919
|
}
|
|
1238
1920
|
}
|
|
1239
1921
|
|
|
1240
1922
|
// src/commands/preview.ts
|
|
1923
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
1241
1924
|
import { resolve as resolve5 } from "path";
|
|
1242
|
-
import pc4 from "picocolors";
|
|
1243
1925
|
import { loadConfig as loadConfig3 } from "@flight-framework/core/config";
|
|
1244
1926
|
async function previewCommand(options) {
|
|
1245
1927
|
printLogo();
|
|
1246
|
-
console.log(
|
|
1928
|
+
console.log(import_picocolors4.default.cyan("\n\u2708\uFE0F Starting Flight preview server...\n"));
|
|
1247
1929
|
try {
|
|
1248
1930
|
const root = resolve5(process.cwd());
|
|
1249
1931
|
const config = await loadConfig3(root);
|
|
@@ -1263,17 +1945,17 @@ async function previewCommand(options) {
|
|
|
1263
1945
|
}
|
|
1264
1946
|
});
|
|
1265
1947
|
console.log(`
|
|
1266
|
-
${
|
|
1948
|
+
${import_picocolors4.default.green("\u2713")} Flight preview server ready
|
|
1267
1949
|
|
|
1268
|
-
${
|
|
1269
|
-
${host === true || host === "0.0.0.0" ? ` ${
|
|
1950
|
+
${import_picocolors4.default.cyan("\u279C")} Local: ${import_picocolors4.default.cyan(`http://localhost:${port}/`)}
|
|
1951
|
+
${host === true || host === "0.0.0.0" ? ` ${import_picocolors4.default.cyan("\u279C")} Network: ${import_picocolors4.default.cyan(`http://0.0.0.0:${port}/`)}` : ""}
|
|
1270
1952
|
|
|
1271
|
-
${
|
|
1272
|
-
${
|
|
1953
|
+
${import_picocolors4.default.dim("This is a preview of your production build.")}
|
|
1954
|
+
${import_picocolors4.default.dim("For development, use")} ${import_picocolors4.default.bold("flight dev")}
|
|
1273
1955
|
`);
|
|
1274
1956
|
server.printUrls();
|
|
1275
1957
|
} catch (error) {
|
|
1276
|
-
console.error(
|
|
1958
|
+
console.error(import_picocolors4.default.red("\nFailed to start preview server:"), error);
|
|
1277
1959
|
process.exit(1);
|
|
1278
1960
|
}
|
|
1279
1961
|
}
|
|
@@ -1625,10 +2307,10 @@ async function typesGenerateCommand(options = {}) {
|
|
|
1625
2307
|
}
|
|
1626
2308
|
|
|
1627
2309
|
// src/commands/add.ts
|
|
2310
|
+
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
1628
2311
|
import { existsSync as existsSync6 } from "fs";
|
|
1629
2312
|
import { join as join5 } from "path";
|
|
1630
2313
|
import { execSync as execSync2 } from "child_process";
|
|
1631
|
-
import pc5 from "picocolors";
|
|
1632
2314
|
var PACKAGES = {
|
|
1633
2315
|
// Core
|
|
1634
2316
|
"http": {
|
|
@@ -1701,7 +2383,7 @@ var PACKAGES = {
|
|
|
1701
2383
|
async function addCommand(packageName) {
|
|
1702
2384
|
const cwd = process.cwd();
|
|
1703
2385
|
if (!existsSync6(join5(cwd, "package.json"))) {
|
|
1704
|
-
console.log(
|
|
2386
|
+
console.log(import_picocolors5.default.red("No package.json found. Run this command from your project directory."));
|
|
1705
2387
|
process.exit(1);
|
|
1706
2388
|
}
|
|
1707
2389
|
if (!packageName) {
|
|
@@ -1710,23 +2392,23 @@ async function addCommand(packageName) {
|
|
|
1710
2392
|
}
|
|
1711
2393
|
const pkg = PACKAGES[packageName];
|
|
1712
2394
|
if (!pkg) {
|
|
1713
|
-
console.log(
|
|
1714
|
-
console.log(
|
|
2395
|
+
console.log(import_picocolors5.default.red(`Unknown package: ${packageName}`));
|
|
2396
|
+
console.log(import_picocolors5.default.dim("Run `flight add` to see available packages."));
|
|
1715
2397
|
process.exit(1);
|
|
1716
2398
|
}
|
|
1717
2399
|
console.log(`
|
|
1718
|
-
${
|
|
1719
|
-
console.log(
|
|
2400
|
+
${import_picocolors5.default.cyan("Adding")} ${import_picocolors5.default.bold(pkg.name)}...`);
|
|
2401
|
+
console.log(import_picocolors5.default.dim(pkg.description));
|
|
1720
2402
|
console.log();
|
|
1721
2403
|
const pm = detectPackageManager2();
|
|
1722
2404
|
try {
|
|
1723
2405
|
const installCmd = pm === "npm" ? "npm install" : `${pm} add`;
|
|
1724
2406
|
execSync2(`${installCmd} ${pkg.name}`, { cwd, stdio: "inherit" });
|
|
1725
2407
|
console.log(`
|
|
1726
|
-
${
|
|
2408
|
+
${import_picocolors5.default.green("[OK]")} ${pkg.name} added successfully!`);
|
|
1727
2409
|
showNextSteps(packageName, pkg);
|
|
1728
2410
|
} catch (error) {
|
|
1729
|
-
console.log(
|
|
2411
|
+
console.log(import_picocolors5.default.red(`
|
|
1730
2412
|
Failed to install ${pkg.name}`));
|
|
1731
2413
|
process.exit(1);
|
|
1732
2414
|
}
|
|
@@ -1740,33 +2422,33 @@ function detectPackageManager2() {
|
|
|
1740
2422
|
}
|
|
1741
2423
|
function showAvailablePackages() {
|
|
1742
2424
|
console.log(`
|
|
1743
|
-
${
|
|
2425
|
+
${import_picocolors5.default.cyan("Available Flight packages:")}
|
|
1744
2426
|
|
|
1745
|
-
${
|
|
1746
|
-
${
|
|
1747
|
-
${
|
|
2427
|
+
${import_picocolors5.default.bold("Core")}
|
|
2428
|
+
${import_picocolors5.default.green("http")} ${import_picocolors5.default.dim("HTTP server with routing and middleware")}
|
|
2429
|
+
${import_picocolors5.default.green("core")} ${import_picocolors5.default.dim("File-based routing and configuration")}
|
|
1748
2430
|
|
|
1749
|
-
${
|
|
1750
|
-
${
|
|
1751
|
-
${
|
|
2431
|
+
${import_picocolors5.default.bold("Data")}
|
|
2432
|
+
${import_picocolors5.default.green("db")} ${import_picocolors5.default.dim("Database abstraction layer")}
|
|
2433
|
+
${import_picocolors5.default.green("cache")} ${import_picocolors5.default.dim("Caching with multiple adapters")}
|
|
1752
2434
|
|
|
1753
|
-
${
|
|
1754
|
-
${
|
|
2435
|
+
${import_picocolors5.default.bold("Auth")}
|
|
2436
|
+
${import_picocolors5.default.green("auth")} ${import_picocolors5.default.dim("Authentication adapters")}
|
|
1755
2437
|
|
|
1756
|
-
${
|
|
1757
|
-
${
|
|
1758
|
-
${
|
|
1759
|
-
${
|
|
1760
|
-
${
|
|
2438
|
+
${import_picocolors5.default.bold("Frontend")}
|
|
2439
|
+
${import_picocolors5.default.green("forms")} ${import_picocolors5.default.dim("Type-safe form handling")}
|
|
2440
|
+
${import_picocolors5.default.green("i18n")} ${import_picocolors5.default.dim("Internationalization")}
|
|
2441
|
+
${import_picocolors5.default.green("seo")} ${import_picocolors5.default.dim("SEO utilities")}
|
|
2442
|
+
${import_picocolors5.default.green("image")} ${import_picocolors5.default.dim("Image optimization")}
|
|
1761
2443
|
|
|
1762
|
-
${
|
|
1763
|
-
${
|
|
1764
|
-
${
|
|
2444
|
+
${import_picocolors5.default.bold("Communication")}
|
|
2445
|
+
${import_picocolors5.default.green("email")} ${import_picocolors5.default.dim("Email sending")}
|
|
2446
|
+
${import_picocolors5.default.green("realtime")} ${import_picocolors5.default.dim("WebSocket and real-time features")}
|
|
1765
2447
|
|
|
1766
|
-
${
|
|
1767
|
-
${
|
|
2448
|
+
${import_picocolors5.default.bold("Utilities")}
|
|
2449
|
+
${import_picocolors5.default.green("helpers")} ${import_picocolors5.default.dim("Optional helper utilities")}
|
|
1768
2450
|
|
|
1769
|
-
${
|
|
2451
|
+
${import_picocolors5.default.cyan("Usage:")}
|
|
1770
2452
|
flight add http
|
|
1771
2453
|
flight add db
|
|
1772
2454
|
flight add auth
|
|
@@ -1775,7 +2457,7 @@ ${pc5.cyan("Usage:")}
|
|
|
1775
2457
|
function showNextSteps(packageName, pkg) {
|
|
1776
2458
|
const examples = {
|
|
1777
2459
|
"http": `
|
|
1778
|
-
${
|
|
2460
|
+
${import_picocolors5.default.cyan("Quick example:")}
|
|
1779
2461
|
|
|
1780
2462
|
import { createServer } from '@flight-framework/http';
|
|
1781
2463
|
|
|
@@ -1785,7 +2467,7 @@ ${pc5.cyan("Quick example:")}
|
|
|
1785
2467
|
export default { port: 3000, fetch: app.fetch };
|
|
1786
2468
|
`,
|
|
1787
2469
|
"db": `
|
|
1788
|
-
${
|
|
2470
|
+
${import_picocolors5.default.cyan("Quick example:")}
|
|
1789
2471
|
|
|
1790
2472
|
import { createDb } from '@flight-framework/db';
|
|
1791
2473
|
import { postgres } from '@flight-framework/db/postgres';
|
|
@@ -1793,13 +2475,13 @@ ${pc5.cyan("Quick example:")}
|
|
|
1793
2475
|
const db = createDb(postgres({ connectionString: process.env.DATABASE_URL }));
|
|
1794
2476
|
const users = await db.query('SELECT * FROM users');
|
|
1795
2477
|
|
|
1796
|
-
${
|
|
1797
|
-
npm install pg ${
|
|
1798
|
-
npm install @libsql/client ${
|
|
1799
|
-
npm install @neondatabase/serverless ${
|
|
2478
|
+
${import_picocolors5.default.dim("You may also need a driver:")}
|
|
2479
|
+
npm install pg ${import_picocolors5.default.dim("# PostgreSQL")}
|
|
2480
|
+
npm install @libsql/client ${import_picocolors5.default.dim("# Turso/SQLite")}
|
|
2481
|
+
npm install @neondatabase/serverless ${import_picocolors5.default.dim("# Neon")}
|
|
1800
2482
|
`,
|
|
1801
2483
|
"cache": `
|
|
1802
|
-
${
|
|
2484
|
+
${import_picocolors5.default.cyan("Quick example:")}
|
|
1803
2485
|
|
|
1804
2486
|
import { createCache, lru } from '@flight-framework/cache';
|
|
1805
2487
|
|
|
@@ -1808,7 +2490,7 @@ ${pc5.cyan("Quick example:")}
|
|
|
1808
2490
|
const value = await cache.get('key');
|
|
1809
2491
|
`,
|
|
1810
2492
|
"auth": `
|
|
1811
|
-
${
|
|
2493
|
+
${import_picocolors5.default.cyan("Quick example:")}
|
|
1812
2494
|
|
|
1813
2495
|
import { createAuth } from '@flight-framework/auth';
|
|
1814
2496
|
import { betterAuth } from '@flight-framework/auth/better-auth';
|
|
@@ -1817,7 +2499,7 @@ ${pc5.cyan("Quick example:")}
|
|
|
1817
2499
|
const user = await auth.getUser(request);
|
|
1818
2500
|
`,
|
|
1819
2501
|
"forms": `
|
|
1820
|
-
${
|
|
2502
|
+
${import_picocolors5.default.cyan("Quick example:")}
|
|
1821
2503
|
|
|
1822
2504
|
import { createForm } from '@flight-framework/forms';
|
|
1823
2505
|
import { zodAdapter } from '@flight-framework/forms/adapters/zod';
|
|
@@ -1829,13 +2511,13 @@ ${pc5.cyan("Quick example:")}
|
|
|
1829
2511
|
if (examples[packageName]) {
|
|
1830
2512
|
console.log(examples[packageName]);
|
|
1831
2513
|
}
|
|
1832
|
-
console.log(`${
|
|
2514
|
+
console.log(`${import_picocolors5.default.dim("Docs:")} https://flight.dev/docs/packages/${packageName}`);
|
|
1833
2515
|
}
|
|
1834
2516
|
|
|
1835
2517
|
// src/commands/adapter-create.ts
|
|
2518
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
1836
2519
|
import { existsSync as existsSync7, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
1837
2520
|
import { join as join6 } from "path";
|
|
1838
|
-
import pc6 from "picocolors";
|
|
1839
2521
|
async function adapterCreateCommand(name, options = {}) {
|
|
1840
2522
|
const cwd = process.cwd();
|
|
1841
2523
|
const adapterName = name.toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
@@ -1843,11 +2525,11 @@ async function adapterCreateCommand(name, options = {}) {
|
|
|
1843
2525
|
const outputDir = options.outputDir || join6(cwd, "packages", `adapter-${adapterName}`);
|
|
1844
2526
|
const type = options.type || "node";
|
|
1845
2527
|
const includeValidation = options.validation || false;
|
|
1846
|
-
console.log(
|
|
2528
|
+
console.log(import_picocolors6.default.cyan(`
|
|
1847
2529
|
Creating adapter: ${packageName}
|
|
1848
2530
|
`));
|
|
1849
2531
|
if (existsSync7(outputDir)) {
|
|
1850
|
-
console.error(
|
|
2532
|
+
console.error(import_picocolors6.default.red(` Error: Directory already exists: ${outputDir}`));
|
|
1851
2533
|
process.exit(1);
|
|
1852
2534
|
}
|
|
1853
2535
|
mkdirSync4(join6(outputDir, "src"), { recursive: true });
|
|
@@ -1856,9 +2538,9 @@ async function adapterCreateCommand(name, options = {}) {
|
|
|
1856
2538
|
for (const [filePath, content] of Object.entries(files)) {
|
|
1857
2539
|
const fullPath = join6(outputDir, filePath);
|
|
1858
2540
|
writeFileSync5(fullPath, content, "utf-8");
|
|
1859
|
-
console.log(
|
|
2541
|
+
console.log(import_picocolors6.default.green(` \u2713 Created ${filePath}`));
|
|
1860
2542
|
}
|
|
1861
|
-
console.log(
|
|
2543
|
+
console.log(import_picocolors6.default.cyan(`
|
|
1862
2544
|
Adapter created successfully!
|
|
1863
2545
|
|
|
1864
2546
|
Next steps:
|
|
@@ -2288,15 +2970,15 @@ MIT
|
|
|
2288
2970
|
// src/index.ts
|
|
2289
2971
|
var cli = cac("flight");
|
|
2290
2972
|
var LOGO = `
|
|
2291
|
-
${
|
|
2292
|
-
${
|
|
2293
|
-
${
|
|
2294
|
-
${
|
|
2295
|
-
${
|
|
2296
|
-
${
|
|
2973
|
+
${import_picocolors7.default.cyan(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557")}
|
|
2974
|
+
${import_picocolors7.default.cyan(" \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D")}
|
|
2975
|
+
${import_picocolors7.default.cyan(" \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 ")}
|
|
2976
|
+
${import_picocolors7.default.cyan(" \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 ")}
|
|
2977
|
+
${import_picocolors7.default.cyan(" \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 ")}
|
|
2978
|
+
${import_picocolors7.default.cyan(" \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D ")}
|
|
2297
2979
|
|
|
2298
|
-
${
|
|
2299
|
-
${
|
|
2980
|
+
${import_picocolors7.default.dim("The Agnostic Full-Stack Framework")}
|
|
2981
|
+
${import_picocolors7.default.dim("Maximum Flexibility. Zero Lock-in.")}
|
|
2300
2982
|
`;
|
|
2301
2983
|
function printLogo() {
|
|
2302
2984
|
console.log(LOGO);
|
|
@@ -2319,7 +3001,7 @@ function run() {
|
|
|
2319
3001
|
}
|
|
2320
3002
|
cli.runMatchedCommand();
|
|
2321
3003
|
} catch (error) {
|
|
2322
|
-
console.error(
|
|
3004
|
+
console.error(import_picocolors7.default.red("Error:"), error instanceof Error ? error.message : error);
|
|
2323
3005
|
process.exit(1);
|
|
2324
3006
|
}
|
|
2325
3007
|
}
|