@xrystal/core 3.55.69 → 3.55.72
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 +46 -2
- package/package.json +1 -1
- package/x/bin/commands/config.mjs +102 -19
- package/x/bin/commands/telepresence.mjs +28 -14
- package/x/bin/helpers/.generated/tmp-schema.mjs +33 -33
- package/x/bin/helpers/build-config.mjs +7 -7
- package/x/bin/helpers/config-sync.mjs +145 -0
- package/x/bin/helpers/resolve-tls-bundle.mjs +109 -0
- package/x/bin/helpers/telepresence-install.mjs +16 -0
- package/x/bin/helpers/telepresence-layout.mjs +18 -2
- package/x/bin/helpers/telepresence-runtime.mjs +109 -66
- package/x/bin/helpers/telepresence-tls-path-rewrite.mjs +69 -0
- package/x/bin/helpers/workspace-scaffold.mjs +4 -1
- package/x/bin/helpers/xrystal-config.mjs +55 -13
- package/x/bin/scripts/telepresence-client-install.sh +27 -0
- package/x/templates/api-service/docker/Dockerfile +2 -2
- package/x/templates/api-service/docker/Dockerfile.dev +2 -2
- package/x/templates/api-service/docker/docker-compose.dev.yml +2 -2
- package/x/templates/api-service/docker/docker-compose.yml +1 -1
- package/x/bin/helpers/resolve-infra-helper.mjs +0 -90
package/README.md
CHANGED
|
@@ -252,16 +252,60 @@ bun run dev
|
|
|
252
252
|
| `xry create <name> --workspace` | Outer `./tmp.yml` + **api/general** + admin/web | Dış tmp + api/general |
|
|
253
253
|
| `xry tmp` | Inner `x/tmp.yml` or outer workspace tmp; **`end.version` = schema (1)** | tmp.yml · şema sürümü |
|
|
254
254
|
| `xry sync` | Inner tsconfig + pin `@xrystal/core` + registry (workspace mode) | tsconfig + core pin |
|
|
255
|
+
| `xry config sync` | Copy TLS bundle + kubeconfig into `~/.xrystal` (explicit `--tls-from` / `--kubeconfig-from`) | PEM + kubeconfig → `~/.xrystal` |
|
|
256
|
+
| `xry config tls` / `xry config kubeconfig` | Pin paths in `~/.xrystal/config.json` | Kalıcı path kaydı |
|
|
255
257
|
| `xry tp connect --ns dev` / `xry tp intercept <deploy> --ns dev` | Telepresence connect / local intercept (`dev` = alias, not namespace) | Telepresence bağlan / local intercept |
|
|
256
258
|
| `xry workspaces` | List `~/.xrystal` workspaces + linked projects | Kayıtlı workspace listesi |
|
|
257
259
|
| `xry dev` | Watch `source/index.ts` + dev env | `source/index.ts` watch + dev env |
|
|
258
260
|
| `xry build` | `tsc` full tree → dist (auto default) + alias/fix post-steps | `tsc` ile tüm `source/` → dist |
|
|
259
261
|
| `xry start` | Run `x/dist` + prod env | `x/dist` + prod env |
|
|
262
|
+
### Laptop cluster + TLS (`xry config sync`)
|
|
263
|
+
|
|
264
|
+
Copy **explicit** sources into `~/.xrystal` — core does not discover infra repos or scan the disk.
|
|
265
|
+
|
|
266
|
+
| Output | Purpose |
|
|
267
|
+
|--------|---------|
|
|
268
|
+
| `~/.xrystal/kubeconfig` | `xry tp connect` (also saved in `config.json`) |
|
|
269
|
+
| `~/.xrystal/certificates/` | Private CA + client PEMs (`ca.crt`, `mongodb.pem`, …) |
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# First time (paths you choose — ops bundle folder + kubeconfig file)
|
|
273
|
+
xry config sync \
|
|
274
|
+
--tls-from /path/to/pem-tree-or-flat \
|
|
275
|
+
--kubeconfig-from /path/to/cluster.kubeconfig
|
|
276
|
+
|
|
277
|
+
# Repeat (uses saved syncTlsFrom / syncKubeconfigFrom in ~/.xrystal/config.json)
|
|
278
|
+
xry config sync
|
|
279
|
+
|
|
280
|
+
# Or shell profile
|
|
281
|
+
export XRY_SYNC_TLS_FROM=/path/to/certs
|
|
282
|
+
export XRY_SYNC_KUBECONFIG_FROM=/path/to/kubeconfig
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**TLS source shape:** sync accepts tree or flat input but **stores flat only** under `~/.xrystal/certificates/` (`ca.crt`, `mongodb.pem`, … — same basenames as `/etc/tls/infra`).
|
|
286
|
+
|
|
287
|
+
**Intercept:** before `xry dev`, `xry tp rewrite-env` patches `.env.telepresence` in place (only when matching PEM exists in `~/.xrystal/certificates`). When intercept ends (`Ctrl+C`, crash, or exit) or `xry tp stop`, cluster env snapshot is removed and empty scaffold is restored.
|
|
288
|
+
|
|
289
|
+
**Unix optional:** `xry config sync --mirror-etc` copies flat PEMs to `/etc/tls/infra` (pod-style paths). Default is **off** — prefer auto path rewrite on dev (below).
|
|
290
|
+
|
|
291
|
+
**TR:** PEM + kubeconfig’i senin gösterdiğin dosyalardan `~/.xrystal` altına kopyalar. Otomatik infra araması yok. Tekrar için `config.json` içindeki kaynaklar veya env.
|
|
292
|
+
|
|
260
293
|
### Runtime env (k8s / Docker) — since 3.55.18
|
|
261
294
|
|
|
262
|
-
**EN:**
|
|
295
|
+
**EN:** `.env.telepresence` (cluster via intercept) is **rewritten in place** for TLS file paths (`/etc/tls/infra/<name>` → `~/.xrystal/certificates/<name>` when that file exists). No second override file. Optional `.env.local`. **Windows:** forward slashes in URIs (`C:/Users/.../.xrystal/certificates/ca.crt`). PEMs flat under `~/.xrystal/certificates` first (`config sync`). Not baked into images; k8s uses Secret `envFrom`.
|
|
296
|
+
|
|
297
|
+
**TR:** TLS path rewrite tek dosyada; `tp stop` snapshot’ı siler. PEM’ler düz `~/.xrystal/certificates`.
|
|
298
|
+
|
|
299
|
+
### `x/environments/.env.local` (laptop, gitignore)
|
|
300
|
+
|
|
301
|
+
| | |
|
|
302
|
+
|---|---|
|
|
303
|
+
| **Committed?** | **No** — stays on your machine in the service tree (`.gitignore`). |
|
|
304
|
+
| **When loaded?** | Every **`xry dev`** / laptop **`xry start`**: after `.env.telepresence` (later file wins on same key). |
|
|
305
|
+
| **Use for** | BM host overrides, new feature flags, local-only vars, anything not in cluster snapshot. |
|
|
306
|
+
| **Not for** | Image / k8s — cluster uses Secret; never `COPY` into Dockerfile. |
|
|
263
307
|
|
|
264
|
-
|
|
308
|
+
`xry tp intercept` scaffolds empty `.env.local` if missing.
|
|
265
309
|
|
|
266
310
|
**Infra preflight:** Before Kafka/Redis/Mongo connect, TCP checks from tmp.yml + env. **Default fail-fast** in cluster and plain local dev. **Telepresence intercept** (pod env on laptop, no service-account token): lenient by default + 2s probe — override with `STRICT_INFRA_PREFLIGHT=1`.
|
|
267
311
|
|
package/package.json
CHANGED
|
@@ -5,28 +5,46 @@ import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
|
5
5
|
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
|
+
import { runConfigSync } from '../helpers/config-sync.mjs'
|
|
8
9
|
import {
|
|
9
|
-
clearCliConfigInfraDir,
|
|
10
10
|
clearCliConfigLang,
|
|
11
11
|
configFilePath,
|
|
12
|
-
|
|
12
|
+
clearCliConfigKubeconfig,
|
|
13
|
+
clearCliConfigTlsDir,
|
|
14
|
+
getCliConfigKubeconfig,
|
|
13
15
|
getCliConfigLang,
|
|
16
|
+
getCliConfigSyncKubeconfigFrom,
|
|
17
|
+
getCliConfigSyncTlsFrom,
|
|
18
|
+
getCliConfigTlsDir,
|
|
14
19
|
listSupportedCliLangs,
|
|
15
20
|
readXrystalConfig,
|
|
16
|
-
|
|
21
|
+
setCliConfigKubeconfig,
|
|
17
22
|
setCliConfigLang,
|
|
23
|
+
setCliConfigTlsDir,
|
|
18
24
|
} from '../helpers/xrystal-config.mjs'
|
|
19
25
|
|
|
20
26
|
function printConfigDoc(doc) {
|
|
21
27
|
console.log(chalk.gray(` file: ${configFilePath()}`))
|
|
22
28
|
console.log(chalk.bold.white('\n cli'))
|
|
23
29
|
const lang = doc.cli?.lang ?? chalk.dim('(not set — default en)')
|
|
24
|
-
const
|
|
30
|
+
const tlsDir = doc.cli?.tlsDir ?? chalk.dim('(default ~/.xrystal/certificates)')
|
|
31
|
+
const kubeconfig = doc.cli?.kubeconfig ?? chalk.dim('(~/.xrystal/kubeconfig after sync)')
|
|
32
|
+
const syncTlsFrom = doc.cli?.syncTlsFrom ?? chalk.dim('(set via config sync)')
|
|
33
|
+
const syncKubeFrom = doc.cli?.syncKubeconfigFrom ?? chalk.dim('(set via config sync)')
|
|
25
34
|
console.log(` lang: ${lang}`)
|
|
26
|
-
console.log(`
|
|
35
|
+
console.log(` tlsDir: ${tlsDir}`)
|
|
36
|
+
console.log(` kubeconfig: ${kubeconfig}`)
|
|
37
|
+
console.log(` syncTlsFrom: ${syncTlsFrom}`)
|
|
38
|
+
console.log(` syncKubeconfigFrom: ${syncKubeFrom}`)
|
|
27
39
|
if (doc.updatedAt) {
|
|
28
40
|
console.log(chalk.gray(`\n updated: ${doc.updatedAt}`))
|
|
29
41
|
}
|
|
42
|
+
console.log(
|
|
43
|
+
chalk.dim(
|
|
44
|
+
'\n session env: XRY_SYNC_TLS_FROM, XRY_SYNC_KUBECONFIG_FROM, XRY_TLS_SOURCE, KUBECONFIG, …',
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
console.log(chalk.dim(`\n materialize: ${CLI_PRIMARY_NAME} config sync --tls-from … --kubeconfig-from …`))
|
|
30
48
|
}
|
|
31
49
|
|
|
32
50
|
export function registerConfigCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
@@ -81,35 +99,100 @@ export function registerConfigCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
81
99
|
})
|
|
82
100
|
|
|
83
101
|
config
|
|
84
|
-
.command('
|
|
85
|
-
.description('
|
|
86
|
-
.action((
|
|
102
|
+
.command('tls [path]')
|
|
103
|
+
.description('Bare-metal PEM tree or flat dir for tp intercept — ~/.xrystal/config.json')
|
|
104
|
+
.action((tlsPath) => {
|
|
87
105
|
const version = readCliPackageJson().version
|
|
88
|
-
printCommandHeader({ cliName, command: 'config
|
|
106
|
+
printCommandHeader({ cliName, command: 'config tls', version })
|
|
89
107
|
|
|
90
|
-
if (!
|
|
91
|
-
const saved =
|
|
92
|
-
console.log(chalk.gray(` saved: ${saved ?? '(
|
|
93
|
-
console.log(chalk.dim(`\n set: ${cliName} config
|
|
108
|
+
if (!tlsPath) {
|
|
109
|
+
const saved = getCliConfigTlsDir()
|
|
110
|
+
console.log(chalk.gray(` saved: ${saved ?? '(default ~/.xrystal/certificates)'}`))
|
|
111
|
+
console.log(chalk.dim(`\n set: ${cliName} config tls /path/to/certs`))
|
|
94
112
|
printCommandFooter({ version })
|
|
95
113
|
return
|
|
96
114
|
}
|
|
97
115
|
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
console.log(chalk.green('
|
|
116
|
+
if (tlsPath === 'reset' || tlsPath === 'clear') {
|
|
117
|
+
clearCliConfigTlsDir()
|
|
118
|
+
console.log(chalk.green(' tlsDir cleared → default ~/.xrystal/certificates'))
|
|
101
119
|
printCommandFooter({ version })
|
|
102
120
|
return
|
|
103
121
|
}
|
|
104
122
|
|
|
105
123
|
try {
|
|
106
|
-
const resolved =
|
|
107
|
-
console.log(chalk.green(`
|
|
108
|
-
console.log(chalk.gray(` saved: ${configFilePath()}`))
|
|
124
|
+
const resolved = setCliConfigTlsDir(tlsPath)
|
|
125
|
+
console.log(chalk.green(` tlsDir → ${resolved}`))
|
|
109
126
|
} catch (error) {
|
|
110
127
|
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
111
128
|
process.exit(1)
|
|
112
129
|
}
|
|
113
130
|
printCommandFooter({ version })
|
|
114
131
|
})
|
|
132
|
+
|
|
133
|
+
config
|
|
134
|
+
.command('kubeconfig [path]')
|
|
135
|
+
.description('Cluster kubeconfig for tp connect — ~/.xrystal/config.json')
|
|
136
|
+
.action((kubePath) => {
|
|
137
|
+
const version = readCliPackageJson().version
|
|
138
|
+
printCommandHeader({ cliName, command: 'config kubeconfig', version })
|
|
139
|
+
|
|
140
|
+
if (!kubePath) {
|
|
141
|
+
const saved = getCliConfigKubeconfig()
|
|
142
|
+
console.log(chalk.gray(` saved: ${saved ?? '(not set)'}`))
|
|
143
|
+
console.log(chalk.dim(`\n set: ${cliName} config kubeconfig /path/to/kubeconfig`))
|
|
144
|
+
printCommandFooter({ version })
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (kubePath === 'reset' || kubePath === 'clear') {
|
|
149
|
+
clearCliConfigKubeconfig()
|
|
150
|
+
console.log(chalk.green(' kubeconfig cleared'))
|
|
151
|
+
printCommandFooter({ version })
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
const resolved = setCliConfigKubeconfig(kubePath)
|
|
157
|
+
console.log(chalk.green(` kubeconfig → ${resolved}`))
|
|
158
|
+
} catch (error) {
|
|
159
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
160
|
+
process.exit(1)
|
|
161
|
+
}
|
|
162
|
+
printCommandFooter({ version })
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
config
|
|
166
|
+
.command('sync')
|
|
167
|
+
.description('Copy TLS + kubeconfig into ~/.xrystal (explicit paths only — no auto-discovery)')
|
|
168
|
+
.option('--tls-from <path>', 'PEM tree or flat dir (or XRY_SYNC_TLS_FROM / saved syncTlsFrom)')
|
|
169
|
+
.option('--kubeconfig-from <path>', 'Kubeconfig file (or XRY_SYNC_KUBECONFIG_FROM / saved)')
|
|
170
|
+
.option('--mirror-etc', 'Unix opt-in: flat PEMs → /etc/tls/infra (cluster env paths unchanged)')
|
|
171
|
+
.action((options) => {
|
|
172
|
+
const version = readCliPackageJson().version
|
|
173
|
+
printCommandHeader({ cliName, command: 'config sync', version })
|
|
174
|
+
try {
|
|
175
|
+
runConfigSync({
|
|
176
|
+
tlsFrom: options.tlsFrom,
|
|
177
|
+
kubeconfigFrom: options.kubeconfigFrom,
|
|
178
|
+
mirrorEtc: Boolean(options.mirrorEtc),
|
|
179
|
+
})
|
|
180
|
+
} catch (error) {
|
|
181
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
182
|
+
console.error(
|
|
183
|
+
chalk.dim(
|
|
184
|
+
` example: ${cliName} config sync --tls-from ~/Downloads/certs --kubeconfig-from ~/Downloads/cluster.kubeconfig`,
|
|
185
|
+
),
|
|
186
|
+
)
|
|
187
|
+
if (!options.tlsFrom && !options.kubeconfigFrom) {
|
|
188
|
+
const savedTls = getCliConfigSyncTlsFrom()
|
|
189
|
+
const savedKube = getCliConfigSyncKubeconfigFrom()
|
|
190
|
+
if (savedTls || savedKube) {
|
|
191
|
+
console.error(chalk.dim(` saved sources: tls=${savedTls ?? '-'} kube=${savedKube ?? '-'}`))
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
process.exit(1)
|
|
195
|
+
}
|
|
196
|
+
printCommandFooter({ version })
|
|
197
|
+
})
|
|
115
198
|
}
|
|
@@ -5,10 +5,11 @@ import chalk from 'chalk'
|
|
|
5
5
|
import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
6
6
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
7
7
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
8
|
-
import {
|
|
8
|
+
import { resolveTelepresenceInstallScript } from '../helpers/telepresence-install.mjs'
|
|
9
9
|
import {
|
|
10
10
|
connectTelepresence,
|
|
11
11
|
quitTelepresence,
|
|
12
|
+
runTelepresenceEnvRewrite,
|
|
12
13
|
runTelepresenceIntercept,
|
|
13
14
|
} from '../helpers/telepresence-runtime.mjs'
|
|
14
15
|
import {
|
|
@@ -19,16 +20,6 @@ import {
|
|
|
19
20
|
} from '../helpers/telepresence-layout.mjs'
|
|
20
21
|
import { findWorkspaceRoot } from '../helpers/workspace-resolve.mjs'
|
|
21
22
|
|
|
22
|
-
function requireInfraScript(name, { cliName } = {}) {
|
|
23
|
-
const script = resolveInfraHelperScript(name, { cwd: process.cwd() })
|
|
24
|
-
if (!script) {
|
|
25
|
-
console.error(chalk.red(`\n✗ ${name} not found\n`))
|
|
26
|
-
console.error(chalk.gray(` ${formatInfraResolveHint({ cliName, cwd: process.cwd() })}\n`))
|
|
27
|
-
process.exit(1)
|
|
28
|
-
}
|
|
29
|
-
return script
|
|
30
|
-
}
|
|
31
|
-
|
|
32
23
|
function parsePort(value) {
|
|
33
24
|
return value && /^\d+$/.test(String(value)) ? String(value) : '3000'
|
|
34
25
|
}
|
|
@@ -92,7 +83,7 @@ function runQuit({ cliName, commandLabel }) {
|
|
|
92
83
|
const version = readCliPackageJson().version
|
|
93
84
|
printCommandHeader({ cliName, command: commandLabel, version })
|
|
94
85
|
try {
|
|
95
|
-
quitTelepresence()
|
|
86
|
+
quitTelepresence({ cwd: process.cwd() })
|
|
96
87
|
} catch (err) {
|
|
97
88
|
console.error(chalk.red(`\n✗ ${err.message}\n`))
|
|
98
89
|
process.exit(1)
|
|
@@ -119,7 +110,7 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
119
110
|
${chalk.gray('intercept')} = omit deploy in service repo → configs.service.name from x/tmp.yml
|
|
120
111
|
${chalk.gray('--ns')} = Kubernetes namespace (default: dev)
|
|
121
112
|
${chalk.gray('<deploy>')} = optional — ${TELEPRESENCE_DEPLOYMENTS.join(', ')}
|
|
122
|
-
${chalk.gray('kubeconfig:')} workspace tmp.yml,
|
|
113
|
+
${chalk.gray('kubeconfig:')} KUBECONFIG, workspace tmp.yml, xry config kubeconfig
|
|
123
114
|
`,
|
|
124
115
|
)
|
|
125
116
|
|
|
@@ -135,12 +126,34 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
135
126
|
.alias('quit')
|
|
136
127
|
.action(() => runQuit({ cliName, commandLabel: 'tp stop' }))
|
|
137
128
|
|
|
129
|
+
tp.command('rewrite-env')
|
|
130
|
+
.description('Rewrite /etc/tls/infra/* → ~/.xrystal/certificates/* in .env.telepresence (flat PEM names)')
|
|
131
|
+
.argument('[envFile]', 'Path to .env.telepresence (default: service x/environments)')
|
|
132
|
+
.action((envFile) => {
|
|
133
|
+
const version = readCliPackageJson().version
|
|
134
|
+
printCommandHeader({ cliName, command: 'tp rewrite-env', version })
|
|
135
|
+
const target =
|
|
136
|
+
envFile ??
|
|
137
|
+
ensureServiceTelepresenceEnv(process.cwd()).envPath
|
|
138
|
+
try {
|
|
139
|
+
runTelepresenceEnvRewrite(path.resolve(process.cwd(), target))
|
|
140
|
+
} catch (err) {
|
|
141
|
+
console.error(chalk.red(`\n✗ ${err.message}\n`))
|
|
142
|
+
process.exit(1)
|
|
143
|
+
}
|
|
144
|
+
printCommandFooter({ version })
|
|
145
|
+
})
|
|
146
|
+
|
|
138
147
|
tp.command('install')
|
|
139
148
|
.description('Install Telepresence OSS client (~2.31.x, matches cluster chart)')
|
|
140
149
|
.action(() => {
|
|
141
150
|
const version = readCliPackageJson().version
|
|
142
151
|
printCommandHeader({ cliName, command: 'telepresence install', version })
|
|
143
|
-
const script =
|
|
152
|
+
const script = resolveTelepresenceInstallScript()
|
|
153
|
+
if (!script) {
|
|
154
|
+
console.error(chalk.red('\n✗ Telepresence install script missing in @xrystal/core package\n'))
|
|
155
|
+
process.exit(1)
|
|
156
|
+
}
|
|
144
157
|
execSync(`bash "${script}"`, { stdio: 'inherit', env: process.env })
|
|
145
158
|
printCommandFooter({ version })
|
|
146
159
|
})
|
|
@@ -190,6 +203,7 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
|
|
|
190
203
|
envFile: env.envPath,
|
|
191
204
|
localCmd,
|
|
192
205
|
cwd: svcDir,
|
|
206
|
+
cliName,
|
|
193
207
|
})
|
|
194
208
|
} catch (err) {
|
|
195
209
|
console.error(chalk.red(`\n✗ ${err.message}\n`))
|
|
@@ -71,23 +71,23 @@ var defaults_default = {
|
|
|
71
71
|
|
|
72
72
|
// source/utils/models/enums/index.ts
|
|
73
73
|
var GlobalTypeEnum;
|
|
74
|
-
((
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
((GlobalTypeEnum) => {
|
|
75
|
+
GlobalTypeEnum["WORKSPACE"] = "workspace";
|
|
76
|
+
GlobalTypeEnum["API_SERVICE"] = "api-service";
|
|
77
|
+
GlobalTypeEnum["FRONTEND"] = "frontend";
|
|
78
|
+
GlobalTypeEnum["CORE_LIBRARY"] = "core-library";
|
|
79
79
|
})(GlobalTypeEnum ||= {});
|
|
80
80
|
var RuntimeEnum;
|
|
81
|
-
((
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
((RuntimeEnum) => {
|
|
82
|
+
RuntimeEnum["BUN"] = "bun";
|
|
83
|
+
RuntimeEnum["NODE"] = "node";
|
|
84
84
|
})(RuntimeEnum ||= {});
|
|
85
85
|
var BundlerEnum;
|
|
86
|
-
((
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
((BundlerEnum) => {
|
|
87
|
+
BundlerEnum["AUTO"] = "auto";
|
|
88
|
+
BundlerEnum["BUN"] = "bun";
|
|
89
|
+
BundlerEnum["TSC"] = "tsc";
|
|
90
|
+
BundlerEnum["ESBUILD"] = "esbuild";
|
|
91
91
|
})(BundlerEnum ||= {});
|
|
92
92
|
|
|
93
93
|
// source/utils/helpers/tmp/seed-from-tmp.ts
|
|
@@ -478,25 +478,25 @@ function resolveTmpAbsPath(projectRoot, configs) {
|
|
|
478
478
|
return `${base}/${runtime.tmpRelPath}`;
|
|
479
479
|
}
|
|
480
480
|
export {
|
|
481
|
-
|
|
482
|
-
resolveTmpLoaders,
|
|
483
|
-
resolveTmpDeploymentName,
|
|
484
|
-
resolveTmpAbsPath,
|
|
485
|
-
resolveProjectRootFromTmpPath,
|
|
486
|
-
resolveMergedPaths,
|
|
487
|
-
resolveEffectiveBundler,
|
|
488
|
-
readTmpGlobalPathsBlock,
|
|
489
|
-
readTmpGlobalBlock,
|
|
490
|
-
readTmpDependsBlock,
|
|
491
|
-
readTmpBuildBlock,
|
|
492
|
-
normalizeTmpDocument,
|
|
493
|
-
normalizeSourceFolder2 as normalizeSourceFolder,
|
|
494
|
-
normalizeRuntime,
|
|
495
|
-
normalizeRootFolder2 as normalizeRootFolder,
|
|
496
|
-
normalizeGlobalType,
|
|
497
|
-
normalizeBundler,
|
|
498
|
-
buildTmpVarContext,
|
|
499
|
-
buildTmpRelPath,
|
|
481
|
+
applyTmpGlobalVars,
|
|
500
482
|
assertNoLegacyTmpKeys,
|
|
501
|
-
|
|
483
|
+
buildTmpRelPath,
|
|
484
|
+
buildTmpVarContext,
|
|
485
|
+
normalizeBundler,
|
|
486
|
+
normalizeGlobalType,
|
|
487
|
+
normalizeRootFolder2 as normalizeRootFolder,
|
|
488
|
+
normalizeRuntime,
|
|
489
|
+
normalizeSourceFolder2 as normalizeSourceFolder,
|
|
490
|
+
normalizeTmpDocument,
|
|
491
|
+
readTmpBuildBlock,
|
|
492
|
+
readTmpDependsBlock,
|
|
493
|
+
readTmpGlobalBlock,
|
|
494
|
+
readTmpGlobalPathsBlock,
|
|
495
|
+
resolveEffectiveBundler,
|
|
496
|
+
resolveMergedPaths,
|
|
497
|
+
resolveProjectRootFromTmpPath,
|
|
498
|
+
resolveTmpAbsPath,
|
|
499
|
+
resolveTmpDeploymentName,
|
|
500
|
+
resolveTmpLoaders,
|
|
501
|
+
resolveTmpRuntimeConfigs
|
|
502
502
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import { rewriteTelepresenceEnvFileInPlace } from './telepresence-tls-path-rewrite.mjs'
|
|
3
5
|
import { fileURLToPath } from 'node:url'
|
|
4
6
|
import yaml from 'yaml'
|
|
5
7
|
|
|
@@ -479,7 +481,8 @@ export function isProcessEnvInjectedRuntime() {
|
|
|
479
481
|
/** Prod dist run: local uses x/environments/*.env; containers use process env only. */
|
|
480
482
|
export function resolveStartEnvFiles(envDir) {
|
|
481
483
|
if (isProcessEnvInjectedRuntime()) return []
|
|
482
|
-
|
|
484
|
+
rewriteTelepresenceEnvFileInPlace(path.join(envDir, '.env.telepresence'))
|
|
485
|
+
const files = resolveEnvFiles(envDir, ['.env.telepresence', '.env.local', '.prod.env'])
|
|
483
486
|
if (files.length === 0 && (process.env.PORT ?? '').trim()) return []
|
|
484
487
|
return files
|
|
485
488
|
}
|
|
@@ -490,13 +493,10 @@ export function resolveDevRunnerEnvFiles(envDir) {
|
|
|
490
493
|
return resolveEnvFiles(envDir, resolveDevEnvFileNames(envDir))
|
|
491
494
|
}
|
|
492
495
|
|
|
493
|
-
/** Dev env load order — telepresence
|
|
496
|
+
/** Dev env load order — `.env.telepresence` (paths rewritten on intercept or at dev start). */
|
|
494
497
|
export function resolveDevEnvFileNames(envDir) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
names.push('.env.telepresence')
|
|
498
|
-
}
|
|
499
|
-
return names
|
|
498
|
+
rewriteTelepresenceEnvFileInPlace(path.join(envDir, '.env.telepresence'))
|
|
499
|
+
return ['.env.telepresence', '.env.local']
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
function appendEnvFileArgs(argv, envFiles) {
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import os from 'node:os'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
defaultCertificatesDir,
|
|
8
|
+
isTlsFlatBundle,
|
|
9
|
+
isTlsTreeRoot,
|
|
10
|
+
K8S_TLS_MOUNT,
|
|
11
|
+
needsTlsDestRefresh,
|
|
12
|
+
resolveTlsSource,
|
|
13
|
+
syncTlsBundleFast,
|
|
14
|
+
} from './resolve-tls-bundle.mjs'
|
|
15
|
+
import {
|
|
16
|
+
getCliConfigSyncKubeconfigFrom,
|
|
17
|
+
getCliConfigSyncTlsFrom,
|
|
18
|
+
setCliConfigKubeconfig,
|
|
19
|
+
setCliConfigSyncKubeconfigFrom,
|
|
20
|
+
setCliConfigSyncTlsFrom,
|
|
21
|
+
setCliConfigTlsDir,
|
|
22
|
+
} from './xrystal-config.mjs'
|
|
23
|
+
import { resolveUserHome } from './xrystal-registry.mjs'
|
|
24
|
+
|
|
25
|
+
function expandHome(filePath) {
|
|
26
|
+
const raw = String(filePath ?? '').trim()
|
|
27
|
+
if (!raw) return raw
|
|
28
|
+
if (raw.startsWith('~/')) return path.join(os.homedir(), raw.slice(2))
|
|
29
|
+
if (raw === '~') return os.homedir()
|
|
30
|
+
return raw
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function defaultKubeconfigPath() {
|
|
34
|
+
return path.join(resolveUserHome(), 'kubeconfig')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function ensureTlsDestDir(dest) {
|
|
38
|
+
if (fs.existsSync(dest)) return
|
|
39
|
+
const isSystemPath = dest.startsWith('/etc/') || dest.startsWith('/var/')
|
|
40
|
+
if (isSystemPath) {
|
|
41
|
+
console.error(`Ensuring ${dest} (may ask sudo once)...`)
|
|
42
|
+
execSync(`sudo mkdir -p "${dest}" && sudo chown "$(id -u):$(id -g)" "${dest}" && chmod 755 "${dest}"`, {
|
|
43
|
+
shell: true,
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
})
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
fs.mkdirSync(dest, { recursive: true })
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function copyTlsIntoHome(sourcePath, destDir) {
|
|
52
|
+
const source = path.resolve(expandHome(sourcePath))
|
|
53
|
+
if (!fs.existsSync(source)) {
|
|
54
|
+
throw new Error(`TLS source not found: ${source}`)
|
|
55
|
+
}
|
|
56
|
+
fs.mkdirSync(destDir, { recursive: true })
|
|
57
|
+
let bundle = null
|
|
58
|
+
if (isTlsTreeRoot(source)) {
|
|
59
|
+
bundle = { kind: 'tree', root: source }
|
|
60
|
+
} else if (isTlsFlatBundle(source)) {
|
|
61
|
+
bundle = { kind: 'flat', root: source }
|
|
62
|
+
} else {
|
|
63
|
+
throw new Error(`TLS source is not a valid bundle (need root/ca.crt or ca.crt): ${source}`)
|
|
64
|
+
}
|
|
65
|
+
// Flat only under ~/.xrystal/certificates (same names as /etc/tls/infra).
|
|
66
|
+
syncTlsBundleFast(destDir, bundle)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function mirrorHomeTlsToEtc() {
|
|
70
|
+
if (process.platform === 'win32') {
|
|
71
|
+
throw new Error('--mirror-etc is not supported on Windows — use tp intercept env rewrite to ~/.xrystal/certificates')
|
|
72
|
+
}
|
|
73
|
+
const source = resolveTlsSource()
|
|
74
|
+
if (!source) {
|
|
75
|
+
console.error('No TLS bundle under ~/.xrystal/certificates after sync.')
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
const dest = process.env.TELEPRESENCE_TLS_DIR
|
|
79
|
+
? path.resolve(expandHome(process.env.TELEPRESENCE_TLS_DIR))
|
|
80
|
+
: K8S_TLS_MOUNT
|
|
81
|
+
const dests = [dest]
|
|
82
|
+
if (!needsTlsDestRefresh(dests, source)) {
|
|
83
|
+
console.log(`TLS mirror up to date → ${dest}`)
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
ensureTlsDestDir(dest)
|
|
87
|
+
console.log(`TLS mirror ${source.root} → ${dest}`)
|
|
88
|
+
syncTlsBundleFast(dest, source)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function copyKubeconfigIntoHome(sourcePath, destPath) {
|
|
92
|
+
const source = path.resolve(expandHome(sourcePath))
|
|
93
|
+
if (!fs.existsSync(source)) {
|
|
94
|
+
throw new Error(`Kubeconfig not found: ${source}`)
|
|
95
|
+
}
|
|
96
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true })
|
|
97
|
+
fs.copyFileSync(source, destPath)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Copy operator-provided TLS + kubeconfig into ~/.xrystal — no auto-discovery.
|
|
102
|
+
*/
|
|
103
|
+
export function runConfigSync({
|
|
104
|
+
tlsFrom,
|
|
105
|
+
kubeconfigFrom,
|
|
106
|
+
mirrorEtc = false,
|
|
107
|
+
} = {}) {
|
|
108
|
+
const tlsSource =
|
|
109
|
+
tlsFrom ||
|
|
110
|
+
process.env.XRY_SYNC_TLS_FROM ||
|
|
111
|
+
getCliConfigSyncTlsFrom()
|
|
112
|
+
const kubeSource =
|
|
113
|
+
kubeconfigFrom ||
|
|
114
|
+
process.env.XRY_SYNC_KUBECONFIG_FROM ||
|
|
115
|
+
process.env.KUBECONFIG?.split(path.delimiter)[0]?.trim() ||
|
|
116
|
+
getCliConfigSyncKubeconfigFrom()
|
|
117
|
+
|
|
118
|
+
if (!tlsSource && !kubeSource) {
|
|
119
|
+
throw new Error(
|
|
120
|
+
'Nothing to sync — pass --tls-from and/or --kubeconfig-from, or set XRY_SYNC_TLS_FROM / XRY_SYNC_KUBECONFIG_FROM / saved sync sources in config',
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (tlsSource) {
|
|
125
|
+
const dest = defaultCertificatesDir()
|
|
126
|
+
console.log(`TLS ${path.resolve(expandHome(tlsSource))} → ${dest}`)
|
|
127
|
+
copyTlsIntoHome(tlsSource, dest)
|
|
128
|
+
setCliConfigTlsDir(dest)
|
|
129
|
+
setCliConfigSyncTlsFrom(path.resolve(expandHome(tlsSource)))
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (kubeSource) {
|
|
133
|
+
const dest = defaultKubeconfigPath()
|
|
134
|
+
console.log(`Kubeconfig ${path.resolve(expandHome(kubeSource))} → ${dest}`)
|
|
135
|
+
copyKubeconfigIntoHome(kubeSource, dest)
|
|
136
|
+
setCliConfigKubeconfig(dest)
|
|
137
|
+
setCliConfigSyncKubeconfigFrom(path.resolve(expandHome(kubeSource)))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (mirrorEtc && tlsSource) {
|
|
141
|
+
mirrorHomeTlsToEtc()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
console.log('Config sync done.')
|
|
145
|
+
}
|