Skip to content

Commit

Permalink
fix(cli): add disabledComponentsScan on server to resolve test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Feb 15, 2023
1 parent 5000344 commit 9228948
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 175 deletions.
2 changes: 1 addition & 1 deletion packages/cli-core/src/services/CliService.ts
Expand Up @@ -16,7 +16,7 @@ import {ProjectPackageJson} from "./ProjectPackageJson";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import inquirer_autocomplete_prompt from "inquirer-autocomplete-prompt";
import {mapCommanderOptions} from "@tsed/cli-core";
import {mapCommanderOptions} from "../utils/mapCommanderOptions";

Inquirer.registerPrompt("autocomplete", inquirer_autocomplete_prompt);

Expand Down
Expand Up @@ -75,7 +75,7 @@ import {InteractionsController} from \\"./controllers/oidc/InteractionsControlle
acceptMimes: [\\"application/json\\"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
componentsScan: false,
disableComponentsScan: true
mount: {
\\"/rest\\": [
...Object.values(rest)
Expand Down Expand Up @@ -186,7 +186,7 @@ import {InteractionsController} from \\"./controllers/oidc/InteractionsControlle
acceptMimes: [\\"application/json\\"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
componentsScan: false,
disableComponentsScan: true
mount: {
\\"/rest\\": [
...Object.values(rest)
Expand Down
Expand Up @@ -17,7 +17,7 @@ import * as rest from \\"./controllers/rest/index\\";
acceptMimes: [\\"application/json\\"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
componentsScan: false,
disableComponentsScan: true
mount: {
\\"/rest\\": [
...Object.values(rest)
Expand Down
Expand Up @@ -14,7 +14,7 @@ import * as rest from \\"./controllers/rest/index\\";
acceptMimes: [\\"application/json\\"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
componentsScan: false,
disableComponentsScan: true
mount: {
\\"/rest\\": [
...Object.values(rest)
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/generate/server.hbs
Expand Up @@ -11,7 +11,7 @@ import {PlatformApplication} from "@tsed/common";
acceptMimes: ["application/json"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
componentsScan: false,
disableComponentsScan: true
mount: {
"{{route}}": [
...Object.values(rest)
Expand Down
@@ -0,0 +1,261 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Init cmd Express.js should generate a project with Convention ANGULAR 1`] = `
"import {join} from \\"path\\";
import {Configuration, Inject} from \\"@tsed/di\\";
import {PlatformApplication} from \\"@tsed/common\\";
import \\"@tsed/platform-express\\"; // /!\\\\ keep this import
import \\"@tsed/ajv\\";
import \\"@tsed/swagger\\";
import {config} from \\"./config/index\\";
import * as rest from \\"./controllers/rest/index\\";
import * as pages from \\"./controllers/pages/index\\";
@Configuration({
...config,
acceptMimes: [\\"application/json\\"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
disableComponentsScan: true
mount: {
\\"/rest\\": [
...Object.values(rest)
],
\\"/\\": [
...Object.values(pages)
]
},
swagger: [
{
path: \\"/doc\\",
specVersion: \\"3.0.1\\"
}
],
middlewares: [
\\"cors\\",
\\"cookie-parser\\",
\\"compression\\",
\\"method-override\\",
\\"json-parser\\",
{ use: \\"urlencoded-parser\\", options: { extended: true }}
],
views: {
root: join(process.cwd(), \\"../views\\"),
extensions: {
ejs: \\"ejs\\"
}
},
exclude: [
\\"**/*.spec.ts\\"
]
})
export class Server {
@Inject()
protected app: PlatformApplication;
@Configuration()
protected settings: Configuration;
}
"
`;

exports[`Init cmd Express.js should generate a project with NPM 1`] = `
"import {join} from \\"path\\";
import {Configuration, Inject} from \\"@tsed/di\\";
import {PlatformApplication} from \\"@tsed/common\\";
import \\"@tsed/platform-express\\"; // /!\\\\ keep this import
import \\"@tsed/ajv\\";
import {config} from \\"./config/index\\";
import * as rest from \\"./controllers/rest/index\\";
@Configuration({
...config,
acceptMimes: [\\"application/json\\"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
disableComponentsScan: true
mount: {
\\"/rest\\": [
...Object.values(rest)
]
},
middlewares: [
\\"cors\\",
\\"cookie-parser\\",
\\"compression\\",
\\"method-override\\",
\\"json-parser\\",
{ use: \\"urlencoded-parser\\", options: { extended: true }}
],
views: {
root: join(process.cwd(), \\"../views\\"),
extensions: {
ejs: \\"ejs\\"
}
},
exclude: [
\\"**/*.spec.ts\\"
]
})
export class Server {
@Inject()
protected app: PlatformApplication;
@Configuration()
protected settings: Configuration;
}
"
`;

exports[`Init cmd Express.js should generate a project with swagger 1`] = `
"import {join} from \\"path\\";
import {Configuration, Inject} from \\"@tsed/di\\";
import {PlatformApplication} from \\"@tsed/common\\";
import \\"@tsed/platform-express\\"; // /!\\\\ keep this import
import \\"@tsed/ajv\\";
import \\"@tsed/swagger\\";
import {config} from \\"./config/index\\";
import * as rest from \\"./controllers/rest/index\\";
import * as pages from \\"./controllers/pages/index\\";
@Configuration({
...config,
acceptMimes: [\\"application/json\\"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
disableComponentsScan: true
mount: {
\\"/rest\\": [
...Object.values(rest)
],
\\"/\\": [
...Object.values(pages)
]
},
swagger: [
{
path: \\"/doc\\",
specVersion: \\"3.0.1\\"
}
],
middlewares: [
\\"cors\\",
\\"cookie-parser\\",
\\"compression\\",
\\"method-override\\",
\\"json-parser\\",
{ use: \\"urlencoded-parser\\", options: { extended: true }}
],
views: {
root: join(process.cwd(), \\"../views\\"),
extensions: {
ejs: \\"ejs\\"
}
},
exclude: [
\\"**/*.spec.ts\\"
]
})
export class Server {
@Inject()
protected app: PlatformApplication;
@Configuration()
protected settings: Configuration;
}
"
`;

exports[`Init cmd Express.js should generate a project with the right options 1`] = `
"import {join} from \\"path\\";
import {Configuration, Inject} from \\"@tsed/di\\";
import {PlatformApplication} from \\"@tsed/common\\";
import \\"@tsed/platform-express\\"; // /!\\\\ keep this import
import \\"@tsed/ajv\\";
import {config} from \\"./config/index\\";
import * as rest from \\"./controllers/rest/index\\";
@Configuration({
...config,
acceptMimes: [\\"application/json\\"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
disableComponentsScan: true
mount: {
\\"/rest\\": [
...Object.values(rest)
]
},
middlewares: [
\\"cors\\",
\\"cookie-parser\\",
\\"compression\\",
\\"method-override\\",
\\"json-parser\\",
{ use: \\"urlencoded-parser\\", options: { extended: true }}
],
views: {
root: join(process.cwd(), \\"../views\\"),
extensions: {
ejs: \\"ejs\\"
}
},
exclude: [
\\"**/*.spec.ts\\"
]
})
export class Server {
@Inject()
protected app: PlatformApplication;
@Configuration()
protected settings: Configuration;
}
"
`;

exports[`Init cmd Koa.js should generate a project with the right options 1`] = `
"import {join} from \\"path\\";
import {Configuration, Inject} from \\"@tsed/di\\";
import {PlatformApplication} from \\"@tsed/common\\";
import \\"@tsed/platform-koa\\"; // /!\\\\ keep this import
import \\"@tsed/ajv\\";
import {config} from \\"./config/index\\";
import * as rest from \\"./controllers/rest/index\\";
@Configuration({
...config,
acceptMimes: [\\"application/json\\"],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
disableComponentsScan: true
mount: {
\\"/rest\\": [
...Object.values(rest)
]
},
middlewares: [
\\"@koa/cors\\",
\\"koa-compress\\",
\\"koa-override\\",
\\"koa-bodyparser\\"
],
views: {
root: join(process.cwd(), \\"../views\\"),
extensions: {
ejs: \\"ejs\\"
}
},
exclude: [
\\"**/*.spec.ts\\"
]
})
export class Server {
@Inject()
protected app: PlatformApplication;
@Configuration()
protected settings: Configuration;
}
"
`;

This file was deleted.

0 comments on commit 9228948

Please sign in to comment.