@xrystal/core 3.54.0 → 3.55.3

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.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @xrystal/core
2
2
 
3
- > **EN** — Microservice runtime: Express or Elysia HTTP, DI loaders, live `tmp.yml`, standardized API responses.
4
- > **TR** — Microservice runtime: Express veya Elysia HTTP, DI loader'lar, canlı `tmp.yml`, standart API cevapları.
3
+ > **EN** — Runtime framework: API services & frontends, workspace CLI, DI loaders, live `tmp.yml`, multi-protocol.
4
+ > **TR** — Runtime framework: API & frontend, workspace CLI, DI loader'lar, canlı `tmp.yml`, çoklu protokol.
5
5
 
6
6
  **CLI:** `xry` · **Version:** `3.52.5` · [npm](https://www.npmjs.com/package/@xrystal/core)
7
7
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.54.0",
5
- "description": "microservice runtime library",
4
+ "version": "3.55.3",
5
+ "description": "Runtime framework and CLI for API services, frontends, and multi-repo workspaces",
6
6
  "publishConfig": {
7
7
  "access": "public",
8
8
  "registry": "https://registry.npmjs.org/"
@@ -0,0 +1,77 @@
1
+ import chalk from 'chalk'
2
+
3
+ import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
4
+ import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
5
+ import { getCliLang, setCliLang, t } from '../helpers/cli-i18n.mjs'
6
+ import { CliLangEnum } from '../helpers/cli-lang.mjs'
7
+ import { readCliPackageJson } from '../helpers/project-root.mjs'
8
+ import {
9
+ clearCliConfigLang,
10
+ configFilePath,
11
+ getCliConfigLang,
12
+ listSupportedCliLangs,
13
+ readXrystalConfig,
14
+ setCliConfigLang,
15
+ } from '../helpers/xrystal-config.mjs'
16
+
17
+ function printConfigDoc(doc) {
18
+ console.log(chalk.gray(` file: ${configFilePath()}`))
19
+ console.log(chalk.bold.white('\n cli'))
20
+ const lang = doc.cli?.lang ?? chalk.dim('(not set — default en)')
21
+ console.log(` lang: ${lang}`)
22
+ if (doc.updatedAt) {
23
+ console.log(chalk.gray(`\n updated: ${doc.updatedAt}`))
24
+ }
25
+ }
26
+
27
+ export function registerConfigCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
28
+ const config = cli
29
+ .command('config')
30
+ .description('~/.xrystal/config.json — persistent CLI preferences')
31
+
32
+ config
33
+ .command('show', { isDefault: true })
34
+ .description('Show ~/.xrystal/config.json')
35
+ .action(() => {
36
+ const version = readCliPackageJson().version
37
+ printCommandHeader({ cliName, command: 'config', version })
38
+ printConfigDoc(readXrystalConfig())
39
+ console.log(chalk.dim(`\n active lang: ${getCliLang()} (session)`))
40
+ printCommandFooter({ version })
41
+ })
42
+
43
+ config
44
+ .command('lang [code]')
45
+ .description('Get or set CLI language (en | tr) — saved to ~/.xrystal/config.json')
46
+ .action((code) => {
47
+ const version = readCliPackageJson().version
48
+ printCommandHeader({ cliName, command: 'config lang', version })
49
+
50
+ if (!code) {
51
+ const saved = getCliConfigLang()
52
+ console.log(chalk.gray(` saved: ${saved ?? 'en (default)'}`))
53
+ console.log(chalk.gray(` active: ${getCliLang()}`))
54
+ console.log(chalk.dim(`\n set: ${cliName} config lang tr`))
55
+ printCommandFooter({ version })
56
+ return
57
+ }
58
+
59
+ if (code === 'reset' || code === 'clear') {
60
+ clearCliConfigLang()
61
+ setCliLang(CliLangEnum.EN)
62
+ console.log(chalk.green(' lang reset → en (default)'))
63
+ printCommandFooter({ version })
64
+ return
65
+ }
66
+
67
+ const supported = listSupportedCliLangs()
68
+ const normalized = setCliConfigLang(code)
69
+ setCliLang(normalized)
70
+ console.log(chalk.green(` lang → ${normalized}`))
71
+ console.log(chalk.gray(` saved: ${configFilePath()}`))
72
+ if (!supported.includes(normalized)) {
73
+ console.log(chalk.yellow(` note: supported: ${supported.join(', ')}`))
74
+ }
75
+ printCommandFooter({ version })
76
+ })
77
+ }
@@ -19,7 +19,10 @@ import { readCliPackageJson } from '../helpers/project-root.mjs'
19
19
  import { setupProjectGitHooks } from '../scripts/install-git-hooks.mjs'
20
20
  import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
21
21
  import { scaffoldWorkspace } from '../helpers/workspace-scaffold.mjs'
22
+ import { scaffoldFrontendProject } from '../helpers/scaffold-frontend.mjs'
22
23
  import { syncRegistryFromPath } from '../helpers/xrystal-registry.mjs'
24
+ import { syncOneProject, printSyncProjectResult } from '../helpers/sync-project.mjs'
25
+ import { GlobalTypeEnum, WorkspaceSlotEnum } from '../helpers/cli-enums.mjs'
23
26
 
24
27
  export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtimeName, packageManager, installCommand, devCommand }) {
25
28
  cli
@@ -90,7 +93,6 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
90
93
  return
91
94
  }
92
95
 
93
- const { WorkspaceSlotEnum } = await import('../helpers/cli-enums.mjs')
94
96
  const slot = options.mobile
95
97
  ? WorkspaceSlotEnum.MOBILE
96
98
  : options.web
@@ -139,25 +141,45 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
139
141
  if (entries.length === 0) fs.rmdirSync(targetPath)
140
142
  }
141
143
 
142
- const spinner = ora(`${runtimeName} — cloning template...`).start()
144
+ const isFrontendSlot = slot === WorkspaceSlotEnum.WEB || slot === WorkspaceSlotEnum.MOBILE
145
+ const spinner = ora(
146
+ isFrontendSlot
147
+ ? `${runtimeName} — scaffolding frontend...`
148
+ : `${runtimeName} — cloning template...`,
149
+ ).start()
143
150
 
144
151
  try {
145
- if (isCurrentDir) {
146
- execSync(`git clone --depth 1 ${Constants.templateRepoUri} .`, { cwd: targetPath, stdio: 'ignore' })
152
+ let tmpResult
153
+ if (isFrontendSlot) {
154
+ if (!isCurrentDir) {
155
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true })
156
+ }
157
+ const coreVersion = readCliPackageJson().version
158
+ const frontend = scaffoldFrontendProject(isCurrentDir ? targetPath : targetPath, {
159
+ projectName: name,
160
+ coreVersion,
161
+ installCommand,
162
+ cliName,
163
+ })
164
+ tmpResult = { tmpFilePath: frontend.tmpFilePath, created: true }
147
165
  } else {
148
- fs.mkdirSync(path.dirname(targetPath), { recursive: true })
149
- execSync(`git clone --depth 1 ${Constants.templateRepoUri} "${targetPath}"`, { stdio: 'ignore' })
150
- }
166
+ if (isCurrentDir) {
167
+ execSync(`git clone --depth 1 ${Constants.templateRepoUri} .`, { cwd: targetPath, stdio: 'ignore' })
168
+ } else {
169
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true })
170
+ execSync(`git clone --depth 1 ${Constants.templateRepoUri} "${targetPath}"`, { stdio: 'ignore' })
171
+ }
151
172
 
152
- const gitFolder = path.join(targetPath, '.git')
153
- if (fs.existsSync(gitFolder)) fs.rmSync(gitFolder, { recursive: true, force: true })
173
+ const gitFolder = path.join(targetPath, '.git')
174
+ if (fs.existsSync(gitFolder)) fs.rmSync(gitFolder, { recursive: true, force: true })
154
175
 
155
- try {
156
- execSync('git init', { cwd: targetPath, stdio: 'ignore' })
157
- } catch {
158
- }
176
+ try {
177
+ execSync('git init', { cwd: targetPath, stdio: 'ignore' })
178
+ } catch {
179
+ }
159
180
 
160
- const tmpResult = ensureTmpFile(targetPath)
181
+ tmpResult = ensureTmpFile(targetPath)
182
+ }
161
183
  const parsedTmp = yaml.parse(fs.readFileSync(tmpResult.tmpFilePath, 'utf8'))
162
184
  const resolvedTmp = resolveObjWithHandlebars(parsedTmp, parsedTmp)
163
185
  const mainPath = resolveMainFolderPath(resolvedTmp?.configs)
@@ -167,10 +189,12 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
167
189
  fs.mkdirSync(projectMainFolderPath, { recursive: true })
168
190
  }
169
191
 
170
- spinner.succeed(chalk.green('Template cloned and git initialized'))
171
- console.log(chalk.blue(`\n📦 Installing dependencies (${packageManager})...`))
192
+ spinner.succeed(chalk.green(isFrontendSlot ? 'Frontend scaffold ready' : 'Template cloned and git initialized'))
172
193
 
173
- execSync(installCommand, { cwd: targetPath, stdio: 'inherit' })
194
+ if (!isFrontendSlot) {
195
+ console.log(chalk.blue(`\n📦 Installing dependencies (${packageManager})...`))
196
+ execSync(installCommand, { cwd: targetPath, stdio: 'inherit' })
197
+ }
174
198
 
175
199
  try {
176
200
  const hookResult = setupProjectGitHooks(targetPath, { cliName })
@@ -206,14 +230,29 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
206
230
  console.log('')
207
231
  }
208
232
 
233
+ const coreVersion = readCliPackageJson().version
234
+ const syncResult = syncOneProject({
235
+ path: targetPath,
236
+ name,
237
+ type: isFrontendSlot ? GlobalTypeEnum.FRONTEND : GlobalTypeEnum.API_SERVICE,
238
+ slot,
239
+ tmp: tmpResult.tmpFilePath,
240
+ }, coreVersion, { tmpPath: tmpResult.tmpFilePath, tmpCreated: Boolean(tmpResult.created) })
241
+ if (!syncResult.failed) {
242
+ console.log(chalk.gray('\n sync (toolchain + core pin):'))
243
+ printSyncProjectResult(syncResult)
244
+ }
245
+
209
246
  if (inWorkspace) {
210
247
  try {
211
248
  syncRegistryFromPath(workspaceRoot)
212
249
  console.log(chalk.gray(' registered in ~/.xrystal'))
213
250
  } catch {
214
251
  }
215
- console.log(chalk.gray(` next: ${cliName} sync --all (from workspace root)`))
216
- printCommandFooter({ version: readCliPackageJson().version })
252
+ if (!isFrontendSlot) {
253
+ console.log(chalk.gray(` next: ${cliName} sync --all (from workspace root)`))
254
+ }
255
+ printCommandFooter({ version: coreVersion })
217
256
  }
218
257
 
219
258
  const relativePath = path.relative(process.cwd(), targetPath)
@@ -0,0 +1,23 @@
1
+ import chalk from 'chalk'
2
+
3
+ import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
4
+ import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
5
+ import { formatScopeGuide, formatSyncHelp } from '../helpers/cli-help.mjs'
6
+ import { getCliLang, t } from '../helpers/cli-i18n.mjs'
7
+ import { readCliPackageJson } from '../helpers/project-root.mjs'
8
+
9
+ export function registerGuideCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
10
+ cli
11
+ .command('guide')
12
+ .description('Scope guide — standalone vs workspace commands (en | tr via --lang / XRY_LANG)')
13
+ .option('--lang <code>', 'CLI language: en | tr')
14
+ .action(() => {
15
+ const version = readCliPackageJson().version
16
+ printCommandHeader({ cliName, command: 'guide', version })
17
+ console.log(chalk.gray(` lang: ${getCliLang()}`))
18
+ console.log(formatScopeGuide({ cliName }))
19
+ console.log(formatSyncHelp({ cliName }))
20
+ console.log(chalk.dim(` ${t('tips.guide')}`))
21
+ printCommandFooter({ version })
22
+ })
23
+ }
@@ -4,11 +4,11 @@ import path from 'node:path'
4
4
  import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
5
5
  import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
6
6
  import { readCliPackageJson } from '../helpers/project-root.mjs'
7
- import { ensureTmpFile } from '../helpers/tmp-layout.mjs'
8
7
  import { ensureTmpSchemaVersion } from '../helpers/tmp-schema-version.mjs'
9
8
  import { resolveSyncScope } from '../helpers/sync-scope.mjs'
10
9
  import { runWorkspaceSelfHeal } from '../helpers/workspace-heal.mjs'
11
10
  import { printSyncProjectResult, syncOneProject } from '../helpers/sync-project.mjs'
11
+ import { ensureSyncProjectTmp, previewSyncProjectTmp } from '../helpers/sync-tmp.mjs'
12
12
  import { formatSyncHelp } from '../helpers/cli-help.mjs'
13
13
 
14
14
  /** Sync tsconfig + @xrystal/core pin from tmp.yml layout. */
@@ -69,17 +69,22 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
69
69
  let failed = 0
70
70
  for (const entry of scope.entries) {
71
71
  if (options.dryRun) {
72
- const preview = syncOneProject(entry, coreVersion, { dryRun: true, tmpPath: entry.tmp ?? null })
72
+ const tmpPreview = previewSyncProjectTmp(entry)
73
+ const preview = syncOneProject(entry, coreVersion, {
74
+ dryRun: true,
75
+ tmpPath: tmpPreview.tmpPath,
76
+ tmpWouldCreate: tmpPreview.wouldCreate,
77
+ })
73
78
  printSyncProjectResult(preview)
74
79
  continue
75
80
  }
76
81
 
77
- let tmpPath = entry.tmp ?? null
78
- if (!tmpPath && scope.mode === 'standalone') {
79
- tmpPath = ensureTmpFile(entry.path).tmpFilePath
80
- }
81
-
82
- const result = syncOneProject(entry, coreVersion, { dryRun: false, tmpPath })
82
+ const ensured = ensureSyncProjectTmp(entry)
83
+ const result = syncOneProject(entry, coreVersion, {
84
+ dryRun: false,
85
+ tmpPath: ensured.tmpPath,
86
+ tmpCreated: ensured.created,
87
+ })
83
88
  printSyncProjectResult(result)
84
89
  if (result.failed) failed += 1
85
90
  }
@@ -1,11 +1,10 @@
1
1
  import { execSync } from 'node:child_process'
2
- import fs from 'node:fs'
3
- import path from 'node:path'
4
2
  import chalk from 'chalk'
5
3
 
6
4
  import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
7
5
  import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
8
6
  import { readCliPackageJson } from '../helpers/project-root.mjs'
7
+ import { resolveInfraHelperScript } from '../helpers/resolve-infra-helper.mjs'
9
8
  import {
10
9
  ensureServiceTelepresenceEnv,
11
10
  resolveTelepresenceServiceDir,
@@ -13,21 +12,6 @@ import {
13
12
  } from '../helpers/telepresence-layout.mjs'
14
13
  import { findWorkspaceRoot } from '../helpers/workspace-resolve.mjs'
15
14
 
16
- function resolveInfraHelper(name) {
17
- const envRoot = process.env.XRYSTAL_INFRA_DIR ?? process.env.XRYSTAL_INFRA_ROOT
18
- const candidates = [
19
- envRoot,
20
- path.resolve(process.cwd(), '../-infrastructure-'),
21
- path.resolve(process.cwd(), '../../-infrastructure-'),
22
- ].filter(Boolean)
23
-
24
- for (const root of candidates) {
25
- const script = path.join(root, 'scripts', 'helpers', name)
26
- if (fs.existsSync(script)) return script
27
- }
28
- return null
29
- }
30
-
31
15
  function runHelper(scriptPath, args, { cwd } = {}) {
32
16
  execSync(`bash "${scriptPath}" ${args.map((a) => JSON.stringify(a)).join(' ')}`, {
33
17
  cwd: cwd ?? process.cwd(),
@@ -36,6 +20,15 @@ function runHelper(scriptPath, args, { cwd } = {}) {
36
20
  })
37
21
  }
38
22
 
23
+ function requireInfraScript(name) {
24
+ const script = resolveInfraHelperScript(name)
25
+ if (!script) {
26
+ console.error(chalk.red(`\n✗ ${name} not found — set XRYSTAL_INFRA_DIR to -infrastructure- repo\n`))
27
+ process.exit(1)
28
+ }
29
+ return script
30
+ }
31
+
39
32
  export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
40
33
  const tp = cli
41
34
  .command('telepresence')
@@ -49,9 +42,10 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
49
42
  ${cliName} tp dev general
50
43
  ${cliName} tp dev gateway 3000
51
44
  ${cliName} telepresence quit
45
+ ${cliName} tp install
52
46
 
53
47
  ${chalk.gray('Deploy names:')} ${TELEPRESENCE_DEPLOYMENTS.join(', ')}
54
- ${chalk.gray('Set')} XRYSTAL_INFRA_DIR ${chalk.gray('to point at -infrastructure- repo (optional).')}
48
+ ${chalk.gray('Infra scripts:')} XRYSTAL_INFRA_DIR ${chalk.gray('or sibling')} ../-infrastructure-
55
49
  `,
56
50
  )
57
51
 
@@ -62,11 +56,7 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
62
56
  .action((options) => {
63
57
  const version = readCliPackageJson().version
64
58
  printCommandHeader({ cliName, command: 'telepresence connect', version })
65
- const script = resolveInfraHelper('telepresence-connect.sh')
66
- if (!script) {
67
- console.error(chalk.red('\n✗ telepresence-connect.sh not found — set XRYSTAL_INFRA_DIR\n'))
68
- process.exit(1)
69
- }
59
+ const script = requireInfraScript('telepresence-connect.sh')
70
60
  process.env.NS = options.ns
71
61
  runHelper(script, [`NS=${options.ns}`])
72
62
  printCommandFooter({ version })
@@ -78,11 +68,18 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
78
68
  .action(() => {
79
69
  const version = readCliPackageJson().version
80
70
  printCommandHeader({ cliName, command: 'telepresence quit', version })
81
- const script = resolveInfraHelper('telepresence-quit.sh')
82
- if (!script) {
83
- console.error(chalk.red('\n✗ telepresence-quit.sh not found — set XRYSTAL_INFRA_DIR\n'))
84
- process.exit(1)
85
- }
71
+ const script = requireInfraScript('telepresence-quit.sh')
72
+ runHelper(script, [])
73
+ printCommandFooter({ version })
74
+ })
75
+
76
+ tp
77
+ .command('install')
78
+ .description('Install Telepresence OSS client (~2.31.x, matches cluster chart)')
79
+ .action(() => {
80
+ const version = readCliPackageJson().version
81
+ printCommandHeader({ cliName, command: 'telepresence install', version })
82
+ const script = requireInfraScript('telepresence-client-install.sh')
86
83
  runHelper(script, [])
87
84
  printCommandFooter({ version })
88
85
  })
@@ -111,23 +108,21 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
111
108
  svcDir = process.cwd()
112
109
  }
113
110
 
114
- ensureServiceTelepresenceEnv(svcDir)
111
+ const env = ensureServiceTelepresenceEnv(svcDir)
112
+ process.env.TELEPRESENCE_ENV_FILE = env.envRel
113
+ process.env.NS = process.env.NS ?? 'dev'
114
+ if (workspaceRoot) process.env.XRYSTAL_WORKSPACE = workspaceRoot
115
+
115
116
  console.log(chalk.gray(` service: ${svcDir}`))
116
- console.log(chalk.gray(` env: x/environments/.env.telepresence\n`))
117
+ console.log(chalk.gray(` env: ${env.envRel}${env.created ? chalk.green(' (created)') : ''}\n`))
117
118
 
118
- const intercept = resolveInfraHelper('telepresence-intercept.sh')
119
- if (!intercept) {
120
- console.error(chalk.red('\n✗ telepresence-intercept.sh not found — set XRYSTAL_INFRA_DIR\n'))
121
- process.exit(1)
122
- }
119
+ const intercept = requireInfraScript('telepresence-intercept.sh')
123
120
 
124
121
  const portArg = port && /^\d+$/.test(String(port)) ? String(port) : '3000'
125
122
  const rest = command.args.slice(port && /^\d+$/.test(String(port)) ? 2 : 1)
126
123
  const localCmd = rest.length ? rest : ['bun', 'run', 'dev']
127
124
  const args = [deployName, portArg, '--', ...localCmd]
128
125
 
129
- process.env.NS = process.env.NS ?? 'dev'
130
- if (workspaceRoot) process.env.XRYSTAL_WORKSPACE = workspaceRoot
131
126
  runHelper(intercept, args, { cwd: svcDir })
132
127
  printCommandFooter({ version })
133
128
  })
@@ -14,7 +14,6 @@ import {
14
14
  } from '../helpers/tmp-layout.mjs'
15
15
  import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs'
16
16
  import { packageDefaults } from '../helpers/package-defaults.mjs'
17
- import { ensureTmpSchemaVersion, readTmpSchemaVersion } from '../helpers/tmp-schema-version.mjs'
18
17
  import { getCliContext } from '../helpers/cli-context-guard.mjs'
19
18
  import { ensureOuterWorkspaceTmp } from '../helpers/workspace-tmp.mjs'
20
19
  import { ProjectScopeKindEnum } from '../helpers/cli-enums.mjs'
@@ -26,17 +25,15 @@ function ensureTmpForContext(ctx) {
26
25
  tmpFilePath: outer.tmpFilePath,
27
26
  created: outer.created,
28
27
  layout: null,
29
- schema: outer.schema,
30
28
  }
31
29
  }
32
- const result = ensureTmpFile(ctx.projectRoot)
33
- return { ...result, schema: ensureTmpSchemaVersion(result.tmpFilePath) }
30
+ return ensureTmpFile(ctx.projectRoot)
34
31
  }
35
32
 
36
33
  export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
37
34
  cli
38
35
  .command('tmp')
39
- .description('Ensure tmp.yml for current scope (outer workspace or inner service)')
36
+ .description('Create missing tmp.yml and show loader profile for current scope')
40
37
  .option('--dry-run', 'Show target path without writing')
41
38
  .action((options) => {
42
39
  const ctx = getCliContext()
@@ -64,14 +61,6 @@ export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
64
61
  console.log(chalk.gray(` root: ${root}`))
65
62
  console.log(result.created ? chalk.green(` created ${rel}`) : chalk.gray(` ok ${rel}`))
66
63
 
67
- const schemaVersion = readTmpSchemaVersion(result.tmpFilePath)
68
- if (schemaVersion) {
69
- const schemaLabel = result.schema?.patched
70
- ? chalk.green(` end.version → ${schemaVersion} (schema)`)
71
- : chalk.gray(` end.version: ${schemaVersion} (schema)`)
72
- console.log(schemaLabel)
73
- }
74
-
75
64
  if (ctx.kind !== ProjectScopeKindEnum.WORKSPACE_ROOT) {
76
65
  try {
77
66
  const tmp = yaml.parse(fs.readFileSync(result.tmpFilePath, 'utf8'))
@@ -12,6 +12,11 @@ import {
12
12
  watchDaemonStatus,
13
13
  watchLogPath,
14
14
  } from '../helpers/xrystal-watch-spawn.mjs'
15
+ import {
16
+ installWatchService,
17
+ uninstallWatchService,
18
+ watchServiceStatus,
19
+ } from '../helpers/xrystal-watch-service.mjs'
15
20
 
16
21
  export function registerWatchCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
17
22
  const watch = cli
@@ -88,4 +93,58 @@ export function registerWatchCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
88
93
  .action(() => {
89
94
  ensureWatchDaemon({ quiet: false })
90
95
  })
96
+
97
+ watch
98
+ .command('install')
99
+ .description('Install OS service (macOS launchd / Linux systemd user) — survives reboot')
100
+ .action(() => {
101
+ const version = readCliPackageJson().version
102
+ printCommandHeader({ cliName, command: 'watch install', version })
103
+ try {
104
+ const result = installWatchService()
105
+ console.log(chalk.green(` ${result.platform} service installed`))
106
+ console.log(chalk.gray(` unit: ${result.unitPath}`))
107
+ console.log(chalk.gray(` log: ${watchLogPath()}`))
108
+ } catch (error) {
109
+ console.error(chalk.red(`\n✗ ${error.message}\n`))
110
+ process.exit(1)
111
+ }
112
+ printCommandFooter({ version })
113
+ })
114
+
115
+ watch
116
+ .command('uninstall')
117
+ .description('Remove OS service (launchd / systemd user)')
118
+ .action(() => {
119
+ const version = readCliPackageJson().version
120
+ printCommandHeader({ cliName, command: 'watch uninstall', version })
121
+ try {
122
+ const result = uninstallWatchService()
123
+ console.log(chalk.green(` ${result.platform} service removed`))
124
+ } catch (error) {
125
+ console.error(chalk.red(`\n✗ ${error.message}\n`))
126
+ process.exit(1)
127
+ }
128
+ printCommandFooter({ version })
129
+ })
130
+
131
+ watch
132
+ .command('service')
133
+ .description('Show launchd/systemd install state')
134
+ .action(() => {
135
+ const version = readCliPackageJson().version
136
+ printCommandHeader({ cliName, command: 'watch service', version })
137
+ const svc = watchServiceStatus()
138
+ if (!svc.platform) {
139
+ console.log(chalk.yellow(' OS service not supported on this platform'))
140
+ } else if (!svc.installed) {
141
+ console.log(chalk.yellow(` not installed (${svc.platform})`))
142
+ console.log(chalk.dim(`\n tip: ${cliName} watch install`))
143
+ } else {
144
+ console.log(chalk.gray(` platform: ${svc.platform}`))
145
+ console.log(chalk.gray(` unit: ${svc.unitPath}`))
146
+ console.log(svc.running ? chalk.green(' running') : chalk.yellow(' installed (not active)'))
147
+ }
148
+ printCommandFooter({ version })
149
+ })
91
150
  }
@@ -16,6 +16,7 @@ var defaults_default = {
16
16
  tmpExtension: ".yml",
17
17
  tmpSchemaVersion: 1,
18
18
  apiServiceTemplateRel: "x/templates/api-service/tmp.yml",
19
+ frontendTemplateRel: "x/templates/frontend/tmp.yml",
19
20
  templateRepoUri: "https://github.com/xdloper/api-gpt-svc",
20
21
  publicFolderName: "public",
21
22
  kafkaLogsTopic: "log",
@@ -24,8 +25,8 @@ var defaults_default = {
24
25
  brand: {
25
26
  primary: "xrystal",
26
27
  secondary: "core",
27
- tagline: "microservice runtime library",
28
- capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
28
+ tagline: "runtime framework for APIs, frontends & workspaces",
29
+ capabilities: "loaders · tmp.yml · workspace · dto · i18n · multi-protocol · scaffold"
29
30
  },
30
31
  runtimes: {
31
32
  bun: {
@@ -11,6 +11,7 @@ var defaults_default = {
11
11
  tmpExtension: ".yml",
12
12
  tmpSchemaVersion: 1,
13
13
  apiServiceTemplateRel: "x/templates/api-service/tmp.yml",
14
+ frontendTemplateRel: "x/templates/frontend/tmp.yml",
14
15
  templateRepoUri: "https://github.com/xdloper/api-gpt-svc",
15
16
  publicFolderName: "public",
16
17
  kafkaLogsTopic: "log",
@@ -19,8 +20,8 @@ var defaults_default = {
19
20
  brand: {
20
21
  primary: "xrystal",
21
22
  secondary: "core",
22
- tagline: "microservice runtime library",
23
- capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
23
+ tagline: "runtime framework for APIs, frontends & workspaces",
24
+ capabilities: "loaders · tmp.yml · workspace · dto · i18n · multi-protocol · scaffold"
24
25
  },
25
26
  runtimes: {
26
27
  bun: {
@@ -32,6 +32,7 @@ var defaults_default = {
32
32
  tmpExtension: ".yml",
33
33
  tmpSchemaVersion: 1,
34
34
  apiServiceTemplateRel: "x/templates/api-service/tmp.yml",
35
+ frontendTemplateRel: "x/templates/frontend/tmp.yml",
35
36
  templateRepoUri: "https://github.com/xdloper/api-gpt-svc",
36
37
  publicFolderName: "public",
37
38
  kafkaLogsTopic: "log",
@@ -40,8 +41,8 @@ var defaults_default = {
40
41
  brand: {
41
42
  primary: "xrystal",
42
43
  secondary: "core",
43
- tagline: "microservice runtime library",
44
- capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
44
+ tagline: "runtime framework for APIs, frontends & workspaces",
45
+ capabilities: "loaders · tmp.yml · workspace · dto · i18n · multi-protocol · scaffold"
45
46
  },
46
47
  runtimes: {
47
48
  bun: {
@@ -37,6 +37,7 @@ var defaults_default = {
37
37
  tmpExtension: ".yml",
38
38
  tmpSchemaVersion: 1,
39
39
  apiServiceTemplateRel: "x/templates/api-service/tmp.yml",
40
+ frontendTemplateRel: "x/templates/frontend/tmp.yml",
40
41
  templateRepoUri: "https://github.com/xdloper/api-gpt-svc",
41
42
  publicFolderName: "public",
42
43
  kafkaLogsTopic: "log",
@@ -45,8 +46,8 @@ var defaults_default = {
45
46
  brand: {
46
47
  primary: "xrystal",
47
48
  secondary: "core",
48
- tagline: "microservice runtime library",
49
- capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
49
+ tagline: "runtime framework for APIs, frontends & workspaces",
50
+ capabilities: "loaders · tmp.yml · workspace · dto · i18n · multi-protocol · scaffold"
50
51
  },
51
52
  runtimes: {
52
53
  bun: {
@@ -410,6 +411,9 @@ function findEntries(workspaceRoot) {
410
411
  // source/utils/helpers/xrystal-home/registry.ts
411
412
  var XRYSTAL_HOME_DIR = ".xrystal";
412
413
  function resolveXrystalHome() {
414
+ const override = process.env.XRYSTAL_HOME?.trim();
415
+ if (override)
416
+ return path5.resolve(override);
413
417
  return path5.join(os.homedir(), XRYSTAL_HOME_DIR);
414
418
  }
415
419
  function registryFilePath() {