@flight-framework/cli 0.0.16 → 0.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/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
@@ -75,6 +75,9 @@ async function createCommand(name, options) {
75
75
  console.log(pc.red("Project creation cancelled."));
76
76
  return;
77
77
  }
78
+ let useCase = options.useCase;
79
+ const useCaseDir = join(TEMPLATES_DIR, "use-cases", useCase || "");
80
+ const isUseCase = useCase && existsSync(useCaseDir);
78
81
  let bundler = options.bundler;
79
82
  if (!bundler) {
80
83
  const response = await prompts({
@@ -110,8 +113,12 @@ async function createCommand(name, options) {
110
113
  Creating project in ${projectPath}...
111
114
  `));
112
115
  try {
113
- copyTemplate(projectPath, uiFramework, bundler, projectName);
114
- console.log(pc.green("\u2713") + " Project structure created");
116
+ if (isUseCase && useCase) {
117
+ copyUseCaseTemplate(projectPath, useCase, projectName);
118
+ } else {
119
+ copyTemplate(projectPath, uiFramework, bundler, projectName);
120
+ }
121
+ console.log(pc.green("[OK]") + " Project structure created");
115
122
  if (options.git) {
116
123
  try {
117
124
  execSync("git init", { cwd: projectPath, stdio: "ignore" });
@@ -179,6 +186,15 @@ function copyTemplate(projectPath, ui, bundler, projectName) {
179
186
  unlinkSync(gitignoreSrc);
180
187
  }
181
188
  }
189
+ function copyUseCaseTemplate(projectPath, useCase, projectName) {
190
+ const useCaseDir = join(TEMPLATES_DIR, "use-cases", useCase);
191
+ mkdirSync(projectPath, { recursive: true });
192
+ const vars = {
193
+ "{{PROJECT_NAME}}": projectName,
194
+ "{{USE_CASE}}": useCase
195
+ };
196
+ copyDirWithTemplates(useCaseDir, projectPath, vars);
197
+ }
182
198
  function copyDirWithTemplates(srcDir, destDir, vars) {
183
199
  if (!existsSync(srcDir)) return;
184
200
  const entries = readdirSync(srcDir, { withFileTypes: true });
@@ -1312,7 +1328,7 @@ function printLogo() {
1312
1328
  }
1313
1329
  cli.version(VERSION);
1314
1330
  cli.help();
1315
- cli.command("create [name]", "Create a new Flight project").option("-t, --template <template>", "Project template to use", { default: "basic" }).option("--ui <framework>", "UI framework (react, vue, svelte, solid, vanilla)").option("--ts", "Use TypeScript", { default: true }).option("--git", "Initialize git repository", { default: true }).option("--install", "Install dependencies", { default: true }).action(createCommand);
1331
+ cli.command("create [name]", "Create a new Flight project").option("-t, --template <template>", "Project template to use", { default: "basic" }).option("--ui <framework>", "UI framework (react, vue, svelte, solid, vanilla)").option("--use-case <useCase>", "Use-case template (blog, ecommerce, saas, api, docs)").option("--ts", "Use TypeScript", { default: true }).option("--git", "Initialize git repository", { default: true }).option("--install", "Install dependencies", { default: true }).action(createCommand);
1316
1332
  cli.command("dev", "Start development server").option("-p, --port <port>", "Port to listen on").option("-h, --host <host>", "Host to bind to").option("--open", "Open browser on start").option("--https", "Enable HTTPS").option("--ssr", "Enable Server-Side Rendering").action(devCommand);
1317
1333
  cli.command("build", "Build for production").option("--outDir <dir>", "Output directory").option("--sourcemap", "Generate source maps").option("--minify", "Minify output", { default: true }).action(buildCommand);
1318
1334
  cli.command("preview", "Preview production build").option("-p, --port <port>", "Port to listen on").option("-h, --host <host>", "Host to bind to").option("--open", "Open browser on start").action(previewCommand);