@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,31 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Inject, Injectable, InjectorService } from "@tsed/di";
3
+ let CliHooks = class CliHooks {
4
+ async emit(hookName, cmd, ...args) {
5
+ const providers = this.injector.getProviders();
6
+ let results = [];
7
+ for (const provider of providers) {
8
+ if (provider.useClass) {
9
+ const instance = this.injector.get(provider.token);
10
+ if (provider.store.has(hookName)) {
11
+ const props = provider.store.get(hookName)[cmd];
12
+ if (props) {
13
+ for (const propertyKey of props) {
14
+ results = results.concat(await instance[propertyKey](...args));
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
20
+ return results.filter((o) => o !== undefined);
21
+ }
22
+ };
23
+ __decorate([
24
+ Inject(),
25
+ __metadata("design:type", InjectorService)
26
+ ], CliHooks.prototype, "injector", void 0);
27
+ CliHooks = __decorate([
28
+ Injectable()
29
+ ], CliHooks);
30
+ export { CliHooks };
31
+ //# sourceMappingURL=CliHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliHooks.js","sourceRoot":"","sources":["../../../src/services/CliHooks.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AAG7D,IAAa,QAAQ,GAArB,MAAa,QAAQ;IAInB,KAAK,CAAC,IAAI,CAAC,QAAgB,EAAE,GAAW,EAAE,GAAG,IAAW;QACtD,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;QAC/C,IAAI,OAAO,GAAQ,EAAE,CAAC;QAEtB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;YAChC,IAAI,QAAQ,CAAC,QAAQ,EAAE;gBACrB,MAAM,QAAQ,GAAQ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAE,CAAC;gBAEzD,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;oBAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;oBAChD,IAAI,KAAK,EAAE;wBACT,KAAK,MAAM,WAAW,IAAI,KAAK,EAAE;4BAC/B,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;yBAChE;qBACF;iBACF;aACF;SACF;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACrD,CAAC;CACF,CAAA;AAvBC;IADC,MAAM,EAAE;8BACC,eAAe;0CAAC;AAFf,QAAQ;IADpB,UAAU,EAAE;GACA,QAAQ,CAyBpB;SAzBY,QAAQ","sourcesContent":["import {Inject, Injectable, InjectorService} from \"@tsed/di\";\n\n@Injectable()\nexport class CliHooks {\n @Inject()\n injector: InjectorService;\n\n async emit(hookName: string, cmd: string, ...args: any[]) {\n const providers = this.injector.getProviders();\n let results: any = [];\n\n for (const provider of providers) {\n if (provider.useClass) {\n const instance: any = this.injector.get(provider.token)!;\n\n if (provider.store.has(hookName)) {\n const props = provider.store.get(hookName)[cmd];\n if (props) {\n for (const propertyKey of props) {\n results = results.concat(await instance[propertyKey](...args));\n }\n }\n }\n }\n }\n\n return results.filter((o: any) => o !== undefined);\n }\n}\n"]}
@@ -0,0 +1,104 @@
1
+ var CliHttpClient_1;
2
+ import { __decorate, __metadata } from "tslib";
3
+ import { Inject, Injectable } from "@tsed/di";
4
+ import axios from "axios";
5
+ import { cleanObject } from "@tsed/core";
6
+ import { stringify } from "querystring";
7
+ import { CliProxyAgent } from "./CliProxyAgent.js";
8
+ import { CliHttpLogClient } from "./CliHttpLogClient.js";
9
+ import { URL } from "url";
10
+ let CliHttpClient = CliHttpClient_1 = class CliHttpClient extends CliHttpLogClient {
11
+ static getParamsSerializer(params) {
12
+ return stringify(cleanObject(params));
13
+ }
14
+ async $onInit() {
15
+ await this.cliProxyAgent.resolveProxySettings();
16
+ }
17
+ async head(endpoint, options = {}) {
18
+ const { headers } = await axios(this.getRequestParameters("HEAD", endpoint, options));
19
+ return headers;
20
+ }
21
+ async get(endpoint, options = {}) {
22
+ const result = await this.send(this.getRequestParameters("GET", endpoint, options));
23
+ return this.mapResponse(result, options);
24
+ }
25
+ async post(endpoint, options = {}) {
26
+ const result = await this.send(this.getRequestParameters("POST", endpoint, options));
27
+ return this.mapResponse(result, options);
28
+ }
29
+ async put(endpoint, options = {}) {
30
+ const result = await this.send(this.getRequestParameters("PUT", endpoint, options));
31
+ return this.mapResponse(result, options);
32
+ }
33
+ async patch(endpoint, options = {}) {
34
+ const result = await this.send(this.getRequestParameters("PATCH", endpoint, options));
35
+ return this.mapResponse(result, options);
36
+ }
37
+ async delete(endpoint, options = {}) {
38
+ const result = await this.send(this.getRequestParameters("DELETE", endpoint, options));
39
+ return this.mapResponse(result, options);
40
+ }
41
+ getRequestParameters(method, endpoint, options) {
42
+ options = {
43
+ method,
44
+ url: (this.host || "") + endpoint.replace(this.host || "", ""),
45
+ ...options,
46
+ params: options.params || options.qs,
47
+ data: options.data,
48
+ headers: {
49
+ "Content-Type": "application/json",
50
+ Accept: "application/json",
51
+ ...(options.headers || {})
52
+ }
53
+ };
54
+ this.configureProxy(endpoint, options);
55
+ return options;
56
+ }
57
+ configureProxy(endpoint, options) {
58
+ const url = new URL(endpoint);
59
+ if (this.cliProxyAgent.hasProxy()) {
60
+ const protocol = url.protocol.replace(":", "");
61
+ switch (protocol) {
62
+ case "https":
63
+ options.httpsAgent = this.cliProxyAgent.get(protocol);
64
+ options.proxy = false;
65
+ break;
66
+ case "http":
67
+ options.httpAgent = this.cliProxyAgent.get(protocol);
68
+ options.proxy = false;
69
+ break;
70
+ default:
71
+ break;
72
+ }
73
+ }
74
+ }
75
+ async send(options) {
76
+ const startTime = new Date().getTime();
77
+ try {
78
+ const response = await axios({
79
+ paramsSerializer: CliHttpClient_1.getParamsSerializer,
80
+ ...options
81
+ });
82
+ this.onSuccess({ startTime, ...options });
83
+ return response;
84
+ }
85
+ catch (error) {
86
+ this.onError(error, { startTime, ...options });
87
+ throw error;
88
+ }
89
+ }
90
+ mapResponse(result, options) {
91
+ const { withHeaders } = options;
92
+ const data = !withHeaders ? result === null || result === void 0 ? void 0 : result.data : result;
93
+ return withHeaders ? { data, headers: result === null || result === void 0 ? void 0 : result.headers } : data;
94
+ }
95
+ };
96
+ __decorate([
97
+ Inject(),
98
+ __metadata("design:type", CliProxyAgent)
99
+ ], CliHttpClient.prototype, "cliProxyAgent", void 0);
100
+ CliHttpClient = CliHttpClient_1 = __decorate([
101
+ Injectable()
102
+ ], CliHttpClient);
103
+ export { CliHttpClient };
104
+ //# sourceMappingURL=CliHttpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliHttpClient.js","sourceRoot":"","sources":["../../../src/services/CliHttpClient.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAmC,MAAM,OAAO,CAAC;AACxD,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAQxB,IAAa,aAAa,qBAA1B,MAAa,aAAc,SAAQ,gBAAgB;IAMjD,MAAM,CAAC,mBAAmB,CAAC,MAAW;QACpC,OAAO,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,aAAa,CAAC,oBAAoB,EAAE,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,IAAI,CAA0B,QAAgB,EAAE,UAAgC,EAAE;QACtF,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QAEpF,OAAO,OAAc,CAAC;IACxB,CAAC;IAED,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,KAAK,GAAG,KAAK,CAAC;oBACtB,MAAM;gBACR;oBACE,MAAM;aACT;SACF;IACH,CAAC;IAES,KAAK,CAAC,IAAI,CAAC,OAA2B;QAC9C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAEvC,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC;gBAC3B,gBAAgB,EAAE,eAAa,CAAC,mBAAmB;gBACnD,GAAG,OAAO;aACX,CAAC,CAAC;YAEH,IAAI,CAAC,SAAS,CAAC,EAAC,SAAS,EAAE,GAAG,OAAO,EAAC,CAAC,CAAC;YAExC,OAAO,QAAQ,CAAC;SACjB;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAC,SAAS,EAAE,GAAG,OAAO,EAAC,CAAC,CAAC;YAC7C,MAAM,KAAK,CAAC;SACb;IACH,CAAC;IAES,WAAW,CAAC,MAAW,EAAE,OAA6B;QAC9D,MAAM,EAAC,WAAW,EAAC,GAAG,OAAO,CAAC;QAE9B,MAAM,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;QAElD,OAAO,WAAW,CAAC,CAAC,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,EAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/D,CAAC;CACF,CAAA;AAhHC;IADC,MAAM,EAAE;8BACgB,aAAa;oDAAC;AAF5B,aAAa;IADzB,UAAU,EAAE;GACA,aAAa,CAkHzB;SAlHY,aAAa","sourcesContent":["import {Inject, Injectable} from \"@tsed/di\";\nimport axios, {AxiosRequestConfig, Method} from \"axios\";\nimport {cleanObject} from \"@tsed/core\";\nimport {stringify} from \"querystring\";\nimport {CliProxyAgent} from \"./CliProxyAgent\";\nimport {CliHttpLogClient} from \"./CliHttpLogClient\";\nimport {URL} from \"url\";\n\nexport interface CliHttpClientOptions extends AxiosRequestConfig, Record<string, unknown> {\n qs?: Record<string, unknown>;\n withHeaders?: boolean;\n}\n\n@Injectable()\nexport class CliHttpClient extends CliHttpLogClient {\n @Inject()\n protected cliProxyAgent: CliProxyAgent;\n\n protected host: string;\n\n static getParamsSerializer(params: any) {\n return stringify(cleanObject(params));\n }\n\n async $onInit() {\n await this.cliProxyAgent.resolveProxySettings();\n }\n\n async head<T = Record<string, any>>(endpoint: string, options: CliHttpClientOptions = {}): Promise<T> {\n const {headers} = await axios(this.getRequestParameters(\"HEAD\", endpoint, options));\n\n return headers as any;\n }\n\n async get<T = unknown>(endpoint: string, options: CliHttpClientOptions = {}): Promise<T> {\n const result = await this.send(this.getRequestParameters(\"GET\", endpoint, options));\n\n return this.mapResponse(result, options);\n }\n\n async post<T = unknown>(endpoint: string, options: CliHttpClientOptions = {}): Promise<T> {\n const result = await this.send(this.getRequestParameters(\"POST\", endpoint, options));\n\n return this.mapResponse(result, options);\n }\n\n async put<T = any>(endpoint: string, options: CliHttpClientOptions = {}): Promise<T> {\n const result = await this.send(this.getRequestParameters(\"PUT\", endpoint, options));\n\n return this.mapResponse(result, options);\n }\n\n async patch<T = any>(endpoint: string, options: CliHttpClientOptions = {}): Promise<T> {\n const result = await this.send(this.getRequestParameters(\"PATCH\", endpoint, options));\n\n return this.mapResponse(result, options);\n }\n\n async delete<T = any>(endpoint: string, options: CliHttpClientOptions = {}): Promise<T> {\n const result = await this.send(this.getRequestParameters(\"DELETE\", endpoint, options));\n\n return this.mapResponse(result, options);\n }\n\n protected getRequestParameters(method: Method, endpoint: string, options: CliHttpClientOptions) {\n options = {\n method,\n url: (this.host || \"\") + endpoint.replace(this.host || \"\", \"\"),\n ...options,\n params: options.params || options.qs,\n data: options.data,\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...(options.headers || {})\n }\n };\n\n this.configureProxy(endpoint, options);\n\n return options;\n }\n\n protected configureProxy(endpoint: string, options: CliHttpClientOptions) {\n const url = new URL(endpoint);\n\n if (this.cliProxyAgent.hasProxy()) {\n const protocol = url.protocol.replace(\":\", \"\");\n switch (protocol) {\n case \"https\":\n options.httpsAgent = this.cliProxyAgent.get(protocol);\n options.proxy = false;\n break;\n case \"http\":\n options.httpAgent = this.cliProxyAgent.get(protocol);\n options.proxy = false;\n break;\n default:\n break;\n }\n }\n }\n\n protected async send(options: AxiosRequestConfig) {\n const startTime = new Date().getTime();\n\n try {\n const response = await axios({\n paramsSerializer: CliHttpClient.getParamsSerializer,\n ...options\n });\n\n this.onSuccess({startTime, ...options});\n\n return response;\n } catch (error) {\n this.onError(error, {startTime, ...options});\n throw error;\n }\n }\n\n protected mapResponse(result: any, options: CliHttpClientOptions) {\n const {withHeaders} = options;\n\n const data = !withHeaders ? result?.data : result;\n\n return withHeaders ? {data, headers: result?.headers} : data;\n }\n}\n"]}
@@ -0,0 +1,80 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
+ import querystring from "querystring";
4
+ import { Inject, Opts } from "@tsed/di";
5
+ import { Logger } from "@tsed/logger";
6
+ import { getValue } from "@tsed/core";
7
+ import { logToCurl } from "../utils/logToCurl.js";
8
+ let CliHttpLogClient = class CliHttpLogClient {
9
+ constructor(options = {}) {
10
+ this.callee = options.callee || "http";
11
+ }
12
+ onSuccess(options) {
13
+ return this.logger.debug({
14
+ ...this.formatLog(options),
15
+ status: "OK"
16
+ });
17
+ }
18
+ onError(error, options) {
19
+ const origin = this.errorMapper(error);
20
+ this.logger.warn({
21
+ ...this.formatLog(options),
22
+ status: "KO",
23
+ callee_code: origin.code,
24
+ callee_error: origin.message,
25
+ callee_request_qs: options.params && querystring.stringify(options.params),
26
+ callee_request_headers: options.headers,
27
+ callee_request_body: options.data && JSON.stringify(options.data),
28
+ callee_response_headers: origin.headers,
29
+ callee_response_body: origin.body && JSON.stringify(origin.body),
30
+ callee_response_request_id: origin.x_request_id,
31
+ curl: this.logToCurl(options)
32
+ });
33
+ }
34
+ logToCurl(options) {
35
+ return logToCurl(options);
36
+ }
37
+ getStatusCodeFromError(error) {
38
+ return getValue(error, "response.status", getValue(error, "response.statusCode", getValue(error, "status")));
39
+ }
40
+ getHeadersFromError(error) {
41
+ return getValue(error, "response.headers", getValue(error, "headers"));
42
+ }
43
+ getResponseBodyFromError(error) {
44
+ return getValue(error, "response.data", getValue(error, "data"));
45
+ }
46
+ formatLog(options) {
47
+ const { startTime, url, method } = options;
48
+ const { callee } = this;
49
+ const duration = new Date().getTime() - startTime;
50
+ return {
51
+ callee,
52
+ url,
53
+ method,
54
+ callee_qs: options.params && querystring.stringify(options.params),
55
+ duration: isNaN(duration) ? undefined : duration
56
+ };
57
+ }
58
+ errorMapper(error) {
59
+ const statusCode = this.getStatusCodeFromError(error);
60
+ const headers = this.getHeadersFromError(error);
61
+ const body = this.getResponseBodyFromError(error);
62
+ return {
63
+ message: error.message || statusCode,
64
+ code: statusCode,
65
+ headers,
66
+ body,
67
+ x_request_id: getValue(error, "response.headers.x-request-id", getValue(error, "headers.x-request-id"))
68
+ };
69
+ }
70
+ };
71
+ __decorate([
72
+ Inject(),
73
+ __metadata("design:type", Logger)
74
+ ], CliHttpLogClient.prototype, "logger", void 0);
75
+ CliHttpLogClient = __decorate([
76
+ __param(0, Opts),
77
+ __metadata("design:paramtypes", [Object])
78
+ ], CliHttpLogClient);
79
+ export { CliHttpLogClient };
80
+ //# sourceMappingURL=CliHttpLogClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliHttpLogClient.js","sourceRoot":"","sources":["../../../src/services/CliHttpLogClient.ts"],"names":[],"mappings":";AAAA,6DAA6D;AAC7D,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,UAAU,CAAC;AACtC,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC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AAE,KAAK,CAAC,OAAO,IAAI,UAAU;YACpC,IAAI,EAAE,UAAU;YAChB,OAAO;YACP,IAAI;YACJ,YAAY,EAAE,QAAQ,CAAC,KAAK,EAAE,+BAA+B,EAAE,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC;SACxG,CAAC;IACJ,CAAC;CACF,CAAA;AAzEC;IADC,MAAM,EAAE;8BACS,MAAM;gDAAC;AAJd,gBAAgB;IAMd,WAAA,IAAI,CAAA;;GANN,gBAAgB,CA6E5B;SA7EY,gBAAgB","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport querystring from \"querystring\";\nimport {Inject, Opts} from \"@tsed/di\";\nimport {Logger} from \"@tsed/logger\";\nimport {getValue} from \"@tsed/core\";\nimport {logToCurl} from \"../utils/logToCurl\";\n\nexport interface BaseLogClientOptions {\n callee: string;\n}\n\nexport class CliHttpLogClient {\n callee: string;\n\n @Inject()\n protected logger: Logger;\n\n constructor(@Opts options: Partial<BaseLogClientOptions> = {}) {\n this.callee = options.callee || \"http\";\n }\n\n protected onSuccess(options: Record<string, unknown>) {\n return this.logger.debug({\n ...this.formatLog(options),\n status: \"OK\"\n });\n }\n\n protected onError(error: any, options: any) {\n const origin = this.errorMapper(error);\n this.logger.warn({\n ...this.formatLog(options),\n status: \"KO\",\n callee_code: origin.code,\n callee_error: origin.message,\n callee_request_qs: options.params && querystring.stringify(options.params),\n callee_request_headers: options.headers,\n callee_request_body: options.data && JSON.stringify(options.data),\n callee_response_headers: origin.headers,\n callee_response_body: origin.body && JSON.stringify(origin.body),\n callee_response_request_id: origin.x_request_id,\n curl: this.logToCurl(options)\n });\n }\n\n protected logToCurl(options: any) {\n return logToCurl(options);\n }\n\n protected getStatusCodeFromError(error: any) {\n return getValue(error, \"response.status\", getValue(error, \"response.statusCode\", getValue(error, \"status\")));\n }\n\n protected getHeadersFromError(error: any) {\n return getValue(error, \"response.headers\", getValue(error, \"headers\"));\n }\n\n protected getResponseBodyFromError(error: any) {\n return getValue(error, \"response.data\", getValue(error, \"data\"));\n }\n\n protected formatLog(options: Record<string, any>) {\n const {startTime, url, method} = options;\n const {callee} = this;\n const duration = new Date().getTime() - startTime;\n\n return {\n callee,\n url,\n method,\n callee_qs: options.params && querystring.stringify(options.params),\n duration: isNaN(duration) ? undefined : duration\n };\n }\n\n protected errorMapper(error: Error) {\n const statusCode = this.getStatusCodeFromError(error);\n const headers = this.getHeadersFromError(error);\n const body = this.getResponseBodyFromError(error);\n\n return {\n message: error.message || statusCode,\n code: statusCode,\n headers,\n body,\n x_request_id: getValue(error, \"response.headers.x-request-id\", getValue(error, \"headers.x-request-id\"))\n };\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { Configuration, Inject, registerProvider } from "@tsed/di";
2
+ export function CliPackageJson() {
3
+ return Inject(CliPackageJson);
4
+ }
5
+ registerProvider({
6
+ provide: CliPackageJson,
7
+ deps: [Configuration],
8
+ useFactory(configuration) {
9
+ return configuration.pkg || {};
10
+ }
11
+ });
12
+ //# sourceMappingURL=CliPackageJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliPackageJson.js","sourceRoot":"","sources":["../../../src/services/CliPackageJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAKjE,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAC,cAAc,CAAC,CAAC;AAChC,CAAC;AAED,gBAAgB,CAAC;IACf,OAAO,EAAE,cAAc;IACvB,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,UAAU,CAAC,aAA4B;QACrC,OAAO,aAAa,CAAC,GAAG,IAAI,EAAE,CAAC;IACjC,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {Configuration, Inject, registerProvider} from \"@tsed/di\";\nimport {PackageJson} from \"../interfaces/PackageJson\";\n\nexport type CliPackageJson = PackageJson;\n\nexport function CliPackageJson() {\n return Inject(CliPackageJson);\n}\n\nregisterProvider({\n provide: CliPackageJson,\n deps: [Configuration],\n useFactory(configuration: Configuration) {\n return configuration.pkg || {};\n }\n});\n"]}
@@ -0,0 +1,75 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { createSubTasks } from "../utils/createTasksRunner.js";
3
+ import chalk from "chalk";
4
+ import { Constant, Inject, Injectable, InjectorService } from "@tsed/di";
5
+ import { CommandStoreKeys } from "../domains/CommandStoreKeys.js";
6
+ import { loadPlugins } from "../utils/loadPlugins.js";
7
+ import { CliHooks } from "./CliHooks.js";
8
+ import { NpmRegistryClient } from "./NpmRegistryClient.js";
9
+ import { ProjectPackageJson } from "./ProjectPackageJson.js";
10
+ function mapPlugins({ package: { name, description = "", ...otherProps } }) {
11
+ return {
12
+ name: `${name} ${description}`.trim(),
13
+ value: name,
14
+ ...otherProps
15
+ };
16
+ }
17
+ let CliPlugins = class CliPlugins {
18
+ async searchPlugins(keyword = "", options = {}) {
19
+ const result = await this.npmRegistryClient.search(this.getKeyword(keyword), options);
20
+ return result.filter(({ package: { name } }) => this.isPlugin(name)).map(mapPlugins);
21
+ }
22
+ async loadPlugins() {
23
+ return loadPlugins(this.injector);
24
+ }
25
+ addPluginsDependencies(ctx) {
26
+ const plugins = Object.keys(this.packageJson.devDependencies).filter((name) => this.isPlugin(name));
27
+ const tasks = plugins.map((plugin) => {
28
+ return {
29
+ title: `Run plugin '${chalk.cyan(plugin)}'`,
30
+ task: () => this.cliHooks.emit(CommandStoreKeys.ADD, plugin, ctx)
31
+ };
32
+ });
33
+ return [
34
+ ...tasks,
35
+ {
36
+ title: "Install",
37
+ task: createSubTasks(() => this.packageJson.install(ctx), { ...ctx, concurrent: false })
38
+ }
39
+ ];
40
+ }
41
+ getKeyword(keyword) {
42
+ return `@${this.name}/cli-plugin-${this.cleanKeyword(keyword)}`;
43
+ }
44
+ cleanKeyword(keyword) {
45
+ return keyword.replace(this.name, "").replace("@", "").replace("/", "").replace("cli-plugin-", "");
46
+ }
47
+ isPlugin(name) {
48
+ return name.startsWith(`@${this.name}/cli-plugin`) || name.includes(`${this.name}-cli-plugin`);
49
+ }
50
+ };
51
+ __decorate([
52
+ Constant("name"),
53
+ __metadata("design:type", String)
54
+ ], CliPlugins.prototype, "name", void 0);
55
+ __decorate([
56
+ Inject(),
57
+ __metadata("design:type", NpmRegistryClient)
58
+ ], CliPlugins.prototype, "npmRegistryClient", void 0);
59
+ __decorate([
60
+ Inject(),
61
+ __metadata("design:type", InjectorService)
62
+ ], CliPlugins.prototype, "injector", void 0);
63
+ __decorate([
64
+ Inject(),
65
+ __metadata("design:type", CliHooks)
66
+ ], CliPlugins.prototype, "cliHooks", void 0);
67
+ __decorate([
68
+ Inject(),
69
+ __metadata("design:type", ProjectPackageJson)
70
+ ], CliPlugins.prototype, "packageJson", void 0);
71
+ CliPlugins = __decorate([
72
+ Injectable()
73
+ ], CliPlugins);
74
+ export { CliPlugins };
75
+ //# sourceMappingURL=CliPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliPlugins.js","sourceRoot":"","sources":["../../../src/services/CliPlugins.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AACvE,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAExD,SAAS,UAAU,CAAC,EAAC,OAAO,EAAE,EAAC,IAAI,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,UAAU,EAAC,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K,EAAE,SAAS;gBAChB,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAC,GAAG,GAAG,EAAE,UAAU,EAAE,KAAK,EAAC,CAAC;aACvF;SACF,CAAC;IACJ,CAAC;IAES,UAAU,CAAC,OAAe;QAClC,OAAO,IAAI,IAAI,CAAC,IAAI,eAAe,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;IAClE,CAAC;IAES,YAAY,CAAC,OAAe;QACpC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IACrG,CAAC;IAEO,QAAQ,CAAC,IAAS;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,IAAI,aAAa,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC;IACjG,CAAC;CACF,CAAA;AAtDC;IADC,QAAQ,CAAC,MAAM,CAAC;;wCACJ;AAGb;IADC,MAAM,EAAE;8BACkB,iBAAiB;qDAAC;AAG7C;IADC,MAAM,EAAE;8BACS,eAAe;4CAAC;AAGlC;IADC,MAAM,EAAE;8BACS,QAAQ;4CAAC;AAG3B;IADC,MAAM,EAAE;8BACY,kBAAkB;+CAAC;AAd7B,UAAU;IADtB,UAAU,EAAE;GACA,UAAU,CAwDtB;SAxDY,UAAU","sourcesContent":["import {createSubTasks} from \"../utils/createTasksRunner\";\nimport chalk from \"chalk\";\nimport {Constant, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {CommandStoreKeys} from \"../domains/CommandStoreKeys\";\nimport {loadPlugins} from \"../utils/loadPlugins\";\nimport {CliHooks} from \"./CliHooks\";\nimport {NpmRegistryClient} from \"./NpmRegistryClient\";\nimport {ProjectPackageJson} from \"./ProjectPackageJson\";\n\nfunction mapPlugins({package: {name, description = \"\", ...otherProps}}: any) {\n return {\n name: `${name} ${description}`.trim(),\n value: name,\n ...otherProps\n };\n}\n\n@Injectable()\nexport class CliPlugins {\n @Constant(\"name\")\n name: string;\n\n @Inject()\n private npmRegistryClient: NpmRegistryClient;\n\n @Inject()\n private injector: InjectorService;\n\n @Inject()\n private cliHooks: CliHooks;\n\n @Inject()\n private packageJson: ProjectPackageJson;\n\n async searchPlugins(keyword = \"\", options: any = {}) {\n const result = await this.npmRegistryClient.search(this.getKeyword(keyword), options);\n\n return result.filter(({package: {name}}: any) => this.isPlugin(name)).map(mapPlugins);\n }\n\n async loadPlugins() {\n return loadPlugins(this.injector);\n }\n\n addPluginsDependencies(ctx: any) {\n const plugins = Object.keys(this.packageJson.devDependencies).filter((name) => this.isPlugin(name));\n\n const tasks = plugins.map((plugin) => {\n return {\n title: `Run plugin '${chalk.cyan(plugin)}'`,\n task: () => this.cliHooks.emit(CommandStoreKeys.ADD, plugin, ctx)\n };\n });\n\n return [\n ...tasks,\n {\n title: \"Install\",\n task: createSubTasks(() => this.packageJson.install(ctx), {...ctx, concurrent: false})\n }\n ];\n }\n\n protected getKeyword(keyword: string) {\n return `@${this.name}/cli-plugin-${this.cleanKeyword(keyword)}`;\n }\n\n protected cleanKeyword(keyword: string) {\n return keyword.replace(this.name, \"\").replace(\"@\", \"\").replace(\"/\", \"\").replace(\"cli-plugin-\", \"\");\n }\n\n private isPlugin(name: any) {\n return name.startsWith(`@${this.name}/cli-plugin`) || name.includes(`${this.name}-cli-plugin`);\n }\n}\n"]}
@@ -0,0 +1,84 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import tunnel from "tunnel";
3
+ import { Configuration, Inject, Injectable, Value } from "@tsed/di";
4
+ import { CliExeca } from "./CliExeca.js";
5
+ import { camelCase } from "change-case";
6
+ import { URL } from "url";
7
+ function cast(value) {
8
+ if (["undefined"].includes(value)) {
9
+ return undefined;
10
+ }
11
+ if (["null"].includes(value)) {
12
+ return null;
13
+ }
14
+ if (["false"].includes(value)) {
15
+ return false;
16
+ }
17
+ if (["true"].includes(value)) {
18
+ return false;
19
+ }
20
+ return value;
21
+ }
22
+ let CliProxyAgent = class CliProxyAgent {
23
+ hasProxy() {
24
+ return !!this.proxySettings.url;
25
+ }
26
+ get(type) {
27
+ if (this.hasProxy()) {
28
+ const { strictSsl = true } = this.proxySettings;
29
+ const url = new URL(this.proxySettings.url);
30
+ const protocol = url.protocol.replace(":", "");
31
+ const options = {
32
+ proxy: {
33
+ host: url.hostname,
34
+ port: (url.port ? +url.port : undefined),
35
+ proxyAuth: url.username && url.password ? `${url.username}:${url.password}` : undefined,
36
+ rejectUnauthorized: strictSsl
37
+ }
38
+ };
39
+ const method = camelCase([type, "over", protocol].join(" "));
40
+ if (tunnel[method]) {
41
+ return tunnel[method](options);
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+ async resolveProxySettings() {
47
+ if (this.hasProxy()) {
48
+ return;
49
+ }
50
+ const result = await Promise.all([
51
+ this.cliExeca.getAsync("npm", ["config", "get", "proxy"]),
52
+ this.cliExeca.getAsync("npm", ["config", "get", "http-proxy"]),
53
+ this.cliExeca.getAsync("npm", ["config", "get", "https-proxy"]),
54
+ this.cliExeca.getAsync("npm", ["config", "get", "strict-ssl"])
55
+ ]);
56
+ const [proxy, httpProxy, httpsProxy, strictSsl] = result.map(cast);
57
+ const url = httpsProxy || httpProxy || proxy;
58
+ if (url) {
59
+ this.proxySettings = {
60
+ url,
61
+ strictSsl: cast(strictSsl) !== false
62
+ };
63
+ }
64
+ }
65
+ };
66
+ __decorate([
67
+ Value("proxy", {}),
68
+ __metadata("design:type", Object)
69
+ ], CliProxyAgent.prototype, "proxySettings", void 0);
70
+ __decorate([
71
+ Inject(),
72
+ __metadata("design:type", CliExeca)
73
+ ], CliProxyAgent.prototype, "cliExeca", void 0);
74
+ CliProxyAgent = __decorate([
75
+ Injectable(),
76
+ Configuration({
77
+ proxy: {
78
+ url: process.env.HTTPS_PROXY || process.env.HTTP_PROXY,
79
+ strictSsl: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== undefined ? process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0" : true
80
+ }
81
+ })
82
+ ], CliProxyAgent);
83
+ export { CliProxyAgent };
84
+ //# sourceMappingURL=CliProxyAgent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliProxyAgent.js","sourceRoot":"","sources":["../../../src/services/CliProxyAgent.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AAClE,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAOxB,SAAS,IAAI,CAAC,KAAU;IACtB,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACjC,OAAO,SAAS,CAAC;KAClB;IACD,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IAED,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC7B,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5B,OAAO,KAAK,CAAC;KACd;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AASD,IAAa,aAAa,GAA1B,MAAa,aAAa;IAOxB,QAAQ;QACN,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;IAClC,CAAC;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port {camelCase} from \"change-case\";\nimport {URL} from \"url\";\n\nexport interface CliProxySettings {\n url: string;\n strictSsl: boolean;\n}\n\nfunction cast(value: any) {\n if ([\"undefined\"].includes(value)) {\n return undefined;\n }\n if ([\"null\"].includes(value)) {\n return null;\n }\n\n if ([\"false\"].includes(value)) {\n return false;\n }\n\n if ([\"true\"].includes(value)) {\n return false;\n }\n\n return value;\n}\n\n@Injectable()\n@Configuration({\n proxy: {\n url: process.env.HTTPS_PROXY || process.env.HTTP_PROXY,\n strictSsl: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== undefined ? process.env.NODE_TLS_REJECT_UNAUTHORIZED !== \"0\" : true\n }\n})\nexport class CliProxyAgent {\n @Value(\"proxy\", {})\n proxySettings: CliProxySettings;\n\n @Inject()\n protected cliExeca: CliExeca;\n\n hasProxy() {\n return !!this.proxySettings.url;\n }\n\n get(type: \"http\" | \"https\") {\n if (this.hasProxy()) {\n const {strictSsl = true} = this.proxySettings;\n const url = new URL(this.proxySettings.url);\n const protocol = url.protocol.replace(\":\", \"\");\n\n const options = {\n proxy: {\n host: url.hostname,\n port: (url.port ? +url.port : undefined) as any,\n proxyAuth: url.username && url.password ? `${url.username}:${url.password}` : undefined,\n rejectUnauthorized: strictSsl\n }\n };\n\n const method = camelCase([type, \"over\", protocol].join(\" \"));\n\n if ((tunnel as any)[method]) {\n return (tunnel as any)[method](options);\n }\n }\n\n return null;\n }\n\n async resolveProxySettings(): Promise<void> {\n if (this.hasProxy()) {\n return;\n }\n\n const result = await Promise.all([\n this.cliExeca.getAsync(\"npm\", [\"config\", \"get\", \"proxy\"]),\n this.cliExeca.getAsync(\"npm\", [\"config\", \"get\", \"http-proxy\"]),\n this.cliExeca.getAsync(\"npm\", [\"config\", \"get\", \"https-proxy\"]),\n this.cliExeca.getAsync(\"npm\", [\"config\", \"get\", \"strict-ssl\"])\n ]);\n\n const [proxy, httpProxy, httpsProxy, strictSsl] = result.map(cast);\n const url = httpsProxy || httpProxy || proxy;\n\n if (url) {\n this.proxySettings = {\n url,\n strictSsl: cast(strictSsl) !== false\n };\n }\n }\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Inject, Injectable } from "@tsed/di";
3
+ import { ProjectPackageJson } from "./ProjectPackageJson.js";
4
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
+ // @ts-ignore
6
+ import runScript from "@npmcli/run-script";
7
+ let CliRunScript = class CliRunScript {
8
+ run(cmd, args, options = {}) {
9
+ return runScript({
10
+ event: "run",
11
+ ...options,
12
+ cmd: `${cmd} ${args.join(" ")}`,
13
+ path: options.cwd || this.projectPackageJson.dir,
14
+ env: options.env || {},
15
+ stdio: options.stdio || "inherit",
16
+ banner: false
17
+ });
18
+ }
19
+ };
20
+ __decorate([
21
+ Inject(),
22
+ __metadata("design:type", ProjectPackageJson)
23
+ ], CliRunScript.prototype, "projectPackageJson", void 0);
24
+ CliRunScript = __decorate([
25
+ Injectable()
26
+ ], CliRunScript);
27
+ export { CliRunScript };
28
+ //# sourceMappingURL=CliRunScript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliRunScript.js","sourceRoot":"","sources":["../../../src/services/CliRunScript.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,6DAA6D;AAC7D,aAAa;AACb,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAG3C,IAAa,YAAY,GAAzB,MAAa,YAAY;IAIvB,GAAG,CAAC,GAAW,EAAE,IAAc,EAAE,UAAe,EAAE;QAChD,OAAO,SAAS,CAAC;YACf,KAAK,EAAE,KAAK;YACZ,GAAG,OAAO;YACV,GAAG,EAAE,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC/B,IAAI,EAAE,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG;YAChD,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE;YACtB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,SAAS;YACjC,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAbC;IADC,MAAM,EAAE;8BACW,kBAAkB;wDAAC;AAF5B,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CAexB;SAfY,YAAY","sourcesContent":["import {Inject, Injectable} from \"@tsed/di\";\nimport {ProjectPackageJson} from \"./ProjectPackageJson\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport runScript from \"@npmcli/run-script\";\n\n@Injectable()\nexport class CliRunScript {\n @Inject()\n projectPackageJson: ProjectPackageJson;\n\n run(cmd: string, args: string[], options: any = {}) {\n return runScript({\n event: \"run\",\n ...options,\n cmd: `${cmd} ${args.join(\" \")}`,\n path: options.cwd || this.projectPackageJson.dir,\n env: options.env || {},\n stdio: options.stdio || \"inherit\",\n banner: false\n });\n }\n}\n"]}