@xrystal/core 3.55.67 → 3.55.69

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
@@ -268,9 +268,22 @@ bun run dev
268
268
  **Docker / Compose:** Image `CMD ["bun", "xry", "start"]` (dev: `xry dev`). Runtime skips `x/environments` when `/.dockerenv` or k8s is detected (optional override: `XRY_RUNTIME=container|docker|k8s`). Compose: `env_file:` on `x/docker/docker-compose*.yml` — not `COPY` env into the image.
269
269
  | `xry test` | Run `x/tests` | `x/tests` çalıştır |
270
270
  | `xry doctor` | CLI, runtime, package health | CLI, runtime, paket uyumu |
271
- | `xry tag` | **This repo only** — tag + npm publish (`@xrystal/core`) | **Sadece core** — servislerde çalışmaz / git tag yok |
272
- | `bun run release:patch` | SemVer **veya** CalVer — `version` şeklinden (default servis = CalVer) | `26.11.11-dev-pN` → CalVer; `2.0.32` → SemVer |
273
- | `bun run release:minor` | `version` SemVer ise (core + eski servis) | CalVer’de yok |
271
+ | `xry tag` | Core → npm publish · service → `v<CalVer>` git tag | Core npm · servis GHCR tag |
272
+ | `bun run release:patch` | Core SemVer patch · service CalVer (+pN) | Core patch · servis CalVer patch |
273
+ | `bun run release:minor` | **Core only** (`-xrystal-core`) | **Sadece core** |
274
+ | `bun run release:major` | **Core only** | **Sadece core** |
275
+
276
+ ### Release scripts (general — tek kaynak)
277
+
278
+ | Repo | `package.json` scripts | Bump |
279
+ |---|---|---|
280
+ | **`-xrystal-core`** | `release:patch`, `release:minor`, `release:major`, `tag` | SemVer |
281
+ | **`api-*-svc`** (deployed) | `release:patch`, `tag` | CalVer (branch → UTC + `pN`) |
282
+ | **`api-gpt-svc`** (template, no cluster deploy) | `release:patch`, `minor`, `major`, `tag` | SemVer **or** CalVer — `version` şekline göre CLI |
283
+
284
+ **EN:** Deployed services: patch + tag only. **`api-gpt-svc`** is the full script template (minor/major when `package.json` is SemVer; CalVer repos use patch only in practice).
285
+
286
+ **TR:** Canlı servis: `bun run release:patch` → commit → `bun run tag`. Yeni servis / örnek: `api-gpt-svc` `package.json` scripts bloğunu kopyala.
274
287
 
275
288
  ---
276
289
 
@@ -879,9 +892,9 @@ class ChatController extends Controller {
879
892
 
880
893
  ## Maintainer note / Geliştirici notu
881
894
 
882
- **EN:** Core: `bun run release:patch` (SemVer) → commit → `xry tag` (npm). **Services:** same `release:patch` (next CalVer `pN` from branch) → commit → `xry tag` (git tag → GHCR). No `release:dev` — env = `dev` / `staging` / `prod` branch.
895
+ **EN:** See **Release scripts (general)**. CalVer npm script örneği yalnız **`api-gpt-svc`** template’inde.
883
896
 
884
897
 
885
898
  **npm CI (`E401` / invalid token):** GitHub → repo **Settings → Environments → NPM** → secret **`TOKEN`** = [npm Granular Access Token](https://www.npmjs.com/settings/~youruser/tokens) with **Publish** on package `@xrystal/core` (or whole `@xrystal` scope). Classic automation tokens that bypass 2FA are being restricted — prefer **Granular** + **Publish**. After rotate: re-run failed **Publish Core Library NPM** workflow or push empty commit / re-tag. Stage flow: workflow runs `npm stage publish` → approve on npmjs.com (`npm stage list` / Approve with 2FA).
886
899
 
887
- **TR:** Core + servis: `bun run release:patch` → commit → `bun run tag` (`xry tag`). Serviste patch = CalVer `dev-pN` / `stag-pN` / prod günü.
900
+ **TR:** Yukarıdaki genel tablo. Serviste `release:minor|major` yok — yalnız CalVer patch.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.55.67",
4
+ "version": "3.55.69",
5
5
  "description": "Runtime framework and CLI for API services, frontends, and multi-repo workspaces",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -13,6 +13,7 @@ import {
13
13
  } from '../helpers/telepresence-runtime.mjs'
14
14
  import {
15
15
  ensureServiceTelepresenceEnv,
16
+ resolveTelepresenceDeployFromCwd,
16
17
  resolveTelepresenceServiceDir,
17
18
  TELEPRESENCE_DEPLOYMENTS,
18
19
  } from '../helpers/telepresence-layout.mjs'
@@ -32,6 +33,73 @@ function parsePort(value) {
32
33
  return value && /^\d+$/.test(String(value)) ? String(value) : '3000'
33
34
  }
34
35
 
36
+ function resolveInterceptTarget(deploy, port, command) {
37
+ let deployName = String(deploy ?? '').trim()
38
+ let portArg = '3000'
39
+
40
+ if (deployName && /^\d+$/.test(deployName)) {
41
+ portArg = deployName
42
+ deployName = ''
43
+ }
44
+ if (port !== undefined && port !== null && String(port).trim() !== '') {
45
+ if (/^\d+$/.test(String(port))) {
46
+ portArg = String(port)
47
+ } else if (!deployName) {
48
+ deployName = String(port).trim()
49
+ }
50
+ }
51
+
52
+ let serviceRootHint = null
53
+ if (!deployName) {
54
+ const resolved = resolveTelepresenceDeployFromCwd(process.cwd())
55
+ deployName = resolved.deploy
56
+ serviceRootHint = resolved.serviceRoot
57
+ }
58
+
59
+ if (!TELEPRESENCE_DEPLOYMENTS.includes(deployName)) {
60
+ console.error(chalk.red(`\n✗ Unknown deploy "${deployName}"\n`))
61
+ console.error(chalk.gray(` Use: ${TELEPRESENCE_DEPLOYMENTS.join(', ')}\n`))
62
+ process.exit(1)
63
+ }
64
+
65
+ return { deployName, portArg, serviceRootHint }
66
+ }
67
+
68
+ function resolveLocalCmd(command) {
69
+ const raw = command?.args ?? []
70
+ let offset = 0
71
+ const first = raw[0] != null ? String(raw[0]).trim() : ''
72
+ const second = raw[1] != null ? String(raw[1]).trim() : ''
73
+ if (first && (TELEPRESENCE_DEPLOYMENTS.includes(first) || /^\d+$/.test(first))) offset++
74
+ if (second && /^\d+$/.test(second)) offset++
75
+ return raw.length > offset ? raw.slice(offset) : ['xry', 'dev']
76
+ }
77
+
78
+ function runConnect(options, { cliName, commandLabel }) {
79
+ const version = readCliPackageJson().version
80
+ printCommandHeader({ cliName, command: commandLabel, version })
81
+ try {
82
+ const code = connectTelepresence({ ns: options.ns, cwd: process.cwd() })
83
+ if (code !== 0) process.exit(code)
84
+ } catch (err) {
85
+ console.error(chalk.red(`\n✗ ${err.message}\n`))
86
+ process.exit(1)
87
+ }
88
+ printCommandFooter({ version })
89
+ }
90
+
91
+ function runQuit({ cliName, commandLabel }) {
92
+ const version = readCliPackageJson().version
93
+ printCommandHeader({ cliName, command: commandLabel, version })
94
+ try {
95
+ quitTelepresence()
96
+ } catch (err) {
97
+ console.error(chalk.red(`\n✗ ${err.message}\n`))
98
+ process.exit(1)
99
+ }
100
+ printCommandFooter({ version })
101
+ }
102
+
35
103
  export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
36
104
  const tp = cli
37
105
  .command('telepresence')
@@ -41,48 +109,31 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
41
109
  'after',
42
110
  `
43
111
  ${chalk.gray('Examples:')}
44
- ${cliName} tp connect --ns dev
45
- ${cliName} tp intercept general --ns dev
46
- ${cliName} tp dev gateway 3000 --ns test
47
- ${cliName} telepresence quit
112
+ ${cliName} tp start --ns dev
113
+ ${cliName} tp intercept
114
+ ${cliName} tp intercept gateway 3000 --ns dev
115
+ ${cliName} tp stop
48
116
  ${cliName} tp install
49
117
 
50
- ${chalk.gray('intercept/dev')} = local intercept + run process (NOT the k8s namespace)
118
+ ${chalk.gray('start/stop')} = connect / quit session
119
+ ${chalk.gray('intercept')} = omit deploy in service repo → configs.service.name from x/tmp.yml
51
120
  ${chalk.gray('--ns')} = Kubernetes namespace (default: dev)
52
- ${chalk.gray('<deploy>')} = ${TELEPRESENCE_DEPLOYMENTS.join(', ')}
121
+ ${chalk.gray('<deploy>')} = optional — ${TELEPRESENCE_DEPLOYMENTS.join(', ')}
53
122
  ${chalk.gray('kubeconfig:')} workspace tmp.yml, KUBECONFIG, data/k3s/cluster.kubeconfig
54
123
  `,
55
124
  )
56
125
 
57
- tp.command('connect')
58
- .description('Connect local machine to cluster namespace')
59
- .option('--ns <namespace>', 'Kubernetes namespace', 'dev')
60
- .action((options) => {
61
- const version = readCliPackageJson().version
62
- printCommandHeader({ cliName, command: 'telepresence connect', version })
63
- try {
64
- const code = connectTelepresence({ ns: options.ns, cwd: process.cwd() })
65
- if (code !== 0) process.exit(code)
66
- } catch (err) {
67
- console.error(chalk.red(`\n✗ ${err.message}\n`))
68
- process.exit(1)
69
- }
70
- printCommandFooter({ version })
126
+ const connectOptions = (cmd) =>
127
+ cmd.option('--ns <namespace>', 'Kubernetes namespace', 'dev').action((options) => {
128
+ runConnect(options, { cliName, commandLabel: 'tp start' })
71
129
  })
72
130
 
73
- tp.command('quit')
74
- .description('Disconnect Telepresence')
75
- .action(() => {
76
- const version = readCliPackageJson().version
77
- printCommandHeader({ cliName, command: 'telepresence quit', version })
78
- try {
79
- quitTelepresence()
80
- } catch (err) {
81
- console.error(chalk.red(`\n✗ ${err.message}\n`))
82
- process.exit(1)
83
- }
84
- printCommandFooter({ version })
85
- })
131
+ connectOptions(tp.command('start').description('Connect Telepresence to cluster (alias: connect)').alias('connect'))
132
+
133
+ tp.command('stop')
134
+ .description('Disconnect Telepresence (alias: quit)')
135
+ .alias('quit')
136
+ .action(() => runQuit({ cliName, commandLabel: 'tp stop' }))
86
137
 
87
138
  tp.command('install')
88
139
  .description('Install Telepresence OSS client (~2.31.x, matches cluster chart)')
@@ -96,27 +147,24 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
96
147
 
97
148
  tp.command('intercept')
98
149
  .alias('dev')
99
- .description('Intercept cluster deployment and run local process (--ns = k8s namespace, not this subcommand name)')
100
- .argument('<deploy>', `Deployment name (${TELEPRESENCE_DEPLOYMENTS.join(', ')})`)
150
+ .description('Intercept deployment → local process (deploy optional in service repo)')
151
+ .argument('[deploy]', `Deployment name (default: configs.service.name in x/tmp.yml) — ${TELEPRESENCE_DEPLOYMENTS.join(', ')}`)
101
152
  .argument('[port]', 'Local listen port', '3000')
102
153
  .option('--ns <namespace>', 'Kubernetes namespace', 'dev')
103
154
  .allowUnknownOption()
104
155
  .allowExcessArguments()
105
156
  .action((deploy, port, options, command) => {
106
157
  const version = readCliPackageJson().version
107
- const deployName = String(deploy ?? '').trim()
108
158
  const ns = String(options.ns ?? 'dev').trim() || 'dev'
159
+ const { deployName, portArg, serviceRootHint } = resolveInterceptTarget(deploy, port, command)
160
+ const localCmd = resolveLocalCmd(command)
109
161
 
110
- if (!TELEPRESENCE_DEPLOYMENTS.includes(deployName)) {
111
- console.error(chalk.red(`\n✗ Unknown deploy "${deployName}"\n`))
112
- console.error(chalk.gray(` Use: ${TELEPRESENCE_DEPLOYMENTS.join(', ')}\n`))
113
- process.exit(1)
114
- }
115
-
116
- printCommandHeader({ cliName, command: `telepresence intercept ${deployName}`, version })
162
+ printCommandHeader({ cliName, command: `tp intercept ${deployName}`, version })
117
163
 
118
164
  const workspaceRoot = findWorkspaceRoot(process.cwd())
119
- let svcDir = resolveTelepresenceServiceDir(workspaceRoot ?? process.cwd(), deployName)
165
+ let svcDir =
166
+ serviceRootHint ??
167
+ resolveTelepresenceServiceDir(workspaceRoot ?? process.cwd(), deployName)
120
168
  if (!svcDir && workspaceRoot) {
121
169
  svcDir = resolveTelepresenceServiceDir(path.dirname(workspaceRoot), deployName)
122
170
  }
@@ -132,11 +180,6 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
132
180
  console.log(chalk.gray(` ns: ${ns}`))
133
181
  console.log(chalk.gray(` service: ${svcDir}`))
134
182
  console.log(chalk.gray(` env: ${env.envRel}${env.created ? chalk.green(' (created)') : ''}\n`))
135
-
136
- const portArg = parsePort(port)
137
- const rest = command.args.slice(/^\d+$/.test(String(port ?? '')) ? 2 : 1)
138
- const localCmd = rest.length ? rest : ['xry', 'dev']
139
-
140
183
  console.log(chalk.gray(` local port: ${portArg} (pod container :3000)`))
141
184
 
142
185
  try {
@@ -369,7 +369,7 @@ function assertNoLegacyTmpKeys(configs) {
369
369
  throw new Error(`${defaults_default.packageName}: configs.depends.loaders.build removed — use configs.global.build`);
370
370
  }
371
371
  if (isRecord2(configs?.cluster)) {
372
- throw new Error(`${defaults_default.packageName}: configs.cluster removed — deployment name is project.name (CLI --deployment overrides)`);
372
+ throw new Error(`${defaults_default.packageName}: configs.cluster removed — deployment name is configs.service.name (CLI --deployment overrides)`);
373
373
  }
374
374
  const global = isRecord2(configs?.global) ? configs.global : {};
375
375
  if ("fileWatchIntervalMs" in global && global.fileWatchIntervalMs !== undefined && global.fileWatchIntervalMs !== null) {
@@ -400,6 +400,11 @@ function resolveTmpLoaders(configs) {
400
400
  }
401
401
  function resolveTmpDeploymentName(tmp) {
402
402
  assertNoLegacyTmpKeys(isRecord2(tmp?.configs) ? tmp.configs : undefined);
403
+ const configs = isRecord2(tmp?.configs) ? tmp.configs : {};
404
+ const service = isRecord2(configs.service) ? configs.service : {};
405
+ const serviceName = typeof service.name === "string" ? service.name.trim() : undefined;
406
+ if (serviceName)
407
+ return serviceName;
403
408
  const project = isRecord2(tmp?.project) ? tmp.project : {};
404
409
  const projectName = typeof project.name === "string" ? project.name.trim() : undefined;
405
410
  return projectName || undefined;
@@ -51,8 +51,9 @@ function commandGroups() {
51
51
  { cmd: 'sync --all', desc: t('quick.syncAll') },
52
52
  { cmd: 'workspaces [list|sync]', desc: t('quick.workspaces') },
53
53
  { cmd: 'watch install', desc: 'OS service — survives reboot (launchd / systemd user)' },
54
- { cmd: 'telepresence intercept <deploy> --ns dev', aliases: 'tp dev', desc: 'Intercept cluster pod → local process (dev = alias, --ns = namespace)' },
55
- { cmd: 'telepresence connect --ns dev', aliases: 'tp connect', desc: 'Connect Telepresence to cluster namespace' },
54
+ { cmd: 'tp start --ns dev', aliases: 'tp connect', desc: 'Connect Telepresence to cluster namespace' },
55
+ { cmd: 'tp stop', aliases: 'tp quit', desc: 'Disconnect Telepresence' },
56
+ { cmd: 'tp intercept [deploy] --ns dev', aliases: 'tp dev', desc: 'Intercept — omit deploy in service repo (uses x/tmp.yml configs.service.name)' },
56
57
  { cmd: 'telepresence install', aliases: 'tp install', desc: 'Install Telepresence OSS client (~2.31.x)' },
57
58
  ],
58
59
  },
@@ -1,6 +1,10 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
3
 
4
+ import yaml from 'yaml'
5
+
6
+ import { resolveTmpDeploymentName } from './tmp-schema.mjs'
7
+
4
8
  const TELEPRESENCE_ENV_EXAMPLE = `# Telepresence intercept env — copied to x/environments/.env.telepresence per service
5
9
  # Used by: telepresence intercept --env-file .env.telepresence
6
10
  NS=dev
@@ -36,7 +40,7 @@ export function ensureServiceTelepresenceEnv(serviceRoot) {
36
40
  return { envPath, envRel: SERVICE_TELEPRESENCE_ENV_REL, created }
37
41
  }
38
42
 
39
- /** Deploy name (tmp project.name) → workspace api folder name */
43
+ /** Deploy name (configs.service.name) → workspace api folder name */
40
44
  export const TELEPRESENCE_DEPLOYMENTS = Object.freeze([
41
45
  'general',
42
46
  'gateway',
@@ -48,6 +52,48 @@ export const TELEPRESENCE_DEPLOYMENTS = Object.freeze([
48
52
  'gpt',
49
53
  ])
50
54
 
55
+ /** Walk up from cwd to a directory containing x/tmp.yml (service repo root). */
56
+ export function findServiceRootFromCwd(cwd = process.cwd()) {
57
+ let dir = path.resolve(cwd)
58
+ for (let depth = 0; depth < 16; depth++) {
59
+ if (fs.existsSync(path.join(dir, 'x', 'tmp.yml'))) return dir
60
+ const parent = path.dirname(dir)
61
+ if (parent === dir) break
62
+ dir = parent
63
+ }
64
+ return null
65
+ }
66
+
67
+ /** configs.service.name from inner x/tmp.yml — must match TELEPRESENCE_DEPLOYMENTS. */
68
+ export function readDeployNameFromServiceRoot(serviceRoot) {
69
+ const tmpPath = path.join(path.resolve(serviceRoot), 'x', 'tmp.yml')
70
+ if (!fs.existsSync(tmpPath)) return null
71
+ let doc
72
+ try {
73
+ doc = yaml.parse(fs.readFileSync(tmpPath, 'utf8'))
74
+ } catch {
75
+ return null
76
+ }
77
+ const name = resolveTmpDeploymentName(doc)
78
+ if (!name) return null
79
+ if (!TELEPRESENCE_DEPLOYMENTS.includes(name)) {
80
+ throw new Error(
81
+ `tmp configs.service.name "${name}" is not a known deploy (${TELEPRESENCE_DEPLOYMENTS.join(', ')}).`,
82
+ )
83
+ }
84
+ return name
85
+ }
86
+
87
+ export function resolveTelepresenceDeployFromCwd(cwd = process.cwd()) {
88
+ const root = findServiceRootFromCwd(cwd)
89
+ if (!root) {
90
+ throw new Error(
91
+ 'No x/tmp.yml in this tree — cd into a service repo or pass deploy: xry tp intercept <gateway|iam|…>',
92
+ )
93
+ }
94
+ return { deploy: readDeployNameFromServiceRoot(root), serviceRoot: root }
95
+ }
96
+
51
97
  export function resolveTelepresenceServiceDir(workspaceRoot, deployName) {
52
98
  const apiRoot = path.join(path.resolve(workspaceRoot), 'api')
53
99
  const slug = String(deployName ?? '').trim()
@@ -178,7 +178,7 @@ export function assertNoLegacyTmpKeys(configs) {
178
178
  throw new Error(`${defaults.packageName}: configs.depends.loaders.build removed — use configs.global.build`);
179
179
  }
180
180
  if (isRecord(configs?.cluster)) {
181
- throw new Error(`${defaults.packageName}: configs.cluster removed — deployment name is project.name (CLI --deployment overrides)`);
181
+ throw new Error(`${defaults.packageName}: configs.cluster removed — deployment name is configs.service.name (CLI --deployment overrides)`);
182
182
  }
183
183
  const global = isRecord(configs?.global) ? configs.global : {};
184
184
  if ('fileWatchIntervalMs' in global && global.fileWatchIntervalMs !== undefined && global.fileWatchIntervalMs !== null) {
@@ -210,6 +210,11 @@ export function resolveTmpLoaders(configs) {
210
210
  }
211
211
  export function resolveTmpDeploymentName(tmp) {
212
212
  assertNoLegacyTmpKeys(isRecord(tmp?.configs) ? tmp.configs : undefined);
213
+ const configs = isRecord(tmp?.configs) ? tmp.configs : {};
214
+ const service = isRecord(configs.service) ? configs.service : {};
215
+ const serviceName = typeof service.name === 'string' ? service.name.trim() : undefined;
216
+ if (serviceName)
217
+ return serviceName;
213
218
  const project = isRecord(tmp?.project) ? tmp.project : {};
214
219
  const projectName = typeof project.name === 'string' ? project.name.trim() : undefined;
215
220
  return projectName || undefined;