@tsed/cli-core 3.20.16 → 3.21.0-rc.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 (298) hide show
  1. package/lib/cjs/CliCore.js +97 -0
  2. package/lib/cjs/CliCore.js.map +1 -0
  3. package/lib/cjs/decorators/command.js +11 -0
  4. package/lib/cjs/decorators/command.js.map +1 -0
  5. package/lib/cjs/decorators/index.js +9 -0
  6. package/lib/cjs/decorators/index.js.map +1 -0
  7. package/lib/cjs/decorators/on.js +13 -0
  8. package/lib/cjs/decorators/on.js.map +1 -0
  9. package/lib/cjs/decorators/onAdd.js +10 -0
  10. package/lib/cjs/decorators/onAdd.js.map +1 -0
  11. package/lib/cjs/decorators/onExec.js +10 -0
  12. package/lib/cjs/decorators/onExec.js.map +1 -0
  13. package/lib/cjs/decorators/onPostInstall.js +10 -0
  14. package/lib/cjs/decorators/onPostInstall.js.map +1 -0
  15. package/lib/cjs/decorators/onPrompt.js +10 -0
  16. package/lib/cjs/decorators/onPrompt.js.map +1 -0
  17. package/lib/cjs/domains/CliError.js +14 -0
  18. package/lib/cjs/domains/CliError.js.map +1 -0
  19. package/lib/cjs/domains/CommandStoreKeys.js +12 -0
  20. package/lib/cjs/domains/CommandStoreKeys.js.map +1 -0
  21. package/lib/cjs/index.js +30 -0
  22. package/lib/cjs/index.js.map +1 -0
  23. package/lib/cjs/interfaces/CliDefaultOptions.js +3 -0
  24. package/lib/cjs/interfaces/CliDefaultOptions.js.map +1 -0
  25. package/lib/cjs/interfaces/CommandMetadata.js +3 -0
  26. package/lib/cjs/interfaces/CommandMetadata.js.map +1 -0
  27. package/lib/cjs/interfaces/CommandParameters.js +3 -0
  28. package/lib/cjs/interfaces/CommandParameters.js.map +1 -0
  29. package/lib/cjs/interfaces/CommandProvider.js +3 -0
  30. package/lib/cjs/interfaces/CommandProvider.js.map +1 -0
  31. package/lib/cjs/interfaces/PackageJson.js +3 -0
  32. package/lib/cjs/interfaces/PackageJson.js.map +1 -0
  33. package/lib/cjs/interfaces/ProjectPreferences.js +10 -0
  34. package/lib/cjs/interfaces/ProjectPreferences.js.map +1 -0
  35. package/lib/cjs/interfaces/Tasks.js +3 -0
  36. package/lib/cjs/interfaces/Tasks.js.map +1 -0
  37. package/lib/cjs/interfaces/index.js +11 -0
  38. package/lib/cjs/interfaces/index.js.map +1 -0
  39. package/lib/cjs/package.json +3 -0
  40. package/lib/cjs/registries/CommandRegistry.js +13 -0
  41. package/lib/cjs/registries/CommandRegistry.js.map +1 -0
  42. package/lib/cjs/services/CliConfiguration.js +21 -0
  43. package/lib/cjs/services/CliConfiguration.js.map +1 -0
  44. package/lib/cjs/services/CliDockerComposeYaml.js +83 -0
  45. package/lib/cjs/services/CliDockerComposeYaml.js.map +1 -0
  46. package/lib/cjs/services/CliExeca.js +45 -0
  47. package/lib/cjs/services/CliExeca.js.map +1 -0
  48. package/lib/cjs/services/CliFs.js +55 -0
  49. package/lib/cjs/services/CliFs.js.map +1 -0
  50. package/lib/cjs/services/CliHooks.js +34 -0
  51. package/lib/cjs/services/CliHooks.js.map +1 -0
  52. package/lib/cjs/services/CliHttpClient.js +107 -0
  53. package/lib/cjs/services/CliHttpClient.js.map +1 -0
  54. package/lib/cjs/services/CliHttpLogClient.js +83 -0
  55. package/lib/cjs/services/CliHttpLogClient.js.map +1 -0
  56. package/lib/cjs/services/CliPackageJson.js +16 -0
  57. package/lib/cjs/services/CliPackageJson.js.map +1 -0
  58. package/lib/cjs/services/CliPlugins.js +78 -0
  59. package/lib/cjs/services/CliPlugins.js.map +1 -0
  60. package/lib/cjs/services/CliProxyAgent.js +87 -0
  61. package/lib/cjs/services/CliProxyAgent.js.map +1 -0
  62. package/lib/cjs/services/CliRunScript.js +31 -0
  63. package/lib/cjs/services/CliRunScript.js.map +1 -0
  64. package/lib/cjs/services/CliService.js +271 -0
  65. package/lib/cjs/services/CliService.js.map +1 -0
  66. package/lib/cjs/services/CliYaml.js +37 -0
  67. package/lib/cjs/services/CliYaml.js.map +1 -0
  68. package/lib/cjs/services/NpmRegistryClient.js +121 -0
  69. package/lib/cjs/services/NpmRegistryClient.js.map +1 -0
  70. package/lib/cjs/services/ProjectPackageJson.js +420 -0
  71. package/lib/cjs/services/ProjectPackageJson.js.map +1 -0
  72. package/lib/cjs/services/Renderer.js +154 -0
  73. package/lib/cjs/services/Renderer.js.map +1 -0
  74. package/lib/cjs/services/index.js +17 -0
  75. package/lib/cjs/services/index.js.map +1 -0
  76. package/lib/cjs/utils/createInjector.js +35 -0
  77. package/lib/cjs/utils/createInjector.js.map +1 -0
  78. package/lib/cjs/utils/createTasksRunner.js +75 -0
  79. package/lib/cjs/utils/createTasksRunner.js.map +1 -0
  80. package/lib/cjs/utils/getCommandMetadata.js +19 -0
  81. package/lib/cjs/utils/getCommandMetadata.js.map +1 -0
  82. package/lib/cjs/utils/getPackageJson.js +38 -0
  83. package/lib/cjs/utils/getPackageJson.js.map +1 -0
  84. package/lib/cjs/utils/hbs/array.js +522 -0
  85. package/lib/cjs/utils/hbs/array.js.map +1 -0
  86. package/lib/cjs/utils/hbs/collection.js +66 -0
  87. package/lib/cjs/utils/hbs/collection.js.map +1 -0
  88. package/lib/cjs/utils/hbs/comparison.js +437 -0
  89. package/lib/cjs/utils/hbs/comparison.js.map +1 -0
  90. package/lib/cjs/utils/hbs/index.js +15 -0
  91. package/lib/cjs/utils/hbs/index.js.map +1 -0
  92. package/lib/cjs/utils/hbs/object.js +245 -0
  93. package/lib/cjs/utils/hbs/object.js.map +1 -0
  94. package/lib/cjs/utils/hbs/switch.js +14 -0
  95. package/lib/cjs/utils/hbs/switch.js.map +1 -0
  96. package/lib/cjs/utils/index.js +14 -0
  97. package/lib/cjs/utils/index.js.map +1 -0
  98. package/lib/cjs/utils/isValidVersion.js +11 -0
  99. package/lib/cjs/utils/isValidVersion.js.map +1 -0
  100. package/lib/cjs/utils/loadPlugins.js +47 -0
  101. package/lib/cjs/utils/loadPlugins.js.map +1 -0
  102. package/lib/cjs/utils/logToCurl.js +19 -0
  103. package/lib/cjs/utils/logToCurl.js.map +1 -0
  104. package/lib/cjs/utils/mapCommanderArgs.js +40 -0
  105. package/lib/cjs/utils/mapCommanderArgs.js.map +1 -0
  106. package/lib/cjs/utils/mapCommanderOptions.js +16 -0
  107. package/lib/cjs/utils/mapCommanderOptions.js.map +1 -0
  108. package/lib/cjs/utils/normalizePath.js +19 -0
  109. package/lib/cjs/utils/normalizePath.js.map +1 -0
  110. package/lib/cjs/utils/parseOption.js +27 -0
  111. package/lib/cjs/utils/parseOption.js.map +1 -0
  112. package/lib/cjs/utils/patchCommander.js +58 -0
  113. package/lib/cjs/utils/patchCommander.js.map +1 -0
  114. package/lib/cjs/utils/renderer/insertAfter.js +17 -0
  115. package/lib/cjs/utils/renderer/insertAfter.js.map +1 -0
  116. package/lib/cjs/utils/renderer/insertImport.js +16 -0
  117. package/lib/cjs/utils/renderer/insertImport.js.map +1 -0
  118. package/lib/esm/CliCore.js +94 -0
  119. package/lib/esm/CliCore.js.map +1 -0
  120. package/lib/esm/decorators/command.js +7 -0
  121. package/lib/esm/decorators/command.js.map +1 -0
  122. package/lib/esm/decorators/index.js +6 -0
  123. package/lib/esm/decorators/index.js.map +1 -0
  124. package/lib/esm/decorators/on.js +9 -0
  125. package/lib/esm/decorators/on.js.map +1 -0
  126. package/lib/esm/decorators/onAdd.js +6 -0
  127. package/lib/esm/decorators/onAdd.js.map +1 -0
  128. package/lib/esm/decorators/onExec.js +6 -0
  129. package/lib/esm/decorators/onExec.js.map +1 -0
  130. package/lib/esm/decorators/onPostInstall.js +6 -0
  131. package/lib/esm/decorators/onPostInstall.js.map +1 -0
  132. package/lib/esm/decorators/onPrompt.js +6 -0
  133. package/lib/esm/decorators/onPrompt.js.map +1 -0
  134. package/lib/esm/domains/CliError.js +10 -0
  135. package/lib/esm/domains/CliError.js.map +1 -0
  136. package/lib/esm/domains/CommandStoreKeys.js +9 -0
  137. package/lib/esm/domains/CommandStoreKeys.js.map +1 -0
  138. package/lib/esm/index.js +12 -0
  139. package/lib/esm/index.js.map +1 -0
  140. package/lib/esm/interfaces/CliDefaultOptions.js +2 -0
  141. package/lib/esm/interfaces/CliDefaultOptions.js.map +1 -0
  142. package/lib/esm/interfaces/CommandMetadata.js +2 -0
  143. package/lib/esm/interfaces/CommandMetadata.js.map +1 -0
  144. package/lib/esm/interfaces/CommandParameters.js +2 -0
  145. package/lib/esm/interfaces/CommandParameters.js.map +1 -0
  146. package/lib/esm/interfaces/CommandProvider.js +2 -0
  147. package/lib/esm/interfaces/CommandProvider.js.map +1 -0
  148. package/lib/esm/interfaces/PackageJson.js +2 -0
  149. package/lib/esm/interfaces/PackageJson.js.map +1 -0
  150. package/lib/esm/interfaces/ProjectPreferences.js +7 -0
  151. package/lib/esm/interfaces/ProjectPreferences.js.map +1 -0
  152. package/lib/esm/interfaces/Tasks.js +2 -0
  153. package/lib/esm/interfaces/Tasks.js.map +1 -0
  154. package/lib/esm/interfaces/index.js +8 -0
  155. package/lib/esm/interfaces/index.js.map +1 -0
  156. package/lib/esm/package.json +3 -0
  157. package/lib/esm/registries/CommandRegistry.js +10 -0
  158. package/lib/esm/registries/CommandRegistry.js.map +1 -0
  159. package/lib/esm/services/CliConfiguration.js +18 -0
  160. package/lib/esm/services/CliConfiguration.js.map +1 -0
  161. package/lib/esm/services/CliDockerComposeYaml.js +80 -0
  162. package/lib/esm/services/CliDockerComposeYaml.js.map +1 -0
  163. package/lib/esm/services/CliExeca.js +42 -0
  164. package/lib/esm/services/CliExeca.js.map +1 -0
  165. package/lib/esm/services/CliFs.js +52 -0
  166. package/lib/esm/services/CliFs.js.map +1 -0
  167. package/lib/esm/services/CliHooks.js +31 -0
  168. package/lib/esm/services/CliHooks.js.map +1 -0
  169. package/lib/esm/services/CliHttpClient.js +104 -0
  170. package/lib/esm/services/CliHttpClient.js.map +1 -0
  171. package/lib/esm/services/CliHttpLogClient.js +80 -0
  172. package/lib/esm/services/CliHttpLogClient.js.map +1 -0
  173. package/lib/esm/services/CliPackageJson.js +12 -0
  174. package/lib/esm/services/CliPackageJson.js.map +1 -0
  175. package/lib/esm/services/CliPlugins.js +75 -0
  176. package/lib/esm/services/CliPlugins.js.map +1 -0
  177. package/lib/esm/services/CliProxyAgent.js +84 -0
  178. package/lib/esm/services/CliProxyAgent.js.map +1 -0
  179. package/lib/esm/services/CliRunScript.js +28 -0
  180. package/lib/esm/services/CliRunScript.js.map +1 -0
  181. package/lib/esm/services/CliService.js +268 -0
  182. package/lib/esm/services/CliService.js.map +1 -0
  183. package/lib/esm/services/CliYaml.js +34 -0
  184. package/lib/esm/services/CliYaml.js.map +1 -0
  185. package/lib/esm/services/NpmRegistryClient.js +117 -0
  186. package/lib/esm/services/NpmRegistryClient.js.map +1 -0
  187. package/lib/esm/services/ProjectPackageJson.js +417 -0
  188. package/lib/esm/services/ProjectPackageJson.js.map +1 -0
  189. package/lib/esm/services/Renderer.js +150 -0
  190. package/lib/esm/services/Renderer.js.map +1 -0
  191. package/lib/esm/services/index.js +14 -0
  192. package/lib/esm/services/index.js.map +1 -0
  193. package/lib/esm/utils/createInjector.js +30 -0
  194. package/lib/esm/utils/createInjector.js.map +1 -0
  195. package/lib/esm/utils/createTasksRunner.js +69 -0
  196. package/lib/esm/utils/createTasksRunner.js.map +1 -0
  197. package/lib/esm/utils/getCommandMetadata.js +15 -0
  198. package/lib/esm/utils/getCommandMetadata.js.map +1 -0
  199. package/lib/esm/utils/getPackageJson.js +33 -0
  200. package/lib/esm/utils/getPackageJson.js.map +1 -0
  201. package/lib/esm/utils/hbs/array.js +518 -0
  202. package/lib/esm/utils/hbs/array.js.map +1 -0
  203. package/lib/esm/utils/hbs/collection.js +62 -0
  204. package/lib/esm/utils/hbs/collection.js.map +1 -0
  205. package/lib/esm/utils/hbs/comparison.js +433 -0
  206. package/lib/esm/utils/hbs/comparison.js.map +1 -0
  207. package/lib/esm/utils/hbs/index.js +12 -0
  208. package/lib/esm/utils/hbs/index.js.map +1 -0
  209. package/lib/esm/utils/hbs/object.js +241 -0
  210. package/lib/esm/utils/hbs/object.js.map +1 -0
  211. package/lib/esm/utils/hbs/switch.js +11 -0
  212. package/lib/esm/utils/hbs/switch.js.map +1 -0
  213. package/lib/esm/utils/index.js +11 -0
  214. package/lib/esm/utils/index.js.map +1 -0
  215. package/lib/esm/utils/isValidVersion.js +6 -0
  216. package/lib/esm/utils/isValidVersion.js.map +1 -0
  217. package/lib/esm/utils/loadPlugins.js +42 -0
  218. package/lib/esm/utils/loadPlugins.js.map +1 -0
  219. package/lib/esm/utils/logToCurl.js +14 -0
  220. package/lib/esm/utils/logToCurl.js.map +1 -0
  221. package/lib/esm/utils/mapCommanderArgs.js +36 -0
  222. package/lib/esm/utils/mapCommanderArgs.js.map +1 -0
  223. package/lib/esm/utils/mapCommanderOptions.js +12 -0
  224. package/lib/esm/utils/mapCommanderOptions.js.map +1 -0
  225. package/lib/esm/utils/normalizePath.js +14 -0
  226. package/lib/esm/utils/normalizePath.js.map +1 -0
  227. package/lib/esm/utils/parseOption.js +23 -0
  228. package/lib/esm/utils/parseOption.js.map +1 -0
  229. package/lib/esm/utils/patchCommander.js +55 -0
  230. package/lib/esm/utils/patchCommander.js.map +1 -0
  231. package/lib/esm/utils/renderer/insertAfter.js +13 -0
  232. package/lib/esm/utils/renderer/insertAfter.js.map +1 -0
  233. package/lib/esm/utils/renderer/insertImport.js +12 -0
  234. package/lib/esm/utils/renderer/insertImport.js.map +1 -0
  235. package/lib/{CliCore.d.ts → types/CliCore.d.ts} +0 -0
  236. package/lib/{decorators → types/decorators}/command.d.ts +0 -0
  237. package/lib/{decorators → types/decorators}/index.d.ts +0 -0
  238. package/lib/{decorators → types/decorators}/on.d.ts +0 -0
  239. package/lib/{decorators → types/decorators}/onAdd.d.ts +0 -0
  240. package/lib/{decorators → types/decorators}/onExec.d.ts +0 -0
  241. package/lib/{decorators → types/decorators}/onPostInstall.d.ts +0 -0
  242. package/lib/{decorators → types/decorators}/onPrompt.d.ts +0 -0
  243. package/lib/{domains → types/domains}/CliError.d.ts +0 -0
  244. package/lib/{domains → types/domains}/CommandStoreKeys.d.ts +0 -0
  245. package/lib/{index.d.ts → types/index.d.ts} +0 -0
  246. package/lib/{interfaces → types/interfaces}/CliDefaultOptions.d.ts +0 -0
  247. package/lib/{interfaces → types/interfaces}/CommandMetadata.d.ts +0 -0
  248. package/lib/{interfaces → types/interfaces}/CommandParameters.d.ts +0 -0
  249. package/lib/{interfaces → types/interfaces}/CommandProvider.d.ts +0 -0
  250. package/lib/{interfaces → types/interfaces}/PackageJson.d.ts +0 -0
  251. package/lib/{interfaces → types/interfaces}/ProjectPreferences.d.ts +0 -0
  252. package/lib/{interfaces → types/interfaces}/Tasks.d.ts +0 -0
  253. package/lib/{interfaces → types/interfaces}/index.d.ts +0 -0
  254. package/lib/{registries → types/registries}/CommandRegistry.d.ts +0 -0
  255. package/lib/{services → types/services}/CliConfiguration.d.ts +0 -0
  256. package/lib/{services → types/services}/CliDockerComposeYaml.d.ts +0 -0
  257. package/lib/{services → types/services}/CliExeca.d.ts +1 -0
  258. package/lib/{services → types/services}/CliFs.d.ts +1 -0
  259. package/lib/{services → types/services}/CliHooks.d.ts +0 -0
  260. package/lib/{services → types/services}/CliHttpClient.d.ts +0 -0
  261. package/lib/{services → types/services}/CliHttpLogClient.d.ts +0 -0
  262. package/lib/{services → types/services}/CliPackageJson.d.ts +0 -0
  263. package/lib/{services → types/services}/CliPlugins.d.ts +0 -0
  264. package/lib/{services → types/services}/CliProxyAgent.d.ts +0 -0
  265. package/lib/{services → types/services}/CliRunScript.d.ts +0 -0
  266. package/lib/{services → types/services}/CliService.d.ts +0 -0
  267. package/lib/{services → types/services}/CliYaml.d.ts +0 -0
  268. package/lib/{services → types/services}/NpmRegistryClient.d.ts +0 -0
  269. package/lib/{services → types/services}/ProjectPackageJson.d.ts +0 -0
  270. package/lib/{services → types/services}/Renderer.d.ts +0 -0
  271. package/lib/{services → types/services}/index.d.ts +0 -0
  272. package/lib/{utils → types/utils}/createInjector.d.ts +0 -0
  273. package/lib/{utils → types/utils}/createTasksRunner.d.ts +0 -0
  274. package/lib/{utils → types/utils}/getCommandMetadata.d.ts +0 -0
  275. package/lib/{utils → types/utils}/getPackageJson.d.ts +0 -0
  276. package/lib/{utils → types/utils}/hbs/array.d.ts +0 -0
  277. package/lib/{utils → types/utils}/hbs/collection.d.ts +0 -0
  278. package/lib/{utils → types/utils}/hbs/comparison.d.ts +0 -0
  279. package/lib/{utils → types/utils}/hbs/index.d.ts +0 -0
  280. package/lib/{utils → types/utils}/hbs/object.d.ts +0 -0
  281. package/lib/{utils → types/utils}/hbs/switch.d.ts +0 -0
  282. package/lib/{utils → types/utils}/index.d.ts +0 -0
  283. package/lib/{utils → types/utils}/isValidVersion.d.ts +0 -0
  284. package/lib/{utils → types/utils}/loadPlugins.d.ts +0 -0
  285. package/lib/{utils → types/utils}/logToCurl.d.ts +0 -0
  286. package/lib/{utils → types/utils}/mapCommanderArgs.d.ts +0 -0
  287. package/lib/{utils → types/utils}/mapCommanderOptions.d.ts +0 -0
  288. package/lib/{utils → types/utils}/normalizePath.d.ts +0 -0
  289. package/lib/{utils → types/utils}/parseOption.d.ts +0 -0
  290. package/lib/{utils → types/utils}/patchCommander.d.ts +0 -0
  291. package/lib/{utils → types/utils}/renderer/insertAfter.d.ts +0 -0
  292. package/lib/{utils → types/utils}/renderer/insertImport.d.ts +0 -0
  293. package/package.json +19 -9
  294. package/tsconfig.compile.esm.json +12 -0
  295. package/lib/index.js +0 -3992
  296. package/lib/index.js.map +0 -1
  297. package/lib/index.modern.js +0 -3832
  298. package/lib/index.modern.js.map +0 -1
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.helpers = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@tsed/core");
6
+ const array_1 = require("./array");
7
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
+ // @ts-ignore
9
+ const handlebars_utils_1 = tslib_1.__importDefault(require("handlebars-utils"));
10
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
+ // @ts-ignore
12
+ const create_frame_1 = tslib_1.__importDefault(require("create-frame"));
13
+ const hasOwn = Object.hasOwnProperty;
14
+ exports.helpers = {};
15
+ /**
16
+ * Extend the context with the properties of other objects.
17
+ * A shallow merge is performed to avoid mutating the context.
18
+ *
19
+ * @param {Object} `objects` One or more objects to extend.
20
+ * @return {Object}
21
+ * @api public
22
+ */
23
+ exports.helpers.extend = function ( /*objects*/) {
24
+ // eslint-disable-next-line prefer-rest-params
25
+ const args = [].slice.call(arguments);
26
+ let opts = {};
27
+ if (handlebars_utils_1.default.isOptions(args[args.length - 1])) {
28
+ // remove handlebars options object
29
+ opts = args.pop().hash;
30
+ // re-add handlebars options.hash object
31
+ args.push(opts);
32
+ }
33
+ const context = {};
34
+ for (let i = 0; i < args.length; i++) {
35
+ const obj = args[i];
36
+ if (handlebars_utils_1.default.isObject(obj)) {
37
+ const keys = Object.keys(obj);
38
+ for (let j = 0; j < keys.length; j++) {
39
+ const key = keys[j];
40
+ context[key] = obj[key];
41
+ }
42
+ }
43
+ }
44
+ return context;
45
+ };
46
+ /**
47
+ * Block helper that iterates over the properties of
48
+ * an object, exposing each key and value on the context.
49
+ *
50
+ * @param {Object} `context`
51
+ * @param {Object} `options`
52
+ * @return {String}
53
+ * @block
54
+ * @api public
55
+ */
56
+ exports.helpers.forIn = function (obj, options) {
57
+ if (!handlebars_utils_1.default.isOptions(options)) {
58
+ return obj.inverse(this);
59
+ }
60
+ const data = (0, create_frame_1.default)(options, options.hash);
61
+ let result = "";
62
+ for (const key in obj) {
63
+ data.key = key;
64
+ result += options.fn(obj[key], { data: data });
65
+ }
66
+ return result;
67
+ };
68
+ /**
69
+ * Block helper that iterates over the **own** properties of
70
+ * an object, exposing each key and value on the context.
71
+ *
72
+ * @param {Object} `obj` The object to iterate over.
73
+ * @param {Object} `options`
74
+ * @return {String}
75
+ * @block
76
+ * @api public
77
+ */
78
+ exports.helpers.forOwn = function (obj, options) {
79
+ if (!handlebars_utils_1.default.isOptions(options)) {
80
+ return obj.inverse(this);
81
+ }
82
+ const data = (0, create_frame_1.default)(options, options.hash);
83
+ let result = "";
84
+ for (const key in obj) {
85
+ if (obj.hasOwnProperty(key)) {
86
+ data.key = key;
87
+ result += options.fn(obj[key], { data: data });
88
+ }
89
+ }
90
+ return result;
91
+ };
92
+ /**
93
+ * Take arguments and, if they are string or number, convert them to a dot-delineated object property path.
94
+ *
95
+ * @param {String|Number} `prop` The property segments to assemble (can be multiple).
96
+ * @return {String}
97
+ * @api public
98
+ */
99
+ exports.helpers.toPath = function (...args) {
100
+ const prop = [];
101
+ for (let i = 0; i < arguments.length; i++) {
102
+ if (typeof args[i] === "string" || typeof args[i] === "number") {
103
+ prop.push(args[i]);
104
+ }
105
+ }
106
+ return prop.join(".");
107
+ };
108
+ /**
109
+ * Use property paths (`a.b.c`) to get a value or nested value from
110
+ * the context. Works as a regular helper or block helper.
111
+ *
112
+ * @param {String} `prop` The property to get, optionally using dot notation for nested properties.
113
+ * @param {Object} `context` The context object
114
+ * @param {Object} `options` The handlebars options object, if used as a block helper.
115
+ * @return {String}
116
+ * @block
117
+ * @api public
118
+ */
119
+ exports.helpers.get = function (prop, context, options) {
120
+ const val = (0, core_1.getValue)(context, prop);
121
+ if (options && options.fn) {
122
+ return val ? options.fn(val) : options.inverse(context);
123
+ }
124
+ return val;
125
+ };
126
+ /**
127
+ * Return true if `key` is an own, enumerable property
128
+ * of the given `context` object.
129
+ *
130
+ * ```handlebars
131
+ * {{hasOwn context key}}
132
+ * ```
133
+ *
134
+ * @param {String} `key`
135
+ * @param {Object} `context` The context object.
136
+ * @return {Boolean}
137
+ * @api public
138
+ */
139
+ exports.helpers.hasOwn = function (context, key) {
140
+ return hasOwn.call(context, key);
141
+ };
142
+ /**
143
+ * Return true if `value` is an object.
144
+ *
145
+ * ```handlebars
146
+ * {{isObject "foo"}}
147
+ * //=> false
148
+ * ```
149
+ * @param {String} `value`
150
+ * @return {Boolean}
151
+ * @api public
152
+ */
153
+ exports.helpers.isObject = core_1.isObject;
154
+ /**
155
+ * Parses the given string using `JSON.parse`.
156
+ *
157
+ * ```handlebars
158
+ * <!-- string: '{"foo": "bar"}' -->
159
+ * {{JSONparse string}}
160
+ * <!-- results in: { foo: 'bar' } -->
161
+ * ```
162
+ * @param {String} `string` The string to parse
163
+ * @contributor github.com/keeganstreet
164
+ * @block
165
+ * @api public
166
+ */
167
+ exports.helpers.JSONparse = function (str) {
168
+ return JSON.parse(str);
169
+ };
170
+ /**
171
+ * Stringify an object using `JSON.stringify`.
172
+ *
173
+ * ```handlebars
174
+ * <!-- object: { foo: 'bar' } -->
175
+ * {{JSONstringify object}}
176
+ * <!-- results in: '{"foo": "bar"}' -->
177
+ * ```
178
+ * @param {Object} `obj` Object to stringify
179
+ * @return {String}
180
+ * @api public
181
+ */
182
+ exports.helpers.JSONstringify = function (obj, indent) {
183
+ if (!(0, core_1.isNumber)(indent)) {
184
+ indent = 0;
185
+ }
186
+ return JSON.stringify(obj, null, indent);
187
+ };
188
+ /**
189
+ * Deeply merge the properties of the given `objects` with the
190
+ * context object.
191
+ *
192
+ * @param {Object} `object` The target object. Pass an empty object to shallow clone.
193
+ * @param {Object} `objects`
194
+ * @return {Object}
195
+ * @api public
196
+ */
197
+ exports.helpers.merge = function (...args1) {
198
+ // eslint-disable-next-line prefer-rest-params
199
+ const args = [].slice.call(args1);
200
+ let opts = {};
201
+ if (handlebars_utils_1.default.isOptions(args[args.length - 1])) {
202
+ // remove handlebars options object
203
+ opts = args.pop().hash;
204
+ // re-add options.hash
205
+ args.push(opts);
206
+ }
207
+ return Object.assign.apply(null, args);
208
+ };
209
+ /**
210
+ * Alias for parseJSON. this will be
211
+ * deprecated in a future release
212
+ */
213
+ exports.helpers.parseJSON = exports.helpers.JSONparse;
214
+ /**
215
+ * Pick properties from the context object.
216
+ *
217
+ * @param {Array|String} `properties` One or more properties to pick.
218
+ * @param {Object} `context`
219
+ * @param {Object} `options` Handlebars options object.
220
+ * @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.
221
+ * @block
222
+ * @api public
223
+ */
224
+ exports.helpers.pick = function (props, context, options) {
225
+ const keys = array_1.helpers.arrayify(props);
226
+ const len = keys.length;
227
+ let i = -1;
228
+ let result = {};
229
+ while (++i < len) {
230
+ result = exports.helpers.extend({}, result, (0, core_1.getValue)(context, keys[i]));
231
+ }
232
+ if (options.fn) {
233
+ if (Object.keys(result).length) {
234
+ return options.fn(result);
235
+ }
236
+ return options.inverse(context);
237
+ }
238
+ return result;
239
+ };
240
+ /**
241
+ * Alias for JSONstringify. this will be
242
+ * deprecated in a future release
243
+ */
244
+ exports.helpers.stringify = exports.helpers.JSONstringify;
245
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../src/utils/hbs/object.ts"],"names":[],"mappings":";;;;AAAA,qCAAwD;AACxD,mCAAyC;AACzC,6DAA6D;AAC7D,aAAa;AACb,gFAAoC;AACpC,6DAA6D;AAC7D,aAAa;AACb,wEAAuC;AACvC,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC;AACxB,QAAA,OAAO,GAAQ,EAAE,CAAC;AAE/B;;;;;;;GAOG;AACH,eAAO,CAAC,MAAM,GAAG,WAAU,WAAW;IACpC,8CAA8C;IAC9C,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,IAAI,IAAI,GAAG,EAAE,CAAC;IAEd,IAAI,0BAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE;QACzC,mCAAmC;QACnC,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;QACvB,wCAAwC;QACxC,IAAI,CAAC,IAAI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I,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACjB;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF;;;GAGG;AAEH,eAAO,CAAC,SAAS,GAAG,eAAO,CAAC,SAAS,CAAC;AAEtC;;;;;;;;;GASG;AAEH,eAAO,CAAC,IAAI,GAAG,UAAU,KAAU,EAAE,OAAY,EAAE,OAAY;IAC7D,MAAM,IAAI,GAAG,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACX,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,OAAO,EAAE,CAAC,GAAG,GAAG,EAAE;QAChB,MAAM,GAAG,eAAO,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAA,eAAQ,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACjE;IAED,IAAI,OAAO,CAAC,EAAE,EAAE;QACd,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE;YAC9B,OAAO,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;SAC3B;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KACjC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;GAGG;AAEH,eAAO,CAAC,SAAS,GAAG,eAAO,CAAC,aAAa,CAAC","sourcesContent":["import {getValue, isNumber, isObject} from \"@tsed/core\";\nimport {helpers as array} from \"./array\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport util from \"handlebars-utils\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport createFrame from \"create-frame\";\nconst hasOwn = Object.hasOwnProperty;\nexport const helpers: any = {};\n\n/**\n * Extend the context with the properties of other objects.\n * A shallow merge is performed to avoid mutating the context.\n *\n * @param {Object} `objects` One or more objects to extend.\n * @return {Object}\n * @api public\n */\nhelpers.extend = function (/*objects*/) {\n // eslint-disable-next-line prefer-rest-params\n const args = [].slice.call(arguments);\n let opts = {};\n\n if (util.isOptions(args[args.length - 1])) {\n // remove handlebars options object\n opts = args.pop().hash;\n // re-add handlebars options.hash object\n args.push(opts);\n }\n\n const context: any = {};\n for (let i = 0; i < args.length; i++) {\n const obj = args[i];\n if (util.isObject(obj)) {\n const keys = Object.keys(obj);\n for (let j = 0; j < keys.length; j++) {\n const key = keys[j];\n context[key] = obj[key];\n }\n }\n }\n\n return context;\n};\n\n/**\n * Block helper that iterates over the properties of\n * an object, exposing each key and value on the context.\n *\n * @param {Object} `context`\n * @param {Object} `options`\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.forIn = function (obj: any, options: any) {\n if (!util.isOptions(options)) {\n return obj.inverse(this);\n }\n\n const data = createFrame(options, options.hash);\n let result = \"\";\n\n for (const key in obj) {\n data.key = key;\n result += options.fn(obj[key], {data: data});\n }\n return result;\n};\n\n/**\n * Block helper that iterates over the **own** properties of\n * an object, exposing each key and value on the context.\n *\n * @param {Object} `obj` The object to iterate over.\n * @param {Object} `options`\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.forOwn = function (obj: any, options: any) {\n if (!util.isOptions(options)) {\n return obj.inverse(this);\n }\n\n const data = createFrame(options, options.hash);\n let result = \"\";\n\n for (const key in obj) {\n if (obj.hasOwnProperty(key)) {\n data.key = key;\n result += options.fn(obj[key], {data: data});\n }\n }\n return result;\n};\n\n/**\n * Take arguments and, if they are string or number, convert them to a dot-delineated object property path.\n *\n * @param {String|Number} `prop` The property segments to assemble (can be multiple).\n * @return {String}\n * @api public\n */\n\nhelpers.toPath = function (...args: any[]) {\n const prop = [];\n for (let i = 0; i < arguments.length; i++) {\n if (typeof args[i] === \"string\" || typeof args[i] === \"number\") {\n prop.push(args[i]);\n }\n }\n return prop.join(\".\");\n};\n\n/**\n * Use property paths (`a.b.c`) to get a value or nested value from\n * the context. Works as a regular helper or block helper.\n *\n * @param {String} `prop` The property to get, optionally using dot notation for nested properties.\n * @param {Object} `context` The context object\n * @param {Object} `options` The handlebars options object, if used as a block helper.\n * @return {String}\n * @block\n * @api public\n */\n\nhelpers.get = function (prop: any, context: any, options: any) {\n const val = getValue(context, prop);\n if (options && options.fn) {\n return val ? options.fn(val) : options.inverse(context);\n }\n return val;\n};\n\n/**\n * Return true if `key` is an own, enumerable property\n * of the given `context` object.\n *\n * ```handlebars\n * {{hasOwn context key}}\n * ```\n *\n * @param {String} `key`\n * @param {Object} `context` The context object.\n * @return {Boolean}\n * @api public\n */\n\nhelpers.hasOwn = function (context: any, key: string) {\n return hasOwn.call(context, key);\n};\n\n/**\n * Return true if `value` is an object.\n *\n * ```handlebars\n * {{isObject \"foo\"}}\n * //=> false\n * ```\n * @param {String} `value`\n * @return {Boolean}\n * @api public\n */\n\nhelpers.isObject = isObject;\n\n/**\n * Parses the given string using `JSON.parse`.\n *\n * ```handlebars\n * <!-- string: '{\"foo\": \"bar\"}' -->\n * {{JSONparse string}}\n * <!-- results in: { foo: 'bar' } -->\n * ```\n * @param {String} `string` The string to parse\n * @contributor github.com/keeganstreet\n * @block\n * @api public\n */\n\nhelpers.JSONparse = function (str: string) {\n return JSON.parse(str);\n};\n\n/**\n * Stringify an object using `JSON.stringify`.\n *\n * ```handlebars\n * <!-- object: { foo: 'bar' } -->\n * {{JSONstringify object}}\n * <!-- results in: '{\"foo\": \"bar\"}' -->\n * ```\n * @param {Object} `obj` Object to stringify\n * @return {String}\n * @api public\n */\n\nhelpers.JSONstringify = function (obj: any, indent: string | number | undefined) {\n if (!isNumber(indent)) {\n indent = 0;\n }\n return JSON.stringify(obj, null, indent);\n};\n\n/**\n * Deeply merge the properties of the given `objects` with the\n * context object.\n *\n * @param {Object} `object` The target object. Pass an empty object to shallow clone.\n * @param {Object} `objects`\n * @return {Object}\n * @api public\n */\nhelpers.merge = function (...args1: any) {\n // eslint-disable-next-line prefer-rest-params\n const args = [].slice.call(args1);\n let opts = {};\n\n if (util.isOptions(args[args.length - 1])) {\n // remove handlebars options object\n opts = args.pop().hash;\n // re-add options.hash\n args.push(opts);\n }\n\n return Object.assign.apply(null, args);\n};\n\n/**\n * Alias for parseJSON. this will be\n * deprecated in a future release\n */\n\nhelpers.parseJSON = helpers.JSONparse;\n\n/**\n * Pick properties from the context object.\n *\n * @param {Array|String} `properties` One or more properties to pick.\n * @param {Object} `context`\n * @param {Object} `options` Handlebars options object.\n * @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.\n * @block\n * @api public\n */\n\nhelpers.pick = function (props: any, context: any, options: any) {\n const keys = array.arrayify(props);\n const len = keys.length;\n let i = -1;\n let result = {};\n\n while (++i < len) {\n result = helpers.extend({}, result, getValue(context, keys[i]));\n }\n\n if (options.fn) {\n if (Object.keys(result).length) {\n return options.fn(result);\n }\n return options.inverse(context);\n }\n return result;\n};\n\n/**\n * Alias for JSONstringify. this will be\n * deprecated in a future release\n */\n\nhelpers.stringify = helpers.JSONstringify;\n"]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.helpers = void 0;
4
+ exports.helpers = {};
5
+ exports.helpers.switch = function (value, options) {
6
+ this.switch_value = value;
7
+ return options.fn(this);
8
+ };
9
+ exports.helpers.case = function (value, options) {
10
+ if (value == this.switch_value) {
11
+ return options.fn(this);
12
+ }
13
+ };
14
+ //# sourceMappingURL=switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../../src/utils/hbs/switch.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAQ,EAAE,CAAC;AAC/B,eAAO,CAAC,MAAM,GAAG,UAAU,KAAU,EAAE,OAAY;IACjD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC1B,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAO,CAAC,IAAI,GAAG,UAAU,KAAU,EAAE,OAAY;IAC/C,IAAI,KAAK,IAAI,IAAI,CAAC,YAAY,EAAE;QAC9B,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;KACzB;AACH,CAAC,CAAC","sourcesContent":["export const helpers: any = {};\nhelpers.switch = function (value: any, options: any) {\n this.switch_value = value;\n return options.fn(this);\n};\n\nhelpers.case = function (value: any, options: any) {\n if (value == this.switch_value) {\n return options.fn(this);\n }\n};\n"]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./createInjector"), exports);
5
+ tslib_1.__exportStar(require("./getCommandMetadata"), exports);
6
+ tslib_1.__exportStar(require("./loadPlugins"), exports);
7
+ tslib_1.__exportStar(require("./logToCurl"), exports);
8
+ tslib_1.__exportStar(require("./mapCommanderArgs"), exports);
9
+ tslib_1.__exportStar(require("./mapCommanderOptions"), exports);
10
+ tslib_1.__exportStar(require("./parseOption"), exports);
11
+ tslib_1.__exportStar(require("./createTasksRunner"), exports);
12
+ tslib_1.__exportStar(require("./normalizePath"), exports);
13
+ tslib_1.__exportStar(require("./getPackageJson"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,+DAAqC;AACrC,wDAA8B;AAC9B,sDAA4B;AAC5B,6DAAmC;AACnC,gEAAsC;AACtC,wDAA8B;AAC9B,8DAAoC;AACpC,0DAAgC;AAChC,2DAAiC","sourcesContent":["export * from \"./createInjector\";\nexport * from \"./getCommandMetadata\";\nexport * from \"./loadPlugins\";\nexport * from \"./logToCurl\";\nexport * from \"./mapCommanderArgs\";\nexport * from \"./mapCommanderOptions\";\nexport * from \"./parseOption\";\nexport * from \"./createTasksRunner\";\nexport * from \"./normalizePath\";\nexport * from \"./getPackageJson\";\n"]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidVersion = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const semver_1 = tslib_1.__importDefault(require("semver"));
6
+ function isValidVersion(version) {
7
+ version = version.replace(/[~>=<]/gi, "");
8
+ return !!semver_1.default.valid(version);
9
+ }
10
+ exports.isValidVersion = isValidVersion;
11
+ //# sourceMappingURL=isValidVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidVersion.js","sourceRoot":"","sources":["../../../src/utils/isValidVersion.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAE5B,SAAgB,cAAc,CAAC,OAAe;IAC5C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,CAAC,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAHD,wCAGC","sourcesContent":["import semver from \"semver\";\n\nexport function isValidVersion(version: string) {\n version = version.replace(/[~>=<]/gi, \"\");\n return !!semver.valid(version);\n}\n"]}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadPlugins = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ const listr2_1 = require("listr2");
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ const CliFs_1 = require("../services/CliFs");
9
+ const ProjectPackageJson_1 = require("../services/ProjectPackageJson");
10
+ const all = (promises) => Promise.all(promises);
11
+ async function loadPlugins(injector) {
12
+ const name = injector.settings.get("name");
13
+ const rootDir = injector.settings.get("project.rootDir");
14
+ const projectPackageJson = injector.invoke(ProjectPackageJson_1.ProjectPackageJson);
15
+ const fs = injector.invoke(CliFs_1.CliFs);
16
+ const promises = Object.keys(projectPackageJson.allDependencies)
17
+ .filter((mod) => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`))
18
+ .map(async (mod) => {
19
+ var _a;
20
+ try {
21
+ const { default: plugin } = await fs.importModule(mod, rootDir);
22
+ if (!injector.has(plugin)) {
23
+ const provider = (_a = di_1.GlobalProviders.get(plugin)) === null || _a === void 0 ? void 0 : _a.clone();
24
+ if (provider === null || provider === void 0 ? void 0 : provider.imports.length) {
25
+ await all(provider.imports.map(async (token) => {
26
+ var _a;
27
+ injector.add(token, (_a = di_1.GlobalProviders.get(token)) === null || _a === void 0 ? void 0 : _a.clone());
28
+ if (injector.settings.get("loaded")) {
29
+ await injector.invoke(token);
30
+ }
31
+ }));
32
+ }
33
+ injector.add(plugin, provider);
34
+ if (injector.settings.get("loaded")) {
35
+ await injector.invoke(plugin);
36
+ }
37
+ }
38
+ injector.logger.info(chalk_1.default.green(listr2_1.figures.tick), mod, "module loaded");
39
+ }
40
+ catch (er) {
41
+ injector.logger.warn(chalk_1.default.red(listr2_1.figures.cross), "Fail to load plugin", mod);
42
+ }
43
+ });
44
+ await all(promises);
45
+ }
46
+ exports.loadPlugins = loadPlugins;
47
+ //# sourceMappingURL=loadPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadPlugins.js","sourceRoot":"","sources":["../../../src/utils/loadPlugins.ts"],"names":[],"mappings":";;;;AAAA,iCAA0D;AAC1D,mCAA+B;AAC/B,0DAA0B;AAC1B,6CAAwC;AACxC,uEAAkE;AAElE,MAAM,GAAG,GAAG,CAAC,QAAe,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEhD,KAAK,UAAU,WAAW,CAAC,QAAyB;IACzD,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CA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ACH,CAAC,CAAC,CACH,CAAC;iBACH;gBAED,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBAE/B,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;oBACnC,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;iBAC/B;aACF;YACD,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,eAAK,CAAC,KAAK,CAAC,gBAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC;SACvE;QAAC,OAAO,EAAE,EAAE;YACX,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,eAAK,CAAC,GAAG,CAAC,gBAAO,CAAC,KAAK,CAAC,EAAE,qBAAqB,EAAE,GAAG,CAAC,CAAC;SAC5E;IACH,CAAC,CAAC,CAAC;IAEL,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC;AAzCD,kCAyCC","sourcesContent":["import {GlobalProviders, InjectorService} from \"@tsed/di\";\nimport {figures} from \"listr2\";\nimport chalk from \"chalk\";\nimport {CliFs} from \"../services/CliFs\";\nimport {ProjectPackageJson} from \"../services/ProjectPackageJson\";\n\nconst all = (promises: any[]) => Promise.all(promises);\n\nexport async function loadPlugins(injector: InjectorService) {\n const name = injector.settings.get(\"name\");\n const rootDir = injector.settings.get(\"project.rootDir\");\n\n const projectPackageJson = injector.invoke<ProjectPackageJson>(ProjectPackageJson);\n const fs = injector.invoke<CliFs>(CliFs);\n\n const promises = Object.keys(projectPackageJson.allDependencies)\n .filter((mod) => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`))\n .map(async (mod) => {\n try {\n const {default: plugin} = await fs.importModule(mod, rootDir);\n\n if (!injector.has(plugin)) {\n const provider = GlobalProviders.get(plugin)?.clone();\n\n if (provider?.imports.length) {\n await all(\n provider.imports.map(async (token) => {\n injector.add(token, GlobalProviders.get(token)?.clone());\n\n if (injector.settings.get(\"loaded\")) {\n await injector.invoke(token);\n }\n })\n );\n }\n\n injector.add(plugin, provider);\n\n if (injector.settings.get(\"loaded\")) {\n await injector.invoke(plugin);\n }\n }\n injector.logger.info(chalk.green(figures.tick), mod, \"module loaded\");\n } catch (er) {\n injector.logger.warn(chalk.red(figures.cross), \"Fail to load plugin\", mod);\n }\n });\n\n await all(promises);\n}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logToCurl = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const url_parse_1 = tslib_1.__importDefault(require("url-parse"));
6
+ function logToCurl({ url, method, params, query, data, headers = {} }) {
7
+ const request = (0, url_parse_1.default)(url, true);
8
+ if (params) {
9
+ request.set("query", Object.assign(params, query));
10
+ }
11
+ let curl = `curl -X ${method.toUpperCase()} '${request.toString()}'`;
12
+ if (data) {
13
+ curl += ` -d '${JSON.stringify(data)}'`;
14
+ }
15
+ curl += Object.entries(headers).reduce((curlHeaders, [key, value]) => `${curlHeaders} -H '${key}: ${value}'`, "");
16
+ return curl;
17
+ }
18
+ exports.logToCurl = logToCurl;
19
+ //# sourceMappingURL=logToCurl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logToCurl.js","sourceRoot":"","sources":["../../../src/utils/logToCurl.ts"],"names":[],"mappings":";;;;AAAA,kEAA8B;AAE9B,SAAgB,SAAS,CAAC,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,EAAM;IAC7E,MAAM,OAAO,GAAG,IAAA,mBAAK,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACjC,IAAI,MAAM,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;KACpD;IAED,IAAI,IAAI,GAAG,WAAW,MAAM,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;IAErE,IAAI,IAAI,EAAE;QACR,IAAI,IAAI,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;KACzC;IAED,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,WAAW,QAAQ,GAAG,KAAK,KAAK,GAAG,EAAE,EAAE,CAAC,CAAC;IAElH,OAAO,IAAI,CAAC;AACd,CAAC;AAfD,8BAeC","sourcesContent":["import parse from \"url-parse\";\n\nexport function logToCurl({url, method, params, query, data, headers = {}}: any) {\n const request = parse(url, true);\n if (params) {\n request.set(\"query\", Object.assign(params, query));\n }\n\n let curl = `curl -X ${method.toUpperCase()} '${request.toString()}'`;\n\n if (data) {\n curl += ` -d '${JSON.stringify(data)}'`;\n }\n\n curl += Object.entries(headers).reduce((curlHeaders, [key, value]) => `${curlHeaders} -H '${key}: ${value}'`, \"\");\n\n return curl;\n}\n"]}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapCommanderArgs = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ function mapValue(value, { type, itemType }) {
6
+ if (!value) {
7
+ return value;
8
+ }
9
+ switch (type) {
10
+ case String:
11
+ value = String(value);
12
+ break;
13
+ case Number:
14
+ value = parseFloat(value);
15
+ break;
16
+ case Boolean:
17
+ value = value === "true";
18
+ break;
19
+ case Array:
20
+ value = String(value)
21
+ .split(",")
22
+ .map((value) => mapValue(value, { type: itemType }));
23
+ break;
24
+ }
25
+ return value;
26
+ }
27
+ function mapCommanderArgs(args, commandArgs) {
28
+ commandArgs = commandArgs.filter((arg) => !(0, core_1.isClass)(arg)).filter((arg) => !(0, core_1.isArray)(arg));
29
+ let index = 0;
30
+ return Object.entries(args).reduce((options, [arg, { defaultValue, type, itemType }]) => {
31
+ const value = commandArgs[index] || defaultValue;
32
+ index++;
33
+ return {
34
+ ...options,
35
+ [arg]: mapValue(value, { type, itemType })
36
+ };
37
+ }, {});
38
+ }
39
+ exports.mapCommanderArgs = mapCommanderArgs;
40
+ //# sourceMappingURL=mapCommanderArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapCommanderArgs.js","sourceRoot":"","sources":["../../../src/utils/mapCommanderArgs.ts"],"names":[],"mappings":";;;AAAA,qCAAkD;AAGlD,SAAS,QAAQ,CAAC,KAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAA2C;IACtF,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,KAAK,CAAC;KACd;IACD,QAAQ,IAAI,EAAE;QACZ,KAAK,MAAM;YACT,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YACtB,MAAM;QACR,KAAK,MAAM;YACT,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;YAC1B,MAAM;QACR,KAAK,OAAO;YACV,KAAK,GAAG,KAAK,KAAK,MAAM,CAAC;YACzB,MAAM;QACR,KAAK,KAAK;YACR,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;iBAClB,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;YACrD,MAAM;KACT;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,gBAAgB,CAAC,IAAiC,EAAE,WAAkB;IACpF,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAA,cAAO,EAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAA,cAAO,EAAC,GAAG,CAAC,CAAC,CAAC;IACxF,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAC,CAAC,EAAE,EAAE;QACpF,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC;QAEjD,KAAK,EAAE,CAAC;QAER,OAAO;YACL,GAAG,OAAO;YACV,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;SACzC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAdD,4CAcC","sourcesContent":["import {isClass, Type, isArray} from \"@tsed/core\";\nimport {CommandArg} from \"../interfaces/CommandParameters\";\n\nfunction mapValue(value: any, {type, itemType}: {type?: Type<any>; itemType?: Type<any>}) {\n if (!value) {\n return value;\n }\n switch (type) {\n case String:\n value = String(value);\n break;\n case Number:\n value = parseFloat(value);\n break;\n case Boolean:\n value = value === \"true\";\n break;\n case Array:\n value = String(value)\n .split(\",\")\n .map((value) => mapValue(value, {type: itemType}));\n break;\n }\n\n return value;\n}\n\nexport function mapCommanderArgs(args: {[arg: string]: CommandArg}, commandArgs: any[]): any {\n commandArgs = commandArgs.filter((arg) => !isClass(arg)).filter((arg) => !isArray(arg));\n let index = 0;\n\n return Object.entries(args).reduce((options, [arg, {defaultValue, type, itemType}]) => {\n const value = commandArgs[index] || defaultValue;\n\n index++;\n\n return {\n ...options,\n [arg]: mapValue(value, {type, itemType})\n };\n }, {});\n}\n"]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapCommanderOptions = void 0;
4
+ function mapCommanderOptions(commands) {
5
+ const options = {};
6
+ commands.forEach((command) => {
7
+ Object.entries(command.opts())
8
+ .filter(([key]) => !key.startsWith("_") && !["commands", "options", "parent", "rawArgs", "args"].includes(key))
9
+ .forEach(([key, value]) => {
10
+ options[key] = value;
11
+ });
12
+ });
13
+ return options;
14
+ }
15
+ exports.mapCommanderOptions = mapCommanderOptions;
16
+ //# sourceMappingURL=mapCommanderOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapCommanderOptions.js","sourceRoot":"","sources":["../../../src/utils/mapCommanderOptions.ts"],"names":[],"mappings":";;;AAEA,SAAgB,mBAAmB,CAAC,QAA6B;IAC/D,MAAM,OAAO,GAAQ,EAAE,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;aAC3B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;aAC9G,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACxB,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACvB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAXD,kDAWC","sourcesContent":["import commander from \"commander\";\n\nexport function mapCommanderOptions(commands: commander.Command[]) {\n const options: any = {};\n commands.forEach((command) => {\n Object.entries(command.opts())\n .filter(([key]) => !key.startsWith(\"_\") && ![\"commands\", \"options\", \"parent\", \"rawArgs\", \"args\"].includes(key))\n .forEach(([key, value]) => {\n options[key] = value;\n });\n });\n\n return options;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizePath = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@tsed/core");
6
+ const path_1 = require("path");
7
+ const normalize_path_1 = tslib_1.__importDefault(require("normalize-path"));
8
+ function normalizePath(item, ...paths) {
9
+ if ((0, core_1.isString)(item)) {
10
+ const path = (0, path_1.join)(item, ...paths);
11
+ return (0, normalize_path_1.default)(path);
12
+ }
13
+ if ((0, core_1.isArray)(item)) {
14
+ return item.map((item) => normalizePath(item));
15
+ }
16
+ return item;
17
+ }
18
+ exports.normalizePath = normalizePath;
19
+ //# sourceMappingURL=normalizePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizePath.js","sourceRoot":"","sources":["../../../src/utils/normalizePath.ts"],"names":[],"mappings":";;;;AAAA,qCAA6C;AAC7C,+BAA0B;AAC1B,4EAAqC;AAIrC,SAAgB,aAAa,CAAC,IAAS,EAAE,GAAG,KAAe;IACzD,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;QAClB,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC;QAClC,OAAO,IAAA,wBAAO,EAAC,IAAI,CAAC,CAAC;KACtB;IAED,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;KACrD;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAXD,sCAWC","sourcesContent":["import {isArray, isString} from \"@tsed/core\";\nimport {join} from \"path\";\nimport fixPath from \"normalize-path\";\n\nexport function normalizePath(item: string, ...paths: string[]): string;\nexport function normalizePath(item: (string | any)[]): (string | any)[];\nexport function normalizePath(item: any, ...paths: string[]) {\n if (isString(item)) {\n const path = join(item, ...paths);\n return fixPath(path);\n }\n\n if (isArray(item)) {\n return item.map((item: any) => normalizePath(item));\n }\n\n return item;\n}\n"]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseOption = void 0;
4
+ function parseOption(value, options) {
5
+ const { type, itemType, customParser } = options;
6
+ if (type) {
7
+ switch (type) {
8
+ case String:
9
+ value = String(value);
10
+ break;
11
+ case Boolean: // the flag is added
12
+ return true;
13
+ case Number:
14
+ value = +value;
15
+ break;
16
+ case Array:
17
+ value = value.split(",").map((value) => parseOption(value, { type: itemType, customParser }));
18
+ break;
19
+ }
20
+ }
21
+ if (options.customParser) {
22
+ value = options.customParser(value);
23
+ }
24
+ return value;
25
+ }
26
+ exports.parseOption = parseOption;
27
+ //# sourceMappingURL=parseOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseOption.js","sourceRoot":"","sources":["../../../src/utils/parseOption.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,KAAU,EAAE,OAAqE;IAC3G,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAC,GAAG,OAAO,CAAC;IAE/C,IAAI,IAAI,EAAE;QACR,QAAQ,IAAI,EAAE;YACZ,KAAK,MAAM;gBACT,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;gBACtB,MAAM;YACR,KAAK,OAAO,EAAE,oBAAoB;gBAChC,OAAO,IAAI,CAAC;YACd,KAAK,MAAM;gBACT,KAAK,GAAG,CAAC,KAAK,CAAC;gBACf,MAAM;YACR,KAAK,KAAK;gBACR,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAC,CAAC,CAAC;gBACpG,MAAM;SACT;KACF;IAED,IAAI,OAAO,CAAC,YAAY,EAAE;QACxB,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;KACrC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAxBD,kCAwBC","sourcesContent":["import {Type} from \"@tsed/core\";\n\nexport function parseOption(value: any, options: {type?: Type<any>; itemType?: Type<any>; customParser?: any}) {\n const {type, itemType, customParser} = options;\n\n if (type) {\n switch (type) {\n case String:\n value = String(value);\n break;\n case Boolean: // the flag is added\n return true;\n case Number:\n value = +value;\n break;\n case Array:\n value = value.split(\",\").map((value: string) => parseOption(value, {type: itemType, customParser}));\n break;\n }\n }\n\n if (options.customParser) {\n value = options.customParser(value);\n }\n\n return value;\n}\n"]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const commander_1 = require("commander");
6
+ function at(n) {
7
+ // ToInteger() abstract op
8
+ n = Math.trunc(n) || 0;
9
+ // Allow negative indexing from the end
10
+ if (n < 0)
11
+ n += this.length;
12
+ // OOB access is guaranteed to return undefined
13
+ if (n < 0 || n >= this.length)
14
+ return undefined;
15
+ // Otherwise, this is just normal property access
16
+ return this[n];
17
+ }
18
+ const TypedArray = Reflect.getPrototypeOf(Int8Array);
19
+ for (const C of [Array, String, TypedArray]) {
20
+ if (C) {
21
+ Object.defineProperty(C.prototype, "at", { value: at, writable: true, enumerable: false, configurable: true });
22
+ }
23
+ }
24
+ const helpInformation = commander_1.Command.prototype.helpInformation;
25
+ function colorizeSection(str, section) {
26
+ // eslint-disable-next-line prefer-const
27
+ let [before, after] = str.split(section);
28
+ after = after
29
+ .split("\n")
30
+ .map((line) => {
31
+ if (!line.match(/(\w+):$/)) {
32
+ const [cmd, ...rest] = line.trim().split(" ");
33
+ if (!cmd.startsWith("-")) {
34
+ return [" ", chalk_1.default.bold(chalk_1.default.blue(cmd)), ...rest].join(" ");
35
+ }
36
+ }
37
+ return line;
38
+ })
39
+ .join("\n");
40
+ return [before, after].join(chalk_1.default.green(section));
41
+ }
42
+ commander_1.Command.prototype.helpInformation = function help() {
43
+ let str = helpInformation.call(this);
44
+ if (str.includes("Commands:")) {
45
+ str = colorizeSection(str, "Commands:");
46
+ }
47
+ if (str.includes("Arguments:")) {
48
+ str = colorizeSection(str, "Arguments:");
49
+ }
50
+ return ("\n" +
51
+ str
52
+ .replace("Usage:", chalk_1.default.green("Usage:"))
53
+ .replace("Options:", chalk_1.default.green("Options:"))
54
+ .replace(/<(\w+)>/gi, `<${chalk_1.default.yellow("$1")}>`)
55
+ .replace(/\[(\w+)]/gi, `[${chalk_1.default.cyan("$1")}]`) +
56
+ "\n");
57
+ };
58
+ //# sourceMappingURL=patchCommander.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patchCommander.js","sourceRoot":"","sources":["../../../src/utils/patchCommander.ts"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,yCAAkC;AAElC,SAAS,EAAE,CAAC,CAAS;IACnB,0BAA0B;IAC1B,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACvB,uCAAuC;IACvC,IAAI,CAAC,GAAG,CAAC;QAAE,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC;IAC5B,+CAA+C;IAC/C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAChD,iDAAiD;IACjD,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AACrD,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE;IAC3C,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,cAAc,CAAE,CAAS,CAAC,SAAS,EAAE,IAAI,EAAE,EAAC,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAC,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,GAAG,GAAG,eAAe,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;KAC1C;IAED,OAAO,CACL,IAAI;QACJ,GAAG;aACA,OAAO,CAAC,QAAQ,EAAE,eAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;aACxC,OAAO,CAAC,UAAU,EAAE,eAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;aAC5C,OAAO,CAAC,WAAW,EAAE,IAAI,eAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;aAC/C,OAAO,CAAC,YAAY,EAAE,IAAI,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QACjD,IAAI,CACL,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import chalk from \"chalk\";\nimport {Command} from \"commander\";\n\nfunction at(n: number) {\n // ToInteger() abstract op\n n = Math.trunc(n) || 0;\n // Allow negative indexing from the end\n if (n < 0) n += this.length;\n // OOB access is guaranteed to return undefined\n if (n < 0 || n >= this.length) return undefined;\n // Otherwise, this is just normal property access\n return this[n];\n}\n\nconst TypedArray = Reflect.getPrototypeOf(Int8Array);\nfor (const C of [Array, String, TypedArray]) {\n if (C) {\n Object.defineProperty((C as any).prototype, \"at\", {value: at, writable: true, enumerable: false, configurable: true});\n }\n}\n\nconst helpInformation = Command.prototype.helpInformation;\n\nfunction colorizeSection(str: any, section: string) {\n // eslint-disable-next-line prefer-const\n let [before, after] = str.split(section);\n after = after\n .split(\"\\n\")\n .map((line: string) => {\n if (!line.match(/(\\w+):$/)) {\n const [cmd, ...rest] = line.trim().split(\" \");\n if (!cmd.startsWith(\"-\")) {\n return [\" \", chalk.bold(chalk.blue(cmd)), ...rest].join(\" \");\n }\n }\n\n return line;\n })\n .join(\"\\n\");\n\n return [before, after].join(chalk.green(section));\n}\n\nCommand.prototype.helpInformation = function help() {\n let str = helpInformation.call(this);\n\n if (str.includes(\"Commands:\")) {\n str = colorizeSection(str, \"Commands:\");\n }\n\n if (str.includes(\"Arguments:\")) {\n str = colorizeSection(str, \"Arguments:\");\n }\n\n return (\n \"\\n\" +\n str\n .replace(\"Usage:\", chalk.green(\"Usage:\"))\n .replace(\"Options:\", chalk.green(\"Options:\"))\n .replace(/<(\\w+)>/gi, `<${chalk.yellow(\"$1\")}>`)\n .replace(/\\[(\\w+)]/gi, `[${chalk.cyan(\"$1\")}]`) +\n \"\\n\"\n );\n};\n"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.insertAfter = void 0;
4
+ function insertAfter(fileContent, content, pattern) {
5
+ const lines = fileContent.split("\n");
6
+ const index = lines.findIndex((line) => {
7
+ return line.match(pattern);
8
+ });
9
+ const indent = lines[index].replace(lines[index].trim(), "");
10
+ lines[index] = lines[index] + "\n" + indent + content;
11
+ if (!["]", "}"].includes(lines[index + 1].trim()) && lines[index - 1].slice(-1) === ",") {
12
+ lines[index] += ",";
13
+ }
14
+ return lines.join("\n");
15
+ }
16
+ exports.insertAfter = insertAfter;
17
+ //# sourceMappingURL=insertAfter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insertAfter.js","sourceRoot":"","sources":["../../../../src/utils/renderer/insertAfter.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,WAAmB,EAAE,OAAe,EAAE,OAAe;IAC/E,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEtC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7D,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC;IAEtD,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACvF,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC;KACrB;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAfD,kCAeC","sourcesContent":["export function insertAfter(fileContent: string, content: string, pattern: RegExp) {\n const lines = fileContent.split(\"\\n\");\n\n const index = lines.findIndex((line) => {\n return line.match(pattern);\n });\n\n const indent = lines[index].replace(lines[index].trim(), \"\");\n lines[index] = lines[index] + \"\\n\" + indent + content;\n\n if (![\"]\", \"}\"].includes(lines[index + 1].trim()) && lines[index - 1].slice(-1) === \",\") {\n lines[index] += \",\";\n }\n\n return lines.join(\"\\n\");\n}\n"]}