qcobjects-cli 2.5.143-beta → 2.5.145-beta

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 (270) hide show
  1. package/.cursor/rules/collaboration-features.mdc +25 -0
  2. package/.cursor/rules/development-guidelines.mdc +37 -0
  3. package/.cursor/rules/project-structure.mdc +36 -0
  4. package/.dockerignore +0 -0
  5. package/.github/FUNDING.yml +0 -0
  6. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  7. package/.github/ISSUE_TEMPLATE/custom.md +0 -0
  8. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  9. package/.github/ISSUE_TEMPLATE/issue-template.md +0 -0
  10. package/.github/workflows/ci.yml +26 -0
  11. package/.github/workflows/codeql-analysis.yml +0 -0
  12. package/.github/workflows/main-pr-source.yml +26 -0
  13. package/.github/workflows/npmpublish-beta.yml +18 -14
  14. package/.github/workflows/npmpublish-lts.yml +18 -14
  15. package/.github/workflows/npmpublish-main.yml +17 -13
  16. package/.github/workflows/open-pr-to-development.yml +70 -0
  17. package/.opencode/instructions/git-workflow.md +46 -0
  18. package/.pre-commit-config.yaml +9 -0
  19. package/AGENTS.md +59 -0
  20. package/CHANGELOG.md +0 -0
  21. package/README.md +75 -0
  22. package/VERSION +1 -1
  23. package/build-esbuild-esm.js +180 -0
  24. package/build-esbuild.js +182 -208
  25. package/deno.json +0 -0
  26. package/dev-requirements.txt +5 -0
  27. package/eslint.config.mjs +0 -0
  28. package/mod.ts +0 -0
  29. package/package.json +45 -44
  30. package/public/browser/api-client_services.js.map +1 -1
  31. package/public/browser/backend/backend-microservice-static.js +211 -219
  32. package/public/browser/backend/backend-microservice-static.js.map +2 -2
  33. package/public/browser/backend/backend-php.js +227 -231
  34. package/public/browser/backend/backend-php.js.map +3 -3
  35. package/public/browser/cli-commands-build-esbuild.js +326 -0
  36. package/public/browser/cli-commands-build-esbuild.js.map +7 -0
  37. package/public/browser/cli-commands-build-typescript.js +114 -0
  38. package/public/browser/cli-commands-build-typescript.js.map +7 -0
  39. package/public/browser/cli-commands-jira.js.map +1 -1
  40. package/public/browser/cli-commands-version.js.map +1 -1
  41. package/public/browser/cli-commands.js +4 -0
  42. package/public/browser/cli-commands.js.map +2 -2
  43. package/public/browser/cli-main.js.map +1 -1
  44. package/public/browser/client_services.js.map +1 -1
  45. package/public/browser/collab-server.js.map +1 -1
  46. package/public/browser/common-pipelog.js.map +1 -1
  47. package/public/browser/defaultsettings.js +68 -27
  48. package/public/browser/defaultsettings.js.map +3 -3
  49. package/public/browser/enterprise-commands.js.map +1 -1
  50. package/public/browser/main-file.js.map +1 -1
  51. package/public/browser/main-http-gae-server.js.map +1 -1
  52. package/public/browser/main-http-server.js.map +1 -1
  53. package/public/browser/main-http2-server.js.map +1 -1
  54. package/public/browser/qcobjects-cli.js.map +1 -1
  55. package/public/browser/qcobjects-collab.js +16 -24
  56. package/public/browser/qcobjects-collab.js.map +2 -2
  57. package/public/browser/qcobjects-createcert.js +46 -54
  58. package/public/browser/qcobjects-createcert.js.map +2 -2
  59. package/public/browser/qcobjects-gae-http-server.js +16 -24
  60. package/public/browser/qcobjects-gae-http-server.js.map +2 -2
  61. package/public/browser/qcobjects-http-server.js +16 -24
  62. package/public/browser/qcobjects-http-server.js.map +2 -2
  63. package/public/browser/qcobjects-http2-server.js +21 -30
  64. package/public/browser/qcobjects-http2-server.js.map +2 -2
  65. package/public/browser/qcobjects-shell.js.map +1 -1
  66. package/public/browser/templates/apps/spa-local.html +0 -0
  67. package/public/browser/templates/apps/spa-local.js +0 -0
  68. package/public/browser/templates/pwa/sw.js +0 -0
  69. package/public/browser/types/global/index.d.js +0 -9
  70. package/public/browser/types/global/index.d.js.map +3 -3
  71. package/public/cjs/api-client_services.js +74 -0
  72. package/public/cjs/api-client_services.js.map +1 -0
  73. package/public/cjs/backend/backend-microservice-static.js +255 -0
  74. package/public/cjs/backend/backend-microservice-static.js.map +1 -0
  75. package/public/cjs/backend/backend-php.js +317 -0
  76. package/public/cjs/backend/backend-php.js.map +1 -0
  77. package/public/cjs/cli-commands-build-esbuild.js +341 -0
  78. package/public/cjs/cli-commands-build-esbuild.js.map +1 -0
  79. package/public/cjs/cli-commands-build-typescript.js +127 -0
  80. package/public/cjs/cli-commands-build-typescript.js.map +1 -0
  81. package/public/cjs/cli-commands-jira.js +115 -0
  82. package/public/cjs/cli-commands-jira.js.map +1 -0
  83. package/public/cjs/cli-commands-publish-static.js +108 -0
  84. package/public/cjs/cli-commands-publish-static.js.map +1 -0
  85. package/public/cjs/cli-commands-version.js +250 -0
  86. package/public/cjs/cli-commands-version.js.map +1 -0
  87. package/public/cjs/cli-commands.js +73 -0
  88. package/public/cjs/cli-commands.js.map +1 -0
  89. package/public/cjs/cli-main.js +487 -0
  90. package/public/cjs/cli-main.js.map +1 -0
  91. package/public/cjs/client_services.js +80 -0
  92. package/public/cjs/client_services.js.map +1 -0
  93. package/public/cjs/collab-server.js +404 -0
  94. package/public/cjs/collab-server.js.map +1 -0
  95. package/public/cjs/common-pipelog.js +57 -0
  96. package/public/cjs/common-pipelog.js.map +1 -0
  97. package/public/cjs/defaultsettings.js +496 -0
  98. package/public/cjs/defaultsettings.js.map +1 -0
  99. package/public/cjs/enterprise-commands.js +173 -0
  100. package/public/cjs/enterprise-commands.js.map +1 -0
  101. package/public/cjs/index.js +38 -0
  102. package/public/cjs/index.js.map +1 -0
  103. package/public/cjs/main-file.js +161 -0
  104. package/public/cjs/main-file.js.map +1 -0
  105. package/public/cjs/main-http-gae-server.js +498 -0
  106. package/public/cjs/main-http-gae-server.js.map +1 -0
  107. package/public/cjs/main-http-server.js +540 -0
  108. package/public/cjs/main-http-server.js.map +1 -0
  109. package/public/cjs/main-http2-server.js +398 -0
  110. package/public/cjs/main-http2-server.js.map +1 -0
  111. package/public/cjs/qcobjects-cli.js +105 -0
  112. package/public/cjs/qcobjects-cli.js.map +1 -0
  113. package/public/cjs/qcobjects-collab.js +51 -0
  114. package/public/cjs/qcobjects-collab.js.map +1 -0
  115. package/public/cjs/qcobjects-createcert.js +89 -0
  116. package/public/cjs/qcobjects-createcert.js.map +1 -0
  117. package/public/cjs/qcobjects-gae-http-server.js +51 -0
  118. package/public/cjs/qcobjects-gae-http-server.js.map +1 -0
  119. package/public/cjs/qcobjects-http-server.js +51 -0
  120. package/public/cjs/qcobjects-http-server.js.map +1 -0
  121. package/public/cjs/qcobjects-http2-server.js +54 -0
  122. package/public/cjs/qcobjects-http2-server.js.map +1 -0
  123. package/public/cjs/qcobjects-shell.js +145 -0
  124. package/public/cjs/qcobjects-shell.js.map +1 -0
  125. package/public/cjs/templates/apps/spa-local.html +0 -0
  126. package/public/cjs/templates/apps/spa-local.js +0 -0
  127. package/public/cjs/templates/pwa/sw.js +0 -0
  128. package/public/esm/api-client_services.mjs.map +1 -1
  129. package/public/esm/backend/backend-microservice-static.mjs +207 -216
  130. package/public/esm/backend/backend-microservice-static.mjs.map +2 -2
  131. package/public/esm/backend/backend-php.mjs +228 -232
  132. package/public/esm/backend/backend-php.mjs.map +2 -2
  133. package/public/esm/cli-commands-build-esbuild.mjs +295 -0
  134. package/public/esm/cli-commands-build-esbuild.mjs.map +7 -0
  135. package/public/esm/cli-commands-build-typescript.mjs +83 -0
  136. package/public/esm/cli-commands-build-typescript.mjs.map +7 -0
  137. package/public/esm/cli-commands-jira.mjs +1 -1
  138. package/public/esm/cli-commands-jira.mjs.map +1 -1
  139. package/public/esm/cli-commands-version.mjs.map +1 -1
  140. package/public/esm/cli-commands.mjs +7 -3
  141. package/public/esm/cli-commands.mjs.map +2 -2
  142. package/public/esm/cli-main.mjs +6 -6
  143. package/public/esm/cli-main.mjs.map +1 -1
  144. package/public/esm/client_services.mjs.map +1 -1
  145. package/public/esm/collab-server.mjs.map +1 -1
  146. package/public/esm/common-pipelog.mjs.map +1 -1
  147. package/public/esm/defaultsettings.mjs +68 -27
  148. package/public/esm/defaultsettings.mjs.map +3 -3
  149. package/public/esm/enterprise-commands.mjs.map +1 -1
  150. package/public/esm/index.mjs +1 -1
  151. package/public/esm/main-file.mjs.map +1 -1
  152. package/public/esm/main-http-gae-server.mjs +2 -2
  153. package/public/esm/main-http-gae-server.mjs.map +1 -1
  154. package/public/esm/main-http-server.mjs +2 -2
  155. package/public/esm/main-http-server.mjs.map +1 -1
  156. package/public/esm/main-http2-server.mjs +2 -2
  157. package/public/esm/main-http2-server.mjs.map +1 -1
  158. package/public/esm/qcobjects-cli.mjs +2 -2
  159. package/public/esm/qcobjects-cli.mjs.map +1 -1
  160. package/public/esm/qcobjects-collab.mjs +14 -23
  161. package/public/esm/qcobjects-collab.mjs.map +2 -2
  162. package/public/esm/qcobjects-createcert.mjs +43 -52
  163. package/public/esm/qcobjects-createcert.mjs.map +2 -2
  164. package/public/esm/qcobjects-gae-http-server.mjs +14 -23
  165. package/public/esm/qcobjects-gae-http-server.mjs.map +2 -2
  166. package/public/esm/qcobjects-http-server.mjs +14 -23
  167. package/public/esm/qcobjects-http-server.mjs.map +2 -2
  168. package/public/esm/qcobjects-http2-server.mjs +21 -31
  169. package/public/esm/qcobjects-http2-server.mjs.map +2 -2
  170. package/public/esm/qcobjects-shell.mjs +1 -1
  171. package/public/esm/qcobjects-shell.mjs.map +1 -1
  172. package/public/esm/templates/apps/spa-local.html +0 -0
  173. package/public/esm/templates/apps/spa-local.js +0 -0
  174. package/public/esm/templates/pwa/sw.js +0 -0
  175. package/public/esm/types/global/index.d.mjs +0 -9
  176. package/public/esm/types/global/index.d.mjs.map +3 -3
  177. package/public/types/index.d.ts +29 -3
  178. package/spec/support/jasmine.json +0 -0
  179. package/spec/testsSpec.ts +0 -0
  180. package/src/api-client_services.ts +1 -1
  181. package/src/backend/backend-microservice-static.ts +196 -196
  182. package/src/backend/backend-php.ts +240 -245
  183. package/src/cli-commands-build-esbuild.ts +375 -0
  184. package/src/cli-commands-build-typescript.ts +139 -0
  185. package/src/cli-commands-jira.ts +1 -1
  186. package/src/cli-commands-publish-static.ts +0 -0
  187. package/src/cli-commands-version.ts +1 -1
  188. package/src/cli-commands.ts +3 -1
  189. package/src/cli-main.ts +1 -1
  190. package/src/client_services.ts +1 -1
  191. package/src/collab-server.ts +1 -1
  192. package/src/common-pipelog.ts +1 -1
  193. package/src/defaultsettings.ts +65 -19
  194. package/src/enterprise-commands.ts +1 -1
  195. package/src/index.ts +0 -0
  196. package/src/main-file.ts +1 -1
  197. package/src/main-http-gae-server.ts +1 -1
  198. package/src/main-http-server.ts +1 -1
  199. package/src/main-http2-server.ts +1 -1
  200. package/src/qcobjects-cli.ts +1 -1
  201. package/src/qcobjects-collab.ts +1 -1
  202. package/src/qcobjects-createcert.ts +1 -1
  203. package/src/qcobjects-gae-http-server.ts +1 -1
  204. package/src/qcobjects-http-server.ts +1 -1
  205. package/src/qcobjects-http2-server.ts +4 -5
  206. package/src/qcobjects-shell.ts +1 -1
  207. package/src/templates/apps/spa-local.html +0 -0
  208. package/src/templates/apps/spa-local.js +0 -0
  209. package/src/templates/pwa/sw.js +0 -0
  210. package/src/types/global/index.d.ts +0 -0
  211. package/transpile.js +0 -0
  212. package/tsconfig.d.json +0 -0
  213. package/tsconfig.jasmine.json +0 -0
  214. package/tsconfig.json +3 -3
  215. package/.gitlab-ci.yml +0 -16
  216. package/public/cjs/api-client_services.cjs +0 -79
  217. package/public/cjs/api-client_services.cjs.map +0 -7
  218. package/public/cjs/backend/backend-microservice-static.cjs +0 -245
  219. package/public/cjs/backend/backend-microservice-static.cjs.map +0 -7
  220. package/public/cjs/backend/backend-php.cjs +0 -301
  221. package/public/cjs/backend/backend-php.cjs.map +0 -7
  222. package/public/cjs/cli-commands-jira.cjs +0 -112
  223. package/public/cjs/cli-commands-jira.cjs.map +0 -7
  224. package/public/cjs/cli-commands-publish-static.cjs +0 -109
  225. package/public/cjs/cli-commands-publish-static.cjs.map +0 -7
  226. package/public/cjs/cli-commands-version.cjs +0 -252
  227. package/public/cjs/cli-commands-version.cjs.map +0 -7
  228. package/public/cjs/cli-commands.cjs +0 -45
  229. package/public/cjs/cli-commands.cjs.map +0 -7
  230. package/public/cjs/cli-main.cjs +0 -417
  231. package/public/cjs/cli-main.cjs.map +0 -7
  232. package/public/cjs/client_services.cjs +0 -86
  233. package/public/cjs/client_services.cjs.map +0 -7
  234. package/public/cjs/collab-server.cjs +0 -444
  235. package/public/cjs/collab-server.cjs.map +0 -7
  236. package/public/cjs/common-pipelog.cjs +0 -50
  237. package/public/cjs/common-pipelog.cjs.map +0 -7
  238. package/public/cjs/defaultsettings.cjs +0 -432
  239. package/public/cjs/defaultsettings.cjs.map +0 -7
  240. package/public/cjs/enterprise-commands.cjs +0 -175
  241. package/public/cjs/enterprise-commands.cjs.map +0 -7
  242. package/public/cjs/index.cjs +0 -36
  243. package/public/cjs/index.cjs.map +0 -7
  244. package/public/cjs/main-file.cjs +0 -194
  245. package/public/cjs/main-file.cjs.map +0 -7
  246. package/public/cjs/main-http-gae-server.cjs +0 -522
  247. package/public/cjs/main-http-gae-server.cjs.map +0 -7
  248. package/public/cjs/main-http-server.cjs +0 -588
  249. package/public/cjs/main-http-server.cjs.map +0 -7
  250. package/public/cjs/main-http2-server.cjs +0 -431
  251. package/public/cjs/main-http2-server.cjs.map +0 -7
  252. package/public/cjs/qcobjects-cli.cjs +0 -92
  253. package/public/cjs/qcobjects-cli.cjs.map +0 -7
  254. package/public/cjs/qcobjects-collab.cjs +0 -43
  255. package/public/cjs/qcobjects-collab.cjs.map +0 -7
  256. package/public/cjs/qcobjects-createcert.cjs +0 -75
  257. package/public/cjs/qcobjects-createcert.cjs.map +0 -7
  258. package/public/cjs/qcobjects-gae-http-server.cjs +0 -43
  259. package/public/cjs/qcobjects-gae-http-server.cjs.map +0 -7
  260. package/public/cjs/qcobjects-http-server.cjs +0 -43
  261. package/public/cjs/qcobjects-http-server.cjs.map +0 -7
  262. package/public/cjs/qcobjects-http2-server.cjs +0 -49
  263. package/public/cjs/qcobjects-http2-server.cjs.map +0 -7
  264. package/public/cjs/qcobjects-shell.cjs +0 -185
  265. package/public/cjs/qcobjects-shell.cjs.map +0 -7
  266. package/public/cjs/types/global/index.d.cjs +0 -2
  267. package/public/cjs/types/global/index.d.cjs.map +0 -7
  268. package/public/types/index.d.ts.map +0 -1
  269. package/src/index.cts +0 -2
  270. package/src/index.mts +0 -2
@@ -0,0 +1,375 @@
1
+ /**
2
+ * QCObjects CLI 2.5
3
+ * ________________
4
+ *
5
+ * Author: Jean Machuca <correojean@gmail.com>
6
+ *
7
+ * Cross Browser Javascript Framework for MVC Patterns
8
+ * QuickCorp/QCObjects is licensed under the
9
+ * GNU Lesser General Public License v3.0
10
+ * [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
11
+ *
12
+ * Permissions of this copyleft license are conditioned on making available
13
+ * complete source code of licensed works and modifications under the same
14
+ * license or the GNU GPLv3. Copyright and license notices must be preserved.
15
+ * Contributors provide an express grant of patent rights. However, a larger
16
+ * work using the licensed work through interfaces provided by the licensed
17
+ * work may be distributed under different terms and without source code for
18
+ * the larger work.
19
+ *
20
+ * Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
21
+ *
22
+ * Everyone is permitted to copy and distribute verbatim copies of this
23
+ * license document, but changing it is not allowed.
24
+ */
25
+ /*eslint no-unused-vars: "off"*/
26
+ /*eslint no-redeclare: "off"*/
27
+ /*eslint no-empty: "off"*/
28
+ /*eslint strict: "off"*/
29
+ /*eslint no-mixed-operators: "off"*/
30
+ /*eslint no-undef: "off"*/
31
+ "use strict";
32
+ import path from "node:path";
33
+ import { readFileSync, writeFileSync } from "node:fs";
34
+ import fs from "node:fs/promises";
35
+ import glob from "glob";
36
+ import esbuild, { BuildOptions, Format } from "esbuild";
37
+ import alias from "esbuild-plugin-alias";
38
+ import { Package, InheritClass, logger } from "qcobjects";
39
+
40
+ const externalPackages = [
41
+ "node:fs", "node:path", "node:os", "node:util", "node:events",
42
+ "node:stream", "node:http", "node:https", "node:crypto", "node:zlib",
43
+ "node:buffer", "node:url", "node:querystring", "node:child_process",
44
+ "node:cluster", "node:dgram", "node:dns", "node:net", "node:readline",
45
+ "node:repl", "node:tls", "node:tty", "node:vm", "node:worker_threads"
46
+ ];
47
+
48
+ // Function to detect and add the extension
49
+ const nameToExtension = (name: string, ext: string, settings: BuildOptions): string => {
50
+ function isPackage(name: string): boolean {
51
+ return !name.startsWith(".") && !name.startsWith("/") && !name.includes("/");
52
+ }
53
+
54
+ const hasExtension = /\.[^/\\]+$/.test(name);
55
+ const isExternalPackage = name.startsWith("qcobjects") ||
56
+ name.startsWith("qcobjects-sdk") ||
57
+ name.startsWith("node:") ||
58
+ name.startsWith("fs") ||
59
+ name.startsWith("path") ||
60
+ name.startsWith("os") ||
61
+ name.startsWith("util") ||
62
+ name.startsWith("events") ||
63
+ name.startsWith("stream") ||
64
+ name.startsWith("http") ||
65
+ name.startsWith("https") ||
66
+ name.startsWith("crypto") ||
67
+ name.startsWith("zlib") ||
68
+ name.startsWith("buffer") ||
69
+ name.startsWith("url") ||
70
+ name.startsWith("querystring") ||
71
+ name.startsWith("child_process") ||
72
+ name.startsWith("cluster") ||
73
+ name.startsWith("dgram") ||
74
+ name.startsWith("dns") ||
75
+ name.startsWith("net") ||
76
+ name.startsWith("readline") ||
77
+ name.startsWith("repl") ||
78
+ name.startsWith("tls") ||
79
+ name.startsWith("tty") ||
80
+ name.startsWith("vm") ||
81
+ name.startsWith("worker_threads")
82
+ || externalPackages.includes(name);
83
+
84
+ if (!hasExtension && !isPackage(name) && !isExternalPackage) {
85
+ name += ext;
86
+ }
87
+
88
+ return name;
89
+ };
90
+
91
+ // Function to add .cjs and .mjs extensions to import/export/require statements
92
+ const addExtensions = (filePath: string, toExt: string, settings: BuildOptions): void => {
93
+ const content = readFileSync(filePath, "utf8");
94
+ const updatedContent = content
95
+ .replace(/(from\s+['"])(.*?)(['"])/g, (match, p1, p2, p3) => {
96
+ return `${p1}${nameToExtension(p2, toExt, settings)}${p3}`;
97
+ })
98
+ .replace(/(import\s+['"])(.*?)(['"])/g, (match, p1, p2, p3) => {
99
+ return `${p1}${nameToExtension(p2, toExt, settings)}${p3}`;
100
+ })
101
+ .replace(/(export\s+['"])(.*?)(['"])/g, (match, p1, p2, p3) => {
102
+ return `${p1}${nameToExtension(p2, toExt, settings)}${p3}`;
103
+ })
104
+ .replace(/(require\s*\(\s*['"])(.*?)(['"]\s*\))/g, (match, p1, p2, p3) => {
105
+ return `${p1}${nameToExtension(p2, toExt, settings)}${p3}`;
106
+ });
107
+ writeFileSync(filePath, updatedContent, "utf8");
108
+ };
109
+
110
+ const copyDir = async (source: string, dest: string, exclude: string[]): Promise<void> => {
111
+ source = path.resolve(source);
112
+ dest = path.resolve(dest);
113
+ const dname = path.basename(source);
114
+ const dirExcluded = exclude.includes(dname);
115
+
116
+ const isDir = async (d: string): Promise<boolean> => {
117
+ try {
118
+ const stat = await fs.stat(d);
119
+ return stat.isDirectory();
120
+ } catch {
121
+ return false;
122
+ }
123
+ };
124
+
125
+ const isFile = async (d: string): Promise<boolean> => {
126
+ try {
127
+ const stat = await fs.stat(d);
128
+ return stat.isFile();
129
+ } catch {
130
+ return false;
131
+ }
132
+ };
133
+
134
+ if (await isDir(source) && !dirExcluded) {
135
+ await fs.mkdir(dest, { recursive: true });
136
+ const paths = await fs.readdir(source, { withFileTypes: true });
137
+ const dirs = paths.filter(d => d.isDirectory());
138
+ const files = paths.filter(f => f.isFile());
139
+
140
+ for (const f of files) {
141
+ const sourceFile = path.resolve(source, f.name);
142
+ const destFile = path.resolve(dest, f.name);
143
+ const fileExcluded = exclude.includes(f.name);
144
+ if (await isFile(sourceFile) && !fileExcluded) {
145
+ logger.debug(`[build:esbuild] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...`);
146
+ await fs.copyFile(sourceFile, destFile);
147
+ logger.debug(`[build:esbuild] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...DONE!`);
148
+ }
149
+ }
150
+
151
+ for (const d of dirs) {
152
+ const sourceDir = path.resolve(source, d.name);
153
+ const destDir = path.resolve(dest, d.name);
154
+ await copyDir(sourceDir, destDir, exclude);
155
+ }
156
+ }
157
+ };
158
+
159
+ const ignorePlugin = {
160
+ name: "transform-qcobjects-imports",
161
+ setup(build: any) {
162
+ build.onResolve({ filter: /^(qcobjects|qcobjects-sdk)$/ }, (args: any) => {
163
+ if (args.kind === "dynamic-import") {
164
+ return {
165
+ path: args.path,
166
+ namespace: "qcobjects-transform"
167
+ };
168
+ }
169
+ return {
170
+ external: true,
171
+ path: args.path
172
+ };
173
+ });
174
+
175
+ build.onResolve({ filter: /.*/, namespace: "file" }, (args: any) => {
176
+ if (args.kind === "dynamic-import") {
177
+ return {
178
+ external: true,
179
+ path: args.path
180
+ };
181
+ }
182
+ return null;
183
+ });
184
+
185
+ build.onLoad({ filter: /.*/, namespace: "qcobjects-transform" }, (args: any) => {
186
+ return {
187
+ contents: `
188
+ module.exports = __toESM(require("${args.path}"), true);
189
+ `,
190
+ loader: "js"
191
+ };
192
+ });
193
+ }
194
+ };
195
+
196
+ export class CommandHandler extends InheritClass {
197
+ choiceOption: {
198
+ [x: string]: any;
199
+ build_esbuild: () => Promise<void>;
200
+ };
201
+
202
+ constructor({
203
+ switchCommander
204
+ }: { switchCommander: any }) {
205
+ super({ switchCommander });
206
+ this.choiceOption = {
207
+ async build_esbuild() {
208
+ try {
209
+ logger.info("[build:esbuild] Starting esbuild process...");
210
+
211
+ // Get all TypeScript entry points
212
+ const entryPoints = glob.sync("src/**/*.ts");
213
+
214
+ // Copy templates
215
+ await copyDir("./src/templates", "./build/templates", []);
216
+ await copyDir("./src/templates", "./public/cjs/templates", []);
217
+ await copyDir("./src/templates", "./public/esm/templates", []);
218
+ await copyDir("./src/templates", "./public/browser/templates", []);
219
+
220
+ const baseSettings: BuildOptions = {
221
+ entryPoints,
222
+ bundle: false,
223
+ outdir: "public/cjs",
224
+ format: "cjs" as Format,
225
+ target: ["node22"],
226
+ tsconfig: "tsconfig.json",
227
+ globalName: "global",
228
+ minify: false,
229
+ keepNames: true,
230
+ sourcemap: true,
231
+ splitting: false,
232
+ chunkNames: "chunks/[name]-[hash]",
233
+ plugins: [
234
+ ignorePlugin,
235
+ alias({
236
+ "types": path.join(process.cwd(), "src/types/global/index.d.ts")
237
+ })
238
+ ]
239
+ };
240
+
241
+ const cjsSettings: BuildOptions = {
242
+ ...baseSettings,
243
+ outdir: "public/cjs",
244
+ format: "cjs" as Format,
245
+ platform: "node",
246
+ outExtension: {
247
+ ".js": ".cjs"
248
+ },
249
+ plugins: [
250
+ ignorePlugin,
251
+ {
252
+ name: "transform-dynamic-imports",
253
+ setup(build: any) {
254
+ build.onEnd(() => {
255
+ const files = glob.sync("public/cjs/**/*.cjs");
256
+ for (const file of files) {
257
+ let content = readFileSync(file, "utf8");
258
+ content = content.replace(
259
+ /await\s+import\(['"]([^'"]+)['"]\)/g,
260
+ "__toESM(require(\"$1\"), true)"
261
+ );
262
+ writeFileSync(file, content, "utf8");
263
+ }
264
+ });
265
+ }
266
+ },
267
+ {
268
+ name: "add-extensions",
269
+ setup(build: any) {
270
+ build.onEnd(() => {
271
+ entryPoints.forEach((entry: string) => {
272
+ const outputFilePath = path.join("./public/cjs", entry.replace("src/", "").replace(".ts", ".cjs"));
273
+ addExtensions(outputFilePath, ".cjs", cjsSettings);
274
+ });
275
+ });
276
+ }
277
+ }
278
+ ]
279
+ };
280
+
281
+ const esmSettings: BuildOptions = {
282
+ ...baseSettings,
283
+ outdir: "public/esm",
284
+ format: "esm" as Format,
285
+ platform: "browser",
286
+ outExtension: {
287
+ ".js": ".mjs"
288
+ },
289
+ plugins: [
290
+ {
291
+ name: "transform-requires",
292
+ setup(build: any) {
293
+ build.onEnd(() => {
294
+ const files = glob.sync("public/esm/**/*.mjs");
295
+ for (const file of files) {
296
+ let content = readFileSync(file, "utf8");
297
+ // Transform require statements to dynamic imports
298
+ content = content.replace(
299
+ /const\s+{([^}]+)}\s*=\s*require\(['"]([^'"]+)['"]\)/g,
300
+ "import { $1 } from \"$2\""
301
+ );
302
+ content = content.replace(
303
+ /const\s+([^=]+)\s*=\s*require\(['"]([^'"]+)['"]\)/g,
304
+ "import $1 from \"$2\""
305
+ );
306
+ writeFileSync(file, content, "utf8");
307
+ }
308
+ });
309
+ }
310
+ },
311
+ {
312
+ name: "add-extensions",
313
+ setup(build: any) {
314
+ build.onEnd(() => {
315
+ entryPoints.forEach((entry: string) => {
316
+ const outputFilePath = path.join("./public/esm", entry.replace("src/", "").replace(".ts", ".mjs"));
317
+ addExtensions(outputFilePath, ".mjs", esmSettings);
318
+ });
319
+ });
320
+ }
321
+ }
322
+ ]
323
+ };
324
+
325
+ const browserSettings: BuildOptions = {
326
+ ...baseSettings,
327
+ outdir: "public/browser",
328
+ format: "iife" as Format,
329
+ platform: "browser",
330
+ outExtension: {
331
+ ".js": ".js"
332
+ }
333
+ };
334
+
335
+ // Build all formats
336
+ await Promise.all([
337
+ esbuild.build(cjsSettings),
338
+ esbuild.build(esmSettings),
339
+ esbuild.build(browserSettings)
340
+ ]);
341
+
342
+ logger.info("[build:esbuild] Build process completed successfully!");
343
+ } catch (e: any) {
344
+ logger.error(`[build:esbuild] Build process failed: ${e.message}`);
345
+ process.exit(1);
346
+ }
347
+ }
348
+ };
349
+
350
+ const commandHandler = this;
351
+ logger.debug("Loading command build:esbuild...");
352
+
353
+ // Register both commands
354
+ switchCommander.program.command("build:esbuild")
355
+ .allowExcessArguments(false)
356
+ .description("Builds the project using esbuild for CJS, ESM, and browser formats")
357
+ .action(function () {
358
+ commandHandler.choiceOption.build_esbuild.call(commandHandler);
359
+ });
360
+
361
+ // Add alias
362
+ switchCommander.program.command("build:esb")
363
+ .allowExcessArguments(false)
364
+ .description("Alias for build:esbuild - Builds the project using esbuild")
365
+ .action(function () {
366
+ commandHandler.choiceOption.build_esbuild.call(commandHandler);
367
+ });
368
+
369
+ logger.debug("Loading command build:esbuild... DONE.");
370
+ }
371
+ }
372
+
373
+ Package("com.qcobjects.cli.commands.build.esbuild", [
374
+ CommandHandler
375
+ ]);
@@ -0,0 +1,139 @@
1
+ /**
2
+ * QCObjects CLI 2.5
3
+ * ________________
4
+ *
5
+ * Author: Jean Machuca <correojean@gmail.com>
6
+ *
7
+ * Cross Browser Javascript Framework for MVC Patterns
8
+ * QuickCorp/QCObjects is licensed under the
9
+ * GNU Lesser General Public License v3.0
10
+ * [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
11
+ *
12
+ * Permissions of this copyleft license are conditioned on making available
13
+ * complete source code of licensed works and modifications under the same
14
+ * license or the GNU GPLv3. Copyright and license notices must be preserved.
15
+ * Contributors provide an express grant of patent rights. However, a larger
16
+ * work using the licensed work through interfaces provided by the licensed
17
+ * work may be distributed under different terms and without source code for
18
+ * the larger work.
19
+ *
20
+ * Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
21
+ *
22
+ * Everyone is permitted to copy and distribute verbatim copies of this
23
+ * license document, but changing it is not allowed.
24
+ */
25
+ /*eslint no-unused-vars: "off"*/
26
+ /*eslint no-redeclare: "off"*/
27
+ /*eslint no-empty: "off"*/
28
+ /*eslint strict: "off"*/
29
+ /*eslint no-mixed-operators: "off"*/
30
+ /*eslint no-undef: "off"*/
31
+ "use strict";
32
+ import path from "node:path";
33
+ import ts from "typescript";
34
+ import { Package, InheritClass, logger } from "qcobjects";
35
+
36
+ export class CommandHandler extends InheritClass {
37
+ choiceOption: {
38
+ [x: string]: any;
39
+ build_typescript: (configFile: string) => void;
40
+ };
41
+
42
+ constructor({
43
+ switchCommander
44
+ }: { switchCommander: any }) {
45
+ super({ switchCommander });
46
+ this.choiceOption = {
47
+ build_typescript(configFile) {
48
+ try {
49
+ logger.info(`[build:typescript] Building TypeScript with config file: ${configFile}...`);
50
+
51
+ // Resolve the path to the tsconfig file
52
+ const configPath = path.resolve(process.cwd(), configFile);
53
+
54
+ // Parse the tsconfig file
55
+ const parsedCommandLine = ts.getParsedCommandLineOfConfigFile(configPath, {}, {
56
+ ...ts.sys,
57
+ onUnRecoverableConfigFileDiagnostic: diagnostic => {
58
+ logger.warn(ts.formatDiagnostic(diagnostic, {
59
+ getCanonicalFileName: (fileName) => fileName,
60
+ getCurrentDirectory: ts.sys.getCurrentDirectory,
61
+ getNewLine: () => ts.sys.newLine,
62
+ }));
63
+ process.exit(1);
64
+ }
65
+ });
66
+
67
+ if (!parsedCommandLine) {
68
+ logger.warn('Failed to parse tsconfig file');
69
+ process.exit(1);
70
+ }
71
+
72
+ // Create a program with the parsed settings
73
+ const program = ts.createProgram({
74
+ rootNames: parsedCommandLine.fileNames,
75
+ options: parsedCommandLine.options,
76
+ });
77
+
78
+ // Emit the compiled files
79
+ const emitResult = program.emit();
80
+
81
+ // Report any diagnostics (errors or warnings)
82
+ const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
83
+
84
+ allDiagnostics.forEach(diagnostic => {
85
+ if (diagnostic.file && diagnostic.start) {
86
+ const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
87
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
88
+ logger.warn(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
89
+ } else {
90
+ logger.warn(ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'));
91
+ }
92
+ });
93
+
94
+ // Check if any files were emitted
95
+ const emittedFiles = emitResult.emittedFiles || [];
96
+ if (emittedFiles.length > 0) {
97
+ logger.info('Emitted files:');
98
+ emittedFiles.forEach(file => logger.info(file));
99
+ }
100
+
101
+ // Exit with an appropriate code
102
+ const exitCode = emitResult.emitSkipped ? 1 : 0;
103
+ logger.info(`Process completed with code '${exitCode}'.`);
104
+ if (exitCode !== 0) {
105
+ process.exit(exitCode);
106
+ }
107
+ } catch (e: any) {
108
+ logger.warn(`Something went wrong trying to build TypeScript: ${e.message}`);
109
+ process.exit(1);
110
+ }
111
+ }
112
+ };
113
+
114
+ const commandHandler = this;
115
+ logger.debug("Loading command build:typescript...");
116
+
117
+ // Register both commands
118
+ const buildCommand = switchCommander.program.command("build:typescript <configFile>")
119
+ .allowExcessArguments(false)
120
+ .description("Builds TypeScript files using the specified config file")
121
+ .action(function (configFile: string) {
122
+ commandHandler.choiceOption.build_typescript.call(commandHandler, configFile);
123
+ });
124
+
125
+ // Add alias
126
+ switchCommander.program.command("build:ts <configFile>")
127
+ .allowExcessArguments(false)
128
+ .description("Alias for build:typescript - Builds TypeScript files using the specified config file")
129
+ .action(function (configFile: string) {
130
+ commandHandler.choiceOption.build_typescript.call(commandHandler, configFile);
131
+ });
132
+
133
+ logger.debug("Loading command build:typescript... DONE.");
134
+ }
135
+ }
136
+
137
+ Package("com.qcobjects.cli.commands.build.typescript", [
138
+ CommandHandler
139
+ ]);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.4.x
2
+ * QCObjects CLI 2.5
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>
File without changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.4.x
2
+ * QCObjects CLI 2.5
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.4.x
2
+ * QCObjects CLI 2.5
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>
@@ -35,3 +35,5 @@
35
35
  export * as versionCommand from "./cli-commands-version";
36
36
  export * as jiraCommand from "./cli-commands-jira";
37
37
  export * as publishStatic from "./cli-commands-publish-static";
38
+ export * as buildTypescript from "./cli-commands-build-typescript";
39
+ export * as buildEsbuild from "./cli-commands-build-esbuild";
package/src/cli-main.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.4.x
2
+ * QCObjects CLI 2.5
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.4.x
2
+ * QCObjects CLI 2.5
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * QCObjects CLI 2.4.x
3
+ * QCObjects CLI 2.5
4
4
  * ________________
5
5
  *
6
6
  * Author: Jean Machuca <correojean@gmail.com>
@@ -1,5 +1,5 @@
1
1
  /**
2
- * QCObjects CLI 2.4.x
2
+ * QCObjects CLI 2.5
3
3
  * ________________
4
4
  *
5
5
  * Author: Jean Machuca <correojean@gmail.com>