@xrystal/core 3.55.16 → 3.55.18
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 +6 -1
- package/package.json +1 -1
- package/x/bin/commands/project.mjs +13 -8
- package/x/bin/commands/release.mjs +22 -4
- package/x/bin/helpers/build-config.mjs +27 -0
package/README.md
CHANGED
|
@@ -257,9 +257,14 @@ bun run dev
|
|
|
257
257
|
| `xry dev` | Watch `source/index.ts` + dev env | `source/index.ts` watch + dev env |
|
|
258
258
|
| `xry build` | `tsc` full tree → dist (auto default) + alias/fix post-steps | `tsc` ile tüm `source/` → dist |
|
|
259
259
|
| `xry start` | Run `x/dist` + prod env | `x/dist` + prod env |
|
|
260
|
+
### Runtime env (k8s / Docker) — since 3.55.18
|
|
261
|
+
|
|
262
|
+
**EN:** `x/environments/.global.env` and `.dev.env` are for **local dev** and **Telepresence** only. They must not be copied into container images. In k8s, inject the same keys via Secret (`envFrom`); `xry start` / `Configs` read **`process.env`** only (detects `KUBERNETES_SERVICE_HOST`, `/.dockerenv`, or `XRY_RUNTIME=container`). Docker Compose: use `env_file:` at compose level — not `COPY x/environments` in the Dockerfile.
|
|
263
|
+
|
|
264
|
+
**TR:** `x/environments/*` yalnızca lokal dev + Telepresence. Image'a gömme. Cluster'da Secret inject; runtime dosya okumaz.
|
|
260
265
|
| `xry test` | Run `x/tests` | `x/tests` çalıştır |
|
|
261
266
|
| `xry doctor` | CLI, runtime, package health | CLI, runtime, paket uyumu |
|
|
262
|
-
| `xry tag` |
|
|
267
|
+
| `xry tag` | **This repo only** — tag + npm publish (`@xrystal/core`) | **Sadece core** — servislerde çalışmaz / git tag yok |
|
|
263
268
|
|
|
264
269
|
---
|
|
265
270
|
|
package/package.json
CHANGED
|
@@ -11,9 +11,10 @@ import {
|
|
|
11
11
|
buildRuntimeStartArgv,
|
|
12
12
|
buildRuntimeWatchArgv,
|
|
13
13
|
resolveDevEntry,
|
|
14
|
-
|
|
14
|
+
resolveDevRunnerEnvFiles,
|
|
15
15
|
resolveDistEntryAbs,
|
|
16
|
-
|
|
16
|
+
isProcessEnvInjectedRuntime,
|
|
17
|
+
resolveStartEnvFiles,
|
|
17
18
|
resolvePackageScriptRunner,
|
|
18
19
|
resolveRuntimeRunner,
|
|
19
20
|
resolveServiceBuildSteps,
|
|
@@ -55,10 +56,7 @@ export function registerProjectCommands(cli, { cliName = CLI_PRIMARY_NAME } = {}
|
|
|
55
56
|
runWithServiceRoot((root) => {
|
|
56
57
|
const { layout, runtime } = readTmpBuildContext(root)
|
|
57
58
|
const entry = resolveDevEntry(root, layout)
|
|
58
|
-
const envFiles =
|
|
59
|
-
layout.pathsAbs.environments,
|
|
60
|
-
resolveDevEnvFileNames(layout.pathsAbs.environments),
|
|
61
|
-
)
|
|
59
|
+
const envFiles = resolveDevRunnerEnvFiles(layout.pathsAbs.environments)
|
|
62
60
|
const { runner, argv } = buildRuntimeWatchArgv(runtime, entry, envFiles)
|
|
63
61
|
|
|
64
62
|
printCommandHeader({ cliName, command: 'dev', version: readCliPackageJson().version })
|
|
@@ -67,6 +65,8 @@ export function registerProjectCommands(cli, { cliName = CLI_PRIMARY_NAME } = {}
|
|
|
67
65
|
console.log(chalk.gray(` entry: ${entry} (.ts)`))
|
|
68
66
|
if (envFiles.length) {
|
|
69
67
|
console.log(chalk.gray(` env: ${envFiles.map((f) => path.relative(root, f)).join(' · ')}\n`))
|
|
68
|
+
} else if (isProcessEnvInjectedRuntime()) {
|
|
69
|
+
console.log(chalk.gray(' env: process environment (injected runtime)\n'))
|
|
70
70
|
} else {
|
|
71
71
|
console.log('')
|
|
72
72
|
}
|
|
@@ -131,13 +131,18 @@ export function registerProjectCommands(cli, { cliName = CLI_PRIMARY_NAME } = {}
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
const entry = relativeFromRoot(root, entryAbs)
|
|
134
|
-
const envFiles =
|
|
134
|
+
const envFiles = resolveStartEnvFiles(layout.pathsAbs.environments)
|
|
135
135
|
const { runner, argv } = buildRuntimeStartArgv(runtime, entry, envFiles)
|
|
136
136
|
|
|
137
137
|
printCommandHeader({ cliName, command: 'start', version: readCliPackageJson().version })
|
|
138
138
|
console.log(chalk.gray(` root: ${root}`))
|
|
139
139
|
console.log(chalk.gray(` runtime: ${runtime}`))
|
|
140
|
-
console.log(chalk.gray(` entry: ${entry} (.js)
|
|
140
|
+
console.log(chalk.gray(` entry: ${entry} (.js)`))
|
|
141
|
+
if (envFiles.length) {
|
|
142
|
+
console.log(chalk.gray(` env: ${envFiles.map((f) => path.relative(root, f)).join(' · ')}\n`))
|
|
143
|
+
} else {
|
|
144
|
+
console.log(chalk.gray(' env: process environment (no --env-file)\n'))
|
|
145
|
+
}
|
|
141
146
|
runRunner(root, runner, argv)
|
|
142
147
|
}, { cliName, command: 'start' })
|
|
143
148
|
})
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
import { readCliPackageJson, readProjectPackageJson } from '../helpers/project-root.mjs'
|
|
3
|
-
import { requireServiceRoot, exitOnCliContextError } from '../helpers/cli-context-guard.mjs'
|
|
3
|
+
import { requireServiceRoot, exitOnCliContextError, CliContextError } from '../helpers/cli-context-guard.mjs'
|
|
4
4
|
import { compareSemver, getVersionState, resolveVersionBaseline, runTagRelease } from '../scripts/version-check.mjs'
|
|
5
|
-
import {
|
|
5
|
+
import { isCorePackageProject } from '../scripts/release-prepare.mjs'
|
|
6
6
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
7
|
+
import { CLI_PRIMARY_NAME, PACKAGE_NAME } from '../helpers/cli-identity.mjs'
|
|
7
8
|
|
|
8
9
|
export function registerTagCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
9
10
|
cli
|
|
10
11
|
.command('tag')
|
|
11
|
-
.description(
|
|
12
|
+
.description(`Git tag + npm publish (${packageDefaults.packageName} repo only)`)
|
|
12
13
|
.option('--dry-run', 'Print commands without executing')
|
|
13
14
|
.option('--strict-clean', 'Require fully clean working tree (default: only package.json must be committed)')
|
|
14
15
|
.option('--skip-prepare', 'Skip lint, test, and build:prod (core only)')
|
|
15
16
|
.action(async (options) => {
|
|
16
17
|
try {
|
|
17
18
|
const { root } = requireServiceRoot(process.cwd(), { cliName, command: 'tag' })
|
|
19
|
+
if (!isCorePackageProject(root)) {
|
|
20
|
+
throw new CliContextError(
|
|
21
|
+
`\`xry tag\` is only for ${packageDefaults.packageName} (library). Services do not create git tags here.`,
|
|
22
|
+
{
|
|
23
|
+
hints: [
|
|
24
|
+
'cd to -xrystal-core and bump package.json → commit → xry tag',
|
|
25
|
+
'Service images: CalVer via platform release (see infra versioning.mdc)',
|
|
26
|
+
`${cliName} version — check package.json in this repo`,
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
}
|
|
18
31
|
await runTagRelease({
|
|
19
32
|
dryRun: options.dryRun,
|
|
20
33
|
requireClean: options.strictClean,
|
|
@@ -52,7 +65,12 @@ export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
52
65
|
console.log(` name: ${chalk.bold(projectPkg.name)}`)
|
|
53
66
|
console.log(` package.json (disk): ${chalk.bold(state.disk.version)}`)
|
|
54
67
|
console.log(` package.json (HEAD): ${chalk.bold(state.committed.version)}`)
|
|
55
|
-
|
|
68
|
+
const isCore = isCorePackageProject(root)
|
|
69
|
+
if (isCore) {
|
|
70
|
+
console.log(` git tag name: ${chalk.bold(`v${state.committed.version}`)}`)
|
|
71
|
+
} else {
|
|
72
|
+
console.log(` service image tag: ${chalk.gray('N/A — CalVer via platform CI (infra versioning.mdc)')}`)
|
|
73
|
+
}
|
|
56
74
|
console.log(` branch: ${state.branch}`)
|
|
57
75
|
console.log(` version match: ${state.versionMatch ? chalk.green('yes') : chalk.red('no')}`)
|
|
58
76
|
console.log(` package.json committed: ${state.isPackageJsonClean ? chalk.green('yes') : chalk.red('no')}`)
|
|
@@ -463,6 +463,33 @@ export function resolveEnvFiles(envDir, names) {
|
|
|
463
463
|
.filter((file) => fs.existsSync(file))
|
|
464
464
|
}
|
|
465
465
|
|
|
466
|
+
/** k8s Secret / Compose env_file / Docker inject — do not pass bun --env-file for baked x/environments. */
|
|
467
|
+
export function isProcessEnvInjectedRuntime() {
|
|
468
|
+
const explicit = (process.env.XRY_RUNTIME ?? '').trim().toLowerCase()
|
|
469
|
+
if (['container', 'k8s', 'kubernetes', 'docker'].includes(explicit)) return true
|
|
470
|
+
if (process.env.KUBERNETES_SERVICE_HOST) return true
|
|
471
|
+
try {
|
|
472
|
+
if (fs.existsSync('/.dockerenv')) return true
|
|
473
|
+
} catch {
|
|
474
|
+
/* ignore */
|
|
475
|
+
}
|
|
476
|
+
return false
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/** Prod dist run: local uses x/environments/*.env; containers use process env only. */
|
|
480
|
+
export function resolveStartEnvFiles(envDir) {
|
|
481
|
+
if (isProcessEnvInjectedRuntime()) return []
|
|
482
|
+
const files = resolveEnvFiles(envDir, ['.global.env', '.prod.env'])
|
|
483
|
+
if (files.length === 0 && (process.env.PORT ?? '').trim()) return []
|
|
484
|
+
return files
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** Dev watch: optional file env when not in injected runtime. */
|
|
488
|
+
export function resolveDevRunnerEnvFiles(envDir) {
|
|
489
|
+
if (isProcessEnvInjectedRuntime()) return []
|
|
490
|
+
return resolveEnvFiles(envDir, resolveDevEnvFileNames(envDir))
|
|
491
|
+
}
|
|
492
|
+
|
|
466
493
|
/** Dev env load order — telepresence cluster env last when present. */
|
|
467
494
|
export function resolveDevEnvFileNames(envDir) {
|
|
468
495
|
const names = ['.global.env', '.dev.env']
|