Skip to content

Commit

Permalink
fix(create-app): update code to newest deepkit version
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed Jan 21, 2024
1 parent bc15c06 commit 7f85620
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/create-app/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/files/src/controller/hello-world.cli.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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}!`);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/create-app/files/src/controller/hello-world.http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 7 additions & 1 deletion packages/create-app/src/controller/create.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7f85620

Please sign in to comment.