Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing imports #366

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install --frozen-lockfile --network-timeout 500000
run: yarn install --immutable
- name: Run lint
run: yarn test:lint

Expand All @@ -47,11 +47,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install --frozen-lockfile --network-timeout 500000
run: yarn install --immutable
- name: Run build
run: yarn tsc --build
- name: Run test
Expand All @@ -67,7 +67,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
Expand All @@ -87,7 +87,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
Expand All @@ -113,19 +113,19 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@v2
with:
name: packages
- name: Install dependencies
run: yarn install --frozen-lockfile --network-timeout 500000
run: yarn install --immutable
- name: Publish pages
env:
CI: true
Expand Down
3 changes: 2 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nodeLinker: node-modules

compressionLevel: mixed
yarnPath: .yarn/releases/yarn-4.1.0.cjs
enableImmutableInstalls: false
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"homepage": "https://github.com/tsedio/tsed-cli",
"dependencies": {
"@samverschueren/stream-to-observable": "0.3.1",
"@tsed/components-scan": ">=7.14.2",
"@tsed/core": ">=7.14.2",
"@tsed/di": ">=7.14.2",
"@tsed/logger": ">=6.2.1",
Expand Down Expand Up @@ -82,7 +81,7 @@
"@swc/helpers": "^0.5.1",
"@swc/jest": "^0.2.26",
"@tsed/markdown-it-symbols": "3.20.4",
"@tsed/monorepo-utils": "2.0.2",
"@tsed/monorepo-utils": "2.1.1",
"@tsed/ts-doc": "^4.1.0",
"@types/jest": "28.1.7",
"@types/node": "18.7.8",
Expand All @@ -106,8 +105,8 @@
"lint-staged": "13.0.3",
"markdown-it": "13.0.1",
"prettier": "2.7.1",
"semantic-release": "19.0.3",
"semantic-release-slack-bot": "3.5.3",
"semantic-release": "23.0.2",
"semantic-release-slack-bot": "4.0.2",
"sinon": "14.0.0",
"sinon-chai": "3.7.0",
"ts-jest": "28.0.8",
Expand Down
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
4 changes: 2 additions & 2 deletions packages/cli-plugin-typeorm/src/hooks/TypeORMGenerateHook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {FeaturesMap, GenerateCmdContext, ProvidersInfoService} from "@tsed/cli";
import {CliDockerComposeYaml, Inject, OnExec, OnPrompt, ProjectPackageJson, SrcRendererService, Tasks} from "@tsed/cli-core";
import {Injectable} from "@tsed/di";
import {constantCase} from "change-case";
import {camelCase} from "change-case";
import {TEMPLATE_DIR} from "../utils/templateDir";

export interface TypeORMGenerateOptions extends GenerateCmdContext {
Expand Down Expand Up @@ -103,7 +103,7 @@ export class TypeORMGenerateHook {
name,
database,
symbolName,
tokenName: constantCase(symbolName)
instanceName: camelCase(symbolName)
},
{
templateDir: TEMPLATE_DIR,
Expand Down
12 changes: 7 additions & 5 deletions packages/cli-plugin-typeorm/templates/datasource.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import {registerProvider} from "@tsed/di";
import {DataSource} from "typeorm";
import {Logger} from "@tsed/logger";

export const {{tokenName}} = Symbol.for("{{symbolName}}");
export const {{symbolName}} = new DataSource({
export const {{symbolName}} = Symbol.for("{{symbolName}}");
export type {{symbolName}} = DataSource;
export const {{instanceName}} = new DataSource({
type: "{{database}}",
entities: [],
{{#switch database}}
Expand Down Expand Up @@ -60,16 +61,17 @@ export const {{symbolName}} = new DataSource({
{{/switch}}
});


registerProvider<DataSource>({
provide: {{tokenName}},
provide: {{symbolName}},
type: "typeorm:datasource",
deps: [Logger],
async useAsyncFactory(logger: Logger) {
await {{symbolName}}.initialize();
await {{instanceName}}.initialize();

logger.info("Connected with typeorm to database: {{name}}");

return {{symbolName}};
return {{instanceName}};
},
hooks: {
$onDestroy(dataSource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ exports[`Generate DataSource should generate the template with the right options
import {DataSource} from \\"typeorm\\";
import {Logger} from \\"@tsed/logger\\";

export const TEST_DATASOURCE = Symbol.for(\\"TestDatasource\\");
export const TestDatasource = new DataSource({
export const TestDatasource = Symbol.for(\\"TestDatasource\\");
export type TestDatasource = DataSource;
export const testDatasource = new DataSource({
type: \\"mysql\\",
entities: [],
host: \\"localhost\\",
Expand All @@ -16,16 +17,17 @@ export const TestDatasource = new DataSource({
database: \\"test\\"
});


registerProvider<DataSource>({
provide: TEST_DATASOURCE,
provide: TestDatasource,
type: \\"typeorm:datasource\\",
deps: [Logger],
async useAsyncFactory(logger: Logger) {
await TestDatasource.initialize();
await testDatasource.initialize();

logger.info(\\"Connected with typeorm to database: Test\\");

return TestDatasource;
return testDatasource;
},
hooks: {
$onDestroy(dataSource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ exports[`TypeORM: Init cmd should generate a project with the right options 3`]
import {DataSource} from \\"typeorm\\";
import {Logger} from \\"@tsed/logger\\";

export const MYSQL_DATASOURCE = Symbol.for(\\"MysqlDatasource\\");
export const MysqlDatasource = new DataSource({
export const MysqlDatasource = Symbol.for(\\"MysqlDatasource\\");
export type MysqlDatasource = DataSource;
export const mysqlDatasource = new DataSource({
type: \\"mysql\\",
entities: [],
host: \\"localhost\\",
Expand All @@ -67,16 +68,17 @@ export const MysqlDatasource = new DataSource({
database: \\"test\\"
});


registerProvider<DataSource>({
provide: MYSQL_DATASOURCE,
provide: MysqlDatasource,
type: \\"typeorm:datasource\\",
deps: [Logger],
async useAsyncFactory(logger: Logger) {
await MysqlDatasource.initialize();
await mysqlDatasource.initialize();

logger.info(\\"Connected with typeorm to database: Mysql\\");

return MysqlDatasource;
return mysqlDatasource;
},
hooks: {
$onDestroy(dataSource) {
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
Loading
Loading