@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,241 @@
1
+ import { getValue, isNumber, isObject } from "@tsed/core";
2
+ import { helpers as array } from "./array.js";
3
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
+ // @ts-ignore
5
+ import util from "handlebars-utils";
6
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
+ // @ts-ignore
8
+ import createFrame from "create-frame";
9
+ const hasOwn = Object.hasOwnProperty;
10
+ export const helpers = {};
11
+ /**
12
+ * Extend the context with the properties of other objects.
13
+ * A shallow merge is performed to avoid mutating the context.
14
+ *
15
+ * @param {Object} `objects` One or more objects to extend.
16
+ * @return {Object}
17
+ * @api public
18
+ */
19
+ helpers.extend = function ( /*objects*/) {
20
+ // eslint-disable-next-line prefer-rest-params
21
+ const args = [].slice.call(arguments);
22
+ let opts = {};
23
+ if (util.isOptions(args[args.length - 1])) {
24
+ // remove handlebars options object
25
+ opts = args.pop().hash;
26
+ // re-add handlebars options.hash object
27
+ args.push(opts);
28
+ }
29
+ const context = {};
30
+ for (let i = 0; i < args.length; i++) {
31
+ const obj = args[i];
32
+ if (util.isObject(obj)) {
33
+ const keys = Object.keys(obj);
34
+ for (let j = 0; j < keys.length; j++) {
35
+ const key = keys[j];
36
+ context[key] = obj[key];
37
+ }
38
+ }
39
+ }
40
+ return context;
41
+ };
42
+ /**
43
+ * Block helper that iterates over the properties of
44
+ * an object, exposing each key and value on the context.
45
+ *
46
+ * @param {Object} `context`
47
+ * @param {Object} `options`
48
+ * @return {String}
49
+ * @block
50
+ * @api public
51
+ */
52
+ helpers.forIn = function (obj, options) {
53
+ if (!util.isOptions(options)) {
54
+ return obj.inverse(this);
55
+ }
56
+ const data = createFrame(options, options.hash);
57
+ let result = "";
58
+ for (const key in obj) {
59
+ data.key = key;
60
+ result += options.fn(obj[key], { data: data });
61
+ }
62
+ return result;
63
+ };
64
+ /**
65
+ * Block helper that iterates over the **own** properties of
66
+ * an object, exposing each key and value on the context.
67
+ *
68
+ * @param {Object} `obj` The object to iterate over.
69
+ * @param {Object} `options`
70
+ * @return {String}
71
+ * @block
72
+ * @api public
73
+ */
74
+ helpers.forOwn = function (obj, options) {
75
+ if (!util.isOptions(options)) {
76
+ return obj.inverse(this);
77
+ }
78
+ const data = createFrame(options, options.hash);
79
+ let result = "";
80
+ for (const key in obj) {
81
+ if (obj.hasOwnProperty(key)) {
82
+ data.key = key;
83
+ result += options.fn(obj[key], { data: data });
84
+ }
85
+ }
86
+ return result;
87
+ };
88
+ /**
89
+ * Take arguments and, if they are string or number, convert them to a dot-delineated object property path.
90
+ *
91
+ * @param {String|Number} `prop` The property segments to assemble (can be multiple).
92
+ * @return {String}
93
+ * @api public
94
+ */
95
+ helpers.toPath = function (...args) {
96
+ const prop = [];
97
+ for (let i = 0; i < arguments.length; i++) {
98
+ if (typeof args[i] === "string" || typeof args[i] === "number") {
99
+ prop.push(args[i]);
100
+ }
101
+ }
102
+ return prop.join(".");
103
+ };
104
+ /**
105
+ * Use property paths (`a.b.c`) to get a value or nested value from
106
+ * the context. Works as a regular helper or block helper.
107
+ *
108
+ * @param {String} `prop` The property to get, optionally using dot notation for nested properties.
109
+ * @param {Object} `context` The context object
110
+ * @param {Object} `options` The handlebars options object, if used as a block helper.
111
+ * @return {String}
112
+ * @block
113
+ * @api public
114
+ */
115
+ helpers.get = function (prop, context, options) {
116
+ const val = getValue(context, prop);
117
+ if (options && options.fn) {
118
+ return val ? options.fn(val) : options.inverse(context);
119
+ }
120
+ return val;
121
+ };
122
+ /**
123
+ * Return true if `key` is an own, enumerable property
124
+ * of the given `context` object.
125
+ *
126
+ * ```handlebars
127
+ * {{hasOwn context key}}
128
+ * ```
129
+ *
130
+ * @param {String} `key`
131
+ * @param {Object} `context` The context object.
132
+ * @return {Boolean}
133
+ * @api public
134
+ */
135
+ helpers.hasOwn = function (context, key) {
136
+ return hasOwn.call(context, key);
137
+ };
138
+ /**
139
+ * Return true if `value` is an object.
140
+ *
141
+ * ```handlebars
142
+ * {{isObject "foo"}}
143
+ * //=> false
144
+ * ```
145
+ * @param {String} `value`
146
+ * @return {Boolean}
147
+ * @api public
148
+ */
149
+ helpers.isObject = isObject;
150
+ /**
151
+ * Parses the given string using `JSON.parse`.
152
+ *
153
+ * ```handlebars
154
+ * <!-- string: '{"foo": "bar"}' -->
155
+ * {{JSONparse string}}
156
+ * <!-- results in: { foo: 'bar' } -->
157
+ * ```
158
+ * @param {String} `string` The string to parse
159
+ * @contributor github.com/keeganstreet
160
+ * @block
161
+ * @api public
162
+ */
163
+ helpers.JSONparse = function (str) {
164
+ return JSON.parse(str);
165
+ };
166
+ /**
167
+ * Stringify an object using `JSON.stringify`.
168
+ *
169
+ * ```handlebars
170
+ * <!-- object: { foo: 'bar' } -->
171
+ * {{JSONstringify object}}
172
+ * <!-- results in: '{"foo": "bar"}' -->
173
+ * ```
174
+ * @param {Object} `obj` Object to stringify
175
+ * @return {String}
176
+ * @api public
177
+ */
178
+ helpers.JSONstringify = function (obj, indent) {
179
+ if (!isNumber(indent)) {
180
+ indent = 0;
181
+ }
182
+ return JSON.stringify(obj, null, indent);
183
+ };
184
+ /**
185
+ * Deeply merge the properties of the given `objects` with the
186
+ * context object.
187
+ *
188
+ * @param {Object} `object` The target object. Pass an empty object to shallow clone.
189
+ * @param {Object} `objects`
190
+ * @return {Object}
191
+ * @api public
192
+ */
193
+ helpers.merge = function (...args1) {
194
+ // eslint-disable-next-line prefer-rest-params
195
+ const args = [].slice.call(args1);
196
+ let opts = {};
197
+ if (util.isOptions(args[args.length - 1])) {
198
+ // remove handlebars options object
199
+ opts = args.pop().hash;
200
+ // re-add options.hash
201
+ args.push(opts);
202
+ }
203
+ return Object.assign.apply(null, args);
204
+ };
205
+ /**
206
+ * Alias for parseJSON. this will be
207
+ * deprecated in a future release
208
+ */
209
+ helpers.parseJSON = helpers.JSONparse;
210
+ /**
211
+ * Pick properties from the context object.
212
+ *
213
+ * @param {Array|String} `properties` One or more properties to pick.
214
+ * @param {Object} `context`
215
+ * @param {Object} `options` Handlebars options object.
216
+ * @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.
217
+ * @block
218
+ * @api public
219
+ */
220
+ helpers.pick = function (props, context, options) {
221
+ const keys = array.arrayify(props);
222
+ const len = keys.length;
223
+ let i = -1;
224
+ let result = {};
225
+ while (++i < len) {
226
+ result = helpers.extend({}, result, getValue(context, keys[i]));
227
+ }
228
+ if (options.fn) {
229
+ if (Object.keys(result).length) {
230
+ return options.fn(result);
231
+ }
232
+ return options.inverse(context);
233
+ }
234
+ return result;
235
+ };
236
+ /**
237
+ * Alias for JSONstringify. this will be
238
+ * deprecated in a future release
239
+ */
240
+ helpers.stringify = helpers.JSONstringify;
241
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../src/utils/hbs/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACxD,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,SAAS,CAAC;AACzC,6DAA6D;AAC7D,aAAa;AACb,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,6DAA6D;AAC7D,aAAa;AACb,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,MAAM,CAAC,MAAM,OAAO,GAAQ,EAAE,CAAC;AAE/B;;;;;;;GAOG;AACH,OAAO,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,IAAI,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,CAAC,IAAI,CAAC,CAAC;KACjB;IAED,MAAM,OAAO,GAAQ,EAAE,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,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,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;AAEtC;;;;;;;;;GASG;AAEH,OAAO,CAAC,IAAI,GAAG,UAAU,KAAU,EAAE,OAAY,EAAE,OAAY;IAC7D,MAAM,IAAI,GAAG,KAAK,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,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,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,OAAO,CAAC,SAAS,GAAG,OAAO,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,11 @@
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
+ };
11
+ //# sourceMappingURL=switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../../src/utils/hbs/switch.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAQ,EAAE,CAAC;AAC/B,OAAO,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,OAAO,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,11 @@
1
+ export * from "./createInjector.js";
2
+ export * from "./getCommandMetadata.js";
3
+ export * from "./loadPlugins.js";
4
+ export * from "./logToCurl.js";
5
+ export * from "./mapCommanderArgs.js";
6
+ export * from "./mapCommanderOptions.js";
7
+ export * from "./parseOption.js";
8
+ export * from "./createTasksRunner.js";
9
+ export * from "./normalizePath.js";
10
+ export * from "./getPackageJson.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC","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,6 @@
1
+ import semver from "semver";
2
+ export function isValidVersion(version) {
3
+ version = version.replace(/[~>=<]/gi, "");
4
+ return !!semver.valid(version);
5
+ }
6
+ //# sourceMappingURL=isValidVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isValidVersion.js","sourceRoot":"","sources":["../../../src/utils/isValidVersion.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC","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,42 @@
1
+ import { GlobalProviders } from "@tsed/di";
2
+ import { figures } from "listr2";
3
+ import chalk from "chalk";
4
+ import { CliFs } from "../services/CliFs.js";
5
+ import { ProjectPackageJson } from "../services/ProjectPackageJson.js";
6
+ const all = (promises) => Promise.all(promises);
7
+ export async function loadPlugins(injector) {
8
+ const name = injector.settings.get("name");
9
+ const rootDir = injector.settings.get("project.rootDir");
10
+ const projectPackageJson = injector.invoke(ProjectPackageJson);
11
+ const fs = injector.invoke(CliFs);
12
+ const promises = Object.keys(projectPackageJson.allDependencies)
13
+ .filter((mod) => mod.startsWith(`@${name}/cli-plugin`) || mod.includes(`${name}-cli-plugin`))
14
+ .map(async (mod) => {
15
+ var _a;
16
+ try {
17
+ const { default: plugin } = await fs.importModule(mod, rootDir);
18
+ if (!injector.has(plugin)) {
19
+ const provider = (_a = GlobalProviders.get(plugin)) === null || _a === void 0 ? void 0 : _a.clone();
20
+ if (provider === null || provider === void 0 ? void 0 : provider.imports.length) {
21
+ await all(provider.imports.map(async (token) => {
22
+ var _a;
23
+ injector.add(token, (_a = GlobalProviders.get(token)) === null || _a === void 0 ? void 0 : _a.clone());
24
+ if (injector.settings.get("loaded")) {
25
+ await injector.invoke(token);
26
+ }
27
+ }));
28
+ }
29
+ injector.add(plugin, provider);
30
+ if (injector.settings.get("loaded")) {
31
+ await injector.invoke(plugin);
32
+ }
33
+ }
34
+ injector.logger.info(chalk.green(figures.tick), mod, "module loaded");
35
+ }
36
+ catch (er) {
37
+ injector.logger.warn(chalk.red(figures.cross), "Fail to load plugin", mod);
38
+ }
39
+ });
40
+ await all(promises);
41
+ }
42
+ //# sourceMappingURL=loadPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadPlugins.js","sourceRoot":"","sources":["../../../src/utils/loadPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAkB,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAElE,MAAM,GAAG,GAAG,CAAC,QAAe,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAyB;IACzD,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAEzD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAqB,kBAAkB,CAAC,CAAC;IACnF,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAQ,KAAK,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC;SAC7D,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,aAAa,CAAC,CAAC;SAC5F,GAAG,CAAC,K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B,EAAE,GAAG,CAAC,CAAC;SAC5E;IACH,CAAC,CAAC,CAAC;IAEL,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC","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,14 @@
1
+ import parse from "url-parse";
2
+ export function logToCurl({ url, method, params, query, data, headers = {} }) {
3
+ const request = parse(url, true);
4
+ if (params) {
5
+ request.set("query", Object.assign(params, query));
6
+ }
7
+ let curl = `curl -X ${method.toUpperCase()} '${request.toString()}'`;
8
+ if (data) {
9
+ curl += ` -d '${JSON.stringify(data)}'`;
10
+ }
11
+ curl += Object.entries(headers).reduce((curlHeaders, [key, value]) => `${curlHeaders} -H '${key}: ${value}'`, "");
12
+ return curl;
13
+ }
14
+ //# sourceMappingURL=logToCurl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logToCurl.js","sourceRoot":"","sources":["../../../src/utils/logToCurl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,WAAW,CAAC;AAE9B,MAAM,UAAU,SAAS,CAAC,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,EAAM;IAC7E,MAAM,OAAO,GAAG,KAAK,CAAC,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","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,36 @@
1
+ import { isClass, isArray } from "@tsed/core";
2
+ function mapValue(value, { type, itemType }) {
3
+ if (!value) {
4
+ return value;
5
+ }
6
+ switch (type) {
7
+ case String:
8
+ value = String(value);
9
+ break;
10
+ case Number:
11
+ value = parseFloat(value);
12
+ break;
13
+ case Boolean:
14
+ value = value === "true";
15
+ break;
16
+ case Array:
17
+ value = String(value)
18
+ .split(",")
19
+ .map((value) => mapValue(value, { type: itemType }));
20
+ break;
21
+ }
22
+ return value;
23
+ }
24
+ export function mapCommanderArgs(args, commandArgs) {
25
+ commandArgs = commandArgs.filter((arg) => !isClass(arg)).filter((arg) => !isArray(arg));
26
+ let index = 0;
27
+ return Object.entries(args).reduce((options, [arg, { defaultValue, type, itemType }]) => {
28
+ const value = commandArgs[index] || defaultValue;
29
+ index++;
30
+ return {
31
+ ...options,
32
+ [arg]: mapValue(value, { type, itemType })
33
+ };
34
+ }, {});
35
+ }
36
+ //# sourceMappingURL=mapCommanderArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapCommanderArgs.js","sourceRoot":"","sources":["../../../src/utils/mapCommanderArgs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAQ,OAAO,EAAC,MAAM,YAAY,CAAC;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,MAAM,UAAU,gBAAgB,CAAC,IAAiC,EAAE,WAAkB;IACpF,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,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","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,12 @@
1
+ export function mapCommanderOptions(commands) {
2
+ const options = {};
3
+ commands.forEach((command) => {
4
+ Object.entries(command.opts())
5
+ .filter(([key]) => !key.startsWith("_") && !["commands", "options", "parent", "rawArgs", "args"].includes(key))
6
+ .forEach(([key, value]) => {
7
+ options[key] = value;
8
+ });
9
+ });
10
+ return options;
11
+ }
12
+ //# sourceMappingURL=mapCommanderOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapCommanderOptions.js","sourceRoot":"","sources":["../../../src/utils/mapCommanderOptions.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,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","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,14 @@
1
+ import { isArray, isString } from "@tsed/core";
2
+ import { join } from "path";
3
+ import fixPath from "normalize-path";
4
+ export function normalizePath(item, ...paths) {
5
+ if (isString(item)) {
6
+ const path = join(item, ...paths);
7
+ return fixPath(path);
8
+ }
9
+ if (isArray(item)) {
10
+ return item.map((item) => normalizePath(item));
11
+ }
12
+ return item;
13
+ }
14
+ //# sourceMappingURL=normalizePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizePath.js","sourceRoot":"","sources":["../../../src/utils/normalizePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAIrC,MAAM,UAAU,aAAa,CAAC,IAAS,EAAE,GAAG,KAAe;IACzD,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;KACtB;IAED,IAAI,OAAO,CAAC,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","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,23 @@
1
+ export function parseOption(value, options) {
2
+ const { type, itemType, customParser } = options;
3
+ if (type) {
4
+ switch (type) {
5
+ case String:
6
+ value = String(value);
7
+ break;
8
+ case Boolean: // the flag is added
9
+ return true;
10
+ case Number:
11
+ value = +value;
12
+ break;
13
+ case Array:
14
+ value = value.split(",").map((value) => parseOption(value, { type: itemType, customParser }));
15
+ break;
16
+ }
17
+ }
18
+ if (options.customParser) {
19
+ value = options.customParser(value);
20
+ }
21
+ return value;
22
+ }
23
+ //# sourceMappingURL=parseOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseOption.js","sourceRoot":"","sources":["../../../src/utils/parseOption.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,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","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,55 @@
1
+ import chalk from "chalk";
2
+ import { Command } from "commander";
3
+ function at(n) {
4
+ // ToInteger() abstract op
5
+ n = Math.trunc(n) || 0;
6
+ // Allow negative indexing from the end
7
+ if (n < 0)
8
+ n += this.length;
9
+ // OOB access is guaranteed to return undefined
10
+ if (n < 0 || n >= this.length)
11
+ return undefined;
12
+ // Otherwise, this is just normal property access
13
+ return this[n];
14
+ }
15
+ const TypedArray = Reflect.getPrototypeOf(Int8Array);
16
+ for (const C of [Array, String, TypedArray]) {
17
+ if (C) {
18
+ Object.defineProperty(C.prototype, "at", { value: at, writable: true, enumerable: false, configurable: true });
19
+ }
20
+ }
21
+ const helpInformation = Command.prototype.helpInformation;
22
+ function colorizeSection(str, section) {
23
+ // eslint-disable-next-line prefer-const
24
+ let [before, after] = str.split(section);
25
+ after = after
26
+ .split("\n")
27
+ .map((line) => {
28
+ if (!line.match(/(\w+):$/)) {
29
+ const [cmd, ...rest] = line.trim().split(" ");
30
+ if (!cmd.startsWith("-")) {
31
+ return [" ", chalk.bold(chalk.blue(cmd)), ...rest].join(" ");
32
+ }
33
+ }
34
+ return line;
35
+ })
36
+ .join("\n");
37
+ return [before, after].join(chalk.green(section));
38
+ }
39
+ Command.prototype.helpInformation = function help() {
40
+ let str = helpInformation.call(this);
41
+ if (str.includes("Commands:")) {
42
+ str = colorizeSection(str, "Commands:");
43
+ }
44
+ if (str.includes("Arguments:")) {
45
+ str = colorizeSection(str, "Arguments:");
46
+ }
47
+ return ("\n" +
48
+ str
49
+ .replace("Usage:", chalk.green("Usage:"))
50
+ .replace("Options:", chalk.green("Options:"))
51
+ .replace(/<(\w+)>/gi, `<${chalk.yellow("$1")}>`)
52
+ .replace(/\[(\w+)]/gi, `[${chalk.cyan("$1")}]`) +
53
+ "\n");
54
+ };
55
+ //# sourceMappingURL=patchCommander.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patchCommander.js","sourceRoot":"","sources":["../../../src/utils/patchCommander.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;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,Q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AC;KACzC;IAED,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;QAC9B,GAAG,GAAG,eAAe,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;KAC1C;IAED,OAAO,CACL,IAAI;QACJ,GAAG;aACA,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;aACxC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;aAC5C,OAAO,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;aAC/C,OAAO,CAAC,YAAY,EAAE,IAAI,KAAK,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,13 @@
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
+ }
13
+ //# sourceMappingURL=insertAfter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insertAfter.js","sourceRoot":"","sources":["../../../../src/utils/renderer/insertAfter.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,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","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"]}
@@ -0,0 +1,12 @@
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
+ }
12
+ //# sourceMappingURL=insertImport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insertImport.js","sourceRoot":"","sources":["../../../../src/utils/renderer/insertImport.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,OAAe;IAC/D,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEtC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QACrC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAE7C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["export function insertImport(fileContent: string, content: string) {\n const lines = fileContent.split(\"\\n\");\n\n const index = lines.findIndex((line) => {\n if (line.startsWith(\"#!\")) {\n return false;\n }\n return !line.startsWith(\"import \");\n });\n\n lines[index] = content + \"\\n\" + lines[index];\n\n return lines.join(\"\\n\");\n}\n"]}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes