@xrystal/core 3.55.74 → 3.55.78
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 +10 -8
- package/package.json +4 -4
- package/x/bin/commands/release.mjs +50 -36
- package/x/bin/commands/telepresence.mjs +65 -14
- package/x/bin/helpers/cli-help.mjs +2 -2
- package/x/bin/helpers/telepresence-layout.mjs +17 -1
- package/x/bin/helpers/telepresence-runtime.mjs +33 -4
- package/x/bin/main-cli.js +1 -2
- package/x/bin/scripts/calver.mjs +12 -8
package/README.md
CHANGED
|
@@ -313,21 +313,23 @@ export XRY_SYNC_KUBECONFIG_FROM=/path/to/kubeconfig
|
|
|
313
313
|
| `xry test` | Run `x/tests` | `x/tests` çalıştır |
|
|
314
314
|
| `xry doctor` | CLI, runtime, package health | CLI, runtime, paket uyumu |
|
|
315
315
|
| `xry tag` | Core → npm publish · service → `v<CalVer>` git tag | Core npm · servis GHCR tag |
|
|
316
|
-
| `bun run
|
|
317
|
-
| `bun run
|
|
318
|
-
| `bun run
|
|
316
|
+
| `bun run version:patch` (or `xry version patch`) | Core SemVer patch · service CalVer (+pN) | Core patch · servis CalVer patch |
|
|
317
|
+
| `bun run version:minor` | **Core only** (`-xrystal-core`) | **Sadece core** |
|
|
318
|
+
| `bun run version:major` | **Core only** (`-xrystal-core`) | **Sadece core** |
|
|
319
319
|
|
|
320
320
|
### Release scripts (general — tek kaynak)
|
|
321
321
|
|
|
322
322
|
| Repo | `package.json` scripts | Bump |
|
|
323
323
|
|---|---|---|
|
|
324
|
-
| **`-xrystal-core`** | `
|
|
325
|
-
| **`api-*-svc`** (deployed) | `
|
|
326
|
-
| **`api-gpt-svc`** (template, no cluster deploy) | `
|
|
324
|
+
| **`-xrystal-core`** | `version:patch`, `version:minor`, `version:major`, `tag` | SemVer |
|
|
325
|
+
| **`api-*-svc`** (deployed) | `version:patch`, `tag` | CalVer (branch → UTC + `pN`) |
|
|
326
|
+
| **`api-gpt-svc`** (template, no cluster deploy) | `version:patch`, `minor`, `major`, `tag` | SemVer **or** CalVer — `version` şekline göre CLI |
|
|
327
327
|
|
|
328
328
|
**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).
|
|
329
329
|
|
|
330
|
-
**TR:** Canlı servis: `bun run
|
|
330
|
+
**TR:** Canlı servis: `xry version patch` (veya `bun run version:patch`) → commit → `xry tag`. Yeni servis: `api-gpt-svc` `package.json` scripts bloğunu kopyala.
|
|
331
|
+
|
|
332
|
+
**GHA (`gha-gitops-pin`):** `make gha-gitops-pin` (infra) → kopyala `.github/workflows/gha-gitops-pin.yml` (`BUILD_ENABLED` / `GITOPS_PIN_ENABLED` ile build-only veya build+pin). `artifact.yml` ve `clean.yml` ayrı bakım workflow'larıdır. **Image sürümü** = **git tag** (`xry version patch` → `xry tag`).
|
|
331
333
|
|
|
332
334
|
---
|
|
333
335
|
|
|
@@ -941,4 +943,4 @@ class ChatController extends Controller {
|
|
|
941
943
|
|
|
942
944
|
**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).
|
|
943
945
|
|
|
944
|
-
**TR:** Yukarıdaki genel tablo. Serviste `
|
|
946
|
+
**TR:** Yukarıdaki genel tablo. Serviste `version: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.
|
|
4
|
+
"version": "3.55.78",
|
|
5
5
|
"description": "Runtime framework and CLI for API services, frontends, and multi-repo workspaces",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"build:dev": "node x/bin/main-cli.js dev",
|
|
85
85
|
"start": "node x/bin/main-cli.js start",
|
|
86
86
|
"tag": "node x/bin/scripts/tag.mjs",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
87
|
+
"version:patch": "node x/bin/scripts/release-bump.mjs patch",
|
|
88
|
+
"version:minor": "node x/bin/scripts/release-bump.mjs minor",
|
|
89
|
+
"version:major": "node x/bin/scripts/release-bump.mjs major",
|
|
90
90
|
"version:check": "node x/bin/scripts/version-check.mjs",
|
|
91
91
|
"hooks:install": "node x/bin/scripts/install-git-hooks.mjs"
|
|
92
92
|
},
|
|
@@ -9,7 +9,13 @@ import {
|
|
|
9
9
|
runTagRelease,
|
|
10
10
|
} from '../scripts/version-check.mjs'
|
|
11
11
|
import { isCorePackageProject } from '../scripts/release-prepare.mjs'
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
runCalverTagPush,
|
|
14
|
+
assertCalverFormat,
|
|
15
|
+
detectCalverEnv,
|
|
16
|
+
bumpCalverPatch,
|
|
17
|
+
gitTagFromCalver,
|
|
18
|
+
} from '../scripts/calver.mjs'
|
|
13
19
|
import { bumpSemverLevel, resolveReleaseMode } from '../scripts/release-bump.mjs'
|
|
14
20
|
import fs from 'node:fs'
|
|
15
21
|
import path from 'node:path'
|
|
@@ -19,7 +25,7 @@ import { CLI_PRIMARY_NAME, PACKAGE_NAME } from '../helpers/cli-identity.mjs'
|
|
|
19
25
|
export function registerTagCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
20
26
|
cli
|
|
21
27
|
.command('tag')
|
|
22
|
-
.description(`Git tag + npm publish (${packageDefaults.packageName}
|
|
28
|
+
.description(`Git tag push (CalVer services) or git tag + npm publish (${packageDefaults.packageName} core only)`)
|
|
23
29
|
.option('--dry-run', 'Print commands without executing')
|
|
24
30
|
.option('--strict-clean', 'Require fully clean working tree (default: only package.json must be committed)')
|
|
25
31
|
.option('--skip-prepare', 'Skip lint, test, and build:prod (core only)')
|
|
@@ -61,51 +67,55 @@ function writePackageVersion(root, version) {
|
|
|
61
67
|
fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`)
|
|
62
68
|
}
|
|
63
69
|
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
function runVersionBump({ cliName, level, dryRun }) {
|
|
71
|
+
try {
|
|
72
|
+
const { root } = requireServiceRoot(process.cwd(), { cliName, command: `version ${level}` })
|
|
73
|
+
const mode = resolveReleaseMode(root)
|
|
74
|
+
const state = getVersionState('HEAD', root)
|
|
75
|
+
let next
|
|
76
|
+
if (mode === 'semver') {
|
|
77
|
+
next = bumpSemverLevel(state.disk.version, level)
|
|
78
|
+
} else {
|
|
79
|
+
if (level !== 'patch') {
|
|
80
|
+
throw new Error('CalVer — only patch. package.json SemVer (2.0.x) ise minor/major açılır.')
|
|
81
|
+
}
|
|
82
|
+
next = bumpCalverPatch(root).next
|
|
83
|
+
}
|
|
84
|
+
if (dryRun) {
|
|
85
|
+
console.log(chalk.bold(next))
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
writePackageVersion(root, next)
|
|
89
|
+
console.log(chalk.green(`package.json → ${next}`))
|
|
90
|
+
console.log(chalk.gray('Commit package.json, then: xry tag'))
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error?.name === 'CliContextError') exitOnCliContextError(error)
|
|
93
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
94
|
+
process.exit(1)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
66
97
|
|
|
98
|
+
function registerVersionBumpSubcommands(versionCmd, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
67
99
|
for (const level of ['patch', 'minor', 'major']) {
|
|
68
|
-
|
|
100
|
+
versionCmd
|
|
69
101
|
.command(level)
|
|
70
102
|
.description(
|
|
71
103
|
level === 'patch'
|
|
72
|
-
? '
|
|
104
|
+
? 'Bump package.json — core SemVer · service CalVer pN'
|
|
73
105
|
: 'SemVer minor/major (CalVer repos: patch only)',
|
|
74
106
|
)
|
|
75
107
|
.option('--dry-run', 'Print next version only')
|
|
76
|
-
.action((options) => {
|
|
77
|
-
try {
|
|
78
|
-
const { root } = requireServiceRoot(process.cwd(), { cliName, command: `release ${level}` })
|
|
79
|
-
const mode = resolveReleaseMode(root)
|
|
80
|
-
const state = getVersionState('HEAD', root)
|
|
81
|
-
let next
|
|
82
|
-
if (mode === 'semver') {
|
|
83
|
-
next = bumpSemverLevel(state.disk.version, level)
|
|
84
|
-
} else {
|
|
85
|
-
if (level !== 'patch') {
|
|
86
|
-
throw new Error('CalVer — only patch. package.json SemVer (2.0.x) ise minor/major açılır.')
|
|
87
|
-
}
|
|
88
|
-
next = bumpCalverPatch(root).next
|
|
89
|
-
}
|
|
90
|
-
if (options.dryRun) {
|
|
91
|
-
console.log(chalk.bold(next))
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
writePackageVersion(root, next)
|
|
95
|
-
console.log(chalk.green(`package.json → ${next}`))
|
|
96
|
-
console.log(chalk.gray('Commit package.json, then: xry tag'))
|
|
97
|
-
} catch (error) {
|
|
98
|
-
if (error?.name === 'CliContextError') exitOnCliContextError(error)
|
|
99
|
-
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
100
|
-
process.exit(1)
|
|
101
|
-
}
|
|
102
|
-
})
|
|
108
|
+
.action((options) => runVersionBump({ cliName, level, dryRun: options.dryRun }))
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
107
|
-
cli
|
|
108
|
-
|
|
113
|
+
const version = cli.command('version').description('Project version: show or bump package.json')
|
|
114
|
+
|
|
115
|
+
registerVersionBumpSubcommands(version, { cliName })
|
|
116
|
+
|
|
117
|
+
version
|
|
118
|
+
.command('show', { isDefault: true })
|
|
109
119
|
.description('Show CLI and project package versions')
|
|
110
120
|
.action(() => {
|
|
111
121
|
try {
|
|
@@ -127,7 +137,11 @@ export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
127
137
|
if (isCore) {
|
|
128
138
|
console.log(` git tag name: ${chalk.bold(`v${state.committed.version}`)}`)
|
|
129
139
|
} else {
|
|
130
|
-
|
|
140
|
+
const cv = detectCalverEnv(state.committed.version)
|
|
141
|
+
const tagLine = cv
|
|
142
|
+
? chalk.bold(gitTagFromCalver(state.committed.version))
|
|
143
|
+
: chalk.gray('set CalVer in package.json, then xry tag')
|
|
144
|
+
console.log(` git / image tag: ${tagLine}`)
|
|
131
145
|
}
|
|
132
146
|
console.log(` branch: ${state.branch}`)
|
|
133
147
|
console.log(` version match: ${state.versionMatch ? chalk.green('yes') : chalk.red('no')}`)
|
|
@@ -93,6 +93,42 @@ function runQuit({ cliName, commandLabel }) {
|
|
|
93
93
|
printCommandFooter({ version })
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
function resolveLeaveTarget(deploy) {
|
|
97
|
+
let deployName = String(deploy ?? '').trim()
|
|
98
|
+
let serviceRoot = process.cwd()
|
|
99
|
+
if (!deployName) {
|
|
100
|
+
const resolved = resolveTelepresenceDeployFromCwd(process.cwd())
|
|
101
|
+
deployName = resolved.deploy
|
|
102
|
+
serviceRoot = resolved.serviceRoot
|
|
103
|
+
} else if (TELEPRESENCE_DEPLOYMENTS.includes(deployName)) {
|
|
104
|
+
const workspaceRoot = findWorkspaceRoot(process.cwd())
|
|
105
|
+
const svcDir =
|
|
106
|
+
resolveTelepresenceServiceDir(workspaceRoot ?? process.cwd(), deployName) ??
|
|
107
|
+
(workspaceRoot
|
|
108
|
+
? resolveTelepresenceServiceDir(path.dirname(workspaceRoot), deployName)
|
|
109
|
+
: null)
|
|
110
|
+
if (svcDir) serviceRoot = svcDir
|
|
111
|
+
} else {
|
|
112
|
+
console.error(chalk.red(`\n✗ Unknown deploy "${deployName}"\n`))
|
|
113
|
+
console.error(chalk.gray(` Use: ${TELEPRESENCE_DEPLOYMENTS.join(', ')}\n`))
|
|
114
|
+
process.exit(1)
|
|
115
|
+
}
|
|
116
|
+
return { deployName, serviceRoot }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function runLeaveIntercept(deploy, ns, { cliName, commandLabel } = {}) {
|
|
120
|
+
const version = readCliPackageJson().version
|
|
121
|
+
const { deployName, serviceRoot } = resolveLeaveTarget(deploy)
|
|
122
|
+
printCommandHeader({ cliName, command: commandLabel ?? `tp leave ${deployName}`, version })
|
|
123
|
+
try {
|
|
124
|
+
leaveTelepresenceIntercept({ deploy: deployName, ns, cwd: serviceRoot })
|
|
125
|
+
} catch (err) {
|
|
126
|
+
console.error(chalk.red(`\n✗ ${err.message}\n`))
|
|
127
|
+
process.exit(1)
|
|
128
|
+
}
|
|
129
|
+
printCommandFooter({ version })
|
|
130
|
+
}
|
|
131
|
+
|
|
96
132
|
export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
97
133
|
const tp = cli
|
|
98
134
|
.command('telepresence')
|
|
@@ -105,7 +141,9 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
105
141
|
${cliName} tp start --ns dev
|
|
106
142
|
${cliName} tp intercept
|
|
107
143
|
${cliName} tp intercept gateway 3000 --ns dev
|
|
144
|
+
${cliName} tp intercept leave
|
|
108
145
|
${cliName} tp stop
|
|
146
|
+
${cliName} tp leave
|
|
109
147
|
${cliName} tp leave gateway --ns dev
|
|
110
148
|
${cliName} tp install
|
|
111
149
|
|
|
@@ -134,20 +172,8 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
134
172
|
.argument('[deploy]', `Deployment (default: configs.service.name in x/tmp.yml)`)
|
|
135
173
|
.option('--ns <namespace>', 'Kubernetes namespace', 'dev')
|
|
136
174
|
.action((deploy, options) => {
|
|
137
|
-
const version = readCliPackageJson().version
|
|
138
175
|
const ns = String(options.ns ?? 'dev').trim() || 'dev'
|
|
139
|
-
|
|
140
|
-
if (!deployName) {
|
|
141
|
-
deployName = resolveTelepresenceDeployFromCwd(process.cwd()).deploy
|
|
142
|
-
}
|
|
143
|
-
printCommandHeader({ cliName, command: `tp leave ${deployName}`, version })
|
|
144
|
-
try {
|
|
145
|
-
leaveTelepresenceIntercept({ deploy: deployName, ns, cwd: process.cwd() })
|
|
146
|
-
} catch (err) {
|
|
147
|
-
console.error(chalk.red(`\n✗ ${err.message}\n`))
|
|
148
|
-
process.exit(1)
|
|
149
|
-
}
|
|
150
|
-
printCommandFooter({ version })
|
|
176
|
+
runLeaveIntercept(deploy, ns, { cliName })
|
|
151
177
|
})
|
|
152
178
|
|
|
153
179
|
tp.command('rewrite-env')
|
|
@@ -182,9 +208,22 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
182
208
|
printCommandFooter({ version })
|
|
183
209
|
})
|
|
184
210
|
|
|
185
|
-
tp
|
|
211
|
+
const interceptCmd = tp
|
|
212
|
+
.command('intercept')
|
|
186
213
|
.alias('dev')
|
|
187
214
|
.description('Intercept deployment → local process (deploy optional in service repo)')
|
|
215
|
+
|
|
216
|
+
interceptCmd
|
|
217
|
+
.command('leave')
|
|
218
|
+
.description('End intercept for this service (default deploy from x/tmp.yml when omitted)')
|
|
219
|
+
.argument('[deploy]', `Deployment (default: configs.service.name in x/tmp.yml)`)
|
|
220
|
+
.option('--ns <namespace>', 'Kubernetes namespace', 'dev')
|
|
221
|
+
.action((deploy, options) => {
|
|
222
|
+
const ns = String(options.ns ?? 'dev').trim() || 'dev'
|
|
223
|
+
runLeaveIntercept(deploy, ns, { cliName, commandLabel: 'tp intercept leave' })
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
interceptCmd
|
|
188
227
|
.argument('[deploy]', `Deployment name (default: configs.service.name in x/tmp.yml) — ${TELEPRESENCE_DEPLOYMENTS.join(', ')}`)
|
|
189
228
|
.argument('[port]', 'Local listen port', '3000')
|
|
190
229
|
.option('--ns <namespace>', 'Kubernetes namespace', 'dev')
|
|
@@ -193,6 +232,18 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
193
232
|
.action((deploy, port, options, command) => {
|
|
194
233
|
const version = readCliPackageJson().version
|
|
195
234
|
const ns = String(options.ns ?? 'dev').trim() || 'dev'
|
|
235
|
+
|
|
236
|
+
const deployToken = String(deploy ?? '').trim().toLowerCase()
|
|
237
|
+
if (deployToken === 'leave') {
|
|
238
|
+
runLeaveIntercept('', ns, { cliName, commandLabel: 'tp intercept leave' })
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
const portToken = String(port ?? '').trim().toLowerCase()
|
|
242
|
+
if (portToken === 'leave' && deployToken && TELEPRESENCE_DEPLOYMENTS.includes(deployToken)) {
|
|
243
|
+
runLeaveIntercept(deployToken, ns, { cliName, commandLabel: `tp intercept ${deployToken} leave` })
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
|
|
196
247
|
const { deployName, portArg, serviceRootHint } = resolveInterceptTarget(deploy, port, command)
|
|
197
248
|
const localCmd = resolveLocalCmd(command)
|
|
198
249
|
|
|
@@ -82,8 +82,8 @@ function commandGroups() {
|
|
|
82
82
|
{
|
|
83
83
|
title: t('sections.release'),
|
|
84
84
|
items: [
|
|
85
|
-
{ cmd: '
|
|
86
|
-
{ cmd: '
|
|
85
|
+
{ cmd: 'version patch', desc: 'Bump package.json — core SemVer · service CalVer pN' },
|
|
86
|
+
{ cmd: 'version minor|major', desc: '@xrystal/core SemVer only' },
|
|
87
87
|
{ cmd: 'tag', desc: 'Core npm publish · service v<CalVer> git tag' },
|
|
88
88
|
],
|
|
89
89
|
},
|
|
@@ -30,6 +30,21 @@ export function writeWorkspaceTelepresenceFiles(workspaceRoot) {
|
|
|
30
30
|
export const SERVICE_TELEPRESENCE_ENV_REL = path.join('x', 'environments', '.env.telepresence')
|
|
31
31
|
export const SERVICE_LOCAL_ENV_REL = path.join('x', 'environments', '.env.local')
|
|
32
32
|
|
|
33
|
+
/** Retired laptop scaffolds — removed on `xry dev` / intercept (never loaded by CLI). */
|
|
34
|
+
export const LEGACY_LAPTOP_ENV_NAMES = Object.freeze(['.global.env', '.dev.env'])
|
|
35
|
+
|
|
36
|
+
export function pruneLegacyLaptopEnvFiles(serviceRoot) {
|
|
37
|
+
const envDir = path.join(path.resolve(serviceRoot), 'x', 'environments')
|
|
38
|
+
const removed = []
|
|
39
|
+
for (const name of LEGACY_LAPTOP_ENV_NAMES) {
|
|
40
|
+
const filePath = path.join(envDir, name)
|
|
41
|
+
if (!fs.existsSync(filePath)) continue
|
|
42
|
+
fs.unlinkSync(filePath)
|
|
43
|
+
removed.push(name)
|
|
44
|
+
}
|
|
45
|
+
return removed
|
|
46
|
+
}
|
|
47
|
+
|
|
33
48
|
const SERVICE_LOCAL_ENV_SCAFFOLD = `# Local-only overrides (gitignored) — BM hosts, feature flags, extra keys
|
|
34
49
|
# Loaded after .env.telepresence on xry dev / start (laptop only)
|
|
35
50
|
`
|
|
@@ -58,9 +73,10 @@ export function ensureServiceTelepresenceEnv(serviceRoot) {
|
|
|
58
73
|
|
|
59
74
|
/** Telepresence + `.env.local` only under x/environments (all gitignored). */
|
|
60
75
|
export function ensureServiceLaptopEnvs(serviceRoot) {
|
|
76
|
+
const removedLegacy = pruneLegacyLaptopEnvFiles(serviceRoot)
|
|
61
77
|
const telepresence = ensureServiceTelepresenceEnv(serviceRoot)
|
|
62
78
|
const local = ensureServiceLocalEnv(serviceRoot)
|
|
63
|
-
return { telepresence, local }
|
|
79
|
+
return { telepresence, local, removedLegacy }
|
|
64
80
|
}
|
|
65
81
|
|
|
66
82
|
/** Deploy name (configs.service.name) → workspace api folder name */
|
|
@@ -3,7 +3,11 @@ import fs from 'node:fs'
|
|
|
3
3
|
import os from 'node:os'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ensureServiceLocalEnv,
|
|
8
|
+
pruneLegacyLaptopEnvFiles,
|
|
9
|
+
SERVICE_TELEPRESENCE_ENV_REL,
|
|
10
|
+
} from './telepresence-layout.mjs'
|
|
7
11
|
import {
|
|
8
12
|
cleanupTelepresenceEnvFiles,
|
|
9
13
|
rewriteTelepresenceEnvFileInPlace,
|
|
@@ -238,24 +242,49 @@ export function leaveTelepresenceIntercept({ deploy, ns = 'dev', cwd = process.c
|
|
|
238
242
|
console.log(`Intercept ended (${deploy}, ns=${ns}). Cluster connect may still be active — use xry tp stop to quit.`)
|
|
239
243
|
}
|
|
240
244
|
|
|
241
|
-
|
|
245
|
+
/** Detach intercept + delete cluster env snapshot (.env.telepresence). `.env.local` is kept. */
|
|
246
|
+
export function finishInterceptEnvSession({ envDir, serviceRoot, deploy, ns }) {
|
|
242
247
|
if (deploy && ns) {
|
|
243
248
|
detachInterceptWorkload({ deploy, ns })
|
|
244
249
|
}
|
|
250
|
+
const removed = []
|
|
245
251
|
if (fs.existsSync(envDir)) {
|
|
252
|
+
const tpEnv = path.join(path.resolve(envDir), '.env.telepresence')
|
|
253
|
+
if (fs.existsSync(tpEnv)) removed.push(SERVICE_TELEPRESENCE_ENV_REL)
|
|
246
254
|
cleanupTelepresenceEnvFiles(envDir)
|
|
247
255
|
}
|
|
248
256
|
if (serviceRoot) {
|
|
249
|
-
|
|
257
|
+
for (const name of pruneLegacyLaptopEnvFiles(serviceRoot)) {
|
|
258
|
+
removed.push(path.join('x', 'environments', name))
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (removed.length) {
|
|
262
|
+
console.log(`Removed laptop env snapshot: ${removed.join(', ')}`)
|
|
250
263
|
}
|
|
251
264
|
}
|
|
252
265
|
|
|
253
266
|
function runInterceptSession({ envDir, serviceRoot, deploy, ns, run }) {
|
|
267
|
+
let sessionEnded = false
|
|
268
|
+
const endSession = () => {
|
|
269
|
+
if (sessionEnded) return
|
|
270
|
+
sessionEnded = true
|
|
271
|
+
finishInterceptEnvSession({ envDir, serviceRoot, deploy, ns })
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const onSignal = () => {
|
|
275
|
+
endSession()
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
process.on('SIGINT', onSignal)
|
|
279
|
+
process.on('SIGTERM', onSignal)
|
|
280
|
+
|
|
254
281
|
let status = 1
|
|
255
282
|
try {
|
|
256
283
|
status = run()
|
|
257
284
|
} finally {
|
|
258
|
-
|
|
285
|
+
process.removeListener('SIGINT', onSignal)
|
|
286
|
+
process.removeListener('SIGTERM', onSignal)
|
|
287
|
+
endSession()
|
|
259
288
|
}
|
|
260
289
|
return status
|
|
261
290
|
}
|
package/x/bin/main-cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { registerProjectCommands } from './commands/project.mjs'
|
|
|
10
10
|
import { registerTmpCommand } from './commands/tmp.mjs'
|
|
11
11
|
import { registerSyncCommand } from './commands/sync.mjs'
|
|
12
12
|
import { registerProjectsCommand, registerWorkspacesCommand } from './commands/projects.mjs'
|
|
13
|
-
import { registerTagCommand, registerVersionCommand
|
|
13
|
+
import { registerTagCommand, registerVersionCommand } from './commands/release.mjs'
|
|
14
14
|
import { registerTelepresenceCommand } from './commands/telepresence.mjs'
|
|
15
15
|
import { registerHooksCommand } from './commands/hooks.mjs'
|
|
16
16
|
import { registerWatchCommand } from './commands/watch.mjs'
|
|
@@ -83,7 +83,6 @@ cli
|
|
|
83
83
|
|
|
84
84
|
registerCreateCommand(cli, cliContext)
|
|
85
85
|
registerVersionCommand(cli, cliContext)
|
|
86
|
-
registerReleaseBumpCommand(cli, cliContext)
|
|
87
86
|
registerTagCommand(cli, cliContext)
|
|
88
87
|
registerDoctorCommand(cli, cliContext)
|
|
89
88
|
registerTmpCommand(cli, cliContext)
|
package/x/bin/scripts/calver.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { getVersionState, readDiskPackageJson, run } from './version-check.mjs'
|
|
|
4
4
|
const CALVER_RELEASE = /^(\d{2})\.(\d{2})\.(\d{2})$/
|
|
5
5
|
const CALVER_DEV = /^(\d{2})\.(\d{2})\.(\d{2})-dev-p(\d+)$/
|
|
6
6
|
const CALVER_STAG = /^(\d{2})\.(\d{2})\.(\d{2})-stag-p(\d+)$/
|
|
7
|
+
const CALVER_PROD_PATCH = /^(\d{2})\.(\d{2})\.(\d{2})-p(\d+)$/
|
|
7
8
|
|
|
8
9
|
export function utcCalverDate() {
|
|
9
10
|
const d = new Date()
|
|
@@ -34,14 +35,15 @@ export function detectCalverEnv(version) {
|
|
|
34
35
|
const v = String(version).trim()
|
|
35
36
|
if (CALVER_DEV.test(v)) return 'dev'
|
|
36
37
|
if (CALVER_STAG.test(v)) return 'stag'
|
|
38
|
+
if (CALVER_PROD_PATCH.test(v)) return 'prod'
|
|
37
39
|
if (CALVER_RELEASE.test(v)) return 'prod'
|
|
38
40
|
return null
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export function assertCalverFormat(version, env) {
|
|
42
44
|
const v = String(version).trim()
|
|
43
|
-
if (env === 'prod' && !CALVER_RELEASE.test(v)) {
|
|
44
|
-
throw new Error(`Invalid prod CalVer "${v}" — expected YY.MM.DD`)
|
|
45
|
+
if (env === 'prod' && !CALVER_RELEASE.test(v) && !CALVER_PROD_PATCH.test(v)) {
|
|
46
|
+
throw new Error(`Invalid prod CalVer "${v}" — expected YY.MM.DD or YY.MM.DD-pN (same-day patch, N ≥ 2)`)
|
|
45
47
|
}
|
|
46
48
|
if (env === 'dev' && !CALVER_DEV.test(v)) {
|
|
47
49
|
throw new Error(`Invalid dev CalVer "${v}" — expected YY.MM.DD-dev-pN`)
|
|
@@ -65,7 +67,7 @@ export function resolveCalverEnv(root = process.cwd()) {
|
|
|
65
67
|
if (fromPkg) return fromPkg
|
|
66
68
|
|
|
67
69
|
throw new Error(
|
|
68
|
-
`Cannot infer CalVer env — checkout dev | staging | prod, or set package.json to YY.MM.DD-dev-pN / -stag-pN / YY.MM.DD.`,
|
|
70
|
+
`Cannot infer CalVer env — checkout dev | staging | prod, or set package.json to YY.MM.DD-dev-pN / -stag-pN / YY.MM.DD / YY.MM.DD-pN.`,
|
|
69
71
|
)
|
|
70
72
|
}
|
|
71
73
|
|
|
@@ -80,12 +82,14 @@ export function bumpCalverPatch(root = process.cwd()) {
|
|
|
80
82
|
export function nextCalverVersion(env, root = process.cwd()) {
|
|
81
83
|
const date = utcCalverDate()
|
|
82
84
|
if (env === 'prod') {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (gitTagExists(tagName, root)) {
|
|
86
|
-
throw new Error(`Git tag ${tagName} already exists — prod release is one tag per UTC day`)
|
|
85
|
+
if (!gitTagExists(`v${date}`, root)) {
|
|
86
|
+
return date
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
let n = 2
|
|
89
|
+
while (gitTagExists(`v${date}-p${n}`, root)) {
|
|
90
|
+
n += 1
|
|
91
|
+
}
|
|
92
|
+
return `${date}-p${n}`
|
|
89
93
|
}
|
|
90
94
|
const mid = env === 'dev' ? '-dev-p' : '-stag-p'
|
|
91
95
|
let n = 1
|