@xrystal/core 3.39.0 → 3.41.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 +65 -34
- package/package.json +2 -4
- package/x/bin/commands/create.mjs +2 -1
- package/x/bin/commands/doctor.mjs +9 -7
- package/x/bin/commands/hooks.mjs +4 -2
- package/x/bin/commands/project.mjs +2 -1
- package/x/bin/commands/release.mjs +5 -3
- package/x/bin/commands/sync.mjs +51 -0
- package/x/bin/commands/tmp.mjs +4 -2
- package/x/bin/helpers/.generated/tmp-schema.mjs +110 -86
- package/x/bin/helpers/banner.mjs +4 -3
- package/x/bin/helpers/build-config.mjs +11 -2
- package/x/bin/helpers/cli-help.mjs +12 -11
- package/x/bin/helpers/cli-identity.mjs +7 -17
- package/x/bin/helpers/defaults.json +14 -30
- package/x/bin/helpers/package-defaults.mjs +43 -12
- package/x/bin/helpers/project-artifacts.mjs +9 -2
- package/x/bin/helpers/project-root.mjs +4 -4
- package/x/bin/helpers/seed-from-tmp.mjs +69 -0
- package/x/bin/helpers/tmp-config.mjs +2 -1
- package/x/bin/helpers/tmp-layout.mjs +5 -5
- package/x/bin/helpers/toolchain-config.mjs +7 -13
- package/x/bin/main-cli.js +3 -3
- package/x/bin/scripts/install-git-hooks.mjs +5 -3
- package/x/bin/scripts/release-prepare.mjs +2 -2
- package/x/bin/scripts/sync-cli-defaults.mjs +7 -2
- package/x/dist/utils/constants/defaults.json +14 -30
- package/x/dist/utils/constants/index.d.ts +19 -12
- 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 +2 -0
- package/x/dist/utils/helpers/tmp/index.js +1 -1
- package/x/dist/utils/helpers/tmp/path-normalize.d.ts +8 -0
- package/x/dist/utils/helpers/tmp/path-normalize.js +1 -0
- package/x/dist/utils/helpers/tmp/seed-from-tmp.d.ts +10 -0
- package/x/dist/utils/helpers/tmp/seed-from-tmp.js +1 -0
- package/x/dist/utils/helpers/tmp/tmp-loader.js +1 -1
- package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +0 -3
- package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -1
- package/x/dist/utils/helpers/tmp/tmp-watch.js +1 -1
- package/x/dist/utils/models/classes/class.x.js +1 -1
- package/x/bin/commands/sync-toolchain.mjs +0 -43
package/README.md
CHANGED
|
@@ -3,20 +3,39 @@
|
|
|
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:** `
|
|
6
|
+
**CLI:** `xry` · **Version:** `3.41.0` · [npm](https://www.npmjs.com/package/@xrystal/core)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## What's new in 3.41.0 / 3.41.0'da ne değişti
|
|
11
|
+
|
|
12
|
+
| Change / Değişiklik | EN | TR |
|
|
13
|
+
|---------------------|----|----|
|
|
14
|
+
| **No layout hardcodes** | `source` / `dist` / `tests` / framework come from bundled `x/tmp.yml` seed | Layout + framework seed = `x/tmp.yml` |
|
|
15
|
+
| **Package name** | Errors, CLI copy, hooks use `defaults.packageName` (not a literal `@xrystal/core`) | Paket adı `defaults.packageName` |
|
|
16
|
+
| **`xry sync`** | Still syncs `tsconfig` paths from project `tmp.yml` | `tmp.yml` → tsconfig |
|
|
17
|
+
| **CLI** | Single bin `xry` (since 3.40.0) | Tek bin `xry` (3.40.0+) |
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx xry sync # apply tmp.yml → tsconfig / bunfig aliases
|
|
21
|
+
npx xry sync --dry-run
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Breaking / Kırıcı:** replace scripts and docs that called `xcore`, `xrystal`, or the old `tmp` bin with `xry`.
|
|
7
25
|
|
|
8
26
|
---
|
|
9
27
|
|
|
10
28
|
## Why / Neden
|
|
11
29
|
|
|
12
|
-
**EN:** `@xrystal/core` is a **kernel**, not only a GitHub template. Most teams already have their own repo layout, CI, Docker, or monorepo — they only need the runtime: DI, `tmp.yml`, `ctr()`, DTO, logger, i18n, trace. Use `
|
|
30
|
+
**EN:** `@xrystal/core` is a **kernel**, not only a GitHub template. Most teams already have their own repo layout, CI, Docker, or monorepo — they only need the runtime: DI, `tmp.yml`, `ctr()`, DTO, logger, i18n, trace. Use `xry create` if you want a starter; otherwise add the package to **your** project and seed `x/tmp.yml`.
|
|
13
31
|
|
|
14
|
-
**TR:** `@xrystal/core` bir **kernel** — sadece GitHub template değil. Çoğu ekipte zaten kendi repo düzeni, CI, Docker veya monorepo vardır; ihtiyaç duyulan şey runtime: DI, `tmp.yml`, `ctr()`, DTO, logger, i18n, trace. Sıfırdan başlıyorsan `
|
|
32
|
+
**TR:** `@xrystal/core` bir **kernel** — sadece GitHub template değil. Çoğu ekipte zaten kendi repo düzeni, CI, Docker veya monorepo vardır; ihtiyaç duyulan şey runtime: DI, `tmp.yml`, `ctr()`, DTO, logger, i18n, trace. Sıfırdan başlıyorsan `xry create`; mevcut projende sadece paketi kur + `xry tmp` yeter.
|
|
15
33
|
|
|
16
34
|
```bash
|
|
17
35
|
# EN: existing project — kernel only · TR: mevcut proje — sadece kernel
|
|
18
36
|
bun add @xrystal/core
|
|
19
|
-
npx
|
|
37
|
+
npx xry tmp # seed x/tmp.yml into YOUR layout
|
|
38
|
+
npx xry sync # align tsconfig paths with tmp.yml
|
|
20
39
|
# wire coreLoader + dtoMiddleware in your entry file
|
|
21
40
|
```
|
|
22
41
|
|
|
@@ -34,13 +53,13 @@ npx xcore tmp # seed x/tmp.yml into YOUR layout
|
|
|
34
53
|
mkdir my-api && cd my-api
|
|
35
54
|
bun init -y
|
|
36
55
|
bun add @xrystal/core
|
|
37
|
-
npx
|
|
56
|
+
npx xry create my-api .
|
|
38
57
|
```
|
|
39
58
|
|
|
40
59
|
```bash
|
|
41
60
|
bun add elysia # EN: or express · TR: veya express
|
|
42
61
|
bun run dev
|
|
43
|
-
npx
|
|
62
|
+
npx xry doctor # EN: setup check · TR: kurulum kontrolü
|
|
44
63
|
```
|
|
45
64
|
|
|
46
65
|
### Path B — Your project + kernel (most common / en yaygın)
|
|
@@ -53,7 +72,8 @@ npx xcore doctor # EN: setup check · TR: kurulum kontrolü
|
|
|
53
72
|
mkdir my-api && cd my-api
|
|
54
73
|
bun init -y
|
|
55
74
|
bun add @xrystal/core elysia
|
|
56
|
-
npx
|
|
75
|
+
npx xry tmp # EN: create x/tmp.yml from seed if missing · TR: yoksa seed'den oluşturur
|
|
76
|
+
npx xry sync # EN: tsconfig from tmp.yml · TR: tmp.yml → tsconfig
|
|
57
77
|
```
|
|
58
78
|
|
|
59
79
|
`package.json`:
|
|
@@ -61,22 +81,23 @@ npx xcore tmp # EN: create x/tmp.yml from seed if missing · TR: yoksa
|
|
|
61
81
|
```json
|
|
62
82
|
{
|
|
63
83
|
"dependencies": {
|
|
64
|
-
"@xrystal/core": "^3.
|
|
84
|
+
"@xrystal/core": "^3.41.0",
|
|
65
85
|
"elysia": "^1.4.19"
|
|
66
86
|
},
|
|
67
87
|
"scripts": {
|
|
68
|
-
"dev": "
|
|
69
|
-
"build": "
|
|
70
|
-
"start": "
|
|
71
|
-
"test": "
|
|
72
|
-
"
|
|
88
|
+
"dev": "xry dev",
|
|
89
|
+
"build": "xry build",
|
|
90
|
+
"start": "xry start",
|
|
91
|
+
"test": "xry test",
|
|
92
|
+
"sync": "xry sync",
|
|
93
|
+
"doctor": "xry doctor"
|
|
73
94
|
}
|
|
74
95
|
}
|
|
75
96
|
```
|
|
76
97
|
|
|
77
|
-
**EN:** No global `
|
|
98
|
+
**EN:** No global `xry` install — runs via `node_modules/.bin` after `bun add @xrystal/core`.
|
|
78
99
|
|
|
79
|
-
**TR:** Global `
|
|
100
|
+
**TR:** Global `xry` gerekmez — `@xrystal/core` kurulunca `node_modules/.bin` üzerinden çalışır.
|
|
80
101
|
|
|
81
102
|
### Project layout / Proje düzeni
|
|
82
103
|
|
|
@@ -84,12 +105,20 @@ npx xcore tmp # EN: create x/tmp.yml from seed if missing · TR: yoksa
|
|
|
84
105
|
my-api/
|
|
85
106
|
├── package.json
|
|
86
107
|
├── source/
|
|
87
|
-
│ ├── index.ts # EN: dev entry (
|
|
108
|
+
│ ├── index.ts # EN: dev entry (xry dev) · TR: dev girişi
|
|
88
109
|
│ └── controllers/
|
|
89
110
|
└── x/
|
|
90
|
-
|
|
111
|
+
└── tmp.yml # EN: runtime + path SSOT · TR: runtime + path tek kaynak
|
|
91
112
|
```
|
|
92
113
|
|
|
114
|
+
### Config sources / Config kaynakları
|
|
115
|
+
|
|
116
|
+
| File / Dosya | Owns / Sahip olduğu |
|
|
117
|
+
|--------------|---------------------|
|
|
118
|
+
| `x/tmp.yml` | Service paths, loaders, protocols, build flags · layout seed |
|
|
119
|
+
| `tsconfig.json` | Compiler language options; path layout via `xry sync` |
|
|
120
|
+
| Package defaults (internal) | CLI name (`xry`), package identity — not project layout |
|
|
121
|
+
|
|
93
122
|
### Minimal `x/tmp.yml`
|
|
94
123
|
|
|
95
124
|
```yaml
|
|
@@ -143,13 +172,14 @@ bun run dev
|
|
|
143
172
|
|
|
144
173
|
| Command / Komut | EN | TR |
|
|
145
174
|
|-----------------|----|----|
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
| `
|
|
152
|
-
| `
|
|
175
|
+
| `xry create [name] [path]` | Start project from template + `tmp.yml` | Template + `tmp.yml` ile proje başlat |
|
|
176
|
+
| `xry tmp` | Create `tmp.yml` from seed if missing | `tmp.yml` yoksa seed'den oluştur |
|
|
177
|
+
| `xry sync` | Sync `tsconfig` / aliases from `tmp.yml` | `tmp.yml` → `tsconfig` / alias |
|
|
178
|
+
| `xry dev` | Watch `source/index.ts` + dev env | `source/index.ts` watch + dev env |
|
|
179
|
+
| `xry build` | Output → `x/dist` | Çıktı → `x/dist` |
|
|
180
|
+
| `xry start` | Run `x/dist` + prod env | `x/dist` + prod env |
|
|
181
|
+
| `xry test` | Run `x/tests` | `x/tests` çalıştır |
|
|
182
|
+
| `xry doctor` | CLI, runtime, package health | CLI, runtime, paket uyumu |
|
|
153
183
|
|
|
154
184
|
---
|
|
155
185
|
|
|
@@ -173,7 +203,7 @@ bun run dev
|
|
|
173
203
|
| **HTTP client** | Retries + circuit breaker + trace header | Dayanıklı outbound HTTP | extend `BaseApiClient` from loader/clients |
|
|
174
204
|
| **Scope validate** | OAuth-style `resource:permission` check | Scope doğrulama | `validateScopes({ scopes, resources, permissions })` |
|
|
175
205
|
| **Realtime** | Same `ctr()` for ws / socket.io | HTTP + ws aynı kalıp | `ctr({ logic }, { protocol: 'ws' })` — [guide](#realtime--websocket--socketio) |
|
|
176
|
-
| **CLI** | dev, build, start, test, doctor
|
|
206
|
+
| **CLI (`xry`)** | create, tmp, sync, dev, build, start, test, doctor | Servis toolchain | `"dev": "xry dev"` · `"sync": "xry sync"` |
|
|
177
207
|
| **Shutdown** | Graceful cleanup on SIGTERM | Temiz kapanış | auto via `registerGracefulShutdown()` on boot |
|
|
178
208
|
|
|
179
209
|
```typescript
|
|
@@ -511,13 +541,14 @@ Details / detay: [`@xrystal/dto`](https://www.npmjs.com/package/@xrystal/dto)
|
|
|
511
541
|
**TR:** Servis yazarken tipik akış.
|
|
512
542
|
|
|
513
543
|
```
|
|
514
|
-
1. Your repo + bun add @xrystal/core +
|
|
515
|
-
2.
|
|
516
|
-
3.
|
|
517
|
-
4.
|
|
518
|
-
5.
|
|
519
|
-
6.
|
|
520
|
-
7.
|
|
544
|
+
1. Your repo + bun add @xrystal/core + xry tmp (or xry create for greenfield)
|
|
545
|
+
2. xry sync → tsconfig include / outDir / @/* from tmp.yml
|
|
546
|
+
3. tmp.yml → framework, loaders, paths
|
|
547
|
+
4. coreLoader() → once at top of YOUR index.ts
|
|
548
|
+
5. Controller → ctr() per endpoint
|
|
549
|
+
6. Framework → dtoMiddleware + routes
|
|
550
|
+
7. xry dev → develop
|
|
551
|
+
8. xry build → start → production
|
|
521
552
|
```
|
|
522
553
|
|
|
523
554
|
### Express — end-to-end / uçtan uca
|
|
@@ -757,6 +788,6 @@ class ChatController extends Controller {
|
|
|
757
788
|
|
|
758
789
|
## Maintainer note / Geliştirici notu
|
|
759
790
|
|
|
760
|
-
**EN:** This repo is the `@xrystal/core` source.
|
|
791
|
+
**EN:** This repo is the `@xrystal/core` source. Bump `package.json` → commit → `xry tag` (runs prepare + pushes `vX.Y.Z`; GitHub Publish workflow releases to npm). Consumers only need `bun add @xrystal/core`.
|
|
761
792
|
|
|
762
|
-
**TR:** Bu repo `@xrystal/core`
|
|
793
|
+
**TR:** Bu repo `@xrystal/core` kaynağıdır. `package.json` bump → commit → `xry tag` (prepare + `vX.Y.Z` push; GitHub Publish → npm). Tüketici için sadece `bun add @xrystal/core` yeter.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Yusuf Yasir KAYGUSUZ",
|
|
3
3
|
"name": "@xrystal/core",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.41.0",
|
|
5
5
|
"description": "Project core for xrystal",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -50,9 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"type": "module",
|
|
52
52
|
"bin": {
|
|
53
|
-
"
|
|
54
|
-
"xrystal": "./x/bin/main-cli.js",
|
|
55
|
-
"tmp": "./x/bin/main-cli.js"
|
|
53
|
+
"xry": "./x/bin/main-cli.js"
|
|
56
54
|
},
|
|
57
55
|
"scripts": {
|
|
58
56
|
"dev": "node x/bin/main-cli.js dev",
|
|
@@ -15,8 +15,9 @@ import {
|
|
|
15
15
|
import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs'
|
|
16
16
|
import { formatCreateHelp, formatCreateCommandHelp, LIST_BULLET } from '../helpers/cli-help.mjs'
|
|
17
17
|
import { setupProjectGitHooks } from '../scripts/install-git-hooks.mjs'
|
|
18
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
18
19
|
|
|
19
|
-
export function registerCreateCommand(cli, { cliName =
|
|
20
|
+
export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtimeName, packageManager, installCommand, devCommand }) {
|
|
20
21
|
cli
|
|
21
22
|
.command('create <project-name> [target-path]')
|
|
22
23
|
.description('Scaffold new service from GitHub template')
|
|
@@ -2,6 +2,7 @@ import chalk from 'chalk'
|
|
|
2
2
|
|
|
3
3
|
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
4
4
|
import { resolveDistLayout } from '../helpers/project-artifacts.mjs'
|
|
5
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
6
|
import {
|
|
6
7
|
getInstalledCoreVersion,
|
|
7
8
|
getProjectRoot,
|
|
@@ -12,6 +13,7 @@ import { listRuntimeInventory, resolveRuntimeInfo } from '../helpers/runtime-inf
|
|
|
12
13
|
import { evaluateVersionBump, getVersionState, resolveCommitVersionHint, resolveVersionBaseline, VERSION_PATTERN } from '../scripts/version-check.mjs'
|
|
13
14
|
import { auditTsconfigAlignment, resolveToolchainPathsFromProject } from '../helpers/toolchain-config.mjs'
|
|
14
15
|
import { isGitHookInstalled } from '../scripts/install-git-hooks.mjs'
|
|
16
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
15
17
|
|
|
16
18
|
function statusValue(value, okLabel = null) {
|
|
17
19
|
if (value == null || value === '') return chalk.gray('—')
|
|
@@ -22,10 +24,10 @@ function printSection(title) {
|
|
|
22
24
|
console.log(chalk.bold.cyan(`\n ${title}`))
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
export function registerDoctorCommand(cli, { cliName =
|
|
27
|
+
export function registerDoctorCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
26
28
|
cli
|
|
27
29
|
.command('doctor')
|
|
28
|
-
.description(
|
|
30
|
+
.description(`Check runtime, git, and ${packageDefaults.packageName} alignment`)
|
|
29
31
|
.action(async () => {
|
|
30
32
|
const root = getProjectRoot()
|
|
31
33
|
const cliPkg = readCliPackageJson()
|
|
@@ -75,11 +77,11 @@ export function registerDoctorCommand(cli, { cliName = 'xcore' } = {}) {
|
|
|
75
77
|
console.log(` ${'source'.padEnd(18)}${chalk.bold(distLayout.layout.mainFolderPath)} ${chalk.gray('(paths.source)')}`)
|
|
76
78
|
console.log(` ${'dist'.padEnd(18)}${chalk.bold(distLayout.distPrefix)} ${chalk.gray('(paths.special.dist)')}`)
|
|
77
79
|
} else {
|
|
78
|
-
console.log(chalk.yellow(
|
|
80
|
+
console.log(chalk.yellow(` layout: tmp.yml not resolved — run ${CLI_PRIMARY_NAME} tmp`))
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
printSection('CLI (tool)')
|
|
82
|
-
console.log(` ${
|
|
84
|
+
console.log(` ${packageDefaults.packageName.padEnd(18)}${chalk.bold(`${cliPkg.name}@${cliPkg.version}`)}`)
|
|
83
85
|
|
|
84
86
|
printSection('Package')
|
|
85
87
|
console.log(` ${'name'.padEnd(18)}${chalk.bold(projectPkg.name)}`)
|
|
@@ -100,7 +102,7 @@ export function registerDoctorCommand(cli, { cliName = 'xcore' } = {}) {
|
|
|
100
102
|
console.log(chalk.bold.red(' ⚠ CLI / node_modules version mismatch'))
|
|
101
103
|
console.log(chalk.yellow(` CLI (this binary): ${cliPkg.version}`))
|
|
102
104
|
console.log(chalk.yellow(` node_modules installed: ${core.installed}`))
|
|
103
|
-
console.log(chalk.gray(` fix: bun add
|
|
105
|
+
console.log(chalk.gray(` fix: bun add ${packageDefaults.packageName}@${cliPkg.version}`))
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
printSection('Git')
|
|
@@ -134,7 +136,7 @@ export function registerDoctorCommand(cli, { cliName = 'xcore' } = {}) {
|
|
|
134
136
|
}
|
|
135
137
|
console.log(` ${'working tree'.padEnd(18)}${state.isClean ? chalk.green('clean') : chalk.yellow('dirty')}`)
|
|
136
138
|
const hookOk = isGitHookInstalled(root)
|
|
137
|
-
console.log(` ${'pre-commit hook'.padEnd(18)}${hookOk ? chalk.green('installed') : chalk.yellow('missing')} ${chalk.gray(
|
|
139
|
+
console.log(` ${'pre-commit hook'.padEnd(18)}${hookOk ? chalk.green('installed') : chalk.yellow('missing')} ${chalk.gray(`· ${CLI_PRIMARY_NAME} hooks install`)}`)
|
|
138
140
|
} catch (error) {
|
|
139
141
|
console.log(chalk.yellow(` git: ${error.message}`))
|
|
140
142
|
}
|
|
@@ -145,7 +147,7 @@ export function registerDoctorCommand(cli, { cliName = 'xcore' } = {}) {
|
|
|
145
147
|
console.log(` ${'outDir'.padEnd(18)}${chalk.bold(toolchain.outDir)}`)
|
|
146
148
|
const tsAudit = auditTsconfigAlignment(root)
|
|
147
149
|
if (tsAudit.missing) {
|
|
148
|
-
console.log(chalk.yellow(` ${'tsconfig'.padEnd(18)}missing · run
|
|
150
|
+
console.log(chalk.yellow(` ${'tsconfig'.padEnd(18)}missing · run ${CLI_PRIMARY_NAME} sync`))
|
|
149
151
|
} else if (tsAudit.ok) {
|
|
150
152
|
console.log(chalk.green(` ${'tsconfig'.padEnd(18)}aligned with tmp.yml`))
|
|
151
153
|
} else {
|
package/x/bin/commands/hooks.mjs
CHANGED
|
@@ -4,8 +4,10 @@ import { printCommandHeader } from '../helpers/banner.mjs'
|
|
|
4
4
|
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
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
8
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
7
9
|
|
|
8
|
-
export function registerHooksCommand(cli, { cliName =
|
|
10
|
+
export function registerHooksCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
9
11
|
const hooks = cli
|
|
10
12
|
.command('hooks')
|
|
11
13
|
.description('Install git hooks for version bump checks')
|
|
@@ -44,7 +46,7 @@ export function registerHooksCommand(cli, { cliName = 'xcore' } = {}) {
|
|
|
44
46
|
|
|
45
47
|
hooks
|
|
46
48
|
.command('status')
|
|
47
|
-
.description(
|
|
49
|
+
.description(`Show whether ${packageDefaults.packageName} pre-commit hook is installed`)
|
|
48
50
|
.action(() => {
|
|
49
51
|
const root = getProjectRoot()
|
|
50
52
|
printCommandHeader({ cliName, command: 'hooks status', version: readCliPackageJson().version })
|
|
@@ -3,6 +3,7 @@ import fs from 'node:fs'
|
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import chalk from 'chalk'
|
|
5
5
|
|
|
6
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
6
7
|
import {
|
|
7
8
|
isCorePackageName,
|
|
8
9
|
readTmpBuildContext,
|
|
@@ -34,7 +35,7 @@ function resolveTestTarget(root) {
|
|
|
34
35
|
)
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
export function registerProjectCommands(cli, { cliName =
|
|
38
|
+
export function registerProjectCommands(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
38
39
|
cli
|
|
39
40
|
.command('dev')
|
|
40
41
|
.description('Watch source/index.ts with dev env files')
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
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
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
4
6
|
|
|
5
|
-
export function registerTagCommand(cli, { cliName =
|
|
7
|
+
export function registerTagCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
6
8
|
cli
|
|
7
9
|
.command('tag')
|
|
8
10
|
.description('Git tag from package.json (+ npm publish for core)')
|
|
@@ -27,7 +29,7 @@ export function registerTagCommand(cli, { cliName = 'xcore' } = {}) {
|
|
|
27
29
|
})
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
export function registerVersionCommand(cli, { cliName =
|
|
32
|
+
export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
31
33
|
cli
|
|
32
34
|
.command('version')
|
|
33
35
|
.description('Show CLI and project package versions')
|
|
@@ -40,7 +42,7 @@ export function registerVersionCommand(cli, { cliName = 'xcore' } = {}) {
|
|
|
40
42
|
|
|
41
43
|
console.log(chalk.cyan(`\n${cliName} version\n`))
|
|
42
44
|
console.log(chalk.gray(' CLI (tool)'))
|
|
43
|
-
console.log(`
|
|
45
|
+
console.log(` ${packageDefaults.packageName}: ${chalk.bold(`${cliPkg.name}@${cliPkg.version}`)}`)
|
|
44
46
|
console.log('')
|
|
45
47
|
console.log(chalk.gray(' Project'))
|
|
46
48
|
console.log(` root: ${root}`)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
|
|
3
|
+
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
4
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
|
+
import { getProjectRoot, readCliPackageJson } from '../helpers/project-root.mjs'
|
|
6
|
+
import { auditTsconfigAlignment, syncProjectToolchain } from '../helpers/toolchain-config.mjs'
|
|
7
|
+
|
|
8
|
+
/** Sync tsconfig include/outDir/@/* from project tmp.yml. */
|
|
9
|
+
export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
10
|
+
const run = (options) => {
|
|
11
|
+
const root = getProjectRoot()
|
|
12
|
+
const auditBefore = auditTsconfigAlignment(root)
|
|
13
|
+
|
|
14
|
+
printCommandHeader({ cliName, command: 'sync', version: readCliPackageJson().version })
|
|
15
|
+
console.log(chalk.gray(` root: ${root}`))
|
|
16
|
+
|
|
17
|
+
const lo = auditBefore.layoutOptions ?? {}
|
|
18
|
+
console.log(chalk.gray(' from tmp.yml:'))
|
|
19
|
+
console.log(chalk.gray(` paths.root: ${lo.rootFolderPath ?? '—'}`))
|
|
20
|
+
console.log(chalk.gray(` paths.source: ${lo.mainFolderPath ?? '—'}`))
|
|
21
|
+
console.log(chalk.gray(` paths.dist: ${lo.pathsDist ?? '—'}`))
|
|
22
|
+
|
|
23
|
+
if (options.dryRun) {
|
|
24
|
+
const preview = syncProjectToolchain(root, { write: false })
|
|
25
|
+
console.log(chalk.gray('\n would write tsconfig.json:'))
|
|
26
|
+
console.log(chalk.gray(` include: ${JSON.stringify(preview.merged.include)}`))
|
|
27
|
+
console.log(chalk.gray(` outDir: ${preview.merged.compilerOptions.outDir}`))
|
|
28
|
+
console.log(chalk.gray(` paths: ${JSON.stringify(preview.merged.compilerOptions.paths)}`))
|
|
29
|
+
console.log(chalk.gray(`\n bunfig → ${preview.paths.bunfigAliasLine}\n`))
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const result = syncProjectToolchain(root, { write: true })
|
|
34
|
+
console.log(result.created
|
|
35
|
+
? chalk.green(` created ${result.tsconfigRel}`)
|
|
36
|
+
: chalk.green(` updated ${result.tsconfigRel}`))
|
|
37
|
+
console.log(chalk.gray(` include → ${JSON.stringify(result.merged.include)}`))
|
|
38
|
+
console.log(chalk.gray(` outDir → ${result.merged.compilerOptions.outDir}`))
|
|
39
|
+
console.log(chalk.yellow(`\n bunfig.toml [resolve.alias]: ${result.paths.bunfigAliasLine}\n`))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
cli
|
|
43
|
+
.command('sync')
|
|
44
|
+
.alias('sync-toolchain')
|
|
45
|
+
.description('Sync tsconfig paths from tmp.yml')
|
|
46
|
+
.option('--dry-run', 'Preview without writing')
|
|
47
|
+
.action(run)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @deprecated use registerSyncCommand */
|
|
51
|
+
export const registerSyncToolchainCommand = registerSyncCommand
|
package/x/bin/commands/tmp.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import yaml from 'yaml'
|
|
|
5
5
|
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
6
6
|
import { resolveObjWithHandlebars } from '../helpers/index.mjs'
|
|
7
7
|
import { getProjectRoot, readCliPackageJson } from '../helpers/project-root.mjs'
|
|
8
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
8
9
|
import {
|
|
9
10
|
ensureTmpFile,
|
|
10
11
|
ownerTmpFilePath,
|
|
@@ -12,11 +13,12 @@ import {
|
|
|
12
13
|
resolveTmpLayoutOrDefaults,
|
|
13
14
|
} from '../helpers/tmp-layout.mjs'
|
|
14
15
|
import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs'
|
|
16
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
15
17
|
|
|
16
|
-
export function registerTmpCommand(cli, { cliName =
|
|
18
|
+
export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
17
19
|
cli
|
|
18
20
|
.command('tmp')
|
|
19
|
-
.description(
|
|
21
|
+
.description(`Ensure tmp.yml exists (seed from ${packageDefaults.packageName})`)
|
|
20
22
|
.option('--dry-run', 'Show target path without writing')
|
|
21
23
|
.action((options) => {
|
|
22
24
|
const root = getProjectRoot()
|