@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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RenderDataContext } from "../interfaces/RenderDataContext.js";
|
|
2
|
+
import { ProjectClient } from "../services/ProjectClient.js";
|
|
3
|
+
import { CliTemplatesService, type TemplateRenderOptions, type TemplateRenderReturnType } from "./CliTemplatesService.js";
|
|
4
|
+
export declare class CliProjectService {
|
|
5
|
+
readonly templates: CliTemplatesService;
|
|
6
|
+
private project;
|
|
7
|
+
private rootDir;
|
|
8
|
+
get srcDir(): string;
|
|
9
|
+
getRelativePath(path: string): string;
|
|
10
|
+
getServerFileName(): "Server" | "server";
|
|
11
|
+
create(): void;
|
|
12
|
+
get(): ProjectClient;
|
|
13
|
+
transformFiles(data: RenderDataContext): Promise<void>;
|
|
14
|
+
createFromTemplate(templateId: string, ctx: TemplateRenderOptions): Promise<TemplateRenderReturnType | undefined>;
|
|
15
|
+
getDirectories(dir: string): string[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CliFs } from "@tsed/cli-core";
|
|
2
|
+
import type { SourceFile } from "ts-morph";
|
|
3
|
+
import type { RenderDataContext } from "../interfaces/index.js";
|
|
4
|
+
import type { DefineTemplateOptions } from "../utils/defineTemplate.js";
|
|
5
|
+
export type TemplateRenderOptions = {
|
|
6
|
+
name?: string;
|
|
7
|
+
symbolName?: string;
|
|
8
|
+
symbolPath?: string;
|
|
9
|
+
directory?: string;
|
|
10
|
+
from?: string;
|
|
11
|
+
} & Partial<RenderDataContext>;
|
|
12
|
+
export type TemplateRenderReturnType = {
|
|
13
|
+
templateId: string;
|
|
14
|
+
content: string;
|
|
15
|
+
outputPath: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
symbolName?: string;
|
|
18
|
+
symbolPath?: string;
|
|
19
|
+
symbolPathBasename?: string;
|
|
20
|
+
source?: SourceFile;
|
|
21
|
+
};
|
|
22
|
+
export declare class CliTemplatesService {
|
|
23
|
+
readonly rootDir: string;
|
|
24
|
+
readonly fs: CliFs;
|
|
25
|
+
get srcDir(): string;
|
|
26
|
+
find(id?: string): DefineTemplateOptions[];
|
|
27
|
+
get(id: string): DefineTemplateOptions | undefined;
|
|
28
|
+
render(templateId: string, data: TemplateRenderOptions): Promise<TemplateRenderReturnType | undefined>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CliDockerComposeYaml, CliFs, ProjectPackageJson } from "@tsed/cli-core";
|
|
2
|
+
import { type KindToNodeMappings, ObjectLiteralExpression, type OptionalKind, Project, type ProjectOptions, type SourceFile, type SourceFileCreateOptions, type SourceFileStructure, SyntaxKind, type WriterFunction } from "ts-morph";
|
|
3
|
+
export declare class ProjectClient extends Project {
|
|
4
|
+
readonly pkg: ProjectPackageJson;
|
|
5
|
+
readonly fs: CliFs;
|
|
6
|
+
readonly dockerCompose: CliDockerComposeYaml;
|
|
7
|
+
rootDir: string;
|
|
8
|
+
constructor({ rootDir, ...options }: ProjectOptions & {
|
|
9
|
+
rootDir: string;
|
|
10
|
+
});
|
|
11
|
+
get srcDir(): string;
|
|
12
|
+
get serverSourceFile(): SourceFile | undefined;
|
|
13
|
+
get configSourceFile(): SourceFile | undefined;
|
|
14
|
+
get indexSourceFile(): SourceFile | undefined;
|
|
15
|
+
get binSourceFile(): SourceFile | undefined;
|
|
16
|
+
get serverName(): string;
|
|
17
|
+
getSource(path: string): SourceFile | undefined;
|
|
18
|
+
createSource(path: string, sourceFileText?: string | OptionalKind<SourceFileStructure> | WriterFunction, options?: SourceFileCreateOptions): Promise<SourceFile | undefined>;
|
|
19
|
+
findClassDecorator(sourceFile: SourceFile, name: string): import("ts-morph").Decorator | undefined;
|
|
20
|
+
addMountPath(path: string, specifier: string): void;
|
|
21
|
+
addNamespaceImport(sourceFile: SourceFile, moduleSpecifier: string, name: string): import("ts-morph").Identifier | undefined;
|
|
22
|
+
findConfiguration(kind: "server" | "config" | "bin"): ObjectLiteralExpression | undefined;
|
|
23
|
+
getPropertyAssignment<TKind extends SyntaxKind>(input: ObjectLiteralExpression, { name, initializer, kind }: {
|
|
24
|
+
name: string;
|
|
25
|
+
initializer: string | WriterFunction;
|
|
26
|
+
kind: TKind;
|
|
27
|
+
}): KindToNodeMappings[TKind];
|
|
28
|
+
getPropertyAssignment<TKind extends SyntaxKind>(input: ObjectLiteralExpression, { name, initializer, kind }: {
|
|
29
|
+
name: string;
|
|
30
|
+
initializer?: string | WriterFunction;
|
|
31
|
+
kind: TKind;
|
|
32
|
+
}): KindToNodeMappings[TKind] | undefined;
|
|
33
|
+
protected findConfigurationDecorationOptions(): ObjectLiteralExpression | undefined;
|
|
34
|
+
protected findConfigConfiguration(): ObjectLiteralExpression | undefined;
|
|
35
|
+
protected findBinConfiguration(): ObjectLiteralExpression | undefined;
|
|
36
|
+
addConfigSource(name: string, { content, moduleSpecifier }: {
|
|
37
|
+
content?: string;
|
|
38
|
+
moduleSpecifier: string;
|
|
39
|
+
}): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GenerateCmdContext } from "../../interfaces/GenerateCmdContext.js";
|
|
2
|
+
type TemplateOptions = {
|
|
3
|
+
type?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
symbolName?: string;
|
|
6
|
+
symbolPath?: string;
|
|
7
|
+
symbolPathBasename?: string;
|
|
8
|
+
directory?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function mapDefaultTemplateOptions(opts: TemplateOptions): GenerateCmdContext;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "./asyncFactory.template.js";
|
|
2
|
+
import "./command.template.js";
|
|
3
|
+
import "./controller.template.js";
|
|
4
|
+
import "./decorator.template.js";
|
|
5
|
+
import "./exception-filter.template.js";
|
|
6
|
+
import "./factory.template.js";
|
|
7
|
+
import "./interface.template.js";
|
|
8
|
+
import "./interceptor.template.js";
|
|
9
|
+
import "./middleware.template.js";
|
|
10
|
+
import "./model.template.js";
|
|
11
|
+
import "./module.template.js";
|
|
12
|
+
import "./pipe.template.js";
|
|
13
|
+
import "./prisma.service.template.js";
|
|
14
|
+
import "./repository.template.js";
|
|
15
|
+
import "./response-filter.template.js";
|
|
16
|
+
import "./service.template.js";
|
|
17
|
+
import "./value.template.js";
|
|
18
|
+
import "./barrels.template.js";
|
|
19
|
+
import "./server.template.js";
|
|
20
|
+
import "./config.template.js";
|
|
21
|
+
import "./index.template.js";
|
|
22
|
+
import "./index.controller.template.js";
|
|
23
|
+
import "./index.command.template.js";
|
|
24
|
+
import "./index.logger.template.js";
|
|
25
|
+
import "./index.config.utils.template.js";
|
|
26
|
+
import "./tsconfig.template.js";
|
|
27
|
+
import "./tsconfig.spec.template.js";
|
|
28
|
+
import "./docker-compose.template.js";
|
|
29
|
+
import "./dockerfile.template.js";
|
|
30
|
+
import "./pm2.template.js";
|
|
31
|
+
import "./readme.template.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { QuestionOptions } from "@tsed/cli-core";
|
|
2
|
+
import { type ProviderOpts } from "@tsed/di";
|
|
3
|
+
import type { GenerateCmdContext } from "../interfaces/index.js";
|
|
4
|
+
import type { TemplateRenderReturnType } from "../services/CliTemplatesService.js";
|
|
5
|
+
export type DefineTemplateOptions = {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
outputDir: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The file name format without the extension.
|
|
13
|
+
*/
|
|
14
|
+
fileName?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The file extension. Default to `ts`
|
|
17
|
+
* Don't include the dot (.) in the extension.
|
|
18
|
+
*/
|
|
19
|
+
ext?: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* If `true` the template will be hidden in the list of available templates
|
|
22
|
+
* during the generate command.
|
|
23
|
+
*/
|
|
24
|
+
hidden?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* If `true` the file name won't be altered (e.g. `MyService` will always be `MyService.ts`)
|
|
27
|
+
* If `false` the file name will be transformed depending on the project style (e.g. `MyService` could be `my-service.ts`).
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
preserveCase?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* If `true` the directory structure will be preserved when generating the file.
|
|
33
|
+
*/
|
|
34
|
+
preserveDirectory?: boolean;
|
|
35
|
+
render(symbolName: string, data: GenerateCmdContext): Promise<string | undefined | TemplateRenderReturnType> | string | undefined | TemplateRenderReturnType;
|
|
36
|
+
prompts?(data: GenerateCmdContext): QuestionOptions<GenerateCmdContext>[] | Promise<QuestionOptions<GenerateCmdContext>[]>;
|
|
37
|
+
hooks?: ProviderOpts["hooks"];
|
|
38
|
+
};
|
|
39
|
+
export declare function defineTemplate(opts: DefineTemplateOptions): DefineTemplateOptions;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/cli",
|
|
3
3
|
"description": "CLI to bootstrap your Ts.ED project",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0-alpha.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"source": "./src/index.ts",
|
|
@@ -48,30 +48,29 @@
|
|
|
48
48
|
"@swc-node/register": "^1.10.9",
|
|
49
49
|
"@swc/core": "1.7.26",
|
|
50
50
|
"@swc/helpers": "^0.5.13",
|
|
51
|
-
"@tsed/cli-core": "
|
|
52
|
-
"@tsed/core": ">=8.0.
|
|
53
|
-
"@tsed/di": ">=8.0.
|
|
54
|
-
"@tsed/hooks": ">=8.0.
|
|
51
|
+
"@tsed/cli-core": "7.0.0-alpha.2",
|
|
52
|
+
"@tsed/core": ">=8.16.0-rc.1",
|
|
53
|
+
"@tsed/di": ">=8.16.0-rc.1",
|
|
54
|
+
"@tsed/hooks": ">=8.16.0-rc.1",
|
|
55
55
|
"@tsed/logger": ">=8.0.3",
|
|
56
56
|
"@tsed/logger-std": ">=8.0.3",
|
|
57
|
-
"@tsed/normalize-path": ">=8.0.
|
|
58
|
-
"@tsed/openspec": ">=8.0.
|
|
59
|
-
"@tsed/schema": ">=8.0.
|
|
57
|
+
"@tsed/normalize-path": ">=8.16.0-rc.1",
|
|
58
|
+
"@tsed/openspec": ">=8.16.0-rc.1",
|
|
59
|
+
"@tsed/schema": ">=8.16.0-rc.1",
|
|
60
60
|
"chalk": "^5.3.0",
|
|
61
61
|
"change-case": "^5.4.4",
|
|
62
62
|
"consolidate": "^1.0.4",
|
|
63
63
|
"create-frame": "^1.0.0",
|
|
64
64
|
"fs-extra": "^11.2.0",
|
|
65
65
|
"globby": "^14.0.2",
|
|
66
|
-
"handlebars": "^4.7.8",
|
|
67
|
-
"handlebars-utils": "^1.0.6",
|
|
68
66
|
"read-pkg-up": "^11.0.0",
|
|
69
67
|
"rxjs": "^7.8.1",
|
|
70
68
|
"semver": "^7.6.3",
|
|
69
|
+
"ts-morph": "^26.0.0",
|
|
71
70
|
"tslib": "^2.7.0"
|
|
72
71
|
},
|
|
73
72
|
"devDependencies": {
|
|
74
|
-
"@tsed/typescript": "
|
|
73
|
+
"@tsed/typescript": "7.0.0-alpha.2",
|
|
75
74
|
"@types/change-case": "^2.3.1",
|
|
76
75
|
"@types/consolidate": "0.14.4",
|
|
77
76
|
"cross-env": "7.0.3",
|
|
@@ -116,5 +115,8 @@
|
|
|
116
115
|
},
|
|
117
116
|
"homepage": "https://github.com/tsedio/tsed-cli/tree/master/packages/cli",
|
|
118
117
|
"author": "Romain Lenzotti",
|
|
119
|
-
"license": "MIT"
|
|
118
|
+
"license": "MIT",
|
|
119
|
+
"publishConfig": {
|
|
120
|
+
"tag": "alpha"
|
|
121
|
+
}
|
|
120
122
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"paths": {
|
|
6
|
+
"@/*": ["src/*"]
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*"],
|
|
10
|
+
"exclude": ["src/**/*.spec.ts", "dist", "node_modules", "**/helpers/*Fixture.ts", "**/__mock__/**", "coverage"],
|
|
11
|
+
"linterOptions": {
|
|
12
|
+
"exclude": []
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const webpack = require("webpack");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const {NODE_ENV = "development"} = process.env;
|
|
5
|
+
const isProduction = NODE_ENV !== "development";
|
|
6
|
+
const packages = require("./package.json");
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
target: "node",
|
|
10
|
+
devtool: false,
|
|
11
|
+
|
|
12
|
+
externals: [...Object.keys(packages.dependencies || {})],
|
|
13
|
+
|
|
14
|
+
plugins: [
|
|
15
|
+
new webpack.EnvironmentPlugin({
|
|
16
|
+
NODE_ENV,
|
|
17
|
+
WEBPACK_ENV: true
|
|
18
|
+
}),
|
|
19
|
+
!isProduction && new webpack.HotModuleReplacementPlugin()
|
|
20
|
+
].filter(Boolean),
|
|
21
|
+
|
|
22
|
+
entry: [!isProduction && "webpack/hot/poll?1000", path.resolve(path.join(__dirname, "./src/index"))].filter(Boolean),
|
|
23
|
+
|
|
24
|
+
output: {
|
|
25
|
+
path: path.resolve(__dirname, "dist"),
|
|
26
|
+
filename: "app.bundle.js",
|
|
27
|
+
libraryTarget: "commonjs2"
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
resolve: {
|
|
31
|
+
extensions: [".webpack-loader.js", ".web-loader.js", ".loader.js", ".js", ".jsx", ".ts", ".tsx", ".json"],
|
|
32
|
+
modules: [path.join(__dirname, "..", "src"), "node_modules"]
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
module: {
|
|
36
|
+
rules: [
|
|
37
|
+
{
|
|
38
|
+
// Include ts, tsx, js, and jsx files.
|
|
39
|
+
test: /\.(ts|js)x?$/,
|
|
40
|
+
exclude: /node_modules/,
|
|
41
|
+
loader: "babel-loader",
|
|
42
|
+
options: {
|
|
43
|
+
babelrc: true,
|
|
44
|
+
cacheDirectory: true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
node: {
|
|
51
|
+
global: false,
|
|
52
|
+
__filename: false,
|
|
53
|
+
__dirname: false
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
export const PROVIDER_TYPES = [
|
|
2
|
-
{
|
|
3
|
-
name: "Controller",
|
|
4
|
-
value: "controller",
|
|
5
|
-
model: "{{symbolName}}.controller"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
name: "Middleware",
|
|
9
|
-
value: "middleware",
|
|
10
|
-
model: "{{symbolName}}.middleware"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: "Service",
|
|
14
|
-
value: "service",
|
|
15
|
-
baseDir: "services",
|
|
16
|
-
model: "{{symbolName}}.service"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: "Model",
|
|
20
|
-
value: "model",
|
|
21
|
-
model: "{{symbolName}}.model"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: "Interface",
|
|
25
|
-
value: "interface",
|
|
26
|
-
model: "{{symbolName}}.interface?"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: "Decorator",
|
|
30
|
-
value: "decorator",
|
|
31
|
-
model: "{{symbolName}}.decorator?"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "Module",
|
|
35
|
-
value: "module",
|
|
36
|
-
model: "{{symbolName}}.module"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "Pipe",
|
|
40
|
-
value: "pipe",
|
|
41
|
-
baseDir: "pipes",
|
|
42
|
-
model: "{{symbolName}}.pipe"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "Interceptor",
|
|
46
|
-
value: "interceptor",
|
|
47
|
-
baseDir: "interceptors",
|
|
48
|
-
model: "{{symbolName}}.interceptor"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "Async Factory",
|
|
52
|
-
value: "async.factory",
|
|
53
|
-
baseDir: "services",
|
|
54
|
-
model: "{{symbolName}}.factory?"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "Factory",
|
|
58
|
-
value: "factory",
|
|
59
|
-
baseDir: "services",
|
|
60
|
-
model: "{{symbolName}}.factory?"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "Value",
|
|
64
|
-
value: "value",
|
|
65
|
-
baseDir: "services",
|
|
66
|
-
model: "{{symbolName}}.value?"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "Server",
|
|
70
|
-
value: "server",
|
|
71
|
-
model: "{{symbolName}}.server"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: "Exception Filter",
|
|
75
|
-
value: "exception-filter",
|
|
76
|
-
baseDir: "filters",
|
|
77
|
-
model: "{{symbolName}}.exception-filter"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: "Response Filter",
|
|
81
|
-
value: "response-filter",
|
|
82
|
-
baseDir: "filters",
|
|
83
|
-
model: "{{symbolName}}.response-filter"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: "Command",
|
|
87
|
-
value: "command",
|
|
88
|
-
baseDir: "bin",
|
|
89
|
-
model: "{{symbolName}}.command"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: "Prisma Service",
|
|
93
|
-
value: "prisma.service",
|
|
94
|
-
baseDir: "services",
|
|
95
|
-
model: "{{symbolName}}.service"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: "Repository",
|
|
99
|
-
value: "repository",
|
|
100
|
-
baseDir: "services",
|
|
101
|
-
model: "{{symbolName}}.repository"
|
|
102
|
-
}
|
|
103
|
-
];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { PackageManager } from "@tsed/cli-core";
|
|
2
|
-
import { ArchitectureConvention } from "../../../interfaces/ArchitectureConvention.js";
|
|
3
|
-
import { PlatformType } from "../../../interfaces/PlatformType.js";
|
|
4
|
-
import { ProjectConvention } from "../../../interfaces/ProjectConvention.js";
|
|
5
|
-
import { FeatureType } from "../config/FeaturesPrompt.js";
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { Injectable, nameOf, Type } from "@tsed/cli-core";
|
|
3
|
-
let ProvidersInfoService = class ProvidersInfoService {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.map = new Map();
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param providerInfo
|
|
10
|
-
* @param owner
|
|
11
|
-
*/
|
|
12
|
-
add(providerInfo, owner) {
|
|
13
|
-
this.map.set(providerInfo.value, {
|
|
14
|
-
...providerInfo,
|
|
15
|
-
owner: nameOf(owner)
|
|
16
|
-
});
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
get(value) {
|
|
20
|
-
return this.map.get(value);
|
|
21
|
-
}
|
|
22
|
-
isMyProvider(value, owner) {
|
|
23
|
-
return this.map.get(value)?.owner === nameOf(owner);
|
|
24
|
-
}
|
|
25
|
-
toArray() {
|
|
26
|
-
return Array.from(this.map.values());
|
|
27
|
-
}
|
|
28
|
-
findProviders(type) {
|
|
29
|
-
const providers = this.toArray();
|
|
30
|
-
if (!type) {
|
|
31
|
-
return providers;
|
|
32
|
-
}
|
|
33
|
-
type = type.toLowerCase();
|
|
34
|
-
if (this.get(type)) {
|
|
35
|
-
return [this.get(type)];
|
|
36
|
-
}
|
|
37
|
-
const proposedProviders = providers.filter((provider) => {
|
|
38
|
-
return provider.name.toLowerCase().includes(type) || provider.value.includes(type);
|
|
39
|
-
});
|
|
40
|
-
return proposedProviders.length ? proposedProviders : providers;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
ProvidersInfoService = __decorate([
|
|
44
|
-
Injectable()
|
|
45
|
-
], ProvidersInfoService);
|
|
46
|
-
export { ProvidersInfoService };
|