diff --git a/packages/create-app/files/package.json b/packages/create-app/files/package.json index 99a47931e..8951cd557 100644 --- a/packages/create-app/files/package.json +++ b/packages/create-app/files/package.json @@ -40,11 +40,11 @@ "devDependencies": { "@deepkit/type-compiler": "^1.0.1-alpha.108", "faker": "^5.5.3", - "typescript": "^4.8.2", - "jest": "^28.1.3", - "ts-jest": "^28.0.7", - "@types/jest": "^28.1.6", - "ts-node": "^10.9.1" + "typescript": "^5.3.3", + "jest": "^29.5.0", + "ts-jest": "^29.1.1", + "@types/jest": "^29.5.11", + "ts-node": "^10.9.2" }, "jest": { "transform": { diff --git a/packages/create-app/files/src/controller/hello-world.cli.ts b/packages/create-app/files/src/controller/hello-world.cli.ts index 752b6d26e..4d4ae3ade 100644 --- a/packages/create-app/files/src/controller/hello-world.cli.ts +++ b/packages/create-app/files/src/controller/hello-world.cli.ts @@ -1,5 +1,5 @@ import { MaxLength } from '@deepkit/type'; -import { cli, arg } from '@deepkit/app'; +import { cli } from '@deepkit/app'; import { Logger } from '@deepkit/logger'; import { Service } from '../app/service'; @@ -8,7 +8,7 @@ export class HelloWorldControllerCli { constructor(private logger: Logger, private service: Service) { } - async execute(@arg name: string & MaxLength<6> = 'World') { + async execute(name: string & MaxLength<6> = 'World') { this.service.doIt(); this.logger.log(`Hello ${name}!`); } diff --git a/packages/create-app/files/src/controller/hello-world.http.ts b/packages/create-app/files/src/controller/hello-world.http.ts index 00354f6ad..cc0c7e639 100644 --- a/packages/create-app/files/src/controller/hello-world.http.ts +++ b/packages/create-app/files/src/controller/hello-world.http.ts @@ -6,6 +6,11 @@ export class HelloWorldControllerHttp { constructor(private service: Service) { } + @http.GET('/') + async index() { + return `Hello World`; + } + @http.GET('/hello/:name') async hello(name: string & MaxLength<6> = 'World') { this.service.doIt(); diff --git a/packages/create-app/src/controller/create.ts b/packages/create-app/src/controller/create.ts index 46cb0128a..ac9308505 100644 --- a/packages/create-app/src/controller/create.ts +++ b/packages/create-app/src/controller/create.ts @@ -1,7 +1,8 @@ import { cli } from '@deepkit/app'; import { Logger } from '@deepkit/logger'; import { existsSync, copySync } from 'fs-extra'; -import { join } from 'path'; +import { basename, join } from 'path'; +import { readFileSync, writeFileSync } from 'fs'; import { findParentPath } from '@deepkit/app'; import { spawn } from 'child_process'; @@ -42,6 +43,11 @@ export class CreateController { } }); + const packageJson = join(localPath, 'package.json'); + const packageJsonContent = JSON.parse(readFileSync(packageJson, 'utf8')); + packageJsonContent.name = basename(path); + writeFileSync(packageJson, JSON.stringify(packageJsonContent, undefined, 2), 'utf8'); + this.logger.log(`Install packages ...`); await exec('npm install', localPath);