11import path from 'path' ;
22import type { ProjectConfig , TemplateContext } from '../types/config.types.js' ;
33import { writeFile } from '../utils/file.utils.js' ;
4- import { resolveDependencies , generateScripts } from '../constants/dependencies.js' ;
4+ import {
5+ resolveDependencies ,
6+ generateScripts ,
7+ } from '../constants/dependencies.js' ;
58
69export async function generatePackageJson (
710 targetDir : string ,
@@ -46,7 +49,9 @@ export async function generateEnvExample(
4649 lines . push ( 'NODE_ENV=development' ) ;
4750 lines . push ( '' ) ;
4851 lines . push ( '# Database' ) ;
49- lines . push ( `MONGO_DATABASE_URL=mongodb://localhost:27017/${ config . projectName } ` ) ;
52+ lines . push (
53+ `MONGO_DATABASE_URL=mongodb://localhost:27017/${ config . projectName } ` ,
54+ ) ;
5055 lines . push ( '' ) ;
5156 lines . push ( '# Client' ) ;
5257 lines . push ( 'CLIENT_SIDE_URL=http://localhost:3000' ) ;
@@ -63,7 +68,9 @@ export async function generateEnvExample(
6368 lines . push ( '# Google OAuth' ) ;
6469 lines . push ( 'GOOGLE_CLIENT_ID=your-google-client-id' ) ;
6570 lines . push ( 'GOOGLE_CLIENT_SECRET=your-google-client-secret' ) ;
66- lines . push ( 'GOOGLE_REDIRECT_URI=http://localhost:3000/auth/google/callback' ) ;
71+ lines . push (
72+ 'GOOGLE_REDIRECT_URI=http://localhost:3000/auth/google/callback' ,
73+ ) ;
6774 lines . push ( '' ) ;
6875 }
6976
@@ -114,7 +121,9 @@ export async function generateEnvExample(
114121 lines . push ( 'AWS_S3_BUCKET=your-bucket-name' ) ;
115122
116123 if ( context . STORAGE_R2 ) {
117- lines . push ( 'AWS_ENDPOINT=https://your-account-id.r2.cloudflarestorage.com' ) ;
124+ lines . push (
125+ 'AWS_ENDPOINT=https://your-account-id.r2.cloudflarestorage.com' ,
126+ ) ;
118127 }
119128 } else if ( context . STORAGE_LOCAL ) {
120129 lines . push ( 'LOCAL_STORAGE_PATH=./uploads' ) ;
@@ -264,7 +273,9 @@ export async function generateReadme(
264273
265274 lines . push ( `# ${ config . projectName } ` ) ;
266275 lines . push ( '' ) ;
267- lines . push ( `Backend API generated with **create-tbk-app** using the **${ config . preset } ** preset.` ) ;
276+ lines . push (
277+ `Backend API generated with **create-tbk-app** using the **${ config . preset } ** preset.` ,
278+ ) ;
268279 lines . push ( '' ) ;
269280 lines . push ( '## Features' ) ;
270281 lines . push ( '' ) ;
@@ -278,7 +289,9 @@ export async function generateReadme(
278289
279290 if ( context . AUTH ) {
280291 if ( context . AUTH_SESSIONS ) {
281- features . push ( `- JWT Authentication with Session Management (${ context . SESSION_DRIVER } )` ) ;
292+ features . push (
293+ `- JWT Authentication with Session Management (${ context . SESSION_DRIVER } )` ,
294+ ) ;
282295 } else {
283296 features . push ( '- JWT Authentication' ) ;
284297 }
@@ -301,7 +314,9 @@ export async function generateReadme(
301314 }
302315
303316 if ( context . STORAGE ) {
304- features . push ( `- File storage (${ context . STORAGE_PROVIDER ?. toUpperCase ( ) } )` ) ;
317+ features . push (
318+ `- File storage (${ context . STORAGE_PROVIDER ?. toUpperCase ( ) } )` ,
319+ ) ;
305320 }
306321
307322 if ( context . EMAIL ) {
@@ -354,12 +369,16 @@ export async function generateReadme(
354369 lines . push ( '' ) ;
355370
356371 if ( context . STORAGE_S3 || context . STORAGE_R2 ) {
357- lines . push ( '> **Note:** Configure your AWS/R2 credentials for file storage' ) ;
372+ lines . push (
373+ '> **Note:** Configure your AWS/R2 credentials for file storage' ,
374+ ) ;
358375 lines . push ( '' ) ;
359376 }
360377
361378 if ( context . EMAIL ) {
362- lines . push ( `> **Note:** Configure your ${ context . EMAIL_PROVIDER } API key for email sending` ) ;
379+ lines . push (
380+ `> **Note:** Configure your ${ context . EMAIL_PROVIDER } API key for email sending` ,
381+ ) ;
363382 lines . push ( '' ) ;
364383 }
365384
@@ -373,14 +392,24 @@ export async function generateReadme(
373392 lines . push ( '## Available Commands' ) ;
374393 lines . push ( '' ) ;
375394 lines . push ( '```bash' ) ;
376- lines . push ( `${ config . packageManager } dev # Start dev server with hot reload` ) ;
395+ lines . push (
396+ `${ config . packageManager } dev # Start dev server with hot reload` ,
397+ ) ;
377398 lines . push ( `${ config . packageManager } build # Build for production` ) ;
378399 lines . push ( `${ config . packageManager } start:prod # Run production build` ) ;
379- lines . push ( `${ config . packageManager } typecheck # Type check without building` ) ;
400+ lines . push (
401+ `${ config . packageManager } typecheck # Type check without building` ,
402+ ) ;
380403 lines . push ( `${ config . packageManager } lint # Run ESLint` ) ;
381- lines . push ( `${ config . packageManager } lint:fix # Auto-fix linting issues` ) ;
382- lines . push ( `${ config . packageManager } openapi # Generate OpenAPI spec` ) ;
383- lines . push ( `${ config . packageManager } tbk # Run CLI tool (see below)` ) ;
404+ lines . push (
405+ `${ config . packageManager } lint:fix # Auto-fix linting issues` ,
406+ ) ;
407+ lines . push (
408+ `${ config . packageManager } tbk docs:openapi # Generate OpenAPI spec` ,
409+ ) ;
410+ lines . push (
411+ `${ config . packageManager } tbk docs:sdk # Generate TypeScript SDK` ,
412+ ) ;
384413 lines . push ( '```' ) ;
385414 lines . push ( '' ) ;
386415
@@ -389,14 +418,26 @@ export async function generateReadme(
389418 lines . push ( 'Generate new modules, plugins, and more:' ) ;
390419 lines . push ( '' ) ;
391420 lines . push ( '```bash' ) ;
392- lines . push ( `${ config . packageManager } tbk generate:module <name> # Generate CRUD module` ) ;
393- lines . push ( `${ config . packageManager } tbk generate:plugin <name> # Generate plugin` ) ;
394- lines . push ( `${ config . packageManager } tbk generate:middleware <name> # Generate middleware` ) ;
421+ lines . push (
422+ `${ config . packageManager } tbk generate:module <name> # Generate CRUD module` ,
423+ ) ;
424+ lines . push (
425+ `${ config . packageManager } tbk generate:plugin <name> # Generate plugin` ,
426+ ) ;
427+ lines . push (
428+ `${ config . packageManager } tbk generate:middleware <name> # Generate middleware` ,
429+ ) ;
395430
396431 if ( context . AUTH ) {
397- lines . push ( `${ config . packageManager } tbk make:factory <module>/<name> # Generate factory` ) ;
398- lines . push ( `${ config . packageManager } tbk make:seeder <module>/<name> # Generate seeder` ) ;
399- lines . push ( `${ config . packageManager } tbk seed # Run seeders` ) ;
432+ lines . push (
433+ `${ config . packageManager } tbk make:factory <module>/<name> # Generate factory` ,
434+ ) ;
435+ lines . push (
436+ `${ config . packageManager } tbk make:seeder <module>/<name> # Generate seeder` ,
437+ ) ;
438+ lines . push (
439+ `${ config . packageManager } tbk seed # Run seeders` ,
440+ ) ;
400441 }
401442
402443 lines . push ( '```' ) ;
@@ -461,7 +502,9 @@ export async function generateReadme(
461502
462503 lines . push ( '## Learn More' ) ;
463504 lines . push ( '' ) ;
464- lines . push ( '- [TypeScript Backend Toolkit Documentation](https://github.com/your-repo)' ) ;
505+ lines . push (
506+ '- [TypeScript Backend Toolkit Documentation](https://github.com/your-repo)' ,
507+ ) ;
465508 lines . push ( '- [Express.js Documentation](https://expressjs.com/)' ) ;
466509 lines . push ( '- [Mongoose Documentation](https://mongoosejs.com/)' ) ;
467510 lines . push ( '' ) ;
0 commit comments