Skip to content

Commit

Permalink
fix(cli): fix template generation issue
Browse files Browse the repository at this point in the history
Closes: #365
  • Loading branch information
Romakita committed Mar 2, 2024
1 parent 781e93a commit 3c1c1b2
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ import { {{symbolName}} } from "./{{symbolPathBasename}}";
import { Server } from "{{relativeSrcPath}}/Server";

describe("{{symbolName}}", () => {
let request: SuperTest.Agent;

beforeEach(PlatformTest.bootstrap(Server, {
mount: {
"/": [{{symbolName}}]
}
}));
beforeEach(() => {
request = SuperTest(PlatformTest.callback());
});

afterEach(PlatformTest.reset);

it("should call GET {{route}}", async () => {
const request = SuperTest(PlatformTest.callback());
const response = await request.get("{{route}}").expect(200);

expect(response.text).toEqual("hello");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ import SuperTest from "supertest";
import { {{symbolName}} } from "./{{symbolPathBasename}}";

describe("{{symbolName}}", () => {
let request: SuperTest.SuperTest<SuperTest.Test>;

beforeEach(PlatformTest.bootstrap({{symbolName}}));
beforeEach(() => {
request = SuperTest(PlatformTest.callback());
});

afterEach(PlatformTest.reset);

it("should call GET {{route}}", async () => {
const request = SuperTest(PlatformTest.callback());
const response = await request.get("{{route}}").expect(404);

expect(response.body).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@ import { {{symbolName}} } from "./{{symbolPathBasename}}";
import { Server } from "{{relativeSrcPath}}/Server";

describe("{{symbolName}}", () => {
let request: SuperTest.Agent;

beforeEach(PlatformTest.bootstrap(Server, {
mount: {
"/": {{symbolName}}
}
}));
beforeEach(() => {
request = SuperTest(PlatformTest.callback());
});

afterEach(PlatformTest.reset);

it("should call GET {{route}}", async () => {
const request = SuperTest(PlatformTest.callback());
const response = await request.get("{{route}}").expect(200);

expect(response.text).to.eq("hello");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ import {expect} from "chai";
import { {{symbolName}} } from "./{{symbolPathBasename}}";

describe("{{symbolName}}", () => {
let request: SuperTest.SuperTest<SuperTest.Test>;

beforeEach(PlatformTest.bootstrap({{symbolName}}));
beforeEach(() => {
request = SuperTest(PlatformTest.callback());
});

afterEach(PlatformTest.reset);

it("should call GET {{route}}", async () => {
const request = SuperTest(PlatformTest.callback());
const response = await request.get("{{route}}").expect(404);

expect(response.body).to.deep.equal({
Expand Down
1 change: 1 addition & 0 deletions packages/cli-plugin-typeorm/templates/datasource.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const {{symbolName}} = new DataSource({
{{/case}}
{{/switch}}
});
export type {{tokenName}} = DataSource;

registerProvider<DataSource>({
provide: {{tokenName}},
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module.exports = {

coverageThreshold: {
global: {
statements: 93.01,
statements: 92.99,
branches: 80.73,
functions: 83.47,
lines: 93.01
lines: 92.99
}
}
};
1 change: 1 addition & 0 deletions packages/cli/src/runtimes/supports/BabelRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class BabelRuntime extends NodeRuntime {
"@babel/plugin-proposal-decorators": "latest",
"@babel/preset-env": "latest",
"@babel/preset-typescript": "latest",
"@babel/plugin-proposal-object-rest-spread": "latest",
"babel-plugin-transform-typescript-metadata": "latest",
"babel-watch": "latest"
};
Expand Down
10 changes: 1 addition & 9 deletions packages/cli/src/runtimes/supports/WebpackRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@ export class WebpackRuntime extends BabelRuntime {

devDependencies() {
return {
"@babel/cli": "latest",
"@babel/core": "latest",
"@babel/node": "latest",
"@babel/plugin-proposal-class-properties": "latest",
"@babel/plugin-proposal-decorators": "latest",
"@babel/preset-env": "latest",
"@babel/preset-typescript": "latest",
"babel-plugin-transform-typescript-metadata": "latest",
"babel-watch": "latest",
...super.devDependencies(),
"babel-loader": "latest",
webpack: "latest",
"webpack-cli": "latest"
Expand Down
1 change: 1 addition & 0 deletions packages/cli/templates/init/src/config/envs/index.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ process.env.NODE_ENV = process.env.NODE_ENV || "development";

export const config = dotenv.config();
export const isProduction = process.env.NODE_ENV === "production";
export const envs = process.env

0 comments on commit 3c1c1b2

Please sign in to comment.