@igniter-js/cli 0.2.2 → 0.2.4

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/index.mjs CHANGED
@@ -12491,11 +12491,12 @@ function showWelcome() {
12491
12491
  console.log(chalk2.dim("This process will configure your project with everything you need."));
12492
12492
  console.log();
12493
12493
  }
12494
- async function runSetupPrompts(targetDir, isExistingProject = false) {
12494
+ async function runSetupPrompts(targetDir, isExistingProject = false, cliOptions = {}) {
12495
12495
  showWelcome();
12496
12496
  const detectedFramework = detectFramework();
12497
12497
  const detectedPackageManager = detectPackageManager();
12498
12498
  const projectName = targetDir ? path3.basename(path3.resolve(targetDir)) : "my-igniter-app";
12499
+ const cliFeatures = cliOptions.features ? cliOptions.features.split(",").map((f) => f.trim()) : [];
12499
12500
  try {
12500
12501
  const answers = await prompts([
12501
12502
  {
@@ -12513,51 +12514,38 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
12513
12514
  format: (value) => value.trim().toLowerCase().replace(/\s+/g, "-")
12514
12515
  },
12515
12516
  {
12516
- type: "select",
12517
+ type: cliOptions.template || isExistingProject && detectedFramework ? null : "select",
12517
12518
  name: "framework",
12518
- message: isExistingProject && detectedFramework !== "generic" ? `We detected ${chalk2.cyan(detectedFramework)}. Please confirm or select another.` : chalk2.bold("\u2022 Which framework are you using?"),
12519
+ message: "\u2022 Which starter would you like to use?",
12519
12520
  choices: [
12520
12521
  {
12521
- title: `${chalk2.green("Next.js")} ${detectedFramework === "nextjs" ? chalk2.dim("(detected)") : ""}`,
12522
- value: "nextjs"
12522
+ title: `${chalk2.green("Next.js")} ${chalk2.dim("(Fullstack)")}`,
12523
+ value: "starter-nextjs"
12523
12524
  },
12524
12525
  {
12525
- title: `${chalk2.yellow("Vite")} ${detectedFramework === "vite" ? chalk2.dim("(detected)") : ""}`,
12526
- value: "vite"
12526
+ title: `${chalk2.yellow("Express.js")} ${chalk2.dim("(REST API)")}`,
12527
+ value: "starter-express-rest-api"
12527
12528
  },
12528
12529
  {
12529
- title: `${chalk2.cyan("Nuxt")} ${detectedFramework === "nuxt" ? chalk2.dim("(detected)") : ""}`,
12530
- value: "nuxt"
12530
+ title: `${chalk2.cyan("Deno")} ${chalk2.dim("(REST API)")}`,
12531
+ value: "starter-deno-rest-api"
12531
12532
  },
12532
12533
  {
12533
- title: `${chalk2.magenta("SvelteKit")} ${detectedFramework === "sveltekit" ? chalk2.dim("(detected)") : ""}`,
12534
- value: "sveltekit"
12534
+ title: `${chalk2.magenta("Bun")} ${chalk2.dim("(REST API)")}`,
12535
+ value: "starter-bun-rest-api"
12535
12536
  },
12536
12537
  {
12537
- title: `${chalk2.red("Remix")} ${detectedFramework === "remix" ? chalk2.dim("(detected)") : ""}`,
12538
- value: "remix"
12538
+ title: `${chalk2.red("Bun + React (Vite)")} ${chalk2.dim("(Fullstack)")}`,
12539
+ value: "starter-bun-react-app"
12539
12540
  },
12540
12541
  {
12541
- title: `${chalk2.white("Astro")} ${detectedFramework === "astro" ? chalk2.dim("(detected)") : ""}`,
12542
- value: "astro"
12543
- },
12544
- {
12545
- title: `${chalk2.blue("Express")} ${detectedFramework === "express" ? chalk2.dim("(detected)") : ""}`,
12546
- value: "express"
12547
- },
12548
- {
12549
- title: `${chalk2.magenta("TanStack Start")} ${detectedFramework === "tanstack-start" ? chalk2.dim("(detected)") : ""}`,
12550
- value: "tanstack-start"
12551
- },
12552
- {
12553
- title: chalk2.gray("Generic/Other"),
12554
- value: "generic"
12542
+ title: `${chalk2.magenta("TanStack Start")} ${chalk2.dim("(Fullstack)")}`,
12543
+ value: "starter-tanstack-start"
12555
12544
  }
12556
- ],
12557
- initial: getFrameworkChoiceIndex(detectedFramework)
12545
+ ]
12558
12546
  },
12559
12547
  {
12560
- type: "multiselect",
12548
+ type: cliOptions.features ? null : "multiselect",
12561
12549
  name: "features",
12562
12550
  message: chalk2.bold("\u2022 Which Igniter.js features would you like to enable?"),
12563
12551
  choices: [
@@ -12594,7 +12582,7 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
12594
12582
  instructions: chalk2.dim("Use \u2191\u2193 to navigate, space to select, enter to confirm")
12595
12583
  },
12596
12584
  {
12597
- type: "select",
12585
+ type: cliOptions.database ? null : "select",
12598
12586
  name: "database",
12599
12587
  message: chalk2.bold("\u2022 Choose your database (optional):"),
12600
12588
  choices: [
@@ -12618,14 +12606,18 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
12618
12606
  initial: 0
12619
12607
  },
12620
12608
  {
12621
- type: (prev) => prev !== "none" ? "confirm" : null,
12609
+ type: (prev) => {
12610
+ if (cliOptions.docker === false) return null;
12611
+ const dbValue = cliOptions.database || prev;
12612
+ return dbValue !== "none" ? "confirm" : null;
12613
+ },
12622
12614
  name: "dockerCompose",
12623
12615
  message: chalk2.bold("\u2022 Setup Docker Compose for development?"),
12624
12616
  hint: chalk2.dim("Includes Redis and your selected database"),
12625
- initial: true
12617
+ initial: cliOptions.docker !== false
12626
12618
  },
12627
12619
  {
12628
- type: "select",
12620
+ type: cliOptions.packageManager ? null : "select",
12629
12621
  name: "packageManager",
12630
12622
  message: isExistingProject ? `We detected ${chalk2.cyan(detectedPackageManager)}. Please confirm or select another.` : chalk2.bold("\u2022 Which package manager?"),
12631
12623
  choices: [
@@ -12646,19 +12638,19 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
12646
12638
  value: "bun"
12647
12639
  }
12648
12640
  ],
12649
- initial: getPackageManagerChoiceIndex(detectedPackageManager)
12641
+ initial: getPackageManagerChoiceIndex(cliOptions.packageManager || detectedPackageManager)
12650
12642
  },
12651
12643
  {
12652
- type: isExistingProject ? null : "confirm",
12644
+ type: isExistingProject || cliOptions.git === false ? null : "confirm",
12653
12645
  name: "initGit",
12654
12646
  message: chalk2.bold("\u2022 Initialize Git repository?"),
12655
- initial: true
12647
+ initial: cliOptions.git !== false
12656
12648
  },
12657
12649
  {
12658
- type: "confirm",
12650
+ type: cliOptions.install === false ? null : "confirm",
12659
12651
  name: "installDependencies",
12660
12652
  message: chalk2.bold("\u2022 Install dependencies automatically?"),
12661
- initial: true
12653
+ initial: cliOptions.install !== false
12662
12654
  }
12663
12655
  ], {
12664
12656
  onCancel: () => {
@@ -12666,22 +12658,24 @@ async function runSetupPrompts(targetDir, isExistingProject = false) {
12666
12658
  process.exit(0);
12667
12659
  }
12668
12660
  });
12661
+ const selectedFeatures = cliOptions.features ? cliFeatures : answers.features || [];
12662
+ const hasExplicitFeatures = cliOptions.features || answers.features && answers.features.length > 0;
12669
12663
  const featuresObj = {
12670
- store: answers.features.includes("store"),
12671
- jobs: answers.features.includes("jobs"),
12672
- mcp: answers.features.includes("mcp"),
12673
- logging: answers.features.includes("logging"),
12674
- telemetry: answers.features.includes("telemetry")
12664
+ store: selectedFeatures.includes("store"),
12665
+ jobs: selectedFeatures.includes("jobs"),
12666
+ mcp: selectedFeatures.includes("mcp"),
12667
+ logging: selectedFeatures.includes("logging") || !hasExplicitFeatures,
12668
+ telemetry: selectedFeatures.includes("telemetry") || !hasExplicitFeatures
12675
12669
  };
12676
12670
  const config = {
12677
12671
  projectName: answers.projectName || projectName,
12678
- framework: answers.framework,
12672
+ framework: cliOptions.template || answers.framework,
12679
12673
  features: featuresObj,
12680
- database: { provider: answers.database },
12681
- packageManager: answers.packageManager,
12682
- initGit: answers.initGit === void 0 ? false : answers.initGit,
12683
- installDependencies: answers.installDependencies,
12684
- dockerCompose: answers.dockerCompose || false
12674
+ database: { provider: cliOptions.database || answers.database || "none" },
12675
+ packageManager: cliOptions.packageManager || answers.packageManager || detectedPackageManager,
12676
+ initGit: cliOptions.git !== false && (answers.initGit !== void 0 ? answers.initGit : !isExistingProject),
12677
+ installDependencies: cliOptions.install !== false && answers.installDependencies !== false,
12678
+ dockerCompose: cliOptions.docker !== false && (answers.dockerCompose || false)
12685
12679
  };
12686
12680
  showConfigSummary(config);
12687
12681
  return config;
@@ -12714,10 +12708,6 @@ function showConfigSummary(config) {
12714
12708
  }
12715
12709
  console.log();
12716
12710
  }
12717
- function getFrameworkChoiceIndex(detected) {
12718
- const frameworks = ["nextjs", "vite", "nuxt", "sveltekit", "remix", "astro", "express", "tanstack-start", "generic"];
12719
- return Math.max(0, frameworks.indexOf(detected));
12720
- }
12721
12711
  function getPackageManagerChoiceIndex(detected) {
12722
12712
  const managers = ["npm", "yarn", "pnpm", "bun"];
12723
12713
  return Math.max(0, managers.indexOf(detected));
@@ -13600,9 +13590,9 @@ var ProjectGenerator = class {
13600
13590
  async downloadTemplate() {
13601
13591
  const { framework } = this.config;
13602
13592
  const templateUrl = `https://github.com/felipebarcelospro/igniter-js.git`;
13603
- const branch = "release/0.2.0-alpha.0";
13593
+ const branch = "main";
13604
13594
  const tempDir = path4.join(this.targetDir, "__igniter_tmp__");
13605
- const starterDir = path4.join(tempDir, "apps", `starter-${framework}`);
13595
+ const starterDir = path4.join(tempDir, "apps", framework);
13606
13596
  const destDir = this.targetDir;
13607
13597
  let isValidStarter = false;
13608
13598
  this.spinner.start(`Baixando apenas o conte\xFAdo da pasta starter (${framework}) do branch ${branch}...`);
@@ -14463,7 +14453,7 @@ async function handleGenerateProcedure(name, feature) {
14463
14453
  // src/index.ts
14464
14454
  var program = new Command();
14465
14455
  program.name("igniter").description("CLI for Igniter.js type-safe client generation").version("1.0.0");
14466
- program.command("init").description("Create a new Igniter.js project with interactive setup").argument("[project-name]", "Name of the project directory").option("--force", "Skip confirmation prompts and overwrite existing files").option("--pm, --package-manager <manager>", "Package manager to use (npm, yarn, pnpm, bun)").option("--template <template>", "Use a specific template (coming soon)").option("-f, --framework <framework>", "Target framework (nextjs, vite, etc.)").option("--no-git", "Skip git repository initialization").option("--no-install", "Skip automatic dependency installation").action(async (projectName, options) => {
14456
+ program.command("init").description("Create a new Igniter.js project with interactive setup").argument("[project-name]", "Name of the project directory").option("--force", "Skip confirmation prompts and overwrite existing files").option("--pm, --package-manager <manager>", "Package manager to use (npm, yarn, pnpm, bun)").option("--template <template>", "Use a specific template (e.g., starter-nextjs, starter-express-rest-api)").option("-f, --framework <framework>", "Target framework (nextjs, vite, etc.)").option("--features <features>", "Comma-separated list of features (store,jobs,mcp,logging,telemetry)").option("--database <database>", "Database provider (none, postgresql, mysql, sqlite)").option("--orm <orm>", "ORM provider (prisma, drizzle)").option("--no-git", "Skip git repository initialization").option("--no-install", "Skip automatic dependency installation").option("--no-docker", "Skip Docker Compose setup").action(async (projectName, options) => {
14467
14457
  const initLogger = createChildLogger({ component: "init-command" });
14468
14458
  try {
14469
14459
  if (!projectName) {
@@ -14500,7 +14490,7 @@ program.command("init").description("Create a new Igniter.js project with intera
14500
14490
  }
14501
14491
  }
14502
14492
  }
14503
- const config = await runSetupPrompts(targetDir, isExistingProject);
14493
+ const config = await runSetupPrompts(targetDir, isExistingProject, options);
14504
14494
  const validation = validateConfig(config);
14505
14495
  if (!validation.isValid) {
14506
14496
  console.error(`\u2717 ${validation.message}`);