@xrystal/core 3.55.3 → 3.55.5
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 +1 -1
- package/package.json +1 -1
- package/x/bin/commands/config.mjs +38 -0
- package/x/bin/commands/create.mjs +1 -1
- package/x/bin/commands/guide.mjs +1 -1
- package/x/bin/commands/telepresence.mjs +41 -24
- package/x/bin/helpers/cli-help.mjs +4 -4
- package/x/bin/helpers/cli-i18n.mjs +3 -3
- package/x/bin/helpers/resolve-infra-helper.mjs +61 -12
- package/x/bin/helpers/telepresence-layout.mjs +1 -1
- package/x/bin/helpers/xrystal-config.mjs +26 -0
package/README.md
CHANGED
|
@@ -258,7 +258,7 @@ bun run dev
|
|
|
258
258
|
| `xry create <name> --workspace` | Outer `./tmp.yml` + **api/general** + admin/web | Dış tmp + api/general |
|
|
259
259
|
| `xry tmp` | Inner `x/tmp.yml` or outer workspace tmp; **`end.version` = schema (1)** | tmp.yml · şema sürümü |
|
|
260
260
|
| `xry sync` | Inner tsconfig + pin `@xrystal/core` + registry (workspace mode) | tsconfig + core pin |
|
|
261
|
-
| `xry tp connect` / `xry tp
|
|
261
|
+
| `xry tp connect --ns dev` / `xry tp intercept <deploy> --ns dev` | Telepresence connect / local intercept (`dev` = alias, not namespace) | Telepresence bağlan / local intercept |
|
|
262
262
|
| `xry workspaces` | List `~/.xrystal` workspaces + linked projects | Kayıtlı workspace listesi |
|
|
263
263
|
| `xry dev` | Watch `source/index.ts` + dev env | `source/index.ts` watch + dev env |
|
|
264
264
|
| `xry build` | `tsc` full tree → dist (auto default) + alias/fix post-steps | `tsc` ile tüm `source/` → dist |
|
package/package.json
CHANGED
|
@@ -6,11 +6,14 @@ import { getCliLang, setCliLang, t } from '../helpers/cli-i18n.mjs'
|
|
|
6
6
|
import { CliLangEnum } from '../helpers/cli-lang.mjs'
|
|
7
7
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
8
8
|
import {
|
|
9
|
+
clearCliConfigInfraDir,
|
|
9
10
|
clearCliConfigLang,
|
|
10
11
|
configFilePath,
|
|
12
|
+
getCliConfigInfraDir,
|
|
11
13
|
getCliConfigLang,
|
|
12
14
|
listSupportedCliLangs,
|
|
13
15
|
readXrystalConfig,
|
|
16
|
+
setCliConfigInfraDir,
|
|
14
17
|
setCliConfigLang,
|
|
15
18
|
} from '../helpers/xrystal-config.mjs'
|
|
16
19
|
|
|
@@ -18,7 +21,9 @@ function printConfigDoc(doc) {
|
|
|
18
21
|
console.log(chalk.gray(` file: ${configFilePath()}`))
|
|
19
22
|
console.log(chalk.bold.white('\n cli'))
|
|
20
23
|
const lang = doc.cli?.lang ?? chalk.dim('(not set — default en)')
|
|
24
|
+
const infraDir = doc.cli?.infraDir ?? chalk.dim('(auto-detect from cwd)')
|
|
21
25
|
console.log(` lang: ${lang}`)
|
|
26
|
+
console.log(` infraDir: ${infraDir}`)
|
|
22
27
|
if (doc.updatedAt) {
|
|
23
28
|
console.log(chalk.gray(`\n updated: ${doc.updatedAt}`))
|
|
24
29
|
}
|
|
@@ -74,4 +79,37 @@ export function registerConfigCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
74
79
|
}
|
|
75
80
|
printCommandFooter({ version })
|
|
76
81
|
})
|
|
82
|
+
|
|
83
|
+
config
|
|
84
|
+
.command('infra [path]')
|
|
85
|
+
.description('Get or set -infrastructure- repo path — saved to ~/.xrystal/config.json')
|
|
86
|
+
.action((infraPath) => {
|
|
87
|
+
const version = readCliPackageJson().version
|
|
88
|
+
printCommandHeader({ cliName, command: 'config infra', version })
|
|
89
|
+
|
|
90
|
+
if (!infraPath) {
|
|
91
|
+
const saved = getCliConfigInfraDir()
|
|
92
|
+
console.log(chalk.gray(` saved: ${saved ?? '(auto-detect from cwd)'}`))
|
|
93
|
+
console.log(chalk.dim(`\n set: ${cliName} config infra /path/to/-infrastructure-`))
|
|
94
|
+
printCommandFooter({ version })
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (infraPath === 'reset' || infraPath === 'clear') {
|
|
99
|
+
clearCliConfigInfraDir()
|
|
100
|
+
console.log(chalk.green(' infraDir reset → auto-detect from cwd'))
|
|
101
|
+
printCommandFooter({ version })
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const resolved = setCliConfigInfraDir(infraPath)
|
|
107
|
+
console.log(chalk.green(` infraDir → ${resolved}`))
|
|
108
|
+
console.log(chalk.gray(` saved: ${configFilePath()}`))
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
111
|
+
process.exit(1)
|
|
112
|
+
}
|
|
113
|
+
printCommandFooter({ version })
|
|
114
|
+
})
|
|
77
115
|
}
|
|
@@ -84,7 +84,7 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
|
|
|
84
84
|
console.log(chalk.gray(' registered in ~/.xrystal'))
|
|
85
85
|
} catch {}
|
|
86
86
|
console.log(chalk.cyan(` ${cliName} sync --all`))
|
|
87
|
-
console.log(chalk.cyan(` ${cliName}
|
|
87
|
+
console.log(chalk.cyan(` ${cliName} tp intercept general --ns dev`))
|
|
88
88
|
printCommandFooter({ version })
|
|
89
89
|
} catch (error) {
|
|
90
90
|
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
package/x/bin/commands/guide.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
|
9
9
|
export function registerGuideCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
10
10
|
cli
|
|
11
11
|
.command('guide')
|
|
12
|
-
.description('Scope guide — standalone vs workspace commands (en | tr via
|
|
12
|
+
.description('Scope guide — standalone vs workspace commands (en | tr via xry config lang)')
|
|
13
13
|
.option('--lang <code>', 'CLI language: en | tr')
|
|
14
14
|
.action(() => {
|
|
15
15
|
const version = readCliPackageJson().version
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process'
|
|
2
|
+
import path from 'node:path'
|
|
2
3
|
import chalk from 'chalk'
|
|
3
4
|
|
|
4
5
|
import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
5
6
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
6
7
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
7
|
-
import { resolveInfraHelperScript } from '../helpers/resolve-infra-helper.mjs'
|
|
8
|
+
import { formatInfraResolveHint, resolveInfraHelperScript } from '../helpers/resolve-infra-helper.mjs'
|
|
8
9
|
import {
|
|
9
10
|
ensureServiceTelepresenceEnv,
|
|
10
11
|
resolveTelepresenceServiceDir,
|
|
@@ -20,43 +21,50 @@ function runHelper(scriptPath, args, { cwd } = {}) {
|
|
|
20
21
|
})
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
function requireInfraScript(name) {
|
|
24
|
-
const script = resolveInfraHelperScript(name)
|
|
24
|
+
function requireInfraScript(name, { cliName } = {}) {
|
|
25
|
+
const script = resolveInfraHelperScript(name, { cwd: process.cwd() })
|
|
25
26
|
if (!script) {
|
|
26
|
-
console.error(chalk.red(`\n✗ ${name} not found
|
|
27
|
+
console.error(chalk.red(`\n✗ ${name} not found\n`))
|
|
28
|
+
console.error(chalk.gray(` ${formatInfraResolveHint({ cliName, cwd: process.cwd() })}\n`))
|
|
27
29
|
process.exit(1)
|
|
28
30
|
}
|
|
29
31
|
return script
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
function parsePort(value) {
|
|
35
|
+
return value && /^\d+$/.test(String(value)) ? String(value) : '3000'
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
33
39
|
const tp = cli
|
|
34
40
|
.command('telepresence')
|
|
35
41
|
.alias('tp')
|
|
36
|
-
.description('Local Telepresence intercept against cluster (dev/test)')
|
|
42
|
+
.description('Local Telepresence intercept against cluster (dev/test namespaces)')
|
|
37
43
|
.addHelpText(
|
|
38
44
|
'after',
|
|
39
45
|
`
|
|
40
46
|
${chalk.gray('Examples:')}
|
|
41
|
-
${cliName}
|
|
42
|
-
${cliName} tp
|
|
43
|
-
${cliName} tp dev gateway 3000
|
|
47
|
+
${cliName} tp connect --ns dev
|
|
48
|
+
${cliName} tp intercept general --ns dev
|
|
49
|
+
${cliName} tp dev gateway 3000 --ns test
|
|
44
50
|
${cliName} telepresence quit
|
|
45
51
|
${cliName} tp install
|
|
46
52
|
|
|
47
|
-
${chalk.gray('
|
|
53
|
+
${chalk.gray('intercept/dev')} = local intercept + run process (NOT the k8s namespace)
|
|
54
|
+
${chalk.gray('--ns')} = Kubernetes namespace (default: dev)
|
|
55
|
+
${chalk.gray('<deploy>')} = ${TELEPRESENCE_DEPLOYMENTS.join(', ')}
|
|
48
56
|
${chalk.gray('Infra scripts:')} XRYSTAL_INFRA_DIR ${chalk.gray('or sibling')} ../-infrastructure-
|
|
49
57
|
`,
|
|
50
58
|
)
|
|
51
59
|
|
|
52
60
|
tp
|
|
53
61
|
.command('connect')
|
|
54
|
-
.description('Connect local machine to cluster namespace
|
|
62
|
+
.description('Connect local machine to cluster namespace')
|
|
55
63
|
.option('--ns <namespace>', 'Kubernetes namespace', 'dev')
|
|
56
64
|
.action((options) => {
|
|
57
65
|
const version = readCliPackageJson().version
|
|
58
66
|
printCommandHeader({ cliName, command: 'telepresence connect', version })
|
|
59
|
-
const script = requireInfraScript('telepresence-connect.sh')
|
|
67
|
+
const script = requireInfraScript('telepresence-connect.sh', { cliName })
|
|
60
68
|
process.env.NS = options.ns
|
|
61
69
|
runHelper(script, [`NS=${options.ns}`])
|
|
62
70
|
printCommandFooter({ version })
|
|
@@ -68,7 +76,7 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
68
76
|
.action(() => {
|
|
69
77
|
const version = readCliPackageJson().version
|
|
70
78
|
printCommandHeader({ cliName, command: 'telepresence quit', version })
|
|
71
|
-
const script = requireInfraScript('telepresence-quit.sh')
|
|
79
|
+
const script = requireInfraScript('telepresence-quit.sh', { cliName })
|
|
72
80
|
runHelper(script, [])
|
|
73
81
|
printCommandFooter({ version })
|
|
74
82
|
})
|
|
@@ -79,25 +87,32 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
79
87
|
.action(() => {
|
|
80
88
|
const version = readCliPackageJson().version
|
|
81
89
|
printCommandHeader({ cliName, command: 'telepresence install', version })
|
|
82
|
-
const script = requireInfraScript('telepresence-client-install.sh')
|
|
90
|
+
const script = requireInfraScript('telepresence-client-install.sh', { cliName })
|
|
83
91
|
runHelper(script, [])
|
|
84
92
|
printCommandFooter({ version })
|
|
85
93
|
})
|
|
86
94
|
|
|
87
|
-
tp
|
|
88
|
-
.command('
|
|
89
|
-
.
|
|
95
|
+
const intercept = tp
|
|
96
|
+
.command('intercept')
|
|
97
|
+
.alias('dev')
|
|
98
|
+
.description('Intercept cluster deployment and run local process (--ns = k8s namespace, not this subcommand name)')
|
|
99
|
+
.argument('<deploy>', `Deployment name (${TELEPRESENCE_DEPLOYMENTS.join(', ')})`)
|
|
100
|
+
.argument('[port]', 'Local listen port', '3000')
|
|
101
|
+
.option('--ns <namespace>', 'Kubernetes namespace', 'dev')
|
|
90
102
|
.allowUnknownOption()
|
|
91
|
-
.
|
|
103
|
+
.allowExcessArguments()
|
|
104
|
+
.action((deploy, port, options, command) => {
|
|
92
105
|
const version = readCliPackageJson().version
|
|
93
106
|
const deployName = String(deploy ?? '').trim()
|
|
107
|
+
const ns = String(options.ns ?? 'dev').trim() || 'dev'
|
|
108
|
+
|
|
94
109
|
if (!TELEPRESENCE_DEPLOYMENTS.includes(deployName)) {
|
|
95
110
|
console.error(chalk.red(`\n✗ Unknown deploy "${deployName}"\n`))
|
|
96
111
|
console.error(chalk.gray(` Use: ${TELEPRESENCE_DEPLOYMENTS.join(', ')}\n`))
|
|
97
112
|
process.exit(1)
|
|
98
113
|
}
|
|
99
114
|
|
|
100
|
-
printCommandHeader({ cliName, command: `telepresence
|
|
115
|
+
printCommandHeader({ cliName, command: `telepresence intercept ${deployName}`, version })
|
|
101
116
|
|
|
102
117
|
const workspaceRoot = findWorkspaceRoot(process.cwd())
|
|
103
118
|
let svcDir = resolveTelepresenceServiceDir(workspaceRoot ?? process.cwd(), deployName)
|
|
@@ -110,20 +125,22 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
110
125
|
|
|
111
126
|
const env = ensureServiceTelepresenceEnv(svcDir)
|
|
112
127
|
process.env.TELEPRESENCE_ENV_FILE = env.envRel
|
|
113
|
-
process.env.NS =
|
|
128
|
+
process.env.NS = ns
|
|
114
129
|
if (workspaceRoot) process.env.XRYSTAL_WORKSPACE = workspaceRoot
|
|
115
130
|
|
|
131
|
+
console.log(chalk.gray(` deploy: ${deployName}`))
|
|
132
|
+
console.log(chalk.gray(` ns: ${ns}`))
|
|
116
133
|
console.log(chalk.gray(` service: ${svcDir}`))
|
|
117
134
|
console.log(chalk.gray(` env: ${env.envRel}${env.created ? chalk.green(' (created)') : ''}\n`))
|
|
118
135
|
|
|
119
|
-
const
|
|
136
|
+
const interceptScript = requireInfraScript('telepresence-intercept.sh', { cliName })
|
|
120
137
|
|
|
121
|
-
const portArg =
|
|
122
|
-
const rest = command.args.slice(
|
|
138
|
+
const portArg = parsePort(port)
|
|
139
|
+
const rest = command.args.slice(/^\d+$/.test(String(port ?? '')) ? 2 : 1)
|
|
123
140
|
const localCmd = rest.length ? rest : ['bun', 'run', 'dev']
|
|
124
|
-
const args = [deployName, portArg, '--', ...localCmd]
|
|
141
|
+
const args = [`NS=${ns}`, deployName, portArg, '--', ...localCmd]
|
|
125
142
|
|
|
126
|
-
runHelper(
|
|
143
|
+
runHelper(interceptScript, args, { cwd: svcDir })
|
|
127
144
|
printCommandFooter({ version })
|
|
128
145
|
})
|
|
129
146
|
}
|
|
@@ -19,7 +19,7 @@ function quickCommands() {
|
|
|
19
19
|
{ cmd: 'create <name> --workspace', desc: t('quick.createWs') },
|
|
20
20
|
{ cmd: 'workspaces', desc: t('quick.workspaces') },
|
|
21
21
|
{ cmd: 'watch status', desc: t('quick.watch') },
|
|
22
|
-
{ cmd: 'tp connect / tp
|
|
22
|
+
{ cmd: 'tp connect / tp intercept <deploy> --ns dev', desc: t('quick.tp') },
|
|
23
23
|
{ cmd: 'dev / build / doctor', desc: t('quick.dev') },
|
|
24
24
|
]
|
|
25
25
|
}
|
|
@@ -51,8 +51,8 @@ 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
|
|
55
|
-
{ cmd: 'telepresence connect', aliases: 'tp connect', desc: 'Connect Telepresence to
|
|
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' },
|
|
56
56
|
{ cmd: 'telepresence install', aliases: 'tp install', desc: 'Install Telepresence OSS client (~2.31.x)' },
|
|
57
57
|
],
|
|
58
58
|
},
|
|
@@ -132,7 +132,7 @@ export function printQuickStartGuide({ cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
132
132
|
console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} guide`)} ${chalk.gray(`· ${t('tips.guide')}`)}`)
|
|
133
133
|
console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} -h`)} ${chalk.gray(`· ${t('tips.help')}`)}`)
|
|
134
134
|
console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} doctor`)} ${chalk.gray(`· ${t('tips.doctor')}`)}`)
|
|
135
|
-
console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} tp
|
|
135
|
+
console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} tp intercept general --ns dev`)} ${chalk.gray(`· ${t('tips.tp')}`)}`)
|
|
136
136
|
console.log(` ${chalk.dim('tip')} ${chalk.gray(t('langTip'))}`)
|
|
137
137
|
console.log('')
|
|
138
138
|
}
|
|
@@ -48,7 +48,7 @@ const MESSAGES = {
|
|
|
48
48
|
createWs: 'Outer tmp + api/general + web/mobile slots',
|
|
49
49
|
workspaces: 'Global registry ~/.xrystal (not repo tmp.yml)',
|
|
50
50
|
watch: 'Background tmp watcher for registered workspaces',
|
|
51
|
-
tp: 'Telepresence: tp connect · tp
|
|
51
|
+
tp: 'Telepresence: tp connect --ns dev · tp intercept general · tp install',
|
|
52
52
|
dev: 'Develop & diagnostics',
|
|
53
53
|
guide: 'Scope guide — standalone vs workspace commands',
|
|
54
54
|
},
|
|
@@ -110,7 +110,7 @@ const MESSAGES = {
|
|
|
110
110
|
createWs: 'Dış tmp + api/general + web/mobile slotları',
|
|
111
111
|
workspaces: 'Global registry ~/.xrystal (repo tmp değil)',
|
|
112
112
|
watch: 'Kayıtlı workspace tmp izleyici (~/.xrystal)',
|
|
113
|
-
tp: 'Telepresence: tp connect · tp
|
|
113
|
+
tp: 'Telepresence: tp connect --ns dev · tp intercept general · tp install',
|
|
114
114
|
dev: 'Geliştir & teşhis',
|
|
115
115
|
guide: 'Kapsam rehberi — standalone vs workspace',
|
|
116
116
|
},
|
|
@@ -188,7 +188,7 @@ export function formatScopeGuide({ cliName = 'xry' } = {}) {
|
|
|
188
188
|
['create <name>', t('yes'), t('yes'), t('yes')],
|
|
189
189
|
['workspaces', '—', t('yes'), t('yes')],
|
|
190
190
|
['watch install', '—', t('yes'), '—'],
|
|
191
|
-
['tp connect /
|
|
191
|
+
['tp connect / intercept', t('yes'), t('yes'), t('yes')],
|
|
192
192
|
]
|
|
193
193
|
|
|
194
194
|
const matrix = rows.map(([cmd, st, root, inner]) =>
|
|
@@ -2,21 +2,70 @@ import fs from 'node:fs'
|
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
|
|
5
|
+
import { getCliConfigInfraDir } from './xrystal-config.mjs'
|
|
6
|
+
|
|
5
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
const HELPERS_DIR = 'scripts/helpers'
|
|
9
|
+
|
|
10
|
+
function infraRootHasHelpers(root) {
|
|
11
|
+
if (!root) return false
|
|
12
|
+
return fs.existsSync(path.join(root, HELPERS_DIR))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Walk cwd → parents; sibling `-infrastructure-` next to each ancestor folder. */
|
|
16
|
+
export function walkUpForInfraRoot(start = process.cwd(), { maxDepth = 12 } = {}) {
|
|
17
|
+
let dir = path.resolve(start)
|
|
18
|
+
for (let depth = 0; depth < maxDepth; depth += 1) {
|
|
19
|
+
const sibling = path.join(path.dirname(dir), '-infrastructure-')
|
|
20
|
+
if (infraRootHasHelpers(sibling)) return sibling
|
|
21
|
+
|
|
22
|
+
const parent = path.dirname(dir)
|
|
23
|
+
if (parent === dir) break
|
|
24
|
+
dir = parent
|
|
25
|
+
}
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function listInfraRootCandidates(start = process.cwd()) {
|
|
30
|
+
const seen = new Set()
|
|
31
|
+
const out = []
|
|
6
32
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
33
|
+
const push = (value) => {
|
|
34
|
+
const resolved = value ? path.resolve(String(value)) : null
|
|
35
|
+
if (!resolved || seen.has(resolved)) return
|
|
36
|
+
seen.add(resolved)
|
|
37
|
+
out.push(resolved)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
push(process.env.XRYSTAL_INFRA_DIR)
|
|
41
|
+
push(process.env.XRYSTAL_INFRA_ROOT)
|
|
42
|
+
push(getCliConfigInfraDir())
|
|
43
|
+
push(walkUpForInfraRoot(start))
|
|
44
|
+
push(path.resolve(start, '../-infrastructure-'))
|
|
45
|
+
push(path.resolve(start, '../../-infrastructure-'))
|
|
46
|
+
push(path.resolve(__dirname, '../../../..', '-infrastructure-'))
|
|
47
|
+
|
|
48
|
+
return out
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Resolve a script under -infrastructure-/scripts/helpers. */
|
|
52
|
+
export function resolveInfraHelperScript(name, { cwd = process.cwd() } = {}) {
|
|
53
|
+
for (const root of listInfraRootCandidates(cwd)) {
|
|
54
|
+
const script = path.join(root, HELPERS_DIR, name)
|
|
19
55
|
if (fs.existsSync(script)) return script
|
|
20
56
|
}
|
|
21
57
|
return null
|
|
22
58
|
}
|
|
59
|
+
|
|
60
|
+
export function formatInfraResolveHint({ cliName = 'xry', cwd = process.cwd() } = {}) {
|
|
61
|
+
const walked = walkUpForInfraRoot(cwd)
|
|
62
|
+
const lines = [
|
|
63
|
+
'Set infra repo path (one of):',
|
|
64
|
+
` ${cliName} config infra /path/to/-infrastructure-`,
|
|
65
|
+
' export XRYSTAL_INFRA_DIR=/path/to/-infrastructure-',
|
|
66
|
+
]
|
|
67
|
+
if (walked) {
|
|
68
|
+
lines.push(` detected near cwd: ${walked}`)
|
|
69
|
+
}
|
|
70
|
+
return lines.join('\n')
|
|
71
|
+
}
|
|
@@ -8,7 +8,7 @@ TELEPRESENCE_INTERCEPT_HEADER=x-intercept-who
|
|
|
8
8
|
# TELEPRESENCE_DEV_ID=your-id
|
|
9
9
|
`
|
|
10
10
|
|
|
11
|
-
const SERVICE_TELEPRESENCE_ENV = `# Auto-scaffolded for local intercept (xry
|
|
11
|
+
const SERVICE_TELEPRESENCE_ENV = `# Auto-scaffolded for local intercept (xry tp intercept --ns dev)
|
|
12
12
|
NS=dev
|
|
13
13
|
NODE_ENV=dev
|
|
14
14
|
TELEPRESENCE_INTERCEPT_HEADER=x-intercept-who
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
2
3
|
|
|
3
4
|
import { CliLangEnum, normalizeCliLang } from './cli-lang.mjs'
|
|
4
5
|
import { ensureXrystalHome, resolveXrystalHome } from './xrystal-registry.mjs'
|
|
@@ -51,6 +52,31 @@ export function setCliConfigLang(lang) {
|
|
|
51
52
|
return normalized
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
export function getCliConfigInfraDir() {
|
|
56
|
+
const infraDir = readXrystalConfig().cli?.infraDir
|
|
57
|
+
if (!infraDir || typeof infraDir !== 'string') return null
|
|
58
|
+
const trimmed = infraDir.trim()
|
|
59
|
+
return trimmed || null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function setCliConfigInfraDir(infraDir) {
|
|
63
|
+
const resolved = path.resolve(String(infraDir ?? '').trim())
|
|
64
|
+
if (!fs.existsSync(resolved)) {
|
|
65
|
+
throw new Error(`Infra directory not found: ${resolved}`)
|
|
66
|
+
}
|
|
67
|
+
if (!fs.existsSync(path.join(resolved, 'scripts', 'helpers'))) {
|
|
68
|
+
throw new Error(`Not an -infrastructure- repo (missing scripts/helpers): ${resolved}`)
|
|
69
|
+
}
|
|
70
|
+
writeXrystalConfig({ cli: { infraDir: resolved } })
|
|
71
|
+
return resolved
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function clearCliConfigInfraDir() {
|
|
75
|
+
const current = readXrystalConfig()
|
|
76
|
+
const { infraDir: _removed, ...rest } = current.cli ?? {}
|
|
77
|
+
writeXrystalConfig({ cli: rest })
|
|
78
|
+
}
|
|
79
|
+
|
|
54
80
|
export function clearCliConfigLang() {
|
|
55
81
|
const current = readXrystalConfig()
|
|
56
82
|
const { lang: _removed, ...rest } = current.cli ?? {}
|