tnp-helpers 21.0.2 → 21.0.5

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 (321) hide show
  1. package/browser/fesm2022/tnp-helpers.mjs +179 -52
  2. package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
  3. package/browser/package.json +1 -1
  4. package/browser/types/tnp-helpers.d.ts +3202 -0
  5. package/lib/base/classes/base-bower-json.js.map +1 -1
  6. package/lib/base/classes/base-cli-worker/base-cli-worker-config.js.map +1 -1
  7. package/lib/base/classes/base-cli-worker/base-cli-worker-controller.d.ts +2 -2
  8. package/lib/base/classes/base-cli-worker/base-cli-worker-controller.js +31 -13
  9. package/lib/base/classes/base-cli-worker/base-cli-worker-controller.js.map +1 -1
  10. package/lib/base/classes/base-cli-worker/base-cli-worker-database-config.js.map +1 -1
  11. package/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.js.map +1 -1
  12. package/lib/base/classes/base-cli-worker/base-cli-worker.js +1 -0
  13. package/lib/base/classes/base-cli-worker/base-cli-worker.js.map +1 -1
  14. package/lib/base/classes/base-cli-worker/base-cli-worker.utils.js.map +1 -1
  15. package/lib/base/classes/base-command-line-feature.js.map +1 -1
  16. package/lib/base/classes/base-compiler-for-project.js.map +1 -1
  17. package/lib/base/classes/base-db.js.map +1 -1
  18. package/lib/base/classes/base-docker.js.map +1 -1
  19. package/lib/base/classes/base-file-folders-operations.js.map +1 -1
  20. package/lib/base/classes/base-git.js.map +1 -1
  21. package/lib/base/classes/base-global-command-line.js +2 -5
  22. package/lib/base/classes/base-global-command-line.js.map +1 -1
  23. package/lib/base/classes/base-ignore-hide.js.map +1 -1
  24. package/lib/base/classes/base-java-jdk.js.map +1 -1
  25. package/lib/base/classes/base-json-file-reader.js.map +1 -1
  26. package/lib/base/classes/base-library-build.js.map +1 -1
  27. package/lib/base/classes/base-linked-projects.js.map +1 -1
  28. package/lib/base/classes/base-linter.js.map +1 -1
  29. package/lib/base/classes/base-node-modules.js +10 -1
  30. package/lib/base/classes/base-node-modules.js.map +1 -1
  31. package/lib/base/classes/base-npm-helpers.js.map +1 -1
  32. package/lib/base/classes/base-package-json.d.ts +3 -2
  33. package/lib/base/classes/base-package-json.js +7 -1
  34. package/lib/base/classes/base-package-json.js.map +1 -1
  35. package/lib/base/classes/base-process-manager.js.map +1 -1
  36. package/lib/base/classes/base-project-resolver.js.map +1 -1
  37. package/lib/base/classes/base-project.d.ts +4 -4
  38. package/lib/base/classes/base-project.js +0 -3
  39. package/lib/base/classes/base-project.js.map +1 -1
  40. package/lib/base/classes/base-quick-fixes.js +7 -3
  41. package/lib/base/classes/base-quick-fixes.js.map +1 -1
  42. package/lib/base/classes/base-release-process.js.map +1 -1
  43. package/lib/base/classes/base-start-config.backend.js.map +1 -1
  44. package/lib/base/classes/base-static-pages.js.map +1 -1
  45. package/lib/base/classes/base-vscode.js +2 -0
  46. package/lib/base/classes/base-vscode.js.map +1 -1
  47. package/lib/base/commit-data.js.map +1 -1
  48. package/lib/base/config-database.js.map +1 -1
  49. package/lib/base/core-project.d.ts +2 -2
  50. package/lib/base/core-project.js.map +1 -1
  51. package/lib/base/gh-temp-code.js.map +1 -1
  52. package/lib/base/index.js.map +1 -1
  53. package/lib/base/linked-project.js.map +1 -1
  54. package/lib/base/project-database.js.map +1 -1
  55. package/lib/base/tcp-udp-ports/not-assignable-port.entity.js +2 -2
  56. package/lib/base/tcp-udp-ports/ports.controller.js +41 -17
  57. package/lib/base/tcp-udp-ports/ports.controller.js.map +1 -1
  58. package/lib/base/tcp-udp-ports/ports.entity.d.ts +3 -3
  59. package/lib/base/tcp-udp-ports/ports.entity.js +21 -9
  60. package/lib/base/tcp-udp-ports/ports.entity.js.map +1 -1
  61. package/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +19 -1
  62. package/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.js.map +1 -1
  63. package/lib/build-info._auto-generated_.d.ts +1 -1
  64. package/lib/build-info._auto-generated_.js +1 -1
  65. package/lib/helpers/for-backend/helpers-cli-tool.backend.js.map +1 -1
  66. package/lib/helpers/for-backend/helpers-console-gui.js.map +1 -1
  67. package/lib/helpers/for-backend/helpers-file-folders.js.map +1 -1
  68. package/lib/helpers/for-backend/helpers-git.backend.js.map +1 -1
  69. package/lib/helpers/for-backend/helpers-npm.backend.js.map +1 -1
  70. package/lib/helpers/for-backend/helpers-process.js.map +1 -1
  71. package/lib/helpers/for-backend/helpers-vscode.backend.js.map +1 -1
  72. package/lib/helpers/for-browser/angular.helper.d.ts +0 -1
  73. package/lib/helpers/for-browser/angular.helper.js +2 -2
  74. package/lib/helpers/for-browser/helpers-browser.js.map +1 -1
  75. package/lib/helpers/helpers-json5.backend.js.map +1 -1
  76. package/lib/helpers/helpers-numbers.js.map +1 -1
  77. package/lib/helpers/helpers-strings-regexes.js.map +1 -1
  78. package/lib/helpers/helpers-strings.js.map +1 -1
  79. package/lib/helpers/helpers.js.map +1 -1
  80. package/lib/models.js.map +1 -1
  81. package/lib/old/base-component.js +2 -2
  82. package/lib/old/base-formly-component.js +2 -2
  83. package/lib/old/dual-component-ctrl.js +2 -2
  84. package/lib/old/execute-command.js.map +1 -1
  85. package/lib/old/helpers.js.map +1 -1
  86. package/lib/utils.d.ts +6 -0
  87. package/lib/utils.js +58 -1
  88. package/lib/utils.js.map +1 -1
  89. package/migrations/1736198527297_init.d.ts +3 -3
  90. package/migrations/1736198527297_init.js +4 -4
  91. package/migrations/1736198527297_init.js.map +1 -1
  92. package/migrations/1736199486472_addingNotAssignablePorts.d.ts +2 -3
  93. package/migrations/1736199486472_addingNotAssignablePorts.js +2 -3
  94. package/migrations/1736199486472_addingNotAssignablePorts.js.map +1 -1
  95. package/migrations/1736454437350_addFreePorts.d.ts +2 -3
  96. package/migrations/1736454437350_addFreePorts.js +2 -3
  97. package/migrations/1736454437350_addFreePorts.js.map +1 -1
  98. package/package.json +2 -3
  99. package/websql/fesm2022/tnp-helpers.mjs +183 -56
  100. package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
  101. package/websql/package.json +1 -1
  102. package/websql/types/tnp-helpers.d.ts +3202 -0
  103. package/browser/index.d.ts +0 -6
  104. package/browser/lib/base/classes/base-bower-json.d.ts +0 -35
  105. package/browser/lib/base/classes/base-cli-worker/base-cli-worker-config.d.ts +0 -32
  106. package/browser/lib/base/classes/base-cli-worker/base-cli-worker-controller.d.ts +0 -15
  107. package/browser/lib/base/classes/base-cli-worker/base-cli-worker-database-config.d.ts +0 -10
  108. package/browser/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.d.ts +0 -42
  109. package/browser/lib/base/classes/base-cli-worker/base-cli-worker.d.ts +0 -150
  110. package/browser/lib/base/classes/base-cli-worker/base-cli-worker.models.d.ts +0 -45
  111. package/browser/lib/base/classes/base-cli-worker/base-cli-worker.utils.d.ts +0 -6
  112. package/browser/lib/base/classes/base-cli-worker/index.d.ts +0 -8
  113. package/browser/lib/base/classes/base-command-line-feature.d.ts +0 -48
  114. package/browser/lib/base/classes/base-compiler-for-project.d.ts +0 -8
  115. package/browser/lib/base/classes/base-db.d.ts +0 -10
  116. package/browser/lib/base/classes/base-debounce-compiler-for-project.d.ts +0 -29
  117. package/browser/lib/base/classes/base-docker.d.ts +0 -13
  118. package/browser/lib/base/classes/base-feature-for-project.d.ts +0 -7
  119. package/browser/lib/base/classes/base-file-folders-operations.d.ts +0 -17
  120. package/browser/lib/base/classes/base-git.d.ts +0 -211
  121. package/browser/lib/base/classes/base-global-command-line.d.ts +0 -294
  122. package/browser/lib/base/classes/base-ignore-hide.d.ts +0 -47
  123. package/browser/lib/base/classes/base-java-jdk.d.ts +0 -9
  124. package/browser/lib/base/classes/base-json-file-reader.d.ts +0 -72
  125. package/browser/lib/base/classes/base-library-build.d.ts +0 -62
  126. package/browser/lib/base/classes/base-linked-projects.d.ts +0 -30
  127. package/browser/lib/base/classes/base-linter.d.ts +0 -12
  128. package/browser/lib/base/classes/base-node-modules.d.ts +0 -70
  129. package/browser/lib/base/classes/base-npm-helpers.d.ts +0 -53
  130. package/browser/lib/base/classes/base-package-json.d.ts +0 -122
  131. package/browser/lib/base/classes/base-process-manager.d.ts +0 -31
  132. package/browser/lib/base/classes/base-project-resolver.d.ts +0 -41
  133. package/browser/lib/base/classes/base-project.d.ts +0 -259
  134. package/browser/lib/base/classes/base-quick-fixes.d.ts +0 -16
  135. package/browser/lib/base/classes/base-release-process.d.ts +0 -75
  136. package/browser/lib/base/classes/base-static-pages.d.ts +0 -15
  137. package/browser/lib/base/classes/base-vscode.d.ts +0 -54
  138. package/browser/lib/base/classes/index.d.ts +0 -23
  139. package/browser/lib/base/commit-data.d.ts +0 -94
  140. package/browser/lib/base/config-database.d.ts +0 -15
  141. package/browser/lib/base/core-project.d.ts +0 -113
  142. package/browser/lib/base/gh-temp-code.d.ts +0 -17
  143. package/browser/lib/base/index.d.ts +0 -6
  144. package/browser/lib/base/linked-project.d.ts +0 -41
  145. package/browser/lib/base/project-database.d.ts +0 -13
  146. package/browser/lib/base/tcp-udp-ports/index.d.ts +0 -4
  147. package/browser/lib/base/tcp-udp-ports/ports.controller.d.ts +0 -29
  148. package/browser/lib/base/tcp-udp-ports/ports.entity.d.ts +0 -19
  149. package/browser/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +0 -20
  150. package/browser/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.d.ts +0 -20
  151. package/browser/lib/base/tcp-udp-ports/tcp-upd-ports.worker.d.ts +0 -9
  152. package/browser/lib/base/translate.d.ts +0 -228
  153. package/browser/lib/build-info._auto-generated_.d.ts +0 -21
  154. package/browser/lib/helpers/for-backend/helpers-file-folders.d.ts +0 -114
  155. package/browser/lib/helpers/for-backend/helpers-process.d.ts +0 -88
  156. package/browser/lib/helpers/for-browser/angular.helper.d.ts +0 -37
  157. package/browser/lib/helpers/for-browser/helpers-browser.d.ts +0 -12
  158. package/browser/lib/helpers/helpers-array-obj.d.ts +0 -32
  159. package/browser/lib/helpers/helpers-numbers.d.ts +0 -8
  160. package/browser/lib/helpers/helpers-strings-regexes.d.ts +0 -29
  161. package/browser/lib/helpers/helpers-strings.d.ts +0 -56
  162. package/browser/lib/helpers/helpers.d.ts +0 -84
  163. package/browser/lib/index.d.ts +0 -9
  164. package/browser/lib/models.d.ts +0 -178
  165. package/browser/lib/old/execute-command.d.ts +0 -15
  166. package/browser/lib/old/helpers.d.ts +0 -62
  167. package/browser/lib/old/models.d.ts +0 -81
  168. package/browser/lib/utils.d.ts +0 -272
  169. package/browser/migrations/1736198527297_init.d.ts +0 -19
  170. package/browser/migrations/1736199486472_addingNotAssignablePorts.d.ts +0 -11
  171. package/browser/migrations/1736454437350_addFreePorts.d.ts +0 -10
  172. package/browser/migrations/index.d.ts +0 -2
  173. package/browser/migrations/migrations_index._auto-generated_.d.ts +0 -12
  174. package/browser/public-api.d.ts +0 -2
  175. package/lib/base/classes/base-command-line-feature.backend.d.ts +0 -47
  176. package/lib/base/classes/base-command-line-feature.backend.js +0 -147
  177. package/lib/base/classes/base-command-line-feature.backend.js.map +0 -1
  178. package/lib/base/classes/base-global-command-line.backend.d.ts +0 -243
  179. package/lib/base/classes/base-global-command-line.backend.js +0 -2212
  180. package/lib/base/classes/base-global-command-line.backend.js.map +0 -1
  181. package/lib/base/classes/base-powershell.d.ts +0 -58
  182. package/lib/base/classes/base-powershell.js +0 -105
  183. package/lib/base/classes/base-powershell.js.map +0 -1
  184. package/lib/base/classes/base-process/base-process-api.service.d.ts +0 -7
  185. package/lib/base/classes/base-process/base-process.context.d.ts +0 -19
  186. package/lib/base/classes/base-process/base-process.context.js +0 -22
  187. package/lib/base/classes/base-process/base-process.context.js.map +0 -1
  188. package/lib/base/classes/base-process/base-process.controller.d.ts +0 -17
  189. package/lib/base/classes/base-process/base-process.controller.js +0 -91
  190. package/lib/base/classes/base-process/base-process.controller.js.map +0 -1
  191. package/lib/base/classes/base-process/base-process.d.ts +0 -8
  192. package/lib/base/classes/base-process/base-process.defaults-values.d.ts +0 -2
  193. package/lib/base/classes/base-process/base-process.defaults-values.js +0 -9
  194. package/lib/base/classes/base-process/base-process.defaults-values.js.map +0 -1
  195. package/lib/base/classes/base-process/base-process.js +0 -62
  196. package/lib/base/classes/base-process/base-process.js.map +0 -1
  197. package/lib/base/classes/base-process/base-process.models.d.ts +0 -6
  198. package/lib/base/classes/base-process/base-process.models.js +0 -3
  199. package/lib/base/classes/base-process/base-process.models.js.map +0 -1
  200. package/lib/base/classes/base-process/base-process.provider.d.ts +0 -16
  201. package/lib/base/classes/base-process/base-process.provider.js +0 -69
  202. package/lib/base/classes/base-process/base-process.provider.js.map +0 -1
  203. package/lib/base/classes/base-process/base-process.repository copy.d.ts +0 -8
  204. package/lib/base/classes/base-process/base-process.repository copy.js +0 -32
  205. package/lib/base/classes/base-process/base-process.repository copy.js.map +0 -1
  206. package/lib/base/classes/base-process/base-process.repository.d.ts +0 -8
  207. package/lib/base/classes/base-process/base-process.repository.js +0 -32
  208. package/lib/base/classes/base-process/base-process.repository.js.map +0 -1
  209. package/lib/base/classes/base-process/base-process.terminal-ui.d.ts +0 -11
  210. package/lib/base/classes/base-process/base-process.terminal-ui.js +0 -54
  211. package/lib/base/classes/base-process/base-process.terminal-ui.js.map +0 -1
  212. package/lib/base/classes/base-process/base-process.worker.d.ts +0 -16
  213. package/lib/base/classes/base-process/base-process.worker.js +0 -29
  214. package/lib/base/classes/base-process/base-process.worker.js.map +0 -1
  215. package/lib/base/classes/base-process/index.d.ts +0 -1
  216. package/lib/base/classes/base-process/index.js +0 -22
  217. package/lib/base/classes/base-process/index.js.map +0 -1
  218. package/lib/base/classes/base-process/processes.repository.d.ts +0 -0
  219. package/lib/base/classes/base-process/processes.repository.js +0 -5
  220. package/lib/base/classes/base-process/processes.repository.js.map +0 -1
  221. package/lib/env-backend._auto-generated_.d.ts +0 -34
  222. package/lib/env-backend._auto-generated_.js +0 -38
  223. package/lib/env-backend._auto-generated_.js.map +0 -1
  224. package/lib/env-browser._auto-generated_.d.ts +0 -34
  225. package/lib/env-browser._auto-generated_.js +0 -38
  226. package/lib/env-browser._auto-generated_.js.map +0 -1
  227. package/lib/env.backend.d.ts +0 -34
  228. package/lib/env.backend.js +0 -40
  229. package/lib/env.backend.js.map +0 -1
  230. package/lib/env.browser.d.ts +0 -34
  231. package/lib/helpers/for-backend/helpers-dependencies.backend.d.ts +0 -2
  232. package/lib/helpers/for-backend/helpers-dependencies.backend.js +0 -7
  233. package/lib/helpers/for-backend/helpers-dependencies.backend.js.map +0 -1
  234. package/lib/helpers/for-backend/helpers-network.backend.d.ts +0 -9
  235. package/lib/helpers/for-backend/helpers-network.backend.js +0 -44
  236. package/lib/helpers/for-backend/helpers-network.backend.js.map +0 -1
  237. package/lib/validators/validators-firedev.d.ts +0 -3
  238. package/lib/validators/validators-firedev.js +0 -34
  239. package/lib/validators/validators-firedev.js.map +0 -1
  240. package/lib/validators/validators-git.d.ts +0 -3
  241. package/lib/validators/validators-git.js +0 -13
  242. package/lib/validators/validators-git.js.map +0 -1
  243. package/lib/validators/validators-network.d.ts +0 -3
  244. package/lib/validators/validators-network.js +0 -19
  245. package/lib/validators/validators-network.js.map +0 -1
  246. package/lib/validators/validators.d.ts +0 -6
  247. package/lib/validators/validators.js +0 -11
  248. package/lib/validators/validators.js.map +0 -1
  249. package/tmp-environment.json +0 -33
  250. package/websql/index.d.ts +0 -6
  251. package/websql/lib/base/classes/base-bower-json.d.ts +0 -35
  252. package/websql/lib/base/classes/base-cli-worker/base-cli-worker-config.d.ts +0 -32
  253. package/websql/lib/base/classes/base-cli-worker/base-cli-worker-controller.d.ts +0 -15
  254. package/websql/lib/base/classes/base-cli-worker/base-cli-worker-database-config.d.ts +0 -10
  255. package/websql/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.d.ts +0 -42
  256. package/websql/lib/base/classes/base-cli-worker/base-cli-worker.d.ts +0 -150
  257. package/websql/lib/base/classes/base-cli-worker/base-cli-worker.models.d.ts +0 -45
  258. package/websql/lib/base/classes/base-cli-worker/base-cli-worker.utils.d.ts +0 -6
  259. package/websql/lib/base/classes/base-cli-worker/index.d.ts +0 -8
  260. package/websql/lib/base/classes/base-command-line-feature.d.ts +0 -48
  261. package/websql/lib/base/classes/base-compiler-for-project.d.ts +0 -8
  262. package/websql/lib/base/classes/base-db.d.ts +0 -10
  263. package/websql/lib/base/classes/base-debounce-compiler-for-project.d.ts +0 -29
  264. package/websql/lib/base/classes/base-docker.d.ts +0 -13
  265. package/websql/lib/base/classes/base-feature-for-project.d.ts +0 -7
  266. package/websql/lib/base/classes/base-file-folders-operations.d.ts +0 -17
  267. package/websql/lib/base/classes/base-git.d.ts +0 -211
  268. package/websql/lib/base/classes/base-global-command-line.d.ts +0 -294
  269. package/websql/lib/base/classes/base-ignore-hide.d.ts +0 -47
  270. package/websql/lib/base/classes/base-java-jdk.d.ts +0 -9
  271. package/websql/lib/base/classes/base-json-file-reader.d.ts +0 -72
  272. package/websql/lib/base/classes/base-library-build.d.ts +0 -62
  273. package/websql/lib/base/classes/base-linked-projects.d.ts +0 -30
  274. package/websql/lib/base/classes/base-linter.d.ts +0 -12
  275. package/websql/lib/base/classes/base-node-modules.d.ts +0 -70
  276. package/websql/lib/base/classes/base-npm-helpers.d.ts +0 -53
  277. package/websql/lib/base/classes/base-package-json.d.ts +0 -122
  278. package/websql/lib/base/classes/base-process-manager.d.ts +0 -31
  279. package/websql/lib/base/classes/base-project-resolver.d.ts +0 -41
  280. package/websql/lib/base/classes/base-project.d.ts +0 -259
  281. package/websql/lib/base/classes/base-quick-fixes.d.ts +0 -16
  282. package/websql/lib/base/classes/base-release-process.d.ts +0 -75
  283. package/websql/lib/base/classes/base-static-pages.d.ts +0 -15
  284. package/websql/lib/base/classes/base-vscode.d.ts +0 -54
  285. package/websql/lib/base/classes/index.d.ts +0 -23
  286. package/websql/lib/base/commit-data.d.ts +0 -94
  287. package/websql/lib/base/config-database.d.ts +0 -15
  288. package/websql/lib/base/core-project.d.ts +0 -113
  289. package/websql/lib/base/gh-temp-code.d.ts +0 -17
  290. package/websql/lib/base/index.d.ts +0 -6
  291. package/websql/lib/base/linked-project.d.ts +0 -41
  292. package/websql/lib/base/project-database.d.ts +0 -13
  293. package/websql/lib/base/tcp-udp-ports/index.d.ts +0 -4
  294. package/websql/lib/base/tcp-udp-ports/ports.controller.d.ts +0 -29
  295. package/websql/lib/base/tcp-udp-ports/ports.entity.d.ts +0 -19
  296. package/websql/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +0 -20
  297. package/websql/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.d.ts +0 -20
  298. package/websql/lib/base/tcp-udp-ports/tcp-upd-ports.worker.d.ts +0 -9
  299. package/websql/lib/base/translate.d.ts +0 -228
  300. package/websql/lib/build-info._auto-generated_.d.ts +0 -21
  301. package/websql/lib/helpers/for-backend/helpers-file-folders.d.ts +0 -114
  302. package/websql/lib/helpers/for-backend/helpers-process.d.ts +0 -88
  303. package/websql/lib/helpers/for-browser/angular.helper.d.ts +0 -37
  304. package/websql/lib/helpers/for-browser/helpers-browser.d.ts +0 -12
  305. package/websql/lib/helpers/helpers-array-obj.d.ts +0 -32
  306. package/websql/lib/helpers/helpers-numbers.d.ts +0 -8
  307. package/websql/lib/helpers/helpers-strings-regexes.d.ts +0 -29
  308. package/websql/lib/helpers/helpers-strings.d.ts +0 -56
  309. package/websql/lib/helpers/helpers.d.ts +0 -84
  310. package/websql/lib/index.d.ts +0 -9
  311. package/websql/lib/models.d.ts +0 -178
  312. package/websql/lib/old/execute-command.d.ts +0 -15
  313. package/websql/lib/old/helpers.d.ts +0 -62
  314. package/websql/lib/old/models.d.ts +0 -81
  315. package/websql/lib/utils.d.ts +0 -272
  316. package/websql/migrations/1736198527297_init.d.ts +0 -19
  317. package/websql/migrations/1736199486472_addingNotAssignablePorts.d.ts +0 -11
  318. package/websql/migrations/1736454437350_addFreePorts.d.ts +0 -10
  319. package/websql/migrations/index.d.ts +0 -2
  320. package/websql/migrations/migrations_index._auto-generated_.d.ts +0 -12
  321. package/websql/public-api.d.ts +0 -2
@@ -1,2212 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseGlobalCommandLine = void 0;
4
- //#region imports
5
- const readline = require("readline"); // @backend
6
- const rxjs_1 = require("rxjs");
7
- const lib_1 = require("tnp-config/lib");
8
- const lib_2 = require("tnp-core/lib");
9
- const lib_3 = require("tnp-core/lib");
10
- const lib_4 = require("tnp-core/lib");
11
- const lib_5 = require("tnp-core/lib");
12
- const lib_6 = require("tnp-core/lib"); //@backend
13
- const index_1 = require("../../index");
14
- const commit_data_1 = require("../commit-data");
15
- const gh_temp_code_1 = require("../gh-temp-code");
16
- const base_command_line_feature_1 = require("./base-command-line-feature");
17
- //#endregion
18
- class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineFeature {
19
- _() {
20
- index_1.Helpers.error('Please select git command');
21
- }
22
- //#region commands / prevent cwd is not project
23
- /**
24
- * TODO return argument not need for now
25
- */
26
- async cwdIsProject(options) {
27
- //#region @backendFunc
28
- const { requireProjectWithGitRoot } = options || {};
29
- if (!!this.project && !requireProjectWithGitRoot) {
30
- return true;
31
- }
32
- if (requireProjectWithGitRoot &&
33
- (!this.project || !this.project.git.isGitRoot)) {
34
- const proj = this.ins.nearestTo(this.cwd, { findGitRoot: true });
35
- if (proj) {
36
- index_1.Helpers.info(`
37
- Current folder (${this.cwd})
38
- is not a git root folder, but nearest project with
39
- git root has been found in: ${lib_2.chalk.bold(proj.genericName)}
40
-
41
- `);
42
- const useRoot = await index_1.Helpers.questionYesNo('Would you like to use this project ?');
43
- if (useRoot) {
44
- this.project = proj;
45
- this.cwd = proj.location;
46
- return true;
47
- }
48
- else {
49
- index_1.Helpers.error(`[${lib_1.config.frameworkName}] This is not git root project folder`, true, true);
50
- }
51
- }
52
- else {
53
- index_1.Helpers.error(`[${lib_1.config.frameworkName}] This folder is not project folder`, false, true);
54
- }
55
- }
56
- return true;
57
- //#endregion
58
- }
59
- //#endregion
60
- //#region commands / hosts
61
- hosts() {
62
- //#region @backendFunc
63
- index_1.Helpers.run(`code ${(0, lib_3.crossPlatformPath)(lib_5.UtilsNetwork.getEtcHostsPath())}`).sync();
64
- process.exit(0);
65
- //#endregion
66
- }
67
- //#endregion
68
- //#region commands / count commits
69
- countCommits() {
70
- //#region @backendFunc
71
- console.log(index_1.Helpers.git.countCommits(this.cwd));
72
- this._exit();
73
- //#endregion
74
- }
75
- //#endregion
76
- //#region commands / remove submodules
77
- removeSubmodules() {
78
- //#region @backendFunc
79
- index_1.Helpers.taskStarted('Removing submodules...');
80
- for (const folderAbsPath of index_1.Helpers.foldersFrom(this.cwd, {
81
- recursive: false,
82
- })) {
83
- if (index_1.Helpers.exists((0, lib_3.crossPlatformPath)([folderAbsPath, '.git']))) {
84
- try {
85
- index_1.Helpers.run(`git rm --cached ${lib_2.path.basename(folderAbsPath)}`).sync();
86
- }
87
- catch (error) { }
88
- }
89
- }
90
- index_1.Helpers.taskDone('Done');
91
- this._exit();
92
- //#endregion
93
- }
94
- removeSubmodule() {
95
- //#region @backendFunc
96
- index_1.Helpers.taskStarted(`Removing submodules.. ${this.firstArg}`);
97
- if (index_1.Helpers.exists((0, lib_3.crossPlatformPath)([this.cwd, this.firstArg || '', '.git']))) {
98
- try {
99
- index_1.Helpers.run(`git rm --cached ${this.firstArg}`).sync();
100
- }
101
- catch (error) { }
102
- }
103
- index_1.Helpers.taskDone('Done');
104
- this._exit();
105
- //#endregion
106
- }
107
- //#endregion
108
- //#region commands / set editor
109
- async setEditor() {
110
- //#region @backendFunc
111
- await this.ins.configDb.selectCodeEditor();
112
- this._exit();
113
- //#endregion
114
- }
115
- //#endregion
116
- //#region commands / api update
117
- async upapi() {
118
- //#region @backendFunc
119
- await this.apiUpdate();
120
- //#endregion
121
- }
122
- async apiup() {
123
- //#region @backendFunc
124
- await this.apiUpdate();
125
- //#endregion
126
- }
127
- async apiUpdate() {
128
- //#region @backendFunc
129
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
130
- return;
131
- }
132
- index_1.Helpers.info('Updating & push project...');
133
- try {
134
- this.project.git.addAndCommit(`chore: api ${!!this.firstArg ? this.firstArg : 'update'}`);
135
- }
136
- catch (error) { }
137
- await this.project.git.pushCurrentBranch({
138
- askToRetry: true,
139
- forcePushNoQuestion: true,
140
- });
141
- index_1.Helpers.info('Done');
142
- this._exit();
143
- //#endregion
144
- }
145
- //#endregion
146
- //#region commands / chore update
147
- async cu() {
148
- //#region @backendFunc
149
- await this.update();
150
- //#endregion
151
- }
152
- async choreUpdate() {
153
- //#region @backendFunc
154
- await this.update();
155
- //#endregion
156
- }
157
- //#endregion
158
- //#region commands / color vscode
159
- colorvscode() {
160
- //#region @backendFunc
161
- this.settingsVscode();
162
- //#endregion
163
- }
164
- //#endregion
165
- //#region commands / settings vscode
166
- /**
167
- * Generate or update .vscode/settings.json file color settings
168
- */
169
- settingsVscode() {
170
- //#region @backendFunc
171
- this.refreshVscodeColors();
172
- //#endregion
173
- }
174
- refreshVscodeColors() {
175
- //#region @backendFunc
176
- this._regenerateVscodeSettingsColors();
177
- this._exit();
178
- //#endregion
179
- }
180
- _regenerateVscodeSettingsColors(overideBottomColor) {
181
- //#region @backendFunc
182
- index_1.UtilsVSCode.regenerateVsCodeSettingsColors(this.cwd, overideBottomColor);
183
- //#endregion
184
- }
185
- //#endregion
186
- //#region commands / quick git update
187
- /**
188
- * quick git update push
189
- */
190
- async update() {
191
- //#region @backendFunc
192
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
193
- return;
194
- }
195
- index_1.Helpers.info('Updating & push project...');
196
- try {
197
- this.project.git.addAndCommit(`chore: ${!!this.firstArg ? this.firstArg : 'update'}`);
198
- }
199
- catch (error) { }
200
- await this.project.git.pushCurrentBranch({
201
- askToRetry: true,
202
- forcePushNoQuestion: true,
203
- });
204
- index_1.Helpers.info('Done');
205
- this._exit();
206
- //#endregion
207
- }
208
- async updateProject(project, force = false) {
209
- //#region @backendFunc
210
- try {
211
- await project.packageJson.bumpPatchVersion();
212
- }
213
- catch (error) { }
214
- try {
215
- project.git.addAndCommit(`chore: ${!!this.firstArg ? this.args.join(' ') : 'update'}`);
216
- }
217
- catch (error) { }
218
- await project.git.pushCurrentBranch({
219
- askToRetry: true,
220
- forcePushNoQuestion: true,
221
- force,
222
- });
223
- if (!project.isMonorepo) {
224
- for (const child of project.children) {
225
- if (child.git.isGitRoot) {
226
- await this.updateProject(child, force);
227
- }
228
- }
229
- }
230
- //#endregion
231
- }
232
- async deepUp(noExit = false) {
233
- //#region @backendFunc
234
- await this.deepUpdate(noExit);
235
- //#endregion
236
- }
237
- async deepUpForce(noExit = false) {
238
- //#region @backendFunc
239
- await this.deepUpdateForce(noExit);
240
- //#endregion
241
- }
242
- async deepUpdateForce(noExit = false) {
243
- //#region @backendFunc
244
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
245
- return;
246
- }
247
- index_1.Helpers.info('(force) Deep updating & force pushing project with children...');
248
- await this.updateProject(this.project, true);
249
- index_1.Helpers.info('Done');
250
- this._exit();
251
- //#endregion
252
- }
253
- async deepUpdate(noExit = false) {
254
- //#region @backendFunc
255
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
256
- return;
257
- }
258
- index_1.Helpers.info('Deep updating & pushing project with children...');
259
- await this.updateProject(this.project);
260
- index_1.Helpers.info('Done');
261
- this._exit();
262
- //#endregion
263
- }
264
- /**
265
- * Push update
266
- */
267
- async up() {
268
- //#region @backendFunc
269
- await this.update();
270
- //#endregion
271
- }
272
- /**
273
- * Push update
274
- */
275
- async pu() {
276
- //#region @backendFunc
277
- await this.update();
278
- //#endregion
279
- }
280
- //#endregion
281
- //#region commands / develop
282
- async develop() {
283
- //#region @backendFunc
284
- // Helpers.clearConsole();
285
- index_1.Helpers.taskStarted(`getting all projects...`);
286
- const founded = ((await this.ins.projectsDb.getAllProjectsFromDB()) || [])
287
- .filter(p => index_1.Helpers.exists(p.location))
288
- .map(p => {
289
- const proj = this.ins.From(p.location);
290
- // console.log(`Proj for ${p.location} `, !!proj)
291
- if (proj) {
292
- return proj;
293
- // return proj.embeddedProject ? proj.embeddedProject : proj;
294
- }
295
- // const nereset = this.ins.nearestTo(p.location);
296
- // if (nereset) {
297
- // const embeded = nereset.linkedProjects.find(l => crossPlatformPath([nereset.location, l.relativeClonePath]) === p.location);
298
- // if (embeded) {
299
- // return this.ins.From([nereset.location, embeded.relativeClonePath]);
300
- // }
301
- // }
302
- })
303
- .filter(p => !!p);
304
- index_1.Helpers.taskDone(`found ${founded.length} projects...`);
305
- index_1.Helpers.taskStarted(`searching for project...`);
306
- // @ts-ignore
307
- const results = index_1.Helpers.uniqArray([
308
- ...index_1.Helpers.arrays.fuzzy(this.args.join(' '), founded, p => p.name)
309
- .results,
310
- ...index_1.Helpers.arrays.fuzzy(this.args.join(' '), founded, p => p.basename)
311
- .results,
312
- ...index_1.Helpers.arrays.fuzzy(this.args.join(' '), founded, p => p.location)
313
- .results,
314
- ], 'location');
315
- index_1.Helpers.taskDone(`found ${results.length} projects...`);
316
- const openInEditor = async (proj) => {
317
- index_1.Helpers.taskStarted(`Getting code editor info...`);
318
- const editor = await this.ins.configDb.getCodeEditor();
319
- index_1.Helpers.taskDone(`Got code editor info...`);
320
- const embededProject = proj.linkedProjects.embeddedProject;
321
- const porjToOpen = embededProject || proj;
322
- const locaitonFolderToOpen = porjToOpen.location;
323
- index_1.Helpers.info('Initing and opening project...');
324
- try {
325
- await porjToOpen?.struct();
326
- }
327
- catch (error) { }
328
- index_1.Helpers.run(`${editor} ${locaitonFolderToOpen}`).sync();
329
- };
330
- if (results.length === 1) {
331
- await openInEditor(lib_2._.first(results));
332
- }
333
- else if (results.length === 0) {
334
- index_1.Helpers.error(`No project found by name: "${this.args.join(' ')}"`, false, true);
335
- }
336
- else {
337
- index_1.Helpers.info(`Opening console gui to select project...`);
338
- const res = await index_1.Helpers.consoleGui.select('Select project to open', results.map(p => {
339
- return {
340
- name: p.genericName,
341
- value: p.location,
342
- };
343
- }), true);
344
- await openInEditor(this.ins.From(res));
345
- }
346
- this._exit();
347
- //#endregion
348
- }
349
- async dev() {
350
- //#region @backendFunc
351
- return await this.develop();
352
- //#endregion
353
- }
354
- //#endregion
355
- //#region commands / repulll
356
- async repul() {
357
- //#region @backendFunc
358
- await this.repull();
359
- //#endregion
360
- }
361
- async repull() {
362
- //#region @backendFunc
363
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
364
- return;
365
- }
366
- await this.project.git.resetHard({ HEAD: 10 });
367
- await this.pull();
368
- //#endregion
369
- }
370
- //#endregion
371
- //#region commands / pull
372
- async pul() {
373
- //#region @backendFunc
374
- await this.pull();
375
- //#endregion
376
- }
377
- async pull() {
378
- //#region @backendFunc
379
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
380
- return;
381
- }
382
- await this.project.git.pullProcess({
383
- setOrigin: this.params['setOrigin'],
384
- });
385
- this._exit();
386
- //#endregion
387
- }
388
- //#endregion
389
- //#region commands / pull all
390
- async pullAll() {
391
- //#region @backendFunc
392
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
393
- return;
394
- }
395
- await this.project.git.pullProcess({
396
- setOrigin: this.params['setOrigin'],
397
- });
398
- this._exit();
399
- //#endregion
400
- }
401
- //#endregion
402
- //#region commands / push and pull
403
- async pp() {
404
- //#region @backendFunc
405
- const currentBranch = this.project.git.currentBranchName;
406
- this.project
407
- .run(`git push origin ${currentBranch} && git pull origin ${currentBranch}`)
408
- .sync();
409
- console.log('Done push and pull');
410
- this._exit();
411
- //#endregion
412
- }
413
- //#endregion
414
- //#region commands / reset
415
- __resetInfo(branchToReset, withChildren) {
416
- //#region @backendFunc
417
- index_1.Helpers.info(`
418
-
419
- YOU ARE RESETING ${withChildren ? 'EVERYTHING' : 'PROJECT'} ` +
420
- `TO BRANCH: ${lib_2.chalk.bold(branchToReset)}
421
-
422
- - curret project (${this.project.name})
423
- ${withChildren &&
424
- lib_2._.isArray(this.project.children) &&
425
- this.project.children.length > 0
426
- ? `- modules:\n${this.project.children
427
- .map(c => `\t${c.basename} (${lib_2.chalk.yellow(c.name)})`)
428
- .join('\n')}`
429
- : ''}
430
- `);
431
- //#endregion
432
- }
433
- async fetch() {
434
- //#region @backendFunc
435
- try {
436
- this.project?.git?.fetch();
437
- }
438
- catch (error) { }
439
- this._exit();
440
- //#endregion
441
- }
442
- async reset() {
443
- //#region @backendFunc
444
- // Helpers.clearConsole();
445
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
446
- return;
447
- }
448
- const parent = this.project.parent;
449
- const branchFromLinkedProjectConfig = parent?.linkedProjects?.linkedProjects.find(l => {
450
- return ((0, lib_3.crossPlatformPath)([parent.location, l.relativeClonePath]) ===
451
- this.project.location);
452
- })?.defaultBranch;
453
- let overrideBranchToReset = this.firstArg ||
454
- branchFromLinkedProjectConfig ||
455
- this.project.core?.branch ||
456
- this.project.git.getDefaultDevelopmentBranch() ||
457
- this.project.git.currentBranchName;
458
- if (this.project.core?.branch) {
459
- index_1.Helpers.info(`
460
-
461
- Core branch for project: ${this.project.core?.branch}
462
-
463
- `);
464
- }
465
- const resetOnlyChildren = !!this.project.linkedProjects.getLinkedProjectsConfig().resetOnlyChildren;
466
- const branches = index_1.Helpers.uniqArray([
467
- ...this.__filterBranchesByPattern(overrideBranchToReset),
468
- ...this.__filterBranchesByPattern(''),
469
- ]);
470
- const resetChildren = this.project.git.resetIsRestingAlsoChildren();
471
- if (resetChildren && resetOnlyChildren) {
472
- index_1.Helpers.info(`Reseting only children...for defualt branches.`);
473
- }
474
- else {
475
- if (branches.length > 0) {
476
- overrideBranchToReset = await this.__selectBrach(branches, 'reset');
477
- }
478
- else {
479
- index_1.Helpers.error(`No branch found by name "${overrideBranchToReset || this.firstArg}"`, false, true);
480
- }
481
- }
482
- overrideBranchToReset = overrideBranchToReset || '';
483
- this.__resetInfo(overrideBranchToReset
484
- ? overrideBranchToReset
485
- : this.project.git.getDefaultDevelopmentBranch(), resetChildren);
486
- let resetProject = this.project;
487
- if (this.project.git.isInsideGitRepo && !this.project.git.isGitRoot) {
488
- index_1.Helpers.warn(`You are not in root of git repo...`, false);
489
- resetProject = this.ins.nearestTo((0, lib_3.crossPlatformPath)([this.project.location, '..']), {
490
- findGitRoot: true,
491
- });
492
- if (!(await index_1.Helpers.questionYesNo(`Would you like to reset root repo instead (project=${lib_2.chalk.bold.red(resetProject.genericName)}) ?`))) {
493
- index_1.Helpers.error(`Aborted`, false, true);
494
- }
495
- }
496
- const res = await index_1.Helpers.questionYesNo(`Reset hard and pull current project ` +
497
- `${resetChildren && resetProject.linkedProjects.linkedProjects.length > 0 ? '(and children)' : ''} ?`);
498
- if (res) {
499
- await resetProject.resetProcess(overrideBranchToReset);
500
- }
501
- this._exit();
502
- //#endregion
503
- }
504
- //#endregion
505
- //#region commands / soft
506
- async soft() {
507
- //#region @backendFunc
508
- // TODO when aciton commit
509
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
510
- return;
511
- }
512
- const howManyCommits = Number(this.firstArg) || 1;
513
- lib_2._.times(howManyCommits, n => {
514
- console.log(`Resetting soft ${n + 1} commit "${this.project.git.lastCommitMessage()}"`);
515
- this.project.git.resetSoftHEAD(1);
516
- });
517
- this._exit();
518
- //#endregion
519
- }
520
- //#endregion
521
- //#region commands / rebase
522
- async rebase() {
523
- //#region @backendFunc
524
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
525
- return;
526
- }
527
- const currentBranch = this.project.git.currentBranchName;
528
- let safeReset = 10;
529
- let rebaseBranch = this.firstArg || this.project.git.getDefaultDevelopmentBranch();
530
- const branches = this.__filterBranchesByPattern(rebaseBranch);
531
- if (branches.length > 1) {
532
- rebaseBranch = await this.__selectBrach(branches, 'rebase');
533
- }
534
- else if (branches.length === 1) {
535
- rebaseBranch = lib_2._.first(branches);
536
- }
537
- else {
538
- index_1.Helpers.error(`No rebase branch found by name "${rebaseBranch}"`, false, true);
539
- }
540
- index_1.Helpers.info(`
541
- You are rebasing current branch (${currentBranch}) to ${rebaseBranch}
542
-
543
- Files from last commit:
544
-
545
- "${lib_2.chalk.gray(await this.project.git.getCommitMessageByHash(this.project.git.lastCommitHash()))}"
546
- (hash: ${lib_2.chalk.gray(this.project.git.lastCommitHash())})
547
-
548
- are going to be applied after rebase.
549
-
550
-
551
- `);
552
- if (!(await lib_4.UtilsTerminal.confirm({
553
- message: `Do you want to continue ?`,
554
- defaultValue: true,
555
- }))) {
556
- this._exit();
557
- }
558
- try {
559
- this.project.git.resetHard();
560
- this.project.git.checkout(rebaseBranch);
561
- this.project.git.resetHard({ HEAD: safeReset });
562
- await this.project.git.pullCurrentBranch();
563
- this.project.git.checkout(currentBranch);
564
- this.project.git.resetSoftHEAD(1);
565
- this.project.git.stageAllFiles();
566
- this.project.git.stash();
567
- this.project.git.resetHard({ HEAD: safeReset });
568
- this.project.git.rebase(rebaseBranch);
569
- this.project.git.stashApply();
570
- await this.project.struct();
571
- index_1.Helpers.info('REBASE DONE');
572
- }
573
- catch (error) {
574
- index_1.Helpers.renderError(error);
575
- try {
576
- // dummy init to get back to previous vscode settings
577
- await this.project.init();
578
- }
579
- catch (error) { }
580
- index_1.Helpers.error('Not able to rebase', true, true);
581
- }
582
- this._exit();
583
- //#endregion
584
- }
585
- //#endregion
586
- //#region commands / stash
587
- /**
588
- * stash only staged files
589
- */
590
- async stash() {
591
- //#region @backendFunc
592
- index_1.Helpers.info(`Stashing only staged files...`);
593
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
594
- return;
595
- }
596
- this.project.git.stash({ onlyStaged: true });
597
- this._exit();
598
- //#endregion
599
- }
600
- //#endregion
601
- //#region commands / stash all
602
- /**
603
- * stash all files
604
- */
605
- async stashAll() {
606
- //#region @backendFunc
607
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
608
- return;
609
- }
610
- this.project.git.stageAllFiles();
611
- this.project.git.stash();
612
- this._exit();
613
- //#endregion
614
- }
615
- //#endregion
616
- //#region commands / push all origins
617
- /**
618
- * push force to all orgins
619
- */
620
- async pushAllForce() {
621
- //#region @backendFunc
622
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
623
- return;
624
- }
625
- await this.pushAll(true);
626
- //#endregion
627
- }
628
- async pAllForce() {
629
- //#region @backendFunc
630
- await this.pushAllForce();
631
- //#endregion
632
- }
633
- async pAllf() {
634
- //#region @backendFunc
635
- await this.pushAllForce();
636
- //#endregion
637
- }
638
- async pAll() {
639
- //#region @backendFunc
640
- await this.pushAll();
641
- //#endregion
642
- }
643
- /**
644
- * push to all origins
645
- */
646
- async pushAll(force = false) {
647
- //#region @backendFunc
648
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
649
- return;
650
- }
651
- const remotes = this.project.git.allOrigins;
652
- index_1.Helpers.info(`
653
-
654
- Remotes for repo:
655
-
656
- ${remotes.map((r, i) => `${i + 1}. ${r.origin} ${r.url}`).join('\n')}
657
-
658
- `);
659
- for (let index = 0; index < remotes.length; index++) {
660
- const { origin, url } = remotes[index];
661
- index_1.Helpers.taskStarted(`Pushing to ${lib_2.chalk.bold(origin)} (${url})...`);
662
- await this.push({ force, origin, noExit: true });
663
- index_1.Helpers.taskDone(`Pushed to ${origin}`);
664
- }
665
- this._exit();
666
- //#endregion
667
- }
668
- //#endregion
669
- //#region commands / push force
670
- async forcePush() {
671
- //#region @backendFunc
672
- await this.push({ force: true, typeofCommit: 'feature' });
673
- //#endregion
674
- }
675
- async pushForce() {
676
- //#region @backendFunc
677
- await this.push({ force: true, typeofCommit: 'feature' });
678
- //#endregion
679
- }
680
- //#endregion
681
- //#region commands / commit
682
- /**
683
- * Commit and push this for single repo
684
- */
685
- async commit(options = {}) {
686
- //#region @backendFunc
687
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
688
- return;
689
- }
690
- await this.project.git.meltActionCommits();
691
- await this.project.git.pushProcess({
692
- ...options,
693
- forcePushNoQuestion: options.force,
694
- args: this.args,
695
- exitCallBack: () => {
696
- this._exit();
697
- },
698
- skipChildren: true,
699
- overrideCommitMessage: this.args.join(' '),
700
- setOrigin: this.params['setOrigin'],
701
- currentOrigin: this.project.git.originURL,
702
- });
703
- if (options.noExit) {
704
- return;
705
- }
706
- this._exit();
707
- //#endregion
708
- }
709
- //#endregion
710
- //#region commands / push
711
- async _preventPushPullFromNotCorrectBranch() {
712
- //#region @backendFunc
713
- while (true) {
714
- const devBranch = this.project.git.duringPushWarnIfProjectNotOnSpecyficDevBranch();
715
- if (!!devBranch && devBranch !== this.project.git.currentBranchName) {
716
- index_1.Helpers.warn(`
717
-
718
- ${this.project.genericName}
719
-
720
- You are not on ${devBranch} branch. Please switch to this branch and try again
721
-
722
-
723
-
724
- `, false);
725
- const options = {
726
- open: { name: 'Open in vscode' },
727
- continue: { name: 'Continue (check again)' },
728
- continueForce: { name: 'Continue (without checking)' },
729
- exit: { name: 'Exit process' },
730
- };
731
- const res = await index_1.Helpers.selectChoicesAsk('What you want to do ?', Object.keys(options).map(k => {
732
- return { name: options[k].name, value: k };
733
- }));
734
- if (res === 'continue') {
735
- continue;
736
- }
737
- if (res === 'exit') {
738
- this._exit();
739
- }
740
- if (res === 'open') {
741
- this.project.run('code . ').sync();
742
- continue;
743
- }
744
- if (res === 'continueForce') {
745
- return;
746
- }
747
- }
748
- return;
749
- }
750
- //#endregion
751
- }
752
- async qPush() {
753
- //#region @backendFunc
754
- await this.quickPush();
755
- //#endregion
756
- }
757
- async quickPush() {
758
- //#region @backendFunc
759
- await this.push({ skipLint: true });
760
- //#endregion
761
- }
762
- async repushauto() {
763
- //#region @backendFunc
764
- await this.rePush(true);
765
- //#endregion
766
- }
767
- async rePush(skipQuesion = false) {
768
- //#region @backendFunc
769
- const lastCommitMessage = this.project.git.lastCommitMessage();
770
- this.project.git.resetSoftHEAD();
771
- this.project.git.stageAllFiles();
772
- this.project.git.commit(lastCommitMessage);
773
- if (!skipQuesion) {
774
- index_1.Helpers.info(`Last fixed commit:
775
- ${lastCommitMessage}
776
-
777
- ...`);
778
- await lib_4.UtilsTerminal.pressAnyKeyToContinueAsync({
779
- message: `Press any key to force push`,
780
- });
781
- }
782
- await this.project.git.pushCurrentBranch({
783
- forcePushNoQuestion: true,
784
- force: true,
785
- });
786
- this._exit();
787
- //#endregion
788
- }
789
- async push(options = {}) {
790
- //#region @backendFunc
791
- // console.log('args', this.args);
792
- // console.log(`argsWithParams "${this.argsWithParams}"` );
793
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
794
- return;
795
- }
796
- await this._preventPushPullFromNotCorrectBranch();
797
- if (!options.overrideCommitMessage &&
798
- this.project.git.useBranchNameDirectlyAsCommitMessage()) {
799
- options.overrideCommitMessage = (this.project.git.currentBranchName || '')
800
- .split('-')
801
- .join(' ');
802
- const jiraNumbers = commit_data_1.CommitData.extractAndOrderJiraNumbers(this.project.git.currentBranchName) || [];
803
- for (const jiraNum of jiraNumbers) {
804
- options.overrideCommitMessage = options.overrideCommitMessage.replace(jiraNum.replace('-', ' '), jiraNum);
805
- }
806
- }
807
- await this.project.git.pushProcess({
808
- ...options,
809
- forcePushNoQuestion: options.force,
810
- args: options?.overrideCommitMessage
811
- ? (options?.overrideCommitMessage || '').split(' ')
812
- : this.args,
813
- exitCallBack: () => {
814
- this._exit();
815
- },
816
- setOrigin: this.params['setOrigin'],
817
- currentOrigin: this.project.git.originURL,
818
- });
819
- if (options.noExit) {
820
- return;
821
- }
822
- this._exit();
823
- //#endregion
824
- }
825
- //#endregion
826
- //#region commands / melt
827
- async melt() {
828
- //#region @backendFunc
829
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
830
- return;
831
- }
832
- await this.meltUpdateCommits({ hideInfo: true });
833
- this._exit();
834
- //#endregion
835
- }
836
- //#endregion
837
- //#region commands / melt
838
- async meltUp() {
839
- //#region @backendFunc
840
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
841
- return;
842
- }
843
- const alreadyProcessedOrigins = [];
844
- const processProject = async (proj) => {
845
- if (alreadyProcessedOrigins.includes(proj.git.originURL)) {
846
- return;
847
- }
848
- alreadyProcessedOrigins.push(proj.git.originURL);
849
- index_1.Helpers.clearConsole();
850
- await proj.git.resolveLastChanges({
851
- tryAutomaticActionFirst: false,
852
- projectNameAsOutputPrefix: this.project.location !== proj.location ? proj.name : void 0,
853
- });
854
- for (const child of proj.children) {
855
- await processProject(child);
856
- }
857
- };
858
- await processProject(this.project);
859
- index_1.Helpers.info('All projects are up to date with remote');
860
- this._exit();
861
- //#endregion
862
- }
863
- //#endregion
864
- //#region commands / melt
865
- async meltAll() {
866
- //#region @backendFunc
867
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
868
- return;
869
- }
870
- await this.meltUpdateCommits({ hideInfo: true });
871
- for (const child of this.project.children) {
872
- await this.__meltCommitsFunc(child, { hideInfo: true });
873
- }
874
- this._exit();
875
- //#endregion
876
- }
877
- //#endregion
878
- //#region commands / melt updat ecommits
879
- async __meltCommitsFunc(project, options) {
880
- //#region @backendFunc
881
- options = options || {};
882
- const meltedCommits = project.git.meltActionCommits();
883
- if (meltedCommits > 0) {
884
- index_1.Helpers.logInfo(`${meltedCommits} has been soft reset (melted) in ${project.genericName}`);
885
- }
886
- else {
887
- index_1.Helpers.logInfo(`No commits to melt for project ${project.genericName}`);
888
- }
889
- //#endregion
890
- }
891
- async meltUpdateCommits(options) {
892
- //#region @backendFunc
893
- await this.__meltCommitsFunc(this.project, options);
894
- //#endregion
895
- }
896
- //#endregion
897
- //#region commands / push feature
898
- async pf() {
899
- //#region @backendFunc
900
- await this.pushFeature();
901
- //#endregion
902
- }
903
- async pRel() {
904
- //#region @backendFunc
905
- await this.pushRelease();
906
- //#endregion
907
- }
908
- async pRelease() {
909
- //#region @backendFunc
910
- await this.pushRelease();
911
- //#endregion
912
- }
913
- async pushRelease() {
914
- //#region @backendFunc
915
- await this.meltUpdateCommits();
916
- await this.push({
917
- typeofCommit: 'release',
918
- commitMessageRequired: true,
919
- overrideCommitMessage: `${lib_2._.first(this.project.releaseProcess.getReleaseWords())} ` +
920
- `version ${this.project.packageJson.version}`,
921
- });
922
- //#endregion
923
- }
924
- async mPush() {
925
- //#region @backendFunc
926
- await this.meltPush();
927
- //#endregion
928
- }
929
- async fmPush() {
930
- //#region @backendFunc
931
- await this.forceMeltPush();
932
- //#endregion
933
- }
934
- async mfPush() {
935
- //#region @backendFunc
936
- await this.forceMeltPush();
937
- //#endregion
938
- }
939
- async mforcePush() {
940
- //#region @backendFunc
941
- await this.forceMeltPush();
942
- //#endregion
943
- }
944
- async meltforcePush() {
945
- //#region @backendFunc
946
- await this.forceMeltPush();
947
- //#endregion
948
- }
949
- async forceMeltPush() {
950
- //#region @backendFunc
951
- await this.meltPush(true);
952
- //#endregion
953
- }
954
- async meltPush(force = false) {
955
- //#region @backendFunc
956
- await this.meltUpdateCommits();
957
- await this.push({
958
- mergeUpdateCommits: true,
959
- force,
960
- });
961
- //#endregion
962
- }
963
- async pushFeature() {
964
- //#region @backendFunc
965
- await this.meltUpdateCommits();
966
- await this.push({ typeofCommit: 'feature', commitMessageRequired: true });
967
- //#endregion
968
- }
969
- //#endregion
970
- //#region commands / push fix
971
- async pushFix() {
972
- //#region @backendFunc
973
- await this.meltUpdateCommits();
974
- await this.push({ typeofCommit: 'bugfix', commitMessageRequired: true });
975
- //#endregion
976
- }
977
- pfix() {
978
- //#region @backendFunc
979
- this.pushFix();
980
- //#endregion
981
- }
982
- //#endregion
983
- //#region commands / push chore
984
- async pushChore() {
985
- //#region @backendFunc
986
- await this.meltUpdateCommits();
987
- await this.push({ typeofCommit: 'chore', commitMessageRequired: true });
988
- //#endregion
989
- }
990
- async pc() {
991
- //#region @backendFunc
992
- await this.pushChore();
993
- //#endregion
994
- }
995
- //#endregion
996
- //#region commands / push refactor
997
- async pushRefactor() {
998
- //#region @backendFunc
999
- await this.meltUpdateCommits();
1000
- await this.push({ typeofCommit: 'refactor', commitMessageRequired: true });
1001
- //#endregion
1002
- }
1003
- async pushref() {
1004
- //#region @backendFunc
1005
- await this.pushRefactor();
1006
- //#endregion
1007
- }
1008
- async pref() {
1009
- //#region @backendFunc
1010
- await this.pushRefactor();
1011
- //#endregion
1012
- }
1013
- //#endregion
1014
- //#region commands / push style
1015
- async pushStyle() {
1016
- //#region @backendFunc
1017
- await this.meltUpdateCommits();
1018
- await this.push({ typeofCommit: 'style', commitMessageRequired: true });
1019
- //#endregion
1020
- }
1021
- async pstyl() {
1022
- //#region @backendFunc
1023
- await this.pushStyle();
1024
- //#endregion
1025
- }
1026
- async pstyle() {
1027
- //#region @backendFunc
1028
- await this.pushStyle();
1029
- //#endregion
1030
- }
1031
- //#endregion
1032
- //#region commands / push docs
1033
- async pushDocs() {
1034
- //#region @backendFunc
1035
- await this.meltUpdateCommits();
1036
- await this.push({ typeofCommit: 'docs', commitMessageRequired: true });
1037
- //#endregion
1038
- }
1039
- async pd() {
1040
- //#region @backendFunc
1041
- await this.pushDocs();
1042
- //#endregion
1043
- }
1044
- async pdocs() {
1045
- //#region @backendFunc
1046
- await this.pushDocs();
1047
- //#endregion
1048
- }
1049
- //#endregion
1050
- //#region commands / push test
1051
- async pushTest() {
1052
- //#region @backendFunc
1053
- await this.meltUpdateCommits();
1054
- await this.push({ typeofCommit: 'test', commitMessageRequired: true });
1055
- //#endregion
1056
- }
1057
- async pTest() {
1058
- //#region @backendFunc
1059
- await this.pushTest();
1060
- //#endregion
1061
- }
1062
- async pTests() {
1063
- //#region @backendFunc
1064
- await this.pushTest();
1065
- //#endregion
1066
- }
1067
- //#endregion
1068
- //#region commands / push perf
1069
- async pushPerf() {
1070
- //#region @backendFunc
1071
- await this.meltUpdateCommits();
1072
- await this.push({
1073
- typeofCommit: 'performance',
1074
- commitMessageRequired: true,
1075
- });
1076
- //#endregion
1077
- }
1078
- //#endregion
1079
- //#region commands / push ci
1080
- async pushCi() {
1081
- //#region @backendFunc
1082
- await this.meltUpdateCommits();
1083
- await this.push({ typeofCommit: 'ci', commitMessageRequired: true });
1084
- //#endregion
1085
- }
1086
- //#endregion
1087
- //#region commands / select branch
1088
- async branch() {
1089
- //#region @backendFunc
1090
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
1091
- return;
1092
- }
1093
- await this.project.struct();
1094
- try {
1095
- this.project.git.fetch();
1096
- }
1097
- catch (error) { }
1098
- let branchName = this.firstArg;
1099
- const branches = this.__filterBranchesByPattern(branchName);
1100
- if (branches.length > 0) {
1101
- branchName = await this.__selectBrach(branches, 'checkout');
1102
- }
1103
- else {
1104
- index_1.Helpers.error(`No branch found by name "${branchName}"`, false, true);
1105
- }
1106
- try {
1107
- this.project.git.stageAllFiles();
1108
- this.project.git.stash();
1109
- }
1110
- catch (error) { }
1111
- this.project.git.checkout(branchName);
1112
- this._exit();
1113
- //#endregion
1114
- }
1115
- //#endregion
1116
- //#region commands / push build
1117
- async pushBuild() {
1118
- //#region @backendFunc
1119
- await this.meltUpdateCommits();
1120
- await this.push({ typeofCommit: 'build', commitMessageRequired: true });
1121
- //#endregion
1122
- }
1123
- //#endregion
1124
- //#region commands / set origin
1125
- async SET_ORIGIN() {
1126
- //#region @backendFunc
1127
- let newOriginNameOrUrl = this.firstArg;
1128
- if (newOriginNameOrUrl === 'ssh') {
1129
- newOriginNameOrUrl = index_1.Helpers.git.originHttpToSsh(index_1.Helpers.git.getOriginURL(this.cwd));
1130
- }
1131
- if (newOriginNameOrUrl === 'http') {
1132
- newOriginNameOrUrl = index_1.Helpers.git.originSshToHttp(index_1.Helpers.git.getOriginURL(this.cwd));
1133
- }
1134
- if (index_1.Helpers.git.isInsideGitRepo(this.cwd)) {
1135
- index_1.Helpers.run(`git remote rm origin`, { cwd: this.cwd }).sync();
1136
- index_1.Helpers.run(`git remote add origin ${newOriginNameOrUrl} `, {
1137
- cwd: this.cwd,
1138
- }).sync();
1139
- index_1.Helpers.info(`Done`);
1140
- }
1141
- else {
1142
- index_1.Helpers.error(`This folder is not a git repo... `, false, true);
1143
- }
1144
- this._exit();
1145
- //#endregion
1146
- }
1147
- //#endregion
1148
- //#region commands / rename origin
1149
- async RENAME_ORIGIN() {
1150
- //#region @backendFunc
1151
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
1152
- return;
1153
- }
1154
- const newOriginNameOrUrl = this.firstArg;
1155
- const proj = this.project;
1156
- if (proj && proj.git.isInsideGitRepo) {
1157
- proj.git.renameOrigin(newOriginNameOrUrl);
1158
- }
1159
- else {
1160
- index_1.Helpers.error(`This folder is not a git repo... `, false, true);
1161
- }
1162
- this._exit();
1163
- //#endregion
1164
- }
1165
- //#endregion
1166
- //#region commands / last hash tag
1167
- async LAST_TAG_HASH() {
1168
- //#region @backendFunc
1169
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
1170
- return;
1171
- }
1172
- index_1.Helpers.info(this.project.git.lastTagHash());
1173
- this._exit();
1174
- //#endregion
1175
- }
1176
- //#endregion
1177
- //#region commands / last tag
1178
- async LAST_TAG() {
1179
- //#region @backendFunc
1180
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
1181
- return;
1182
- }
1183
- const proj = this.project;
1184
- index_1.Helpers.info(`
1185
-
1186
- last tag: ${proj.git.lastTagVersionName}
1187
- last tag hash: ${proj.git.lastTagHash()}
1188
-
1189
- `);
1190
- this._exit();
1191
- //#endregion
1192
- }
1193
- //#endregion
1194
- //#region commands / check tag exists
1195
- CHECK_TAG_EXISTS() {
1196
- //#region @backendFunc
1197
- index_1.Helpers.info(`tag "${this.firstArg}" exits = ${index_1.Helpers.git.checkTagExists(this.firstArg)} `);
1198
- this._exit();
1199
- //#endregion
1200
- }
1201
- //#endregion
1202
- //#region commands / lint
1203
- /**
1204
- * TODO move somewhere
1205
- */
1206
- async lint() {
1207
- //#region @backendFunc
1208
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
1209
- return;
1210
- }
1211
- await this.project.lint();
1212
- //#endregion
1213
- }
1214
- //#endregion
1215
- //#region commands / version
1216
- /**
1217
- * TODO move somewhere
1218
- */
1219
- async version() {
1220
- //#region @backendFunc
1221
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
1222
- return;
1223
- }
1224
- console.log('Current project verison: ' + this.project.packageJson.version);
1225
- this._exit();
1226
- //#endregion
1227
- }
1228
- //#endregion
1229
- //#region commands / init
1230
- /**
1231
- * TODO move somewhere
1232
- */
1233
- async init() {
1234
- //#region @backendFunc
1235
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
1236
- return;
1237
- }
1238
- await this.project.init();
1239
- this._exit();
1240
- //#endregion
1241
- }
1242
- /**
1243
- * init parent and first level children
1244
- */
1245
- async initAll() {
1246
- //#region @backendFunc
1247
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
1248
- return;
1249
- }
1250
- await this.project.init();
1251
- for (const child of this.project.children) {
1252
- await child.init();
1253
- }
1254
- this._exit();
1255
- //#endregion
1256
- }
1257
- //#endregion
1258
- //#region commands / struct
1259
- /**
1260
- * TODO move somewhere
1261
- */
1262
- async struct() {
1263
- //#region @backendFunc
1264
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
1265
- return;
1266
- }
1267
- await this.project.struct();
1268
- this._exit();
1269
- //#endregion
1270
- }
1271
- //#endregion
1272
- //#region commands / info
1273
- /**
1274
- * TODO move somewhere
1275
- */
1276
- async info() {
1277
- //#region @backendFunc
1278
- if (!(await this.cwdIsProject({
1279
- requireProjectWithGitRoot: false,
1280
- }))) {
1281
- return;
1282
- }
1283
- index_1.Helpers.clearConsole();
1284
- index_1.Helpers.info(await this.project.info());
1285
- await this.project.linkedProjects.saveAllLinkedProjectsToDB();
1286
- this._exit();
1287
- //#endregion
1288
- }
1289
- //#endregion
1290
- //#region commands / info
1291
- async modified() {
1292
- //#region @backendFunc
1293
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
1294
- return;
1295
- }
1296
- const proj = this.project;
1297
- const libs = proj.children.filter(child => {
1298
- process.stdout.write('.');
1299
- return child.git.thereAreSomeUncommitedChangeExcept([
1300
- lib_1.config.file.package_json,
1301
- ]);
1302
- });
1303
- console.log('\n' + index_1.Helpers.terminalLine());
1304
- index_1.Helpers.info(libs.length
1305
- ? libs
1306
- .map(c => `${lib_2.chalk.bold(c.name)} (${c.git.uncommitedFiles.map(p => lib_2.chalk.black(lib_2.path.basename(p))).join(', ')})`)
1307
- .join('\n')
1308
- : 'Nothing modifed');
1309
- this._exit();
1310
- //#endregion
1311
- }
1312
- //#endregion
1313
- //#region commands / update
1314
- async refresh() {
1315
- //#region @backendFunc
1316
- await this.project.refreshChildrenProjects({
1317
- askUserAboutUpdate: true,
1318
- });
1319
- this._exit(0);
1320
- //#endregion
1321
- }
1322
- //#endregion
1323
- //#region commands / changes
1324
- async changes() {
1325
- //#region @backendFunc
1326
- index_1.Helpers.info(await this.project.git.changesSummary());
1327
- index_1.Helpers.terminalLine();
1328
- for (const chil of this.project.children) {
1329
- index_1.Helpers.info(await chil.git.changesSummary());
1330
- }
1331
- this._exit();
1332
- //#endregion
1333
- }
1334
- //#endregion
1335
- //#region commands / all tags
1336
- async allTags() {
1337
- //#region @backendFunc
1338
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
1339
- return;
1340
- }
1341
- const allTags = await index_1.Helpers.git.getAllTags(this.cwd);
1342
- console.log(allTags);
1343
- this._exit();
1344
- //#endregion
1345
- }
1346
- //#endregion
1347
- //#region commands / remove tag
1348
- async removeTag() {
1349
- //#region @backendFunc
1350
- let tagToRemove = this.firstArg;
1351
- if (!tagToRemove) {
1352
- const allTags = await index_1.Helpers.git.getAllTags(this.cwd);
1353
- tagToRemove = await lib_4.UtilsTerminal.select({
1354
- question: `Select tag to remove`,
1355
- autocomplete: true,
1356
- choices: allTags.map(t => {
1357
- return { name: t, value: t };
1358
- }),
1359
- });
1360
- }
1361
- index_1.Helpers.git.removeTag(this.cwd, tagToRemove);
1362
- this._exit();
1363
- //#endregion
1364
- }
1365
- //#endregion
1366
- //#region commands / branch name
1367
- BRANCH_NAME() {
1368
- //#region @backendFunc
1369
- console.log(`current branch name: "${index_1.Helpers.git.currentBranchName(process.cwd())}"`);
1370
- this._exit();
1371
- //#endregion
1372
- }
1373
- //#endregion
1374
- //#region commands / remotes
1375
- REMOTES() {
1376
- //#region @backendFunc
1377
- console.log(index_1.Helpers.git.allOrigins(this.cwd));
1378
- this._exit();
1379
- //#endregion
1380
- }
1381
- async SET_REMOTE_SSH() {
1382
- //#region @backendFunc
1383
- await index_1.Helpers.git.changeRemoteFromHttpsToSSh(this.cwd);
1384
- this._exit();
1385
- //#endregion
1386
- }
1387
- async SET_REMOTE_http() {
1388
- //#region @backendFunc
1389
- await index_1.Helpers.git.changeRemoveFromSshToHttps(this.cwd);
1390
- this._exit();
1391
- //#endregion
1392
- }
1393
- async SET_REMOTE_https() {
1394
- //#region @backendFunc
1395
- await this.SET_REMOTE_http();
1396
- //#endregion
1397
- }
1398
- _resolveChildFromArg() {
1399
- //#region @backendFunc
1400
- const { resolved: projFromArg, clearedCommand } = index_1.Helpers.cliTool.resolveItemFromArgsBegin(this.args, arg => this.ins.From([this.cwd, arg]));
1401
- if (!!projFromArg) {
1402
- this.args = clearedCommand.split(' ');
1403
- this.cwd = projFromArg.location;
1404
- this.project = projFromArg;
1405
- }
1406
- //#endregion
1407
- }
1408
- origin() {
1409
- //#region @backendFunc
1410
- this._resolveChildFromArg();
1411
- console.log(index_1.Helpers.git.getOriginURL(this.cwd));
1412
- this._exit();
1413
- //#endregion
1414
- }
1415
- remote() {
1416
- //#region @backendFunc
1417
- console.log(index_1.Helpers.git.getOriginURL(this.cwd));
1418
- this._exit();
1419
- //#endregion
1420
- }
1421
- originHttp() {
1422
- //#region @backendFunc
1423
- console.log(index_1.Helpers.git.originSshToHttp(index_1.Helpers.git.getOriginURL(this.cwd)));
1424
- this._exit();
1425
- //#endregion
1426
- }
1427
- originHttps() {
1428
- //#region @backendFunc
1429
- console.log(index_1.Helpers.git.originSshToHttp(index_1.Helpers.git.getOriginURL(this.cwd)));
1430
- this._exit();
1431
- //#endregion
1432
- }
1433
- originssh() {
1434
- //#region @backendFunc
1435
- console.log(index_1.Helpers.git.originHttpToSsh(index_1.Helpers.git.getOriginURL(this.cwd)));
1436
- this._exit();
1437
- //#endregion
1438
- }
1439
- origins() {
1440
- //#region @backendFunc
1441
- this.REMOTES();
1442
- //#endregion
1443
- }
1444
- //#endregion
1445
- //#region commands / git config
1446
- gitConfig() {
1447
- //#region @backendFunc
1448
- const root = index_1.Helpers.git.findGitRoot(this.cwd);
1449
- index_1.Helpers.run(`code ${(0, lib_3.crossPlatformPath)([root, '.git', 'config'])}`).sync();
1450
- this._exit();
1451
- //#endregion
1452
- }
1453
- //#endregion
1454
- //#region commands / lastCommitHash
1455
- LAST_COMMIT_HASH() {
1456
- //#region @backendFunc
1457
- console.log(index_1.Helpers.git.lastCommitHash(this.cwd));
1458
- this._exit();
1459
- //#endregion
1460
- }
1461
- //#endregion
1462
- //#region commands / commit message by hash
1463
- async COMMIT_MESSAGE_BY_HASH() {
1464
- //#region @backendFunc
1465
- const hash = this.firstArg;
1466
- console.log(await this.project.git.getCommitMessageByHash(hash));
1467
- this._exit();
1468
- //#endregion
1469
- }
1470
- //#endregion
1471
- //#region commands / last 5 commit hashes
1472
- async LAST_5_COMMITS() {
1473
- //#region @backendFunc
1474
- for (let index = 0; index < 5; index++) {
1475
- const hash = await this.project.git.getCommitHashByIndex(index);
1476
- console.log(hash);
1477
- }
1478
- this._exit();
1479
- //#endregion
1480
- }
1481
- //#endregion
1482
- //#region commands / update deps from
1483
- async updateDepsFrom() {
1484
- //#region @backendFunc
1485
- let locations = this.args.join(' ').trim() === '' ? [] : this.args;
1486
- if (lib_2._.isArray(locations)) {
1487
- locations = locations.map(l => {
1488
- if (lib_2.path.isAbsolute(l)) {
1489
- return lib_2.path.resolve(l);
1490
- }
1491
- return lib_2.path.resolve(lib_2.path.join(this.cwd, l));
1492
- });
1493
- }
1494
- this.project.packageJson.updateDepsFrom(locations);
1495
- this._exit();
1496
- //#endregion
1497
- }
1498
- //#endregion
1499
- //#region is terminal supported
1500
- isSupportedTaonTerminal() {
1501
- //#region @backendFunc
1502
- console.log(`Terminal is supported: ${index_1.Helpers.isSupportedTaonTerminal}`);
1503
- this._exit();
1504
- //#endregion
1505
- }
1506
- //#endregion
1507
- //#region is terminal running inside cmd
1508
- isRunningInWindowsCmd() {
1509
- //#region @backendFunc
1510
- console.log(`Is terminal running insdie cmd.exe: ${lib_2.UtilsOs.isRunningInWindowsCmd()}`);
1511
- this._exit();
1512
- //#endregion
1513
- }
1514
- //#endregion
1515
- //#region is running inside powershell
1516
- isRunningInWindowsPowerShell() {
1517
- //#region @backendFunc
1518
- console.log(`Is terminal running insdie powershell: ${lib_2.UtilsOs.isRunningInWindowsPowerShell()}`);
1519
- this._exit();
1520
- //#endregion
1521
- }
1522
- //#endregion
1523
- //#region prox ext
1524
- async INSTALL_PROJECT_EXTENSIONS() {
1525
- //#region @backendFunc
1526
- await this.INSTALL_PROJ_EXT();
1527
- //#endregion
1528
- }
1529
- async INSTALL_PROJECT_EXT() {
1530
- //#region @backendFunc
1531
- await this.INSTALL_PROJ_EXT();
1532
- //#endregion
1533
- }
1534
- async INS_PROJ_EXT() {
1535
- //#region @backendFunc
1536
- await this.INSTALL_PROJ_EXT();
1537
- //#endregion
1538
- }
1539
- async INSTALL_PROJ_EXT() {
1540
- //#region @backendFunc
1541
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
1542
- return;
1543
- }
1544
- this.project.vsCodeHelpers.recreateExtensions();
1545
- const p = this.project.pathFor('.vscode/extensions.json');
1546
- const extensions = index_1.Helpers.readJson(p, { recommendations: [] }, true);
1547
- index_1.Helpers.clearConsole();
1548
- await this.project.vsCodeHelpers.installExtensions(extensions.recommendations, true);
1549
- this._exit();
1550
- //#endregion
1551
- }
1552
- //#endregion
1553
- //#region proj db
1554
- async projdb() {
1555
- //#region @backendFunc
1556
- if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
1557
- return;
1558
- }
1559
- index_1.Helpers.info(`Projects db location:
1560
- ${this.project.linkedProjects.projectsDbLocation}
1561
-
1562
- opening in vscode...
1563
-
1564
- `);
1565
- index_1.Helpers.run(`code ${this.project.linkedProjects.projectsDbLocation}`).sync();
1566
- this._exit();
1567
- //#endregion
1568
- }
1569
- //#endregion
1570
- //#region filter all project branches by pattern
1571
- __filterBranchesByPattern(branchPatternOrBranchName) {
1572
- //#region @backendFunc
1573
- const branches = index_1.Helpers.arrays.uniqArray(this.project.git.getBranchesNamesBy(branchPatternOrBranchName) ||
1574
- this.project.getMainBranches());
1575
- // console.log('branches', branches);
1576
- return branches;
1577
- //#endregion
1578
- }
1579
- //#endregion
1580
- //#region select branch from list of branches
1581
- async __selectBrach(branches, task) {
1582
- //#region @backendFunc
1583
- const actionWithoutChildren = task === 'reset' && !this.project.git.resetIsRestingAlsoChildren();
1584
- const childrenMsg = actionWithoutChildren
1585
- ? '(without children)'
1586
- : this.project.children.length == 0
1587
- ? '(no children in project)'
1588
- : '(with children)';
1589
- return await index_1.Helpers.autocompleteAsk(`Choose branch to ${task} in this project ${childrenMsg}: `, branches.map(b => {
1590
- return { name: b, value: b };
1591
- }));
1592
- //#endregion
1593
- }
1594
- //#endregion
1595
- //#region commands / clone
1596
- async clone() {
1597
- //#region @backendFunc
1598
- let url = this.firstArg;
1599
- const originType = this.params['setOrigin'];
1600
- if (originType) {
1601
- if (originType === 'ssh') {
1602
- url = index_1.Helpers.git.originHttpToSsh(url);
1603
- }
1604
- if (originType === 'http') {
1605
- url = index_1.Helpers.git.originSshToHttp(url);
1606
- }
1607
- }
1608
- await index_1.Helpers.git.clone({
1609
- url,
1610
- cwd: this.cwd,
1611
- });
1612
- this._exit();
1613
- //#endregion
1614
- }
1615
- //#endregion
1616
- //#region commands / gh temp
1617
- async ghSave() {
1618
- //#region @backendFunc
1619
- await new gh_temp_code_1.GhTempCode(this.cwd, this.project).init().save();
1620
- this._exit();
1621
- //#endregion
1622
- }
1623
- async ghRestore() {
1624
- //#region @backendFunc
1625
- await new gh_temp_code_1.GhTempCode(this.cwd, this.project).init().restore();
1626
- this._exit();
1627
- //#endregion
1628
- }
1629
- //#endregion
1630
- //#region commands / start cli service ports worker
1631
- async ports() {
1632
- //#region @backendFunc
1633
- await this.ins.portsWorker.terminalUI.infoScreen();
1634
- //#endregion
1635
- }
1636
- /**
1637
- * tnp startCliServicePortsWorker --restart
1638
- */
1639
- async startCliServicePortsWorker() {
1640
- //#region @backendFunc
1641
- await this.ins.portsWorker.cliStartProcedure(this.params);
1642
- //#endregion
1643
- }
1644
- //#endregion
1645
- //#region commands / wait for any key
1646
- async waitForUserAnyKey() {
1647
- //#region @backendFunc
1648
- console.log('Press any key to exit...');
1649
- await lib_4.UtilsTerminal.waitForUserAnyKey(async () => {
1650
- console.log('Exiting...');
1651
- this._exit();
1652
- });
1653
- //#endregion
1654
- }
1655
- //#endregion
1656
- //#region commands / pause terminal
1657
- pauseTerminal() {
1658
- //#region @backendFunc
1659
- index_1.Helpers.pressKeyAndContinue();
1660
- this._exit();
1661
- //#endregion
1662
- }
1663
- //#endregion
1664
- //#region commands / sleep terminal
1665
- sleepTerminal() {
1666
- //#region @backendFunc
1667
- index_1.Helpers.info(`Sleeping terminal for 1 second... before exit`);
1668
- index_1.Helpers.sleep(1);
1669
- this._exit();
1670
- //#endregion
1671
- }
1672
- //#endregion
1673
- //#region commands / gh pages init
1674
- async ghPagesInit() {
1675
- //#region @backendFunc
1676
- await this.project.init();
1677
- await this.project.staticPages.init(this.params['provider'] || 'github', !!this.params['full']);
1678
- index_1.Helpers.run('code .', {
1679
- cwd: this.project.staticPages.mainFolderAbsPath,
1680
- }).sync();
1681
- this._exit();
1682
- //#endregion
1683
- }
1684
- //#endregion
1685
- //#region commands / is port in use
1686
- async isPortInUse() {
1687
- //#region @backendFunc
1688
- const port = parseInt(this.firstArg);
1689
- console.log(`Port ${port} is in use: ${await lib_2.UtilsOs.isPortInUse(port)}`);
1690
- this._exit();
1691
- //#endregion
1692
- }
1693
- //#endregion
1694
- //#region commands / proc menu
1695
- //#region @notForNpm
1696
- async procMenu() {
1697
- //#region @backendFunc
1698
- const { BaseProcessManger, CommandConfig } = await Promise.resolve().then(() => require('./base-process-manager'));
1699
- const ngBuildLibCommand = CommandConfig.from({
1700
- name: 'TSC',
1701
- cmd: 'node -e "let i = 0; setInterval(() => console.log(\'TSC lib Compiled success \' + (++i)), 1000)"',
1702
- goToNextCommandWhenOutput: {
1703
- stdoutContains: 'TSC lib Compiled success 5',
1704
- },
1705
- });
1706
- const angularNormalNgServe = CommandConfig.from({
1707
- shouldBeActiveOrAlreadyBuild: [ngBuildLibCommand],
1708
- name: 'NG Normal',
1709
- cmd: 'node -e "let i = 0; setInterval(() => console.log(\'NG NORMAL: Hello from ng --watch \' + (++i)), 1200)"',
1710
- goToNextCommandWhenOutput: {
1711
- stdoutContains: 'NG NORMAL: Hello from ng --watch 5',
1712
- },
1713
- });
1714
- const angularWebsqlNgServe = CommandConfig.from({
1715
- shouldBeActiveOrAlreadyBuild: [ngBuildLibCommand],
1716
- name: 'NG websql',
1717
- cmd: 'node -e "let i = 0; setInterval(() => console.log(\'NG WEBSQL: Hello from ng --watch \' + (++i)), 1200)"',
1718
- goToNextCommandWhenOutput: {
1719
- stdoutContains: 'NG WEBSQL: Hello from ng --watch 5',
1720
- },
1721
- });
1722
- const electronNormalNgServe = CommandConfig.from({
1723
- shouldBeActiveOrAlreadyBuild: [angularNormalNgServe],
1724
- name: 'ELECTRON Normal',
1725
- cmd: 'node -e "let i = 0; setInterval(() => console.log(\'ELECTRON Normal: Hello from electron \' + (++i)), 1500)"',
1726
- });
1727
- const updateAssets = CommandConfig.from({
1728
- name: 'Update assets',
1729
- cmd: 'node -e "let i = 0; setInterval(() => console.log(\'Updated assets \' + (++i)), 1000)"',
1730
- });
1731
- await new BaseProcessManger(this.project).init({
1732
- title: 'What do you want to build?',
1733
- header: 'Starting process selection...',
1734
- watch: true,
1735
- commands: [
1736
- ngBuildLibCommand,
1737
- angularNormalNgServe,
1738
- angularWebsqlNgServe,
1739
- electronNormalNgServe,
1740
- updateAssets,
1741
- ],
1742
- });
1743
- //#endregion
1744
- }
1745
- //#endregion
1746
- //#endregion
1747
- //#region commands / proc info
1748
- procInfo() {
1749
- //#region @backendFunc
1750
- this.processInfo();
1751
- //#endregion
1752
- }
1753
- processInfo() {
1754
- //#region @backendFunc
1755
- index_1.Helpers.info(`
1756
-
1757
- Is running in CLI mode: ${lib_2.UtilsOs.isRunningInCliMode()}
1758
- Is running in Mocha test: ${lib_2.UtilsOs.isRunningInMochaTest()}
1759
- Is running in VSCode extension: ${lib_2.UtilsOs.isRunningInVscodeExtension()}
1760
- Is running in Electron: ${lib_2.UtilsOs.isRunningInElectron()}
1761
- Is running in Docker: ${lib_2.UtilsOs.isRunningInDocker()}
1762
- Is running in WebSQL: ${lib_2.UtilsOs.isRunningInWebSQL()}
1763
- Is running in WSL: ${lib_2.UtilsOs.isRunningInWsl()}
1764
- Is running in Linux graphics capable environment: ${lib_2.UtilsOs.isRunningInLinuxGraphicsCapableEnvironment()}
1765
- Is running in Node: ${lib_2.UtilsOs.isRunningInNode()}
1766
- Is running in Browser: ${lib_2.UtilsOs.isRunningInBrowser()}
1767
-
1768
- `);
1769
- this._exit();
1770
- //#endregion
1771
- }
1772
- //#endregion
1773
- //#region commands / last git tag
1774
- lastGitTag() {
1775
- //#region @backendFunc
1776
- console.log('Latest tag');
1777
- console.log(this.project?.git.lastTagVersionName);
1778
- this._exit();
1779
- //#endregion
1780
- }
1781
- //#endregion
1782
- //#region commands / check ports
1783
- async checkPort() {
1784
- //#region @backendFunc
1785
- await this.checkPorts();
1786
- //#endregion
1787
- }
1788
- async checkPorts() {
1789
- //#region @backendFunc
1790
- const ports = this.args
1791
- .join(' ')
1792
- .replace(/\,/, '')
1793
- .split(' ')
1794
- .map(p => {
1795
- return parseInt(p);
1796
- });
1797
- console.log(`Checking ports: ${ports.join(', ')}`);
1798
- if (ports.length === 0) {
1799
- index_1.Helpers.error(`No ports provided`, false, true);
1800
- }
1801
- for (const port of ports) {
1802
- const isPortInUse = await lib_2.UtilsOs.isPortInUse(port);
1803
- console.log(`Port ${port} is in use: ${isPortInUse ? lib_2.chalk.red('YES') : lib_2.chalk.green('NO')}`);
1804
- }
1805
- this._exit();
1806
- //#endregion
1807
- }
1808
- //#endregion
1809
- //#region commands / remove symlinks
1810
- removeSymlinksDryRun() {
1811
- //#region @backendFunc
1812
- index_1.Helpers.removeSymlinks(this.project.nodeModules.path, {
1813
- dryRun: true,
1814
- });
1815
- //#endregion
1816
- }
1817
- //#endregion
1818
- //#region commands / select java
1819
- async selectJava() {
1820
- //#region @backendFunc
1821
- const selectedJava = await index_1.UtilsJava.selectJdkVersion();
1822
- index_1.UtilsJava.updateJavaHomePath(selectedJava);
1823
- //#endregion
1824
- }
1825
- //#endregion
1826
- //#region commands / select tomcat
1827
- async selectTomcat() {
1828
- //#region @backendFunc
1829
- const selectedTomcat = await index_1.UtilsJava.selectTomcatVersion();
1830
- index_1.UtilsJava.updateTomcatHomePath(selectedTomcat);
1831
- this._exit();
1832
- //#endregion
1833
- }
1834
- //#endregion
1835
- //#region commands / ln
1836
- LN() {
1837
- //#region @backendFunc
1838
- const [source, dest] = this.args;
1839
- index_1.Helpers.createSymLink(source, dest);
1840
- this._exit();
1841
- //#endregion
1842
- }
1843
- //#endregion
1844
- //#region commands / copy
1845
- copy() {
1846
- //#region @backendFunc
1847
- let [from, to] = this.args;
1848
- from = lib_2.path.isAbsolute(from)
1849
- ? (0, lib_3.crossPlatformPath)(from)
1850
- : (0, lib_3.crossPlatformPath)([this.cwd, from]);
1851
- to = lib_2.path.isAbsolute(to)
1852
- ? (0, lib_3.crossPlatformPath)(to)
1853
- : (0, lib_3.crossPlatformPath)([this.cwd, to]);
1854
- if (lib_2.path.basename(to) !== lib_2.path.basename(from)) {
1855
- to = (0, lib_3.crossPlatformPath)([to, lib_2.path.basename(from)]);
1856
- }
1857
- index_1.Helpers.taskStarted(`Copying from ${from} to ${to}`);
1858
- if (!index_1.Helpers.exists(from)) {
1859
- index_1.Helpers.error(`Source file or folder "${from}" does not exist`, false, true);
1860
- }
1861
- if (index_1.Helpers.isFolder(from)) {
1862
- index_1.Helpers.copy(from, to);
1863
- }
1864
- else {
1865
- index_1.Helpers.copyFile(from, to);
1866
- }
1867
- index_1.Helpers.taskDone(`Copied`);
1868
- this._exit();
1869
- //#endregion
1870
- }
1871
- //#endregion
1872
- //#region commands / simulate domain
1873
- async simulateDomain() {
1874
- //#region @backendFunc
1875
- // UtilsTerminal.clearConsole();
1876
- await lib_5.UtilsNetwork.simulateDomain(this.args);
1877
- this._exit();
1878
- //#endregion
1879
- }
1880
- //#endregion
1881
- //#region commands / preview
1882
- async preview() {
1883
- //#region @backendFunc
1884
- //#region handle preview of docker compose
1885
- if ([lib_1.fileName.docker_compose_yml, lib_1.fileName.compose_yml].includes(lib_2.path.basename(this.firstArg))) {
1886
- const simulateDomain = this.params['domain'] || this.params['domains'];
1887
- const firstArg = lib_2.path.isAbsolute(this.firstArg)
1888
- ? this.firstArg
1889
- : (0, lib_3.crossPlatformPath)([this.cwd, this.firstArg]);
1890
- const cwd = (0, lib_3.crossPlatformPath)(lib_2.path.dirname(firstArg));
1891
- const composeFileName = lib_2.path.basename(firstArg);
1892
- // import { spawn } from 'child_process';
1893
- // import { readFileSync } from 'fs';
1894
- // import { resolve } from 'path';
1895
- const envPath = (0, lib_3.crossPlatformPath)([cwd, '.env']);
1896
- const COMPOSE_PROJECT_NAME = lib_5.UtilsDotFile.getValueFromDotFile(envPath, 'COMPOSE_PROJECT_NAME');
1897
- const envContent = lib_5.UtilsDotFile.getValuesKeysAsJsonObject(envPath) || {};
1898
- const allDomains = lib_2.Utils.uniqArray(Object.keys(envContent)
1899
- .filter(key => {
1900
- return key.startsWith('FRONTEND_HOST_URL_');
1901
- })
1902
- .map(domainKey => envContent[domainKey]));
1903
- if (simulateDomain && allDomains.length === 0) {
1904
- index_1.Helpers.error(`No domains to simulate found in .env file.
1905
-
1906
- Before release build update your
1907
-
1908
- env.ts or env.angular-node-app.ENVIRONTMENT_NAME.ts with
1909
-
1910
- ${lib_2.chalk.bold(`website.useDomain = true;`)}
1911
-
1912
- `, false, true);
1913
- }
1914
- const project = this.ins.From(cwd);
1915
- await project.docker.updateDockerComposePorts();
1916
- let closing = false;
1917
- const triggerRevertChangesToEtcHosts = new rxjs_1.Subject();
1918
- if (simulateDomain) {
1919
- await lib_5.UtilsNetwork.simulateDomain(allDomains, {
1920
- triggerRevertChangesToEtcHosts,
1921
- });
1922
- }
1923
- const child = project.docker.getDockerComposeUpExecChildProcess('up');
1924
- console.log(`
1925
-
1926
-
1927
- ${lib_2.chalk.bold('PRESS ANY KEY TO STOP')} RUNNING CONTAINER(S) ` +
1928
- `FOR ${lib_2.chalk.bold.underline(COMPOSE_PROJECT_NAME)}
1929
- ${simulateDomain ? `AND SIMULATING DOMAINS: ${allDomains.join(', ')} IN ETC/HOST` : ''}
1930
-
1931
-
1932
- `);
1933
- process.stdin.setRawMode(true);
1934
- process.stdin.resume();
1935
- process.stdin.on('data', () => {
1936
- if (closing) {
1937
- return;
1938
- }
1939
- // If we are already closing, ignore further input
1940
- closing = true;
1941
- triggerRevertChangesToEtcHosts.next();
1942
- console.log('Stopping container...');
1943
- child.kill('SIGINT');
1944
- console.log('Exiting...');
1945
- const downProcess = project.docker.getDockerComposeUpExecChildProcess('down');
1946
- downProcess.on('close', code => {
1947
- console.log(`docker compose down exited with code ${code}`);
1948
- process.exit(0);
1949
- });
1950
- });
1951
- }
1952
- else {
1953
- index_1.Helpers.error(`You can preview only docker-compose.yml or compose.yml files`, false, true);
1954
- }
1955
- //#endregion
1956
- //#endregion
1957
- }
1958
- //#endregion
1959
- //#region commands / shorten
1960
- /**
1961
- * read huge file and display only lines with specyfic words
1962
- */
1963
- async shorten() {
1964
- //#region @backendFunc
1965
- const rl = readline.createInterface({
1966
- input: lib_2.fse.createReadStream(lib_2.path.isAbsolute(this.firstArg)
1967
- ? (0, lib_3.crossPlatformPath)(this.firstArg)
1968
- : (0, lib_3.crossPlatformPath)([this.cwd, this.firstArg]), { encoding: 'utf8' }),
1969
- crlfDelay: Infinity,
1970
- });
1971
- const keywords = this.args.splice(1);
1972
- console.log(`Searching for keywords: ${keywords.join(', ')}`);
1973
- for await (const line of rl) {
1974
- if (keywords.some(word => line.includes(word))) {
1975
- console.log(line);
1976
- }
1977
- }
1978
- index_1.Helpers.info(`File processed`);
1979
- this._exit();
1980
- //#endregion
1981
- }
1982
- //#endregion
1983
- //#region commands / dump packages versions
1984
- dumpPackagesVersions() {
1985
- //#region @backendFunc
1986
- const getData = (location) => {
1987
- const version = index_1.Helpers.readValueFromJson((0, lib_3.crossPlatformPath)([location, lib_1.fileName.package_json]), 'version');
1988
- const name = index_1.Helpers.readValueFromJson((0, lib_3.crossPlatformPath)([location, lib_1.fileName.package_json]), 'name');
1989
- return { version, name };
1990
- };
1991
- const pkgs = index_1.Helpers.foldersFrom([this.cwd, lib_1.folderName.node_modules], {
1992
- recursive: false,
1993
- })
1994
- .reduce((arr, c) => {
1995
- if (lib_2.path.basename(c).startsWith('@')) {
1996
- const newData = index_1.Helpers.foldersFrom([
1997
- this.cwd,
1998
- lib_1.folderName.node_modules,
1999
- lib_2.path.basename(c),
2000
- ]).map(c2 => getData(c2));
2001
- return arr.concat(newData);
2002
- }
2003
- return arr.concat(getData(c));
2004
- }, [])
2005
- .reduce((arr, c) => {
2006
- return lib_2._.merge(arr, { [c.name]: c.version });
2007
- }, {});
2008
- index_1.Helpers.writeJson([this.cwd, 'packages-versions.json'], pkgs);
2009
- index_1.Helpers.info(`packages-versions.json created with ${pkgs.length} packages`);
2010
- this._exit();
2011
- //#endregion
2012
- }
2013
- //#endregion
2014
- //#region commands / zip
2015
- async zip() {
2016
- //#region @backendFunc
2017
- let folderPath = (0, lib_3.crossPlatformPath)(this.firstArg);
2018
- if (!lib_2.path.isAbsolute(folderPath)) {
2019
- folderPath = (0, lib_3.crossPlatformPath)([this.cwd, this.firstArg]);
2020
- }
2021
- if (!index_1.Helpers.exists(folderPath)) {
2022
- index_1.Helpers.error(`File or folder to zip does not exist: ${folderPath}`, false, true);
2023
- }
2024
- if (!index_1.Helpers.isFolder(folderPath)) {
2025
- index_1.Helpers.error(`You can zip only folders. Provided path is not a folder: ${folderPath}`, false, true);
2026
- }
2027
- const zipFilePath = await index_1.UtilsZip.zipDir(folderPath, {
2028
- overrideIfZipFileExists: true,
2029
- });
2030
- index_1.Helpers.info(`Created zip file: ${zipFilePath}`);
2031
- this._exit();
2032
- //#endregion
2033
- }
2034
- //#endregion
2035
- //#region commands / unzip
2036
- async unzip() {
2037
- //#region @backendFunc
2038
- let folderPath = (0, lib_3.crossPlatformPath)(this.firstArg);
2039
- if (!lib_2.path.isAbsolute(folderPath)) {
2040
- folderPath = (0, lib_3.crossPlatformPath)([this.cwd, this.firstArg]);
2041
- }
2042
- if (!index_1.Helpers.exists(folderPath)) {
2043
- index_1.Helpers.error(`File or folder to zip does not exist: ${folderPath}`, false, true);
2044
- }
2045
- await index_1.UtilsZip.unzipArchive(folderPath);
2046
- index_1.Helpers.info(`Created zip file: ${folderPath.replace('.zip', '')}`);
2047
- this._exit();
2048
- //#endregion
2049
- }
2050
- //#endregion
2051
- //#region commands / start transmission
2052
- async startTransmission() {
2053
- //#region @backendFunc
2054
- await this._removeTransmission();
2055
- const userProfile = process.env.USERPROFILE || lib_2.os.homedir();
2056
- const downloadsDir = lib_2.path.join(userProfile, 'Downloads');
2057
- const configDir = lib_2.path.join(userProfile, 'transmission-config');
2058
- await lib_2.UtilsProcess.killProcessOnPort(9091);
2059
- const ctrl = await this.ins.portsWorker.getControllerForRemoteConnection();
2060
- const data = await ctrl
2061
- .registerAndAssignPort('transmission service for whole system')
2062
- .request();
2063
- const mainPort = data.body.json.port;
2064
- index_1.Helpers.info(`Transmission will use port: ${mainPort}`);
2065
- const args = [
2066
- 'run',
2067
- '-d',
2068
- '--name',
2069
- 'transmission',
2070
- '-p',
2071
- '9091:9091',
2072
- '-p',
2073
- `${mainPort}:${mainPort}`,
2074
- '-p',
2075
- `${mainPort}:${mainPort}/udp`,
2076
- '-e',
2077
- 'TZ=Europe/Warsaw',
2078
- '-e',
2079
- `TRANSMISSION_PEER_PORT=${mainPort}`,
2080
- '-v',
2081
- `${downloadsDir}:/downloads`,
2082
- '-v',
2083
- `${configDir}:/config`,
2084
- '--restart',
2085
- 'unless-stopped',
2086
- 'linuxserver/transmission:latest',
2087
- ];
2088
- console.log('Running:', 'docker', args.join(' '));
2089
- const child = lib_6.child_process.spawn('docker', args, { stdio: 'inherit' });
2090
- child.on('exit', code => {
2091
- if (code === 0) {
2092
- console.log('✅ Transmission container started');
2093
- console.log('➡ Open http://localhost:9091 in your browser');
2094
- }
2095
- else {
2096
- console.error('❌ Docker exited with code', code);
2097
- }
2098
- this._exit();
2099
- });
2100
- //#endregion
2101
- }
2102
- async _removeTransmission() {
2103
- //#region @backendFunc
2104
- return new Promise(resolve => {
2105
- const args = ['rm', '-f', 'transmission'];
2106
- console.log('Running:', 'docker', args.join(' '));
2107
- const child = lib_6.child_process.spawn('docker', args, { stdio: 'inherit' });
2108
- child.on('exit', code => {
2109
- if (code === 0) {
2110
- console.log('🗑️ Transmission container removed');
2111
- }
2112
- else {
2113
- // In bash `2>$null` would silence errors; here we just log a note
2114
- console.warn('⚠️ Could not remove container (maybe it doesn’t exist)');
2115
- }
2116
- resolve();
2117
- });
2118
- });
2119
- //#endregion
2120
- }
2121
- //#endregion
2122
- //#region commands / backup branch
2123
- async backupBranch() {
2124
- //#region @backendFunc
2125
- await this.project.git.backupBranch(this.firstArg);
2126
- this._exit();
2127
- //#endregion
2128
- }
2129
- async bb() {
2130
- //#region @backendFunc
2131
- await this.backupBranch();
2132
- //#endregion
2133
- }
2134
- //#endregion
2135
- //#region commands / count code lines
2136
- async countCodeLines() {
2137
- //#region @backendFunc
2138
- await this.countLines();
2139
- //#endregion
2140
- }
2141
- async countLines() {
2142
- //#region @backendFunc
2143
- let extensions = (this.args || []).filter(f => !!f).map(ext => `.${ext}`);
2144
- extensions = extensions.length ? extensions : ['.ts', '.tsx'];
2145
- console.log('Counting SLOC for extensions: ', extensions.join(', '));
2146
- const sloc = require('sloc');
2147
- let total = {
2148
- source: 0,
2149
- comment: 0,
2150
- single: 0,
2151
- block: 0,
2152
- empty: 0,
2153
- total: 0,
2154
- };
2155
- const skip = [
2156
- 'node_modules',
2157
- '.',
2158
- 'tmp-',
2159
- 'environments',
2160
- 'dist',
2161
- 'browser',
2162
- ];
2163
- const walk = (folder) => {
2164
- const entries = lib_2.fse.readdirSync(folder, { withFileTypes: true });
2165
- for (const entry of entries) {
2166
- const fullPath = lib_2.path.join(folder, entry.name);
2167
- if (skip.some(s => entry.name.startsWith(s))) {
2168
- continue;
2169
- }
2170
- if (entry.isDirectory()) {
2171
- console.log('Processing: ', lib_2.path.basename(fullPath));
2172
- walk(fullPath);
2173
- }
2174
- else if (extensions.includes(lib_2.path.extname(entry.name))) {
2175
- const code = lib_2.fse.readFileSync(fullPath, 'utf8');
2176
- const stats = sloc(code, lib_2.path.extname(entry.name).slice(1)); // e.g., "ts" or "js"
2177
- for (const key in total) {
2178
- total[key] += stats[key] ?? 0;
2179
- }
2180
- }
2181
- }
2182
- };
2183
- walk((0, lib_3.crossPlatformPath)([
2184
- this.cwd,
2185
- // 'src'
2186
- ]));
2187
- console.log('📊 SLOC Results:');
2188
- console.table(total);
2189
- this._exit?.(); // your existing exit hook
2190
- return total;
2191
- //#endregion
2192
- }
2193
- //#endregion
2194
- //#region commands / is node version ok
2195
- isNodeVersionOk() {
2196
- //#region @backendFunc
2197
- try {
2198
- lib_2.UtilsOs.isNodeVersionOk({
2199
- throwErrorIfNotOk: true,
2200
- });
2201
- console.info(`Node.js version is OK: ${process.version}`);
2202
- this._exit();
2203
- }
2204
- catch (error) {
2205
- console.error(error);
2206
- this._exit(1);
2207
- }
2208
- //#endregion
2209
- }
2210
- }
2211
- exports.BaseGlobalCommandLine = BaseGlobalCommandLine;
2212
- //# sourceMappingURL=base-global-command-line.backend.js.map