@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,236 +0,0 @@
|
|
|
1
|
-
import { getValue, isNumber, isObject } from "@tsed/core";
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import createFrame from "create-frame";
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import util from "handlebars-utils";
|
|
6
|
-
import { helpers as array } from "./array.js";
|
|
7
|
-
const hasOwn = Object.hasOwnProperty;
|
|
8
|
-
export const helpers = {};
|
|
9
|
-
/**
|
|
10
|
-
* Extend the context with the properties of other objects.
|
|
11
|
-
* A shallow merge is performed to avoid mutating the context.
|
|
12
|
-
*
|
|
13
|
-
* @param {Object} `objects` One or more objects to extend.
|
|
14
|
-
* @return {Object}
|
|
15
|
-
* @api public
|
|
16
|
-
*/
|
|
17
|
-
helpers.extend = function ( /*objects*/) {
|
|
18
|
-
const args = [].slice.call(arguments);
|
|
19
|
-
let opts = {};
|
|
20
|
-
if (util.isOptions(args[args.length - 1])) {
|
|
21
|
-
// remove handlebars options object
|
|
22
|
-
opts = args.pop().hash;
|
|
23
|
-
// re-add handlebars options.hash object
|
|
24
|
-
args.push(opts);
|
|
25
|
-
}
|
|
26
|
-
const context = {};
|
|
27
|
-
for (let i = 0; i < args.length; i++) {
|
|
28
|
-
const obj = args[i];
|
|
29
|
-
if (util.isObject(obj)) {
|
|
30
|
-
const keys = Object.keys(obj);
|
|
31
|
-
for (let j = 0; j < keys.length; j++) {
|
|
32
|
-
const key = keys[j];
|
|
33
|
-
context[key] = obj[key];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return context;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Block helper that iterates over the properties of
|
|
41
|
-
* an object, exposing each key and value on the context.
|
|
42
|
-
*
|
|
43
|
-
* @param {Object} `context`
|
|
44
|
-
* @param {Object} `options`
|
|
45
|
-
* @return {String}
|
|
46
|
-
* @block
|
|
47
|
-
* @api public
|
|
48
|
-
*/
|
|
49
|
-
helpers.forIn = function (obj, options) {
|
|
50
|
-
if (!util.isOptions(options)) {
|
|
51
|
-
return obj.inverse(this);
|
|
52
|
-
}
|
|
53
|
-
const data = createFrame(options, options.hash);
|
|
54
|
-
let result = "";
|
|
55
|
-
for (const key in obj) {
|
|
56
|
-
data.key = key;
|
|
57
|
-
result += options.fn(obj[key], { data: data });
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Block helper that iterates over the **own** properties of
|
|
63
|
-
* an object, exposing each key and value on the context.
|
|
64
|
-
*
|
|
65
|
-
* @param {Object} `obj` The object to iterate over.
|
|
66
|
-
* @param {Object} `options`
|
|
67
|
-
* @return {String}
|
|
68
|
-
* @block
|
|
69
|
-
* @api public
|
|
70
|
-
*/
|
|
71
|
-
helpers.forOwn = function (obj, options) {
|
|
72
|
-
if (!util.isOptions(options)) {
|
|
73
|
-
return obj.inverse(this);
|
|
74
|
-
}
|
|
75
|
-
const data = createFrame(options, options.hash);
|
|
76
|
-
let result = "";
|
|
77
|
-
for (const key in obj) {
|
|
78
|
-
if (obj.hasOwnProperty(key)) {
|
|
79
|
-
data.key = key;
|
|
80
|
-
result += options.fn(obj[key], { data: data });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Take arguments and, if they are string or number, convert them to a dot-delineated object property path.
|
|
87
|
-
*
|
|
88
|
-
* @param {String|Number} `prop` The property segments to assemble (can be multiple).
|
|
89
|
-
* @return {String}
|
|
90
|
-
* @api public
|
|
91
|
-
*/
|
|
92
|
-
helpers.toPath = function (...args) {
|
|
93
|
-
const prop = [];
|
|
94
|
-
for (let i = 0; i < arguments.length; i++) {
|
|
95
|
-
if (typeof args[i] === "string" || typeof args[i] === "number") {
|
|
96
|
-
prop.push(args[i]);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return prop.join(".");
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Use property paths (`a.b.c`) to get a value or nested value from
|
|
103
|
-
* the context. Works as a regular helper or block helper.
|
|
104
|
-
*
|
|
105
|
-
* @param {String} `prop` The property to get, optionally using dot notation for nested properties.
|
|
106
|
-
* @param {Object} `context` The context object
|
|
107
|
-
* @param {Object} `options` The handlebars options object, if used as a block helper.
|
|
108
|
-
* @return {String}
|
|
109
|
-
* @block
|
|
110
|
-
* @api public
|
|
111
|
-
*/
|
|
112
|
-
helpers.get = function (prop, context, options) {
|
|
113
|
-
const val = getValue(context, prop);
|
|
114
|
-
if (options && options.fn) {
|
|
115
|
-
return val ? options.fn(val) : options.inverse(context);
|
|
116
|
-
}
|
|
117
|
-
return val;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Return true if `key` is an own, enumerable property
|
|
121
|
-
* of the given `context` object.
|
|
122
|
-
*
|
|
123
|
-
* ```handlebars
|
|
124
|
-
* {{hasOwn context key}}
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
* @param {String} `key`
|
|
128
|
-
* @param {Object} `context` The context object.
|
|
129
|
-
* @return {Boolean}
|
|
130
|
-
* @api public
|
|
131
|
-
*/
|
|
132
|
-
helpers.hasOwn = function (context, key) {
|
|
133
|
-
return hasOwn.call(context, key);
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Return true if `value` is an object.
|
|
137
|
-
*
|
|
138
|
-
* ```handlebars
|
|
139
|
-
* {{isObject "foo"}}
|
|
140
|
-
* //=> false
|
|
141
|
-
* ```
|
|
142
|
-
* @param {String} `value`
|
|
143
|
-
* @return {Boolean}
|
|
144
|
-
* @api public
|
|
145
|
-
*/
|
|
146
|
-
helpers.isObject = isObject;
|
|
147
|
-
/**
|
|
148
|
-
* Parses the given string using `JSON.parse`.
|
|
149
|
-
*
|
|
150
|
-
* ```handlebars
|
|
151
|
-
* <!-- string: '{"foo": "bar"}' -->
|
|
152
|
-
* {{JSONparse string}}
|
|
153
|
-
* <!-- results in: { foo: 'bar' } -->
|
|
154
|
-
* ```
|
|
155
|
-
* @param {String} `string` The string to parse
|
|
156
|
-
* @contributor github.com/keeganstreet
|
|
157
|
-
* @block
|
|
158
|
-
* @api public
|
|
159
|
-
*/
|
|
160
|
-
helpers.JSONparse = function (str) {
|
|
161
|
-
return JSON.parse(str);
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Stringify an object using `JSON.stringify`.
|
|
165
|
-
*
|
|
166
|
-
* ```handlebars
|
|
167
|
-
* <!-- object: { foo: 'bar' } -->
|
|
168
|
-
* {{JSONstringify object}}
|
|
169
|
-
* <!-- results in: '{"foo": "bar"}' -->
|
|
170
|
-
* ```
|
|
171
|
-
* @param {Object} `obj` Object to stringify
|
|
172
|
-
* @return {String}
|
|
173
|
-
* @api public
|
|
174
|
-
*/
|
|
175
|
-
helpers.JSONstringify = function (obj, indent) {
|
|
176
|
-
if (!isNumber(indent)) {
|
|
177
|
-
indent = 0;
|
|
178
|
-
}
|
|
179
|
-
return JSON.stringify(obj, null, indent);
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Deeply merge the properties of the given `objects` with the
|
|
183
|
-
* context object.
|
|
184
|
-
*
|
|
185
|
-
* @param {Object} `object` The target object. Pass an empty object to shallow clone.
|
|
186
|
-
* @param {Object} `objects`
|
|
187
|
-
* @return {Object}
|
|
188
|
-
* @api public
|
|
189
|
-
*/
|
|
190
|
-
helpers.merge = function (...args1) {
|
|
191
|
-
const args = [].slice.call(args1);
|
|
192
|
-
let opts = {};
|
|
193
|
-
if (util.isOptions(args[args.length - 1])) {
|
|
194
|
-
// remove handlebars options object
|
|
195
|
-
opts = args.pop().hash;
|
|
196
|
-
// re-add options.hash
|
|
197
|
-
args.push(opts);
|
|
198
|
-
}
|
|
199
|
-
return Object.assign.apply(null, args);
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* Alias for parseJSON. this will be
|
|
203
|
-
* deprecated in a future release
|
|
204
|
-
*/
|
|
205
|
-
helpers.parseJSON = helpers.JSONparse;
|
|
206
|
-
/**
|
|
207
|
-
* Pick properties from the context object.
|
|
208
|
-
*
|
|
209
|
-
* @param {Array|String} `properties` One or more properties to pick.
|
|
210
|
-
* @param {Object} `context`
|
|
211
|
-
* @param {Object} `options` Handlebars options object.
|
|
212
|
-
* @return {Object} Returns an object with the picked values. If used as a block helper, the values are passed as context to the inner block. If no values are found, the context is passed to the inverse block.
|
|
213
|
-
* @block
|
|
214
|
-
* @api public
|
|
215
|
-
*/
|
|
216
|
-
helpers.pick = function (props, context, options) {
|
|
217
|
-
const keys = array.arrayify(props);
|
|
218
|
-
const len = keys.length;
|
|
219
|
-
let i = -1;
|
|
220
|
-
let result = {};
|
|
221
|
-
while (++i < len) {
|
|
222
|
-
result = helpers.extend({}, result, getValue(context, keys[i]));
|
|
223
|
-
}
|
|
224
|
-
if (options.fn) {
|
|
225
|
-
if (Object.keys(result).length) {
|
|
226
|
-
return options.fn(result);
|
|
227
|
-
}
|
|
228
|
-
return options.inverse(context);
|
|
229
|
-
}
|
|
230
|
-
return result;
|
|
231
|
-
};
|
|
232
|
-
/**
|
|
233
|
-
* Alias for JSONstringify. this will be
|
|
234
|
-
* deprecated in a future release
|
|
235
|
-
*/
|
|
236
|
-
helpers.stringify = helpers.JSONstringify;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function insertAfter(fileContent, content, pattern) {
|
|
2
|
-
const lines = fileContent.split("\n");
|
|
3
|
-
const index = lines.findIndex((line) => {
|
|
4
|
-
return line.match(pattern);
|
|
5
|
-
});
|
|
6
|
-
const indent = lines[index].replace(lines[index].trim(), "");
|
|
7
|
-
lines[index] = lines[index] + "\n" + indent + content;
|
|
8
|
-
if (!["]", "}"].includes(lines[index + 1].trim()) && lines[index - 1].slice(-1) === ",") {
|
|
9
|
-
lines[index] += ",";
|
|
10
|
-
}
|
|
11
|
-
return lines.join("\n");
|
|
12
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function insertImport(fileContent, content) {
|
|
2
|
-
const lines = fileContent.split("\n");
|
|
3
|
-
const index = lines.findIndex((line) => {
|
|
4
|
-
if (line.startsWith("#!")) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
return !line.startsWith("import ");
|
|
8
|
-
});
|
|
9
|
-
lines[index] = content + "\n" + lines[index];
|
|
10
|
-
return lines.join("\n");
|
|
11
|
-
}
|
|
@@ -1,20 +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";
|
|
6
|
-
export interface InitOptions {
|
|
7
|
-
root: string;
|
|
8
|
-
projectName: string;
|
|
9
|
-
features: FeatureType[];
|
|
10
|
-
skipPrompt: boolean;
|
|
11
|
-
platform: PlatformType;
|
|
12
|
-
tsedVersion: string;
|
|
13
|
-
cliVersion: string;
|
|
14
|
-
architecture: ArchitectureConvention;
|
|
15
|
-
convention: ProjectConvention;
|
|
16
|
-
packageManager: PackageManager;
|
|
17
|
-
runtime: "node" | "babel" | "swc" | "webpack" | "bun";
|
|
18
|
-
oidcBasePath: string;
|
|
19
|
-
file: string;
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/cli-core";
|
|
2
|
-
export interface ProviderInfo {
|
|
3
|
-
name: string;
|
|
4
|
-
value: string;
|
|
5
|
-
model?: string;
|
|
6
|
-
baseDir?: string;
|
|
7
|
-
owner?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare class ProvidersInfoService {
|
|
10
|
-
readonly map: Map<string, ProviderInfo>;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param providerInfo
|
|
14
|
-
* @param owner
|
|
15
|
-
*/
|
|
16
|
-
add(providerInfo: ProviderInfo, owner?: Type<any>): this;
|
|
17
|
-
get(value: string): any;
|
|
18
|
-
isMyProvider(value: string, owner: Type<any>): boolean;
|
|
19
|
-
toArray(): ProviderInfo[];
|
|
20
|
-
findProviders(type: string | undefined): ProviderInfo[];
|
|
21
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import "../utils/hbs/index.js";
|
|
2
|
-
import { CliFs } from "@tsed/cli-core";
|
|
3
|
-
import { Observable } from "rxjs";
|
|
4
|
-
export interface RenderOptions {
|
|
5
|
-
path: string;
|
|
6
|
-
templateDir: string;
|
|
7
|
-
rootDir: string;
|
|
8
|
-
output: string;
|
|
9
|
-
baseDir: string;
|
|
10
|
-
basename: string;
|
|
11
|
-
replaces?: string[];
|
|
12
|
-
}
|
|
13
|
-
export declare abstract class Renderer {
|
|
14
|
-
templateDir: string;
|
|
15
|
-
readonly fs: CliFs;
|
|
16
|
-
readonly cache: Set<string>;
|
|
17
|
-
abstract get rootDir(): string;
|
|
18
|
-
loadPartials(cwd: string): Promise<void>;
|
|
19
|
-
render(path: string, data: any, options?: Partial<RenderOptions>): Promise<void>;
|
|
20
|
-
renderAll(paths: (string | RenderOptions)[], data: any, options?: Partial<RenderOptions>): Observable<unknown>;
|
|
21
|
-
write(content: string, options: any): Promise<void>;
|
|
22
|
-
templateExists(path: string, options?: Partial<RenderOptions>): boolean;
|
|
23
|
-
scan(pattern: string[], options?: any): Promise<string[]>;
|
|
24
|
-
relativeFrom(path: string): string;
|
|
25
|
-
update(path: string, actions: {
|
|
26
|
-
type?: string;
|
|
27
|
-
content: string;
|
|
28
|
-
pattern?: RegExp;
|
|
29
|
-
}[]): Promise<void>;
|
|
30
|
-
protected mapOptions(path: string, options: Partial<RenderOptions>): {
|
|
31
|
-
output: string;
|
|
32
|
-
templateDir: string;
|
|
33
|
-
rootDir: string;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export declare class RootRendererService extends Renderer {
|
|
37
|
-
get rootDir(): string;
|
|
38
|
-
}
|
|
39
|
-
export declare class SrcRendererService extends Renderer {
|
|
40
|
-
get rootDir(): string;
|
|
41
|
-
}
|
|
42
|
-
export declare class ScriptsRendererService extends Renderer {
|
|
43
|
-
get rootDir(): string;
|
|
44
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function fillImports(ctx: any): any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const helpers: any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const helpers: any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const helpers: any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const helpers: any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const helpers: any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function insertAfter(fileContent: string, content: string, pattern: RegExp): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function insertImport(fileContent: string, content: string): string;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {Configuration, Inject, registerProvider} from "@tsed/di";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Inject {{symbolName}} to the service, controller, etc...
|
|
5
|
-
*
|
|
6
|
-
* ## Usage
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import {Injectable} from "@tsed/di";
|
|
10
|
-
* import {{{symbolName}}} from "./{{symbolName}}";
|
|
11
|
-
*
|
|
12
|
-
* @Injectable()
|
|
13
|
-
* class MyService {
|
|
14
|
-
* @{{symbolName}}()
|
|
15
|
-
* private factory: {{symbolName}};
|
|
16
|
-
*
|
|
17
|
-
* // or
|
|
18
|
-
* constructor(@{{symbolName}}() private factory: {{symbolName}}){}
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* @decorator
|
|
22
|
-
*/
|
|
23
|
-
export function {{symbolName}}() {
|
|
24
|
-
return Inject({{symbolName}});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type {{symbolName}} = any; // implement type or interface for type checking
|
|
28
|
-
|
|
29
|
-
registerProvider({
|
|
30
|
-
provide: {{symbolName}},
|
|
31
|
-
deps: [Configuration],
|
|
32
|
-
async useAsyncFactory(settings: Configuration) {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {Command, CommandProvider, QuestionOptions} from "@tsed/cli-core";
|
|
2
|
-
|
|
3
|
-
export interface {{symbolName}}Context {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
@Command({
|
|
7
|
-
name: "{{symbolParamName}}",
|
|
8
|
-
description: "Command description",
|
|
9
|
-
args: {
|
|
10
|
-
},
|
|
11
|
-
options: {
|
|
12
|
-
},
|
|
13
|
-
allowUnknownOption: false
|
|
14
|
-
})
|
|
15
|
-
export class {{symbolName}} implements CommandProvider {
|
|
16
|
-
/**
|
|
17
|
-
* Ask questions with Inquirer. Return an empty array or don't implement the method to skip this step
|
|
18
|
-
*/
|
|
19
|
-
async $prompt(initialOptions: Partial<{{symbolName}}Context>): Promise<QuestionOptions> {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* This method is called after the $prompt to create / map inputs to a proper context for the next step
|
|
25
|
-
*/
|
|
26
|
-
$mapContext(ctx: Partial<{{symbolName}}Context>): {{symbolName}}Context {
|
|
27
|
-
return {
|
|
28
|
-
...ctx
|
|
29
|
-
// map something, based on ctx
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* This step run your tasks with Listr module
|
|
34
|
-
*/
|
|
35
|
-
async $exec(ctx: {{symbolName}}Context): Promise<any> {
|
|
36
|
-
return [
|
|
37
|
-
{
|
|
38
|
-
title: "Do something",
|
|
39
|
-
task: () => {
|
|
40
|
-
console.log('HELLO')
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export interface {{symbolName}}Options {
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function {{symbolName}}(options: {{symbolName}}Options): ClassDecorator {
|
|
7
|
-
return (target: any): any => {
|
|
8
|
-
return class extends target {
|
|
9
|
-
constructor(...args: any[]) {
|
|
10
|
-
super(...args);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {useDecorators} from "@tsed/core";
|
|
2
|
-
import {JsonEntityFn, JsonEntityStore} from "@tsed/schema";
|
|
3
|
-
|
|
4
|
-
export interface {{symbolName}}Options {
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function {{symbolName}}(options: {{symbolName}}Options): MethodDecorator {
|
|
9
|
-
return useDecorators(
|
|
10
|
-
JsonEntityFn((entity: JsonEntityStore) => {
|
|
11
|
-
entity.store.set({{symbolName}}, options);
|
|
12
|
-
})
|
|
13
|
-
// add other decorator like Use(), UseBefore, UseAuth, etc...
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {DecoratorTypes, UnsupportedDecoratorType, decoratorTypeOf} from "@tsed/core";
|
|
2
|
-
|
|
3
|
-
export interface {{symbolName}}Options {
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function {{symbolName}}(options: {{symbolName}}Options): any {
|
|
8
|
-
return (...args: DecoratorParameters): any => {
|
|
9
|
-
switch(decoratorTypeOf(args)) {
|
|
10
|
-
case DecoratorTypes.CLASS:
|
|
11
|
-
case DecoratorTypes.PROP:
|
|
12
|
-
console.log("do something")
|
|
13
|
-
break;
|
|
14
|
-
|
|
15
|
-
default:
|
|
16
|
-
throw new UnsupportedDecoratorType({{symbolName}}, args);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface {{symbolName}}Options {
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function {{symbolName}}(options: {{symbolName}}Options): MethodDecorator {
|
|
6
|
-
return <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {
|
|
7
|
-
const originalMethod = descriptor.value;
|
|
8
|
-
|
|
9
|
-
descriptor.value = function wrappedMethod (...args: any[]) {
|
|
10
|
-
// do something before
|
|
11
|
-
const result = originalMethod.apply(this, args)
|
|
12
|
-
// do something after
|
|
13
|
-
return result
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {useDecorators, StoreSet} from "@tsed/core";
|
|
2
|
-
import {Middleware{{#eq middlewarePosition "before"}}, UseBefore{{/eq}}{{#eq middlewarePosition "after"}}, UseAfter{{/eq}}\} from "@tsed/platform-middlewares";
|
|
3
|
-
import {Context} from "@tsed/platform-params";
|
|
4
|
-
import {Req, Res} from "@tsed/platform-http";
|
|
5
|
-
|
|
6
|
-
export interface {{symbolName}}Options {
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@Middleware()
|
|
11
|
-
export class {{symbolName}}Middleware {
|
|
12
|
-
use(@Req() req: Req, @Res() res: Res, @Context() context: Context) {
|
|
13
|
-
const {}: {{symbolName}}Options = context.endpoint.get({{symbolName}}Middleware);
|
|
14
|
-
//do something{{#eq middlewarePosition "after"}}
|
|
15
|
-
const data = context.data;
|
|
16
|
-
// do something with data and return data
|
|
17
|
-
return data{{/eq}}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function {{symbolName}}(options: {{symbolName}}Options): MethodDecorator {
|
|
22
|
-
return useDecorators(
|
|
23
|
-
StoreSet({{symbolName}}Middleware, options),
|
|
24
|
-
{{#eq middlewarePosition "before"}}UseBefore({{symbolName}}Middleware){{/eq}}{{#eq middlewarePosition "after"}}UseAfter({{symbolName}}Middleware){{/eq}}
|
|
25
|
-
);
|
|
26
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {useDecorators} from "@tsed/core";
|
|
2
|
-
import {ParamMetadata, ParamFn} from "@tsed/platform-params";
|
|
3
|
-
|
|
4
|
-
export interface {{symbolName}}Options {
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function {{symbolName}}(options: {{symbolName}}Options): ParameterDecorator {
|
|
9
|
-
return useDecorators(
|
|
10
|
-
ParamFn((param: ParamMetadata) => {
|
|
11
|
-
param.store.set({{symbolName}}, options)
|
|
12
|
-
})
|
|
13
|
-
// Add UsePipe decorator to invoke custom pipe on the parameter
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {useDecorators} from "@tsed/core";
|
|
2
|
-
import {JsonEntityFn, JsonEntityStore} from "@tsed/schema";
|
|
3
|
-
|
|
4
|
-
export interface {{symbolName}}Options {
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function {{symbolName}}(options: {{symbolName}}Options): PropertyDecorator {
|
|
9
|
-
return useDecorators(
|
|
10
|
-
JsonEntityFn((entity: JsonEntityStore) => {
|
|
11
|
-
|
|
12
|
-
})
|
|
13
|
-
);
|
|
14
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {constant, injectable} from "@tsed/di";
|
|
2
|
-
|
|
3
|
-
export type {{symbolName}} = any; // implement type or interface for type checking
|
|
4
|
-
export const {{symbolName}} = injectable(Symbol.for("{{symbolName}}")
|
|
5
|
-
.factory(() => {
|
|
6
|
-
// retrieve custom configuration from settings (e.g.: `@Configuration({hello: "value"})`)
|
|
7
|
-
const hello = constant("hello");
|
|
8
|
-
|
|
9
|
-
return {hello};
|
|
10
|
-
})
|
|
11
|
-
.token();
|