qcobjects-cli 2.5.141-beta → 2.5.144-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 (273) 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 +20 -13
  14. package/.github/workflows/npmpublish-lts.yml +20 -13
  15. package/.github/workflows/npmpublish-main.yml +19 -12
  16. package/.github/workflows/open-pr-to-development.yml +70 -0
  17. package/.gitlab-ci.yml +0 -0
  18. package/.opencode/instructions/git-workflow.md +46 -0
  19. package/.pre-commit-config.yaml +9 -0
  20. package/AGENTS.md +59 -0
  21. package/CHANGELOG.md +0 -0
  22. package/README.md +75 -0
  23. package/VERSION +1 -1
  24. package/build-esbuild-esm.js +180 -0
  25. package/build-esbuild.js +182 -208
  26. package/deno.json +0 -0
  27. package/dev-requirements.txt +5 -0
  28. package/eslint.config.mjs +0 -0
  29. package/mod.ts +0 -0
  30. package/package.json +48 -47
  31. package/public/browser/api-client_services.js.map +1 -1
  32. package/public/browser/backend/backend-microservice-static.js +211 -219
  33. package/public/browser/backend/backend-microservice-static.js.map +2 -2
  34. package/public/browser/backend/backend-php.js +227 -231
  35. package/public/browser/backend/backend-php.js.map +3 -3
  36. package/public/browser/cli-commands-build-esbuild.js +326 -0
  37. package/public/browser/cli-commands-build-esbuild.js.map +7 -0
  38. package/public/browser/cli-commands-build-typescript.js +114 -0
  39. package/public/browser/cli-commands-build-typescript.js.map +7 -0
  40. package/public/browser/cli-commands-jira.js.map +1 -1
  41. package/public/browser/cli-commands-version.js.map +1 -1
  42. package/public/browser/cli-commands.js +4 -0
  43. package/public/browser/cli-commands.js.map +2 -2
  44. package/public/browser/cli-main.js.map +1 -1
  45. package/public/browser/client_services.js.map +1 -1
  46. package/public/browser/collab-server.js.map +1 -1
  47. package/public/browser/common-pipelog.js.map +1 -1
  48. package/public/browser/defaultsettings.js +68 -27
  49. package/public/browser/defaultsettings.js.map +3 -3
  50. package/public/browser/enterprise-commands.js.map +1 -1
  51. package/public/browser/main-file.js.map +1 -1
  52. package/public/browser/main-http-gae-server.js +3 -0
  53. package/public/browser/main-http-gae-server.js.map +2 -2
  54. package/public/browser/main-http-server.js +3 -0
  55. package/public/browser/main-http-server.js.map +2 -2
  56. package/public/browser/main-http2-server.js +3 -0
  57. package/public/browser/main-http2-server.js.map +2 -2
  58. package/public/browser/qcobjects-cli.js.map +1 -1
  59. package/public/browser/qcobjects-collab.js +16 -24
  60. package/public/browser/qcobjects-collab.js.map +2 -2
  61. package/public/browser/qcobjects-createcert.js +46 -54
  62. package/public/browser/qcobjects-createcert.js.map +2 -2
  63. package/public/browser/qcobjects-gae-http-server.js +16 -24
  64. package/public/browser/qcobjects-gae-http-server.js.map +2 -2
  65. package/public/browser/qcobjects-http-server.js +16 -24
  66. package/public/browser/qcobjects-http-server.js.map +2 -2
  67. package/public/browser/qcobjects-http2-server.js +21 -30
  68. package/public/browser/qcobjects-http2-server.js.map +2 -2
  69. package/public/browser/qcobjects-shell.js.map +1 -1
  70. package/public/browser/templates/apps/spa-local.html +0 -0
  71. package/public/browser/templates/apps/spa-local.js +0 -0
  72. package/public/browser/templates/pwa/sw.js +0 -0
  73. package/public/browser/types/global/index.d.js +0 -9
  74. package/public/browser/types/global/index.d.js.map +3 -3
  75. package/public/cjs/api-client_services.js +74 -0
  76. package/public/cjs/api-client_services.js.map +1 -0
  77. package/public/cjs/backend/backend-microservice-static.js +255 -0
  78. package/public/cjs/backend/backend-microservice-static.js.map +1 -0
  79. package/public/cjs/backend/backend-php.js +317 -0
  80. package/public/cjs/backend/backend-php.js.map +1 -0
  81. package/public/cjs/cli-commands-build-esbuild.js +341 -0
  82. package/public/cjs/cli-commands-build-esbuild.js.map +1 -0
  83. package/public/cjs/cli-commands-build-typescript.js +127 -0
  84. package/public/cjs/cli-commands-build-typescript.js.map +1 -0
  85. package/public/cjs/cli-commands-jira.js +115 -0
  86. package/public/cjs/cli-commands-jira.js.map +1 -0
  87. package/public/cjs/cli-commands-publish-static.js +108 -0
  88. package/public/cjs/cli-commands-publish-static.js.map +1 -0
  89. package/public/cjs/cli-commands-version.js +250 -0
  90. package/public/cjs/cli-commands-version.js.map +1 -0
  91. package/public/cjs/cli-commands.js +73 -0
  92. package/public/cjs/cli-commands.js.map +1 -0
  93. package/public/cjs/cli-main.js +487 -0
  94. package/public/cjs/cli-main.js.map +1 -0
  95. package/public/cjs/client_services.js +80 -0
  96. package/public/cjs/client_services.js.map +1 -0
  97. package/public/cjs/collab-server.js +404 -0
  98. package/public/cjs/collab-server.js.map +1 -0
  99. package/public/cjs/common-pipelog.js +57 -0
  100. package/public/cjs/common-pipelog.js.map +1 -0
  101. package/public/cjs/defaultsettings.js +496 -0
  102. package/public/cjs/defaultsettings.js.map +1 -0
  103. package/public/cjs/enterprise-commands.js +173 -0
  104. package/public/cjs/enterprise-commands.js.map +1 -0
  105. package/public/cjs/index.js +38 -0
  106. package/public/cjs/index.js.map +1 -0
  107. package/public/cjs/main-file.js +161 -0
  108. package/public/cjs/main-file.js.map +1 -0
  109. package/public/cjs/main-http-gae-server.js +498 -0
  110. package/public/cjs/main-http-gae-server.js.map +1 -0
  111. package/public/cjs/main-http-server.js +540 -0
  112. package/public/cjs/main-http-server.js.map +1 -0
  113. package/public/cjs/main-http2-server.js +398 -0
  114. package/public/cjs/main-http2-server.js.map +1 -0
  115. package/public/cjs/qcobjects-cli.js +105 -0
  116. package/public/cjs/qcobjects-cli.js.map +1 -0
  117. package/public/cjs/qcobjects-collab.js +51 -0
  118. package/public/cjs/qcobjects-collab.js.map +1 -0
  119. package/public/cjs/qcobjects-createcert.js +89 -0
  120. package/public/cjs/qcobjects-createcert.js.map +1 -0
  121. package/public/cjs/qcobjects-gae-http-server.js +51 -0
  122. package/public/cjs/qcobjects-gae-http-server.js.map +1 -0
  123. package/public/cjs/qcobjects-http-server.js +51 -0
  124. package/public/cjs/qcobjects-http-server.js.map +1 -0
  125. package/public/cjs/qcobjects-http2-server.js +54 -0
  126. package/public/cjs/qcobjects-http2-server.js.map +1 -0
  127. package/public/cjs/qcobjects-shell.js +145 -0
  128. package/public/cjs/qcobjects-shell.js.map +1 -0
  129. package/public/cjs/templates/apps/spa-local.html +0 -0
  130. package/public/cjs/templates/apps/spa-local.js +0 -0
  131. package/public/cjs/templates/pwa/sw.js +0 -0
  132. package/public/esm/api-client_services.mjs.map +1 -1
  133. package/public/esm/backend/backend-microservice-static.mjs +207 -216
  134. package/public/esm/backend/backend-microservice-static.mjs.map +2 -2
  135. package/public/esm/backend/backend-php.mjs +228 -232
  136. package/public/esm/backend/backend-php.mjs.map +2 -2
  137. package/public/esm/cli-commands-build-esbuild.mjs +295 -0
  138. package/public/esm/cli-commands-build-esbuild.mjs.map +7 -0
  139. package/public/esm/cli-commands-build-typescript.mjs +83 -0
  140. package/public/esm/cli-commands-build-typescript.mjs.map +7 -0
  141. package/public/esm/cli-commands-jira.mjs +1 -1
  142. package/public/esm/cli-commands-jira.mjs.map +1 -1
  143. package/public/esm/cli-commands-version.mjs.map +1 -1
  144. package/public/esm/cli-commands.mjs +7 -3
  145. package/public/esm/cli-commands.mjs.map +2 -2
  146. package/public/esm/cli-main.mjs +6 -6
  147. package/public/esm/cli-main.mjs.map +1 -1
  148. package/public/esm/client_services.mjs.map +1 -1
  149. package/public/esm/collab-server.mjs.map +1 -1
  150. package/public/esm/common-pipelog.mjs.map +1 -1
  151. package/public/esm/defaultsettings.mjs +68 -27
  152. package/public/esm/defaultsettings.mjs.map +3 -3
  153. package/public/esm/enterprise-commands.mjs.map +1 -1
  154. package/public/esm/index.mjs +1 -1
  155. package/public/esm/main-file.mjs.map +1 -1
  156. package/public/esm/main-http-gae-server.mjs +5 -2
  157. package/public/esm/main-http-gae-server.mjs.map +2 -2
  158. package/public/esm/main-http-server.mjs +5 -2
  159. package/public/esm/main-http-server.mjs.map +2 -2
  160. package/public/esm/main-http2-server.mjs +5 -2
  161. package/public/esm/main-http2-server.mjs.map +2 -2
  162. package/public/esm/qcobjects-cli.mjs +2 -2
  163. package/public/esm/qcobjects-cli.mjs.map +1 -1
  164. package/public/esm/qcobjects-collab.mjs +14 -23
  165. package/public/esm/qcobjects-collab.mjs.map +2 -2
  166. package/public/esm/qcobjects-createcert.mjs +43 -52
  167. package/public/esm/qcobjects-createcert.mjs.map +2 -2
  168. package/public/esm/qcobjects-gae-http-server.mjs +14 -23
  169. package/public/esm/qcobjects-gae-http-server.mjs.map +2 -2
  170. package/public/esm/qcobjects-http-server.mjs +14 -23
  171. package/public/esm/qcobjects-http-server.mjs.map +2 -2
  172. package/public/esm/qcobjects-http2-server.mjs +21 -31
  173. package/public/esm/qcobjects-http2-server.mjs.map +2 -2
  174. package/public/esm/qcobjects-shell.mjs +1 -1
  175. package/public/esm/qcobjects-shell.mjs.map +1 -1
  176. package/public/esm/templates/apps/spa-local.html +0 -0
  177. package/public/esm/templates/apps/spa-local.js +0 -0
  178. package/public/esm/templates/pwa/sw.js +0 -0
  179. package/public/esm/types/global/index.d.mjs +0 -9
  180. package/public/esm/types/global/index.d.mjs.map +3 -3
  181. package/public/types/index.d.ts +29 -3
  182. package/spec/support/jasmine.json +0 -0
  183. package/spec/testsSpec.ts +0 -0
  184. package/src/api-client_services.ts +1 -1
  185. package/src/backend/backend-microservice-static.ts +196 -196
  186. package/src/backend/backend-php.ts +240 -245
  187. package/src/cli-commands-build-esbuild.ts +375 -0
  188. package/src/cli-commands-build-typescript.ts +139 -0
  189. package/src/cli-commands-jira.ts +1 -1
  190. package/src/cli-commands-publish-static.ts +0 -0
  191. package/src/cli-commands-version.ts +1 -1
  192. package/src/cli-commands.ts +3 -1
  193. package/src/cli-main.ts +1 -1
  194. package/src/client_services.ts +1 -1
  195. package/src/collab-server.ts +1 -1
  196. package/src/common-pipelog.ts +1 -1
  197. package/src/defaultsettings.ts +65 -19
  198. package/src/enterprise-commands.ts +1 -1
  199. package/src/index.ts +0 -0
  200. package/src/main-file.ts +1 -1
  201. package/src/main-http-gae-server.ts +6 -1
  202. package/src/main-http-server.ts +6 -1
  203. package/src/main-http2-server.ts +6 -1
  204. package/src/qcobjects-cli.ts +1 -1
  205. package/src/qcobjects-collab.ts +1 -1
  206. package/src/qcobjects-createcert.ts +1 -1
  207. package/src/qcobjects-gae-http-server.ts +1 -1
  208. package/src/qcobjects-http-server.ts +1 -1
  209. package/src/qcobjects-http2-server.ts +4 -5
  210. package/src/qcobjects-shell.ts +1 -1
  211. package/src/templates/apps/spa-local.html +0 -0
  212. package/src/templates/apps/spa-local.js +0 -0
  213. package/src/templates/pwa/sw.js +0 -0
  214. package/src/types/global/index.d.ts +0 -0
  215. package/transpile.js +0 -0
  216. package/tsconfig.d.json +0 -0
  217. package/tsconfig.jasmine.json +0 -0
  218. package/tsconfig.json +3 -3
  219. package/public/cjs/api-client_services.cjs +0 -79
  220. package/public/cjs/api-client_services.cjs.map +0 -7
  221. package/public/cjs/backend/backend-microservice-static.cjs +0 -245
  222. package/public/cjs/backend/backend-microservice-static.cjs.map +0 -7
  223. package/public/cjs/backend/backend-php.cjs +0 -301
  224. package/public/cjs/backend/backend-php.cjs.map +0 -7
  225. package/public/cjs/cli-commands-jira.cjs +0 -112
  226. package/public/cjs/cli-commands-jira.cjs.map +0 -7
  227. package/public/cjs/cli-commands-publish-static.cjs +0 -109
  228. package/public/cjs/cli-commands-publish-static.cjs.map +0 -7
  229. package/public/cjs/cli-commands-version.cjs +0 -252
  230. package/public/cjs/cli-commands-version.cjs.map +0 -7
  231. package/public/cjs/cli-commands.cjs +0 -45
  232. package/public/cjs/cli-commands.cjs.map +0 -7
  233. package/public/cjs/cli-main.cjs +0 -417
  234. package/public/cjs/cli-main.cjs.map +0 -7
  235. package/public/cjs/client_services.cjs +0 -86
  236. package/public/cjs/client_services.cjs.map +0 -7
  237. package/public/cjs/collab-server.cjs +0 -444
  238. package/public/cjs/collab-server.cjs.map +0 -7
  239. package/public/cjs/common-pipelog.cjs +0 -50
  240. package/public/cjs/common-pipelog.cjs.map +0 -7
  241. package/public/cjs/defaultsettings.cjs +0 -432
  242. package/public/cjs/defaultsettings.cjs.map +0 -7
  243. package/public/cjs/enterprise-commands.cjs +0 -175
  244. package/public/cjs/enterprise-commands.cjs.map +0 -7
  245. package/public/cjs/index.cjs +0 -36
  246. package/public/cjs/index.cjs.map +0 -7
  247. package/public/cjs/main-file.cjs +0 -194
  248. package/public/cjs/main-file.cjs.map +0 -7
  249. package/public/cjs/main-http-gae-server.cjs +0 -519
  250. package/public/cjs/main-http-gae-server.cjs.map +0 -7
  251. package/public/cjs/main-http-server.cjs +0 -585
  252. package/public/cjs/main-http-server.cjs.map +0 -7
  253. package/public/cjs/main-http2-server.cjs +0 -428
  254. package/public/cjs/main-http2-server.cjs.map +0 -7
  255. package/public/cjs/qcobjects-cli.cjs +0 -92
  256. package/public/cjs/qcobjects-cli.cjs.map +0 -7
  257. package/public/cjs/qcobjects-collab.cjs +0 -43
  258. package/public/cjs/qcobjects-collab.cjs.map +0 -7
  259. package/public/cjs/qcobjects-createcert.cjs +0 -75
  260. package/public/cjs/qcobjects-createcert.cjs.map +0 -7
  261. package/public/cjs/qcobjects-gae-http-server.cjs +0 -43
  262. package/public/cjs/qcobjects-gae-http-server.cjs.map +0 -7
  263. package/public/cjs/qcobjects-http-server.cjs +0 -43
  264. package/public/cjs/qcobjects-http-server.cjs.map +0 -7
  265. package/public/cjs/qcobjects-http2-server.cjs +0 -49
  266. package/public/cjs/qcobjects-http2-server.cjs.map +0 -7
  267. package/public/cjs/qcobjects-shell.cjs +0 -185
  268. package/public/cjs/qcobjects-shell.cjs.map +0 -7
  269. package/public/cjs/types/global/index.d.cjs +0 -2
  270. package/public/cjs/types/global/index.d.cjs.map +0 -7
  271. package/public/types/index.d.ts.map +0 -1
  272. package/src/index.cts +0 -2
  273. package/src/index.mts +0 -2
@@ -0,0 +1,180 @@
1
+ const esbuild = require("esbuild");
2
+ const alias = require("esbuild-plugin-alias");
3
+ const path = require("node:path");
4
+ const { readFileSync, writeFileSync } = require("node:fs");
5
+ const fs = require("node:fs/promises");
6
+ const glob = require("glob");
7
+
8
+ // Organized external packages into categories
9
+ const externalPackages = {
10
+ node: [
11
+ "fs", "path", "os", "util", "events", "stream", "http", "https",
12
+ "crypto", "zlib", "buffer", "url", "querystring", "child_process",
13
+ "cluster", "dgram", "dns", "net", "readline", "repl", "tls", "tty",
14
+ "vm", "worker_threads"
15
+ ],
16
+ qcobjects: ["qcobjects", "qcobjects-sdk"]
17
+ };
18
+
19
+ // Flatten external packages for quick lookup
20
+ const allExternalPackages = [
21
+ ...externalPackages.node.map(pkg => `node:${pkg}`),
22
+ ...externalPackages.qcobjects
23
+ ];
24
+
25
+ // Function to detect and add the extension
26
+ const nameToExtension = (name, ext, settings) => {
27
+ const isPackage = name => !name.startsWith(".") && !name.startsWith("/") && !name.includes("/");
28
+ const hasExtension = /\.[^/\\]+$/.test(name);
29
+ const isExternalPackage = allExternalPackages.includes(name);
30
+
31
+ if (!hasExtension && !isPackage(name) && !isExternalPackage) {
32
+ name += ext;
33
+ }
34
+
35
+ return name;
36
+ };
37
+
38
+ // Function to add extensions to import/export/require statements
39
+ const addExtensions = (filePath, toExt, settings) => {
40
+ const content = readFileSync(filePath, 'utf8');
41
+ const patterns = [
42
+ [/(from\s+['"])(.*?)(['"])/g, '$1$2$3'],
43
+ [/(import\s+['"])(.*?)(['"])/g, '$1$2$3'],
44
+ [/(export\s+['"])(.*?)(['"])/g, '$1$2$3'],
45
+ [/(require\s*\(\s*['"])(.*?)(['"]\s*\))/g, '$1$2$3']
46
+ ];
47
+
48
+ const updatedContent = patterns.reduce((content, [pattern, replacement]) => {
49
+ return content.replace(pattern, (match, p1, p2, p3) => {
50
+ return `${p1}${nameToExtension(p2, toExt, settings)}${p3}`;
51
+ });
52
+ }, content);
53
+
54
+ writeFileSync(filePath, updatedContent, 'utf8');
55
+ };
56
+
57
+ // Common build settings
58
+ const baseSettings = {
59
+ entryPoints: glob.sync('src/**/*.ts').map(file => path.resolve(file)),
60
+ bundle: false,
61
+ target: ["node22"],
62
+ tsconfig: "tsconfig.json",
63
+ globalName: "global",
64
+ minify: false,
65
+ keepNames: true,
66
+ sourcemap: true,
67
+ splitting: false,
68
+ chunkNames: "chunks/[name]-[hash]",
69
+ plugins: [
70
+ {
71
+ name: 'transform-qcobjects-imports',
72
+ setup(build) {
73
+ build.onResolve({ filter: /^(qcobjects|qcobjects-sdk)$/ }, args => ({
74
+ path: path.resolve(args.path),
75
+ namespace: args.kind === 'dynamic-import' ? 'qcobjects-transform' : undefined,
76
+ external: args.kind !== 'dynamic-import'
77
+ }));
78
+
79
+ build.onResolve({ filter: /.*/, namespace: 'file' }, args => ({
80
+ external: args.kind === 'dynamic-import',
81
+ path: path.resolve(args.path)
82
+ }));
83
+
84
+ build.onLoad({ filter: /.*/, namespace: 'qcobjects-transform' }, args => ({
85
+ contents: `module.exports = __toESM(require("${path.resolve(args.path)}"), true);`,
86
+ loader: 'js'
87
+ }));
88
+ }
89
+ },
90
+ alias({
91
+ "types": path.resolve(__dirname, "src/types/global/index.d.ts")
92
+ })
93
+ ]
94
+ };
95
+
96
+ // Build settings for different formats
97
+ const buildConfigs = {
98
+ esm: {
99
+ ...baseSettings,
100
+ outdir: "public/esm",
101
+ format: "esm",
102
+ platform: "browser",
103
+ outExtension: { ".js": ".mjs" },
104
+ plugins: [
105
+ ...baseSettings.plugins,
106
+ {
107
+ name: 'transform-requires',
108
+ setup(build) {
109
+ build.onEnd(() => {
110
+ glob.sync('public/esm/**/*.mjs').forEach(file => {
111
+ let content = readFileSync(file, 'utf8');
112
+ content = content
113
+ .replace(/const\s+{([^}]+)}\s*=\s*require\(['"]([^'"]+)['"]\)/g, 'import { $1 } from "$2"')
114
+ .replace(/const\s+([^=]+)\s*=\s*require\(['"]([^'"]+)['"]\)/g, 'import $1 from "$2"');
115
+ writeFileSync(file, content, 'utf8');
116
+ });
117
+ });
118
+ }
119
+ }
120
+ ]
121
+ }
122
+ };
123
+
124
+ // Utility functions
125
+ const logError = (e) => { console.error(e); process.exit(1); };
126
+ const logDebug = (e) => { console.debug(e); };
127
+
128
+ const copyDir = async (source, dest, exclude = []) => {
129
+ source = path.resolve(source);
130
+ dest = path.resolve(dest);
131
+ const dname = path.basename(source);
132
+
133
+ if (exclude.includes(dname)) return;
134
+
135
+ try {
136
+ const stat = await fs.stat(source);
137
+ if (!stat.isDirectory()) return;
138
+
139
+ await fs.mkdir(dest, { recursive: true });
140
+ const paths = await fs.readdir(source, { withFileTypes: true });
141
+
142
+ await Promise.all(paths.map(async item => {
143
+ const sourcePath = path.resolve(source, item.name);
144
+ const destPath = path.resolve(dest, item.name);
145
+
146
+ if (item.isFile() && !exclude.includes(item.name)) {
147
+ logDebug(`[publish:static] Copying ${sourcePath} to ${destPath}`);
148
+ await fs.copyFile(sourcePath, destPath);
149
+ } else if (item.isDirectory()) {
150
+ await copyDir(sourcePath, destPath, exclude);
151
+ }
152
+ }));
153
+ } catch (error) {
154
+ logError(error);
155
+ }
156
+ };
157
+
158
+ // Main execution
159
+ (async () => {
160
+ try {
161
+ // Copy templates
162
+ const templateDirs = [
163
+ "./build/templates",
164
+ "./public/cjs/templates",
165
+ "./public/esm/templates",
166
+ "./public/browser/templates"
167
+ ];
168
+
169
+ await Promise.all(templateDirs.map(dir =>
170
+ copyDir("./src/templates", dir, [])
171
+ ));
172
+
173
+ // Run builds in parallel
174
+ await Promise.all([
175
+ esbuild.build(buildConfigs.esm)
176
+ ]);
177
+ } catch (error) {
178
+ logError(error);
179
+ }
180
+ })();
package/build-esbuild.js CHANGED
@@ -2,239 +2,213 @@ const esbuild = require("esbuild");
2
2
  const alias = require("esbuild-plugin-alias");
3
3
  const path = require("node:path");
4
4
  const { readFileSync, writeFileSync } = require("node:fs");
5
- const fs = require("node:fs").promises;
5
+ const fs = require("node:fs/promises");
6
6
  const glob = require("glob");
7
7
 
8
- // Function to detect and add the extension
9
- const nameToExtension = (name, ext) => {
10
- function isPackage(name) {
11
- // Simple check to determine if the name is a package
12
- // This can be enhanced based on your specific needs
13
- return !name.startsWith(".") && !name.startsWith("/") && !name.includes("/");
14
- }
15
-
16
- const hasExtension = /\.[^/\\]+$/.test(name);
17
- if (!hasExtension && !isPackage(name)) {
18
- name += ext;
19
- }
20
-
21
- return name;
22
- };
23
-
24
- // Function to add .cjs and .mjs extensions to import/export/require statements
25
- const addExtensions = (filePath, toExt) => {
26
- const content = readFileSync(filePath, 'utf8');
27
- const updatedContent = content.replace(/(from\s+['"])(.*?)(['"])/g, (match, p1, p2, p3) => {
28
- return `${p1}${nameToExtension(p2, toExt)}${p3}`;
29
- }).replace(/(import\s+['"])(.*?)(['"])/g, (match, p1, p2, p3) => {
30
- return `${p1}${nameToExtension(p2, toExt)}${p3}`;
31
- }).replace(/(export\s+['"])(.*?)(['"])/g, (match, p1, p2, p3) => {
32
- return `${p1}${nameToExtension(p2, toExt)}${p3}`;
33
- }).replace(/(require\s*\(\s*['"])(.*?)(['"]\s*\))/g, (match, p1, p2, p3) => {
34
- return `${p1}${nameToExtension(p2, toExt)}${p3}`;
35
- });
36
- writeFileSync(filePath, updatedContent, 'utf8');
37
- };
8
+ // Organized external packages into categories
9
+ const externalPackages = {
10
+ node: [
11
+ "fs", "path", "os", "util", "events", "stream", "http", "https",
12
+ "crypto", "zlib", "buffer", "url", "querystring", "child_process",
13
+ "cluster", "dgram", "dns", "net", "readline", "repl", "tls", "tty",
14
+ "vm", "worker_threads"
15
+ ],
16
+ qcobjects: ["qcobjects", "qcobjects-sdk"]
17
+ };
38
18
 
39
- // Get all TypeScript entry points
40
- const entryPoints = glob.sync('src/**/*.ts');
19
+ // Flatten external packages for quick lookup
20
+ const allExternalPackages = [
21
+ ...externalPackages.node.map(pkg => `node:${pkg}`),
22
+ ...externalPackages.qcobjects
23
+ ];
41
24
 
42
- const logError = (e) => { console.error(e); process.exit(1); };
43
- const logDebug = (e) => { console.debug(e); }
44
-
45
- const copyDir = async (source, dest, exclude) => {
46
- source = path.resolve(source);
47
- dest = path.resolve(dest);
48
- const dname = path.basename(source);
49
- const dirExcluded = exclude.includes(dname);
50
-
51
- const isDir = async (d) => {
52
- try {
53
- const stat = await fs.stat(d);
54
- return stat.isDirectory();
55
- } catch {
56
- return false;
57
- }
58
- };
59
-
60
- const isFile = async (d) => {
61
- try {
62
- const stat = await fs.stat(d);
63
- return stat.isFile();
64
- } catch {
65
- return false;
66
- }
67
- };
68
-
69
- if (await isDir(source) && !dirExcluded) {
70
- await fs.mkdir(dest, { recursive: true });
71
- const paths = await fs.readdir(source, { withFileTypes: true });
72
- const dirs = paths.filter(d => d.isDirectory());
73
- const files = paths.filter(f => f.isFile());
74
-
75
- for (const f of files) {
76
- const sourceFile = path.resolve(source, f.name);
77
- const destFile = path.resolve(dest, f.name);
78
- const fileExcluded = exclude.includes(f.name);
79
- if (await isFile(sourceFile) && !fileExcluded) {
80
- logDebug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...`);
81
- await fs.copyFile(sourceFile, destFile);
82
- logDebug(`[publish:static] Copying files from ${sourceFile} to ${destFile} excluding ${exclude}...DONE!`);
83
- }
84
- }
25
+ // Function to detect and add the extension
26
+ const nameToExtension = (name, ext, settings) => {
27
+ const isPackage = name => !name.startsWith(".") && !name.startsWith("/") && !name.includes("/");
28
+ const hasExtension = /\.[^/\\]+$/.test(name);
29
+ const isExternalPackage = allExternalPackages.includes(name);
85
30
 
86
- for (const d of dirs) {
87
- const sourceDir = path.resolve(source, d.name);
88
- const destDir = path.resolve(dest, d.name);
89
- await copyDir(sourceDir, destDir, exclude);
90
- }
91
- }
92
- };
31
+ if (!hasExtension && !isPackage(name) && !isExternalPackage) {
32
+ name += ext;
33
+ }
93
34
 
94
- (async () => {
95
- await copyDir("./src/templates", "./build/templates", []);
96
- await copyDir("./src/templates", "./public/cjs/templates", []);
97
- await copyDir("./src/templates", "./public/esm/templates", []);
98
- await copyDir("./src/templates", "./public/browser/templates", []);
99
- })();
100
-
101
- const ignorePlugin = {
102
- name: 'transform-qcobjects-imports',
103
- setup(build) {
104
- // Handle qcobjects and qcobjects-sdk dynamic imports
105
- build.onResolve({ filter: /^(qcobjects|qcobjects-sdk)$/ }, args => {
106
- if (args.kind === 'dynamic-import') {
107
- return {
108
- path: args.path,
109
- namespace: 'qcobjects-transform'
110
- }
111
- }
112
- return {
113
- external: true,
114
- path: args.path
115
- }
116
- });
35
+ return name;
36
+ };
117
37
 
118
- // Handle all other dynamic imports (handlers, commands, dev commands, libs)
119
- build.onResolve({ filter: /.*/, namespace: 'file' }, args => {
120
- if (args.kind === 'dynamic-import') {
121
- return {
122
- external: true,
123
- path: args.path
124
- }
125
- }
126
- return null;
38
+ // Function to add extensions to import/export/require statements
39
+ const addExtensions = (filePath, toExt, settings) => {
40
+ const content = readFileSync(filePath, 'utf8');
41
+ const patterns = [
42
+ [/(from\s+['"])(.*?)(['"])/g, '$1$2$3'],
43
+ [/(import\s+['"])(.*?)(['"])/g, '$1$2$3'],
44
+ [/(export\s+['"])(.*?)(['"])/g, '$1$2$3'],
45
+ [/(require\s*\(\s*['"])(.*?)(['"]\s*\))/g, '$1$2$3']
46
+ ];
47
+
48
+ const updatedContent = patterns.reduce((content, [pattern, replacement]) => {
49
+ return content.replace(pattern, (match, p1, p2, p3) => {
50
+ return `${p1}${nameToExtension(p2, toExt, settings)}${p3}`;
127
51
  });
52
+ }, content);
128
53
 
129
- build.onLoad({ filter: /.*/, namespace: 'qcobjects-transform' }, args => {
130
- return {
131
- contents: `
132
- module.exports = __toESM(require("${args.path}"), true);
133
- `,
134
- loader: 'js'
135
- }
136
- });
137
- }
138
- }
54
+ writeFileSync(filePath, updatedContent, 'utf8');
55
+ };
139
56
 
57
+ // Common build settings
140
58
  const baseSettings = {
141
- entryPoints: entryPoints,
142
- bundle: false,
143
- outdir: "public/cjs",
144
- format: "cjs",
145
- target: ["node22"],
146
- tsconfig: "tsconfig.json",
147
- globalName: "global",
148
- minify: false,
149
- keepNames: true,
150
- sourcemap: true,
151
- splitting: false,
152
- chunkNames: "chunks/[name]-[hash]",
153
- plugins: [
154
- ignorePlugin,
155
- alias({
156
- "types": path.join(__dirname, "src/types/global/index.d.ts")
157
- })
158
- ]
59
+ entryPoints: glob.sync('src/**/*.ts').map(file => path.resolve(file)),
60
+ bundle: false,
61
+ target: ["node22"],
62
+ tsconfig: "tsconfig.json",
63
+ globalName: "global",
64
+ minify: false,
65
+ keepNames: true,
66
+ sourcemap: true,
67
+ splitting: false,
68
+ chunkNames: "chunks/[name]-[hash]",
69
+ plugins: [
70
+ {
71
+ name: 'transform-qcobjects-imports',
72
+ setup(build) {
73
+ build.onResolve({ filter: /^(qcobjects|qcobjects-sdk)$/ }, args => ({
74
+ path: path.resolve(args.path),
75
+ namespace: args.kind === 'dynamic-import' ? 'qcobjects-transform' : undefined,
76
+ external: args.kind !== 'dynamic-import'
77
+ }));
78
+
79
+ build.onResolve({ filter: /.*/, namespace: 'file' }, args => ({
80
+ external: args.kind === 'dynamic-import',
81
+ path: path.resolve(args.path)
82
+ }));
83
+
84
+ build.onLoad({ filter: /.*/, namespace: 'qcobjects-transform' }, args => ({
85
+ contents: `module.exports = __toESM(require("${path.resolve(args.path)}"), true);`,
86
+ loader: 'js'
87
+ }));
88
+ }
89
+ },
90
+ alias({
91
+ "types": path.resolve(__dirname, "src/types/global/index.d.ts")
92
+ })
93
+ ]
159
94
  };
160
95
 
161
- const cjsSettings = {
96
+ // Build settings for different formats
97
+ const buildConfigs = {
98
+ cjs: {
162
99
  ...baseSettings,
163
100
  outdir: "public/cjs",
164
101
  format: "cjs",
165
102
  platform: "node",
166
- outExtension: {
167
- ".js": ".cjs"
168
- },
103
+ outExtension: { ".js": ".cjs", ".ts": ".cjs" },
169
104
  plugins: [
170
- ignorePlugin,
171
- {
172
- name: 'transform-dynamic-imports',
173
- setup(build) {
174
- // Transform dynamic imports in the final output
175
- build.onEnd(() => {
176
- const files = glob.sync('public/cjs/**/*.cjs');
177
- for (const file of files) {
178
- let content = readFileSync(file, 'utf8');
179
-
180
- // Transform dynamic imports to requires
181
- content = content.replace(
182
- /await\s+import\(['"]([^'"]+)['"]\)/g,
183
- '__toESM(require("$1"), true)'
184
- );
185
-
186
- writeFileSync(file, content, 'utf8');
187
- }
188
- });
189
- }
190
- },
191
- {
192
- name: 'add-extensions',
193
- setup(build) {
194
- build.onEnd(() => {
195
- entryPoints.forEach(entry => {
196
- const outputFilePath = path.join('./public/cjs', entry.replace('src/', '').replace('.ts', '.cjs'));
197
- addExtensions(outputFilePath, '.cjs');
198
- });
199
- });
200
- }
105
+ ...baseSettings.plugins,
106
+ {
107
+ name: 'transform-dynamic-imports',
108
+ setup(build) {
109
+ build.onEnd(() => {
110
+ glob.sync('public/cjs/**/*.cjs').forEach(file => {
111
+ let content = readFileSync(file, 'utf8');
112
+ content = content.replace(
113
+ /await\s+import\(['"]([^'"]+)['"]\)/g,
114
+ '__toESM(require("$1"), true)'
115
+ );
116
+ writeFileSync(file, content, 'utf8');
117
+ });
118
+ });
201
119
  }
120
+ }
202
121
  ]
203
- };
204
-
205
- const esmSettings = {
122
+ },
123
+ esm: {
206
124
  ...baseSettings,
207
- outdir: "public/esm", // Output dir
208
- format: "esm", // or "esm" depending on your module system
209
- platform: "browser", // or "browser" depending on your target environment
210
- outExtension: {
211
- ".js": ".mjs"
212
- },
125
+ outdir: "public/esm",
126
+ format: "esm",
127
+ platform: "browser",
128
+ outExtension: { ".js": ".mjs" },
213
129
  plugins: [
214
- {
215
- name: 'add-extensions',
216
- setup(build) {
217
- build.onEnd(() => {
218
- entryPoints.forEach(entry => {
219
- const outputFilePath = path.join('./public/esm', entry.replace('src/', '').replace('.ts', '.mjs'));
220
- addExtensions(outputFilePath, '.mjs');
221
- });
222
- });
223
- }
130
+ ...baseSettings.plugins,
131
+ {
132
+ name: 'transform-requires',
133
+ setup(build) {
134
+ build.onEnd(() => {
135
+ glob.sync('public/esm/**/*.mjs').forEach(file => {
136
+ let content = readFileSync(file, 'utf8');
137
+ content = content
138
+ .replace(/const\s+{([^}]+)}\s*=\s*require\(['"]([^'"]+)['"]\)/g, 'import { $1 } from "$2"')
139
+ .replace(/const\s+([^=]+)\s*=\s*require\(['"]([^'"]+)['"]\)/g, 'import $1 from "$2"');
140
+ writeFileSync(file, content, 'utf8');
141
+ });
142
+ });
224
143
  }
144
+ }
225
145
  ]
146
+ },
147
+ browser: {
148
+ ...baseSettings,
149
+ outdir: "public/browser",
150
+ format: "iife",
151
+ platform: "browser",
152
+ outExtension: { ".js": ".js" }
153
+ }
226
154
  };
227
155
 
228
- const browserSettings = {
229
- ...baseSettings,
230
- outdir: "public/browser", // Output dir
231
- format: "iife", // or "esm" depending on your module system
232
- platform: "browser", // or "browser" depending on your target environment
233
- outExtension: {
234
- ".js": ".js"
235
- }
156
+ // Utility functions
157
+ const logError = (e) => { console.error(e); process.exit(1); };
158
+ const logDebug = (e) => { console.debug(e); };
159
+
160
+ const copyDir = async (source, dest, exclude = []) => {
161
+ source = path.resolve(source);
162
+ dest = path.resolve(dest);
163
+ const dname = path.basename(source);
164
+
165
+ if (exclude.includes(dname)) return;
166
+
167
+ try {
168
+ const stat = await fs.stat(source);
169
+ if (!stat.isDirectory()) return;
170
+
171
+ await fs.mkdir(dest, { recursive: true });
172
+ const paths = await fs.readdir(source, { withFileTypes: true });
173
+
174
+ await Promise.all(paths.map(async item => {
175
+ const sourcePath = path.resolve(source, item.name);
176
+ const destPath = path.resolve(dest, item.name);
177
+
178
+ if (item.isFile() && !exclude.includes(item.name)) {
179
+ logDebug(`[publish:static] Copying ${sourcePath} to ${destPath}`);
180
+ await fs.copyFile(sourcePath, destPath);
181
+ } else if (item.isDirectory()) {
182
+ await copyDir(sourcePath, destPath, exclude);
183
+ }
184
+ }));
185
+ } catch (error) {
186
+ logError(error);
187
+ }
236
188
  };
237
189
 
238
- esbuild.build(cjsSettings).catch(logError);
239
- esbuild.build(esmSettings).catch(logError);
240
- esbuild.build(browserSettings).catch(logError);
190
+ // Main execution
191
+ (async () => {
192
+ try {
193
+ // Copy templates
194
+ const templateDirs = [
195
+ "./build/templates",
196
+ "./public/cjs/templates",
197
+ "./public/esm/templates",
198
+ "./public/browser/templates"
199
+ ];
200
+
201
+ await Promise.all(templateDirs.map(dir =>
202
+ copyDir("./src/templates", dir, [])
203
+ ));
204
+
205
+ // Run builds in parallel
206
+ await Promise.all([
207
+ // esbuild.build(buildConfigs.cjs),
208
+ esbuild.build(buildConfigs.esm),
209
+ esbuild.build(buildConfigs.browser)
210
+ ]);
211
+ } catch (error) {
212
+ logError(error);
213
+ }
214
+ })();
package/deno.json CHANGED
File without changes
@@ -0,0 +1,5 @@
1
+ # Dev tools (not used in production)
2
+ # Add language-specific tools here, e.g.:
3
+ # ruff==0.9.6
4
+ # mypy==1.15.0
5
+ pre-commit==4.1.0
package/eslint.config.mjs CHANGED
File without changes
package/mod.ts CHANGED
File without changes