@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,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CliFs = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
7
+ const path_1 = require("path");
8
+ const normalizePath_1 = require("../utils/normalizePath");
9
+ let CliFs = class CliFs {
10
+ constructor() {
11
+ this.raw = fs_extra_1.default;
12
+ }
13
+ exists(path) {
14
+ return this.raw.existsSync(path);
15
+ }
16
+ join(...args) {
17
+ return (0, normalizePath_1.normalizePath)((0, path_1.join)(...args));
18
+ }
19
+ async readFile(file, encoding) {
20
+ return this.raw.readFile(file, encoding);
21
+ }
22
+ writeFileSync(path, data, options) {
23
+ return this.raw.writeFileSync(path, data, options);
24
+ }
25
+ writeFile(file, data, options) {
26
+ return this.raw.writeFile(file, data, options);
27
+ }
28
+ ensureDir(path, options) {
29
+ return this.raw.ensureDir(path, options);
30
+ }
31
+ ensureDirSync(path, options) {
32
+ return this.raw.ensureDirSync(path, options);
33
+ }
34
+ findUpFile(root, file) {
35
+ return [(0, path_1.join)(root, file), (0, path_1.join)(root, "..", file), (0, path_1.join)(root, "..", "..", file), (0, path_1.join)(root, "..", "..", "..", file)].find((path) => this.exists(path));
36
+ }
37
+ async importModule(mod, root = process.cwd()) {
38
+ try {
39
+ if (process.env.NODE_ENV === "development") {
40
+ return await Promise.resolve().then(() => tslib_1.__importStar(require(mod)));
41
+ }
42
+ }
43
+ catch (er) { }
44
+ const path = this.findUpFile(root, (0, path_1.join)("node_modules", mod));
45
+ if (path) {
46
+ return Promise.resolve().then(() => tslib_1.__importStar(require(path)));
47
+ }
48
+ return Promise.resolve().then(() => tslib_1.__importStar(require(mod)));
49
+ }
50
+ };
51
+ CliFs = tslib_1.__decorate([
52
+ (0, di_1.Injectable)()
53
+ ], CliFs);
54
+ exports.CliFs = CliFs;
55
+ //# sourceMappingURL=CliFs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliFs.js","sourceRoot":"","sources":["../../../src/services/CliFs.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAEpC,gEAA0B;AAE1B,+BAA0B;AAC1B,0DAAqD;AAGrD,IAAa,KAAK,GAAlB,MAAa,KAAK;IAAlB;QACE,QAAG,GAAG,kBAAE,CAAC;IA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,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAChI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAClB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,GAAW,EAAE,OAAe,OAAO,CAAC,GAAG,EAAE;QAC1D,IAAI;YACF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;gBAC1C,OAAO,gEAAa,GAAG,GAAC,CAAC;aAC1B;SACF;QAAC,OAAO,EAAE,EAAE,GAAE;QAEf,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAA,WAAI,EAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;QAE9D,IAAI,IAAI,EAAE;YACR,iEAAc,IAAI,IAAE;SACrB;QAED,iEAAc,GAAG,IAAE;IACrB,CAAC;CACF,CAAA;AApDY,KAAK;IADjB,IAAA,eAAU,GAAE;GACA,KAAK,CAoDjB;AApDY,sBAAK","sourcesContent":["import {Injectable} from \"@tsed/di\";\nimport {PathLike, WriteFileOptions} from \"fs\";\nimport Fs from \"fs-extra\";\nimport {EnsureOptions} from \"fs-extra\";\nimport {join} from \"path\";\nimport {normalizePath} from \"../utils/normalizePath\";\n\n@Injectable()\nexport class CliFs {\n raw = Fs;\n\n exists(path: string) {\n return this.raw.existsSync(path);\n }\n\n join(...args: string[]) {\n return normalizePath(join(...args));\n }\n\n async readFile(file: string | Buffer | number, encoding?: any): Promise<string> {\n return this.raw.readFile(file, encoding) as any;\n }\n\n writeFileSync(path: PathLike | number, data: any, options?: WriteFileOptions) {\n return this.raw.writeFileSync(path, data, options);\n }\n\n writeFile(file: string | Buffer | number, data: any, options?: WriteFileOptions | string) {\n return this.raw.writeFile(file, data, options as any);\n }\n\n ensureDir(path: string, options?: EnsureOptions | number) {\n return this.raw.ensureDir(path, options);\n }\n\n ensureDirSync(path: string, options?: EnsureOptions | number): void {\n return this.raw.ensureDirSync(path, options);\n }\n\n findUpFile(root: string, file: string) {\n return [join(root, file), join(root, \"..\", file), join(root, \"..\", \"..\", file), join(root, \"..\", \"..\", \"..\", file)].find((path) =>\n this.exists(path)\n );\n }\n\n async importModule(mod: string, root: string = process.cwd()) {\n try {\n if (process.env.NODE_ENV === \"development\") {\n return await import(mod);\n }\n } catch (er) {}\n\n const path = this.findUpFile(root, join(\"node_modules\", mod));\n\n if (path) {\n return import(path);\n }\n\n return import(mod);\n }\n}\n"]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CliHooks = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ let CliHooks = class CliHooks {
7
+ async emit(hookName, cmd, ...args) {
8
+ const providers = this.injector.getProviders();
9
+ let results = [];
10
+ for (const provider of providers) {
11
+ if (provider.useClass) {
12
+ const instance = this.injector.get(provider.token);
13
+ if (provider.store.has(hookName)) {
14
+ const props = provider.store.get(hookName)[cmd];
15
+ if (props) {
16
+ for (const propertyKey of props) {
17
+ results = results.concat(await instance[propertyKey](...args));
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ return results.filter((o) => o !== undefined);
24
+ }
25
+ };
26
+ tslib_1.__decorate([
27
+ (0, di_1.Inject)(),
28
+ tslib_1.__metadata("design:type", di_1.InjectorService)
29
+ ], CliHooks.prototype, "injector", void 0);
30
+ CliHooks = tslib_1.__decorate([
31
+ (0, di_1.Injectable)()
32
+ ], CliHooks);
33
+ exports.CliHooks = CliHooks;
34
+ //# sourceMappingURL=CliHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliHooks.js","sourceRoot":"","sources":["../../../src/services/CliHooks.ts"],"names":[],"mappings":";;;;AAAA,iCAA6D;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,IAAA,WAAM,GAAE;sCACC,oBAAe;0CAAC;AAFf,QAAQ;IADpB,IAAA,eAAU,GAAE;GACA,QAAQ,CAyBpB;AAzBY,4BAAQ","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,107 @@
1
+ "use strict";
2
+ var CliHttpClient_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CliHttpClient = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const di_1 = require("@tsed/di");
7
+ const axios_1 = tslib_1.__importDefault(require("axios"));
8
+ const core_1 = require("@tsed/core");
9
+ const querystring_1 = require("querystring");
10
+ const CliProxyAgent_1 = require("./CliProxyAgent");
11
+ const CliHttpLogClient_1 = require("./CliHttpLogClient");
12
+ const url_1 = require("url");
13
+ let CliHttpClient = CliHttpClient_1 = class CliHttpClient extends CliHttpLogClient_1.CliHttpLogClient {
14
+ static getParamsSerializer(params) {
15
+ return (0, querystring_1.stringify)((0, core_1.cleanObject)(params));
16
+ }
17
+ async $onInit() {
18
+ await this.cliProxyAgent.resolveProxySettings();
19
+ }
20
+ async head(endpoint, options = {}) {
21
+ const { headers } = await (0, axios_1.default)(this.getRequestParameters("HEAD", endpoint, options));
22
+ return headers;
23
+ }
24
+ async get(endpoint, options = {}) {
25
+ const result = await this.send(this.getRequestParameters("GET", endpoint, options));
26
+ return this.mapResponse(result, options);
27
+ }
28
+ async post(endpoint, options = {}) {
29
+ const result = await this.send(this.getRequestParameters("POST", endpoint, options));
30
+ return this.mapResponse(result, options);
31
+ }
32
+ async put(endpoint, options = {}) {
33
+ const result = await this.send(this.getRequestParameters("PUT", endpoint, options));
34
+ return this.mapResponse(result, options);
35
+ }
36
+ async patch(endpoint, options = {}) {
37
+ const result = await this.send(this.getRequestParameters("PATCH", endpoint, options));
38
+ return this.mapResponse(result, options);
39
+ }
40
+ async delete(endpoint, options = {}) {
41
+ const result = await this.send(this.getRequestParameters("DELETE", endpoint, options));
42
+ return this.mapResponse(result, options);
43
+ }
44
+ getRequestParameters(method, endpoint, options) {
45
+ options = {
46
+ method,
47
+ url: (this.host || "") + endpoint.replace(this.host || "", ""),
48
+ ...options,
49
+ params: options.params || options.qs,
50
+ data: options.data,
51
+ headers: {
52
+ "Content-Type": "application/json",
53
+ Accept: "application/json",
54
+ ...(options.headers || {})
55
+ }
56
+ };
57
+ this.configureProxy(endpoint, options);
58
+ return options;
59
+ }
60
+ configureProxy(endpoint, options) {
61
+ const url = new url_1.URL(endpoint);
62
+ if (this.cliProxyAgent.hasProxy()) {
63
+ const protocol = url.protocol.replace(":", "");
64
+ switch (protocol) {
65
+ case "https":
66
+ options.httpsAgent = this.cliProxyAgent.get(protocol);
67
+ options.proxy = false;
68
+ break;
69
+ case "http":
70
+ options.httpAgent = this.cliProxyAgent.get(protocol);
71
+ options.proxy = false;
72
+ break;
73
+ default:
74
+ break;
75
+ }
76
+ }
77
+ }
78
+ async send(options) {
79
+ const startTime = new Date().getTime();
80
+ try {
81
+ const response = await (0, axios_1.default)({
82
+ paramsSerializer: CliHttpClient_1.getParamsSerializer,
83
+ ...options
84
+ });
85
+ this.onSuccess({ startTime, ...options });
86
+ return response;
87
+ }
88
+ catch (error) {
89
+ this.onError(error, { startTime, ...options });
90
+ throw error;
91
+ }
92
+ }
93
+ mapResponse(result, options) {
94
+ const { withHeaders } = options;
95
+ const data = !withHeaders ? result === null || result === void 0 ? void 0 : result.data : result;
96
+ return withHeaders ? { data, headers: result === null || result === void 0 ? void 0 : result.headers } : data;
97
+ }
98
+ };
99
+ tslib_1.__decorate([
100
+ (0, di_1.Inject)(),
101
+ tslib_1.__metadata("design:type", CliProxyAgent_1.CliProxyAgent)
102
+ ], CliHttpClient.prototype, "cliProxyAgent", void 0);
103
+ CliHttpClient = CliHttpClient_1 = tslib_1.__decorate([
104
+ (0, di_1.Injectable)()
105
+ ], CliHttpClient);
106
+ exports.CliHttpClient = CliHttpClient;
107
+ //# sourceMappingURL=CliHttpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliHttpClient.js","sourceRoot":"","sources":["../../../src/services/CliHttpClient.ts"],"names":[],"mappings":";;;;;AAAA,iCAA4C;AAC5C,0DAAwD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,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,IAAA,WAAM,GAAE;sCACgB,6BAAa;oDAAC;AAF5B,aAAa;IADzB,IAAA,eAAU,GAAE;GACA,aAAa,CAkHzB;AAlHY,sCAAa","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,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CliHttpLogClient = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
+ const querystring_1 = tslib_1.__importDefault(require("querystring"));
7
+ const di_1 = require("@tsed/di");
8
+ const logger_1 = require("@tsed/logger");
9
+ const core_1 = require("@tsed/core");
10
+ const logToCurl_1 = require("../utils/logToCurl");
11
+ let CliHttpLogClient = class CliHttpLogClient {
12
+ constructor(options = {}) {
13
+ this.callee = options.callee || "http";
14
+ }
15
+ onSuccess(options) {
16
+ return this.logger.debug({
17
+ ...this.formatLog(options),
18
+ status: "OK"
19
+ });
20
+ }
21
+ onError(error, options) {
22
+ const origin = this.errorMapper(error);
23
+ this.logger.warn({
24
+ ...this.formatLog(options),
25
+ status: "KO",
26
+ callee_code: origin.code,
27
+ callee_error: origin.message,
28
+ callee_request_qs: options.params && querystring_1.default.stringify(options.params),
29
+ callee_request_headers: options.headers,
30
+ callee_request_body: options.data && JSON.stringify(options.data),
31
+ callee_response_headers: origin.headers,
32
+ callee_response_body: origin.body && JSON.stringify(origin.body),
33
+ callee_response_request_id: origin.x_request_id,
34
+ curl: this.logToCurl(options)
35
+ });
36
+ }
37
+ logToCurl(options) {
38
+ return (0, logToCurl_1.logToCurl)(options);
39
+ }
40
+ getStatusCodeFromError(error) {
41
+ return (0, core_1.getValue)(error, "response.status", (0, core_1.getValue)(error, "response.statusCode", (0, core_1.getValue)(error, "status")));
42
+ }
43
+ getHeadersFromError(error) {
44
+ return (0, core_1.getValue)(error, "response.headers", (0, core_1.getValue)(error, "headers"));
45
+ }
46
+ getResponseBodyFromError(error) {
47
+ return (0, core_1.getValue)(error, "response.data", (0, core_1.getValue)(error, "data"));
48
+ }
49
+ formatLog(options) {
50
+ const { startTime, url, method } = options;
51
+ const { callee } = this;
52
+ const duration = new Date().getTime() - startTime;
53
+ return {
54
+ callee,
55
+ url,
56
+ method,
57
+ callee_qs: options.params && querystring_1.default.stringify(options.params),
58
+ duration: isNaN(duration) ? undefined : duration
59
+ };
60
+ }
61
+ errorMapper(error) {
62
+ const statusCode = this.getStatusCodeFromError(error);
63
+ const headers = this.getHeadersFromError(error);
64
+ const body = this.getResponseBodyFromError(error);
65
+ return {
66
+ message: error.message || statusCode,
67
+ code: statusCode,
68
+ headers,
69
+ body,
70
+ x_request_id: (0, core_1.getValue)(error, "response.headers.x-request-id", (0, core_1.getValue)(error, "headers.x-request-id"))
71
+ };
72
+ }
73
+ };
74
+ tslib_1.__decorate([
75
+ (0, di_1.Inject)(),
76
+ tslib_1.__metadata("design:type", logger_1.Logger)
77
+ ], CliHttpLogClient.prototype, "logger", void 0);
78
+ CliHttpLogClient = tslib_1.__decorate([
79
+ tslib_1.__param(0, di_1.Opts),
80
+ tslib_1.__metadata("design:paramtypes", [Object])
81
+ ], CliHttpLogClient);
82
+ exports.CliHttpLogClient = CliHttpLogClient;
83
+ //# sourceMappingURL=CliHttpLogClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliHttpLogClient.js","sourceRoot":"","sources":["../../../src/services/CliHttpLogClient.ts"],"names":[],"mappings":";;;;AAAA,6DAA6D;AAC7D,sEAAsC;AACtC,iCAAsC;AACtC,yCAAoC;AACpC,qCAAoC;AACpC,kDAA6C;AAM7C,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAM3B,YAAkB,UAAyC,EAAE;QAC3D,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC;IACzC,CAAC;IAES,SAAS,CAAC,OAAgC;QAClD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YACvB,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC1B,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;IACL,CAAC;IAES,OAAO,CAAC,KAAU,EAAE,OAAY;QACxC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,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AC;IACnE,CAAC;IAES,SAAS,CAAC,OAA4B;QAC9C,MAAM,EAAC,SAAS,EAAE,GAAG,EAAE,MAAM,EAAC,GAAG,OAAO,CAAC;QACzC,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC;QACtB,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC;QAElD,OAAO;YACL,MAAM;YACN,GAAG;YACH,MAAM;YACN,SAAS,EAAE,OAAO,CAAC,MAAM,IAAI,qBAAW,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;YAClE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;SACjD,CAAC;IACJ,CAAC;IAES,WAAW,CAAC,KAAY;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACtD,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;QAElD,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,UAAU;YACpC,IAAI,EAAE,UAAU;YAChB,OAAO;YACP,IAAI;YACJ,YAAY,EAAE,IAAA,eAAQ,EAAC,KAAK,EAAE,+BAA+B,EAAE,IAAA,eAAQ,EAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC;SACxG,CAAC;IACJ,CAAC;CACF,CAAA;AAzEC;IADC,IAAA,WAAM,GAAE;sCACS,eAAM;gDAAC;AAJd,gBAAgB;IAMd,mBAAA,SAAI,CAAA;;GANN,gBAAgB,CA6E5B;AA7EY,4CAAgB","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,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CliPackageJson = void 0;
4
+ const di_1 = require("@tsed/di");
5
+ function CliPackageJson() {
6
+ return (0, di_1.Inject)(CliPackageJson);
7
+ }
8
+ exports.CliPackageJson = CliPackageJson;
9
+ (0, di_1.registerProvider)({
10
+ provide: CliPackageJson,
11
+ deps: [di_1.Configuration],
12
+ useFactory(configuration) {
13
+ return configuration.pkg || {};
14
+ }
15
+ });
16
+ //# sourceMappingURL=CliPackageJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliPackageJson.js","sourceRoot":"","sources":["../../../src/services/CliPackageJson.ts"],"names":[],"mappings":";;;AAAA,iCAAiE;AAKjE,SAAgB,cAAc;IAC5B,OAAO,IAAA,WAAM,EAAC,cAAc,CAAC,CAAC;AAChC,CAAC;AAFD,wCAEC;AAED,IAAA,qBAAgB,EAAC;IACf,OAAO,EAAE,cAAc;IACvB,IAAI,EAAE,CAAC,kBAAa,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,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CliPlugins = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const createTasksRunner_1 = require("../utils/createTasksRunner");
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const di_1 = require("@tsed/di");
8
+ const CommandStoreKeys_1 = require("../domains/CommandStoreKeys");
9
+ const loadPlugins_1 = require("../utils/loadPlugins");
10
+ const CliHooks_1 = require("./CliHooks");
11
+ const NpmRegistryClient_1 = require("./NpmRegistryClient");
12
+ const ProjectPackageJson_1 = require("./ProjectPackageJson");
13
+ function mapPlugins({ package: { name, description = "", ...otherProps } }) {
14
+ return {
15
+ name: `${name} ${description}`.trim(),
16
+ value: name,
17
+ ...otherProps
18
+ };
19
+ }
20
+ let CliPlugins = class CliPlugins {
21
+ async searchPlugins(keyword = "", options = {}) {
22
+ const result = await this.npmRegistryClient.search(this.getKeyword(keyword), options);
23
+ return result.filter(({ package: { name } }) => this.isPlugin(name)).map(mapPlugins);
24
+ }
25
+ async loadPlugins() {
26
+ return (0, loadPlugins_1.loadPlugins)(this.injector);
27
+ }
28
+ addPluginsDependencies(ctx) {
29
+ const plugins = Object.keys(this.packageJson.devDependencies).filter((name) => this.isPlugin(name));
30
+ const tasks = plugins.map((plugin) => {
31
+ return {
32
+ title: `Run plugin '${chalk_1.default.cyan(plugin)}'`,
33
+ task: () => this.cliHooks.emit(CommandStoreKeys_1.CommandStoreKeys.ADD, plugin, ctx)
34
+ };
35
+ });
36
+ return [
37
+ ...tasks,
38
+ {
39
+ title: "Install",
40
+ task: (0, createTasksRunner_1.createSubTasks)(() => this.packageJson.install(ctx), { ...ctx, concurrent: false })
41
+ }
42
+ ];
43
+ }
44
+ getKeyword(keyword) {
45
+ return `@${this.name}/cli-plugin-${this.cleanKeyword(keyword)}`;
46
+ }
47
+ cleanKeyword(keyword) {
48
+ return keyword.replace(this.name, "").replace("@", "").replace("/", "").replace("cli-plugin-", "");
49
+ }
50
+ isPlugin(name) {
51
+ return name.startsWith(`@${this.name}/cli-plugin`) || name.includes(`${this.name}-cli-plugin`);
52
+ }
53
+ };
54
+ tslib_1.__decorate([
55
+ (0, di_1.Constant)("name"),
56
+ tslib_1.__metadata("design:type", String)
57
+ ], CliPlugins.prototype, "name", void 0);
58
+ tslib_1.__decorate([
59
+ (0, di_1.Inject)(),
60
+ tslib_1.__metadata("design:type", NpmRegistryClient_1.NpmRegistryClient)
61
+ ], CliPlugins.prototype, "npmRegistryClient", void 0);
62
+ tslib_1.__decorate([
63
+ (0, di_1.Inject)(),
64
+ tslib_1.__metadata("design:type", di_1.InjectorService)
65
+ ], CliPlugins.prototype, "injector", void 0);
66
+ tslib_1.__decorate([
67
+ (0, di_1.Inject)(),
68
+ tslib_1.__metadata("design:type", CliHooks_1.CliHooks)
69
+ ], CliPlugins.prototype, "cliHooks", void 0);
70
+ tslib_1.__decorate([
71
+ (0, di_1.Inject)(),
72
+ tslib_1.__metadata("design:type", ProjectPackageJson_1.ProjectPackageJson)
73
+ ], CliPlugins.prototype, "packageJson", void 0);
74
+ CliPlugins = tslib_1.__decorate([
75
+ (0, di_1.Injectable)()
76
+ ], CliPlugins);
77
+ exports.CliPlugins = CliPlugins;
78
+ //# sourceMappingURL=CliPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliPlugins.js","sourceRoot":"","sources":["../../../src/services/CliPlugins.ts"],"names":[],"mappings":";;;;AAAA,kEAA0D;AAC1D,0DAA0B;AAC1B,iCAAuE;AACvE,kEAA6D;AAC7D,sDAAiD;AACjD,yCAAoC;AACpC,2DAAsD;AACtD,6DAAwD;AAExD,SAAS,UAAU,CAAC,EAAC,OAAO,EAAE,EAAC,IAAI,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,UAAU,EAAC,EAAM;IACzE,OAAO;QACL,IAAI,EAAE,GAAG,IAAI,IAAI,WAAW,EAAE,CAAC,IAAI,EAAE;QACrC,KAAK,EAAE,IAAI;QACX,GAAG,UAAU;KACd,CAAC;AACJ,CAAC;AAGD,IAAa,UAAU,GAAvB,MAAa,UAAU;IAgBrB,KAAK,CAAC,aAAa,CAAC,OAAO,GAAG,EAAE,EAAE,UAAe,EAAE;QACjD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QAEtF,OAAO,MA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C,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,IAAA,aAAQ,EAAC,MAAM,CAAC;;wCACJ;AAGb;IADC,IAAA,WAAM,GAAE;sCACkB,qCAAiB;qDAAC;AAG7C;IADC,IAAA,WAAM,GAAE;sCACS,oBAAe;4CAAC;AAGlC;IADC,IAAA,WAAM,GAAE;sCACS,mBAAQ;4CAAC;AAG3B;IADC,IAAA,WAAM,GAAE;sCACY,uCAAkB;+CAAC;AAd7B,UAAU;IADtB,IAAA,eAAU,GAAE;GACA,UAAU,CAwDtB;AAxDY,gCAAU","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,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CliProxyAgent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const tunnel_1 = tslib_1.__importDefault(require("tunnel"));
6
+ const di_1 = require("@tsed/di");
7
+ const CliExeca_1 = require("./CliExeca");
8
+ const change_case_1 = require("change-case");
9
+ const url_1 = require("url");
10
+ function cast(value) {
11
+ if (["undefined"].includes(value)) {
12
+ return undefined;
13
+ }
14
+ if (["null"].includes(value)) {
15
+ return null;
16
+ }
17
+ if (["false"].includes(value)) {
18
+ return false;
19
+ }
20
+ if (["true"].includes(value)) {
21
+ return false;
22
+ }
23
+ return value;
24
+ }
25
+ let CliProxyAgent = class CliProxyAgent {
26
+ hasProxy() {
27
+ return !!this.proxySettings.url;
28
+ }
29
+ get(type) {
30
+ if (this.hasProxy()) {
31
+ const { strictSsl = true } = this.proxySettings;
32
+ const url = new url_1.URL(this.proxySettings.url);
33
+ const protocol = url.protocol.replace(":", "");
34
+ const options = {
35
+ proxy: {
36
+ host: url.hostname,
37
+ port: (url.port ? +url.port : undefined),
38
+ proxyAuth: url.username && url.password ? `${url.username}:${url.password}` : undefined,
39
+ rejectUnauthorized: strictSsl
40
+ }
41
+ };
42
+ const method = (0, change_case_1.camelCase)([type, "over", protocol].join(" "));
43
+ if (tunnel_1.default[method]) {
44
+ return tunnel_1.default[method](options);
45
+ }
46
+ }
47
+ return null;
48
+ }
49
+ async resolveProxySettings() {
50
+ if (this.hasProxy()) {
51
+ return;
52
+ }
53
+ const result = await Promise.all([
54
+ this.cliExeca.getAsync("npm", ["config", "get", "proxy"]),
55
+ this.cliExeca.getAsync("npm", ["config", "get", "http-proxy"]),
56
+ this.cliExeca.getAsync("npm", ["config", "get", "https-proxy"]),
57
+ this.cliExeca.getAsync("npm", ["config", "get", "strict-ssl"])
58
+ ]);
59
+ const [proxy, httpProxy, httpsProxy, strictSsl] = result.map(cast);
60
+ const url = httpsProxy || httpProxy || proxy;
61
+ if (url) {
62
+ this.proxySettings = {
63
+ url,
64
+ strictSsl: cast(strictSsl) !== false
65
+ };
66
+ }
67
+ }
68
+ };
69
+ tslib_1.__decorate([
70
+ (0, di_1.Value)("proxy", {}),
71
+ tslib_1.__metadata("design:type", Object)
72
+ ], CliProxyAgent.prototype, "proxySettings", void 0);
73
+ tslib_1.__decorate([
74
+ (0, di_1.Inject)(),
75
+ tslib_1.__metadata("design:type", CliExeca_1.CliExeca)
76
+ ], CliProxyAgent.prototype, "cliExeca", void 0);
77
+ CliProxyAgent = tslib_1.__decorate([
78
+ (0, di_1.Injectable)(),
79
+ (0, di_1.Configuration)({
80
+ proxy: {
81
+ url: process.env.HTTPS_PROXY || process.env.HTTP_PROXY,
82
+ strictSsl: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== undefined ? process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0" : true
83
+ }
84
+ })
85
+ ], CliProxyAgent);
86
+ exports.CliProxyAgent = CliProxyAgent;
87
+ //# sourceMappingURL=CliProxyAgent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliProxyAgent.js","sourceRoot":"","sources":["../../../src/services/CliProxyAgent.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAC5B,iCAAkE;AAClE,yCAAoC;AACpC,6CAAsC;AACtC,6BAAwB;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;IAED,GAAG,CAAC,IAAsB;QACxB,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE;YACnB,MAAM,EAAC,SAAS,GAAG,IAAI,EAAC,GAAG,IAAI,CAAC,aAAa,CAAC;YAC9C,MAAM,GAAG,GAAG,IAAI,SAAG,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YAC5C,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAE/C,MAAM,OAAO,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AAC;SAC/D,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnE,MAAM,GAAG,GAAG,UAAU,IAAI,SAAS,IAAI,KAAK,CAAC;QAE7C,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,aAAa,GAAG;gBACnB,GAAG;gBACH,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,KAAK;aACrC,CAAC;SACH;IACH,CAAC;CACF,CAAA;AAxDC;IADC,IAAA,UAAK,EAAC,OAAO,EAAE,EAAE,CAAC;;oDACa;AAGhC;IADC,IAAA,WAAM,GAAE;sCACW,mBAAQ;+CAAC;AALlB,aAAa;IAPzB,IAAA,eAAU,GAAE;IACZ,IAAA,kBAAa,EAAC;QACb,KAAK,EAAE;YACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU;YACtD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI;SAC5H;KACF,CAAC;GACW,aAAa,CA0DzB;AA1DY,sCAAa","sourcesContent":["import tunnel from \"tunnel\";\nimport {Configuration, Inject, Injectable, Value} from \"@tsed/di\";\nimport {CliExeca} from \"./CliExeca\";\nimport {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,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CliRunScript = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ const ProjectPackageJson_1 = require("./ProjectPackageJson");
7
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
+ // @ts-ignore
9
+ const run_script_1 = tslib_1.__importDefault(require("@npmcli/run-script"));
10
+ let CliRunScript = class CliRunScript {
11
+ run(cmd, args, options = {}) {
12
+ return (0, run_script_1.default)({
13
+ event: "run",
14
+ ...options,
15
+ cmd: `${cmd} ${args.join(" ")}`,
16
+ path: options.cwd || this.projectPackageJson.dir,
17
+ env: options.env || {},
18
+ stdio: options.stdio || "inherit",
19
+ banner: false
20
+ });
21
+ }
22
+ };
23
+ tslib_1.__decorate([
24
+ (0, di_1.Inject)(),
25
+ tslib_1.__metadata("design:type", ProjectPackageJson_1.ProjectPackageJson)
26
+ ], CliRunScript.prototype, "projectPackageJson", void 0);
27
+ CliRunScript = tslib_1.__decorate([
28
+ (0, di_1.Injectable)()
29
+ ], CliRunScript);
30
+ exports.CliRunScript = CliRunScript;
31
+ //# sourceMappingURL=CliRunScript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CliRunScript.js","sourceRoot":"","sources":["../../../src/services/CliRunScript.ts"],"names":[],"mappings":";;;;AAAA,iCAA4C;AAC5C,6DAAwD;AACxD,6DAA6D;AAC7D,aAAa;AACb,4EAA2C;AAG3C,IAAa,YAAY,GAAzB,MAAa,YAAY;IAIvB,GAAG,CAAC,GAAW,EAAE,IAAc,EAAE,UAAe,EAAE;QAChD,OAAO,IAAA,oBAAS,EAAC;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,IAAA,WAAM,GAAE;sCACW,uCAAkB;wDAAC;AAF5B,YAAY;IADxB,IAAA,eAAU,GAAE;GACA,YAAY,CAexB;AAfY,oCAAY","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"]}