create-newt-app 0.23.1 → 0.23.2

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.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  #!/usr/bin/env node
2
- type Testing = 'jest' | 'vitest';
3
- type Database = 'sqlite' | 'postgres';
4
- type Linter = 'eslint' | 'oxc';
5
- type Deployment = 'none' | 'standalone' | 'custom-server' | 'spa';
2
+ declare const TESTING_CHOICES: readonly ["jest", "vitest"];
3
+ declare const DATABASE_CHOICES: readonly ["sqlite", "postgres"];
4
+ declare const LINTER_CHOICES: readonly ["eslint", "oxc"];
5
+ declare const DEPLOYMENT_CHOICES: readonly ["none", "standalone", "custom-server", "spa"];
6
+ type Testing = (typeof TESTING_CHOICES)[number];
7
+ type Database = (typeof DATABASE_CHOICES)[number];
8
+ type Linter = (typeof LINTER_CHOICES)[number];
9
+ type Deployment = (typeof DEPLOYMENT_CHOICES)[number];
6
10
  type Options = {
7
11
  name?: string;
8
12
  install: boolean;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import chalk from "chalk";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "create-newt-app",
10
- version: "0.23.1",
10
+ version: "0.23.2",
11
11
  license: "MIT",
12
12
  private: false,
13
13
  type: "module",
@@ -12011,6 +12011,24 @@ async function sortPackageJsons(destDir) {
12011
12011
  })
12012
12012
  );
12013
12013
  }
12014
+ function validateFlagValue(flag, value, allowed) {
12015
+ if (allowed.includes(value)) {
12016
+ return { valid: true };
12017
+ }
12018
+ return {
12019
+ valid: false,
12020
+ error: `Invalid value "${value}" for ${flag}. Valid choices: ${allowed.join(", ")}.`
12021
+ };
12022
+ }
12023
+ function validateDeploymentCombo(deployment, nestDiOnly2) {
12024
+ if (deployment === "spa" && nestDiOnly2) {
12025
+ return {
12026
+ valid: false,
12027
+ error: "--deployment spa cannot be combined with --nest-di-only.\nSPA mode statically exports Next.js (output: 'export'), which cannot include the\nAPI route handlers that DI-only mode depends on. Pick one: drop --nest-di-only to\nget SPA mode with NestJS controllers, or drop --deployment spa."
12028
+ };
12029
+ }
12030
+ return { valid: true };
12031
+ }
12014
12032
  function validateProjectName(projectName) {
12015
12033
  if (!projectName) {
12016
12034
  return { valid: false, error: "Project name is required" };
@@ -12086,6 +12104,10 @@ async function initGit(cwd) {
12086
12104
  }
12087
12105
 
12088
12106
  // src/index.ts
12107
+ var TESTING_CHOICES = ["jest", "vitest"];
12108
+ var DATABASE_CHOICES = ["sqlite", "postgres"];
12109
+ var LINTER_CHOICES = ["eslint", "oxc"];
12110
+ var DEPLOYMENT_CHOICES = ["none", "standalone", "custom-server", "spa"];
12089
12111
  var TaskBuilder = class {
12090
12112
  tasks = [];
12091
12113
  add(task) {
@@ -12170,10 +12192,9 @@ async function doInit(options) {
12170
12192
  const deployment = options.nonInteractive ? options.deployment : group2.deployment ?? "none";
12171
12193
  const nestDiOnly2 = options.nonInteractive ? options.nestDiOnly : group2.nestDiOnly ?? false;
12172
12194
  const todoExample = options.nonInteractive ? !options.bare : group2.todoExample ?? true;
12173
- if (deployment === "spa" && nestDiOnly2) {
12174
- throw new Error(
12175
- "--deployment spa cannot be combined with --nest-di-only.\nSPA mode statically exports Next.js (output: 'export'), which cannot include the\nAPI route handlers that DI-only mode depends on. Pick one: drop --nest-di-only to\nget SPA mode with NestJS controllers, or drop --deployment spa."
12176
- );
12195
+ const deploymentCombo = validateDeploymentCombo(deployment, nestDiOnly2);
12196
+ if (!deploymentCombo.valid) {
12197
+ throw new Error(deploymentCombo.error);
12177
12198
  }
12178
12199
  const deploymentModule = deployment === "standalone" ? templates.deploymentStandalone : deployment === "custom-server" ? templates.deploymentCustomServer : deployment === "spa" ? templates.deploymentSpa : null;
12179
12200
  const webModule = deployment === "spa" ? {
@@ -12271,16 +12292,27 @@ program.name("create-newt-app").version(package_default.version).description("Cr
12271
12292
  const nonInteractive = configFlags.some(
12272
12293
  (flag) => command.getOptionValueSource(flag) === "cli"
12273
12294
  );
12295
+ const choices = [
12296
+ { flag: "--testing", value: options.testing, allowed: TESTING_CHOICES },
12297
+ { flag: "--database", value: options.database, allowed: DATABASE_CHOICES },
12298
+ { flag: "--linter", value: options.linter, allowed: LINTER_CHOICES },
12299
+ { flag: "--deployment", value: options.deployment, allowed: DEPLOYMENT_CHOICES }
12300
+ ];
12301
+ const invalid = choices.map(({ flag, value, allowed }) => validateFlagValue(flag, value, allowed)).find((result) => !result.valid);
12302
+ if (invalid) {
12303
+ console.error(`Error: ${invalid.error}`);
12304
+ process.exit(1);
12305
+ }
12274
12306
  await doInit({
12275
12307
  name,
12276
12308
  install: options.install,
12277
12309
  git: options.git,
12278
12310
  nonInteractive,
12279
12311
  shadcn: options.shadcn,
12280
- testing: options.testing === "vitest" ? "vitest" : "jest",
12281
- database: options.database === "postgres" ? "postgres" : "sqlite",
12282
- linter: options.linter === "oxc" ? "oxc" : "eslint",
12283
- deployment: ["standalone", "custom-server", "spa"].includes(options.deployment) ? options.deployment : "none",
12312
+ testing: options.testing,
12313
+ database: options.database,
12314
+ linter: options.linter,
12315
+ deployment: options.deployment,
12284
12316
  nestDiOnly: options.nestDiOnly,
12285
12317
  bare: options.bare
12286
12318
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-newt-app",
3
- "version": "0.23.1",
3
+ "version": "0.23.2",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",