@xrystal/core 3.55.74 → 3.55.75
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/package.json
CHANGED
|
@@ -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
|
}
|