@newt-app/templates 0.6.0 → 0.8.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/dist/index.d.ts CHANGED
@@ -42,9 +42,11 @@ declare const templates: {
42
42
  typescriptConfig: Module;
43
43
  testingJest: Module;
44
44
  testingVitest: Module;
45
+ deploymentStandalone: Module;
45
46
  deploymentCustomServer: Module;
46
47
  deploymentSpa: Module;
47
48
  deploymentVercel: Module;
49
+ nestDiOnly: Module;
48
50
  };
49
51
 
50
52
  export { type File, type Module, type Package, type Script, type Template, type TemplateData, getStaticFilePath, staticDir, staticDirPath, templates };
package/dist/index.js CHANGED
@@ -183,6 +183,22 @@ BETTER_AUTH_URL=http://localhost:3000
183
183
  BETTER_AUTH_SECRET=your-secret-here`
184
184
  };
185
185
 
186
+ // src/root/templates/agents-md.ts
187
+ var agents_md_default = {
188
+ filename: "AGENTS.md",
189
+ template: `<!-- BEGIN:nextjs-agent-rules -->
190
+ # This is NOT the Next.js you know
191
+
192
+ This version has breaking changes \u2014 APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in \`node_modules/next/dist/docs/\` before writing any code. Heed deprecation notices.
193
+ <!-- END:nextjs-agent-rules -->`
194
+ };
195
+
196
+ // src/root/templates/claude-md.ts
197
+ var claude_md_default = {
198
+ filename: "CLAUDE.md",
199
+ template: `@AGENTS.md`
200
+ };
201
+
186
202
  // src/root/index.ts
187
203
  var root = {
188
204
  templates: [
@@ -194,7 +210,9 @@ var root = {
194
210
  turbo_json_default,
195
211
  pnpm_workspace_default,
196
212
  readme_default,
197
- env_example_default
213
+ env_example_default,
214
+ agents_md_default,
215
+ claude_md_default
198
216
  ]
199
217
  };
200
218
  var root_default = root;
@@ -342,7 +360,6 @@ dotenv.config({ path: resolve(process.cwd(), '.env') });
342
360
 
343
361
  /** @type {import('next').NextConfig} */
344
362
  const nextConfig = {
345
- output: "standalone",
346
363
  async rewrites() {
347
364
  return [
348
365
  {
@@ -1229,20 +1246,24 @@ var package_json_default4 = {
1229
1246
  "version": "0.0.0",
1230
1247
  "private": true,
1231
1248
  "exports": {
1232
- ".": "./src/index.ts"
1249
+ ".": {
1250
+ "default": "./dist/index.js",
1251
+ "types": "./dist/index.d.ts"
1252
+ }
1233
1253
  },
1234
1254
  "scripts": {
1255
+ "build": "tsc",
1235
1256
  "migrate": "dotenv -e .env -- auth migrate --config src/index.ts",
1236
1257
  "generate": "dotenv -e .env -- auth generate --config src/index.ts"
1237
1258
  },
1238
1259
  "dependencies": {
1260
+ "auth": "^1.5.5",
1239
1261
  "better-auth": "^1.2.8",
1240
1262
  "pg": "^8.14.1"
1241
1263
  },
1242
1264
  "devDependencies": {
1243
1265
  "@<%= projectName %>/typescript-config": "workspace:*",
1244
1266
  "@types/pg": "^8.11.13",
1245
- "auth": "^1.5.5",
1246
1267
  "dotenv-cli": "^11.0.0",
1247
1268
  "typescript": "6.0.2"
1248
1269
  }
@@ -1270,10 +1291,18 @@ export type Auth = typeof auth;`
1270
1291
  var tsconfig_default3 = {
1271
1292
  filename: "packages/auth/tsconfig.json",
1272
1293
  template: `{
1273
- "extends": "@<%= projectName %>/typescript-config/base.json",
1274
1294
  "compilerOptions": {
1295
+ "declaration": true,
1296
+ "declarationMap": true,
1297
+ "esModuleInterop": true,
1298
+ "lib": ["es2022"],
1299
+ "module": "NodeNext",
1300
+ "moduleResolution": "NodeNext",
1275
1301
  "outDir": "dist",
1276
- "strictNullChecks": true
1302
+ "rootDir": "src",
1303
+ "skipLibCheck": true,
1304
+ "strict": true,
1305
+ "target": "ES2022"
1277
1306
  },
1278
1307
  "include": ["src"],
1279
1308
  "exclude": ["node_modules", "dist"]
@@ -8458,6 +8487,182 @@ var testingVitest = {
8458
8487
  };
8459
8488
  var testing_vitest_default = testingVitest;
8460
8489
 
8490
+ // src/deployment-standalone/templates/dockerfile.ts
8491
+ var dockerfile_default = {
8492
+ filename: "Dockerfile",
8493
+ template: `FROM node:22-alpine AS base
8494
+ ENV PNPM_HOME="/pnpm"
8495
+ ENV PATH="$PNPM_HOME:$PATH"
8496
+ RUN corepack enable
8497
+
8498
+ FROM base AS build
8499
+ WORKDIR /app
8500
+ COPY . .
8501
+ RUN pnpm install --frozen-lockfile
8502
+ ARG API_HOST=localhost
8503
+ ENV API_HOST=$API_HOST
8504
+ RUN pnpm build --filter=web --filter=api --filter=@<%= projectName %>/auth
8505
+ RUN pnpm deploy --filter=api --prod /deploy/api
8506
+ RUN pnpm deploy --filter=@<%= projectName %>/auth --prod /deploy/auth
8507
+
8508
+ # --- web ---
8509
+ FROM base AS web
8510
+ WORKDIR /app
8511
+ ENV NODE_ENV=production
8512
+ COPY --from=build /app/apps/web/.next/standalone ./
8513
+ COPY --from=build /app/apps/web/.next/static ./apps/web/.next/static
8514
+ COPY --from=build /app/apps/web/public ./apps/web/public
8515
+ EXPOSE 3000
8516
+ CMD ["node", "apps/web/server.js"]
8517
+
8518
+ # --- api ---
8519
+ FROM base AS api
8520
+ ENV NODE_ENV=production
8521
+ COPY --from=build /deploy/api /app
8522
+ WORKDIR /app
8523
+ EXPOSE 3001
8524
+ CMD ["node", "dist/main"]
8525
+
8526
+ # --- migrate ---
8527
+ FROM base AS migrate
8528
+ COPY --from=build /deploy/auth /app
8529
+ WORKDIR /app
8530
+ CMD ["/app/node_modules/.bin/auth", "migrate", "--config", "src/index.ts", "-y"]`
8531
+ };
8532
+
8533
+ // src/deployment-standalone/templates/docker-compose.ts
8534
+ var docker_compose_default = {
8535
+ filename: "docker-compose.yml",
8536
+ template: `x-app-env: &app-env
8537
+ BETTER_AUTH_SECRET: \${BETTER_AUTH_SECRET}
8538
+ DATABASE_URL: postgresql://postgres:\${POSTGRES_PASSWORD:-postgres}@db:5432/postgres
8539
+
8540
+ services:
8541
+ web:
8542
+ build:
8543
+ context: .
8544
+ target: web
8545
+ args:
8546
+ - API_HOST=api
8547
+ ports:
8548
+ - "3000:3000"
8549
+ environment:
8550
+ <<: *app-env
8551
+ depends_on:
8552
+ - api
8553
+
8554
+ migrate:
8555
+ build:
8556
+ context: .
8557
+ target: migrate
8558
+ command: ["/app/node_modules/.bin/auth", "migrate", "--config", "src/index.ts", "-y"]
8559
+ environment:
8560
+ <<: *app-env
8561
+ depends_on:
8562
+ db:
8563
+ condition: service_healthy
8564
+ restart: "no"
8565
+
8566
+ api:
8567
+ build:
8568
+ context: .
8569
+ target: api
8570
+ ports:
8571
+ - "3001:3001"
8572
+ environment:
8573
+ <<: *app-env
8574
+ depends_on:
8575
+ db:
8576
+ condition: service_healthy
8577
+ migrate:
8578
+ condition: service_completed_successfully
8579
+
8580
+ db:
8581
+ image: postgres:17-alpine
8582
+ ports:
8583
+ - "5432:5432"
8584
+ environment:
8585
+ - POSTGRES_PASSWORD=\${POSTGRES_PASSWORD:-postgres}
8586
+ volumes:
8587
+ - db_data:/var/lib/postgresql/data
8588
+ healthcheck:
8589
+ test: ["CMD-SHELL", "pg_isready -U postgres"]
8590
+ interval: 5s
8591
+ timeout: 5s
8592
+ retries: 5
8593
+
8594
+ volumes:
8595
+ db_data:`
8596
+ };
8597
+
8598
+ // src/deployment-standalone/templates/next-config.ts
8599
+ var next_config_default2 = {
8600
+ filename: "apps/web/next.config.js",
8601
+ template: `import dotenv from 'dotenv';
8602
+ import { resolve } from 'path';
8603
+
8604
+ // Load root .env first, then local .env (local takes precedence)
8605
+ dotenv.config({ path: resolve(process.cwd(), '../../.env') });
8606
+ dotenv.config({ path: resolve(process.cwd(), '.env') });
8607
+
8608
+ /** @type {import('next').NextConfig} */
8609
+ const nextConfig = {
8610
+ output: "standalone",
8611
+ async rewrites() {
8612
+ return [
8613
+ {
8614
+ source: '/api/:path*',
8615
+ destination: \`http://\${process.env.API_HOST ?? 'localhost'}:3001/api/:path*\`,
8616
+ },
8617
+ ];
8618
+ },
8619
+ };
8620
+
8621
+ export default nextConfig;`
8622
+ };
8623
+
8624
+ // src/deployment-standalone/templates/turbo-json.ts
8625
+ var turbo_json_default2 = {
8626
+ filename: "turbo.json",
8627
+ template: `{
8628
+ "$schema": "https://turborepo.dev/schema.json",
8629
+ "ui": "tui",
8630
+ "tasks": {
8631
+ "build": {
8632
+ "dependsOn": ["^build"],
8633
+ "inputs": ["$TURBO_DEFAULT$", ".env*"],
8634
+ "env": ["API_HOST"],
8635
+ "outputs": [".next/**", "!.next/cache/**"]
8636
+ },
8637
+ "lint": {
8638
+ "dependsOn": ["^lint"],
8639
+ "env": ["NODE_ENV"]
8640
+ },
8641
+ "test": {
8642
+ "dependsOn": ["^build"],
8643
+ "outputs": ["coverage/**"]
8644
+ },
8645
+ "dev": {
8646
+ "cache": false,
8647
+ "persistent": true
8648
+ },
8649
+ "migrate": {
8650
+ "cache": false,
8651
+ "interactive": true
8652
+ },
8653
+ "generate": {
8654
+ "cache": false
8655
+ }
8656
+ }
8657
+ }`
8658
+ };
8659
+
8660
+ // src/deployment-standalone/index.ts
8661
+ var deploymentStandalone = {
8662
+ templates: [dockerfile_default, docker_compose_default, next_config_default2, turbo_json_default2]
8663
+ };
8664
+ var deployment_standalone_default = deploymentStandalone;
8665
+
8461
8666
  // src/single-process-custom-server/templates/api-package-json.ts
8462
8667
  var api_package_json_default = {
8463
8668
  filename: "apps/api/package.json",
@@ -8944,6 +9149,283 @@ var singleProcessPages = {
8944
9149
  };
8945
9150
  var single_process_pages_default = singleProcessPages;
8946
9151
 
9152
+ // src/nest-di-only/templates/api-package-json.ts
9153
+ var api_package_json_default4 = {
9154
+ filename: "apps/api/package.json",
9155
+ template: `{
9156
+ "name": "@<%= projectName %>/api",
9157
+ "version": "0.0.1",
9158
+ "description": "",
9159
+ "author": "",
9160
+ "private": true,
9161
+ "license": "UNLICENSED",
9162
+ "exports": {
9163
+ ".": "./src/index.ts"
9164
+ },
9165
+ "scripts": {
9166
+ "build": "nest build",
9167
+ "start": "nest start",
9168
+ "dev": "nest start --watch",
9169
+ "start:dev": "nest start --watch",
9170
+ "start:debug": "nest start --debug --watch",
9171
+ "start:prod": "node dist/main",
9172
+ "lint": "eslint \\"{src,apps,libs,test}/**/*.ts\\" --fix"
9173
+ },
9174
+ "dependencies": {
9175
+ "@nestjs/common": "^11.0.1",
9176
+ "@nestjs/core": "^11.0.1",
9177
+ "@nestjs/platform-express": "^11.0.1",
9178
+ "@<%= projectName %>/auth": "workspace:*",
9179
+ "@thallesp/nestjs-better-auth": "^2.5.1",
9180
+ "dotenv": "^17.3.1",
9181
+ "reflect-metadata": "^0.2.2",
9182
+ "rxjs": "^7.8.1"
9183
+ },
9184
+ "devDependencies": {
9185
+ "@eslint/eslintrc": "^3.2.0",
9186
+ "@eslint/js": "^9.18.0",
9187
+ "@nestjs/cli": "^11.0.0",
9188
+ "@nestjs/schematics": "^11.0.0",
9189
+ "@nestjs/testing": "^11.0.1",
9190
+ "@types/express": "^5.0.0",
9191
+ "@types/node": "^22.10.7",
9192
+ "@types/supertest": "^6.0.2",
9193
+ "eslint": "^9.18.0",
9194
+ "eslint-config-prettier": "^10.0.1",
9195
+ "globals": "^16.0.0",
9196
+ "supertest": "^7.0.0",
9197
+ "ts-node": "^10.9.2",
9198
+ "tsconfig-paths": "^4.2.0",
9199
+ "typescript": "6.0.2",
9200
+ "typescript-eslint": "^8.20.0"
9201
+ }
9202
+ }`
9203
+ };
9204
+
9205
+ // src/nest-di-only/templates/api-tsconfig.ts
9206
+ var api_tsconfig_default = {
9207
+ filename: "apps/api/tsconfig.json",
9208
+ template: `{
9209
+ "compilerOptions": {
9210
+ "module": "nodenext",
9211
+ "moduleResolution": "nodenext",
9212
+ "resolvePackageJsonExports": true,
9213
+ "esModuleInterop": true,
9214
+ "isolatedModules": true,
9215
+ "declaration": true,
9216
+ "removeComments": true,
9217
+ "emitDecoratorMetadata": true,
9218
+ "experimentalDecorators": true,
9219
+ "allowSyntheticDefaultImports": true,
9220
+ "target": "ES2023",
9221
+ "sourceMap": true,
9222
+ "outDir": "./dist",
9223
+ "rootDir": "./src",
9224
+ "skipLibCheck": true,
9225
+ "strictNullChecks": true,
9226
+ "forceConsistentCasingInFileNames": true,
9227
+ "noImplicitAny": false,
9228
+ "strictBindCallApply": false,
9229
+ "noFallthroughCasesInSwitch": false,
9230
+ "types": [<% if (testing === 'jest') { %>"jest", <% } %>"node"]
9231
+ },
9232
+ "include": ["src/**/*"],
9233
+ "exclude": ["node_modules", "dist"]
9234
+ }`
9235
+ };
9236
+
9237
+ // src/nest-di-only/templates/api-index.ts
9238
+ var api_index_default = {
9239
+ filename: "apps/api/src/index.ts",
9240
+ template: `export { AppModule } from './app.module';
9241
+ export { TodosService } from './todos/todos.service';
9242
+ export type { Todo } from './todos/todos.service';`
9243
+ };
9244
+
9245
+ // src/nest-di-only/templates/web-nest-context.ts
9246
+ var web_nest_context_default = {
9247
+ filename: "apps/web/lib/nest.ts",
9248
+ template: `import 'reflect-metadata';
9249
+ import { NestFactory } from '@nestjs/core';
9250
+ import { AppModule } from '@<%= projectName %>/api';
9251
+ import type { INestApplicationContext } from '@nestjs/common';
9252
+
9253
+ let context: INestApplicationContext | null = null;
9254
+
9255
+ export async function getNestApp(): Promise<INestApplicationContext> {
9256
+ if (!context) {
9257
+ context = await NestFactory.createApplicationContext(AppModule, {
9258
+ logger: false,
9259
+ });
9260
+ }
9261
+ return context;
9262
+ }`
9263
+ };
9264
+
9265
+ // src/nest-di-only/templates/web-todos-route.ts
9266
+ var web_todos_route_default = {
9267
+ filename: "apps/web/app/api/todos/route.ts",
9268
+ template: `import { NextResponse } from 'next/server';
9269
+ import { getNestApp } from '@/lib/nest';
9270
+ import { TodosService } from '@<%= projectName %>/api';
9271
+
9272
+ export async function GET() {
9273
+ const app = await getNestApp();
9274
+ const todos = app.get(TodosService);
9275
+ return NextResponse.json(todos.findAll());
9276
+ }
9277
+
9278
+ export async function POST(req: Request) {
9279
+ const { title } = await req.json();
9280
+ const app = await getNestApp();
9281
+ const todos = app.get(TodosService);
9282
+ return NextResponse.json(todos.create(title), { status: 201 });
9283
+ }`
9284
+ };
9285
+
9286
+ // src/nest-di-only/templates/web-todos-id-route.ts
9287
+ var web_todos_id_route_default = {
9288
+ filename: "apps/web/app/api/todos/[id]/route.ts",
9289
+ template: `import { NextResponse } from 'next/server';
9290
+ import { getNestApp } from '@/lib/nest';
9291
+ import { TodosService } from '@<%= projectName %>/api';
9292
+
9293
+ export async function DELETE(_req: Request, { params }: { params: Promise<{ id: string }> }) {
9294
+ const { id } = await params;
9295
+ const app = await getNestApp();
9296
+ const todos = app.get(TodosService);
9297
+ todos.remove(Number(id));
9298
+ return new NextResponse(null, { status: 204 });
9299
+ }`
9300
+ };
9301
+
9302
+ // src/nest-di-only/templates/web-todos-toggle-route.ts
9303
+ var web_todos_toggle_route_default = {
9304
+ filename: "apps/web/app/api/todos/[id]/toggle/route.ts",
9305
+ template: `import { NextResponse } from 'next/server';
9306
+ import { getNestApp } from '@/lib/nest';
9307
+ import { TodosService } from '@<%= projectName %>/api';
9308
+
9309
+ export async function PATCH(_req: Request, { params }: { params: Promise<{ id: string }> }) {
9310
+ const { id } = await params;
9311
+ const app = await getNestApp();
9312
+ const todos = app.get(TodosService);
9313
+ return NextResponse.json(todos.toggle(Number(id)));
9314
+ }`
9315
+ };
9316
+
9317
+ // src/nest-di-only/templates/web-package-json.ts
9318
+ var web_package_json_default3 = {
9319
+ filename: "apps/web/package.json",
9320
+ template: `{
9321
+ "name": "web",
9322
+ "version": "0.1.0",
9323
+ "type": "module",
9324
+ "private": true,
9325
+ "scripts": {
9326
+ "dev": "next dev --port 3000",
9327
+ "build": "next build",
9328
+ "start": "next start",
9329
+ "lint": "eslint --max-warnings 0 && next typegen && tsc --noEmit",
9330
+ "db:migrate": "better-auth migrate"
9331
+ },
9332
+ "dependencies": {
9333
+ "@<%= projectName %>/api": "workspace:*",
9334
+ "@<%= projectName %>/auth": "workspace:*",
9335
+ "@<%= projectName %>/ui": "workspace:*",
9336
+ "@nestjs/common": "^11.0.1",
9337
+ "@nestjs/core": "^11.0.1",
9338
+ "reflect-metadata": "^0.2.2",
9339
+ "@tailwindcss/postcss": "^4.2.1",
9340
+ "dotenv": "^17.3.1",
9341
+ "@tanstack/react-form": "^1.28.5",
9342
+ "@tanstack/react-query": "^5.90.21",
9343
+ "better-auth": "^1.2.8",
9344
+ "next": "16.2.1",
9345
+ "react": "^19.2.4",
9346
+ "react-dom": "^19.2.4",
9347
+ "tailwindcss": "^4.2.1"
9348
+ },
9349
+ "devDependencies": {
9350
+ "@<%= projectName %>/eslint-config": "workspace:*",
9351
+ "@<%= projectName %>/typescript-config": "workspace:*",
9352
+ "@types/node": "^22.15.3",
9353
+ "@types/react": "19.2.14",
9354
+ "@types/react-dom": "19.2.3",
9355
+ "eslint": "^9.39.1",
9356
+ "typescript": "6.0.2"
9357
+ }
9358
+ }`
9359
+ };
9360
+
9361
+ // src/nest-di-only/templates/web-next-config.ts
9362
+ var web_next_config_default4 = {
9363
+ filename: "apps/web/next.config.js",
9364
+ template: `import dotenv from 'dotenv';
9365
+ import { resolve } from 'path';
9366
+
9367
+ dotenv.config({ path: resolve(process.cwd(), '../../.env') });
9368
+ dotenv.config({ path: resolve(process.cwd(), '.env') });
9369
+
9370
+ /** @type {import('next').NextConfig} */
9371
+ const nextConfig = {
9372
+ serverExternalPackages: [
9373
+ '@<%= projectName %>/api',
9374
+ '@nestjs/core',
9375
+ '@nestjs/common',
9376
+ 'reflect-metadata',
9377
+ ],
9378
+ };
9379
+
9380
+ export default nextConfig;`
9381
+ };
9382
+
9383
+ // src/nest-di-only/templates/web-tsconfig.ts
9384
+ var web_tsconfig_default = {
9385
+ filename: "apps/web/tsconfig.json",
9386
+ template: `{
9387
+ "extends": "@<%= projectName %>/typescript-config/nextjs.json",
9388
+ "compilerOptions": {
9389
+ "plugins": [
9390
+ {
9391
+ "name": "next"
9392
+ }
9393
+ ],
9394
+ "strictNullChecks": true,
9395
+ "experimentalDecorators": true,
9396
+ "emitDecoratorMetadata": true,
9397
+ "paths": {
9398
+ "@/*": ["./*"]
9399
+ }
9400
+ },
9401
+ "include": [
9402
+ "**/*.ts",
9403
+ "**/*.tsx",
9404
+ "next-env.d.ts",
9405
+ "next.config.js",
9406
+ ".next/types/**/*.ts"
9407
+ ],
9408
+ "exclude": ["node_modules"]
9409
+ }`
9410
+ };
9411
+
9412
+ // src/nest-di-only/index.ts
9413
+ var nestDiOnly = {
9414
+ templates: [
9415
+ api_package_json_default4,
9416
+ api_tsconfig_default,
9417
+ api_index_default,
9418
+ web_nest_context_default,
9419
+ web_todos_route_default,
9420
+ web_todos_id_route_default,
9421
+ web_todos_toggle_route_default,
9422
+ web_package_json_default3,
9423
+ web_next_config_default4,
9424
+ web_tsconfig_default
9425
+ ]
9426
+ };
9427
+ var nest_di_only_default = nestDiOnly;
9428
+
8947
9429
  // src/index.ts
8948
9430
  var staticDir = new URL("./static/", import.meta.url);
8949
9431
  var staticDirPath = fileURLToPath(staticDir);
@@ -8961,9 +9443,11 @@ var templates = {
8961
9443
  typescriptConfig: typescript_config_default,
8962
9444
  testingJest: testing_jest_default,
8963
9445
  testingVitest: testing_vitest_default,
9446
+ deploymentStandalone: deployment_standalone_default,
8964
9447
  deploymentCustomServer: single_process_custom_server_default,
8965
9448
  deploymentSpa: single_process_static_export_default,
8966
- deploymentVercel: single_process_pages_default
9449
+ deploymentVercel: single_process_pages_default,
9450
+ nestDiOnly: nest_di_only_default
8967
9451
  };
8968
9452
  export {
8969
9453
  getStaticFilePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newt-app/templates",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "private": false,
5
5
  "description": "Templates for newt-app",
6
6
  "type": "module",