@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.
Files changed (246) hide show
  1. package/lib/esm/commands/add/AddCmd.js +16 -16
  2. package/lib/esm/commands/generate/GenerateCmd.js +69 -222
  3. package/lib/esm/commands/generate/mappers/mapGenerateContext.js +29 -0
  4. package/lib/esm/commands/init/InitCmd.js +190 -171
  5. package/lib/esm/commands/init/config/FeaturesPrompt.js +101 -3
  6. package/lib/esm/commands/init/mappers/mapToContext.js +4 -3
  7. package/lib/esm/commands/run/RunCmd.js +22 -26
  8. package/lib/esm/commands/update/UpdateCmd.js +9 -13
  9. package/lib/esm/fn/exec.js +5 -0
  10. package/lib/esm/fn/render.js +5 -0
  11. package/lib/esm/fn/taskOutput.js +7 -0
  12. package/lib/esm/index.js +7 -4
  13. package/lib/esm/interfaces/AlterPackageJson.js +1 -0
  14. package/lib/esm/interfaces/AlterProjectFiles.js +1 -0
  15. package/lib/esm/interfaces/AlterRenderFiles.js +1 -0
  16. package/lib/esm/interfaces/CliCommandHooks.js +1 -0
  17. package/lib/esm/interfaces/GenerateCmdContext.js +1 -0
  18. package/lib/esm/interfaces/InitCmdOptions.js +1 -0
  19. package/lib/esm/interfaces/RenderDataContext.js +1 -0
  20. package/lib/esm/interfaces/RuntimeTypes.js +1 -0
  21. package/lib/esm/interfaces/index.js +9 -0
  22. package/lib/esm/pipes/OutputFilePathPipe.js +40 -18
  23. package/lib/esm/pipes/RoutePipe.js +4 -8
  24. package/lib/esm/pipes/{ClassNamePipe.js → SymbolNamePipe.js} +14 -11
  25. package/lib/esm/pipes/index.js +1 -1
  26. package/lib/esm/platforms/{InitPlatformsModule.js → PlatformsModule.js} +4 -10
  27. package/lib/esm/platforms/supports/InitExpressPlatform.js +27 -10
  28. package/lib/esm/platforms/supports/InitFastifyPlatform.js +27 -10
  29. package/lib/esm/platforms/supports/InitKoaPlatform.js +16 -10
  30. package/lib/esm/processors/__fixtures__/createFakeProject.js +35 -0
  31. package/lib/esm/processors/transformBinFile.js +47 -0
  32. package/lib/esm/processors/transformConfigFile.js +105 -0
  33. package/lib/esm/processors/transformIndexFile.js +23 -0
  34. package/lib/esm/processors/transformServerFile.js +60 -0
  35. package/lib/esm/runtimes/RuntimesModule.js +7 -17
  36. package/lib/esm/runtimes/supports/BabelRuntime.js +5 -11
  37. package/lib/esm/runtimes/supports/BunRuntime.js +4 -10
  38. package/lib/esm/runtimes/supports/NodeRuntime.js +1 -1
  39. package/lib/esm/runtimes/supports/WebpackRuntime.js +1 -1
  40. package/lib/esm/services/CliProjectService.js +96 -0
  41. package/lib/esm/services/CliRunScript.js +4 -8
  42. package/lib/esm/services/CliTemplatesService.js +68 -0
  43. package/lib/esm/services/ProjectClient.js +161 -0
  44. package/lib/esm/services/mappers/mapDefaultTemplateOptions.js +30 -0
  45. package/lib/esm/templates/asyncFactory.template.js +38 -0
  46. package/lib/esm/templates/barrels.template.js +22 -0
  47. package/lib/esm/templates/command.template.js +56 -0
  48. package/lib/esm/templates/config.template.js +27 -0
  49. package/lib/esm/templates/controller.template.js +45 -0
  50. package/lib/esm/templates/decorator.template.js +182 -0
  51. package/lib/esm/templates/docker-compose.template.js +25 -0
  52. package/lib/esm/templates/dockerfile.template.js +236 -0
  53. package/lib/esm/templates/exception-filter.template.js +19 -0
  54. package/lib/esm/templates/factory.template.js +37 -0
  55. package/lib/esm/templates/index.command.template.js +18 -0
  56. package/lib/esm/templates/index.config.utils.template.js +17 -0
  57. package/{templates/init/src/controllers/pages/IndexController.ts.hbs → lib/esm/templates/index.controller.template.js} +14 -3
  58. package/lib/esm/templates/index.js +32 -0
  59. package/lib/esm/templates/index.logger.template.js +38 -0
  60. package/{templates/init/src/index.ts.hbs → lib/esm/templates/index.template.js} +17 -5
  61. package/lib/esm/templates/interceptor.template.js +31 -0
  62. package/lib/esm/templates/interface.template.js +13 -0
  63. package/lib/esm/templates/middleware.template.js +34 -0
  64. package/lib/esm/templates/model.template.js +16 -0
  65. package/lib/esm/templates/module.template.js +16 -0
  66. package/lib/esm/templates/pipe.template.js +19 -0
  67. package/lib/esm/templates/pm2.template.js +111 -0
  68. package/lib/esm/templates/prisma.service.template.js +23 -0
  69. package/{templates/init/README.md.hbs → lib/esm/templates/readme.template.js} +28 -13
  70. package/lib/esm/templates/repository.template.js +16 -0
  71. package/lib/esm/templates/response-filter.template.js +19 -0
  72. package/lib/esm/templates/server.template.js +37 -0
  73. package/lib/esm/templates/service.template.js +16 -0
  74. package/lib/esm/templates/tsconfig.spec.template.js +34 -0
  75. package/lib/esm/templates/tsconfig.template.js +31 -0
  76. package/lib/esm/templates/value.template.js +13 -0
  77. package/lib/esm/utils/defineTemplate.js +13 -0
  78. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  79. package/lib/types/commands/add/AddCmd.d.ts +2 -2
  80. package/lib/types/commands/generate/GenerateCmd.d.ts +33 -87
  81. package/lib/types/commands/generate/mappers/mapGenerateContext.d.ts +2 -0
  82. package/lib/types/commands/init/InitCmd.d.ts +18 -20
  83. package/lib/types/commands/init/config/FeaturesPrompt.d.ts +11 -2
  84. package/lib/types/commands/init/mappers/mapToContext.d.ts +2 -2
  85. package/lib/types/commands/init/mappers/mapUniqFeatures.d.ts +1 -1
  86. package/lib/types/commands/init/prompts/getFeaturesPrompt.d.ts +1 -1
  87. package/lib/types/commands/update/UpdateCmd.d.ts +2 -2
  88. package/lib/types/fn/exec.d.ts +1 -0
  89. package/lib/types/fn/render.d.ts +2 -0
  90. package/lib/types/fn/taskOutput.d.ts +1 -0
  91. package/lib/types/index.d.ts +7 -4
  92. package/lib/types/interfaces/AlterGenerateTasks.d.ts +5 -0
  93. package/lib/types/interfaces/AlterInitSubTasks.d.ts +5 -0
  94. package/lib/types/interfaces/AlterPackageJson.d.ts +5 -0
  95. package/lib/types/interfaces/AlterProjectFiles.d.ts +5 -0
  96. package/lib/types/interfaces/AlterRenderFiles.d.ts +10 -0
  97. package/lib/types/interfaces/CliCommandHooks.d.ts +11 -0
  98. package/lib/types/interfaces/GenerateCmdContext.d.ts +19 -0
  99. package/lib/types/interfaces/InitCmdOptions.d.ts +8 -0
  100. package/lib/types/interfaces/PlatformType.d.ts +7 -0
  101. package/lib/types/interfaces/RenderDataContext.d.ts +61 -0
  102. package/lib/types/interfaces/RuntimeTypes.d.ts +8 -0
  103. package/lib/types/interfaces/index.d.ts +9 -0
  104. package/lib/types/pipes/OutputFilePathPipe.d.ts +7 -4
  105. package/lib/types/pipes/{ClassNamePipe.d.ts → SymbolNamePipe.d.ts} +3 -3
  106. package/lib/types/pipes/index.d.ts +1 -1
  107. package/lib/types/platforms/{InitPlatformsModule.d.ts → PlatformsModule.d.ts} +1 -1
  108. package/lib/types/platforms/supports/InitBasePlatform.d.ts +3 -0
  109. package/lib/types/platforms/supports/InitExpressPlatform.d.ts +2 -0
  110. package/lib/types/platforms/supports/InitFastifyPlatform.d.ts +2 -0
  111. package/lib/types/platforms/supports/InitKoaPlatform.d.ts +2 -0
  112. package/lib/types/processors/__fixtures__/createFakeProject.d.ts +5 -0
  113. package/lib/types/processors/transformBinFile.d.ts +3 -0
  114. package/lib/types/processors/transformConfigFile.d.ts +3 -0
  115. package/lib/types/processors/transformIndexFile.d.ts +3 -0
  116. package/lib/types/processors/transformServerFile.d.ts +3 -0
  117. package/lib/types/runtimes/RuntimesModule.d.ts +5 -5
  118. package/lib/types/services/CliProjectService.d.ts +16 -0
  119. package/lib/types/services/CliTemplatesService.d.ts +29 -0
  120. package/lib/types/services/ProjectClient.d.ts +40 -0
  121. package/lib/types/services/mappers/mapDefaultTemplateOptions.d.ts +11 -0
  122. package/lib/types/templates/asyncFactory.template.d.ts +2 -0
  123. package/lib/types/templates/barrels.template.d.ts +2 -0
  124. package/lib/types/templates/command.template.d.ts +2 -0
  125. package/lib/types/templates/config.template.d.ts +2 -0
  126. package/lib/types/templates/controller.template.d.ts +2 -0
  127. package/lib/types/templates/decorator.template.d.ts +2 -0
  128. package/lib/types/templates/docker-compose.template.d.ts +2 -0
  129. package/lib/types/templates/dockerfile.template.d.ts +1 -0
  130. package/lib/types/templates/exception-filter.template.d.ts +2 -0
  131. package/lib/types/templates/factory.template.d.ts +2 -0
  132. package/lib/types/templates/index.command.template.d.ts +2 -0
  133. package/lib/types/templates/index.config.utils.template.d.ts +2 -0
  134. package/lib/types/templates/index.controller.template.d.ts +2 -0
  135. package/lib/types/templates/index.d.ts +31 -0
  136. package/lib/types/templates/index.logger.template.d.ts +2 -0
  137. package/lib/types/templates/index.template.d.ts +2 -0
  138. package/lib/types/templates/interceptor.template.d.ts +2 -0
  139. package/lib/types/templates/interface.template.d.ts +2 -0
  140. package/lib/types/templates/middleware.template.d.ts +2 -0
  141. package/lib/types/templates/model.template.d.ts +2 -0
  142. package/lib/types/templates/module.template.d.ts +2 -0
  143. package/lib/types/templates/pipe.template.d.ts +2 -0
  144. package/lib/types/templates/pm2.template.d.ts +1 -0
  145. package/lib/types/templates/prisma.service.template.d.ts +2 -0
  146. package/lib/types/templates/readme.template.d.ts +2 -0
  147. package/lib/types/templates/repository.template.d.ts +2 -0
  148. package/lib/types/templates/response-filter.template.d.ts +2 -0
  149. package/lib/types/templates/server.template.d.ts +2 -0
  150. package/lib/types/templates/service.template.d.ts +2 -0
  151. package/lib/types/templates/tsconfig.spec.template.d.ts +2 -0
  152. package/lib/types/templates/tsconfig.template.d.ts +2 -0
  153. package/lib/types/templates/value.template.d.ts +2 -0
  154. package/lib/types/utils/defineTemplate.d.ts +39 -0
  155. package/package.json +14 -12
  156. package/templates/tsconfig.node.json +14 -0
  157. package/templates/webpack.config.js +55 -0
  158. package/lib/esm/commands/generate/ProviderTypes.js +0 -103
  159. package/lib/esm/commands/init/interfaces/InitOptions.js +0 -5
  160. package/lib/esm/services/ProvidersInfoService.js +0 -46
  161. package/lib/esm/services/Renderer.js +0 -162
  162. package/lib/esm/utils/fillImports.js +0 -38
  163. package/lib/esm/utils/hbs/array.js +0 -515
  164. package/lib/esm/utils/hbs/collection.js +0 -60
  165. package/lib/esm/utils/hbs/comparison.js +0 -431
  166. package/lib/esm/utils/hbs/index.js +0 -11
  167. package/lib/esm/utils/hbs/object.js +0 -236
  168. package/lib/esm/utils/hbs/switch.js +0 -10
  169. package/lib/esm/utils/renderer/insertAfter.js +0 -12
  170. package/lib/esm/utils/renderer/insertImport.js +0 -11
  171. package/lib/types/commands/generate/ProviderTypes.d.ts +0 -11
  172. package/lib/types/commands/init/interfaces/InitCmdContext.d.ts +0 -6
  173. package/lib/types/commands/init/interfaces/InitOptions.d.ts +0 -20
  174. package/lib/types/services/ProvidersInfoService.d.ts +0 -21
  175. package/lib/types/services/Renderer.d.ts +0 -44
  176. package/lib/types/utils/fillImports.d.ts +0 -1
  177. package/lib/types/utils/hbs/array.d.ts +0 -1
  178. package/lib/types/utils/hbs/collection.d.ts +0 -1
  179. package/lib/types/utils/hbs/comparison.d.ts +0 -1
  180. package/lib/types/utils/hbs/object.d.ts +0 -1
  181. package/lib/types/utils/hbs/switch.d.ts +0 -1
  182. package/lib/types/utils/renderer/insertAfter.d.ts +0 -1
  183. package/lib/types/utils/renderer/insertImport.d.ts +0 -1
  184. package/templates/generate/async.factory.hbs +0 -35
  185. package/templates/generate/command.hbs +0 -45
  186. package/templates/generate/controller.hbs +0 -10
  187. package/templates/generate/decorator.class.hbs +0 -14
  188. package/templates/generate/decorator.endpoint.hbs +0 -15
  189. package/templates/generate/decorator.generic.hbs +0 -19
  190. package/templates/generate/decorator.method.hbs +0 -16
  191. package/templates/generate/decorator.middleware.hbs +0 -26
  192. package/templates/generate/decorator.param.hbs +0 -15
  193. package/templates/generate/decorator.parameters.hbs +0 -9
  194. package/templates/generate/decorator.prop.hbs +0 -14
  195. package/templates/generate/decorator.property.hbs +0 -5
  196. package/templates/generate/exception-filter.hbs +0 -9
  197. package/templates/generate/factory.hbs +0 -11
  198. package/templates/generate/injectable.hbs +0 -6
  199. package/templates/generate/interceptor.hbs +0 -21
  200. package/templates/generate/interface.hbs +0 -3
  201. package/templates/generate/middleware.hbs +0 -9
  202. package/templates/generate/model.hbs +0 -6
  203. package/templates/generate/module.hbs +0 -6
  204. package/templates/generate/pipe.hbs +0 -9
  205. package/templates/generate/prisma.service.hbs +0 -13
  206. package/templates/generate/repository.hbs +0 -6
  207. package/templates/generate/response-filter.hbs +0 -9
  208. package/templates/generate/server/_partials/server-footer.hbs +0 -10
  209. package/templates/generate/server/_partials/server-header.hbs +0 -34
  210. package/templates/generate/server/express/server.hbs +0 -10
  211. package/templates/generate/server/fastify/server.hbs +0 -14
  212. package/templates/generate/server/koa/server.hbs +0 -8
  213. package/templates/generate/service.hbs +0 -6
  214. package/templates/generate/value.hbs +0 -3
  215. package/templates/init/.barrels.json.hbs +0 -9
  216. package/templates/init/.gitignore.hbs +0 -57
  217. package/templates/init/.npmrc.hbs +0 -2
  218. package/templates/init/docker/_partials/docker-body.hbs +0 -5
  219. package/templates/init/docker/_partials/docker-dev-tools.hbs +0 -2
  220. package/templates/init/docker/_partials/docker-header.hbs +0 -16
  221. package/templates/init/docker/bun/Dockerfile.hbs +0 -36
  222. package/templates/init/docker/npm/Dockerfile.hbs +0 -28
  223. package/templates/init/docker/pnpm/Dockerfile.hbs +0 -28
  224. package/templates/init/docker/yarn/Dockerfile.hbs +0 -28
  225. package/templates/init/docker/yarn_berry/Dockerfile.hbs +0 -31
  226. package/templates/init/docker-compose.yml.hbs +0 -14
  227. package/templates/init/pm2/bun/processes.config.cjs.hbs +0 -23
  228. package/templates/init/pm2/node-compiled/processes.config.cjs.hbs +0 -22
  229. package/templates/init/pm2/node-loader/processes.config.cjs.hbs +0 -24
  230. package/templates/init/src/bin/index.ts.hbs +0 -9
  231. package/templates/init/src/config/envs/index.ts.hbs +0 -7
  232. package/templates/init/src/config/index.ts.hbs +0 -38
  233. package/templates/init/src/config/logger/index.ts.hbs +0 -25
  234. package/templates/init/tsconfig.json.hbs +0 -16
  235. package/templates/init/tsconfig.node.json.hbs +0 -20
  236. package/templates/init/tsconfig.spec.json.hbs +0 -25
  237. package/templates/init/webpack.config.js.hbs +0 -65
  238. /package/lib/esm/{commands/init/interfaces/InitCmdContext.js → interfaces/AlterGenerateTasks.js} +0 -0
  239. /package/lib/{types/utils/hbs/index.d.ts → esm/interfaces/AlterInitSubTasks.js} +0 -0
  240. /package/templates/{init/.babelrc.hbs → .babelrc} +0 -0
  241. /package/templates/{init/.dockerignore.hbs → .dockerignore} +0 -0
  242. /package/templates/{init/.swcrc.hbs → .swcrc} +0 -0
  243. /package/templates/{init/.yarnrc.hbs → .yarnrc} +0 -0
  244. /package/templates/{init/nodemon.json.hbs → nodemon.json} +0 -0
  245. /package/templates/{init/tsconfig.base.json.hbs → tsconfig.base.json} +0 -0
  246. /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,10 +0,0 @@
1
- export const helpers = {};
2
- helpers.switch = function (value, options) {
3
- this.switch_value = value;
4
- return options.fn(this);
5
- };
6
- helpers.case = function (value, options) {
7
- if (value == this.switch_value) {
8
- return options.fn(this);
9
- }
10
- };
@@ -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,11 +0,0 @@
1
- export declare const PROVIDER_TYPES: ({
2
- name: string;
3
- value: string;
4
- model: string;
5
- baseDir?: undefined;
6
- } | {
7
- name: string;
8
- value: string;
9
- baseDir: string;
10
- model: string;
11
- })[];
@@ -1,6 +0,0 @@
1
- import type { CliDefaultOptions } from "@tsed/cli-core";
2
- import type { InitOptions } from "./InitOptions.js";
3
- export interface InitCmdContext extends InitOptions, CliDefaultOptions, Record<string, any> {
4
- root: string;
5
- srcDir: string;
6
- }
@@ -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,10 +0,0 @@
1
- import {Controller} from "@tsed/di";
2
- import {Get} from "@tsed/schema";
3
-
4
- @Controller("{{route}}")
5
- export class {{symbolName}} {
6
- @Get("/")
7
- get() {
8
- return "hello";
9
- }
10
- }
@@ -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,9 +0,0 @@
1
- export interface {{symbolName}}Options {
2
-
3
- }
4
-
5
- export function {{symbolName}}(options: {{symbolName}}Options): ParameterDecorator {
6
- return (target: Object, propertyKey: string | symbol, index: number) => {
7
-
8
- };
9
- }
@@ -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,5 +0,0 @@
1
- export function {{symbolName}}(): PropertyDecorator {
2
- return (target: Object, propertyKey: string | symbol) => {
3
-
4
- };
5
- }
@@ -1,9 +0,0 @@
1
- import {BaseContext} from "@tsed/di";
2
- import {Catch, ExceptionFilterMethods} from "@tsed/platform-exceptions";
3
-
4
- @Catch(Error)
5
- export class HttpExceptionFilter implements ExceptionFilterMethods {
6
- catch(exception: Exception, ctx: BaseContext) {
7
-
8
- }
9
- }
@@ -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();
@@ -1,6 +0,0 @@
1
- import {Injectable} from "@tsed/di";
2
-
3
- @Injectable()
4
- export class {{symbolName}} {
5
-
6
- }