@xrystal/core 3.41.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/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 +6 -0
- package/x/bin/helpers/banner.mjs +21 -20
- package/x/bin/helpers/build-config.mjs +7 -6
- package/x/bin/helpers/cli-identity.mjs +1 -1
- package/x/bin/helpers/package-defaults.mjs +11 -5
- package/x/bin/helpers/project-artifacts.mjs +89 -35
- package/x/bin/helpers/project-root.mjs +1 -1
- package/x/bin/helpers/seed-from-tmp.mjs +12 -64
- package/x/bin/helpers/tmp-layout.mjs +8 -4
- package/x/bin/helpers/toolchain-config.mjs +2 -1
- package/x/bin/paths.mjs +13 -2
- package/x/bin/scripts/publish-guard.mjs +36 -15
- 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 +7 -0
- package/x/dist/utils/constants/index.js +1 -1
- package/x/dist/utils/helpers/tmp/seed-from-tmp.d.ts +2 -0
- package/x/dist/utils/helpers/tmp/seed-from-tmp.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
|
-
| **
|
|
15
|
-
| **
|
|
16
|
-
|
|
|
17
|
-
| **CLI** |
|
|
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
|
@@ -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,
|
package/x/bin/helpers/banner.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
CLI_BIN_NAMES,
|
|
5
|
+
CLI_PRIMARY_NAME,
|
|
6
|
+
packageDefaults,
|
|
7
|
+
} from './package-defaults.mjs'
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
const XRYSTAL_LINES = [
|
|
9
|
+
const WORDMARK_PRIMARY = [
|
|
8
10
|
' _ _ ',
|
|
9
11
|
' __ ___ __ _ _ ___| |_ __ _| |',
|
|
10
12
|
" \\ \\/ / '__| | | / __| __/ _` | |",
|
|
@@ -13,7 +15,7 @@ const XRYSTAL_LINES = [
|
|
|
13
15
|
' |___/ ',
|
|
14
16
|
]
|
|
15
17
|
|
|
16
|
-
const
|
|
18
|
+
const WORDMARK_SECONDARY = [
|
|
17
19
|
'',
|
|
18
20
|
' ___ ___ _ __ ___ ',
|
|
19
21
|
" / __/ _ \\| '__/ _ \\",
|
|
@@ -22,43 +24,46 @@ const CORE_LINES = [
|
|
|
22
24
|
'',
|
|
23
25
|
]
|
|
24
26
|
|
|
25
|
-
const WORDMARK_WIDTH = Math.max(...
|
|
27
|
+
const WORDMARK_WIDTH = Math.max(...WORDMARK_PRIMARY.map((line) => line.length))
|
|
26
28
|
const BIN_ALIASES_LABEL = CLI_BIN_NAMES.join(' · ')
|
|
29
|
+
|
|
30
|
+
function brand() {
|
|
31
|
+
return packageDefaults.brand
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
export function printWordmark() {
|
|
28
|
-
const rows = Math.max(
|
|
35
|
+
const rows = Math.max(WORDMARK_PRIMARY.length, WORDMARK_SECONDARY.length)
|
|
29
36
|
for (let i = 0; i < rows; i += 1) {
|
|
30
|
-
const left = (
|
|
31
|
-
const right =
|
|
37
|
+
const left = (WORDMARK_PRIMARY[i] ?? '').padEnd(WORDMARK_WIDTH)
|
|
38
|
+
const right = WORDMARK_SECONDARY[i] ?? ''
|
|
32
39
|
console.log(` ${chalk.bold.white(left)}${chalk.bold.magenta(right)}`)
|
|
33
40
|
}
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
export function brandTitle() {
|
|
37
|
-
|
|
44
|
+
const { primary, secondary } = brand()
|
|
45
|
+
return `${chalk.bold.white(`${primary} `)}${chalk.bold.magenta(secondary)}`
|
|
38
46
|
}
|
|
39
47
|
|
|
40
|
-
/** Full banner — bare `xry` / `xry -h` (root help). */
|
|
41
48
|
export function printBanner({ version, runtimeName, invokedAs } = {}) {
|
|
42
49
|
const bin = invokedAs && invokedAs !== 'main-cli.js' ? invokedAs : CLI_PRIMARY_NAME
|
|
43
50
|
const versionLabel = version ? chalk.bold.green(`v${version}`) : chalk.gray('v?')
|
|
44
51
|
const runtimeLabel = runtimeName ? chalk.bold.white(runtimeName) : ''
|
|
52
|
+
const { tagline, capabilities } = brand()
|
|
45
53
|
|
|
46
54
|
console.log('')
|
|
47
|
-
|
|
48
55
|
printWordmark()
|
|
49
56
|
console.log('')
|
|
50
|
-
console.log(chalk.bold.gray(
|
|
51
|
-
|
|
57
|
+
console.log(chalk.bold.gray(` ${tagline}`))
|
|
52
58
|
console.log('')
|
|
53
59
|
console.log(
|
|
54
60
|
` ${chalk.bold.cyan(bin)} ${chalk.gray('·')} ${chalk.bold(packageDefaults.packageName)} ${versionLabel}${runtimeLabel ? ` ${chalk.gray('·')} ${runtimeLabel}` : ''}`,
|
|
55
61
|
)
|
|
56
|
-
console.log(chalk.bold.gray(
|
|
62
|
+
console.log(chalk.bold.gray(` ${capabilities}`))
|
|
57
63
|
console.log(chalk.dim(` cli: ${BIN_ALIASES_LABEL}`))
|
|
58
64
|
console.log('')
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
/** One-line header for subcommands (build, dev, doctor, …). */
|
|
62
67
|
export function printCommandHeader({ cliName, command, version } = {}) {
|
|
63
68
|
const label = cliName || CLI_PRIMARY_NAME
|
|
64
69
|
const versionLabel = version ? chalk.green(`v${version}`) : ''
|
|
@@ -68,10 +73,6 @@ export function printCommandHeader({ cliName, command, version } = {}) {
|
|
|
68
73
|
)
|
|
69
74
|
}
|
|
70
75
|
|
|
71
|
-
/**
|
|
72
|
-
* Root banner: bare CLI, or root-level -h / --help / help.
|
|
73
|
-
* Subcommands keep compact headers only.
|
|
74
|
-
*/
|
|
75
76
|
export function shouldShowBanner(argv = process.argv) {
|
|
76
77
|
const args = argv.slice(2)
|
|
77
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
|
|
|
@@ -2,20 +2,25 @@ 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
|
-
`package defaults
|
|
23
|
+
`package defaults missing. Expected authored ${AUTHORED_DEFAULTS} or embedded packageIdentityDefaults`,
|
|
19
24
|
)
|
|
20
25
|
}
|
|
21
26
|
|
|
@@ -27,6 +32,7 @@ export const packageDefaults = Object.freeze({
|
|
|
27
32
|
mainSourceFolder: seed.mainSourceFolder,
|
|
28
33
|
framework: seed.framework,
|
|
29
34
|
layoutPaths: seed.layoutPaths,
|
|
35
|
+
brand: Object.freeze({ ...(raw.brand ?? {}) }),
|
|
30
36
|
buildDefaults: Object.freeze({ ...(raw.buildDefaults ?? {}) }),
|
|
31
37
|
tmpWatchDefaults: Object.freeze({ ...(raw.tmpWatchDefaults ?? {}) }),
|
|
32
38
|
cliBinNames: Object.freeze([...(raw.cliBinNames ?? [raw.cliName])]),
|
|
@@ -9,8 +9,18 @@ import { ensureTmpFile, relativeFromRoot } from './tmp-layout.mjs'
|
|
|
9
9
|
import { packageDefaults } from './package-defaults.mjs'
|
|
10
10
|
|
|
11
11
|
const CLI_BIN_DIR = path.dirname(fileURLToPath(import.meta.url))
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const CLI_GENERATED_DIR = path.join(CLI_BIN_DIR, '.generated')
|
|
13
|
+
|
|
14
|
+
const CLI_GENERATED_MODULES = [
|
|
15
|
+
{
|
|
16
|
+
source: 'source/utils/helpers/tmp/tmp-schema.ts',
|
|
17
|
+
outfile: path.join(CLI_GENERATED_DIR, 'tmp-schema.mjs'),
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
source: 'source/utils/helpers/tmp/seed-from-tmp.ts',
|
|
21
|
+
outfile: path.join(CLI_GENERATED_DIR, 'seed-from-tmp.mjs'),
|
|
22
|
+
},
|
|
23
|
+
]
|
|
14
24
|
|
|
15
25
|
const CORE_EXPORT_SUBPATHS = [
|
|
16
26
|
'utils',
|
|
@@ -56,11 +66,21 @@ export function buildCorePackageExports(distPrefix) {
|
|
|
56
66
|
return exports
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
function corePublishFilesStatic() {
|
|
70
|
+
const root = packageDefaults.packageRootFolder
|
|
71
|
+
const tmpName = `${packageDefaults.tmpBaseName}${packageDefaults.tmpExtension}`
|
|
72
|
+
return [
|
|
73
|
+
`${root}/bin`,
|
|
74
|
+
`${root}/${tmpName}`,
|
|
75
|
+
`${root}/assets`,
|
|
76
|
+
'tsconfig.base.json',
|
|
77
|
+
'README.md',
|
|
78
|
+
]
|
|
79
|
+
}
|
|
60
80
|
|
|
61
81
|
function normalizeFilesList(files, distRel) {
|
|
62
82
|
const distEntry = distRel.replace(/^\.\//, '')
|
|
63
|
-
const base = [...
|
|
83
|
+
const base = [...corePublishFilesStatic()]
|
|
64
84
|
if (!base.includes(distEntry)) base.unshift(distEntry)
|
|
65
85
|
return base
|
|
66
86
|
}
|
|
@@ -76,39 +96,74 @@ function stablePackageShape(pkg) {
|
|
|
76
96
|
}
|
|
77
97
|
|
|
78
98
|
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Defaults identity is authored at source/utils/constants/defaults.json.
|
|
101
|
+
* npm has no source/ — defaults are embedded into .generated/seed-from-tmp.mjs via bun build.
|
|
102
|
+
* This sync rebuilds generated CLI modules when authored defaults/seed sources change.
|
|
103
|
+
*/
|
|
104
|
+
export function syncCliDefaults(root = process.cwd(), { force = false } = {}) {
|
|
105
|
+
const authored = path.join(root, 'source/utils/constants/defaults.json')
|
|
106
|
+
const seedOut = path.join(CLI_GENERATED_DIR, 'seed-from-tmp.mjs')
|
|
107
|
+
const needs = force
|
|
108
|
+
|| !fs.existsSync(seedOut)
|
|
109
|
+
|| (fs.existsSync(authored) && fs.statSync(authored).mtimeMs > fs.statSync(seedOut).mtimeMs)
|
|
110
|
+
|
|
111
|
+
if (!needs) {
|
|
112
|
+
return { synced: false, reason: 'up-to-date', embeddedIn: seedOut }
|
|
113
|
+
}
|
|
90
114
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
115
|
+
const generated = syncCliGeneratedModules(root, { force: true })
|
|
116
|
+
return {
|
|
117
|
+
synced: generated.synced,
|
|
118
|
+
reason: 'embedded into .generated/seed-from-tmp.mjs',
|
|
119
|
+
embeddedIn: seedOut,
|
|
120
|
+
generated,
|
|
95
121
|
}
|
|
122
|
+
}
|
|
96
123
|
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
124
|
+
export function syncCliGeneratedModules(root = process.cwd(), { force = false } = {}) {
|
|
125
|
+
const results = []
|
|
126
|
+
fs.mkdirSync(CLI_GENERATED_DIR, { recursive: true })
|
|
127
|
+
|
|
128
|
+
for (const mod of CLI_GENERATED_MODULES) {
|
|
129
|
+
const srcAbs = path.join(root, mod.source)
|
|
130
|
+
if (!fs.existsSync(srcAbs)) {
|
|
131
|
+
results.push({ source: mod.source, synced: false, reason: 'missing source' })
|
|
132
|
+
continue
|
|
133
|
+
}
|
|
101
134
|
|
|
102
|
-
|
|
135
|
+
const needsSync = force
|
|
136
|
+
|| !fs.existsSync(mod.outfile)
|
|
137
|
+
|| fs.statSync(srcAbs).mtimeMs > fs.statSync(mod.outfile).mtimeMs
|
|
103
138
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
139
|
+
if (!needsSync) {
|
|
140
|
+
results.push({ source: mod.source, synced: false, reason: 'up-to-date', out: mod.outfile })
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
execSync(
|
|
145
|
+
`bun build "${srcAbs}" --outfile "${mod.outfile}" --target node --format esm --external yaml`,
|
|
146
|
+
{ cwd: root, stdio: 'pipe' },
|
|
147
|
+
)
|
|
148
|
+
results.push({ source: mod.source, synced: true, out: mod.outfile })
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const fromLines = CLI_GENERATED_MODULES.map((m) => m.source).join('\n')
|
|
152
|
+
fs.writeFileSync(path.join(CLI_GENERATED_DIR, '.generated-from'), `${fromLines}\n`)
|
|
153
|
+
return { synced: results.some((r) => r.synced), results }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** @deprecated use syncCliGeneratedModules */
|
|
157
|
+
export function syncCliTmpSchema(root = process.cwd(), options = {}) {
|
|
158
|
+
const result = syncCliGeneratedModules(root, options)
|
|
159
|
+
const schema = result.results.find((r) => r.source.includes('tmp-schema'))
|
|
160
|
+
return { synced: Boolean(schema?.synced), out: schema?.out, reason: schema?.reason }
|
|
161
|
+
}
|
|
110
162
|
|
|
111
|
-
|
|
163
|
+
export function syncCliRuntime(root = process.cwd(), { force = false } = {}) {
|
|
164
|
+
const defaults = syncCliDefaults(root, { force })
|
|
165
|
+
const generated = defaults.generated ?? syncCliGeneratedModules(root, { force })
|
|
166
|
+
return { defaults, generated }
|
|
112
167
|
}
|
|
113
168
|
|
|
114
169
|
export function syncPackageManifest(root = process.cwd(), { write = true } = {}) {
|
|
@@ -120,7 +175,7 @@ export function syncPackageManifest(root = process.cwd(), { write = true } = {})
|
|
|
120
175
|
}
|
|
121
176
|
|
|
122
177
|
const { distPrefix, distRel } = resolveDistLayout(root)
|
|
123
|
-
const binEntry =
|
|
178
|
+
const binEntry = `./${packageDefaults.packageRootFolder}/bin/main-cli.js`
|
|
124
179
|
const bin = Object.fromEntries(packageDefaults.cliBinNames.map((name) => [name, binEntry]))
|
|
125
180
|
|
|
126
181
|
const next = {
|
|
@@ -148,8 +203,7 @@ export function ensureProjectArtifacts(root = process.cwd(), options = {}) {
|
|
|
148
203
|
forceSchema = false,
|
|
149
204
|
} = options
|
|
150
205
|
|
|
151
|
-
const
|
|
152
|
-
const defaults = syncCliDefaults(root)
|
|
206
|
+
const { generated, defaults } = syncCliRuntime(root, { force: forceSchema })
|
|
153
207
|
const toolchain = syncProjectToolchain(root, { write: writeToolchain })
|
|
154
208
|
let manifest = { synced: false, reason: 'skipped' }
|
|
155
209
|
|
|
@@ -158,5 +212,5 @@ export function ensureProjectArtifacts(root = process.cwd(), options = {}) {
|
|
|
158
212
|
manifest = syncPackageManifest(root, { write: true })
|
|
159
213
|
}
|
|
160
214
|
|
|
161
|
-
return {
|
|
215
|
+
return { generated, defaults, toolchain, manifest }
|
|
162
216
|
}
|
|
@@ -52,7 +52,7 @@ export function getInstalledCoreVersion(root = resolveProjectRoot()) {
|
|
|
52
52
|
?? project.devDependencies?.[packageDefaults.packageName]
|
|
53
53
|
?? null
|
|
54
54
|
|
|
55
|
-
const installedPath = path.join(root, 'node_modules', '
|
|
55
|
+
const installedPath = path.join(root, 'node_modules', ...packageDefaults.packageName.split('/'), 'package.json')
|
|
56
56
|
if (!fs.existsSync(installedPath)) {
|
|
57
57
|
if (root === packageRoot) {
|
|
58
58
|
const cli = readCliPackageJson()
|
|
@@ -1,69 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
loadSeedFromBundledTmp,
|
|
3
|
+
seedFromTmp,
|
|
4
|
+
packageIdentityDefaults,
|
|
5
|
+
} from './.generated/seed-from-tmp.mjs'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function requireString(value, label) {
|
|
9
|
-
if (typeof value !== 'string' || !value.trim()) {
|
|
10
|
-
throw new Error(label)
|
|
11
|
-
}
|
|
12
|
-
return value.trim()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function normalizeRootFolder(value, fallback) {
|
|
16
|
-
if (typeof value !== 'string' || !value.trim()) return fallback
|
|
17
|
-
return value.trim().replace(/^\.\/+/, '')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function normalizeSourceFolder(value, packageName) {
|
|
21
|
-
const trimmed = requireString(value, `${packageName}: bundled tmp.yml missing configs.service.paths.source`)
|
|
22
|
-
if (trimmed.startsWith('./') || trimmed.startsWith('../')) return trimmed
|
|
23
|
-
return `./${trimmed}`
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function readLayout(special, packageName) {
|
|
27
|
-
const block = special && typeof special === 'object' && !Array.isArray(special) ? special : {}
|
|
28
|
-
const miss = (field) => `${packageName}: bundled tmp.yml missing configs.service.paths.special.${field}`
|
|
29
|
-
return Object.freeze({
|
|
30
|
-
tests: requireString(block.tests, miss('tests')),
|
|
31
|
-
environments: requireString(block.environments, miss('environments')),
|
|
32
|
-
dist: requireString(block.dist, miss('dist')),
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function findBundledTmpFile(packageRoot, raw) {
|
|
37
|
-
const packageName = requireString(raw.packageName, 'defaults.packageName required')
|
|
38
|
-
const rootFolder = requireString(raw.packageRootFolder, `${packageName}: defaults.packageRootFolder required`)
|
|
39
|
-
const tmpBase = requireString(raw.tmpBaseName, `${packageName}: defaults.tmpBaseName required`)
|
|
40
|
-
const tmpExt = requireString(raw.tmpExtension, `${packageName}: defaults.tmpExtension required`)
|
|
41
|
-
const tmpFileName = `${tmpBase}${tmpExt}`
|
|
42
|
-
const direct = path.join(packageRoot, rootFolder, tmpFileName)
|
|
43
|
-
if (fs.existsSync(direct)) return { file: direct, rootFolder, packageName }
|
|
44
|
-
|
|
45
|
-
let dir = path.resolve(here)
|
|
46
|
-
for (;;) {
|
|
47
|
-
const candidate = path.join(dir, rootFolder, tmpFileName)
|
|
48
|
-
if (fs.existsSync(candidate)) return { file: candidate, rootFolder, packageName }
|
|
49
|
-
const parent = path.dirname(dir)
|
|
50
|
-
if (parent === dir) break
|
|
51
|
-
dir = parent
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
throw new Error(`${packageName}: bundled ${rootFolder}/${tmpFileName} not found`)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function loadSeedLayoutFromBundledTmp(packageRoot, raw = {}) {
|
|
58
|
-
const { file, rootFolder, packageName } = findBundledTmpFile(packageRoot, raw)
|
|
59
|
-
const doc = yaml.parse(fs.readFileSync(file, 'utf8'))
|
|
60
|
-
const service = doc?.configs?.service ?? {}
|
|
61
|
-
const paths = service.paths ?? {}
|
|
7
|
+
export { loadSeedFromBundledTmp, seedFromTmp, packageIdentityDefaults }
|
|
62
8
|
|
|
9
|
+
export function loadSeedLayoutFromBundledTmp(_packageRoot = process.cwd(), _raw = {}) {
|
|
10
|
+
const seed = loadSeedFromBundledTmp()
|
|
63
11
|
return {
|
|
64
|
-
rootFolder:
|
|
65
|
-
mainSourceFolder:
|
|
66
|
-
framework:
|
|
67
|
-
layoutPaths:
|
|
12
|
+
rootFolder: seed.rootFolder,
|
|
13
|
+
mainSourceFolder: seed.sourceFolder,
|
|
14
|
+
framework: seed.framework,
|
|
15
|
+
layoutPaths: Object.freeze({ ...seed.layout }),
|
|
68
16
|
}
|
|
69
17
|
}
|
|
@@ -7,8 +7,6 @@ import { findAllFilesRecursively, findFileRecursively } from './index.mjs'
|
|
|
7
7
|
import { getBundledCoreTmpPath } from './project-root.mjs'
|
|
8
8
|
import { normalizeTmpDocument, normalizeRootFolder, normalizeSourceFolder, readTmpServiceBlock, resolveServiceLayoutPaths } from './tmp-schema.mjs'
|
|
9
9
|
|
|
10
|
-
const DEFAULT_PATHS = packageDefaults.layoutPaths
|
|
11
|
-
|
|
12
10
|
function formatTmpTarget(name, ext) {
|
|
13
11
|
return `${name}${ext.startsWith('.') ? ext : `.${ext}`}`
|
|
14
12
|
}
|
|
@@ -259,8 +257,14 @@ export function ensureTmpFile(projectRoot = process.cwd(), { patchServiceName =
|
|
|
259
257
|
: null
|
|
260
258
|
if (serviceName) {
|
|
261
259
|
const tmp = yaml.parse(content)
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
const configs = tmp.configs ?? {}
|
|
261
|
+
const service = configs.service
|
|
262
|
+
if (typeof service === 'object' && service !== null && !Array.isArray(service)) {
|
|
263
|
+
service.name = serviceName
|
|
264
|
+
} else {
|
|
265
|
+
configs.service = { name: serviceName }
|
|
266
|
+
}
|
|
267
|
+
tmp.configs = configs
|
|
264
268
|
content = yaml.stringify(tmp)
|
|
265
269
|
}
|
|
266
270
|
}
|
|
@@ -201,8 +201,9 @@ export function resolveCoreBuildEntries(root) {
|
|
|
201
201
|
const addEntry = (spec) => {
|
|
202
202
|
if (typeof spec !== 'string' || !spec) return
|
|
203
203
|
const normalized = spec.startsWith('./') ? spec : `./${spec}`
|
|
204
|
+
const sourcePrefix = String(packageDefaults.mainSourceFolder).replace(/^\.\//, '')
|
|
204
205
|
const tsPath = normalized
|
|
205
|
-
.replace(
|
|
206
|
+
.replace(new RegExp('^\\./[^/]+/dist/'), `./${sourcePrefix}/`)
|
|
206
207
|
.replace(/\.js$/, '.ts')
|
|
207
208
|
if (tsPath.endsWith('.ts') && fs.existsSync(path.join(root, tsPath))) {
|
|
208
209
|
entries.add(tsPath)
|
package/x/bin/paths.mjs
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import { fileURLToPath } from 'node:url'
|
|
3
3
|
|
|
4
|
+
import {
|
|
5
|
+
packageDefaults,
|
|
6
|
+
coreVersionPattern,
|
|
7
|
+
semverVersionPattern,
|
|
8
|
+
} from './helpers/package-defaults.mjs'
|
|
9
|
+
|
|
4
10
|
const binDir = path.dirname(fileURLToPath(import.meta.url))
|
|
5
11
|
|
|
6
12
|
export const packageRoot = path.resolve(binDir, '..', '..')
|
|
7
|
-
|
|
13
|
+
|
|
14
|
+
function stripDotSlash(value) {
|
|
15
|
+
return String(value ?? '').replace(/^\.\//, '')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const sourceDir = path.join(packageRoot, stripDotSlash(packageDefaults.mainSourceFolder))
|
|
8
19
|
|
|
9
20
|
export {
|
|
10
21
|
packageDefaults,
|
|
11
22
|
packageDefaults as Constants,
|
|
12
23
|
coreVersionPattern,
|
|
13
24
|
semverVersionPattern,
|
|
14
|
-
}
|
|
25
|
+
}
|
|
@@ -2,6 +2,8 @@ import { execSync } from 'node:child_process'
|
|
|
2
2
|
import fs from 'node:fs'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
|
|
5
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
6
|
+
|
|
5
7
|
export class PublishGuardError extends Error {
|
|
6
8
|
constructor(message) {
|
|
7
9
|
super(message)
|
|
@@ -9,6 +11,21 @@ export class PublishGuardError extends Error {
|
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
|
|
14
|
+
function distRelFromPackage(pkg) {
|
|
15
|
+
const main = String(pkg.main ?? '').replace(/^\.\//, '')
|
|
16
|
+
const match = main.match(/^(.+\/dist)\//)
|
|
17
|
+
if (match) return match[1]
|
|
18
|
+
return path.posix.join(packageDefaults.packageRootFolder, packageDefaults.layoutPaths.dist)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function resolveMainEntry(root, pkg) {
|
|
22
|
+
const main = String(pkg.main ?? '').replace(/^\.\//, '')
|
|
23
|
+
if (!main) {
|
|
24
|
+
throw new PublishGuardError('package.json main is empty')
|
|
25
|
+
}
|
|
26
|
+
return path.join(root, main)
|
|
27
|
+
}
|
|
28
|
+
|
|
12
29
|
export function readPackage(root = process.cwd()) {
|
|
13
30
|
return JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
|
|
14
31
|
}
|
|
@@ -26,22 +43,23 @@ export function assertFilesListNoSource(pkg) {
|
|
|
26
43
|
|
|
27
44
|
export function assertFilesListHasDist(pkg) {
|
|
28
45
|
const files = Array.isArray(pkg.files) ? pkg.files : []
|
|
46
|
+
const distRel = distRelFromPackage(pkg)
|
|
29
47
|
if (!files.some((entry) => String(entry).replace(/^\.\//, '').includes('dist'))) {
|
|
30
|
-
throw new PublishGuardError(
|
|
48
|
+
throw new PublishGuardError(`package.json files must include ${distRel}`)
|
|
31
49
|
}
|
|
32
50
|
}
|
|
33
51
|
|
|
34
52
|
export function assertMainExportsPointToDist(pkg) {
|
|
35
53
|
const main = String(pkg.main ?? '')
|
|
36
54
|
if (!main.includes('/dist/')) {
|
|
37
|
-
throw new PublishGuardError(`package.json main must point to
|
|
55
|
+
throw new PublishGuardError(`package.json main must point to dist (got ${main || 'empty'})`)
|
|
38
56
|
}
|
|
39
57
|
const exports = pkg.exports ?? {}
|
|
40
58
|
for (const [key, value] of Object.entries(exports)) {
|
|
41
59
|
if (key === './tsconfig.base.json') continue
|
|
42
60
|
const target = typeof value === 'string' ? value : value?.default
|
|
43
61
|
if (target && !String(target).includes('/dist/')) {
|
|
44
|
-
throw new PublishGuardError(`exports[${key}] must point to
|
|
62
|
+
throw new PublishGuardError(`exports[${key}] must point to dist (got ${target})`)
|
|
45
63
|
}
|
|
46
64
|
}
|
|
47
65
|
}
|
|
@@ -52,8 +70,8 @@ export function assertSourceAbsentOnDisk(root = process.cwd()) {
|
|
|
52
70
|
}
|
|
53
71
|
}
|
|
54
72
|
|
|
55
|
-
export function countDistJs(root = process.cwd()) {
|
|
56
|
-
const distDir = path.join(root,
|
|
73
|
+
export function countDistJs(root = process.cwd(), pkg = readPackage(root)) {
|
|
74
|
+
const distDir = path.join(root, distRelFromPackage(pkg))
|
|
57
75
|
if (!fs.existsSync(distDir)) return 0
|
|
58
76
|
let count = 0
|
|
59
77
|
const walk = (dir) => {
|
|
@@ -68,22 +86,25 @@ export function countDistJs(root = process.cwd()) {
|
|
|
68
86
|
}
|
|
69
87
|
|
|
70
88
|
export function assertDistTree(root = process.cwd(), minJs = 10) {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
89
|
+
const pkg = readPackage(root)
|
|
90
|
+
const entry = resolveMainEntry(root, pkg)
|
|
91
|
+
if (!fs.existsSync(entry)) {
|
|
92
|
+
throw new PublishGuardError(`${path.relative(root, entry) || entry} missing — run build first`)
|
|
74
93
|
}
|
|
75
|
-
const jsCount = countDistJs(root)
|
|
94
|
+
const jsCount = countDistJs(root, pkg)
|
|
76
95
|
if (jsCount < minJs) {
|
|
77
|
-
throw new PublishGuardError(`
|
|
96
|
+
throw new PublishGuardError(`dist incomplete (${jsCount} .js files, need >= ${minJs})`)
|
|
78
97
|
}
|
|
79
98
|
}
|
|
80
99
|
|
|
81
100
|
export function assertDistMinified(root = process.cwd()) {
|
|
82
|
-
const
|
|
101
|
+
const pkg = readPackage(root)
|
|
102
|
+
const entry = resolveMainEntry(root, pkg)
|
|
103
|
+
const indexJs = fs.readFileSync(entry, 'utf8')
|
|
83
104
|
const lines = indexJs.split('\n').filter((line) => line.trim().length > 0)
|
|
84
105
|
const looksReadable = lines.length > 3 && indexJs.includes("from './") && !indexJs.includes('from"')
|
|
85
106
|
if (looksReadable) {
|
|
86
|
-
throw new PublishGuardError(
|
|
107
|
+
throw new PublishGuardError(`${path.relative(root, entry)} looks unminified — enable build.minify before publish`)
|
|
87
108
|
}
|
|
88
109
|
}
|
|
89
110
|
|
|
@@ -92,8 +113,8 @@ export function assertNpmPackClean(root = process.cwd()) {
|
|
|
92
113
|
if (/source\/.*\.ts/.test(dryRun) || /npm notice.*source\//.test(dryRun)) {
|
|
93
114
|
throw new PublishGuardError('npm pack tarball lists source/ — TypeScript source must not ship')
|
|
94
115
|
}
|
|
95
|
-
if (
|
|
96
|
-
throw new PublishGuardError('npm pack tarball must include
|
|
116
|
+
if (!/\/dist\/.*\.js/.test(dryRun)) {
|
|
117
|
+
throw new PublishGuardError('npm pack tarball must include dist/**/*.js')
|
|
97
118
|
}
|
|
98
119
|
return dryRun
|
|
99
120
|
}
|
|
@@ -109,5 +130,5 @@ export function runPublishGuards(root = process.cwd(), { strictDisk = false } =
|
|
|
109
130
|
assertSourceAbsentOnDisk(root)
|
|
110
131
|
assertDistMinified(root)
|
|
111
132
|
}
|
|
112
|
-
return { pkg, jsCount: countDistJs(root) }
|
|
133
|
+
return { pkg, jsCount: countDistJs(root, pkg) }
|
|
113
134
|
}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
* Publish artifact only.
|
|
4
|
-
* Authoring source of truth: source/utils/constants/defaults.json
|
|
5
|
-
* Local CLI prefers the authored file; npm pack needs this copy under x/bin.
|
|
6
|
-
*/
|
|
7
|
-
import fs from 'node:fs'
|
|
8
|
-
import path from 'node:path'
|
|
2
|
+
import { syncCliRuntime } from '../helpers/project-artifacts.mjs'
|
|
9
3
|
|
|
10
4
|
const root = process.cwd()
|
|
11
|
-
const
|
|
12
|
-
const dest = path.join(root, 'x/bin/helpers/defaults.json')
|
|
5
|
+
const result = syncCliRuntime(root, { force: process.argv.includes('--force') })
|
|
13
6
|
|
|
14
|
-
if (
|
|
15
|
-
console.
|
|
16
|
-
|
|
7
|
+
if (result.defaults.synced) {
|
|
8
|
+
console.log(`sync-cli-defaults: ${result.defaults.reason}`)
|
|
9
|
+
} else {
|
|
10
|
+
console.log(`sync-cli-defaults: ${result.defaults.reason ?? 'ok'}`)
|
|
17
11
|
}
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
console.log(
|
|
13
|
+
for (const item of result.generated.results ?? []) {
|
|
14
|
+
const state = item.synced ? 'built' : (item.reason ?? 'ok')
|
|
15
|
+
console.log(`sync-cli-defaults: ${item.source} → ${state}`)
|
|
16
|
+
}
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
"kafkaLogsTopic": "log",
|
|
13
13
|
"pathAliasKey": "@/*",
|
|
14
14
|
"eslintRestrictedImportDepth": 2,
|
|
15
|
+
"brand": {
|
|
16
|
+
"primary": "xrystal",
|
|
17
|
+
"secondary": "core",
|
|
18
|
+
"tagline": "microservice runtime library",
|
|
19
|
+
"capabilities": "loaders \u00b7 tmp.yml \u00b7 dto \u00b7 i18n \u00b7 multi-protocol \u00b7 scaffold"
|
|
20
|
+
},
|
|
15
21
|
"tmpWatchDefaults": {
|
|
16
22
|
"intervalMs": 500,
|
|
17
23
|
"minIntervalMs": 100,
|
|
@@ -23,7 +23,14 @@ export declare class Constants {
|
|
|
23
23
|
static readonly cliName: string;
|
|
24
24
|
static readonly cliBinNames: string[] & readonly string[];
|
|
25
25
|
static readonly pathAliasKey: string;
|
|
26
|
+
static readonly brand: {
|
|
27
|
+
primary: string;
|
|
28
|
+
secondary: string;
|
|
29
|
+
tagline: string;
|
|
30
|
+
capabilities: string;
|
|
31
|
+
};
|
|
26
32
|
static readonly mainSourceFolder: string;
|
|
33
|
+
static readonly framework: string;
|
|
27
34
|
static readonly layoutPaths: {
|
|
28
35
|
tests: string;
|
|
29
36
|
environments: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"node:path";import{packageRootDir as q}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}),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 v=`${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 mainSourceFolder=packageDefaults.mainSourceFolder;static layoutPaths=packageDefaults.layoutPaths;static bundledCoreTmpPath=n.join(q,packageDefaults.packageRootFolder,v)}export{seedFromTmp,loadSeedFromBundledTmp}from"../../utils/helpers/tmp/seed-from-tmp";
|
|
1
|
+
import n from"node:path";import{packageRootDir as q}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}),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 v=`${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 bundledCoreTmpPath=n.join(q,packageDefaults.packageRootFolder,v)}export{seedFromTmp,loadSeedFromBundledTmp}from"../../utils/helpers/tmp/seed-from-tmp";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import defaults from '../../../utils/constants/defaults.json';
|
|
1
2
|
import { type LayoutPaths } from '../../../utils/helpers/tmp/path-normalize';
|
|
3
|
+
export { defaults as packageIdentityDefaults };
|
|
2
4
|
export type SeedLayoutPaths = LayoutPaths;
|
|
3
5
|
export type SeedFromTmp = {
|
|
4
6
|
rootFolder: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import J from"node:fs";import I from"node:path";import{fileURLToPath as Q}from"node:url";import V from"yaml";import defaults from"../../../utils/constants/defaults.json" with { type: 'json' };import{normalizeRootFolder as W,normalizeSourceFolder as X}from"../../../utils/helpers/tmp/path-normalize";export{defaults as packageIdentityDefaults};const M=I.dirname(Q(import.meta.url)),O=`${defaults.tmpBaseName}${defaults.tmpExtension}`;function H(j,A){if(typeof j!=="string"||!j.trim())throw Error(`${defaults.packageName}: bundled tmp.yml missing ${A}`);return j.trim()}function Y(j){const A=j&&typeof j==="object"&&!Array.isArray(j)?j:{};return{tests:H(A.tests,"configs.service.paths.special.tests"),environments:H(A.environments,"configs.service.paths.special.environments"),dist:H(A.dist,"configs.service.paths.special.dist")}}function Z(j){if(j){if(!J.existsSync(j))throw Error(`${defaults.packageName}: bundled tmp.yml missing at ${j}`);return j}const A=[M,process.cwd()];for(const G of A){let C=I.resolve(G);for(;;){const D=I.join(C,defaults.packageRootFolder,O);if(J.existsSync(D))return D;const E=I.dirname(C);if(E===C)break;C=E}}throw Error(`${defaults.packageName}: bundled ${defaults.packageRootFolder}/${O} not found from ${M}`)}export function loadSeedFromBundledTmp(j){const A=Z(j),G=V.parse(J.readFileSync(A,"utf8")),C=G?.configs&&typeof G.configs==="object"?G.configs:{},D=C.service&&typeof C.service==="object"?C.service:{},E=D.paths&&typeof D.paths==="object"?D.paths:{},K=H(E.source,"configs.service.paths.source");return{rootFolder:W(E.root,defaults.packageRootFolder),sourceFolder:X(K,K),framework:H(D.framework,"configs.service.framework"),layout:Y(E.special)}}export const seedFromTmp=loadSeedFromBundledTmp();
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"packageName": "@xrystal/core",
|
|
3
|
-
"packageRootFolder": "x",
|
|
4
|
-
"cliName": "xry",
|
|
5
|
-
"cliBinNames": [
|
|
6
|
-
"xry"
|
|
7
|
-
],
|
|
8
|
-
"tmpBaseName": "tmp",
|
|
9
|
-
"tmpExtension": ".yml",
|
|
10
|
-
"templateRepoUri": "https://github.com/xdloper/api-gpt-svc",
|
|
11
|
-
"publicFolderName": "public",
|
|
12
|
-
"kafkaLogsTopic": "log",
|
|
13
|
-
"pathAliasKey": "@/*",
|
|
14
|
-
"eslintRestrictedImportDepth": 2,
|
|
15
|
-
"tmpWatchDefaults": {
|
|
16
|
-
"intervalMs": 500,
|
|
17
|
-
"minIntervalMs": 100,
|
|
18
|
-
"maxIntervalMs": 10000
|
|
19
|
-
},
|
|
20
|
-
"buildDefaults": {
|
|
21
|
-
"tsconfig": "tsconfig.json",
|
|
22
|
-
"typecheck": false,
|
|
23
|
-
"tscLenient": false,
|
|
24
|
-
"declarations": false,
|
|
25
|
-
"sourcemap": false,
|
|
26
|
-
"minify": false
|
|
27
|
-
}
|
|
28
|
-
}
|