create-newt-app 0.22.20 → 0.23.1
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 +1 -1
- package/dist/index.js +270 -61
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
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.
|
|
10
|
+
version: "0.23.1",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
private: false,
|
|
13
13
|
type: "module",
|
|
@@ -10183,12 +10183,11 @@ var api_package_json_default = {
|
|
|
10183
10183
|
"private": true,
|
|
10184
10184
|
"license": "UNLICENSED",
|
|
10185
10185
|
"exports": {
|
|
10186
|
-
".": "./
|
|
10186
|
+
".": "./dist/index.js"
|
|
10187
10187
|
},
|
|
10188
10188
|
"scripts": {
|
|
10189
10189
|
"build": "nest build",
|
|
10190
10190
|
"start": "nest start",
|
|
10191
|
-
"dev": "nest start --watch",
|
|
10192
10191
|
"start:dev": "nest start --watch",
|
|
10193
10192
|
"start:debug": "nest start --debug --watch",
|
|
10194
10193
|
"start:prod": "node dist/main"
|
|
@@ -10251,6 +10250,8 @@ async function main() {
|
|
|
10251
10250
|
await nextApp.prepare();
|
|
10252
10251
|
|
|
10253
10252
|
const nestApp = await NestFactory.create(AppModule);
|
|
10253
|
+
// apps/api/src/main.ts never runs here, so its prefix is set again
|
|
10254
|
+
nestApp.setGlobalPrefix('api');
|
|
10254
10255
|
await nestApp.init();
|
|
10255
10256
|
|
|
10256
10257
|
const nestListener = nestApp
|
|
@@ -10283,14 +10284,15 @@ var web_package_json_default = {
|
|
|
10283
10284
|
"private": true,
|
|
10284
10285
|
"scripts": {
|
|
10285
10286
|
"dev": "tsx watch --tsconfig tsconfig.server.json server.ts",
|
|
10286
|
-
"build": "next build",
|
|
10287
|
-
"start": "
|
|
10287
|
+
"build": "next build && tsc -p tsconfig.server.json",
|
|
10288
|
+
"start": "node dist/server.js",
|
|
10288
10289
|
"db:migrate": "better-auth migrate"
|
|
10289
10290
|
},
|
|
10290
10291
|
"dependencies": {
|
|
10291
10292
|
"@<%= projectName %>/api": "workspace:*",
|
|
10292
10293
|
"@<%= projectName %>/auth": "workspace:*",
|
|
10293
10294
|
"@<%= projectName %>/ui": "workspace:*",
|
|
10295
|
+
"@nestjs/core": "^11.0.1",
|
|
10294
10296
|
"@tailwindcss/postcss": "^4.2.1",
|
|
10295
10297
|
"dotenv": "^17.3.1",
|
|
10296
10298
|
"@tanstack/react-form": "^1.28.5",
|
|
@@ -10299,6 +10301,7 @@ var web_package_json_default = {
|
|
|
10299
10301
|
"next": "16.2.10",
|
|
10300
10302
|
"react": "^19.2.4",
|
|
10301
10303
|
"react-dom": "^19.2.4",
|
|
10304
|
+
"reflect-metadata": "^0.2.2",
|
|
10302
10305
|
"tailwindcss": "^4.2.1"
|
|
10303
10306
|
},
|
|
10304
10307
|
"devDependencies": {
|
|
@@ -10322,21 +10325,49 @@ import { resolve } from 'path';
|
|
|
10322
10325
|
dotenv.config({ path: resolve(process.cwd(), '../../.env') });
|
|
10323
10326
|
dotenv.config({ path: resolve(process.cwd(), '.env') });
|
|
10324
10327
|
|
|
10328
|
+
// No output setting: server.ts is the server, so Next runs in-process rather
|
|
10329
|
+
// than through its own standalone entrypoint.
|
|
10325
10330
|
/** @type {import('next').NextConfig} */
|
|
10326
|
-
const nextConfig = {
|
|
10327
|
-
output: "standalone",
|
|
10328
|
-
};
|
|
10331
|
+
const nextConfig = {};
|
|
10329
10332
|
|
|
10330
10333
|
export default nextConfig;`
|
|
10331
10334
|
};
|
|
10332
10335
|
|
|
10336
|
+
// src/templates/single-process-custom-server/templates/web-tsconfig.ts
|
|
10337
|
+
var web_tsconfig_default = {
|
|
10338
|
+
filename: "apps/web/tsconfig.json",
|
|
10339
|
+
template: `{
|
|
10340
|
+
"extends": "@<%= projectName %>/typescript-config/nextjs.json",
|
|
10341
|
+
"compilerOptions": {
|
|
10342
|
+
"plugins": [
|
|
10343
|
+
{
|
|
10344
|
+
"name": "next"
|
|
10345
|
+
}
|
|
10346
|
+
],
|
|
10347
|
+
"strictNullChecks": true,
|
|
10348
|
+
"paths": {
|
|
10349
|
+
"@/*": ["./*"]
|
|
10350
|
+
}
|
|
10351
|
+
},
|
|
10352
|
+
"include": [
|
|
10353
|
+
"**/*.ts",
|
|
10354
|
+
"**/*.tsx",
|
|
10355
|
+
"next-env.d.ts",
|
|
10356
|
+
"next.config.js",
|
|
10357
|
+
".next/types/**/*.ts"
|
|
10358
|
+
],
|
|
10359
|
+
"exclude": ["node_modules", "server.ts"]
|
|
10360
|
+
}`
|
|
10361
|
+
};
|
|
10362
|
+
|
|
10333
10363
|
// src/templates/single-process-custom-server/templates/web-tsconfig-server.ts
|
|
10334
10364
|
var web_tsconfig_server_default = {
|
|
10335
10365
|
filename: "apps/web/tsconfig.server.json",
|
|
10336
10366
|
template: `{
|
|
10337
10367
|
"compilerOptions": {
|
|
10338
|
-
"module": "
|
|
10339
|
-
"moduleResolution": "
|
|
10368
|
+
"module": "esnext",
|
|
10369
|
+
"moduleResolution": "bundler",
|
|
10370
|
+
"outDir": "dist",
|
|
10340
10371
|
"target": "ES2023",
|
|
10341
10372
|
"esModuleInterop": true,
|
|
10342
10373
|
"emitDecoratorMetadata": true,
|
|
@@ -10351,6 +10382,42 @@ var web_tsconfig_server_default = {
|
|
|
10351
10382
|
}`
|
|
10352
10383
|
};
|
|
10353
10384
|
|
|
10385
|
+
// src/templates/single-process-custom-server/templates/turbo-json.ts
|
|
10386
|
+
var turbo_json_default3 = {
|
|
10387
|
+
filename: "turbo.json",
|
|
10388
|
+
template: `{
|
|
10389
|
+
"$schema": "https://turborepo.dev/schema.json",
|
|
10390
|
+
"ui": "tui",
|
|
10391
|
+
"tasks": {
|
|
10392
|
+
"build": {
|
|
10393
|
+
"dependsOn": ["^build"],
|
|
10394
|
+
"inputs": ["$TURBO_DEFAULT$", ".env*"],
|
|
10395
|
+
"outputs": [".next/**", "!.next/cache/**", "dist/**"]
|
|
10396
|
+
},
|
|
10397
|
+
"lint": {
|
|
10398
|
+
"dependsOn": ["^lint"],
|
|
10399
|
+
"env": ["NODE_ENV"]
|
|
10400
|
+
},
|
|
10401
|
+
"test": {
|
|
10402
|
+
"dependsOn": ["^build"],
|
|
10403
|
+
"outputs": ["coverage/**"]
|
|
10404
|
+
},
|
|
10405
|
+
"dev": {
|
|
10406
|
+
"dependsOn": ["^migrate", "^build"],
|
|
10407
|
+
"cache": false,
|
|
10408
|
+
"persistent": true
|
|
10409
|
+
},
|
|
10410
|
+
"migrate": {
|
|
10411
|
+
"dependsOn": ["^migrate"],
|
|
10412
|
+
"cache": false
|
|
10413
|
+
},
|
|
10414
|
+
"generate": {
|
|
10415
|
+
"cache": false
|
|
10416
|
+
}
|
|
10417
|
+
}
|
|
10418
|
+
}`
|
|
10419
|
+
};
|
|
10420
|
+
|
|
10354
10421
|
// src/templates/single-process-custom-server/index.ts
|
|
10355
10422
|
var singleProcessCustomServer = {
|
|
10356
10423
|
templates: [
|
|
@@ -10359,38 +10426,13 @@ var singleProcessCustomServer = {
|
|
|
10359
10426
|
web_server_default,
|
|
10360
10427
|
web_package_json_default,
|
|
10361
10428
|
web_next_config_default,
|
|
10362
|
-
|
|
10429
|
+
web_tsconfig_default,
|
|
10430
|
+
web_tsconfig_server_default,
|
|
10431
|
+
turbo_json_default3
|
|
10363
10432
|
]
|
|
10364
10433
|
};
|
|
10365
10434
|
var single_process_custom_server_default = singleProcessCustomServer;
|
|
10366
10435
|
|
|
10367
|
-
// src/templates/single-process-static-export/templates/api-app-module.ts
|
|
10368
|
-
var api_app_module_default = {
|
|
10369
|
-
filename: "apps/api/src/app.module.ts",
|
|
10370
|
-
template: `import { join } from 'path';
|
|
10371
|
-
import { Module } from '@nestjs/common';
|
|
10372
|
-
import { APP_GUARD } from '@nestjs/core';
|
|
10373
|
-
import { ServeStaticModule } from '@nestjs/serve-static';
|
|
10374
|
-
import { AuthGuard, AuthModule } from '@thallesp/nestjs-better-auth';
|
|
10375
|
-
import { auth } from '@<%= projectName %>/auth';
|
|
10376
|
-
import { AppController } from './app.controller';
|
|
10377
|
-
import { TodosModule } from './todos/todos.module';
|
|
10378
|
-
|
|
10379
|
-
@Module({
|
|
10380
|
-
imports: [
|
|
10381
|
-
ServeStaticModule.forRoot({
|
|
10382
|
-
rootPath: join(process.cwd(), '../web/out'),
|
|
10383
|
-
exclude: ['/api/(.*)'],
|
|
10384
|
-
}),
|
|
10385
|
-
AuthModule.forRoot({ auth }),
|
|
10386
|
-
TodosModule,
|
|
10387
|
-
],
|
|
10388
|
-
controllers: [AppController],
|
|
10389
|
-
providers: [{ provide: APP_GUARD, useClass: AuthGuard }],
|
|
10390
|
-
})
|
|
10391
|
-
export class AppModule {}`
|
|
10392
|
-
};
|
|
10393
|
-
|
|
10394
10436
|
// src/templates/single-process-static-export/templates/api-package-json.ts
|
|
10395
10437
|
var api_package_json_default2 = {
|
|
10396
10438
|
filename: "apps/api/package.json",
|
|
@@ -10472,7 +10514,7 @@ export default nextConfig;`
|
|
|
10472
10514
|
|
|
10473
10515
|
// src/templates/single-process-static-export/index.ts
|
|
10474
10516
|
var singleProcessStaticExport = {
|
|
10475
|
-
templates: [
|
|
10517
|
+
templates: [api_package_json_default2, web_next_config_default2]
|
|
10476
10518
|
};
|
|
10477
10519
|
var single_process_static_export_default = singleProcessStaticExport;
|
|
10478
10520
|
|
|
@@ -10648,7 +10690,7 @@ export default nextConfig;`
|
|
|
10648
10690
|
};
|
|
10649
10691
|
|
|
10650
10692
|
// src/templates/nest-di-only/templates/web-tsconfig.ts
|
|
10651
|
-
var
|
|
10693
|
+
var web_tsconfig_default2 = {
|
|
10652
10694
|
filename: "apps/web/tsconfig.json",
|
|
10653
10695
|
template: `{
|
|
10654
10696
|
"extends": "@<%= projectName %>/typescript-config/nextjs.json",
|
|
@@ -10699,11 +10741,131 @@ var nestDiOnly = {
|
|
|
10699
10741
|
web_hello_route_default,
|
|
10700
10742
|
web_package_json_default2,
|
|
10701
10743
|
web_next_config_default3,
|
|
10702
|
-
|
|
10744
|
+
web_tsconfig_default2
|
|
10703
10745
|
]
|
|
10704
10746
|
};
|
|
10705
10747
|
var nest_di_only_default = nestDiOnly;
|
|
10706
10748
|
|
|
10749
|
+
// src/templates/deployment-standalone-di/templates/dockerfile.ts
|
|
10750
|
+
var dockerfile_default2 = {
|
|
10751
|
+
filename: "Dockerfile",
|
|
10752
|
+
template: `FROM node:22-alpine AS base
|
|
10753
|
+
ENV PNPM_HOME="/pnpm"
|
|
10754
|
+
ENV PATH="$PNPM_HOME:$PATH"
|
|
10755
|
+
RUN corepack enable
|
|
10756
|
+
|
|
10757
|
+
FROM base AS build
|
|
10758
|
+
WORKDIR /app
|
|
10759
|
+
COPY . .
|
|
10760
|
+
RUN pnpm install --frozen-lockfile
|
|
10761
|
+
RUN pnpm build --filter=web --filter=api --filter=@<%= projectName %>/auth
|
|
10762
|
+
|
|
10763
|
+
# --- web ---
|
|
10764
|
+
# DI-only has no api entrypoint: Nest is wired into this image through the
|
|
10765
|
+
# Next.js server, so there is no separate api stage.
|
|
10766
|
+
FROM base AS web
|
|
10767
|
+
WORKDIR /app
|
|
10768
|
+
ENV NODE_ENV=production
|
|
10769
|
+
COPY --from=build /app/apps/web/.next/standalone ./
|
|
10770
|
+
COPY --from=build /app/apps/web/.next/static ./apps/web/.next/static
|
|
10771
|
+
COPY --from=build /app/apps/web/public ./apps/web/public
|
|
10772
|
+
EXPOSE 3000
|
|
10773
|
+
CMD ["node", "apps/web/server.js"]
|
|
10774
|
+
|
|
10775
|
+
# --- migrate ---
|
|
10776
|
+
FROM build AS migrate
|
|
10777
|
+
WORKDIR /app
|
|
10778
|
+
CMD ["pnpm", "db:migrate"]`
|
|
10779
|
+
};
|
|
10780
|
+
|
|
10781
|
+
// src/templates/deployment-standalone-di/templates/docker-compose.ts
|
|
10782
|
+
var docker_compose_default2 = {
|
|
10783
|
+
filename: "docker-compose.yml",
|
|
10784
|
+
template: `x-app-env: &app-env
|
|
10785
|
+
BETTER_AUTH_SECRET: \${BETTER_AUTH_SECRET}
|
|
10786
|
+
DATABASE_URL: postgresql://postgres:\${POSTGRES_PASSWORD:-postgres}@db:5432/postgres
|
|
10787
|
+
|
|
10788
|
+
services:
|
|
10789
|
+
web:
|
|
10790
|
+
build:
|
|
10791
|
+
context: .
|
|
10792
|
+
target: web
|
|
10793
|
+
ports:
|
|
10794
|
+
- "3000:3000"
|
|
10795
|
+
environment:
|
|
10796
|
+
<<: *app-env
|
|
10797
|
+
depends_on:
|
|
10798
|
+
db:
|
|
10799
|
+
condition: service_healthy
|
|
10800
|
+
migrate:
|
|
10801
|
+
condition: service_completed_successfully
|
|
10802
|
+
|
|
10803
|
+
migrate:
|
|
10804
|
+
build:
|
|
10805
|
+
context: .
|
|
10806
|
+
target: migrate
|
|
10807
|
+
environment:
|
|
10808
|
+
<<: *app-env
|
|
10809
|
+
depends_on:
|
|
10810
|
+
db:
|
|
10811
|
+
condition: service_healthy
|
|
10812
|
+
restart: "no"
|
|
10813
|
+
|
|
10814
|
+
db:
|
|
10815
|
+
image: postgres:17-alpine
|
|
10816
|
+
ports:
|
|
10817
|
+
- "5432:5432"
|
|
10818
|
+
environment:
|
|
10819
|
+
- POSTGRES_PASSWORD=\${POSTGRES_PASSWORD:-postgres}
|
|
10820
|
+
volumes:
|
|
10821
|
+
- db_data:/var/lib/postgresql/data
|
|
10822
|
+
healthcheck:
|
|
10823
|
+
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
10824
|
+
interval: 5s
|
|
10825
|
+
timeout: 5s
|
|
10826
|
+
retries: 5
|
|
10827
|
+
|
|
10828
|
+
volumes:
|
|
10829
|
+
db_data:`
|
|
10830
|
+
};
|
|
10831
|
+
|
|
10832
|
+
// src/templates/deployment-standalone-di/templates/next-config.ts
|
|
10833
|
+
var next_config_default3 = {
|
|
10834
|
+
filename: "apps/web/next.config.js",
|
|
10835
|
+
template: `import dotenv from 'dotenv';
|
|
10836
|
+
import { resolve } from 'path';
|
|
10837
|
+
|
|
10838
|
+
// Load root .env first, then local .env (local takes precedence)
|
|
10839
|
+
dotenv.config({ path: resolve(process.cwd(), '../../.env') });
|
|
10840
|
+
dotenv.config({ path: resolve(process.cwd(), '.env') });
|
|
10841
|
+
|
|
10842
|
+
// No /api rewrite: DI-only runs Nest inside this process, so Next serves
|
|
10843
|
+
// /api itself and there is no separate api container to proxy to.
|
|
10844
|
+
/** @type {import('next').NextConfig} */
|
|
10845
|
+
const nextConfig = {
|
|
10846
|
+
output: "standalone",
|
|
10847
|
+
serverExternalPackages: [
|
|
10848
|
+
'@<%= projectName %>/api',
|
|
10849
|
+
'@<%= projectName %>/db',
|
|
10850
|
+
'@nestjs/core',
|
|
10851
|
+
'@nestjs/common',
|
|
10852
|
+
'@nestjs/microservices',
|
|
10853
|
+
'@nestjs/websockets',
|
|
10854
|
+
'@thallesp/nestjs-better-auth',
|
|
10855
|
+
'reflect-metadata',
|
|
10856
|
+
'express',
|
|
10857
|
+
],
|
|
10858
|
+
};
|
|
10859
|
+
|
|
10860
|
+
export default nextConfig;`
|
|
10861
|
+
};
|
|
10862
|
+
|
|
10863
|
+
// src/templates/deployment-standalone-di/index.ts
|
|
10864
|
+
var deploymentStandaloneDi = {
|
|
10865
|
+
templates: [dockerfile_default2, docker_compose_default2, next_config_default3]
|
|
10866
|
+
};
|
|
10867
|
+
var deployment_standalone_di_default = deploymentStandaloneDi;
|
|
10868
|
+
|
|
10707
10869
|
// src/templates/api-controllers/templates/app-controller.ts
|
|
10708
10870
|
var app_controller_default = {
|
|
10709
10871
|
filename: "apps/api/src/app.controller.ts",
|
|
@@ -10759,15 +10921,26 @@ describe('AppController', () => {
|
|
|
10759
10921
|
// src/templates/api-controllers/templates/app-module.ts
|
|
10760
10922
|
var app_module_default2 = {
|
|
10761
10923
|
filename: "apps/api/src/app.module.ts",
|
|
10762
|
-
template:
|
|
10924
|
+
template: `<% if (deployment === 'spa') { %>import { join } from 'path';
|
|
10925
|
+
<% } %>import { Module } from '@nestjs/common';
|
|
10763
10926
|
import { APP_GUARD } from '@nestjs/core';
|
|
10764
|
-
import {
|
|
10927
|
+
<% if (deployment === 'spa') { %>import { ServeStaticModule } from '@nestjs/serve-static';
|
|
10928
|
+
<% } %>import { AuthGuard, AuthModule } from '@thallesp/nestjs-better-auth';
|
|
10765
10929
|
import { auth } from '@<%= projectName %>/auth';
|
|
10766
10930
|
import { AppController } from './app.controller';
|
|
10767
10931
|
import { AppService } from './app.service';
|
|
10768
10932
|
|
|
10769
10933
|
@Module({
|
|
10770
|
-
imports: [
|
|
10934
|
+
<% if (deployment === 'spa') { %> imports: [
|
|
10935
|
+
// serves apps/web's static export; the api runs from apps/api
|
|
10936
|
+
ServeStaticModule.forRoot({
|
|
10937
|
+
rootPath: join(process.cwd(), '../web/out'),
|
|
10938
|
+
exclude: ['/api/{*splat}'],
|
|
10939
|
+
}),
|
|
10940
|
+
AuthModule.forRoot({ auth }),
|
|
10941
|
+
],
|
|
10942
|
+
<% } else { %> imports: [AuthModule.forRoot({ auth })],
|
|
10943
|
+
<% } -%>
|
|
10771
10944
|
controllers: [AppController],
|
|
10772
10945
|
providers: [AppService, { provide: APP_GUARD, useClass: AuthGuard }],
|
|
10773
10946
|
})
|
|
@@ -11071,16 +11244,28 @@ export class TodosModule {}`
|
|
|
11071
11244
|
// src/templates/todo-example/templates/app-module-controllers.ts
|
|
11072
11245
|
var app_module_controllers_default = {
|
|
11073
11246
|
filename: "apps/api/src/app.module.ts",
|
|
11074
|
-
template:
|
|
11247
|
+
template: `<% if (deployment === 'spa') { %>import { join } from 'path';
|
|
11248
|
+
<% } %>import { Module } from '@nestjs/common';
|
|
11075
11249
|
import { APP_GUARD } from '@nestjs/core';
|
|
11076
|
-
import {
|
|
11250
|
+
<% if (deployment === 'spa') { %>import { ServeStaticModule } from '@nestjs/serve-static';
|
|
11251
|
+
<% } %>import { AuthGuard, AuthModule } from '@thallesp/nestjs-better-auth';
|
|
11077
11252
|
import { auth } from '@<%= projectName %>/auth';
|
|
11078
11253
|
import { AppController } from './app.controller';
|
|
11079
11254
|
import { AppService } from './app.service';
|
|
11080
11255
|
import { TodosModule } from './todos/todos.module';
|
|
11081
11256
|
|
|
11082
11257
|
@Module({
|
|
11083
|
-
|
|
11258
|
+
<% if (deployment === 'spa') { %> imports: [
|
|
11259
|
+
// serves apps/web's static export; the api runs from apps/api
|
|
11260
|
+
ServeStaticModule.forRoot({
|
|
11261
|
+
rootPath: join(process.cwd(), '../web/out'),
|
|
11262
|
+
exclude: ['/api/{*splat}'],
|
|
11263
|
+
}),
|
|
11264
|
+
AuthModule.forRoot({ auth }),
|
|
11265
|
+
TodosModule,
|
|
11266
|
+
],
|
|
11267
|
+
<% } else { %> imports: [AuthModule.forRoot({ auth }), TodosModule],
|
|
11268
|
+
<% } -%>
|
|
11084
11269
|
controllers: [AppController],
|
|
11085
11270
|
providers: [AppService, { provide: APP_GUARD, useClass: AuthGuard }],
|
|
11086
11271
|
})
|
|
@@ -11702,6 +11887,7 @@ var templates = {
|
|
|
11702
11887
|
deploymentCustomServer: single_process_custom_server_default,
|
|
11703
11888
|
deploymentSpa: single_process_static_export_default,
|
|
11704
11889
|
nestDiOnly: nest_di_only_default,
|
|
11890
|
+
deploymentStandaloneDi: deployment_standalone_di_default,
|
|
11705
11891
|
apiControllers: api_controllers_default,
|
|
11706
11892
|
todoExampleApi,
|
|
11707
11893
|
todoExampleControllers,
|
|
@@ -11863,6 +12049,7 @@ async function scaffold(modules, options) {
|
|
|
11863
12049
|
projectName: options.name,
|
|
11864
12050
|
testing: options.testing,
|
|
11865
12051
|
database: options.database,
|
|
12052
|
+
deployment: options.deployment,
|
|
11866
12053
|
authSecret: randomBytes(32).toString("base64url")
|
|
11867
12054
|
};
|
|
11868
12055
|
await renderTemplatesToDisk(modules, options.name, templateData);
|
|
@@ -11918,7 +12105,7 @@ async function doInit(options) {
|
|
|
11918
12105
|
}
|
|
11919
12106
|
})
|
|
11920
12107
|
},
|
|
11921
|
-
...!options.
|
|
12108
|
+
...!options.nonInteractive && {
|
|
11922
12109
|
shadcn: () => p.confirm({
|
|
11923
12110
|
message: "Use shadcn/ui?",
|
|
11924
12111
|
initialValue: true
|
|
@@ -11955,13 +12142,15 @@ async function doInit(options) {
|
|
|
11955
12142
|
message: "Include the todo example?",
|
|
11956
12143
|
initialValue: true
|
|
11957
12144
|
}),
|
|
11958
|
-
deployment: () => p.select({
|
|
12145
|
+
deployment: ({ results }) => p.select({
|
|
11959
12146
|
message: "Deployment extras?",
|
|
11960
12147
|
options: [
|
|
11961
12148
|
{ value: "none", label: "None", hint: "skip" },
|
|
11962
12149
|
{ value: "standalone", label: "Standalone + Dockerfile", hint: "Dockerfiles + docker-compose.yml" },
|
|
11963
12150
|
{ value: "custom-server", label: "Custom Server", hint: "single process, single port" },
|
|
11964
|
-
|
|
12151
|
+
// SPA statically exports Next.js, which can't hold the route
|
|
12152
|
+
// handlers DI-only mode runs on
|
|
12153
|
+
...results.nestDiOnly ? [] : [{ value: "spa", label: "SPA Mode", hint: "static export served by NestJS" }]
|
|
11965
12154
|
],
|
|
11966
12155
|
initialValue: "none"
|
|
11967
12156
|
})
|
|
@@ -11974,13 +12163,18 @@ async function doInit(options) {
|
|
|
11974
12163
|
process.exit(0);
|
|
11975
12164
|
}
|
|
11976
12165
|
});
|
|
11977
|
-
const useShadcn = options.
|
|
11978
|
-
const testing = options.
|
|
11979
|
-
const database = options.
|
|
11980
|
-
const linter = options.
|
|
11981
|
-
const deployment = options.
|
|
11982
|
-
const nestDiOnly2 = options.
|
|
11983
|
-
const todoExample = options.
|
|
12166
|
+
const useShadcn = options.nonInteractive ? options.shadcn : group2.shadcn ?? true;
|
|
12167
|
+
const testing = options.nonInteractive ? options.testing : group2.testing ?? "jest";
|
|
12168
|
+
const database = options.nonInteractive ? options.database : group2.database ?? "sqlite";
|
|
12169
|
+
const linter = options.nonInteractive ? options.linter : group2.linter ?? "eslint";
|
|
12170
|
+
const deployment = options.nonInteractive ? options.deployment : group2.deployment ?? "none";
|
|
12171
|
+
const nestDiOnly2 = options.nonInteractive ? options.nestDiOnly : group2.nestDiOnly ?? false;
|
|
12172
|
+
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
|
+
);
|
|
12177
|
+
}
|
|
11984
12178
|
const deploymentModule = deployment === "standalone" ? templates.deploymentStandalone : deployment === "custom-server" ? templates.deploymentCustomServer : deployment === "spa" ? templates.deploymentSpa : null;
|
|
11985
12179
|
const webModule = deployment === "spa" ? {
|
|
11986
12180
|
...templates.web,
|
|
@@ -12000,6 +12194,9 @@ async function doInit(options) {
|
|
|
12000
12194
|
testing === "vitest" ? templates.testingVitest : templates.testingJest,
|
|
12001
12195
|
...deploymentModule ? [deploymentModule] : [],
|
|
12002
12196
|
...nestDiOnly2 ? [templates.nestDiOnly] : [templates.apiControllers],
|
|
12197
|
+
// nest-di-only overwrites the standalone next.config.js and leaves the
|
|
12198
|
+
// Dockerfile pointing at an api entrypoint DI-only never emits
|
|
12199
|
+
...nestDiOnly2 && deployment === "standalone" ? [templates.deploymentStandaloneDi] : [],
|
|
12003
12200
|
...todoExample ? [
|
|
12004
12201
|
templates.todoExampleApi,
|
|
12005
12202
|
...nestDiOnly2 ? [templates.todoExampleDi] : [templates.todoExampleControllers],
|
|
@@ -12011,7 +12208,7 @@ async function doInit(options) {
|
|
|
12011
12208
|
taskBuilder.add({
|
|
12012
12209
|
title: "Scaffolding project",
|
|
12013
12210
|
task: async () => {
|
|
12014
|
-
await scaffold(allModules, { name, testing, database });
|
|
12211
|
+
await scaffold(allModules, { name, testing, database, deployment });
|
|
12015
12212
|
return "Scaffolded.";
|
|
12016
12213
|
}
|
|
12017
12214
|
});
|
|
@@ -12059,14 +12256,26 @@ async function doInit(options) {
|
|
|
12059
12256
|
}
|
|
12060
12257
|
}
|
|
12061
12258
|
var program = new Command();
|
|
12062
|
-
program.name("create-newt-app").version(package_default.version).description("Create a new newt-app monorepo").argument("[name]").option("-ni, --no-install", "Skip pnpm install", true).option("-ng, --no-git", "Skip git initialization", true).option("--
|
|
12063
|
-
async (name, options) => {
|
|
12259
|
+
program.name("create-newt-app").version(package_default.version).description("Create a new newt-app monorepo").argument("[name]").option("-ni, --no-install", "Skip pnpm install", true).option("-ng, --no-git", "Skip git initialization", true).option("--shadcn", "Include shadcn/ui", false).option("--testing <framework>", "Testing framework: vitest or jest", "jest").option("--database <database>", "Database: sqlite or postgres", "sqlite").option("--linter <linter>", "Linter: eslint or oxc", "eslint").option("--deployment <strategy>", "Deployment extras: standalone, custom-server, spa", "none").option("--nest-di-only", "Use NestJS for dependency injection only", false).option("--bare", "Skip the todo example", false).action(
|
|
12260
|
+
async (name, options, command) => {
|
|
12064
12261
|
intro(`Create a ${chalk.blue("newt")} app.`);
|
|
12262
|
+
const configFlags = [
|
|
12263
|
+
"shadcn",
|
|
12264
|
+
"testing",
|
|
12265
|
+
"database",
|
|
12266
|
+
"linter",
|
|
12267
|
+
"deployment",
|
|
12268
|
+
"nestDiOnly",
|
|
12269
|
+
"bare"
|
|
12270
|
+
];
|
|
12271
|
+
const nonInteractive = configFlags.some(
|
|
12272
|
+
(flag) => command.getOptionValueSource(flag) === "cli"
|
|
12273
|
+
);
|
|
12065
12274
|
await doInit({
|
|
12066
12275
|
name,
|
|
12067
12276
|
install: options.install,
|
|
12068
12277
|
git: options.git,
|
|
12069
|
-
|
|
12278
|
+
nonInteractive,
|
|
12070
12279
|
shadcn: options.shadcn,
|
|
12071
12280
|
testing: options.testing === "vitest" ? "vitest" : "jest",
|
|
12072
12281
|
database: options.database === "postgres" ? "postgres" : "sqlite",
|