@xrystal/core 3.55.5 → 3.55.6

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.55.5",
4
+ "version": "3.55.6",
5
5
  "description": "Runtime framework and CLI for API services, frontends, and multi-repo workspaces",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -1,4 +1,4 @@
1
- import { execSync } from 'node:child_process'
1
+ import { execSync, spawnSync } from 'node:child_process'
2
2
  import fs from 'node:fs'
3
3
  import path from 'node:path'
4
4
  import chalk from 'chalk'
@@ -8,7 +8,10 @@ import {
8
8
  isCorePackageName,
9
9
  readTmpBuildContext,
10
10
  resolveCoreBuildSteps,
11
+ buildRuntimeStartArgv,
12
+ buildRuntimeWatchArgv,
11
13
  resolveDevEntry,
14
+ resolveDevEnvFileNames,
12
15
  resolveDistEntryAbs,
13
16
  resolveEnvFiles,
14
17
  resolvePackageScriptRunner,
@@ -28,6 +31,12 @@ function runInProject(root, command) {
28
31
  execSync(command, { cwd: root, stdio: 'inherit', env: process.env })
29
32
  }
30
33
 
34
+ function runRunner(root, runner, argv) {
35
+ const result = spawnSync(runner, argv, { cwd: root, stdio: 'inherit', env: process.env })
36
+ if (result.error) throw result.error
37
+ if (result.status !== 0) process.exit(result.status ?? 1)
38
+ }
39
+
31
40
  function resolveTestTarget(root) {
32
41
  const layout = ensureTmpFile(root).layout
33
42
  if (fs.existsSync(layout.pathsAbs.tests)) {
@@ -46,15 +55,22 @@ export function registerProjectCommands(cli, { cliName = CLI_PRIMARY_NAME } = {}
46
55
  runWithServiceRoot((root) => {
47
56
  const { layout, runtime } = readTmpBuildContext(root)
48
57
  const entry = resolveDevEntry(root, layout)
49
- const envFiles = resolveEnvFiles(layout.pathsAbs.environments, ['.global.env', '.dev.env'])
50
- const envArgs = envFiles.map((file) => `--env-file=${file}`).join(' ')
51
- const runner = resolveRuntimeRunner(runtime)
58
+ const envFiles = resolveEnvFiles(
59
+ layout.pathsAbs.environments,
60
+ resolveDevEnvFileNames(layout.pathsAbs.environments),
61
+ )
62
+ const { runner, argv } = buildRuntimeWatchArgv(runtime, entry, envFiles)
52
63
 
53
64
  printCommandHeader({ cliName, command: 'dev', version: readCliPackageJson().version })
54
65
  console.log(chalk.gray(` root: ${root}`))
55
66
  console.log(chalk.gray(` runtime: ${runtime}`))
56
- console.log(chalk.gray(` entry: ${entry} (.ts)\n`))
57
- runInProject(root, `${runner} --watch ${envArgs} ${entry}`.trim())
67
+ console.log(chalk.gray(` entry: ${entry} (.ts)`))
68
+ if (envFiles.length) {
69
+ console.log(chalk.gray(` env: ${envFiles.map((f) => path.relative(root, f)).join(' · ')}\n`))
70
+ } else {
71
+ console.log('')
72
+ }
73
+ runRunner(root, runner, argv)
58
74
  }, { cliName, command: 'dev' })
59
75
  })
60
76
 
@@ -116,14 +132,13 @@ export function registerProjectCommands(cli, { cliName = CLI_PRIMARY_NAME } = {}
116
132
 
117
133
  const entry = relativeFromRoot(root, entryAbs)
118
134
  const envFiles = resolveEnvFiles(layout.pathsAbs.environments, ['.global.env', '.prod.env'])
119
- const envArgs = envFiles.map((file) => `--env-file=${file}`).join(' ')
120
- const runner = resolveRuntimeRunner(runtime)
135
+ const { runner, argv } = buildRuntimeStartArgv(runtime, entry, envFiles)
121
136
 
122
137
  printCommandHeader({ cliName, command: 'start', version: readCliPackageJson().version })
123
138
  console.log(chalk.gray(` root: ${root}`))
124
139
  console.log(chalk.gray(` runtime: ${runtime}`))
125
140
  console.log(chalk.gray(` entry: ${entry} (.js)\n`))
126
- runInProject(root, `${runner} ${envArgs} ${entry}`.trim())
141
+ runRunner(root, runner, argv)
127
142
  }, { cliName, command: 'start' })
128
143
  })
129
144
 
@@ -137,7 +137,7 @@ export function registerTelepresenceCommand(cli, { cliName = CLI_PRIMARY_NAME }
137
137
 
138
138
  const portArg = parsePort(port)
139
139
  const rest = command.args.slice(/^\d+$/.test(String(port ?? '')) ? 2 : 1)
140
- const localCmd = rest.length ? rest : ['bun', 'run', 'dev']
140
+ const localCmd = rest.length ? rest : ['xry', 'dev']
141
141
  const args = [`NS=${ns}`, deployName, portArg, '--', ...localCmd]
142
142
 
143
143
  runHelper(interceptScript, args, { cwd: svcDir })
@@ -463,6 +463,36 @@ export function resolveEnvFiles(envDir, names) {
463
463
  .filter((file) => fs.existsSync(file))
464
464
  }
465
465
 
466
+ /** Dev env load order — telepresence cluster env last when present. */
467
+ export function resolveDevEnvFileNames(envDir) {
468
+ const names = ['.global.env', '.dev.env']
469
+ if (fs.existsSync(path.join(envDir, '.env.telepresence'))) {
470
+ names.push('.env.telepresence')
471
+ }
472
+ return names
473
+ }
474
+
475
+ function appendEnvFileArgs(argv, envFiles) {
476
+ for (const file of envFiles) {
477
+ argv.push('--env-file', file)
478
+ }
479
+ return argv
480
+ }
481
+
482
+ export function buildRuntimeWatchArgv(runtime, entry, envFiles) {
483
+ const runner = resolveRuntimeRunner(runtime)
484
+ const argv = appendEnvFileArgs(['--watch'], envFiles)
485
+ argv.push(entry)
486
+ return { runner, argv }
487
+ }
488
+
489
+ export function buildRuntimeStartArgv(runtime, entry, envFiles) {
490
+ const runner = resolveRuntimeRunner(runtime)
491
+ const argv = appendEnvFileArgs([], envFiles)
492
+ argv.push(entry)
493
+ return { runner, argv }
494
+ }
495
+
466
496
 
467
497
  export function resolveRuntimeRunner(runtime = detectCliHostRuntime()) {
468
498
  return getRuntimeTooling(runtime).binRunner