@tsed/cli 6.6.3 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/commands/add/AddCmd.js +16 -16
- package/lib/esm/commands/generate/GenerateCmd.js +69 -222
- package/lib/esm/commands/generate/mappers/mapGenerateContext.js +29 -0
- package/lib/esm/commands/init/InitCmd.js +190 -171
- package/lib/esm/commands/init/config/FeaturesPrompt.js +101 -3
- package/lib/esm/commands/init/mappers/mapToContext.js +4 -3
- package/lib/esm/commands/run/RunCmd.js +22 -26
- package/lib/esm/commands/update/UpdateCmd.js +9 -13
- package/lib/esm/fn/exec.js +5 -0
- package/lib/esm/fn/render.js +5 -0
- package/lib/esm/fn/taskOutput.js +7 -0
- package/lib/esm/index.js +7 -4
- package/lib/esm/interfaces/AlterPackageJson.js +1 -0
- package/lib/esm/interfaces/AlterProjectFiles.js +1 -0
- package/lib/esm/interfaces/AlterRenderFiles.js +1 -0
- package/lib/esm/interfaces/CliCommandHooks.js +1 -0
- package/lib/esm/interfaces/GenerateCmdContext.js +1 -0
- package/lib/esm/interfaces/InitCmdOptions.js +1 -0
- package/lib/esm/interfaces/RenderDataContext.js +1 -0
- package/lib/esm/interfaces/RuntimeTypes.js +1 -0
- package/lib/esm/interfaces/index.js +9 -0
- package/lib/esm/pipes/OutputFilePathPipe.js +40 -18
- package/lib/esm/pipes/RoutePipe.js +4 -8
- package/lib/esm/pipes/{ClassNamePipe.js → SymbolNamePipe.js} +14 -11
- package/lib/esm/pipes/index.js +1 -1
- package/lib/esm/platforms/{InitPlatformsModule.js → PlatformsModule.js} +4 -10
- package/lib/esm/platforms/supports/InitExpressPlatform.js +27 -10
- package/lib/esm/platforms/supports/InitFastifyPlatform.js +27 -10
- package/lib/esm/platforms/supports/InitKoaPlatform.js +16 -10
- package/lib/esm/processors/__fixtures__/createFakeProject.js +35 -0
- package/lib/esm/processors/transformBinFile.js +47 -0
- package/lib/esm/processors/transformConfigFile.js +105 -0
- package/lib/esm/processors/transformIndexFile.js +23 -0
- package/lib/esm/processors/transformServerFile.js +60 -0
- package/lib/esm/runtimes/RuntimesModule.js +7 -17
- package/lib/esm/runtimes/supports/BabelRuntime.js +5 -11
- package/lib/esm/runtimes/supports/BunRuntime.js +4 -10
- package/lib/esm/runtimes/supports/NodeRuntime.js +1 -1
- package/lib/esm/runtimes/supports/WebpackRuntime.js +1 -1
- package/lib/esm/services/CliProjectService.js +96 -0
- package/lib/esm/services/CliRunScript.js +4 -8
- package/lib/esm/services/CliTemplatesService.js +68 -0
- package/lib/esm/services/ProjectClient.js +161 -0
- package/lib/esm/services/mappers/mapDefaultTemplateOptions.js +30 -0
- package/lib/esm/templates/asyncFactory.template.js +38 -0
- package/lib/esm/templates/barrels.template.js +22 -0
- package/lib/esm/templates/command.template.js +56 -0
- package/lib/esm/templates/config.template.js +27 -0
- package/lib/esm/templates/controller.template.js +45 -0
- package/lib/esm/templates/decorator.template.js +182 -0
- package/lib/esm/templates/docker-compose.template.js +25 -0
- package/lib/esm/templates/dockerfile.template.js +236 -0
- package/lib/esm/templates/exception-filter.template.js +19 -0
- package/lib/esm/templates/factory.template.js +37 -0
- package/lib/esm/templates/index.command.template.js +18 -0
- package/lib/esm/templates/index.config.utils.template.js +17 -0
- package/{templates/init/src/controllers/pages/IndexController.ts.hbs → lib/esm/templates/index.controller.template.js} +14 -3
- package/lib/esm/templates/index.js +32 -0
- package/lib/esm/templates/index.logger.template.js +38 -0
- package/{templates/init/src/index.ts.hbs → lib/esm/templates/index.template.js} +17 -5
- package/lib/esm/templates/interceptor.template.js +31 -0
- package/lib/esm/templates/interface.template.js +13 -0
- package/lib/esm/templates/middleware.template.js +34 -0
- package/lib/esm/templates/model.template.js +16 -0
- package/lib/esm/templates/module.template.js +16 -0
- package/lib/esm/templates/pipe.template.js +19 -0
- package/lib/esm/templates/pm2.template.js +111 -0
- package/lib/esm/templates/prisma.service.template.js +23 -0
- package/{templates/init/README.md.hbs → lib/esm/templates/readme.template.js} +28 -13
- package/lib/esm/templates/repository.template.js +16 -0
- package/lib/esm/templates/response-filter.template.js +19 -0
- package/lib/esm/templates/server.template.js +37 -0
- package/lib/esm/templates/service.template.js +16 -0
- package/lib/esm/templates/tsconfig.spec.template.js +34 -0
- package/lib/esm/templates/tsconfig.template.js +31 -0
- package/lib/esm/templates/value.template.js +13 -0
- package/lib/esm/utils/defineTemplate.js +13 -0
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/commands/add/AddCmd.d.ts +2 -2
- package/lib/types/commands/generate/GenerateCmd.d.ts +33 -87
- package/lib/types/commands/generate/mappers/mapGenerateContext.d.ts +2 -0
- package/lib/types/commands/init/InitCmd.d.ts +18 -20
- package/lib/types/commands/init/config/FeaturesPrompt.d.ts +11 -2
- package/lib/types/commands/init/mappers/mapToContext.d.ts +2 -2
- package/lib/types/commands/init/mappers/mapUniqFeatures.d.ts +1 -1
- package/lib/types/commands/init/prompts/getFeaturesPrompt.d.ts +1 -1
- package/lib/types/commands/update/UpdateCmd.d.ts +2 -2
- package/lib/types/fn/exec.d.ts +1 -0
- package/lib/types/fn/render.d.ts +2 -0
- package/lib/types/fn/taskOutput.d.ts +1 -0
- package/lib/types/index.d.ts +7 -4
- package/lib/types/interfaces/AlterGenerateTasks.d.ts +5 -0
- package/lib/types/interfaces/AlterInitSubTasks.d.ts +5 -0
- package/lib/types/interfaces/AlterPackageJson.d.ts +5 -0
- package/lib/types/interfaces/AlterProjectFiles.d.ts +5 -0
- package/lib/types/interfaces/AlterRenderFiles.d.ts +10 -0
- package/lib/types/interfaces/CliCommandHooks.d.ts +11 -0
- package/lib/types/interfaces/GenerateCmdContext.d.ts +19 -0
- package/lib/types/interfaces/InitCmdOptions.d.ts +8 -0
- package/lib/types/interfaces/PlatformType.d.ts +7 -0
- package/lib/types/interfaces/RenderDataContext.d.ts +61 -0
- package/lib/types/interfaces/RuntimeTypes.d.ts +8 -0
- package/lib/types/interfaces/index.d.ts +9 -0
- package/lib/types/pipes/OutputFilePathPipe.d.ts +7 -4
- package/lib/types/pipes/{ClassNamePipe.d.ts → SymbolNamePipe.d.ts} +3 -3
- package/lib/types/pipes/index.d.ts +1 -1
- package/lib/types/platforms/{InitPlatformsModule.d.ts → PlatformsModule.d.ts} +1 -1
- package/lib/types/platforms/supports/InitBasePlatform.d.ts +3 -0
- package/lib/types/platforms/supports/InitExpressPlatform.d.ts +2 -0
- package/lib/types/platforms/supports/InitFastifyPlatform.d.ts +2 -0
- package/lib/types/platforms/supports/InitKoaPlatform.d.ts +2 -0
- package/lib/types/processors/__fixtures__/createFakeProject.d.ts +5 -0
- package/lib/types/processors/transformBinFile.d.ts +3 -0
- package/lib/types/processors/transformConfigFile.d.ts +3 -0
- package/lib/types/processors/transformIndexFile.d.ts +3 -0
- package/lib/types/processors/transformServerFile.d.ts +3 -0
- package/lib/types/runtimes/RuntimesModule.d.ts +5 -5
- package/lib/types/services/CliProjectService.d.ts +16 -0
- package/lib/types/services/CliTemplatesService.d.ts +29 -0
- package/lib/types/services/ProjectClient.d.ts +40 -0
- package/lib/types/services/mappers/mapDefaultTemplateOptions.d.ts +11 -0
- package/lib/types/templates/asyncFactory.template.d.ts +2 -0
- package/lib/types/templates/barrels.template.d.ts +2 -0
- package/lib/types/templates/command.template.d.ts +2 -0
- package/lib/types/templates/config.template.d.ts +2 -0
- package/lib/types/templates/controller.template.d.ts +2 -0
- package/lib/types/templates/decorator.template.d.ts +2 -0
- package/lib/types/templates/docker-compose.template.d.ts +2 -0
- package/lib/types/templates/dockerfile.template.d.ts +1 -0
- package/lib/types/templates/exception-filter.template.d.ts +2 -0
- package/lib/types/templates/factory.template.d.ts +2 -0
- package/lib/types/templates/index.command.template.d.ts +2 -0
- package/lib/types/templates/index.config.utils.template.d.ts +2 -0
- package/lib/types/templates/index.controller.template.d.ts +2 -0
- package/lib/types/templates/index.d.ts +31 -0
- package/lib/types/templates/index.logger.template.d.ts +2 -0
- package/lib/types/templates/index.template.d.ts +2 -0
- package/lib/types/templates/interceptor.template.d.ts +2 -0
- package/lib/types/templates/interface.template.d.ts +2 -0
- package/lib/types/templates/middleware.template.d.ts +2 -0
- package/lib/types/templates/model.template.d.ts +2 -0
- package/lib/types/templates/module.template.d.ts +2 -0
- package/lib/types/templates/pipe.template.d.ts +2 -0
- package/lib/types/templates/pm2.template.d.ts +1 -0
- package/lib/types/templates/prisma.service.template.d.ts +2 -0
- package/lib/types/templates/readme.template.d.ts +2 -0
- package/lib/types/templates/repository.template.d.ts +2 -0
- package/lib/types/templates/response-filter.template.d.ts +2 -0
- package/lib/types/templates/server.template.d.ts +2 -0
- package/lib/types/templates/service.template.d.ts +2 -0
- package/lib/types/templates/tsconfig.spec.template.d.ts +2 -0
- package/lib/types/templates/tsconfig.template.d.ts +2 -0
- package/lib/types/templates/value.template.d.ts +2 -0
- package/lib/types/utils/defineTemplate.d.ts +39 -0
- package/package.json +14 -12
- package/templates/tsconfig.node.json +14 -0
- package/templates/webpack.config.js +55 -0
- package/lib/esm/commands/generate/ProviderTypes.js +0 -103
- package/lib/esm/commands/init/interfaces/InitOptions.js +0 -5
- package/lib/esm/services/ProvidersInfoService.js +0 -46
- package/lib/esm/services/Renderer.js +0 -162
- package/lib/esm/utils/fillImports.js +0 -38
- package/lib/esm/utils/hbs/array.js +0 -515
- package/lib/esm/utils/hbs/collection.js +0 -60
- package/lib/esm/utils/hbs/comparison.js +0 -431
- package/lib/esm/utils/hbs/index.js +0 -11
- package/lib/esm/utils/hbs/object.js +0 -236
- package/lib/esm/utils/hbs/switch.js +0 -10
- package/lib/esm/utils/renderer/insertAfter.js +0 -12
- package/lib/esm/utils/renderer/insertImport.js +0 -11
- package/lib/types/commands/generate/ProviderTypes.d.ts +0 -11
- package/lib/types/commands/init/interfaces/InitCmdContext.d.ts +0 -6
- package/lib/types/commands/init/interfaces/InitOptions.d.ts +0 -20
- package/lib/types/services/ProvidersInfoService.d.ts +0 -21
- package/lib/types/services/Renderer.d.ts +0 -44
- package/lib/types/utils/fillImports.d.ts +0 -1
- package/lib/types/utils/hbs/array.d.ts +0 -1
- package/lib/types/utils/hbs/collection.d.ts +0 -1
- package/lib/types/utils/hbs/comparison.d.ts +0 -1
- package/lib/types/utils/hbs/object.d.ts +0 -1
- package/lib/types/utils/hbs/switch.d.ts +0 -1
- package/lib/types/utils/renderer/insertAfter.d.ts +0 -1
- package/lib/types/utils/renderer/insertImport.d.ts +0 -1
- package/templates/generate/async.factory.hbs +0 -35
- package/templates/generate/command.hbs +0 -45
- package/templates/generate/controller.hbs +0 -10
- package/templates/generate/decorator.class.hbs +0 -14
- package/templates/generate/decorator.endpoint.hbs +0 -15
- package/templates/generate/decorator.generic.hbs +0 -19
- package/templates/generate/decorator.method.hbs +0 -16
- package/templates/generate/decorator.middleware.hbs +0 -26
- package/templates/generate/decorator.param.hbs +0 -15
- package/templates/generate/decorator.parameters.hbs +0 -9
- package/templates/generate/decorator.prop.hbs +0 -14
- package/templates/generate/decorator.property.hbs +0 -5
- package/templates/generate/exception-filter.hbs +0 -9
- package/templates/generate/factory.hbs +0 -11
- package/templates/generate/injectable.hbs +0 -6
- package/templates/generate/interceptor.hbs +0 -21
- package/templates/generate/interface.hbs +0 -3
- package/templates/generate/middleware.hbs +0 -9
- package/templates/generate/model.hbs +0 -6
- package/templates/generate/module.hbs +0 -6
- package/templates/generate/pipe.hbs +0 -9
- package/templates/generate/prisma.service.hbs +0 -13
- package/templates/generate/repository.hbs +0 -6
- package/templates/generate/response-filter.hbs +0 -9
- package/templates/generate/server/_partials/server-footer.hbs +0 -10
- package/templates/generate/server/_partials/server-header.hbs +0 -34
- package/templates/generate/server/express/server.hbs +0 -10
- package/templates/generate/server/fastify/server.hbs +0 -14
- package/templates/generate/server/koa/server.hbs +0 -8
- package/templates/generate/service.hbs +0 -6
- package/templates/generate/value.hbs +0 -3
- package/templates/init/.barrels.json.hbs +0 -9
- package/templates/init/.gitignore.hbs +0 -57
- package/templates/init/.npmrc.hbs +0 -2
- package/templates/init/docker/_partials/docker-body.hbs +0 -5
- package/templates/init/docker/_partials/docker-dev-tools.hbs +0 -2
- package/templates/init/docker/_partials/docker-header.hbs +0 -16
- package/templates/init/docker/bun/Dockerfile.hbs +0 -36
- package/templates/init/docker/npm/Dockerfile.hbs +0 -28
- package/templates/init/docker/pnpm/Dockerfile.hbs +0 -28
- package/templates/init/docker/yarn/Dockerfile.hbs +0 -28
- package/templates/init/docker/yarn_berry/Dockerfile.hbs +0 -31
- package/templates/init/docker-compose.yml.hbs +0 -14
- package/templates/init/pm2/bun/processes.config.cjs.hbs +0 -23
- package/templates/init/pm2/node-compiled/processes.config.cjs.hbs +0 -22
- package/templates/init/pm2/node-loader/processes.config.cjs.hbs +0 -24
- package/templates/init/src/bin/index.ts.hbs +0 -9
- package/templates/init/src/config/envs/index.ts.hbs +0 -7
- package/templates/init/src/config/index.ts.hbs +0 -38
- package/templates/init/src/config/logger/index.ts.hbs +0 -25
- package/templates/init/tsconfig.json.hbs +0 -16
- package/templates/init/tsconfig.node.json.hbs +0 -20
- package/templates/init/tsconfig.spec.json.hbs +0 -25
- package/templates/init/webpack.config.js.hbs +0 -65
- /package/lib/esm/{commands/init/interfaces/InitCmdContext.js → interfaces/AlterGenerateTasks.js} +0 -0
- /package/lib/{types/utils/hbs/index.d.ts → esm/interfaces/AlterInitSubTasks.js} +0 -0
- /package/templates/{init/.babelrc.hbs → .babelrc} +0 -0
- /package/templates/{init/.dockerignore.hbs → .dockerignore} +0 -0
- /package/templates/{init/.swcrc.hbs → .swcrc} +0 -0
- /package/templates/{init/.yarnrc.hbs → .yarnrc} +0 -0
- /package/templates/{init/nodemon.json.hbs → nodemon.json} +0 -0
- /package/templates/{init/tsconfig.base.json.hbs → tsconfig.base.json} +0 -0
- /package/templates/{init/views/swagger.ejs.hbs → views/swagger.ejs} +0 -0
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
1
|
import { basename, join } from "node:path";
|
|
3
|
-
import { CliExeca, CliFs, CliLoadFile, cliPackageJson, CliPlugins,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { CliExeca, CliFs, CliLoadFile, cliPackageJson, CliPlugins, command, Configuration, createSubTasks, createTasksRunner, inject, PackageManager, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
|
|
3
|
+
import { isString } from "@tsed/core";
|
|
4
|
+
import { constant } from "@tsed/di";
|
|
5
|
+
import { $asyncAlter } from "@tsed/hooks";
|
|
6
|
+
import { kebabCase } from "change-case";
|
|
7
|
+
import { DEFAULT_TSED_TAGS, TEMPLATE_DIR } from "../../constants/index.js";
|
|
8
|
+
import { exec } from "../../fn/exec.js";
|
|
9
|
+
import { render } from "../../fn/render.js";
|
|
10
|
+
import { taskOutput } from "../../fn/taskOutput.js";
|
|
6
11
|
import { ArchitectureConvention } from "../../interfaces/ArchitectureConvention.js";
|
|
7
12
|
import { PlatformType } from "../../interfaces/index.js";
|
|
8
13
|
import { ProjectConvention } from "../../interfaces/ProjectConvention.js";
|
|
9
|
-
import {
|
|
10
|
-
import { InitPlatformsModule } from "../../platforms/InitPlatformsModule.js";
|
|
14
|
+
import { PlatformsModule } from "../../platforms/PlatformsModule.js";
|
|
11
15
|
import { RuntimesModule } from "../../runtimes/RuntimesModule.js";
|
|
12
16
|
import { BunRuntime } from "../../runtimes/supports/BunRuntime.js";
|
|
13
17
|
import { NodeRuntime } from "../../runtimes/supports/NodeRuntime.js";
|
|
14
|
-
import {
|
|
15
|
-
import { fillImports } from "../../utils/fillImports.js";
|
|
18
|
+
import { CliProjectService } from "../../services/CliProjectService.js";
|
|
16
19
|
import { FeaturesMap, FeatureType } from "./config/FeaturesPrompt.js";
|
|
17
20
|
import { InitFileSchema } from "./config/InitFileSchema.js";
|
|
18
21
|
import { mapToContext } from "./mappers/mapToContext.js";
|
|
19
22
|
import { getFeaturesPrompt } from "./prompts/getFeaturesPrompt.js";
|
|
20
|
-
|
|
23
|
+
export class InitCmd {
|
|
21
24
|
constructor() {
|
|
22
25
|
this.configuration = inject(Configuration);
|
|
23
26
|
this.cliPlugins = inject(CliPlugins);
|
|
24
27
|
this.packageJson = inject(ProjectPackageJson);
|
|
25
28
|
this.packageManagers = inject(PackageManagersModule);
|
|
26
29
|
this.runtimes = inject(RuntimesModule);
|
|
27
|
-
this.platforms = inject(
|
|
30
|
+
this.platforms = inject(PlatformsModule);
|
|
28
31
|
this.cliPackageJson = cliPackageJson();
|
|
29
|
-
this.cliService = inject(CliService);
|
|
30
32
|
this.cliLoadFile = inject(CliLoadFile);
|
|
31
|
-
this.
|
|
32
|
-
this.outputFilePathPipe = inject(OutputFilePathPipe);
|
|
33
|
+
this.project = inject(CliProjectService);
|
|
33
34
|
this.execa = inject(CliExeca);
|
|
34
35
|
this.fs = inject(CliFs);
|
|
35
36
|
}
|
|
@@ -101,29 +102,28 @@ let InitCmd = class InitCmd {
|
|
|
101
102
|
this.packageManagers.list().forEach((key) => {
|
|
102
103
|
ctx[key] = ctx.packageManager === key;
|
|
103
104
|
});
|
|
104
|
-
return
|
|
105
|
+
return {
|
|
105
106
|
...ctx,
|
|
106
|
-
entryServer: ctx.convention !== ProjectConvention.ANGULAR ? "Server" : "server",
|
|
107
107
|
cliVersion: ctx.cliVersion || this.cliPackageJson.version,
|
|
108
|
-
srcDir:
|
|
109
|
-
|
|
110
|
-
});
|
|
108
|
+
srcDir: constant("project.srcDir", "src")
|
|
109
|
+
};
|
|
111
110
|
}
|
|
112
111
|
async $beforeExec(ctx) {
|
|
113
112
|
this.fs.ensureDirSync(this.packageJson.dir);
|
|
114
|
-
this.packageJson.name = ctx.projectName;
|
|
113
|
+
ctx.projectName && (this.packageJson.name = ctx.projectName);
|
|
115
114
|
ctx.packageManager && this.packageJson.setPreference("packageManager", ctx.packageManager);
|
|
116
115
|
ctx.runtime && this.packageJson.setPreference("runtime", ctx.runtime);
|
|
117
116
|
ctx.architecture && this.packageJson.setPreference("architecture", ctx.architecture);
|
|
118
117
|
ctx.convention && this.packageJson.setPreference("convention", ctx.convention);
|
|
118
|
+
ctx.platform && this.packageJson.setPreference("platform", ctx.convention);
|
|
119
119
|
ctx.GH_TOKEN && this.packageJson.setGhToken(ctx.GH_TOKEN);
|
|
120
120
|
await createTasksRunner([
|
|
121
121
|
{
|
|
122
122
|
title: "Write RC files",
|
|
123
123
|
skip: () => !ctx.GH_TOKEN,
|
|
124
|
-
task: () =>
|
|
125
|
-
|
|
126
|
-
}
|
|
124
|
+
task: () => {
|
|
125
|
+
return Promise.all([render(".npmrc", ctx), render(".yarnrc", ctx)]);
|
|
126
|
+
}
|
|
127
127
|
},
|
|
128
128
|
{
|
|
129
129
|
title: "Initialize package.json",
|
|
@@ -151,39 +151,52 @@ let InitCmd = class InitCmd {
|
|
|
151
151
|
}
|
|
152
152
|
async $exec(ctx) {
|
|
153
153
|
this.checkPrecondition(ctx);
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
...(await this.cliService.getTasks("generate", {
|
|
162
|
-
type: "controller",
|
|
163
|
-
route: "hello-world",
|
|
164
|
-
name: "HelloWorld",
|
|
165
|
-
directory: "rest"
|
|
166
|
-
})),
|
|
167
|
-
...(ctx.commands
|
|
168
|
-
? await this.cliService.getTasks("generate", {
|
|
169
|
-
type: "command",
|
|
170
|
-
route: "hello",
|
|
171
|
-
name: "hello"
|
|
172
|
-
})
|
|
173
|
-
: [])
|
|
174
|
-
];
|
|
154
|
+
const runtime = this.runtimes.get();
|
|
155
|
+
ctx = {
|
|
156
|
+
...ctx,
|
|
157
|
+
node: runtime instanceof NodeRuntime,
|
|
158
|
+
bun: runtime instanceof BunRuntime,
|
|
159
|
+
compiled: runtime instanceof NodeRuntime && runtime.isCompiled()
|
|
160
|
+
};
|
|
175
161
|
return [
|
|
176
162
|
{
|
|
177
|
-
title: "
|
|
178
|
-
task:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
163
|
+
title: "Render base files",
|
|
164
|
+
task: () => this.renderFiles(ctx)
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
title: "Alter package json",
|
|
168
|
+
task: () => {
|
|
169
|
+
return $asyncAlter("$alterPackageJson", this.packageJson, [ctx]);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
title: "Generate additional project files",
|
|
174
|
+
task: createSubTasks(async () => {
|
|
175
|
+
const subTasks = [
|
|
176
|
+
...(await exec("generate", {
|
|
177
|
+
//...ctx,
|
|
178
|
+
type: "controller",
|
|
179
|
+
route: "rest",
|
|
180
|
+
name: "HelloWorld",
|
|
181
|
+
directory: "rest"
|
|
182
|
+
})),
|
|
183
|
+
...(ctx.commands
|
|
184
|
+
? await exec("generate", {
|
|
185
|
+
//...ctx,
|
|
186
|
+
type: "command",
|
|
187
|
+
route: "hello",
|
|
188
|
+
name: "hello"
|
|
189
|
+
})
|
|
190
|
+
: [])
|
|
191
|
+
];
|
|
192
|
+
return $asyncAlter("$alterInitSubTasks", subTasks, [ctx]);
|
|
193
|
+
}, { ...ctx, concurrent: false })
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
title: "transform generated files to the project configuration",
|
|
197
|
+
task: async () => {
|
|
198
|
+
return this.project.transformFiles(ctx);
|
|
199
|
+
}
|
|
187
200
|
}
|
|
188
201
|
];
|
|
189
202
|
}
|
|
@@ -227,6 +240,7 @@ let InitCmd = class InitCmd {
|
|
|
227
240
|
"@tsed/core": ctx.tsedVersion,
|
|
228
241
|
"@tsed/di": ctx.tsedVersion,
|
|
229
242
|
"@tsed/ajv": ctx.tsedVersion,
|
|
243
|
+
"@tsed/config": ctx.tsedVersion,
|
|
230
244
|
"@tsed/exceptions": ctx.tsedVersion,
|
|
231
245
|
"@tsed/schema": ctx.tsedVersion,
|
|
232
246
|
"@tsed/json-mapper": ctx.tsedVersion,
|
|
@@ -245,9 +259,6 @@ let InitCmd = class InitCmd {
|
|
|
245
259
|
"@tsed/barrels": "latest",
|
|
246
260
|
ajv: "latest",
|
|
247
261
|
"cross-env": "latest",
|
|
248
|
-
dotenv: "latest",
|
|
249
|
-
"dotenv-expand": "latest",
|
|
250
|
-
"dotenv-flow": "latest",
|
|
251
262
|
...this.runtimes.get().dependencies(),
|
|
252
263
|
...this.platforms.get(ctx.platform).dependencies(ctx)
|
|
253
264
|
});
|
|
@@ -262,7 +273,7 @@ let InitCmd = class InitCmd {
|
|
|
262
273
|
}, ctx);
|
|
263
274
|
}
|
|
264
275
|
addFeatures(ctx) {
|
|
265
|
-
ctx.features
|
|
276
|
+
ctx.features?.forEach((value) => {
|
|
266
277
|
const feature = FeaturesMap[value.toLowerCase()];
|
|
267
278
|
if (feature) {
|
|
268
279
|
if (feature.dependencies) {
|
|
@@ -273,128 +284,136 @@ let InitCmd = class InitCmd {
|
|
|
273
284
|
}
|
|
274
285
|
}
|
|
275
286
|
});
|
|
276
|
-
if (ctx.features
|
|
287
|
+
if (ctx.features?.find((value) => value === FeatureType.GRAPHQL)) {
|
|
277
288
|
this.packageJson.addDependencies({
|
|
278
289
|
[`apollo-server-${ctx.platform}`]: "2.25.2"
|
|
279
290
|
}, ctx);
|
|
280
291
|
}
|
|
281
292
|
}
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
name: "Index",
|
|
285
|
-
type: "controller",
|
|
286
|
-
format: ctx.convention
|
|
287
|
-
})}.ts`);
|
|
288
|
-
const runtime = this.runtimes.get();
|
|
289
|
-
const packageManager = this.packageManagers.get();
|
|
290
|
-
ctx = {
|
|
291
|
-
...ctx,
|
|
292
|
-
node: runtime instanceof NodeRuntime,
|
|
293
|
-
bun: runtime instanceof BunRuntime,
|
|
294
|
-
compiled: runtime instanceof NodeRuntime && runtime.isCompiled()
|
|
295
|
-
};
|
|
293
|
+
async baseFiles(ctx) {
|
|
294
|
+
const packageManager = inject(PackageManagersModule).get();
|
|
296
295
|
const pm2 = ctx.bun ? "bun" : ctx.compiled ? "node-compiled" : "node-loader";
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
"
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
"
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
"
|
|
314
|
-
"
|
|
315
|
-
"
|
|
316
|
-
"
|
|
317
|
-
|
|
318
|
-
"/
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
ctx.commands && "/init/src/bin/index.ts.hbs",
|
|
323
|
-
ctx.swagger && "/init/views/swagger.ejs.hbs",
|
|
324
|
-
ctx.swagger && {
|
|
325
|
-
path: "/init/src/controllers/pages/IndexController.ts.hbs",
|
|
326
|
-
basename: indexCtrlBaseName,
|
|
327
|
-
replaces: [ctx.architecture === ArchitectureConvention.FEATURE ? "controllers" : null]
|
|
328
|
-
}
|
|
329
|
-
].filter(Boolean), ctx, {
|
|
330
|
-
baseDir: "/init"
|
|
296
|
+
const runtimes = inject(RuntimesModule);
|
|
297
|
+
const runtime = runtimes.get();
|
|
298
|
+
// files with higher priority
|
|
299
|
+
const promises = [
|
|
300
|
+
"tsconfig.base.json",
|
|
301
|
+
"tsconfig.config.json",
|
|
302
|
+
"tsconfig.spec.json",
|
|
303
|
+
"tsconfig.node.json",
|
|
304
|
+
"docker-compose.yml",
|
|
305
|
+
`dockerfile.${packageManager.name}`,
|
|
306
|
+
".dockerignore",
|
|
307
|
+
".gitignore",
|
|
308
|
+
"server",
|
|
309
|
+
"config",
|
|
310
|
+
"index",
|
|
311
|
+
"index.config.util",
|
|
312
|
+
"index.logger",
|
|
313
|
+
"index.controller",
|
|
314
|
+
"barrels",
|
|
315
|
+
"readme",
|
|
316
|
+
`pm2.${pm2}`,
|
|
317
|
+
ctx.swagger && "/views/swagger.ejs",
|
|
318
|
+
...runtime.files()
|
|
319
|
+
].map((id) => {
|
|
320
|
+
return id && render(id, ctx);
|
|
331
321
|
});
|
|
322
|
+
await Promise.all(promises);
|
|
332
323
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
324
|
+
async renderFiles(ctx) {
|
|
325
|
+
// base files
|
|
326
|
+
let startTime = Date.now();
|
|
327
|
+
await this.baseFiles(ctx);
|
|
328
|
+
taskOutput(`Base files rendered (${Date.now() - startTime}ms)`);
|
|
329
|
+
const files = await $asyncAlter("$alterRenderFiles", [], [ctx]);
|
|
330
|
+
startTime = Date.now();
|
|
331
|
+
const promises = files.map((option) => {
|
|
332
|
+
if (!option) {
|
|
333
|
+
return;
|
|
343
334
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
"-a, --arch <architecture>": {
|
|
352
|
-
type: String,
|
|
353
|
-
defaultValue: ArchitectureConvention.DEFAULT,
|
|
354
|
-
description: `Set the default architecture convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`
|
|
355
|
-
},
|
|
356
|
-
"-c, --convention <convention>": {
|
|
357
|
-
type: String,
|
|
358
|
-
defaultValue: ProjectConvention.DEFAULT,
|
|
359
|
-
description: `Set the default project convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`
|
|
360
|
-
},
|
|
361
|
-
"-p, --platform <platform>": {
|
|
362
|
-
type: String,
|
|
363
|
-
defaultValue: PlatformType.EXPRESS,
|
|
364
|
-
description: "Set the default platform for Ts.ED (express, koa or fastify)"
|
|
365
|
-
},
|
|
366
|
-
"--features <features...>": {
|
|
367
|
-
type: Array,
|
|
368
|
-
itemType: String,
|
|
369
|
-
defaultValue: [],
|
|
370
|
-
description: "List of the Ts.ED features."
|
|
371
|
-
},
|
|
372
|
-
"--runtime <runtime>": {
|
|
373
|
-
itemType: String,
|
|
374
|
-
defaultValue: "node",
|
|
375
|
-
description: "The default runtime used to run the project"
|
|
376
|
-
},
|
|
377
|
-
"-m, --package-manager <packageManager>": {
|
|
378
|
-
itemType: String,
|
|
379
|
-
defaultValue: PackageManager.YARN,
|
|
380
|
-
description: "The default package manager to install the project"
|
|
381
|
-
},
|
|
382
|
-
"-t, --tsed-version <version>": {
|
|
383
|
-
type: String,
|
|
384
|
-
defaultValue: DEFAULT_TSED_TAGS,
|
|
385
|
-
description: "Use a specific version of Ts.ED (format: 5.x.x)."
|
|
386
|
-
},
|
|
387
|
-
"-f, --file <path>": {
|
|
388
|
-
type: String,
|
|
389
|
-
description: "Location of a file in which the features are defined."
|
|
390
|
-
},
|
|
391
|
-
"-s, --skip-prompt": {
|
|
392
|
-
type: Boolean,
|
|
393
|
-
defaultValue: false,
|
|
394
|
-
description: "Skip the prompt."
|
|
335
|
+
if (isString(option)) {
|
|
336
|
+
const [id, name] = option.split(":");
|
|
337
|
+
return render(id, {
|
|
338
|
+
...ctx,
|
|
339
|
+
from: TEMPLATE_DIR,
|
|
340
|
+
name: name || id
|
|
341
|
+
});
|
|
395
342
|
}
|
|
343
|
+
else {
|
|
344
|
+
if ("id" in option) {
|
|
345
|
+
return render(option.id, {
|
|
346
|
+
...ctx,
|
|
347
|
+
...option
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
await Promise.all(promises);
|
|
353
|
+
taskOutput(`Plugins files rendered (${Date.now() - startTime}ms)`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
command(InitCmd, {
|
|
357
|
+
name: "init",
|
|
358
|
+
description: "Init a new Ts.ED project",
|
|
359
|
+
args: {
|
|
360
|
+
root: {
|
|
361
|
+
type: String,
|
|
362
|
+
defaultValue: ".",
|
|
363
|
+
description: "Root directory to initialize the Ts.ED project"
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
options: {
|
|
367
|
+
"-n, --project-name <projectName>": {
|
|
368
|
+
type: String,
|
|
369
|
+
defaultValue: "",
|
|
370
|
+
description: "Set the project name. By default, the project is the same as the name directory."
|
|
371
|
+
},
|
|
372
|
+
"-a, --arch <architecture>": {
|
|
373
|
+
type: String,
|
|
374
|
+
defaultValue: ArchitectureConvention.DEFAULT,
|
|
375
|
+
description: `Set the default architecture convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`
|
|
376
|
+
},
|
|
377
|
+
"-c, --convention <convention>": {
|
|
378
|
+
type: String,
|
|
379
|
+
defaultValue: ProjectConvention.DEFAULT,
|
|
380
|
+
description: `Set the default project convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`
|
|
396
381
|
},
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
382
|
+
"-p, --platform <platform>": {
|
|
383
|
+
type: String,
|
|
384
|
+
defaultValue: PlatformType.EXPRESS,
|
|
385
|
+
description: "Set the default platform for Ts.ED (express, koa or fastify)"
|
|
386
|
+
},
|
|
387
|
+
"--features <features...>": {
|
|
388
|
+
type: Array,
|
|
389
|
+
itemType: String,
|
|
390
|
+
defaultValue: [],
|
|
391
|
+
description: "List of the Ts.ED features."
|
|
392
|
+
},
|
|
393
|
+
"--runtime <runtime>": {
|
|
394
|
+
itemType: String,
|
|
395
|
+
defaultValue: "node",
|
|
396
|
+
description: "The default runtime used to run the project"
|
|
397
|
+
},
|
|
398
|
+
"-m, --package-manager <packageManager>": {
|
|
399
|
+
itemType: String,
|
|
400
|
+
defaultValue: PackageManager.YARN,
|
|
401
|
+
description: "The default package manager to install the project"
|
|
402
|
+
},
|
|
403
|
+
"-t, --tsed-version <version>": {
|
|
404
|
+
type: String,
|
|
405
|
+
defaultValue: DEFAULT_TSED_TAGS,
|
|
406
|
+
description: "Use a specific version of Ts.ED (format: 5.x.x)."
|
|
407
|
+
},
|
|
408
|
+
"-f, --file <path>": {
|
|
409
|
+
type: String,
|
|
410
|
+
description: "Location of a file in which the features are defined."
|
|
411
|
+
},
|
|
412
|
+
"-s, --skip-prompt": {
|
|
413
|
+
type: Boolean,
|
|
414
|
+
defaultValue: false,
|
|
415
|
+
description: "Skip the prompt."
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
disableReadUpPkg: true
|
|
419
|
+
});
|
|
@@ -7,9 +7,20 @@ export var FeatureType;
|
|
|
7
7
|
FeatureType["SOCKETIO"] = "socketio";
|
|
8
8
|
FeatureType["OIDC"] = "oidc";
|
|
9
9
|
FeatureType["PASSPORTJS"] = "passportjs";
|
|
10
|
+
FeatureType["CONFIG"] = "config";
|
|
10
11
|
FeatureType["COMMANDS"] = "commands";
|
|
11
12
|
FeatureType["DB"] = "db";
|
|
12
13
|
FeatureType["DOC"] = "doc";
|
|
14
|
+
// CONFIG
|
|
15
|
+
FeatureType["CONFIG_ENVS"] = "config:envs";
|
|
16
|
+
FeatureType["CONFIG_DOTENV"] = "config:dotenv";
|
|
17
|
+
FeatureType["CONFIG_JSON"] = "config:json";
|
|
18
|
+
FeatureType["CONFIG_YAML"] = "config:yaml";
|
|
19
|
+
FeatureType["CONFIG_AWS_SECRETS"] = "config:aws_secrets";
|
|
20
|
+
FeatureType["CONFIG_IOREDIS"] = "config:ioredis";
|
|
21
|
+
FeatureType["CONFIG_MONGO"] = "config:mongo";
|
|
22
|
+
FeatureType["CONFIG_VAULT"] = "config:vault";
|
|
23
|
+
FeatureType["CONFIG_POSTGRES"] = "config:postgres";
|
|
13
24
|
// DOC
|
|
14
25
|
FeatureType["SWAGGER"] = "swagger";
|
|
15
26
|
FeatureType["SCALAR"] = "scalar";
|
|
@@ -32,7 +43,7 @@ export var FeatureType;
|
|
|
32
43
|
FeatureType["TYPEORM_SQLJS"] = "typeorm:sqljs";
|
|
33
44
|
FeatureType["TYPEORM_REACTNATIVE"] = "typeorm:reactnative";
|
|
34
45
|
FeatureType["TYPEORM_EXPO"] = "typeorm:expo";
|
|
35
|
-
// TESTING
|
|
46
|
+
// TESTING & LINTER
|
|
36
47
|
FeatureType["TESTING"] = "testing";
|
|
37
48
|
FeatureType["JEST"] = "jest";
|
|
38
49
|
FeatureType["VITEST"] = "vitest";
|
|
@@ -137,6 +148,73 @@ export const FeaturesMap = {
|
|
|
137
148
|
name: "Feature",
|
|
138
149
|
checked: false
|
|
139
150
|
},
|
|
151
|
+
/// CONFIGURATION SOURCES
|
|
152
|
+
[FeatureType.CONFIG]: {
|
|
153
|
+
name: "Configuration sources",
|
|
154
|
+
dependencies: {
|
|
155
|
+
"@tsed/config": "{{tsedVersion}}"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
[FeatureType.CONFIG_ENVS]: {
|
|
159
|
+
name: "Envs"
|
|
160
|
+
},
|
|
161
|
+
[FeatureType.CONFIG_DOTENV]: {
|
|
162
|
+
name: "Dotenv",
|
|
163
|
+
dependencies: {
|
|
164
|
+
dotenv: "latest",
|
|
165
|
+
"dotenv-expand": "latest",
|
|
166
|
+
"dotenv-flow": "latest"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
[FeatureType.CONFIG_JSON]: {
|
|
170
|
+
name: "JSON"
|
|
171
|
+
},
|
|
172
|
+
[FeatureType.CONFIG_YAML]: {
|
|
173
|
+
name: "YAML",
|
|
174
|
+
dependencies: {
|
|
175
|
+
"js-yaml": "latest"
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
[FeatureType.CONFIG_AWS_SECRETS]: {
|
|
179
|
+
name: "AWS Secrets Manager (Premium)",
|
|
180
|
+
dependencies: {
|
|
181
|
+
"@tsedio/config-source-aws-secrets": "latest",
|
|
182
|
+
"@aws-sdk/client-secrets-manager": "latest"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
[FeatureType.CONFIG_IOREDIS]: {
|
|
186
|
+
name: "IORedis (Premium)",
|
|
187
|
+
dependencies: {
|
|
188
|
+
"@tsedio/config-ioredis": "{{tsedVersion}}",
|
|
189
|
+
"@tsed/ioredis": "{{tsedVersion}}",
|
|
190
|
+
ioredis: "latest"
|
|
191
|
+
},
|
|
192
|
+
devDependencies: {
|
|
193
|
+
"@tsedio/testcontainers-redis": "latest"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
[FeatureType.CONFIG_MONGO]: {
|
|
197
|
+
name: "MongoDB (Premium)",
|
|
198
|
+
dependencies: {
|
|
199
|
+
mongodb: "latest",
|
|
200
|
+
"@tsedio/config-mongo": "latest"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
[FeatureType.CONFIG_VAULT]: {
|
|
204
|
+
name: "Vault (Premium)",
|
|
205
|
+
dependencies: {
|
|
206
|
+
"@tsedio/config-vault": "latest",
|
|
207
|
+
"node-vault": "latest"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
[FeatureType.CONFIG_POSTGRES]: {
|
|
211
|
+
name: "Postgres (Premium)",
|
|
212
|
+
dependencies: {
|
|
213
|
+
pg: "latest",
|
|
214
|
+
"@tsedio/config-postgres": "latest"
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
/// TYPEORM
|
|
140
218
|
[FeatureType.TYPEORM_MYSQL]: {
|
|
141
219
|
name: "MySQL",
|
|
142
220
|
dependencies: {
|
|
@@ -225,6 +303,7 @@ export const FeaturesMap = {
|
|
|
225
303
|
typeorm: "latest"
|
|
226
304
|
}
|
|
227
305
|
},
|
|
306
|
+
/// TESTING
|
|
228
307
|
[FeatureType.VITEST]: {
|
|
229
308
|
name: "Vitest",
|
|
230
309
|
devDependencies: {
|
|
@@ -237,6 +316,7 @@ export const FeaturesMap = {
|
|
|
237
316
|
"@tsed/cli-plugin-jest": "{{cliVersion}}"
|
|
238
317
|
}
|
|
239
318
|
},
|
|
319
|
+
// LINTER
|
|
240
320
|
[FeatureType.ESLINT]: {
|
|
241
321
|
name: "EsLint",
|
|
242
322
|
checked: true,
|
|
@@ -308,6 +388,7 @@ export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
|
|
|
308
388
|
name: "features",
|
|
309
389
|
message: "Check the features needed for your project",
|
|
310
390
|
choices: [
|
|
391
|
+
FeatureType.CONFIG,
|
|
311
392
|
FeatureType.GRAPHQL,
|
|
312
393
|
FeatureType.DB,
|
|
313
394
|
FeatureType.PASSPORTJS,
|
|
@@ -317,6 +398,23 @@ export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
|
|
|
317
398
|
FeatureType.TESTING,
|
|
318
399
|
FeatureType.LINTER,
|
|
319
400
|
FeatureType.COMMANDS
|
|
401
|
+
].sort((a, b) => a.localeCompare(b))
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
type: "checkbox",
|
|
405
|
+
message: "Choose configuration sources",
|
|
406
|
+
name: "featuresConfig",
|
|
407
|
+
when: hasFeature(FeatureType.CONFIG),
|
|
408
|
+
choices: [
|
|
409
|
+
FeatureType.CONFIG_ENVS,
|
|
410
|
+
FeatureType.CONFIG_DOTENV,
|
|
411
|
+
FeatureType.CONFIG_JSON,
|
|
412
|
+
FeatureType.CONFIG_YAML,
|
|
413
|
+
FeatureType.CONFIG_AWS_SECRETS,
|
|
414
|
+
FeatureType.CONFIG_IOREDIS,
|
|
415
|
+
FeatureType.CONFIG_MONGO,
|
|
416
|
+
FeatureType.CONFIG_VAULT,
|
|
417
|
+
FeatureType.CONFIG_POSTGRES
|
|
320
418
|
]
|
|
321
419
|
},
|
|
322
420
|
{
|
|
@@ -359,8 +457,8 @@ export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
|
|
|
359
457
|
// type: "password",
|
|
360
458
|
// name: "GH_TOKEN",
|
|
361
459
|
// message:
|
|
362
|
-
// "Enter GH_TOKEN to use the premium @tsedio
|
|
363
|
-
// when: hasValue("featuresDB.type", "prisma")
|
|
460
|
+
// "Enter GH_TOKEN to use the premium @tsedio package or leave blank (see https://tsed.dev/plugins/premium/install-premium-plugins.html)"
|
|
461
|
+
// // when: hasValue("featuresDB.type", "prisma")
|
|
364
462
|
// },
|
|
365
463
|
{
|
|
366
464
|
message: "Choose unit framework",
|
|
@@ -3,9 +3,10 @@ import { mapUniqFeatures } from "./mapUniqFeatures.js";
|
|
|
3
3
|
export function mapToContext(options) {
|
|
4
4
|
options = mapUniqFeatures(options);
|
|
5
5
|
options.features.forEach((feature) => {
|
|
6
|
-
feature.split(":")
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const [base, type] = feature.split(":");
|
|
7
|
+
options[camelCase(base)] = true;
|
|
8
|
+
type && (options[camelCase(type)] = true);
|
|
9
|
+
feature && (options[camelCase(feature)] = true);
|
|
9
10
|
});
|
|
10
11
|
return options;
|
|
11
12
|
}
|