@xrystal/core 3.32.1 → 3.37.4

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 (264) hide show
  1. package/README.md +676 -136
  2. package/package.json +27 -24
  3. package/tsconfig.base.json +15 -0
  4. package/x/bin/commands/create.mjs +34 -5
  5. package/x/bin/commands/doctor.mjs +115 -25
  6. package/x/bin/commands/hooks.mjs +55 -0
  7. package/x/bin/commands/project.mjs +75 -42
  8. package/x/bin/commands/release.mjs +8 -3
  9. package/x/bin/commands/sync-toolchain.mjs +43 -0
  10. package/x/bin/commands/tmp.mjs +13 -4
  11. package/x/bin/helpers/.generated/.generated-from +1 -0
  12. package/x/bin/helpers/.generated/tmp-schema.mjs +192 -0
  13. package/x/bin/helpers/banner.mjs +66 -12
  14. package/x/bin/helpers/build-config.mjs +342 -0
  15. package/x/bin/helpers/cli-help.mjs +164 -0
  16. package/x/bin/helpers/create-target.mjs +18 -2
  17. package/x/bin/helpers/project-artifacts.mjs +142 -0
  18. package/x/bin/helpers/runtime-info.mjs +172 -0
  19. package/x/bin/helpers/tmp-config.mjs +11 -10
  20. package/x/bin/helpers/tmp-layout.mjs +10 -16
  21. package/x/bin/helpers/tmp-schema.mjs +9 -0
  22. package/x/bin/helpers/toolchain-config.mjs +233 -0
  23. package/x/bin/main-cli.js +31 -3
  24. package/x/bin/scripts/clean-source-types.mjs +19 -0
  25. package/x/bin/scripts/fix-dist-imports.mjs +80 -0
  26. package/x/bin/scripts/install-git-hooks.mjs +86 -0
  27. package/x/bin/scripts/minify-dist.mjs +50 -0
  28. package/x/bin/scripts/prepare-npm-publish.mjs +39 -0
  29. package/x/bin/scripts/publish-guard.mjs +113 -0
  30. package/x/bin/scripts/verify-npm-pack.mjs +12 -0
  31. package/x/bin/scripts/verify-publish-config.mjs +10 -0
  32. package/x/bin/scripts/verify-version-bump.mjs +27 -0
  33. package/x/bin/scripts/version-check.mjs +173 -0
  34. package/x/dist/index.js +1 -0
  35. package/x/dist/loader/clients/index.js +1 -0
  36. package/x/dist/loader/configs/index.js +1 -0
  37. package/{source → x/dist}/loader/controller/index.d.ts +20 -17
  38. package/x/dist/loader/controller/index.js +1 -0
  39. package/x/dist/loader/dto/index.js +1 -0
  40. package/x/dist/loader/events/index.js +1 -0
  41. package/x/dist/loader/index.d.ts +11 -0
  42. package/x/dist/loader/index.js +1 -0
  43. package/{source → x/dist}/loader/kafka/index.d.ts +1 -0
  44. package/x/dist/loader/kafka/index.js +1 -0
  45. package/x/dist/loader/localizations/index.js +1 -0
  46. package/{source → x/dist}/loader/logger/index.d.ts +1 -0
  47. package/x/dist/loader/logger/index.js +2 -0
  48. package/x/dist/loader/service/index.js +1 -0
  49. package/x/dist/loader/system/index.js +1 -0
  50. package/x/dist/project/index.d.ts +12 -0
  51. package/x/dist/project/index.js +1 -0
  52. package/x/dist/utils/constants/defaults.json +44 -0
  53. package/x/dist/utils/constants/index.js +1 -0
  54. package/x/dist/utils/helpers/configs/index.js +1 -0
  55. package/x/dist/utils/helpers/context/controller-store.js +1 -0
  56. package/x/dist/utils/helpers/context/index.js +1 -0
  57. package/{source → x/dist}/utils/helpers/core/index.d.ts +1 -1
  58. package/x/dist/utils/helpers/core/index.js +1 -0
  59. package/x/dist/utils/helpers/core/paths.js +1 -0
  60. package/x/dist/utils/helpers/core/tmp-layout.js +1 -0
  61. package/x/dist/utils/helpers/date/index.js +1 -0
  62. package/x/dist/utils/helpers/dispatch/index.js +1 -0
  63. package/x/dist/utils/helpers/dto/index.js +1 -0
  64. package/x/dist/utils/helpers/filters/index.js +1 -0
  65. package/x/dist/utils/helpers/framework/index.js +1 -0
  66. package/x/dist/utils/helpers/handlers/adapters.js +1 -0
  67. package/x/dist/utils/helpers/handlers/execute.js +1 -0
  68. package/x/dist/utils/helpers/handlers/index.js +1 -0
  69. package/x/dist/utils/helpers/hash/crypto.js +1 -0
  70. package/x/dist/utils/helpers/id/index.js +1 -0
  71. package/x/dist/utils/helpers/index.js +1 -0
  72. package/x/dist/utils/helpers/ip/index.js +1 -0
  73. package/x/dist/utils/helpers/is/index.js +1 -0
  74. package/x/dist/utils/helpers/locales/index.js +1 -0
  75. package/x/dist/utils/helpers/math/index.js +1 -0
  76. package/{source → x/dist}/utils/helpers/middleware/index.d.ts +2 -2
  77. package/x/dist/utils/helpers/middleware/index.js +1 -0
  78. package/x/dist/utils/helpers/objects/index.js +1 -0
  79. package/x/dist/utils/helpers/path/index.js +1 -0
  80. package/{source → x/dist}/utils/helpers/protocol/index.d.ts +2 -10
  81. package/x/dist/utils/helpers/protocol/index.js +1 -0
  82. package/x/dist/utils/helpers/protocol/options.js +1 -0
  83. package/x/dist/utils/helpers/regex/checkSpecialRegexControl.js +1 -0
  84. package/x/dist/utils/helpers/runtime/dto-access.js +1 -0
  85. package/x/dist/utils/helpers/runtime/dto-types.js +1 -0
  86. package/{source → x/dist}/utils/helpers/runtime/index.d.ts +1 -0
  87. package/x/dist/utils/helpers/runtime/index.js +1 -0
  88. package/x/dist/utils/helpers/runtime/shutdown.d.ts +3 -0
  89. package/x/dist/utils/helpers/runtime/shutdown.js +1 -0
  90. package/x/dist/utils/helpers/state/index.js +1 -0
  91. package/x/dist/utils/helpers/state/props-from-tmp.js +1 -0
  92. package/x/dist/utils/helpers/state/request-key-guard.js +1 -0
  93. package/x/dist/utils/helpers/state/scopes.js +1 -0
  94. package/x/dist/utils/helpers/string/index.js +1 -0
  95. package/x/dist/utils/helpers/tests/tmp-schema.test.js +1 -0
  96. package/x/dist/utils/helpers/tests/tmp-watch.test.d.ts +1 -0
  97. package/x/dist/utils/helpers/tests/tmp-watch.test.js +1 -0
  98. package/x/dist/utils/helpers/timer/index.js +1 -0
  99. package/x/dist/utils/helpers/tmp/index.d.ts +5 -0
  100. package/x/dist/utils/helpers/tmp/index.js +1 -0
  101. package/x/dist/utils/helpers/tmp/loader-tmp-sync.js +1 -0
  102. package/{source → x/dist}/utils/helpers/tmp/runtime-tmp.d.ts +2 -6
  103. package/x/dist/utils/helpers/tmp/runtime-tmp.js +1 -0
  104. package/{source → x/dist}/utils/helpers/tmp/tmp-loader.d.ts +1 -0
  105. package/x/dist/utils/helpers/tmp/tmp-loader.js +1 -0
  106. package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +47 -0
  107. package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -0
  108. package/x/dist/utils/helpers/tmp/tmp-watch.d.ts +1 -0
  109. package/x/dist/utils/helpers/tmp/tmp-watch.js +1 -0
  110. package/x/dist/utils/helpers/validates/index.js +1 -0
  111. package/x/dist/utils/index.js +1 -0
  112. package/x/dist/utils/models/classes/class.clients.js +1 -0
  113. package/x/dist/utils/models/classes/class.interfaces.js +1 -0
  114. package/x/dist/utils/models/classes/class.service-locator.js +1 -0
  115. package/{source → x/dist}/utils/models/classes/class.tmp-file-loader.d.ts +3 -2
  116. package/x/dist/utils/models/classes/class.tmp-file-loader.js +1 -0
  117. package/x/dist/utils/models/classes/class.x.js +1 -0
  118. package/x/dist/utils/models/enums/index.js +1 -0
  119. package/x/dist/utils/models/index.js +1 -0
  120. package/x/dist/utils/models/types/index.js +1 -0
  121. package/x/dist/utils/package-root.js +1 -0
  122. package/x/tmp.yml +51 -42
  123. package/source/index.js +0 -11
  124. package/source/loader/clients/index.js +0 -22
  125. package/source/loader/configs/index.js +0 -88
  126. package/source/loader/controller/index.js +0 -236
  127. package/source/loader/dto/index.js +0 -92
  128. package/source/loader/events/index.js +0 -44
  129. package/source/loader/index.d.ts +0 -11
  130. package/source/loader/index.js +0 -11
  131. package/source/loader/kafka/index.js +0 -137
  132. package/source/loader/localizations/index.js +0 -46
  133. package/source/loader/logger/index.js +0 -217
  134. package/source/loader/service/index.js +0 -7
  135. package/source/loader/system/index.js +0 -25
  136. package/source/project/index.d.ts +0 -8
  137. package/source/project/index.js +0 -70
  138. package/source/utils/constants/defaults.json +0 -15
  139. package/source/utils/constants/defaults.mjs +0 -10
  140. package/source/utils/constants/index.js +0 -22
  141. package/source/utils/helpers/configs/index.js +0 -1
  142. package/source/utils/helpers/context/controller-store.js +0 -12
  143. package/source/utils/helpers/context/index.js +0 -24
  144. package/source/utils/helpers/core/index.js +0 -58
  145. package/source/utils/helpers/core/paths.js +0 -78
  146. package/source/utils/helpers/core/tmp-layout.js +0 -241
  147. package/source/utils/helpers/date/index.js +0 -48
  148. package/source/utils/helpers/dispatch/index.js +0 -53
  149. package/source/utils/helpers/dto/index.js +0 -10
  150. package/source/utils/helpers/filters/index.js +0 -44
  151. package/source/utils/helpers/framework/index.js +0 -17
  152. package/source/utils/helpers/handlers/adapters.js +0 -40
  153. package/source/utils/helpers/handlers/execute.js +0 -82
  154. package/source/utils/helpers/handlers/index.js +0 -31
  155. package/source/utils/helpers/hash/crypto.js +0 -22
  156. package/source/utils/helpers/id/index.js +0 -24
  157. package/source/utils/helpers/index.js +0 -26
  158. package/source/utils/helpers/ip/index.js +0 -21
  159. package/source/utils/helpers/is/index.js +0 -35
  160. package/source/utils/helpers/locales/index.js +0 -82
  161. package/source/utils/helpers/math/index.js +0 -14
  162. package/source/utils/helpers/middleware/index.js +0 -36
  163. package/source/utils/helpers/objects/index.js +0 -55
  164. package/source/utils/helpers/path/index.js +0 -4
  165. package/source/utils/helpers/protocol/index.js +0 -99
  166. package/source/utils/helpers/protocol/options.js +0 -13
  167. package/source/utils/helpers/regex/checkSpecialRegexControl.js +0 -3
  168. package/source/utils/helpers/runtime/dto-access.js +0 -5
  169. package/source/utils/helpers/runtime/index.js +0 -1
  170. package/source/utils/helpers/state/index.js +0 -185
  171. package/source/utils/helpers/state/props-from-tmp.js +0 -44
  172. package/source/utils/helpers/state/request-key-guard.js +0 -42
  173. package/source/utils/helpers/state/scopes.js +0 -69
  174. package/source/utils/helpers/string/index.js +0 -9
  175. package/source/utils/helpers/timer/index.js +0 -5
  176. package/source/utils/helpers/tmp/index.d.ts +0 -3
  177. package/source/utils/helpers/tmp/index.js +0 -3
  178. package/source/utils/helpers/tmp/loader-tmp-sync.js +0 -13
  179. package/source/utils/helpers/tmp/runtime-tmp.js +0 -30
  180. package/source/utils/helpers/tmp/tmp-loader.js +0 -48
  181. package/source/utils/helpers/validates/index.js +0 -20
  182. package/source/utils/index.js +0 -3
  183. package/source/utils/models/classes/class.clients.js +0 -142
  184. package/source/utils/models/classes/class.interfaces.js +0 -10
  185. package/source/utils/models/classes/class.service-locator.js +0 -16
  186. package/source/utils/models/classes/class.tmp-file-loader.js +0 -38
  187. package/source/utils/models/classes/class.x.js +0 -180
  188. package/source/utils/models/enums/index.js +0 -148
  189. package/source/utils/models/index.js +0 -9
  190. package/source/utils/models/types/index.js +0 -2
  191. package/source/utils/models/types/shims.d.ts +0 -123
  192. package/source/utils/package-root.js +0 -5
  193. package/x/tests/cli.test.ts +0 -85
  194. package/x/tests/context.test.ts +0 -25
  195. package/x/tests/dispatch.test.ts +0 -84
  196. package/x/tests/fixtures/locales/en/translation.json +0 -8
  197. package/x/tests/fixtures/locales/tr/translation.json +0 -8
  198. package/x/tests/frameworks.integration.test.ts +0 -185
  199. package/x/tests/helpers/i18n-setup.ts +0 -52
  200. package/x/tests/helpers/middleware.ts +0 -23
  201. package/x/tests/helpers/register-test-dto.ts +0 -52
  202. package/x/tests/i18n.integration.test.ts +0 -77
  203. package/x/tests/i18n.test.ts +0 -96
  204. package/x/tests/middleware.test.ts +0 -83
  205. package/x/tests/project-layout.test.ts +0 -65
  206. package/x/tests/protocol.test.ts +0 -75
  207. package/x/tests/realtime.examples.test.ts +0 -198
  208. package/x/tests/runtime-tmp.test.ts +0 -49
  209. package/x/tests/socket.integration.test.ts +0 -174
  210. package/x/tests/state.test.ts +0 -183
  211. package/x/tests/tmp-layout-guard.test.ts +0 -40
  212. /package/{source → x/dist}/index.d.ts +0 -0
  213. /package/{source → x/dist}/loader/clients/index.d.ts +0 -0
  214. /package/{source → x/dist}/loader/configs/index.d.ts +0 -0
  215. /package/{source → x/dist}/loader/dto/index.d.ts +0 -0
  216. /package/{source → x/dist}/loader/events/index.d.ts +0 -0
  217. /package/{source → x/dist}/loader/localizations/index.d.ts +0 -0
  218. /package/{source → x/dist}/loader/service/index.d.ts +0 -0
  219. /package/{source → x/dist}/loader/system/index.d.ts +0 -0
  220. /package/{source → x/dist}/utils/constants/index.d.ts +0 -0
  221. /package/{source → x/dist}/utils/helpers/configs/index.d.ts +0 -0
  222. /package/{source → x/dist}/utils/helpers/context/controller-store.d.ts +0 -0
  223. /package/{source → x/dist}/utils/helpers/context/index.d.ts +0 -0
  224. /package/{source → x/dist}/utils/helpers/core/paths.d.ts +0 -0
  225. /package/{source → x/dist}/utils/helpers/core/tmp-layout.d.ts +0 -0
  226. /package/{source → x/dist}/utils/helpers/date/index.d.ts +0 -0
  227. /package/{source → x/dist}/utils/helpers/dispatch/index.d.ts +0 -0
  228. /package/{source → x/dist}/utils/helpers/dto/index.d.ts +0 -0
  229. /package/{source → x/dist}/utils/helpers/filters/index.d.ts +0 -0
  230. /package/{source → x/dist}/utils/helpers/framework/index.d.ts +0 -0
  231. /package/{source → x/dist}/utils/helpers/handlers/adapters.d.ts +0 -0
  232. /package/{source → x/dist}/utils/helpers/handlers/execute.d.ts +0 -0
  233. /package/{source → x/dist}/utils/helpers/handlers/index.d.ts +0 -0
  234. /package/{source → x/dist}/utils/helpers/hash/crypto.d.ts +0 -0
  235. /package/{source → x/dist}/utils/helpers/id/index.d.ts +0 -0
  236. /package/{source → x/dist}/utils/helpers/index.d.ts +0 -0
  237. /package/{source → x/dist}/utils/helpers/ip/index.d.ts +0 -0
  238. /package/{source → x/dist}/utils/helpers/is/index.d.ts +0 -0
  239. /package/{source → x/dist}/utils/helpers/locales/index.d.ts +0 -0
  240. /package/{source → x/dist}/utils/helpers/math/index.d.ts +0 -0
  241. /package/{source → x/dist}/utils/helpers/objects/index.d.ts +0 -0
  242. /package/{source → x/dist}/utils/helpers/path/index.d.ts +0 -0
  243. /package/{source → x/dist}/utils/helpers/protocol/options.d.ts +0 -0
  244. /package/{source → x/dist}/utils/helpers/regex/checkSpecialRegexControl.d.ts +0 -0
  245. /package/{source → x/dist}/utils/helpers/runtime/dto-access.d.ts +0 -0
  246. /package/{source → x/dist}/utils/helpers/runtime/dto-types.d.ts +0 -0
  247. /package/{source → x/dist}/utils/helpers/state/index.d.ts +0 -0
  248. /package/{source → x/dist}/utils/helpers/state/props-from-tmp.d.ts +0 -0
  249. /package/{source → x/dist}/utils/helpers/state/request-key-guard.d.ts +0 -0
  250. /package/{source → x/dist}/utils/helpers/state/scopes.d.ts +0 -0
  251. /package/{source → x/dist}/utils/helpers/string/index.d.ts +0 -0
  252. /package/{source/utils/helpers/runtime/dto-types.js → x/dist/utils/helpers/tests/tmp-schema.test.d.ts} +0 -0
  253. /package/{source → x/dist}/utils/helpers/timer/index.d.ts +0 -0
  254. /package/{source → x/dist}/utils/helpers/tmp/loader-tmp-sync.d.ts +0 -0
  255. /package/{source → x/dist}/utils/helpers/validates/index.d.ts +0 -0
  256. /package/{source → x/dist}/utils/index.d.ts +0 -0
  257. /package/{source → x/dist}/utils/models/classes/class.clients.d.ts +0 -0
  258. /package/{source → x/dist}/utils/models/classes/class.interfaces.d.ts +0 -0
  259. /package/{source → x/dist}/utils/models/classes/class.service-locator.d.ts +0 -0
  260. /package/{source → x/dist}/utils/models/classes/class.x.d.ts +0 -0
  261. /package/{source → x/dist}/utils/models/enums/index.d.ts +0 -0
  262. /package/{source → x/dist}/utils/models/index.d.ts +0 -0
  263. /package/{source → x/dist}/utils/models/types/index.d.ts +0 -0
  264. /package/{source → x/dist}/utils/package-root.d.ts +0 -0
@@ -0,0 +1,43 @@
1
+ import chalk from 'chalk'
2
+ import { printCommandHeader } from '../helpers/banner.mjs'
3
+ import { readCliPackageJson } from '../helpers/project-root.mjs'
4
+
5
+ import { syncProjectToolchain, auditTsconfigAlignment } from '../helpers/toolchain-config.mjs'
6
+ import { getProjectRoot } from '../helpers/project-root.mjs'
7
+
8
+ export function registerSyncToolchainCommand(cli, { cliName = 'xcore' } = {}) {
9
+ cli
10
+ .command('sync-toolchain')
11
+ .description('Sync tsconfig paths from tmp.yml layout')
12
+ .option('--dry-run', 'Show changes without writing tsconfig.json')
13
+ .action((options) => {
14
+ const root = getProjectRoot()
15
+ const auditBefore = auditTsconfigAlignment(root)
16
+
17
+ printCommandHeader({ cliName, command: 'sync-toolchain', version: readCliPackageJson().version })
18
+ console.log(chalk.gray(` root: ${root}`))
19
+
20
+ const lo = auditBefore.layoutOptions ?? {}
21
+ console.log(chalk.gray(' tmp.yml layout:'))
22
+ console.log(chalk.gray(` paths.root: ${lo.rootFolderPath ?? 'x'}`))
23
+ console.log(chalk.gray(` paths.source: ${lo.mainFolderPath ?? './source'}`))
24
+ console.log(chalk.gray(` paths.dist: ${lo.pathsDist ?? 'dist'}`))
25
+
26
+ if (options.dryRun) {
27
+ const preview = syncProjectToolchain(root, { write: false })
28
+ console.log(chalk.gray('\n would write tsconfig.json:'))
29
+ console.log(chalk.gray(` include: ${JSON.stringify(preview.merged.include)}`))
30
+ console.log(chalk.gray(` outDir: ${preview.merged.compilerOptions.outDir}`))
31
+ console.log(chalk.gray(` paths: ${JSON.stringify(preview.merged.compilerOptions.paths)}`))
32
+ console.log(chalk.gray(`\n bunfig.toml → ${preview.paths.bunfigAliasLine}\n`))
33
+ return
34
+ }
35
+
36
+ const result = syncProjectToolchain(root, { write: true })
37
+ console.log(result.created ? chalk.green(` created ${result.tsconfigRel}`) : chalk.green(` updated ${result.tsconfigRel}`))
38
+ console.log(chalk.gray(` include → ${JSON.stringify(result.merged.include)}`))
39
+ console.log(chalk.gray(` outDir → ${result.merged.compilerOptions.outDir}`))
40
+ console.log(chalk.gray(` eslint → ${result.paths.eslintFiles.join(', ')}`))
41
+ console.log(chalk.yellow(`\n bunfig.toml [resolve.alias]: ${result.paths.bunfigAliasLine}\n`))
42
+ })
43
+ }
@@ -2,29 +2,33 @@ import fs from 'node:fs'
2
2
  import chalk from 'chalk'
3
3
  import yaml from 'yaml'
4
4
 
5
+ import { printCommandHeader } from '../helpers/banner.mjs'
5
6
  import { resolveObjWithHandlebars } from '../helpers/index.mjs'
7
+ import { getProjectRoot, readCliPackageJson } from '../helpers/project-root.mjs'
6
8
  import {
7
9
  ensureTmpFile,
8
10
  ownerTmpFilePath,
9
11
  relativeFromRoot,
10
12
  resolveTmpLayoutOrDefaults,
11
13
  } from '../helpers/tmp-layout.mjs'
12
- import { getProjectRoot } from '../helpers/project-root.mjs'
13
14
  import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs'
14
15
 
15
16
  export function registerTmpCommand(cli, { cliName = 'xcore' } = {}) {
16
17
  cli
17
18
  .command('tmp')
18
- .description('Ensure project tmp.yml exists (auto-create from template if missing)')
19
+ .description('Ensure tmp.yml exists (seed from @xrystal/core)')
19
20
  .option('--dry-run', 'Show target path without writing')
20
21
  .action((options) => {
21
22
  const root = getProjectRoot()
23
+ const version = readCliPackageJson().version
22
24
 
23
25
  if (options.dryRun) {
24
26
  const layout = resolveTmpLayoutOrDefaults(root)
25
27
  const target = layout.tmpFilePath ?? ownerTmpFilePath(root, layout)
26
28
  const exists = fs.existsSync(target)
27
- console.log(chalk.cyan(`\n${cliName} tmp (dry-run)\n`))
29
+
30
+ printCommandHeader({ cliName, command: 'tmp (dry-run)', version })
31
+ console.log(chalk.gray(` root: ${root}`))
28
32
  console.log(` ${exists ? 'exists' : 'would create'}: ${target}`)
29
33
  console.log('')
30
34
  return
@@ -33,14 +37,19 @@ export function registerTmpCommand(cli, { cliName = 'xcore' } = {}) {
33
37
  const result = ensureTmpFile(root)
34
38
  const rel = relativeFromRoot(root, result.tmpFilePath)
35
39
 
36
- console.log(chalk.cyan(`\n${cliName} tmp\n`))
40
+ printCommandHeader({ cliName, command: 'tmp', version })
41
+ console.log(chalk.gray(` root: ${root}`))
37
42
  console.log(result.created ? chalk.green(` created ${rel}`) : chalk.gray(` ok ${rel}`))
38
43
 
39
44
  try {
40
45
  const tmp = yaml.parse(fs.readFileSync(result.tmpFilePath, 'utf8'))
41
46
  const summary = summarizeLoaders(resolveObjWithHandlebars(tmp, tmp))
42
47
  console.log(chalk.gray(` root: ${result.layout.rootFolderPath} · service: ${summary.service ?? '-'}`))
48
+ if (summary.items?.length) {
49
+ console.log(chalk.gray(` loaders: ${formatLoaderSummary(summary)}`))
50
+ }
43
51
  } catch {
52
+ // summary optional
44
53
  }
45
54
 
46
55
  console.log('')
@@ -0,0 +1 @@
1
+ source/utils/helpers/tmp/tmp-schema.ts
@@ -0,0 +1,192 @@
1
+ // source/utils/constants/index.ts
2
+ import path2 from "node:path";
3
+
4
+ // source/utils/package-root.ts
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ var utilsDir = path.dirname(fileURLToPath(import.meta.url));
8
+ var sourceDir = path.resolve(utilsDir, "..");
9
+ var packageRootDir = path.resolve(utilsDir, "..", "..");
10
+ // source/utils/constants/defaults.json
11
+ var defaults_default = {
12
+ packageName: "@xrystal/core",
13
+ packageRootFolder: "x",
14
+ tmpBaseName: "tmp",
15
+ tmpExtension: ".yml",
16
+ mainSourceFolder: "./source",
17
+ layoutPaths: {
18
+ tests: "tests",
19
+ environments: "environments",
20
+ dist: "dist"
21
+ },
22
+ buildDefaults: {
23
+ tsconfig: "tsconfig.json",
24
+ typecheck: false,
25
+ tscLenient: false,
26
+ declarations: false,
27
+ sourcemap: false,
28
+ minify: false
29
+ },
30
+ tsconfigDefaults: {
31
+ pathAliasKey: "@/*",
32
+ compilerOptions: {
33
+ noEmit: false,
34
+ noEmitOnError: false,
35
+ declaration: true,
36
+ emitDeclarationOnly: false,
37
+ sourceMap: false,
38
+ declarationMap: false,
39
+ strict: true,
40
+ noImplicitAny: true
41
+ }
42
+ },
43
+ eslintDefaults: {
44
+ restrictedImportDepth: 2
45
+ },
46
+ tmpWatchDefaults: {
47
+ intervalMs: 500,
48
+ minIntervalMs: 100,
49
+ maxIntervalMs: 1e4
50
+ },
51
+ publicFolderName: "public",
52
+ kafkaLogsTopic: "log",
53
+ templateRepoUri: "https://github.com/xdloper/api-gpt-svc"
54
+ };
55
+
56
+ // source/utils/constants/index.ts
57
+ var packageDefaults = Object.freeze({
58
+ ...defaults_default,
59
+ layoutPaths: Object.freeze({ ...defaults_default.layoutPaths })
60
+ });
61
+ var tmpFileName = `${packageDefaults.tmpBaseName}${packageDefaults.tmpExtension}`;
62
+
63
+ class Constants {
64
+ static packageName = packageDefaults.packageName;
65
+ static packageRootFolder = packageDefaults.packageRootFolder;
66
+ static tmpBaseName = packageDefaults.tmpBaseName;
67
+ static tmpExtension = packageDefaults.tmpExtension;
68
+ static mainSourceFolder = packageDefaults.mainSourceFolder;
69
+ static layoutPaths = packageDefaults.layoutPaths;
70
+ static publicFolderName = packageDefaults.publicFolderName;
71
+ static kafkaLogsTopic = packageDefaults.kafkaLogsTopic;
72
+ static templateRepoUri = packageDefaults.templateRepoUri;
73
+ static bundledCoreTmpPath = path2.join(packageRootDir, packageDefaults.packageRootFolder, tmpFileName);
74
+ }
75
+
76
+ // source/utils/helpers/tmp/tmp-schema.ts
77
+ function isRecord(value) {
78
+ return typeof value === "object" && value !== null && !Array.isArray(value);
79
+ }
80
+ function readWatchIntervalValue(raw) {
81
+ if (typeof raw === "number" || typeof raw === "string")
82
+ return raw;
83
+ return;
84
+ }
85
+ function normalizeRootFolder(value) {
86
+ if (!value?.trim())
87
+ return Constants.packageRootFolder;
88
+ return value.trim().replace(/^\.\/+/, "");
89
+ }
90
+ function normalizeSourceFolder(value) {
91
+ if (!value?.trim())
92
+ return Constants.mainSourceFolder;
93
+ const trimmed = value.trim();
94
+ if (trimmed.startsWith("./") || trimmed.startsWith("../"))
95
+ return trimmed;
96
+ return `./${trimmed}`;
97
+ }
98
+ function readTmpCoreBlock(configs) {
99
+ const core = isRecord(configs?.core) ? configs.core : {};
100
+ const tmp = isRecord(core.tmp) ? core.tmp : {};
101
+ return {
102
+ tmp: {
103
+ fileWatchIntervalMs: readWatchIntervalValue(tmp.fileWatchIntervalMs)
104
+ }
105
+ };
106
+ }
107
+ function readTmpServiceBlock(configs) {
108
+ const service = isRecord(configs?.service) ? configs.service : {};
109
+ const pathsRaw = isRecord(service.paths) ? service.paths : {};
110
+ const special = isRecord(pathsRaw.special) ? pathsRaw.special : {};
111
+ let loaders = isRecord(service.loaders) ? { ...service.loaders } : undefined;
112
+ let build = isRecord(service.build) ? service.build : undefined;
113
+ if (loaders && isRecord(loaders.build)) {
114
+ const { build: nestedBuild, ...rest } = loaders;
115
+ loaders = rest;
116
+ if (!build && isRecord(nestedBuild)) {
117
+ build = nestedBuild;
118
+ }
119
+ }
120
+ return {
121
+ name: typeof service.name === "string" ? service.name : undefined,
122
+ framework: typeof service.framework === "string" ? service.framework : undefined,
123
+ paths: {
124
+ root: typeof pathsRaw.root === "string" ? pathsRaw.root : undefined,
125
+ source: typeof pathsRaw.source === "string" ? pathsRaw.source : undefined,
126
+ special: {
127
+ tests: typeof special.tests === "string" ? special.tests : undefined,
128
+ environments: typeof special.environments === "string" ? special.environments : undefined,
129
+ dist: typeof special.dist === "string" ? special.dist : undefined
130
+ }
131
+ },
132
+ protocols: service.protocols,
133
+ loaders,
134
+ build
135
+ };
136
+ }
137
+ function resolveServiceLayoutPaths(service) {
138
+ const special = service.paths?.special ?? {};
139
+ return {
140
+ tests: special.tests?.trim() || Constants.layoutPaths.tests,
141
+ environments: special.environments?.trim() || Constants.layoutPaths.environments,
142
+ dist: special.dist?.trim() || Constants.layoutPaths.dist
143
+ };
144
+ }
145
+ function buildNormalizedService(service) {
146
+ const layoutPaths = resolveServiceLayoutPaths(service);
147
+ return {
148
+ name: service.name,
149
+ framework: service.framework ?? "elysia",
150
+ paths: {
151
+ root: service.paths?.root ?? Constants.packageRootFolder,
152
+ source: service.paths?.source ?? Constants.mainSourceFolder,
153
+ special: layoutPaths
154
+ },
155
+ protocols: service.protocols,
156
+ loaders: service.loaders,
157
+ build: service.build
158
+ };
159
+ }
160
+ function buildNormalizedCore(core) {
161
+ return {
162
+ tmp: {
163
+ fileWatchIntervalMs: core.tmp?.fileWatchIntervalMs
164
+ }
165
+ };
166
+ }
167
+ function resolveTmpRuntimeConfigs(tmp) {
168
+ const configs = isRecord(tmp?.configs) ? tmp.configs : {};
169
+ const service = readTmpServiceBlock(configs);
170
+ const core = readTmpCoreBlock(configs);
171
+ const normalizedService = buildNormalizedService(service);
172
+ return {
173
+ service: normalizedService,
174
+ core: buildNormalizedCore(core),
175
+ rootFolderPath: normalizeRootFolder(normalizedService.paths.root)
176
+ };
177
+ }
178
+ function normalizeTmpDocument(tmp) {
179
+ return {
180
+ ...tmp,
181
+ configs: resolveTmpRuntimeConfigs(tmp)
182
+ };
183
+ }
184
+ export {
185
+ resolveTmpRuntimeConfigs,
186
+ resolveServiceLayoutPaths,
187
+ readTmpServiceBlock,
188
+ readTmpCoreBlock,
189
+ normalizeTmpDocument,
190
+ normalizeSourceFolder,
191
+ normalizeRootFolder
192
+ };
@@ -1,26 +1,80 @@
1
1
  import chalk from 'chalk'
2
- import { CLI_PRIMARY_NAME } from './cli-identity.mjs'
3
2
 
4
- const LOGO = [
5
- '╦ ╦┬─┐┬ ┬┌─┐┬ ┌─┐ ┌─┐┬─┐┬─┐┬─┐',
6
- '╚╦╝├┬┘└┐┌┘├─┤│ ├─┤ │ ├┬┘├┬┘│┬┘',
7
- ' ╩ ┴└─ └┘ ┴ ┴┴─┘┴ ┴ └─┘┴└─┴└─┴└─',
3
+ import { CLI_BIN_NAMES, CLI_PRIMARY_NAME } from './cli-identity.mjs'
4
+
5
+ /** figlet standard — lowercase wordmark, split for two-tone print */
6
+ const XRYSTAL_LINES = [
7
+ ' _ _ ',
8
+ ' __ ___ __ _ _ ___| |_ __ _| |',
9
+ " \\ \\/ / '__| | | / __| __/ _` | |",
10
+ ' > <| | | |_| \\__ \\ || (_| | |',
11
+ ' /_/\\_\\_| \\__, |___/\\__\\__,_|_|',
12
+ ' |___/ ',
13
+ ]
14
+
15
+ const CORE_LINES = [
16
+ '',
17
+ ' ___ ___ _ __ ___ ',
18
+ " / __/ _ \\| '__/ _ \\",
19
+ ' | (_| (_) | | | __/',
20
+ ' \\___\\___/|_| \\___/',
21
+ '',
8
22
  ]
9
23
 
10
- const COLORS = [chalk.cyan, chalk.magenta, chalk.yellow, chalk.green, chalk.blue]
24
+ const WORDMARK_WIDTH = Math.max(...XRYSTAL_LINES.map((line) => line.length))
25
+ const BIN_ALIASES_LABEL = CLI_BIN_NAMES.join(' · ')
26
+ export function printWordmark() {
27
+ const rows = Math.max(XRYSTAL_LINES.length, CORE_LINES.length)
28
+ for (let i = 0; i < rows; i += 1) {
29
+ const left = (XRYSTAL_LINES[i] ?? '').padEnd(WORDMARK_WIDTH)
30
+ const right = CORE_LINES[i] ?? ''
31
+ console.log(` ${chalk.bold.white(left)}${chalk.bold.magenta(right)}`)
32
+ }
33
+ }
11
34
 
35
+ export function brandTitle() {
36
+ return `${chalk.bold.white('xrystal ')}${chalk.bold.magenta('core')}`
37
+ }
38
+
39
+ /** Full banner — bare `xcore` / `xcore -h` (root help). */
12
40
  export function printBanner({ version, runtimeName, invokedAs } = {}) {
41
+ const bin = invokedAs && invokedAs !== 'main-cli.js' ? invokedAs : CLI_PRIMARY_NAME
42
+ const versionLabel = version ? chalk.bold.green(`v${version}`) : chalk.gray('v?')
43
+ const runtimeLabel = runtimeName ? chalk.bold.white(runtimeName) : ''
44
+
13
45
  console.log('')
14
- LOGO.forEach((line, i) => console.log(COLORS[i % COLORS.length].bold(line)))
15
- const label = invokedAs && invokedAs !== 'main-cli.js' ? invokedAs : CLI_PRIMARY_NAME
16
- console.log(chalk.gray(` ${label} · @xrystal/core${version ? ` v${version}` : ''}${runtimeName ? ` · ${runtimeName}` : ''}`))
17
- console.log(chalk.dim(' scaffold · loaders · dto · i18n · multi-protocol'))
46
+
47
+ printWordmark()
48
+ console.log('')
49
+ console.log(chalk.bold.gray(' microservice runtime library'))
50
+
51
+ console.log('')
52
+ console.log(
53
+ ` ${chalk.bold.cyan(bin)} ${chalk.gray('·')} ${chalk.bold('@xrystal/core')} ${versionLabel}${runtimeLabel ? ` ${chalk.gray('·')} ${runtimeLabel}` : ''}`,
54
+ )
55
+ console.log(chalk.bold.gray(' loaders · tmp.yml · dto · i18n · multi-protocol · scaffold'))
56
+ console.log(chalk.dim(` bin aliases: ${BIN_ALIASES_LABEL}`))
57
+ console.log('')
58
+ }
59
+
60
+ /** One-line header for subcommands (build, dev, doctor, …). */
61
+ export function printCommandHeader({ cliName, command, version } = {}) {
62
+ const label = cliName || CLI_PRIMARY_NAME
63
+ const versionLabel = version ? chalk.green(`v${version}`) : ''
18
64
  console.log('')
65
+ console.log(
66
+ `${chalk.bold.cyan(`${label} ${command}`)} ${chalk.gray('·')} ${brandTitle()} ${versionLabel}`.trim(),
67
+ )
19
68
  }
20
69
 
70
+ /**
71
+ * Root banner: bare CLI, or root-level -h / --help / help.
72
+ * Subcommands keep compact headers only.
73
+ */
21
74
  export function shouldShowBanner(argv = process.argv) {
22
75
  const args = argv.slice(2)
23
76
  if (!args.length) return true
24
- if (args.some((a) => ['-V', '--version', '-h', '--help'].includes(a))) return false
25
- return true
77
+ if (args.length === 1 && ['-h', '--help', 'help'].includes(args[0])) return true
78
+ if (args.some((a) => ['-V', '--version'].includes(a))) return false
79
+ return false
26
80
  }