@xrystal/core 3.40.0 → 3.42.0
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 +7 -7
- package/package.json +1 -1
- package/x/bin/commands/doctor.mjs +4 -3
- package/x/bin/commands/hooks.mjs +2 -1
- package/x/bin/commands/release.mjs +2 -1
- package/x/bin/commands/tmp.mjs +2 -1
- package/x/bin/helpers/.generated/.generated-from +1 -0
- package/x/bin/helpers/.generated/seed-from-tmp.mjs +115 -0
- package/x/bin/helpers/.generated/tmp-schema.mjs +74 -13
- package/x/bin/helpers/banner.mjs +22 -20
- package/x/bin/helpers/build-config.mjs +7 -6
- package/x/bin/helpers/cli-help.mjs +3 -2
- package/x/bin/helpers/cli-identity.mjs +1 -1
- package/x/bin/helpers/package-defaults.mjs +14 -11
- package/x/bin/helpers/project-artifacts.mjs +90 -36
- package/x/bin/helpers/project-root.mjs +5 -5
- package/x/bin/helpers/seed-from-tmp.mjs +13 -48
- package/x/bin/helpers/tmp-config.mjs +2 -1
- package/x/bin/helpers/tmp-layout.mjs +13 -9
- package/x/bin/helpers/toolchain-config.mjs +4 -3
- package/x/bin/main-cli.js +1 -1
- package/x/bin/paths.mjs +13 -2
- package/x/bin/scripts/install-git-hooks.mjs +2 -1
- package/x/bin/scripts/publish-guard.mjs +36 -15
- package/x/bin/scripts/release-prepare.mjs +2 -2
- package/x/bin/scripts/sync-cli-defaults.mjs +10 -15
- package/x/dist/utils/constants/defaults.json +6 -0
- package/x/dist/utils/constants/index.d.ts +8 -2
- package/x/dist/utils/constants/index.js +1 -1
- package/x/dist/utils/helpers/core/tmp-layout.js +1 -1
- package/x/dist/utils/helpers/tmp/index.d.ts +1 -1
- package/x/dist/utils/helpers/tmp/index.js +1 -1
- package/x/dist/utils/helpers/tmp/path-normalize.d.ts +3 -5
- package/x/dist/utils/helpers/tmp/path-normalize.js +1 -1
- package/x/dist/utils/helpers/tmp/seed-from-tmp.d.ts +3 -0
- package/x/dist/utils/helpers/tmp/seed-from-tmp.js +1 -1
- package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +0 -4
- package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -1
- package/x/dist/utils/models/classes/class.x.js +1 -1
- package/x/bin/helpers/defaults.json +0 -28
package/README.md
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
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.
|
|
6
|
+
**CLI:** `xry` · **Version:** `3.42.0` · [npm](https://www.npmjs.com/package/@xrystal/core)
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
## What's new in 3.
|
|
10
|
+
## What's new in 3.42.0 / 3.42.0'da ne değişti
|
|
11
11
|
|
|
12
12
|
| Change / Değişiklik | EN | TR |
|
|
13
13
|
|---------------------|----|----|
|
|
14
|
-
| **Single
|
|
15
|
-
|
|
|
16
|
-
| **
|
|
17
|
-
|
|
|
14
|
+
| **Single config pipeline** | Author `source/.../defaults.json` + `x/tmp.yml`; build embeds into CLI `.generated` | Source config → build embed |
|
|
15
|
+
| **No helpers/defaults.json copy** | npm reads identity from generated seed bundle | Ayrı publish kopyası yok |
|
|
16
|
+
| **No hardcodes** | packageName / layout / brand from config seed | Hardcode yok |
|
|
17
|
+
| **CLI** | `xry` · `xry sync` | `xry` · `xry sync` |
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
npx xry sync # apply tmp.yml → tsconfig / bunfig aliases
|
|
@@ -81,7 +81,7 @@ npx xry sync # EN: tsconfig from tmp.yml · TR: tmp.yml → tsconfig
|
|
|
81
81
|
```json
|
|
82
82
|
{
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@xrystal/core": "^3.
|
|
84
|
+
"@xrystal/core": "^3.42.0",
|
|
85
85
|
"elysia": "^1.4.19"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import { listRuntimeInventory, resolveRuntimeInfo } from '../helpers/runtime-inf
|
|
|
13
13
|
import { evaluateVersionBump, getVersionState, resolveCommitVersionHint, resolveVersionBaseline, VERSION_PATTERN } from '../scripts/version-check.mjs'
|
|
14
14
|
import { auditTsconfigAlignment, resolveToolchainPathsFromProject } from '../helpers/toolchain-config.mjs'
|
|
15
15
|
import { isGitHookInstalled } from '../scripts/install-git-hooks.mjs'
|
|
16
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
16
17
|
|
|
17
18
|
function statusValue(value, okLabel = null) {
|
|
18
19
|
if (value == null || value === '') return chalk.gray('—')
|
|
@@ -26,7 +27,7 @@ function printSection(title) {
|
|
|
26
27
|
export function registerDoctorCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
27
28
|
cli
|
|
28
29
|
.command('doctor')
|
|
29
|
-
.description(
|
|
30
|
+
.description(`Check runtime, git, and ${packageDefaults.packageName} alignment`)
|
|
30
31
|
.action(async () => {
|
|
31
32
|
const root = getProjectRoot()
|
|
32
33
|
const cliPkg = readCliPackageJson()
|
|
@@ -80,7 +81,7 @@ export function registerDoctorCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
printSection('CLI (tool)')
|
|
83
|
-
console.log(` ${
|
|
84
|
+
console.log(` ${packageDefaults.packageName.padEnd(18)}${chalk.bold(`${cliPkg.name}@${cliPkg.version}`)}`)
|
|
84
85
|
|
|
85
86
|
printSection('Package')
|
|
86
87
|
console.log(` ${'name'.padEnd(18)}${chalk.bold(projectPkg.name)}`)
|
|
@@ -101,7 +102,7 @@ export function registerDoctorCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
101
102
|
console.log(chalk.bold.red(' ⚠ CLI / node_modules version mismatch'))
|
|
102
103
|
console.log(chalk.yellow(` CLI (this binary): ${cliPkg.version}`))
|
|
103
104
|
console.log(chalk.yellow(` node_modules installed: ${core.installed}`))
|
|
104
|
-
console.log(chalk.gray(` fix: bun add
|
|
105
|
+
console.log(chalk.gray(` fix: bun add ${packageDefaults.packageName}@${cliPkg.version}`))
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
printSection('Git')
|
package/x/bin/commands/hooks.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
|
5
5
|
import { installGitHooks, isGitHookInstalled } from '../scripts/install-git-hooks.mjs'
|
|
6
6
|
import { getProjectRoot } from '../helpers/project-root.mjs'
|
|
7
7
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
8
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
8
9
|
|
|
9
10
|
export function registerHooksCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
10
11
|
const hooks = cli
|
|
@@ -45,7 +46,7 @@ export function registerHooksCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
45
46
|
|
|
46
47
|
hooks
|
|
47
48
|
.command('status')
|
|
48
|
-
.description(
|
|
49
|
+
.description(`Show whether ${packageDefaults.packageName} pre-commit hook is installed`)
|
|
49
50
|
.action(() => {
|
|
50
51
|
const root = getProjectRoot()
|
|
51
52
|
printCommandHeader({ cliName, command: 'hooks status', version: readCliPackageJson().version })
|
|
@@ -2,6 +2,7 @@ import chalk from 'chalk'
|
|
|
2
2
|
import { readCliPackageJson, readProjectPackageJson, getProjectRoot } from '../helpers/project-root.mjs'
|
|
3
3
|
import { compareSemver, getVersionState, resolveVersionBaseline, runTagRelease } from '../scripts/version-check.mjs'
|
|
4
4
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
5
6
|
|
|
6
7
|
export function registerTagCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
7
8
|
cli
|
|
@@ -41,7 +42,7 @@ export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
41
42
|
|
|
42
43
|
console.log(chalk.cyan(`\n${cliName} version\n`))
|
|
43
44
|
console.log(chalk.gray(' CLI (tool)'))
|
|
44
|
-
console.log(`
|
|
45
|
+
console.log(` ${packageDefaults.packageName}: ${chalk.bold(`${cliPkg.name}@${cliPkg.version}`)}`)
|
|
45
46
|
console.log('')
|
|
46
47
|
console.log(chalk.gray(' Project'))
|
|
47
48
|
console.log(` root: ${root}`)
|
package/x/bin/commands/tmp.mjs
CHANGED
|
@@ -13,11 +13,12 @@ import {
|
|
|
13
13
|
resolveTmpLayoutOrDefaults,
|
|
14
14
|
} from '../helpers/tmp-layout.mjs'
|
|
15
15
|
import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs'
|
|
16
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
16
17
|
|
|
17
18
|
export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
18
19
|
cli
|
|
19
20
|
.command('tmp')
|
|
20
|
-
.description(
|
|
21
|
+
.description(`Ensure tmp.yml exists (seed from ${packageDefaults.packageName})`)
|
|
21
22
|
.option('--dry-run', 'Show target path without writing')
|
|
22
23
|
.action((options) => {
|
|
23
24
|
const root = getProjectRoot()
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// source/utils/helpers/tmp/seed-from-tmp.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import yaml from "yaml";
|
|
6
|
+
// source/utils/constants/defaults.json
|
|
7
|
+
var defaults_default = {
|
|
8
|
+
packageName: "@xrystal/core",
|
|
9
|
+
packageRootFolder: "x",
|
|
10
|
+
cliName: "xry",
|
|
11
|
+
cliBinNames: [
|
|
12
|
+
"xry"
|
|
13
|
+
],
|
|
14
|
+
tmpBaseName: "tmp",
|
|
15
|
+
tmpExtension: ".yml",
|
|
16
|
+
templateRepoUri: "https://github.com/xdloper/api-gpt-svc",
|
|
17
|
+
publicFolderName: "public",
|
|
18
|
+
kafkaLogsTopic: "log",
|
|
19
|
+
pathAliasKey: "@/*",
|
|
20
|
+
eslintRestrictedImportDepth: 2,
|
|
21
|
+
brand: {
|
|
22
|
+
primary: "xrystal",
|
|
23
|
+
secondary: "core",
|
|
24
|
+
tagline: "microservice runtime library",
|
|
25
|
+
capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
|
|
26
|
+
},
|
|
27
|
+
tmpWatchDefaults: {
|
|
28
|
+
intervalMs: 500,
|
|
29
|
+
minIntervalMs: 100,
|
|
30
|
+
maxIntervalMs: 1e4
|
|
31
|
+
},
|
|
32
|
+
buildDefaults: {
|
|
33
|
+
tsconfig: "tsconfig.json",
|
|
34
|
+
typecheck: false,
|
|
35
|
+
tscLenient: false,
|
|
36
|
+
declarations: false,
|
|
37
|
+
sourcemap: false,
|
|
38
|
+
minify: false
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// source/utils/helpers/tmp/path-normalize.ts
|
|
43
|
+
function normalizeRootFolder(value, fallback) {
|
|
44
|
+
if (typeof value !== "string" || !value.trim())
|
|
45
|
+
return fallback;
|
|
46
|
+
return value.trim().replace(/^\.\/+/, "");
|
|
47
|
+
}
|
|
48
|
+
function normalizeSourceFolder(value, fallback) {
|
|
49
|
+
if (typeof value !== "string" || !value.trim())
|
|
50
|
+
return fallback;
|
|
51
|
+
const trimmed = value.trim();
|
|
52
|
+
if (trimmed.startsWith("./") || trimmed.startsWith("../"))
|
|
53
|
+
return trimmed;
|
|
54
|
+
return `./${trimmed}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// source/utils/helpers/tmp/seed-from-tmp.ts
|
|
58
|
+
var here = path.dirname(fileURLToPath(import.meta.url));
|
|
59
|
+
var tmpFileName = `${defaults_default.tmpBaseName}${defaults_default.tmpExtension}`;
|
|
60
|
+
function requireString(value, label) {
|
|
61
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
62
|
+
throw new Error(`${defaults_default.packageName}: bundled tmp.yml missing ${label}`);
|
|
63
|
+
}
|
|
64
|
+
return value.trim();
|
|
65
|
+
}
|
|
66
|
+
function readLayoutFromSpecial(special) {
|
|
67
|
+
const block = special && typeof special === "object" && !Array.isArray(special) ? special : {};
|
|
68
|
+
return {
|
|
69
|
+
tests: requireString(block.tests, "configs.service.paths.special.tests"),
|
|
70
|
+
environments: requireString(block.environments, "configs.service.paths.special.environments"),
|
|
71
|
+
dist: requireString(block.dist, "configs.service.paths.special.dist")
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function findBundledTmpFile(explicit) {
|
|
75
|
+
if (explicit) {
|
|
76
|
+
if (!fs.existsSync(explicit)) {
|
|
77
|
+
throw new Error(`${defaults_default.packageName}: bundled tmp.yml missing at ${explicit}`);
|
|
78
|
+
}
|
|
79
|
+
return explicit;
|
|
80
|
+
}
|
|
81
|
+
const starts = [here, process.cwd()];
|
|
82
|
+
for (const start of starts) {
|
|
83
|
+
let dir = path.resolve(start);
|
|
84
|
+
for (;; ) {
|
|
85
|
+
const candidate = path.join(dir, defaults_default.packageRootFolder, tmpFileName);
|
|
86
|
+
if (fs.existsSync(candidate))
|
|
87
|
+
return candidate;
|
|
88
|
+
const parent = path.dirname(dir);
|
|
89
|
+
if (parent === dir)
|
|
90
|
+
break;
|
|
91
|
+
dir = parent;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`${defaults_default.packageName}: bundled ${defaults_default.packageRootFolder}/${tmpFileName} not found from ${here}`);
|
|
95
|
+
}
|
|
96
|
+
function loadSeedFromBundledTmp(tmpFilePath) {
|
|
97
|
+
const file = findBundledTmpFile(tmpFilePath);
|
|
98
|
+
const doc = yaml.parse(fs.readFileSync(file, "utf8"));
|
|
99
|
+
const configs = doc?.configs && typeof doc.configs === "object" ? doc.configs : {};
|
|
100
|
+
const service = configs.service && typeof configs.service === "object" ? configs.service : {};
|
|
101
|
+
const paths = service.paths && typeof service.paths === "object" ? service.paths : {};
|
|
102
|
+
const sourceRaw = requireString(paths.source, "configs.service.paths.source");
|
|
103
|
+
return {
|
|
104
|
+
rootFolder: normalizeRootFolder(paths.root, defaults_default.packageRootFolder),
|
|
105
|
+
sourceFolder: normalizeSourceFolder(sourceRaw, sourceRaw),
|
|
106
|
+
framework: requireString(service.framework, "configs.service.framework"),
|
|
107
|
+
layout: readLayoutFromSpecial(paths.special)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
var seedFromTmp = loadSeedFromBundledTmp();
|
|
111
|
+
export {
|
|
112
|
+
seedFromTmp,
|
|
113
|
+
defaults_default as packageIdentityDefaults,
|
|
114
|
+
loadSeedFromBundledTmp
|
|
115
|
+
};
|
|
@@ -13,6 +13,12 @@ var defaults_default = {
|
|
|
13
13
|
kafkaLogsTopic: "log",
|
|
14
14
|
pathAliasKey: "@/*",
|
|
15
15
|
eslintRestrictedImportDepth: 2,
|
|
16
|
+
brand: {
|
|
17
|
+
primary: "xrystal",
|
|
18
|
+
secondary: "core",
|
|
19
|
+
tagline: "microservice runtime library",
|
|
20
|
+
capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
|
|
21
|
+
},
|
|
16
22
|
tmpWatchDefaults: {
|
|
17
23
|
intervalMs: 500,
|
|
18
24
|
minIntervalMs: 100,
|
|
@@ -28,18 +34,19 @@ var defaults_default = {
|
|
|
28
34
|
}
|
|
29
35
|
};
|
|
30
36
|
|
|
37
|
+
// source/utils/helpers/tmp/seed-from-tmp.ts
|
|
38
|
+
import fs from "node:fs";
|
|
39
|
+
import path from "node:path";
|
|
40
|
+
import { fileURLToPath } from "node:url";
|
|
41
|
+
import yaml from "yaml";
|
|
42
|
+
|
|
31
43
|
// source/utils/helpers/tmp/path-normalize.ts
|
|
32
|
-
|
|
33
|
-
tests: "tests",
|
|
34
|
-
environments: "environments",
|
|
35
|
-
dist: "dist"
|
|
36
|
-
});
|
|
37
|
-
function normalizeRootFolder(value, fallback = "x") {
|
|
44
|
+
function normalizeRootFolder(value, fallback) {
|
|
38
45
|
if (typeof value !== "string" || !value.trim())
|
|
39
46
|
return fallback;
|
|
40
47
|
return value.trim().replace(/^\.\/+/, "");
|
|
41
48
|
}
|
|
42
|
-
function normalizeSourceFolder(value, fallback
|
|
49
|
+
function normalizeSourceFolder(value, fallback) {
|
|
43
50
|
if (typeof value !== "string" || !value.trim())
|
|
44
51
|
return fallback;
|
|
45
52
|
const trimmed = value.trim();
|
|
@@ -47,7 +54,7 @@ function normalizeSourceFolder(value, fallback = "./source") {
|
|
|
47
54
|
return trimmed;
|
|
48
55
|
return `./${trimmed}`;
|
|
49
56
|
}
|
|
50
|
-
function normalizeLayoutPaths(special, fallback
|
|
57
|
+
function normalizeLayoutPaths(special, fallback) {
|
|
51
58
|
const block = special && typeof special === "object" && !Array.isArray(special) ? special : {};
|
|
52
59
|
const pick = (key) => {
|
|
53
60
|
const raw = block[key];
|
|
@@ -60,8 +67,62 @@ function normalizeLayoutPaths(special, fallback = DEFAULT_LAYOUT_PATHS) {
|
|
|
60
67
|
};
|
|
61
68
|
}
|
|
62
69
|
|
|
70
|
+
// source/utils/helpers/tmp/seed-from-tmp.ts
|
|
71
|
+
var here = path.dirname(fileURLToPath(import.meta.url));
|
|
72
|
+
var tmpFileName = `${defaults_default.tmpBaseName}${defaults_default.tmpExtension}`;
|
|
73
|
+
function requireString(value, label) {
|
|
74
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
75
|
+
throw new Error(`${defaults_default.packageName}: bundled tmp.yml missing ${label}`);
|
|
76
|
+
}
|
|
77
|
+
return value.trim();
|
|
78
|
+
}
|
|
79
|
+
function readLayoutFromSpecial(special) {
|
|
80
|
+
const block = special && typeof special === "object" && !Array.isArray(special) ? special : {};
|
|
81
|
+
return {
|
|
82
|
+
tests: requireString(block.tests, "configs.service.paths.special.tests"),
|
|
83
|
+
environments: requireString(block.environments, "configs.service.paths.special.environments"),
|
|
84
|
+
dist: requireString(block.dist, "configs.service.paths.special.dist")
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function findBundledTmpFile(explicit) {
|
|
88
|
+
if (explicit) {
|
|
89
|
+
if (!fs.existsSync(explicit)) {
|
|
90
|
+
throw new Error(`${defaults_default.packageName}: bundled tmp.yml missing at ${explicit}`);
|
|
91
|
+
}
|
|
92
|
+
return explicit;
|
|
93
|
+
}
|
|
94
|
+
const starts = [here, process.cwd()];
|
|
95
|
+
for (const start of starts) {
|
|
96
|
+
let dir = path.resolve(start);
|
|
97
|
+
for (;; ) {
|
|
98
|
+
const candidate = path.join(dir, defaults_default.packageRootFolder, tmpFileName);
|
|
99
|
+
if (fs.existsSync(candidate))
|
|
100
|
+
return candidate;
|
|
101
|
+
const parent = path.dirname(dir);
|
|
102
|
+
if (parent === dir)
|
|
103
|
+
break;
|
|
104
|
+
dir = parent;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
throw new Error(`${defaults_default.packageName}: bundled ${defaults_default.packageRootFolder}/${tmpFileName} not found from ${here}`);
|
|
108
|
+
}
|
|
109
|
+
function loadSeedFromBundledTmp(tmpFilePath) {
|
|
110
|
+
const file = findBundledTmpFile(tmpFilePath);
|
|
111
|
+
const doc = yaml.parse(fs.readFileSync(file, "utf8"));
|
|
112
|
+
const configs = doc?.configs && typeof doc.configs === "object" ? doc.configs : {};
|
|
113
|
+
const service = configs.service && typeof configs.service === "object" ? configs.service : {};
|
|
114
|
+
const paths = service.paths && typeof service.paths === "object" ? service.paths : {};
|
|
115
|
+
const sourceRaw = requireString(paths.source, "configs.service.paths.source");
|
|
116
|
+
return {
|
|
117
|
+
rootFolder: normalizeRootFolder(paths.root, defaults_default.packageRootFolder),
|
|
118
|
+
sourceFolder: normalizeSourceFolder(sourceRaw, sourceRaw),
|
|
119
|
+
framework: requireString(service.framework, "configs.service.framework"),
|
|
120
|
+
layout: readLayoutFromSpecial(paths.special)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
var seedFromTmp = loadSeedFromBundledTmp();
|
|
124
|
+
|
|
63
125
|
// source/utils/helpers/tmp/tmp-schema.ts
|
|
64
|
-
var BOOTSTRAP_SOURCE = "./source";
|
|
65
126
|
function isRecord(value) {
|
|
66
127
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
67
128
|
}
|
|
@@ -74,7 +135,7 @@ function normalizeRootFolder2(value) {
|
|
|
74
135
|
return normalizeRootFolder(value, defaults_default.packageRootFolder);
|
|
75
136
|
}
|
|
76
137
|
function normalizeSourceFolder2(value) {
|
|
77
|
-
return normalizeSourceFolder(value,
|
|
138
|
+
return normalizeSourceFolder(value, seedFromTmp.sourceFolder);
|
|
78
139
|
}
|
|
79
140
|
function readTmpCoreBlock(configs) {
|
|
80
141
|
const core = isRecord(configs?.core) ? configs.core : {};
|
|
@@ -116,16 +177,16 @@ function readTmpServiceBlock(configs) {
|
|
|
116
177
|
};
|
|
117
178
|
}
|
|
118
179
|
function resolveServiceLayoutPaths(service) {
|
|
119
|
-
return normalizeLayoutPaths(service.paths?.special,
|
|
180
|
+
return normalizeLayoutPaths(service.paths?.special, seedFromTmp.layout);
|
|
120
181
|
}
|
|
121
182
|
function buildNormalizedService(service) {
|
|
122
183
|
const layoutPaths = resolveServiceLayoutPaths(service);
|
|
123
184
|
return {
|
|
124
185
|
name: service.name,
|
|
125
|
-
framework: service.framework ??
|
|
186
|
+
framework: service.framework ?? seedFromTmp.framework,
|
|
126
187
|
paths: {
|
|
127
188
|
root: service.paths?.root ?? defaults_default.packageRootFolder,
|
|
128
|
-
source: service.paths?.source ??
|
|
189
|
+
source: service.paths?.source ?? seedFromTmp.sourceFolder,
|
|
129
190
|
special: layoutPaths
|
|
130
191
|
},
|
|
131
192
|
protocols: service.protocols,
|
package/x/bin/helpers/banner.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CLI_BIN_NAMES,
|
|
5
|
+
CLI_PRIMARY_NAME,
|
|
6
|
+
packageDefaults,
|
|
7
|
+
} from './package-defaults.mjs'
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
const XRYSTAL_LINES = [
|
|
9
|
+
const WORDMARK_PRIMARY = [
|
|
7
10
|
' _ _ ',
|
|
8
11
|
' __ ___ __ _ _ ___| |_ __ _| |',
|
|
9
12
|
" \\ \\/ / '__| | | / __| __/ _` | |",
|
|
@@ -12,7 +15,7 @@ const XRYSTAL_LINES = [
|
|
|
12
15
|
' |___/ ',
|
|
13
16
|
]
|
|
14
17
|
|
|
15
|
-
const
|
|
18
|
+
const WORDMARK_SECONDARY = [
|
|
16
19
|
'',
|
|
17
20
|
' ___ ___ _ __ ___ ',
|
|
18
21
|
" / __/ _ \\| '__/ _ \\",
|
|
@@ -21,43 +24,46 @@ const CORE_LINES = [
|
|
|
21
24
|
'',
|
|
22
25
|
]
|
|
23
26
|
|
|
24
|
-
const WORDMARK_WIDTH = Math.max(...
|
|
27
|
+
const WORDMARK_WIDTH = Math.max(...WORDMARK_PRIMARY.map((line) => line.length))
|
|
25
28
|
const BIN_ALIASES_LABEL = CLI_BIN_NAMES.join(' · ')
|
|
29
|
+
|
|
30
|
+
function brand() {
|
|
31
|
+
return packageDefaults.brand
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
export function printWordmark() {
|
|
27
|
-
const rows = Math.max(
|
|
35
|
+
const rows = Math.max(WORDMARK_PRIMARY.length, WORDMARK_SECONDARY.length)
|
|
28
36
|
for (let i = 0; i < rows; i += 1) {
|
|
29
|
-
const left = (
|
|
30
|
-
const right =
|
|
37
|
+
const left = (WORDMARK_PRIMARY[i] ?? '').padEnd(WORDMARK_WIDTH)
|
|
38
|
+
const right = WORDMARK_SECONDARY[i] ?? ''
|
|
31
39
|
console.log(` ${chalk.bold.white(left)}${chalk.bold.magenta(right)}`)
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
export function brandTitle() {
|
|
36
|
-
|
|
44
|
+
const { primary, secondary } = brand()
|
|
45
|
+
return `${chalk.bold.white(`${primary} `)}${chalk.bold.magenta(secondary)}`
|
|
37
46
|
}
|
|
38
47
|
|
|
39
|
-
/** Full banner — bare `xry` / `xry -h` (root help). */
|
|
40
48
|
export function printBanner({ version, runtimeName, invokedAs } = {}) {
|
|
41
49
|
const bin = invokedAs && invokedAs !== 'main-cli.js' ? invokedAs : CLI_PRIMARY_NAME
|
|
42
50
|
const versionLabel = version ? chalk.bold.green(`v${version}`) : chalk.gray('v?')
|
|
43
51
|
const runtimeLabel = runtimeName ? chalk.bold.white(runtimeName) : ''
|
|
52
|
+
const { tagline, capabilities } = brand()
|
|
44
53
|
|
|
45
54
|
console.log('')
|
|
46
|
-
|
|
47
55
|
printWordmark()
|
|
48
56
|
console.log('')
|
|
49
|
-
console.log(chalk.bold.gray(
|
|
50
|
-
|
|
57
|
+
console.log(chalk.bold.gray(` ${tagline}`))
|
|
51
58
|
console.log('')
|
|
52
59
|
console.log(
|
|
53
|
-
` ${chalk.bold.cyan(bin)} ${chalk.gray('·')} ${chalk.bold(
|
|
60
|
+
` ${chalk.bold.cyan(bin)} ${chalk.gray('·')} ${chalk.bold(packageDefaults.packageName)} ${versionLabel}${runtimeLabel ? ` ${chalk.gray('·')} ${runtimeLabel}` : ''}`,
|
|
54
61
|
)
|
|
55
|
-
console.log(chalk.bold.gray(
|
|
62
|
+
console.log(chalk.bold.gray(` ${capabilities}`))
|
|
56
63
|
console.log(chalk.dim(` cli: ${BIN_ALIASES_LABEL}`))
|
|
57
64
|
console.log('')
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
/** One-line header for subcommands (build, dev, doctor, …). */
|
|
61
67
|
export function printCommandHeader({ cliName, command, version } = {}) {
|
|
62
68
|
const label = cliName || CLI_PRIMARY_NAME
|
|
63
69
|
const versionLabel = version ? chalk.green(`v${version}`) : ''
|
|
@@ -67,10 +73,6 @@ export function printCommandHeader({ cliName, command, version } = {}) {
|
|
|
67
73
|
)
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
/**
|
|
71
|
-
* Root banner: bare CLI, or root-level -h / --help / help.
|
|
72
|
-
* Subcommands keep compact headers only.
|
|
73
|
-
*/
|
|
74
76
|
export function shouldShowBanner(argv = process.argv) {
|
|
75
77
|
const args = argv.slice(2)
|
|
76
78
|
if (!args.length) return true
|
|
@@ -285,19 +285,20 @@ export function resolveEffectiveBuildOptions(root, layout, buildConfig = {}) {
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
export function resolveCoreBuildSteps(root, distRel, buildConfig = {}) {
|
|
288
|
-
const tsconfigRel = resolveTsconfigRel(root, buildConfig) ??
|
|
288
|
+
const tsconfigRel = resolveTsconfigRel(root, buildConfig) ?? packageDefaults.buildDefaults.tsconfig
|
|
289
|
+
const scripts = `node ${packageDefaults.packageRootFolder}/bin/scripts`
|
|
289
290
|
const steps = [
|
|
290
|
-
|
|
291
|
+
`${scripts}/sync-cli-defaults.mjs`,
|
|
291
292
|
`rm -rf ${distRel}`,
|
|
292
293
|
`bun run tsc --project ${tsconfigRel}`,
|
|
293
294
|
`bunx tsc-alias -p ${tsconfigRel}`,
|
|
294
295
|
]
|
|
295
296
|
if (resolveMinifyEnabled(buildConfig)) {
|
|
296
|
-
steps.push(
|
|
297
|
+
steps.push(`${scripts}/minify-dist.mjs`)
|
|
297
298
|
}
|
|
298
|
-
steps.push(
|
|
299
|
-
steps.push(
|
|
300
|
-
steps.push(
|
|
299
|
+
steps.push(`${scripts}/fix-dist-imports.mjs`)
|
|
300
|
+
steps.push(`${scripts}/clean-dist-tests.mjs`)
|
|
301
|
+
steps.push(`${scripts}/clean-source-types.mjs`)
|
|
301
302
|
return steps
|
|
302
303
|
}
|
|
303
304
|
|
|
@@ -4,6 +4,7 @@ import { CLI_BIN_NAMES, CLI_PRIMARY_NAME } from './cli-identity.mjs'
|
|
|
4
4
|
|
|
5
5
|
export const LIST_BULLET = chalk.cyan('◆')
|
|
6
6
|
import { brandTitle } from './banner.mjs'
|
|
7
|
+
import { packageDefaults } from './package-defaults.mjs'
|
|
7
8
|
|
|
8
9
|
const QUICK_COMMANDS = [
|
|
9
10
|
{ cmd: 'create', hint: '<name> [path]', desc: 'Scaffold service · path defaults to cwd' },
|
|
@@ -36,7 +37,7 @@ const COMMAND_GROUPS = [
|
|
|
36
37
|
{
|
|
37
38
|
title: 'Diagnostics',
|
|
38
39
|
items: [
|
|
39
|
-
{ cmd: 'doctor', desc:
|
|
40
|
+
{ cmd: 'doctor', desc: `Runtime · git · ${packageDefaults.packageName} version alignment` },
|
|
40
41
|
{ cmd: 'version', desc: 'CLI tool vs project package.json versions' },
|
|
41
42
|
],
|
|
42
43
|
},
|
|
@@ -85,7 +86,7 @@ export function printQuickStartGuide({ cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
85
86
|
|
|
86
87
|
function formatOptionsSection(cliName) {
|
|
87
88
|
const items = [
|
|
88
|
-
{ cmd: '-V, --version', desc:
|
|
89
|
+
{ cmd: '-V, --version', desc: `Show ${packageDefaults.packageName} CLI version` },
|
|
89
90
|
{ cmd: '-h, --help', desc: 'Show full command list' },
|
|
90
91
|
]
|
|
91
92
|
const lines = [
|
|
@@ -2,39 +2,42 @@ import fs from 'node:fs'
|
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
loadSeedLayoutFromBundledTmp,
|
|
7
|
+
packageIdentityDefaults,
|
|
8
|
+
} from './seed-from-tmp.mjs'
|
|
6
9
|
|
|
7
10
|
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
8
11
|
const packageRoot = path.resolve(here, '..', '..', '..')
|
|
9
12
|
|
|
10
13
|
const AUTHORED_DEFAULTS = path.join(packageRoot, 'source', 'utils', 'constants', 'defaults.json')
|
|
11
|
-
const PUBLISHED_DEFAULTS = path.join(here, 'defaults.json')
|
|
12
14
|
|
|
13
15
|
function loadRawDefaults() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
if (fs.existsSync(AUTHORED_DEFAULTS)) {
|
|
17
|
+
return JSON.parse(fs.readFileSync(AUTHORED_DEFAULTS, 'utf8'))
|
|
18
|
+
}
|
|
19
|
+
if (packageIdentityDefaults && typeof packageIdentityDefaults === 'object') {
|
|
20
|
+
return packageIdentityDefaults
|
|
16
21
|
}
|
|
17
22
|
throw new Error(
|
|
18
|
-
|
|
23
|
+
`package defaults missing. Expected authored ${AUTHORED_DEFAULTS} or embedded packageIdentityDefaults`,
|
|
19
24
|
)
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
const raw = loadRawDefaults()
|
|
23
28
|
const seed = loadSeedLayoutFromBundledTmp(packageRoot, raw)
|
|
24
29
|
|
|
25
|
-
/**
|
|
26
|
-
* defaults.json → package identity + CLI + build flags
|
|
27
|
-
* helpers/seed-from-tmp → layout from bundled x/tmp.yml
|
|
28
|
-
*/
|
|
29
30
|
export const packageDefaults = Object.freeze({
|
|
30
31
|
...raw,
|
|
31
32
|
mainSourceFolder: seed.mainSourceFolder,
|
|
33
|
+
framework: seed.framework,
|
|
32
34
|
layoutPaths: seed.layoutPaths,
|
|
35
|
+
brand: Object.freeze({ ...(raw.brand ?? {}) }),
|
|
33
36
|
buildDefaults: Object.freeze({ ...(raw.buildDefaults ?? {}) }),
|
|
34
37
|
tmpWatchDefaults: Object.freeze({ ...(raw.tmpWatchDefaults ?? {}) }),
|
|
35
38
|
cliBinNames: Object.freeze([...(raw.cliBinNames ?? [raw.cliName])]),
|
|
36
|
-
pathAliasKey: raw.pathAliasKey
|
|
37
|
-
eslintRestrictedImportDepth: raw.eslintRestrictedImportDepth
|
|
39
|
+
pathAliasKey: raw.pathAliasKey,
|
|
40
|
+
eslintRestrictedImportDepth: raw.eslintRestrictedImportDepth,
|
|
38
41
|
})
|
|
39
42
|
|
|
40
43
|
export const coreVersionPattern = /^\d{2}\.\d{2}\.\d{2}-v\d+$/
|