@xrystal/core 3.45.1 → 3.45.2
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 +9 -2
- package/package.json +1 -1
- package/x/bin/helpers/.generated/seed-from-tmp.mjs +30 -0
- package/x/bin/helpers/.generated/tmp-schema.mjs +30 -0
- package/x/bin/helpers/build-config.mjs +23 -21
- package/x/bin/helpers/cli-runtime.mjs +84 -0
- package/x/bin/helpers/package-defaults.mjs +23 -0
- package/x/bin/helpers/runtime-info.mjs +13 -4
- package/x/bin/main-cli.js +5 -9
- package/x/dist/utils/constants/defaults.json +30 -0
- package/x/dist/utils/constants/index.js +1 -1
package/README.md
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
> **EN** — Microservice runtime: Express or Elysia HTTP, DI loaders, live `tmp.yml`, standardized API responses.
|
|
4
4
|
> **TR** — Microservice runtime: Express veya Elysia HTTP, DI loader'lar, canlı `tmp.yml`, standart API cevapları.
|
|
5
5
|
|
|
6
|
-
**CLI:** `xry` · **Version:** `3.45.
|
|
6
|
+
**CLI:** `xry` · **Version:** `3.45.2` · [npm](https://www.npmjs.com/package/@xrystal/core)
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## What's new in 3.45.2 / 3.45.2'da ne değişti
|
|
11
|
+
|
|
12
|
+
| Change / Değişiklik | EN | TR |
|
|
13
|
+
|---------------------|----|----|
|
|
14
|
+
| **Runtime SSOT** | `defaults.runtimes` + `RuntimeEnum`; no Bun/Node hardcodes in CLI | Runtime hardcode kalktı |
|
|
15
|
+
| **tmp.global.runtime** | Banner/project runtime from tmp.yml | Proje runtime tmp'den |
|
|
16
|
+
|
|
10
17
|
## What's new in 3.45.1 / 3.45.1'da ne değişti
|
|
11
18
|
|
|
12
19
|
| Change / Değişiklik | EN | TR |
|
|
@@ -79,7 +86,7 @@ npx xry doctor # EN: optional health check · TR: isteğe bağlı sağlı
|
|
|
79
86
|
```json
|
|
80
87
|
{
|
|
81
88
|
"dependencies": {
|
|
82
|
-
"@xrystal/core": "^3.45.
|
|
89
|
+
"@xrystal/core": "^3.45.2",
|
|
83
90
|
"elysia": "^1.4.19"
|
|
84
91
|
},
|
|
85
92
|
"scripts": {
|
package/package.json
CHANGED
|
@@ -25,6 +25,36 @@ var defaults_default = {
|
|
|
25
25
|
tagline: "microservice runtime library",
|
|
26
26
|
capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
|
|
27
27
|
},
|
|
28
|
+
runtimes: {
|
|
29
|
+
bun: {
|
|
30
|
+
label: "Bun",
|
|
31
|
+
packageManager: "bun",
|
|
32
|
+
installCommand: "bun install",
|
|
33
|
+
scriptRunner: "bun run",
|
|
34
|
+
binRunner: "bun",
|
|
35
|
+
testRunner: "bun test",
|
|
36
|
+
tscBin: "bunx tsc",
|
|
37
|
+
esbuildBin: "bunx esbuild",
|
|
38
|
+
devInvoker: null
|
|
39
|
+
},
|
|
40
|
+
node: {
|
|
41
|
+
label: "Node.js",
|
|
42
|
+
packageManager: "npm",
|
|
43
|
+
installCommand: "npm install",
|
|
44
|
+
scriptRunner: "npm run",
|
|
45
|
+
binRunner: "node",
|
|
46
|
+
testRunner: "node --test",
|
|
47
|
+
tscBin: "npx tsc",
|
|
48
|
+
esbuildBin: "npx esbuild",
|
|
49
|
+
devInvoker: "npx"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
bundlers: [
|
|
53
|
+
"auto",
|
|
54
|
+
"bun",
|
|
55
|
+
"tsc",
|
|
56
|
+
"esbuild"
|
|
57
|
+
],
|
|
28
58
|
tmpWatchDefaults: {
|
|
29
59
|
intervalMs: 500,
|
|
30
60
|
minIntervalMs: 100,
|
|
@@ -20,6 +20,36 @@ var defaults_default = {
|
|
|
20
20
|
tagline: "microservice runtime library",
|
|
21
21
|
capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
|
|
22
22
|
},
|
|
23
|
+
runtimes: {
|
|
24
|
+
bun: {
|
|
25
|
+
label: "Bun",
|
|
26
|
+
packageManager: "bun",
|
|
27
|
+
installCommand: "bun install",
|
|
28
|
+
scriptRunner: "bun run",
|
|
29
|
+
binRunner: "bun",
|
|
30
|
+
testRunner: "bun test",
|
|
31
|
+
tscBin: "bunx tsc",
|
|
32
|
+
esbuildBin: "bunx esbuild",
|
|
33
|
+
devInvoker: null
|
|
34
|
+
},
|
|
35
|
+
node: {
|
|
36
|
+
label: "Node.js",
|
|
37
|
+
packageManager: "npm",
|
|
38
|
+
installCommand: "npm install",
|
|
39
|
+
scriptRunner: "npm run",
|
|
40
|
+
binRunner: "node",
|
|
41
|
+
testRunner: "node --test",
|
|
42
|
+
tscBin: "npx tsc",
|
|
43
|
+
esbuildBin: "npx esbuild",
|
|
44
|
+
devInvoker: "npx"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
bundlers: [
|
|
48
|
+
"auto",
|
|
49
|
+
"bun",
|
|
50
|
+
"tsc",
|
|
51
|
+
"esbuild"
|
|
52
|
+
],
|
|
23
53
|
tmpWatchDefaults: {
|
|
24
54
|
intervalMs: 500,
|
|
25
55
|
minIntervalMs: 100,
|
|
@@ -3,6 +3,7 @@ import path from 'node:path'
|
|
|
3
3
|
import yaml from 'yaml'
|
|
4
4
|
|
|
5
5
|
import { packageDefaults } from '../paths.mjs'
|
|
6
|
+
import { getRuntimeTooling, RuntimeEnum, BundlerEnum, detectCliHostRuntime } from './cli-runtime.mjs'
|
|
6
7
|
import { ensureTmpFile, relativeFromRoot } from './tmp-layout.mjs'
|
|
7
8
|
import {
|
|
8
9
|
normalizeTmpDocument,
|
|
@@ -233,17 +234,17 @@ export function resolveSourcemapFlag(buildConfig = {}, tsconfig = null) {
|
|
|
233
234
|
return ''
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
function resolveTscBin(runtime =
|
|
237
|
-
return runtime
|
|
237
|
+
function resolveTscBin(runtime = detectCliHostRuntime()) {
|
|
238
|
+
return getRuntimeTooling(runtime).tscBin
|
|
238
239
|
}
|
|
239
240
|
|
|
240
|
-
function withTscProject(root, buildConfig, extraArgs, runtime =
|
|
241
|
+
function withTscProject(root, buildConfig, extraArgs, runtime = detectCliHostRuntime()) {
|
|
241
242
|
const tsconfigRel = resolveTsconfigRel(root, buildConfig)
|
|
242
243
|
const projectFlag = tsconfigRel ? `--project ${tsconfigRel} ` : ''
|
|
243
244
|
return `${resolveTscBin(runtime)} ${projectFlag}${extraArgs}`.replace(/\s+/g, ' ').trim()
|
|
244
245
|
}
|
|
245
246
|
|
|
246
|
-
export function resolveTypecheckCommand(root, buildConfig = {}, runtime =
|
|
247
|
+
export function resolveTypecheckCommand(root, buildConfig = {}, runtime = detectCliHostRuntime()) {
|
|
247
248
|
const tsconfigRel = resolveTsconfigRel(root, buildConfig)
|
|
248
249
|
if (!tsconfigRel) {
|
|
249
250
|
throw new Error(
|
|
@@ -253,7 +254,7 @@ export function resolveTypecheckCommand(root, buildConfig = {}, runtime = 'bun')
|
|
|
253
254
|
return withTscProject(root, buildConfig, '--noEmit', runtime)
|
|
254
255
|
}
|
|
255
256
|
|
|
256
|
-
export function resolveTscCommand(root, distRel, buildConfig = {}, runtime =
|
|
257
|
+
export function resolveTscCommand(root, distRel, buildConfig = {}, runtime = detectCliHostRuntime()) {
|
|
257
258
|
const cmd = withTscProject(root, buildConfig, `--emitDeclarationOnly --declaration --outDir ${distRel}`, runtime)
|
|
258
259
|
return buildConfig.tscLenient ? `${cmd} || true` : cmd
|
|
259
260
|
}
|
|
@@ -265,30 +266,30 @@ export function resolveBunBuildCommand(entryGlobs, distRel, buildConfig = {}, ts
|
|
|
265
266
|
return `bun build ${entryGlobs.join(' ')} ${flags.join(' ')}`.replace(/\s+/g, ' ').trim()
|
|
266
267
|
}
|
|
267
268
|
|
|
268
|
-
export function resolveTscBuildCommand(root, distRel, buildConfig = {}, runtime =
|
|
269
|
+
export function resolveTscBuildCommand(root, distRel, buildConfig = {}, runtime = detectCliHostRuntime()) {
|
|
269
270
|
return withTscProject(root, buildConfig, `--outDir ${distRel}`, runtime)
|
|
270
271
|
}
|
|
271
272
|
|
|
272
|
-
export function resolveEsbuildBuildCommand(entryGlobs, distRel, buildConfig = {}, tsconfig = null, runtime =
|
|
273
|
+
export function resolveEsbuildBuildCommand(entryGlobs, distRel, buildConfig = {}, tsconfig = null, runtime = detectCliHostRuntime()) {
|
|
273
274
|
const minify = resolveMinifyEnabled(buildConfig) ? ' --minify' : ''
|
|
274
275
|
const sourcemapFlag = resolveSourcemapFlag(buildConfig, tsconfig)
|
|
275
276
|
const sourcemap = sourcemapFlag ? ' --sourcemap' : ''
|
|
276
|
-
const bin = runtime
|
|
277
|
+
const bin = getRuntimeTooling(runtime).esbuildBin
|
|
277
278
|
const entries = entryGlobs.join(' ')
|
|
278
279
|
return `${bin} ${entries} --bundle --platform=node --packages=external --outdir=${distRel}${minify}${sourcemap}`.replace(/\s+/g, ' ').trim()
|
|
279
280
|
}
|
|
280
281
|
|
|
281
|
-
export function resolveServiceBundleCommand(root, plan, buildConfig = {}, runtime =
|
|
282
|
-
if (bundler ===
|
|
282
|
+
export function resolveServiceBundleCommand(root, plan, buildConfig = {}, runtime = detectCliHostRuntime(), bundler = normalizeBundler('bun')) {
|
|
283
|
+
if (bundler === BundlerEnum.TSC) {
|
|
283
284
|
return resolveTscBuildCommand(root, plan.distRel, buildConfig, runtime)
|
|
284
285
|
}
|
|
285
|
-
if (bundler ===
|
|
286
|
+
if (bundler === BundlerEnum.ESBUILD) {
|
|
286
287
|
return resolveEsbuildBuildCommand(plan.entryGlobs, plan.distRel, buildConfig, plan.tsconfig, runtime)
|
|
287
288
|
}
|
|
288
289
|
return resolveBunBuildCommand(plan.entryGlobs, plan.distRel, buildConfig, plan.tsconfig)
|
|
289
290
|
}
|
|
290
291
|
|
|
291
|
-
export function resolveEffectiveBuildOptions(root, layout, buildConfig = {}, runtime =
|
|
292
|
+
export function resolveEffectiveBuildOptions(root, layout, buildConfig = {}, runtime = detectCliHostRuntime()) {
|
|
292
293
|
const tsconfig = readTsconfigJson(root, buildConfig)
|
|
293
294
|
const distRel = resolveDistRelWithTsconfig(root, layout, buildConfig, tsconfig)
|
|
294
295
|
const entryGlobs = resolveBuildEntryGlobs(layout.mainFolderPath, buildConfig, tsconfig)
|
|
@@ -340,7 +341,7 @@ export function resolveCoreBuildSteps(root, distRel, buildConfig = {}) {
|
|
|
340
341
|
return steps
|
|
341
342
|
}
|
|
342
343
|
|
|
343
|
-
export function resolveServiceBuildSteps(root, layout, buildConfig = {}, runtime =
|
|
344
|
+
export function resolveServiceBuildSteps(root, layout, buildConfig = {}, runtime = detectCliHostRuntime()) {
|
|
344
345
|
const plan = resolveEffectiveBuildOptions(root, layout, buildConfig, runtime)
|
|
345
346
|
const steps = []
|
|
346
347
|
|
|
@@ -360,7 +361,7 @@ export function resolveServiceBuildSteps(root, layout, buildConfig = {}, runtime
|
|
|
360
361
|
return steps
|
|
361
362
|
}
|
|
362
363
|
|
|
363
|
-
export function summarizeBuildPlan(root, layout, buildConfig = {}, runtime =
|
|
364
|
+
export function summarizeBuildPlan(root, layout, buildConfig = {}, runtime = detectCliHostRuntime()) {
|
|
364
365
|
const plan = resolveEffectiveBuildOptions(root, layout, buildConfig, runtime)
|
|
365
366
|
return {
|
|
366
367
|
distRel: plan.distRel,
|
|
@@ -394,15 +395,16 @@ export function resolveEnvFiles(envDir, names) {
|
|
|
394
395
|
}
|
|
395
396
|
|
|
396
397
|
|
|
397
|
-
export function resolveRuntimeRunner(runtime =
|
|
398
|
-
return runtime
|
|
398
|
+
export function resolveRuntimeRunner(runtime = detectCliHostRuntime()) {
|
|
399
|
+
return getRuntimeTooling(runtime).binRunner
|
|
399
400
|
}
|
|
400
401
|
|
|
401
|
-
export function resolvePackageScriptRunner(runtime =
|
|
402
|
-
return runtime
|
|
402
|
+
export function resolvePackageScriptRunner(runtime = detectCliHostRuntime()) {
|
|
403
|
+
return getRuntimeTooling(runtime).scriptRunner
|
|
403
404
|
}
|
|
404
405
|
|
|
405
|
-
export function resolveTestCommand(runtime =
|
|
406
|
-
|
|
407
|
-
return `bun test ${target}`
|
|
406
|
+
export function resolveTestCommand(runtime = detectCliHostRuntime(), target) {
|
|
407
|
+
return `${getRuntimeTooling(runtime).testRunner} ${target}`.trim()
|
|
408
408
|
}
|
|
409
|
+
|
|
410
|
+
export { RuntimeEnum, detectCliHostRuntime, getRuntimeTooling }
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import yaml from 'yaml'
|
|
3
|
+
|
|
4
|
+
import { packageDefaults, PACKAGE_NAME } from './package-defaults.mjs'
|
|
5
|
+
import { normalizeRuntime, normalizeTmpDocument, readTmpGlobalBlock } from './tmp-schema.mjs'
|
|
6
|
+
import { ensureTmpFile } from './tmp-layout.mjs'
|
|
7
|
+
|
|
8
|
+
/** Runtime ids = keys of defaults.runtimes (aligned with RuntimeEnum). */
|
|
9
|
+
export const RuntimeEnum = Object.freeze(
|
|
10
|
+
Object.fromEntries(
|
|
11
|
+
Object.keys(packageDefaults.runtimes).map((key) => [key.toUpperCase(), key]),
|
|
12
|
+
),
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
/** Bundler ids = defaults.bundlers (aligned with BundlerEnum). */
|
|
16
|
+
export const BundlerEnum = Object.freeze(
|
|
17
|
+
Object.fromEntries(
|
|
18
|
+
packageDefaults.bundlers.map((key) => [String(key).toUpperCase(), key]),
|
|
19
|
+
),
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
export function detectCliHostRuntime() {
|
|
23
|
+
const bunKey = RuntimeEnum.BUN
|
|
24
|
+
const nodeKey = RuntimeEnum.NODE
|
|
25
|
+
if (!bunKey || !nodeKey) {
|
|
26
|
+
throw new Error(`${PACKAGE_NAME}: defaults.runtimes must define bun and node`)
|
|
27
|
+
}
|
|
28
|
+
return process.versions.bun ? bunKey : nodeKey
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getRuntimeTooling(runtime) {
|
|
32
|
+
const key = normalizeRuntime(runtime)
|
|
33
|
+
const tooling = packageDefaults.runtimes?.[key]
|
|
34
|
+
if (!tooling) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`${PACKAGE_NAME}: defaults.runtimes.${key} missing — add it to defaults.json`,
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
return tooling
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Project runtime from tmp.yml configs.global.runtime. */
|
|
43
|
+
export function resolveProjectRuntime(root = process.cwd()) {
|
|
44
|
+
const { tmpFilePath } = ensureTmpFile(root)
|
|
45
|
+
const raw = yaml.parse(fs.readFileSync(tmpFilePath, 'utf8'))
|
|
46
|
+
const normalized = normalizeTmpDocument(raw)
|
|
47
|
+
const global = readTmpGlobalBlock(normalized.configs)
|
|
48
|
+
return normalizeRuntime(global.runtime)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function resolveDevCommand(cliName, runtime = detectCliHostRuntime()) {
|
|
52
|
+
const tooling = getRuntimeTooling(runtime)
|
|
53
|
+
if (tooling.devInvoker) return `${tooling.devInvoker} ${cliName} dev`
|
|
54
|
+
return `${cliName} dev`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* CLI UX context: banner/project runtime from tmp; install tooling from host process.
|
|
59
|
+
*/
|
|
60
|
+
export function resolveCliContext({ cliName, root = process.cwd() } = {}) {
|
|
61
|
+
const hostRuntime = detectCliHostRuntime()
|
|
62
|
+
const hostTooling = getRuntimeTooling(hostRuntime)
|
|
63
|
+
|
|
64
|
+
let projectRuntime = hostRuntime
|
|
65
|
+
let projectTooling = hostTooling
|
|
66
|
+
try {
|
|
67
|
+
projectRuntime = resolveProjectRuntime(root)
|
|
68
|
+
projectTooling = getRuntimeTooling(projectRuntime)
|
|
69
|
+
} catch {
|
|
70
|
+
// create / pre-tmp flows: host only until tmp.yml exists
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
cliName,
|
|
75
|
+
runtime: projectRuntime,
|
|
76
|
+
hostRuntime,
|
|
77
|
+
runtimeName: projectTooling.label,
|
|
78
|
+
packageManager: hostTooling.packageManager,
|
|
79
|
+
installCommand: hostTooling.installCommand,
|
|
80
|
+
devCommand: resolveDevCommand(cliName, hostRuntime),
|
|
81
|
+
tooling: projectTooling,
|
|
82
|
+
hostTooling,
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -60,6 +60,21 @@ function assertIdentityDefaults(raw, sourceLabel) {
|
|
|
60
60
|
throw new Error(`package defaults incomplete (${sourceLabel}): cliBinNames or cliName required`)
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
const runtimes = raw.runtimes
|
|
64
|
+
if (!runtimes || typeof runtimes !== 'object') {
|
|
65
|
+
throw new Error(`package defaults incomplete (${sourceLabel}): runtimes map required`)
|
|
66
|
+
}
|
|
67
|
+
for (const key of Object.keys(runtimes)) {
|
|
68
|
+
const entry = runtimes[key]
|
|
69
|
+
for (const field of ['label', 'packageManager', 'installCommand', 'scriptRunner', 'binRunner', 'testRunner', 'tscBin', 'esbuildBin']) {
|
|
70
|
+
if (entry?.[field] == null || String(entry[field]).trim() === '') {
|
|
71
|
+
throw new Error(`package defaults incomplete (${sourceLabel}): runtimes.${key}.${field}`)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!Array.isArray(raw.bundlers) || raw.bundlers.length === 0) {
|
|
76
|
+
throw new Error(`package defaults incomplete (${sourceLabel}): bundlers list required`)
|
|
77
|
+
}
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
function loadRawDefaults() {
|
|
@@ -86,12 +101,20 @@ if (!seed?.mainSourceFolder || !String(seed.mainSourceFolder).trim()) {
|
|
|
86
101
|
)
|
|
87
102
|
}
|
|
88
103
|
|
|
104
|
+
const frozenRuntimes = Object.freeze(
|
|
105
|
+
Object.fromEntries(
|
|
106
|
+
Object.entries(raw.runtimes).map(([key, value]) => [key, Object.freeze({ ...value })]),
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
|
|
89
110
|
export const packageDefaults = Object.freeze({
|
|
90
111
|
...raw,
|
|
91
112
|
mainSourceFolder: seed.mainSourceFolder,
|
|
92
113
|
framework: seed.framework,
|
|
93
114
|
layoutPaths: seed.layoutPaths,
|
|
94
115
|
brand: Object.freeze({ ...(raw.brand ?? {}) }),
|
|
116
|
+
runtimes: frozenRuntimes,
|
|
117
|
+
bundlers: Object.freeze([...raw.bundlers]),
|
|
95
118
|
buildDefaults: Object.freeze({ ...(raw.buildDefaults ?? {}) }),
|
|
96
119
|
tmpWatchDefaults: Object.freeze({ ...(raw.tmpWatchDefaults ?? {}) }),
|
|
97
120
|
cliBinNames: Object.freeze([...(raw.cliBinNames ?? [raw.cliName])]),
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
import { packageDefaults } from './package-defaults.mjs'
|
|
1
2
|
import { execSync } from 'node:child_process'
|
|
2
3
|
import fs from 'node:fs'
|
|
3
4
|
import os from 'node:os'
|
|
4
5
|
import path from 'node:path'
|
|
5
6
|
|
|
7
|
+
function runtimeExecutable(key) {
|
|
8
|
+
const tooling = packageDefaults.runtimes?.[key]
|
|
9
|
+
if (!tooling) {
|
|
10
|
+
throw new Error(`defaults.runtimes.${key} missing`)
|
|
11
|
+
}
|
|
12
|
+
return { key, label: tooling.label, cmd: tooling.binRunner }
|
|
13
|
+
}
|
|
14
|
+
|
|
6
15
|
const EXECUTABLES = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{ key:
|
|
16
|
+
runtimeExecutable('node'),
|
|
17
|
+
runtimeExecutable('bun'),
|
|
18
|
+
{ key: packageDefaults.runtimes.node.packageManager, label: packageDefaults.runtimes.node.packageManager, cmd: packageDefaults.runtimes.node.packageManager },
|
|
10
19
|
{ key: 'pnpm', label: 'pnpm', cmd: 'pnpm' },
|
|
11
20
|
{ key: 'yarn', label: 'Yarn', cmd: 'yarn' },
|
|
12
21
|
{ key: 'deno', label: 'Deno', cmd: 'deno' },
|
|
@@ -130,7 +139,7 @@ export function detectPackageManager(root = process.cwd()) {
|
|
|
130
139
|
export function resolveRuntimeInfo(root = process.cwd()) {
|
|
131
140
|
const bunEmbedded = process.versions.bun
|
|
132
141
|
const cliHost = bunEmbedded ? 'bun' : 'node'
|
|
133
|
-
const cliHostLabel = bunEmbedded ?
|
|
142
|
+
const cliHostLabel = bunEmbedded ? packageDefaults.runtimes.bun.label : packageDefaults.runtimes.node.label
|
|
134
143
|
const cliHostVersion = bunEmbedded
|
|
135
144
|
? normalizeSemver(bunEmbedded)
|
|
136
145
|
: normalizeSemver(process.version.replace(/^v/, ''))
|
package/x/bin/main-cli.js
CHANGED
|
@@ -19,25 +19,21 @@ import {
|
|
|
19
19
|
} from './helpers/cli-identity.mjs'
|
|
20
20
|
import { readCliPackageJson, getProjectRoot } from './helpers/project-root.mjs'
|
|
21
21
|
import { ensureProjectArtifacts } from './helpers/project-artifacts.mjs'
|
|
22
|
+
import { resolveCliContext } from './helpers/cli-runtime.mjs'
|
|
22
23
|
|
|
23
24
|
const pkg = readCliPackageJson()
|
|
25
|
+
const projectRoot = getProjectRoot()
|
|
24
26
|
|
|
25
27
|
try {
|
|
26
|
-
ensureProjectArtifacts(
|
|
28
|
+
ensureProjectArtifacts(projectRoot, { writeToolchain: false, writeManifest: false })
|
|
27
29
|
} catch {
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
const cliName = resolveInvokedAs()
|
|
31
|
-
|
|
32
|
-
const isBun = !!process.versions.bun
|
|
33
|
-
const runtimeName = isBun ? 'Bun' : 'Node.js'
|
|
34
|
-
const packageManager = isBun ? 'bun' : 'npm'
|
|
35
|
-
const installCommand = isBun ? 'bun install' : 'npm install'
|
|
36
|
-
const devCommand = isBun ? `${cliName} dev` : `npx ${cliName} dev`
|
|
37
|
-
const cliContext = { cliName, runtimeName, packageManager, installCommand, devCommand }
|
|
33
|
+
const cliContext = resolveCliContext({ cliName, root: projectRoot })
|
|
38
34
|
|
|
39
35
|
if (shouldShowBanner()) {
|
|
40
|
-
printBanner({ version: pkg.version, runtimeName, invokedAs: cliName })
|
|
36
|
+
printBanner({ version: pkg.version, runtimeName: cliContext.runtimeName, invokedAs: cliName })
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
if (isRootHelpRequest()) {
|
|
@@ -19,6 +19,36 @@
|
|
|
19
19
|
"tagline": "microservice runtime library",
|
|
20
20
|
"capabilities": "loaders \u00b7 tmp.yml \u00b7 dto \u00b7 i18n \u00b7 multi-protocol \u00b7 scaffold"
|
|
21
21
|
},
|
|
22
|
+
"runtimes": {
|
|
23
|
+
"bun": {
|
|
24
|
+
"label": "Bun",
|
|
25
|
+
"packageManager": "bun",
|
|
26
|
+
"installCommand": "bun install",
|
|
27
|
+
"scriptRunner": "bun run",
|
|
28
|
+
"binRunner": "bun",
|
|
29
|
+
"testRunner": "bun test",
|
|
30
|
+
"tscBin": "bunx tsc",
|
|
31
|
+
"esbuildBin": "bunx esbuild",
|
|
32
|
+
"devInvoker": null
|
|
33
|
+
},
|
|
34
|
+
"node": {
|
|
35
|
+
"label": "Node.js",
|
|
36
|
+
"packageManager": "npm",
|
|
37
|
+
"installCommand": "npm install",
|
|
38
|
+
"scriptRunner": "npm run",
|
|
39
|
+
"binRunner": "node",
|
|
40
|
+
"testRunner": "node --test",
|
|
41
|
+
"tscBin": "npx tsc",
|
|
42
|
+
"esbuildBin": "npx esbuild",
|
|
43
|
+
"devInvoker": "npx"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"bundlers": [
|
|
47
|
+
"auto",
|
|
48
|
+
"bun",
|
|
49
|
+
"tsc",
|
|
50
|
+
"esbuild"
|
|
51
|
+
],
|
|
22
52
|
"tmpWatchDefaults": {
|
|
23
53
|
"intervalMs": 500,
|
|
24
54
|
"minIntervalMs": 100,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import w from"node:path";import{packageRootDir as x}from"../../utils/package-root";import b from"./defaults.json" with { type: 'json' };import{seedFromTmp as j}from"../../utils/helpers/tmp/seed-from-tmp";export const packageDefaults=Object.freeze({...b,mainSourceFolder:j.sourceFolder,framework:j.framework,layoutPaths:Object.freeze({...j.layout}),brand:Object.freeze({...b.brand}),runtimes:Object.freeze(Object.fromEntries(Object.entries(b.runtimes).map(([n,q])=>[n,Object.freeze({...q})]))),bundlers:Object.freeze([...b.bundlers]),buildDefaults:Object.freeze({...b.buildDefaults}),tmpWatchDefaults:Object.freeze({...b.tmpWatchDefaults}),cliBinNames:Object.freeze([...b.cliBinNames??[b.cliName]])}),coreVersionPattern=/^\d{2}\.\d{2}\.\d{2}-v\d+$/,semverVersionPattern=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/;const z=`${packageDefaults.tmpBaseName}${packageDefaults.tmpExtension}`;export class Constants{static packageName=packageDefaults.packageName;static packageRootFolder=packageDefaults.packageRootFolder;static tmpBaseName=packageDefaults.tmpBaseName;static tmpExtension=packageDefaults.tmpExtension;static publicFolderName=packageDefaults.publicFolderName;static kafkaLogsTopic=packageDefaults.kafkaLogsTopic;static templateRepoUri=packageDefaults.templateRepoUri;static cliName=packageDefaults.cliName;static cliBinNames=packageDefaults.cliBinNames;static pathAliasKey=packageDefaults.pathAliasKey;static brand=packageDefaults.brand;static mainSourceFolder=packageDefaults.mainSourceFolder;static framework=packageDefaults.framework;static layoutPaths=packageDefaults.layoutPaths;static cliBinFile=packageDefaults.cliBinFile;static logTag=packageDefaults.packageName;static bundledCoreTmpPath=w.join(x,packageDefaults.packageRootFolder,z)}export{seedFromTmp,loadSeedFromBundledTmp}from"../../utils/helpers/tmp/seed-from-tmp";
|