create-newt-app 0.23.2 → 0.23.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.js +61 -13
- package/package.json +1 -1
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.
|
|
10
|
+
version: "0.23.4",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
private: false,
|
|
13
13
|
type: "module",
|
|
@@ -147,6 +147,7 @@ var npmrc_default = {
|
|
|
147
147
|
|
|
148
148
|
// src/templates/root/templates/turbo-json.ts
|
|
149
149
|
var turbo_json_default = {
|
|
150
|
+
when: (s) => s.deployment !== "standalone" && s.deployment !== "custom-server",
|
|
150
151
|
filename: "turbo.json",
|
|
151
152
|
template: `{
|
|
152
153
|
"$schema": "https://turborepo.dev/schema.json",
|
|
@@ -265,6 +266,7 @@ var root_default = root;
|
|
|
265
266
|
|
|
266
267
|
// src/templates/web/templates/package-json.ts
|
|
267
268
|
var package_json_default2 = {
|
|
269
|
+
when: (s) => !s.nestDiOnly && s.deployment !== "custom-server",
|
|
268
270
|
filename: "apps/web/package.json",
|
|
269
271
|
template: `{
|
|
270
272
|
"name": "web",
|
|
@@ -384,6 +386,7 @@ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/bui
|
|
|
384
386
|
|
|
385
387
|
// src/templates/web/templates/next-config.ts
|
|
386
388
|
var next_config_default = {
|
|
389
|
+
when: (s) => s.deployment === "none" && !s.nestDiOnly,
|
|
387
390
|
filename: "apps/web/next.config.js",
|
|
388
391
|
template: `import dotenv from 'dotenv';
|
|
389
392
|
import { resolve } from 'path';
|
|
@@ -415,6 +418,7 @@ var postcss_config_default = {
|
|
|
415
418
|
|
|
416
419
|
// src/templates/web/templates/tsconfig.ts
|
|
417
420
|
var tsconfig_default = {
|
|
421
|
+
when: (s) => !s.nestDiOnly && s.deployment !== "custom-server",
|
|
418
422
|
filename: "apps/web/tsconfig.json",
|
|
419
423
|
template: `{
|
|
420
424
|
"extends": "@<%= projectName %>/typescript-config/nextjs.json",
|
|
@@ -442,6 +446,7 @@ var tsconfig_default = {
|
|
|
442
446
|
|
|
443
447
|
// src/templates/web/templates/layout.ts
|
|
444
448
|
var layout_default = {
|
|
449
|
+
when: (s) => !s.shadcn,
|
|
445
450
|
filename: "apps/web/app/layout.tsx",
|
|
446
451
|
template: `import type { Metadata } from "next";
|
|
447
452
|
import localFont from "next/font/local";
|
|
@@ -486,6 +491,7 @@ export default function RootLayout({
|
|
|
486
491
|
|
|
487
492
|
// src/templates/web/templates/page.ts
|
|
488
493
|
var page_default = {
|
|
494
|
+
when: (s) => !s.todoExample && !s.shadcn,
|
|
489
495
|
filename: "apps/web/app/page.tsx",
|
|
490
496
|
template: `'use client';
|
|
491
497
|
|
|
@@ -575,6 +581,7 @@ export default function Home() {
|
|
|
575
581
|
|
|
576
582
|
// src/templates/web/templates/providers.ts
|
|
577
583
|
var providers_default = {
|
|
584
|
+
when: (s) => !s.shadcn,
|
|
578
585
|
filename: "apps/web/app/providers.tsx",
|
|
579
586
|
template: `'use client';
|
|
580
587
|
|
|
@@ -589,6 +596,7 @@ export default function Providers({ children }: { children: React.ReactNode }) {
|
|
|
589
596
|
|
|
590
597
|
// src/templates/web/templates/auth-form.ts
|
|
591
598
|
var auth_form_default = {
|
|
599
|
+
when: (s) => !s.shadcn,
|
|
592
600
|
filename: "apps/web/app/auth-form.tsx",
|
|
593
601
|
template: `'use client';
|
|
594
602
|
|
|
@@ -797,6 +805,7 @@ var web_default = web;
|
|
|
797
805
|
|
|
798
806
|
// src/templates/api/templates/package-json.ts
|
|
799
807
|
var package_json_default3 = {
|
|
808
|
+
when: (s) => !s.nestDiOnly && s.deployment !== "spa" && s.deployment !== "custom-server",
|
|
800
809
|
filename: "apps/api/package.json",
|
|
801
810
|
template: `{
|
|
802
811
|
"name": "api",
|
|
@@ -854,6 +863,7 @@ var nest_cli_default = {
|
|
|
854
863
|
|
|
855
864
|
// src/templates/api/templates/tsconfig.ts
|
|
856
865
|
var tsconfig_default2 = {
|
|
866
|
+
when: (s) => !s.nestDiOnly,
|
|
857
867
|
filename: "apps/api/tsconfig.json",
|
|
858
868
|
template: `{
|
|
859
869
|
"compilerOptions": {
|
|
@@ -894,6 +904,7 @@ var tsconfig_build_default = {
|
|
|
894
904
|
|
|
895
905
|
// src/templates/api/templates/app-module.ts
|
|
896
906
|
var app_module_default = {
|
|
907
|
+
when: (s) => s.nestDiOnly && !s.todoExample,
|
|
897
908
|
filename: "apps/api/src/app.module.ts",
|
|
898
909
|
template: `import { Module } from '@nestjs/common';
|
|
899
910
|
import { AppService } from './app.service';
|
|
@@ -1060,6 +1071,7 @@ var tsconfig_default4 = {
|
|
|
1060
1071
|
|
|
1061
1072
|
// src/templates/db/templates/src-schema.ts
|
|
1062
1073
|
var src_schema_default = {
|
|
1074
|
+
when: (s) => !s.todoExample,
|
|
1063
1075
|
filename: "packages/db/src/schema.ts",
|
|
1064
1076
|
template: `<% const date = database === 'postgres' ? 'Date' : 'string'; const bool = database === 'postgres' ? 'boolean' : 'number'; -%>
|
|
1065
1077
|
export interface UserTable {
|
|
@@ -2013,6 +2025,7 @@ export default function RootLayout({
|
|
|
2013
2025
|
|
|
2014
2026
|
// src/templates/shadcn-ui/templates/page.ts
|
|
2015
2027
|
var page_default2 = {
|
|
2028
|
+
when: (s) => !s.todoExample,
|
|
2016
2029
|
filename: "apps/web/app/page.tsx",
|
|
2017
2030
|
template: `'use client';
|
|
2018
2031
|
|
|
@@ -10001,6 +10014,7 @@ var testing_vitest_default = testingVitest;
|
|
|
10001
10014
|
|
|
10002
10015
|
// src/templates/deployment-standalone/templates/dockerfile.ts
|
|
10003
10016
|
var dockerfile_default = {
|
|
10017
|
+
when: (s) => !s.nestDiOnly,
|
|
10004
10018
|
filename: "Dockerfile",
|
|
10005
10019
|
template: `FROM node:22-alpine AS base
|
|
10006
10020
|
ENV PNPM_HOME="/pnpm"
|
|
@@ -10042,9 +10056,13 @@ CMD ["pnpm", "db:migrate"]`
|
|
|
10042
10056
|
|
|
10043
10057
|
// src/templates/deployment-standalone/templates/docker-compose.ts
|
|
10044
10058
|
var docker_compose_default = {
|
|
10059
|
+
when: (s) => !s.nestDiOnly,
|
|
10045
10060
|
filename: "docker-compose.yml",
|
|
10046
10061
|
template: `x-app-env: &app-env
|
|
10047
10062
|
BETTER_AUTH_SECRET: \${BETTER_AUTH_SECRET}
|
|
10063
|
+
# Better Auth trusts this origin; without it every deployment falls back to
|
|
10064
|
+
# localhost:3000 and rejects requests from the real one.
|
|
10065
|
+
BETTER_AUTH_URL: \${BETTER_AUTH_URL:-http://localhost:3000}
|
|
10048
10066
|
DATABASE_URL: postgresql://postgres:\${POSTGRES_PASSWORD:-postgres}@db:5432/postgres
|
|
10049
10067
|
|
|
10050
10068
|
services:
|
|
@@ -10106,6 +10124,7 @@ volumes:
|
|
|
10106
10124
|
|
|
10107
10125
|
// src/templates/deployment-standalone/templates/next-config.ts
|
|
10108
10126
|
var next_config_default2 = {
|
|
10127
|
+
when: (s) => !s.nestDiOnly,
|
|
10109
10128
|
filename: "apps/web/next.config.js",
|
|
10110
10129
|
template: `import dotenv from 'dotenv';
|
|
10111
10130
|
import { resolve } from 'path';
|
|
@@ -10317,6 +10336,7 @@ var web_package_json_default = {
|
|
|
10317
10336
|
|
|
10318
10337
|
// src/templates/single-process-custom-server/templates/web-next-config.ts
|
|
10319
10338
|
var web_next_config_default = {
|
|
10339
|
+
when: (s) => !s.nestDiOnly,
|
|
10320
10340
|
filename: "apps/web/next.config.js",
|
|
10321
10341
|
template: `import dotenv from 'dotenv';
|
|
10322
10342
|
import { resolve } from 'path';
|
|
@@ -10590,6 +10610,7 @@ var api_tsconfig_default = {
|
|
|
10590
10610
|
|
|
10591
10611
|
// src/templates/nest-di-only/templates/api-index.ts
|
|
10592
10612
|
var api_index_default = {
|
|
10613
|
+
when: (s) => !s.todoExample,
|
|
10593
10614
|
filename: "apps/api/src/index.ts",
|
|
10594
10615
|
template: `export { AppModule } from './app.module';
|
|
10595
10616
|
export { AppService } from './app.service';`
|
|
@@ -10664,6 +10685,7 @@ var web_package_json_default2 = {
|
|
|
10664
10685
|
|
|
10665
10686
|
// src/templates/nest-di-only/templates/web-next-config.ts
|
|
10666
10687
|
var web_next_config_default3 = {
|
|
10688
|
+
when: (s) => s.deployment !== "standalone",
|
|
10667
10689
|
filename: "apps/web/next.config.js",
|
|
10668
10690
|
template: `import dotenv from 'dotenv';
|
|
10669
10691
|
import { resolve } from 'path';
|
|
@@ -10758,7 +10780,7 @@ FROM base AS build
|
|
|
10758
10780
|
WORKDIR /app
|
|
10759
10781
|
COPY . .
|
|
10760
10782
|
RUN pnpm install --frozen-lockfile
|
|
10761
|
-
RUN pnpm build --filter=web --filter
|
|
10783
|
+
RUN pnpm build --filter=web --filter=@<%= projectName %>/api --filter=@<%= projectName %>/auth
|
|
10762
10784
|
|
|
10763
10785
|
# --- web ---
|
|
10764
10786
|
# DI-only has no api entrypoint: Nest is wired into this image through the
|
|
@@ -10783,6 +10805,9 @@ var docker_compose_default2 = {
|
|
|
10783
10805
|
filename: "docker-compose.yml",
|
|
10784
10806
|
template: `x-app-env: &app-env
|
|
10785
10807
|
BETTER_AUTH_SECRET: \${BETTER_AUTH_SECRET}
|
|
10808
|
+
# Better Auth trusts this origin; without it every deployment falls back to
|
|
10809
|
+
# localhost:3000 and rejects requests from the real one.
|
|
10810
|
+
BETTER_AUTH_URL: \${BETTER_AUTH_URL:-http://localhost:3000}
|
|
10786
10811
|
DATABASE_URL: postgresql://postgres:\${POSTGRES_PASSWORD:-postgres}@db:5432/postgres
|
|
10787
10812
|
|
|
10788
10813
|
services:
|
|
@@ -10920,6 +10945,7 @@ describe('AppController', () => {
|
|
|
10920
10945
|
|
|
10921
10946
|
// src/templates/api-controllers/templates/app-module.ts
|
|
10922
10947
|
var app_module_default2 = {
|
|
10948
|
+
when: (s) => !s.nestDiOnly && !s.todoExample,
|
|
10923
10949
|
filename: "apps/api/src/app.module.ts",
|
|
10924
10950
|
template: `<% if (deployment === 'spa') { %>import { join } from 'path';
|
|
10925
10951
|
<% } %>import { Module } from '@nestjs/common';
|
|
@@ -10985,6 +11011,7 @@ var api_controllers_default = apiControllers;
|
|
|
10985
11011
|
|
|
10986
11012
|
// src/templates/todo-example/templates/todos-module.ts
|
|
10987
11013
|
var todos_module_default = {
|
|
11014
|
+
when: (s) => s.nestDiOnly,
|
|
10988
11015
|
filename: "apps/api/src/todos/todos.module.ts",
|
|
10989
11016
|
template: `import { Module } from '@nestjs/common';
|
|
10990
11017
|
import { TodosService } from './todos.service';
|
|
@@ -11243,6 +11270,7 @@ export class TodosModule {}`
|
|
|
11243
11270
|
|
|
11244
11271
|
// src/templates/todo-example/templates/app-module-controllers.ts
|
|
11245
11272
|
var app_module_controllers_default = {
|
|
11273
|
+
when: (s) => !s.nestDiOnly && s.todoExample,
|
|
11246
11274
|
filename: "apps/api/src/app.module.ts",
|
|
11247
11275
|
template: `<% if (deployment === 'spa') { %>import { join } from 'path';
|
|
11248
11276
|
<% } %>import { Module } from '@nestjs/common';
|
|
@@ -11274,6 +11302,7 @@ export class AppModule {}`
|
|
|
11274
11302
|
|
|
11275
11303
|
// src/templates/todo-example/templates/app-module-di.ts
|
|
11276
11304
|
var app_module_di_default = {
|
|
11305
|
+
when: (s) => s.nestDiOnly && s.todoExample,
|
|
11277
11306
|
filename: "apps/api/src/app.module.ts",
|
|
11278
11307
|
template: `import { Module } from '@nestjs/common';
|
|
11279
11308
|
import { AppService } from './app.service';
|
|
@@ -11504,6 +11533,7 @@ export function TodoList({
|
|
|
11504
11533
|
|
|
11505
11534
|
// src/templates/todo-example/templates/web-page.ts
|
|
11506
11535
|
var web_page_default = {
|
|
11536
|
+
when: (s) => s.todoExample && !s.shadcn,
|
|
11507
11537
|
filename: "apps/web/app/page.tsx",
|
|
11508
11538
|
template: `'use client';
|
|
11509
11539
|
|
|
@@ -11735,6 +11765,7 @@ export function TodoList({
|
|
|
11735
11765
|
|
|
11736
11766
|
// src/templates/todo-example/templates/shadcn-page.ts
|
|
11737
11767
|
var shadcn_page_default = {
|
|
11768
|
+
when: (s) => s.todoExample && s.shadcn,
|
|
11738
11769
|
filename: "apps/web/app/page.tsx",
|
|
11739
11770
|
template: `'use client';
|
|
11740
11771
|
|
|
@@ -11953,17 +11984,20 @@ async function updateScripts(destDir, scripts, templateData) {
|
|
|
11953
11984
|
);
|
|
11954
11985
|
}
|
|
11955
11986
|
}
|
|
11956
|
-
async function renderTemplatesToDisk(basePackages, destDir, templateData) {
|
|
11987
|
+
async function renderTemplatesToDisk(basePackages, destDir, templateData, selection) {
|
|
11957
11988
|
await promises.mkdir(destDir, { recursive: true });
|
|
11958
11989
|
await basePackages.reduce(async (prev, pkg) => {
|
|
11959
11990
|
await prev;
|
|
11960
|
-
|
|
11991
|
+
const applicable = pkg.templates.filter(
|
|
11992
|
+
(template) => template.when?.(selection) ?? true
|
|
11993
|
+
);
|
|
11994
|
+
await applicable.reduce(async (prev2, template) => {
|
|
11995
|
+
await prev2;
|
|
11961
11996
|
const destPath = path.join(destDir, template.filename);
|
|
11962
|
-
|
|
11963
|
-
await promises.mkdir(destDirPath, { recursive: true });
|
|
11997
|
+
await promises.mkdir(path.dirname(destPath), { recursive: true });
|
|
11964
11998
|
const output = await ejs.render(template.template, templateData);
|
|
11965
11999
|
await promises.writeFile(destPath, output, "utf8");
|
|
11966
|
-
}
|
|
12000
|
+
}, Promise.resolve());
|
|
11967
12001
|
if (pkg.staticFiles) {
|
|
11968
12002
|
await pkg.staticFiles.reduce(async (prev2, staticFile) => {
|
|
11969
12003
|
await prev2;
|
|
@@ -12027,6 +12061,12 @@ function validateDeploymentCombo(deployment, nestDiOnly2) {
|
|
|
12027
12061
|
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
12062
|
};
|
|
12029
12063
|
}
|
|
12064
|
+
if (deployment === "custom-server" && nestDiOnly2) {
|
|
12065
|
+
return {
|
|
12066
|
+
valid: false,
|
|
12067
|
+
error: "--deployment custom-server cannot be combined with --nest-di-only.\nDI-only keeps Next.js as the server and calls Nest in-process, so it overwrites the\nscripts that would run the custom server \u2014 apps/web/server.ts would be generated but\nnever invoked. Both already run Nest inside the Next.js process; pick one."
|
|
12068
|
+
};
|
|
12069
|
+
}
|
|
12030
12070
|
return { valid: true };
|
|
12031
12071
|
}
|
|
12032
12072
|
function validateProjectName(projectName) {
|
|
@@ -12070,7 +12110,7 @@ async function scaffold(modules, options) {
|
|
|
12070
12110
|
deployment: options.deployment,
|
|
12071
12111
|
authSecret: randomBytes(32).toString("base64url")
|
|
12072
12112
|
};
|
|
12073
|
-
await renderTemplatesToDisk(modules, options.name, templateData);
|
|
12113
|
+
await renderTemplatesToDisk(modules, options.name, templateData, options.selection);
|
|
12074
12114
|
const packages = modules.map((mod) => mod.packages).filter((ele) => ele !== void 0).flat();
|
|
12075
12115
|
if (packages.length > 0) {
|
|
12076
12116
|
await updatePackageJson(options.name, packages, templateData);
|
|
@@ -12169,10 +12209,12 @@ async function doInit(options) {
|
|
|
12169
12209
|
options: [
|
|
12170
12210
|
{ value: "none", label: "None", hint: "skip" },
|
|
12171
12211
|
{ value: "standalone", label: "Standalone + Dockerfile", hint: "Dockerfiles + docker-compose.yml" },
|
|
12172
|
-
|
|
12173
|
-
//
|
|
12174
|
-
|
|
12175
|
-
|
|
12212
|
+
// DI-only already runs Nest inside the Next process, and SPA's static
|
|
12213
|
+
// export can't hold the route handlers DI-only depends on
|
|
12214
|
+
...results.nestDiOnly ? [] : [
|
|
12215
|
+
{ value: "custom-server", label: "Custom Server", hint: "single process, single port" },
|
|
12216
|
+
{ value: "spa", label: "SPA Mode", hint: "static export served by NestJS" }
|
|
12217
|
+
]
|
|
12176
12218
|
],
|
|
12177
12219
|
initialValue: "none"
|
|
12178
12220
|
})
|
|
@@ -12229,7 +12271,13 @@ async function doInit(options) {
|
|
|
12229
12271
|
taskBuilder.add({
|
|
12230
12272
|
title: "Scaffolding project",
|
|
12231
12273
|
task: async () => {
|
|
12232
|
-
await scaffold(allModules, {
|
|
12274
|
+
await scaffold(allModules, {
|
|
12275
|
+
name,
|
|
12276
|
+
testing,
|
|
12277
|
+
database,
|
|
12278
|
+
deployment,
|
|
12279
|
+
selection: { deployment, nestDiOnly: nestDiOnly2, todoExample, shadcn: useShadcn, database }
|
|
12280
|
+
});
|
|
12233
12281
|
return "Scaffolded.";
|
|
12234
12282
|
}
|
|
12235
12283
|
});
|