@flight-framework/cli 0.4.12 → 0.4.13

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Flight Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/bin.js CHANGED
@@ -8,7 +8,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
8
 
9
9
  // src/index.ts
10
10
  import { defineCommand, runMain } from "citty";
11
- import { consola as consola7 } from "consola";
11
+ import { consola as consola6 } from "consola";
12
12
 
13
13
  // src/version.ts
14
14
  var VERSION = "0.0.1";
@@ -35,7 +35,7 @@ var UI_FRAMEWORKS = [
35
35
  ];
36
36
  var BUNDLERS = [
37
37
  { title: "Vite", value: "vite", description: "Next Gen Frontend Tooling (recommended)" },
38
- { title: "FlightPack", value: "flightpack", description: "Native Rust bundler for maximum performance" },
38
+ { title: "Turboflight", value: "turboflight", description: "Native Rust bundler for maximum performance" },
39
39
  { title: "esbuild", value: "esbuild", description: "Ultra-fast builds for performance-focused projects" },
40
40
  { title: "Rolldown", value: "rolldown", description: "Rust-based Rollup replacement (experimental)" }
41
41
  ];
@@ -1168,8 +1168,32 @@ function getNetworkAddress() {
1168
1168
  // src/commands/build.ts
1169
1169
  import { resolve as resolve4 } from "path";
1170
1170
  import { existsSync as existsSync4 } from "fs";
1171
- import { consola as consola3 } from "consola";
1172
1171
  import { loadConfig as loadConfig2 } from "@flight-framework/core/config";
1172
+ import pc from "picocolors";
1173
+ var prefixes = {
1174
+ wait: pc.white(pc.bold("\u2192")),
1175
+ error: pc.red(pc.bold("\u2717")),
1176
+ warn: pc.yellow(pc.bold("!")),
1177
+ ready: pc.green(pc.bold("\u26A1")),
1178
+ info: pc.cyan(pc.bold("\u2192")),
1179
+ event: pc.green(pc.bold("\u2713"))
1180
+ };
1181
+ function log(prefix, ...message) {
1182
+ console.log(`${prefixes[prefix]} ${message.join(" ")}`);
1183
+ }
1184
+ function formatSize(bytes) {
1185
+ const kb = bytes / 1024;
1186
+ if (kb >= 1024) {
1187
+ return `${(kb / 1024).toFixed(2)} MB`;
1188
+ }
1189
+ return `${kb.toFixed(2)} kB`;
1190
+ }
1191
+ function formatDuration(ms) {
1192
+ if (ms >= 1e3) {
1193
+ return `${(ms / 1e3).toFixed(2)}s`;
1194
+ }
1195
+ return `${Math.round(ms)}ms`;
1196
+ }
1173
1197
  function findEntryServer(root, srcDir) {
1174
1198
  const tsxPath = resolve4(root, srcDir, "entry-server.tsx");
1175
1199
  const tsPath = resolve4(root, srcDir, "entry-server.ts");
@@ -1179,44 +1203,71 @@ function findEntryServer(root, srcDir) {
1179
1203
  }
1180
1204
  async function buildCommand(options) {
1181
1205
  const startTime = Date.now();
1182
- printLogo();
1183
- consola3.info("Building Flight project for production...\n");
1184
1206
  try {
1185
1207
  const root = resolve4(process.cwd());
1186
1208
  const config = await loadConfig2(root);
1187
1209
  const outDir = options.outDir ?? config.build.outDir;
1188
1210
  const sourcemap = options.sourcemap ?? config.build.sourcemap;
1189
1211
  const minify = options.minify ?? config.build.minify;
1190
- consola3.log(`Output directory: ${outDir}`);
1191
- consola3.log(`Sourcemaps: ${sourcemap ? "enabled" : "disabled"}`);
1192
- consola3.log(`Minification: ${minify ? "enabled" : "disabled"}
1193
- `);
1212
+ console.log();
1213
+ console.log(pc.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`));
1214
+ console.log(pc.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`));
1215
+ console.log(pc.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 `));
1216
+ console.log(pc.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 `));
1217
+ console.log(pc.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 `));
1218
+ console.log(pc.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 `));
1219
+ console.log();
1220
+ log("info", pc.white("Creating an optimized production build..."));
1221
+ console.log();
1194
1222
  const bundler = config.bundler;
1195
1223
  if (bundler && typeof bundler.build === "function") {
1196
- consola3.info(`Using bundler: ${bundler.name || bundler.bundler || "custom"}`);
1224
+ const bundlerName = bundler.name || bundler.bundler || "custom";
1225
+ log("wait", `Compiling with ${pc.cyan(bundlerName)}...`);
1197
1226
  const result = await bundler.build(config);
1198
1227
  if (!result.success) {
1228
+ console.log();
1199
1229
  for (const error of result.errors) {
1200
- consola3.error(error.message);
1230
+ log("error", error.message);
1201
1231
  }
1202
1232
  throw new Error("Build failed");
1203
1233
  }
1204
- const elapsed = Date.now() - startTime;
1205
- const elapsedSeconds = (elapsed / 1e3).toFixed(2);
1206
- consola3.success(`Build complete! (${elapsedSeconds}s)`);
1207
- consola3.log(`
1208
- Output: ${resolve4(root, outDir)}`);
1209
- consola3.log(`
1210
- To preview the build:`);
1211
- consola3.log(` $ flight preview
1212
- `);
1234
+ const moduleCount = result.moduleCount ?? result.files.length;
1235
+ console.log();
1236
+ log("event", `Compiled ${pc.bold(String(moduleCount))} modules in ${pc.cyan(formatDuration(result.duration))}`);
1237
+ console.log();
1238
+ console.log(pc.dim(" Route Size"));
1239
+ console.log(pc.dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
1240
+ for (const file of result.files) {
1241
+ const filename = file.path.split("/").pop() || file.path;
1242
+ const size = formatSize(file.size);
1243
+ const padding = Math.max(1, 38 - filename.length);
1244
+ let coloredName;
1245
+ if (filename.endsWith(".js")) {
1246
+ coloredName = pc.cyan(filename);
1247
+ } else if (filename.endsWith(".css")) {
1248
+ coloredName = pc.magenta(filename);
1249
+ } else if (filename.endsWith(".html")) {
1250
+ coloredName = pc.green(filename);
1251
+ } else {
1252
+ coloredName = pc.dim(filename);
1253
+ }
1254
+ console.log(` ${coloredName}${" ".repeat(padding)}${pc.dim(size)}`);
1255
+ }
1256
+ console.log();
1257
+ const totalSize = result.files.reduce((acc, f) => acc + f.size, 0);
1258
+ log("ready", `Build completed in ${pc.bold(formatDuration(result.duration))}`);
1259
+ console.log(pc.dim(` \u2514\u2500 ${result.files.length} files, ${formatSize(totalSize)} total`));
1260
+ console.log();
1261
+ console.log(pc.dim(` Output: ${resolve4(root, outDir)}`));
1262
+ console.log(pc.dim(` Preview: ${pc.cyan("flight preview")}`));
1263
+ console.log();
1213
1264
  } else {
1214
- consola3.info("Using bundler: Vite (default)");
1265
+ log("wait", `Compiling with ${pc.cyan("vite")}...`);
1215
1266
  const { build: build2 } = await import("vite");
1216
- consola3.info("Building client...");
1217
1267
  await build2({
1218
1268
  root,
1219
1269
  mode: "production",
1270
+ logLevel: "silent",
1220
1271
  build: {
1221
1272
  outDir: `${outDir}/client`,
1222
1273
  sourcemap,
@@ -1226,12 +1277,11 @@ To preview the build:`);
1226
1277
  }
1227
1278
  }
1228
1279
  });
1229
- consola3.success("Client build complete");
1230
1280
  if (config.rendering.default !== "csr") {
1231
- consola3.info("Building server...");
1232
1281
  await build2({
1233
1282
  root,
1234
1283
  mode: "production",
1284
+ logLevel: "silent",
1235
1285
  build: {
1236
1286
  outDir: `${outDir}/server`,
1237
1287
  sourcemap,
@@ -1242,39 +1292,34 @@ To preview the build:`);
1242
1292
  }
1243
1293
  }
1244
1294
  });
1245
- consola3.success("Server build complete");
1246
- }
1247
- if (config.adapter) {
1248
- consola3.info(`Running ${config.adapter.name} adapter...`);
1249
- consola3.success(`${config.adapter.name} adapter complete`);
1250
1295
  }
1251
1296
  const elapsed = Date.now() - startTime;
1252
- const elapsedSeconds = (elapsed / 1e3).toFixed(2);
1253
- consola3.success(`Build complete! (${elapsedSeconds}s)`);
1254
- consola3.log(`
1255
- Output: ${resolve4(root, outDir)}`);
1256
- consola3.log(`
1257
- To preview the build:`);
1258
- consola3.log(` $ flight preview
1259
- `);
1260
- consola3.log(`To deploy:`);
1261
- consola3.log(` \u2022 Upload ${outDir}/ to your server`);
1262
- consola3.log(` \u2022 Or use your configured adapter
1263
- `);
1297
+ console.log();
1298
+ log("event", `Compiled successfully in ${pc.cyan(formatDuration(elapsed))}`);
1299
+ console.log();
1300
+ log("ready", "Build completed");
1301
+ console.log(pc.dim(` Output: ${resolve4(root, outDir)}`));
1302
+ console.log(pc.dim(` Preview: ${pc.cyan("flight preview")}`));
1303
+ console.log();
1264
1304
  }
1265
1305
  } catch (error) {
1266
- consola3.error("Build failed:", error);
1306
+ console.log();
1307
+ log("error", pc.red("Build failed"));
1308
+ if (error instanceof Error) {
1309
+ console.log(pc.dim(` ${error.message}`));
1310
+ }
1311
+ console.log();
1267
1312
  process.exit(1);
1268
1313
  }
1269
1314
  }
1270
1315
 
1271
1316
  // src/commands/preview.ts
1272
1317
  import { resolve as resolve5 } from "path";
1273
- import { consola as consola4 } from "consola";
1318
+ import { consola as consola3 } from "consola";
1274
1319
  import { loadConfig as loadConfig3 } from "@flight-framework/core/config";
1275
1320
  async function previewCommand(options) {
1276
1321
  printLogo();
1277
- consola4.info("Starting Flight preview server...\n");
1322
+ consola3.info("Starting Flight preview server...\n");
1278
1323
  try {
1279
1324
  const root = resolve5(process.cwd());
1280
1325
  const config = await loadConfig3(root);
@@ -1283,11 +1328,11 @@ async function previewCommand(options) {
1283
1328
  const open = options.open ?? false;
1284
1329
  const bundler = config.bundler;
1285
1330
  if (bundler && typeof bundler.preview === "function") {
1286
- consola4.info(`Using bundler: ${bundler.name || bundler.bundler || "custom"}`);
1331
+ consola3.info(`Using bundler: ${bundler.name || bundler.bundler || "custom"}`);
1287
1332
  const server = await bundler.preview(config);
1288
1333
  server.printUrls?.();
1289
1334
  } else {
1290
- consola4.info("Using bundler: Vite (default)");
1335
+ consola3.info("Using bundler: Vite (default)");
1291
1336
  const { preview: preview2 } = await import("vite");
1292
1337
  const server = await preview2({
1293
1338
  root,
@@ -1300,18 +1345,18 @@ async function previewCommand(options) {
1300
1345
  outDir: config.build.outDir
1301
1346
  }
1302
1347
  });
1303
- consola4.success("Flight preview server ready");
1304
- consola4.log(`
1348
+ consola3.success("Flight preview server ready");
1349
+ consola3.log(`
1305
1350
  \u279C Local: http://localhost:${port}/`);
1306
1351
  if (host === true || host === "0.0.0.0") {
1307
- consola4.log(` \u279C Network: http://0.0.0.0:${port}/`);
1352
+ consola3.log(` \u279C Network: http://0.0.0.0:${port}/`);
1308
1353
  }
1309
- consola4.log("\n This is a preview of your production build.");
1310
- consola4.log(" For development, use: flight dev\n");
1354
+ consola3.log("\n This is a preview of your production build.");
1355
+ consola3.log(" For development, use: flight dev\n");
1311
1356
  server.printUrls();
1312
1357
  }
1313
1358
  } catch (error) {
1314
- consola4.error("Failed to start preview server:", error);
1359
+ consola3.error("Failed to start preview server:", error);
1315
1360
  process.exit(1);
1316
1361
  }
1317
1362
  }
@@ -1666,7 +1711,7 @@ async function typesGenerateCommand(options = {}) {
1666
1711
  import { existsSync as existsSync6 } from "fs";
1667
1712
  import { join as join5 } from "path";
1668
1713
  import { execSync as execSync2 } from "child_process";
1669
- import { consola as consola5 } from "consola";
1714
+ import { consola as consola4 } from "consola";
1670
1715
  var PACKAGES = {
1671
1716
  // Core
1672
1717
  "http": {
@@ -1739,7 +1784,7 @@ var PACKAGES = {
1739
1784
  async function addCommand(packageName) {
1740
1785
  const cwd = process.cwd();
1741
1786
  if (!existsSync6(join5(cwd, "package.json"))) {
1742
- consola5.error("No package.json found. Run this command from your project directory.");
1787
+ consola4.error("No package.json found. Run this command from your project directory.");
1743
1788
  process.exit(1);
1744
1789
  }
1745
1790
  if (!packageName) {
@@ -1748,21 +1793,21 @@ async function addCommand(packageName) {
1748
1793
  }
1749
1794
  const pkg = PACKAGES[packageName];
1750
1795
  if (!pkg) {
1751
- consola5.error(`Unknown package: ${packageName}`);
1752
- consola5.log("Run `flight add` to see available packages.");
1796
+ consola4.error(`Unknown package: ${packageName}`);
1797
+ consola4.log("Run `flight add` to see available packages.");
1753
1798
  process.exit(1);
1754
1799
  }
1755
- consola5.info(`Adding ${pkg.name}...`);
1756
- consola5.log(pkg.description);
1757
- consola5.log("");
1800
+ consola4.info(`Adding ${pkg.name}...`);
1801
+ consola4.log(pkg.description);
1802
+ consola4.log("");
1758
1803
  const pm = detectPackageManager2();
1759
1804
  try {
1760
1805
  const installCmd = pm === "npm" ? "npm install" : `${pm} add`;
1761
1806
  execSync2(`${installCmd} ${pkg.name}`, { cwd, stdio: "inherit" });
1762
- consola5.success(`${pkg.name} added successfully!`);
1807
+ consola4.success(`${pkg.name} added successfully!`);
1763
1808
  showNextSteps(packageName, pkg);
1764
1809
  } catch (error) {
1765
- consola5.error(`Failed to install ${pkg.name}`);
1810
+ consola4.error(`Failed to install ${pkg.name}`);
1766
1811
  process.exit(1);
1767
1812
  }
1768
1813
  }
@@ -1774,7 +1819,7 @@ function detectPackageManager2() {
1774
1819
  return "npm";
1775
1820
  }
1776
1821
  function showAvailablePackages() {
1777
- consola5.log(`
1822
+ consola4.log(`
1778
1823
  Available Flight packages:
1779
1824
 
1780
1825
  Core
@@ -1862,15 +1907,15 @@ Quick example:
1862
1907
  `
1863
1908
  };
1864
1909
  if (examples[packageName]) {
1865
- consola5.log(examples[packageName]);
1910
+ consola4.log(examples[packageName]);
1866
1911
  }
1867
- consola5.log(`Docs: https://flight.dev/docs/packages/${packageName}`);
1912
+ consola4.log(`Docs: https://flight.dev/docs/packages/${packageName}`);
1868
1913
  }
1869
1914
 
1870
1915
  // src/commands/adapter-create.ts
1871
1916
  import { existsSync as existsSync7, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
1872
1917
  import { join as join6 } from "path";
1873
- import { consola as consola6 } from "consola";
1918
+ import { consola as consola5 } from "consola";
1874
1919
  async function adapterCreateCommand(name, options = {}) {
1875
1920
  const cwd = process.cwd();
1876
1921
  const adapterName = name.toLowerCase().replace(/[^a-z0-9-]/g, "-");
@@ -1878,9 +1923,9 @@ async function adapterCreateCommand(name, options = {}) {
1878
1923
  const outputDir = options.outputDir || join6(cwd, "packages", `adapter-${adapterName}`);
1879
1924
  const type = options.type || "node";
1880
1925
  const includeValidation = options.validation || false;
1881
- consola6.info(`Creating adapter: ${packageName}`);
1926
+ consola5.info(`Creating adapter: ${packageName}`);
1882
1927
  if (existsSync7(outputDir)) {
1883
- consola6.error(`Directory already exists: ${outputDir}`);
1928
+ consola5.error(`Directory already exists: ${outputDir}`);
1884
1929
  process.exit(1);
1885
1930
  }
1886
1931
  mkdirSync4(join6(outputDir, "src"), { recursive: true });
@@ -1889,9 +1934,9 @@ async function adapterCreateCommand(name, options = {}) {
1889
1934
  for (const [filePath, content] of Object.entries(files)) {
1890
1935
  const fullPath = join6(outputDir, filePath);
1891
1936
  writeFileSync5(fullPath, content, "utf-8");
1892
- consola6.success(`Created ${filePath}`);
1937
+ consola5.success(`Created ${filePath}`);
1893
1938
  }
1894
- consola6.success(`Adapter created successfully!
1939
+ consola5.success(`Adapter created successfully!
1895
1940
 
1896
1941
  Next steps:
1897
1942
  1. cd packages/adapter-${adapterName}
@@ -2330,7 +2375,7 @@ var LOGO = `
2330
2375
  Maximum Flexibility. Zero Lock-in.
2331
2376
  `;
2332
2377
  function printLogo() {
2333
- consola7.log(LOGO);
2378
+ consola6.log(LOGO);
2334
2379
  }
2335
2380
  var create = defineCommand({
2336
2381
  meta: {
@@ -2591,7 +2636,10 @@ var main = defineCommand({
2591
2636
  "types:generate": typesGenerate,
2592
2637
  "adapter:create": adapterCreate
2593
2638
  },
2594
- setup() {
2639
+ setup({ rawArgs }) {
2640
+ if (rawArgs?.includes("build")) {
2641
+ return;
2642
+ }
2595
2643
  printLogo();
2596
2644
  }
2597
2645
  });