@xrystal/core 3.52.1 → 3.52.3
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 +11 -11
- package/package.json +1 -1
- package/x/bin/commands/create.mjs +7 -2
- package/x/bin/commands/projects.mjs +90 -46
- package/x/bin/commands/sync.mjs +34 -8
- package/x/bin/commands/tmp.mjs +3 -3
- package/x/bin/helpers/banner.mjs +6 -0
- package/x/bin/helpers/cli-help.mjs +12 -4
- package/x/bin/helpers/sync-core-dependency.mjs +50 -0
- package/x/bin/main-cli.js +2 -1
- package/x/bin/scripts/publish-guard.mjs +31 -0
package/README.md
CHANGED
|
@@ -3,25 +3,25 @@
|
|
|
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.52.
|
|
6
|
+
**CLI:** `xry` · **Version:** `3.52.3` · [npm](https://www.npmjs.com/package/@xrystal/core)
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
## Platform services / Platform servisleri
|
|
11
11
|
|
|
12
|
-
**EN:** Consumer microservices in `../services/` — pin `@xrystal/core` to the latest published minor (currently **3.52.
|
|
12
|
+
**EN:** Consumer microservices in `../services/` — pin `@xrystal/core` to the latest published minor (currently **3.52.3**).
|
|
13
13
|
|
|
14
|
-
**TR:** `../services/` altındaki tüketen microservice'ler — `@xrystal/core` sürümünü npm latest ile hizala (şu an **3.52.
|
|
14
|
+
**TR:** `../services/` altındaki tüketen microservice'ler — `@xrystal/core` sürümünü npm latest ile hizala (şu an **3.52.3**).
|
|
15
15
|
|
|
16
16
|
| Repo folder | `tmp.yml` name | Role | Service pkg | `@xrystal/core` |
|
|
17
17
|
|-------------|----------------|------|-------------|-----------------|
|
|
18
|
-
| `api-core-svc` | `core` | Core domain API | `1.0.24` | `3.52.
|
|
19
|
-
| `api-cron-svc` | `crons` | Scheduled jobs / Kafka queue worker | `0.1.25` | `3.52.
|
|
20
|
-
| `api-gateway-svc` | `gateway` | Edge gateway, routing, cache, Mongo config | `2.0.49` | `3.52.
|
|
21
|
-
| `api-gpt-svc` | `gpt` | GPT / AI features | `1.0.22` | `3.52.
|
|
22
|
-
| `api-iam-svc` | `iam` | Identity & access management | `0.7.26` | `3.52.
|
|
23
|
-
| `api-log-svc` | `log` | Logging service | `1.0.20` | `3.52.
|
|
24
|
-
| `api-websocket-svc` | `websocket` | WebSocket / realtime | `0.8.31` | `3.52.
|
|
18
|
+
| `api-core-svc` | `core` | Core domain API | `1.0.24` | `3.52.3` |
|
|
19
|
+
| `api-cron-svc` | `crons` | Scheduled jobs / Kafka queue worker | `0.1.25` | `3.52.3` |
|
|
20
|
+
| `api-gateway-svc` | `gateway` | Edge gateway, routing, cache, Mongo config | `2.0.49` | `3.52.3` |
|
|
21
|
+
| `api-gpt-svc` | `gpt` | GPT / AI features | `1.0.22` | `3.52.3` |
|
|
22
|
+
| `api-iam-svc` | `iam` | Identity & access management | `0.7.26` | `3.52.3` |
|
|
23
|
+
| `api-log-svc` | `log` | Logging service | `1.0.20` | `3.52.3` |
|
|
24
|
+
| `api-websocket-svc` | `websocket` | WebSocket / realtime | `0.8.31` | `3.52.3` |
|
|
25
25
|
|
|
26
26
|
**SSL / TLS helpers** (since 3.49.0): import from loader subpaths, not `@xrystal/core/utils`:
|
|
27
27
|
|
|
@@ -35,7 +35,7 @@ import { resolveMongoConnectOptions } from '@xrystal/core/loader/mongo'
|
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
37
|
cd ../services/api-<name>-svc
|
|
38
|
-
bun add @xrystal/core@3.52.
|
|
38
|
+
bun add @xrystal/core@3.52.3
|
|
39
39
|
bun run build
|
|
40
40
|
```
|
|
41
41
|
|
package/package.json
CHANGED
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
} from '../helpers/tmp-layout.mjs'
|
|
15
15
|
import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs'
|
|
16
16
|
import { formatCreateHelp, formatCreateCommandHelp, LIST_BULLET } from '../helpers/cli-help.mjs'
|
|
17
|
+
import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
18
|
+
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
17
19
|
import { setupProjectGitHooks } from '../scripts/install-git-hooks.mjs'
|
|
18
20
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
19
21
|
import { scaffoldWorkspace } from '../helpers/workspace-scaffold.mjs'
|
|
@@ -24,7 +26,7 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
|
|
|
24
26
|
.command('create <project-name> [target-path]')
|
|
25
27
|
.description('Scaffold new service from GitHub template')
|
|
26
28
|
.option('-f, --force', 'Allow creating in a non-empty directory')
|
|
27
|
-
.option('--workspace', 'Scaffold multi-repo workspace (root tmp.yml + api/admin/
|
|
29
|
+
.option('--workspace', 'Scaffold multi-repo workspace (root tmp.yml + api/admin/web folders)')
|
|
28
30
|
.action(async (projectName, targetDir, options) => {
|
|
29
31
|
const name = projectName?.trim()
|
|
30
32
|
if (!name) {
|
|
@@ -56,6 +58,8 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
try {
|
|
61
|
+
const version = readCliPackageJson().version
|
|
62
|
+
printCommandHeader({ cliName, command: 'create (workspace)', version })
|
|
59
63
|
const result = scaffoldWorkspace(targetPath, name)
|
|
60
64
|
console.log(chalk.green('\n✓ Workspace ready\n'))
|
|
61
65
|
console.log(chalk.gray(` tmp: ${path.relative(process.cwd(), result.tmpPath) || result.tmpPath}`))
|
|
@@ -66,7 +70,8 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
|
|
|
66
70
|
syncRegistryFromPath(result.root)
|
|
67
71
|
console.log(chalk.gray(' registered in ~/.xrystal'))
|
|
68
72
|
} catch {}
|
|
69
|
-
console.log(chalk.cyan(` ${cliName} sync
|
|
73
|
+
console.log(chalk.cyan(` ${cliName} sync`))
|
|
74
|
+
printCommandFooter({ version })
|
|
70
75
|
} catch (error) {
|
|
71
76
|
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
72
77
|
process.exit(1)
|
|
@@ -1,53 +1,97 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
|
|
3
|
-
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
3
|
+
import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
4
4
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
5
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import { readRegistry, resolveXrystalHome, syncRegistryFromPath } from '../helpers/xrystal-registry.mjs'
|
|
7
|
+
|
|
8
|
+
function printProjectsRegistry() {
|
|
9
|
+
const registry = readRegistry()
|
|
10
|
+
console.log(chalk.gray(` home: ${resolveXrystalHome()}`))
|
|
11
|
+
console.log(chalk.gray(` workspaces: ${registry.workspaces.length}`))
|
|
12
|
+
|
|
13
|
+
if (registry.workspaces.length === 0) {
|
|
14
|
+
console.log(chalk.yellow('\n no workspaces registered — run xry create demo --workspace then xry workspaces sync\n'))
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (const ws of registry.workspaces) {
|
|
19
|
+
console.log(chalk.cyan(`\n${ws.name}`))
|
|
20
|
+
console.log(chalk.gray(` path: ${ws.path}`))
|
|
21
|
+
if (ws.projects.length === 0) {
|
|
22
|
+
console.log(chalk.gray(' projects: (none linked yet)'))
|
|
23
|
+
continue
|
|
24
|
+
}
|
|
25
|
+
for (const project of ws.projects) {
|
|
26
|
+
const cluster = project.cluster ? chalk.yellow(` cluster=${project.cluster}`) : ''
|
|
27
|
+
console.log(` • ${project.name} [${project.type}] → ${project.path}${cluster}`)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
console.log('')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function resolveRegistryMode(action, options) {
|
|
34
|
+
if (options.sync || action === 'sync') return 'sync'
|
|
35
|
+
if (!action || action === 'list') return 'list'
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function runRegistryCommand(commandName, action, options, { cliName }) {
|
|
40
|
+
const mode = resolveRegistryMode(action, options)
|
|
41
|
+
if (!mode) {
|
|
42
|
+
console.error(chalk.red(`\n✗ Unknown ${commandName} action: ${action}\n`))
|
|
43
|
+
console.error(chalk.gray(` Use: ${cliName} ${commandName} [list|sync]\n`))
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const version = readCliPackageJson().version
|
|
48
|
+
const command = mode === 'sync' ? `${commandName} sync` : `${commandName} list`
|
|
49
|
+
printCommandHeader({ cliName, command, version })
|
|
50
|
+
|
|
51
|
+
if (mode === 'sync') {
|
|
52
|
+
try {
|
|
53
|
+
syncRegistryFromPath(process.cwd())
|
|
54
|
+
console.log(chalk.green(' registry synced'))
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.log(chalk.yellow(` sync skipped: ${error.message}`))
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
printProjectsRegistry()
|
|
61
|
+
printCommandFooter({ version })
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function attachRegistryCommand(command, { cliName, label }) {
|
|
65
|
+
return command
|
|
66
|
+
.option('--sync', 'Rescan current workspace before listing (alias for sync)')
|
|
67
|
+
.addHelpText(
|
|
68
|
+
'after',
|
|
69
|
+
`
|
|
70
|
+
${chalk.gray('Examples:')}
|
|
71
|
+
${cliName} ${label}
|
|
72
|
+
${cliName} ${label} list
|
|
73
|
+
${cliName} ${label} sync
|
|
74
|
+
${cliName} ${label} --sync
|
|
75
|
+
`,
|
|
76
|
+
)
|
|
77
|
+
.action((action, options) => runRegistryCommand(label, action, options, { cliName }))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function registerWorkspacesCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
81
|
+
attachRegistryCommand(
|
|
82
|
+
cli
|
|
83
|
+
.command('workspaces [action]')
|
|
84
|
+
.description('List ~/.xrystal workspaces and linked projects'),
|
|
85
|
+
{ cliName, label: 'workspaces' },
|
|
86
|
+
)
|
|
87
|
+
}
|
|
12
88
|
|
|
13
89
|
export function registerProjectsCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (options.sync) {
|
|
22
|
-
try {
|
|
23
|
-
syncRegistryFromPath(process.cwd())
|
|
24
|
-
console.log(chalk.green(' registry synced'))
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.log(chalk.yellow(` sync skipped: ${error.message}`))
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const registry = readRegistry()
|
|
31
|
-
console.log(chalk.gray(` home: ${resolveXrystalHome()}`))
|
|
32
|
-
console.log(chalk.gray(` workspaces: ${registry.workspaces.length}`))
|
|
33
|
-
|
|
34
|
-
if (registry.workspaces.length === 0) {
|
|
35
|
-
console.log(chalk.yellow('\n no workspaces registered — run xry create demo --workspace then xry sync\n'))
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
for (const ws of registry.workspaces) {
|
|
40
|
-
console.log(chalk.cyan(`\n${ws.name}`))
|
|
41
|
-
console.log(chalk.gray(` path: ${ws.path}`))
|
|
42
|
-
if (ws.projects.length === 0) {
|
|
43
|
-
console.log(chalk.gray(' projects: (none linked yet)'))
|
|
44
|
-
continue
|
|
45
|
-
}
|
|
46
|
-
for (const project of ws.projects) {
|
|
47
|
-
const cluster = project.cluster ? chalk.yellow(` cluster=${project.cluster}`) : ''
|
|
48
|
-
console.log(` • ${project.name} [${project.type}] → ${project.path}${cluster}`)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
console.log('')
|
|
52
|
-
})
|
|
90
|
+
attachRegistryCommand(
|
|
91
|
+
cli
|
|
92
|
+
.command('projects [action]')
|
|
93
|
+
.description('Alias for workspaces — list ~/.xrystal registry')
|
|
94
|
+
.alias('ws'),
|
|
95
|
+
{ cliName, label: 'projects' },
|
|
96
|
+
)
|
|
53
97
|
}
|
package/x/bin/commands/sync.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
|
|
3
|
-
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
3
|
+
import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
4
4
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
5
|
import { getProjectRoot, readCliPackageJson } from '../helpers/project-root.mjs'
|
|
6
6
|
import { auditTsconfigAlignment, syncProjectToolchain } from '../helpers/toolchain-config.mjs'
|
|
7
7
|
import { findEntries, findWorkspaceRoot } from '../helpers/workspace-resolve.mjs'
|
|
8
8
|
import { syncCliRuntime } from '../helpers/project-artifacts.mjs'
|
|
9
|
+
import { syncCoreDependency } from '../helpers/sync-core-dependency.mjs'
|
|
10
|
+
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
9
11
|
import { syncRegistryFromPath } from '../helpers/xrystal-registry.mjs'
|
|
10
12
|
|
|
11
13
|
/** Sync tsconfig include/outDir/@/* from project tmp.yml. */
|
|
@@ -13,15 +15,17 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
13
15
|
const run = (options) => {
|
|
14
16
|
const cwd = process.cwd()
|
|
15
17
|
const workspaceRoot = findWorkspaceRoot(cwd)
|
|
18
|
+
const coreVersion = readCliPackageJson().version
|
|
16
19
|
|
|
17
20
|
if (workspaceRoot) {
|
|
18
21
|
const entries = findEntries(workspaceRoot)
|
|
19
|
-
printCommandHeader({ cliName, command: 'sync', version:
|
|
22
|
+
printCommandHeader({ cliName, command: 'sync', version: coreVersion })
|
|
20
23
|
console.log(chalk.gray(` workspace: ${workspaceRoot}`))
|
|
21
24
|
console.log(chalk.gray(` entries: ${entries.length}`))
|
|
22
25
|
|
|
23
26
|
if (entries.length === 0) {
|
|
24
|
-
console.log(chalk.yellow('\n no linked projects under api/admin/web yet
|
|
27
|
+
console.log(chalk.yellow('\n no linked projects under api/admin/web yet'))
|
|
28
|
+
printCommandFooter({ version: coreVersion })
|
|
25
29
|
return
|
|
26
30
|
}
|
|
27
31
|
|
|
@@ -32,6 +36,12 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
32
36
|
if (options.dryRun) {
|
|
33
37
|
const preview = syncProjectToolchain(entry.path, { write: false })
|
|
34
38
|
console.log(chalk.gray(` would update ${preview.tsconfigRel ?? 'tsconfig.json'}`))
|
|
39
|
+
const core = syncCoreDependency(entry.path, coreVersion, { dryRun: true })
|
|
40
|
+
if (core.synced) {
|
|
41
|
+
console.log(chalk.gray(` would pin ${packageDefaults.packageName}@${coreVersion} (from ${core.current ?? core.declared})`))
|
|
42
|
+
} else if (core.reason === 'up-to-date') {
|
|
43
|
+
console.log(chalk.gray(` ${packageDefaults.packageName}@${coreVersion} (ok)`))
|
|
44
|
+
}
|
|
35
45
|
continue
|
|
36
46
|
}
|
|
37
47
|
try {
|
|
@@ -40,6 +50,15 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
40
50
|
console.log(result.created
|
|
41
51
|
? chalk.green(` created ${result.tsconfigRel}`)
|
|
42
52
|
: chalk.green(` updated ${result.tsconfigRel}`))
|
|
53
|
+
const core = syncCoreDependency(entry.path, coreVersion, { dryRun: options.dryRun })
|
|
54
|
+
if (core.synced) {
|
|
55
|
+
const label = options.dryRun
|
|
56
|
+
? chalk.gray(` would pin ${packageDefaults.packageName}@${coreVersion}`)
|
|
57
|
+
: chalk.green(` pinned ${packageDefaults.packageName}@${coreVersion}`)
|
|
58
|
+
console.log(label)
|
|
59
|
+
} else if (core.reason === 'up-to-date') {
|
|
60
|
+
console.log(chalk.gray(` ${packageDefaults.packageName}@${coreVersion} (ok)`))
|
|
61
|
+
}
|
|
43
62
|
} catch (error) {
|
|
44
63
|
failed += 1
|
|
45
64
|
console.log(chalk.red(` failed: ${error.message}`))
|
|
@@ -51,15 +70,20 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
51
70
|
} catch (error) {
|
|
52
71
|
console.log(chalk.yellow(` registry skipped: ${error.message}`))
|
|
53
72
|
}
|
|
54
|
-
|
|
55
|
-
|
|
73
|
+
if (failed) {
|
|
74
|
+
console.log(chalk.red(`\n sync finished with ${failed} error(s)`))
|
|
75
|
+
printCommandFooter({ version: coreVersion })
|
|
76
|
+
process.exit(1)
|
|
77
|
+
}
|
|
78
|
+
console.log(chalk.green('\n workspace sync done'))
|
|
79
|
+
printCommandFooter({ version: coreVersion })
|
|
56
80
|
return
|
|
57
81
|
}
|
|
58
82
|
|
|
59
83
|
const root = getProjectRoot()
|
|
60
84
|
const auditBefore = auditTsconfigAlignment(root)
|
|
61
85
|
|
|
62
|
-
printCommandHeader({ cliName, command: 'sync', version:
|
|
86
|
+
printCommandHeader({ cliName, command: 'sync', version: coreVersion })
|
|
63
87
|
console.log(chalk.gray(` root: ${root}`))
|
|
64
88
|
|
|
65
89
|
const lo = auditBefore.layoutOptions ?? {}
|
|
@@ -74,7 +98,8 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
74
98
|
console.log(chalk.gray(` include: ${JSON.stringify(preview.merged.include)}`))
|
|
75
99
|
console.log(chalk.gray(` outDir: ${preview.merged.compilerOptions.outDir}`))
|
|
76
100
|
console.log(chalk.gray(` paths: ${JSON.stringify(preview.merged.compilerOptions.paths)}`))
|
|
77
|
-
console.log(chalk.gray(`\n bunfig → ${preview.paths.bunfigAliasLine}
|
|
101
|
+
console.log(chalk.gray(`\n bunfig → ${preview.paths.bunfigAliasLine}`))
|
|
102
|
+
printCommandFooter({ version: coreVersion })
|
|
78
103
|
return
|
|
79
104
|
}
|
|
80
105
|
|
|
@@ -84,7 +109,8 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
84
109
|
: chalk.green(` updated ${result.tsconfigRel}`))
|
|
85
110
|
console.log(chalk.gray(` include → ${JSON.stringify(result.merged.include)}`))
|
|
86
111
|
console.log(chalk.gray(` outDir → ${result.merged.compilerOptions.outDir}`))
|
|
87
|
-
console.log(chalk.yellow(`\n bunfig.toml [resolve.alias]: ${result.paths.bunfigAliasLine}
|
|
112
|
+
console.log(chalk.yellow(`\n bunfig.toml [resolve.alias]: ${result.paths.bunfigAliasLine}`))
|
|
113
|
+
printCommandFooter({ version: coreVersion })
|
|
88
114
|
}
|
|
89
115
|
|
|
90
116
|
cli
|
package/x/bin/commands/tmp.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'node:fs'
|
|
|
2
2
|
import chalk from 'chalk'
|
|
3
3
|
import yaml from 'yaml'
|
|
4
4
|
|
|
5
|
-
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
5
|
+
import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
6
6
|
import { resolveObjWithHandlebars } from '../helpers/index.mjs'
|
|
7
7
|
import { getProjectRoot, readCliPackageJson } from '../helpers/project-root.mjs'
|
|
8
8
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
@@ -32,7 +32,7 @@ export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
32
32
|
printCommandHeader({ cliName, command: 'tmp (dry-run)', version })
|
|
33
33
|
console.log(chalk.gray(` root: ${root}`))
|
|
34
34
|
console.log(` ${exists ? 'exists' : 'would create'}: ${target}`)
|
|
35
|
-
|
|
35
|
+
printCommandFooter({ version })
|
|
36
36
|
return
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -54,6 +54,6 @@ export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
54
54
|
// summary optional
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
printCommandFooter({ version })
|
|
58
58
|
})
|
|
59
59
|
}
|
package/x/bin/helpers/banner.mjs
CHANGED
|
@@ -73,6 +73,12 @@ export function printCommandHeader({ cliName: _cliName, command, version } = {})
|
|
|
73
73
|
)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
export function printCommandFooter({ version } = {}) {
|
|
77
|
+
if (!version) return
|
|
78
|
+
console.log(chalk.dim(` ${packageDefaults.packageName} v${version}`))
|
|
79
|
+
console.log('')
|
|
80
|
+
}
|
|
81
|
+
|
|
76
82
|
export function shouldShowBanner(argv = process.argv) {
|
|
77
83
|
const args = argv.slice(2)
|
|
78
84
|
if (!args.length) return true
|
|
@@ -24,15 +24,22 @@ const COMMAND_GROUPS = [
|
|
|
24
24
|
{ cmd: 'test', desc: 'Run project tests (paths.tests)' },
|
|
25
25
|
],
|
|
26
26
|
},
|
|
27
|
+
{
|
|
28
|
+
title: 'Workspace',
|
|
29
|
+
items: [
|
|
30
|
+
{ cmd: 'create <name> --workspace', desc: 'Scaffold workspace (tmp.yml + api/admin/web folders)' },
|
|
31
|
+
{ cmd: 'sync', desc: 'Sync all linked projects in workspace + update ~/.xrystal' },
|
|
32
|
+
{ cmd: 'workspaces [list|sync]', desc: 'List registered workspaces and linked projects' },
|
|
33
|
+
{ cmd: 'workspaces sync', aliases: 'projects sync', desc: 'Rescan cwd workspace into ~/.xrystal' },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
27
36
|
{
|
|
28
37
|
title: 'Project',
|
|
29
38
|
items: [
|
|
30
|
-
{ cmd: 'create', hint: '<name> [path]', desc: 'Scaffold template · optional parent dir' },
|
|
39
|
+
{ cmd: 'create', hint: '<name> [path]', desc: 'Scaffold single service template · optional parent dir' },
|
|
31
40
|
{ cmd: 'tmp', desc: 'Ensure tmp.yml exists (runtime config seed)' },
|
|
32
41
|
{ cmd: 'hooks install', desc: 'Install .git/hooks pre-commit version check' },
|
|
33
42
|
{ cmd: 'hooks status', desc: 'Show whether pre-commit hook is installed' },
|
|
34
|
-
{ cmd: 'sync', desc: 'Sync tsconfig for project or all workspace entries' },
|
|
35
|
-
{ cmd: 'projects', desc: 'List ~/.xrystal registry (workspaces + linked projects)' },
|
|
36
43
|
],
|
|
37
44
|
},
|
|
38
45
|
{
|
|
@@ -52,6 +59,7 @@ const COMMAND_GROUPS = [
|
|
|
52
59
|
|
|
53
60
|
const SECTION_COLORS = {
|
|
54
61
|
Develop: chalk.bold.cyan,
|
|
62
|
+
Workspace: chalk.bold.blue,
|
|
55
63
|
Project: chalk.bold.green,
|
|
56
64
|
Diagnostics: chalk.bold.yellow,
|
|
57
65
|
Release: chalk.bold.magenta,
|
|
@@ -122,7 +130,7 @@ export function formatRootHelp({ cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
122
130
|
|
|
123
131
|
export function formatCreateHelp({ cliName = CLI_PRIMARY_NAME } = {}) {
|
|
124
132
|
const examples = [
|
|
125
|
-
{ cmd: `${cliName} create demo --workspace`, desc: '→ workspace with api/admin/
|
|
133
|
+
{ cmd: `${cliName} create demo --workspace`, desc: '→ workspace with api/admin/web' },
|
|
126
134
|
{ cmd: `${cliName} create my-api`, desc: '→ ./my-api (current folder)' },
|
|
127
135
|
{ cmd: `${cliName} create my-api ..`, desc: '→ ../my-api' },
|
|
128
136
|
{ cmd: `${cliName} create my-api ~/services`, desc: '→ ~/services/my-api' },
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { getRuntimeTooling, detectCliHostRuntime } from './cli-runtime.mjs'
|
|
6
|
+
import { packageDefaults } from './package-defaults.mjs'
|
|
7
|
+
|
|
8
|
+
function readDeclaredCoreVersion(pkg) {
|
|
9
|
+
return pkg.dependencies?.[packageDefaults.packageName]
|
|
10
|
+
?? pkg.devDependencies?.[packageDefaults.packageName]
|
|
11
|
+
?? null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function normalizePinnedVersion(value) {
|
|
15
|
+
return String(value ?? '').trim().replace(/^[\^~]/, '')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function syncCoreDependency(root, targetVersion, { dryRun = false } = {}) {
|
|
19
|
+
const pkgPath = path.join(root, 'package.json')
|
|
20
|
+
if (!fs.existsSync(pkgPath)) {
|
|
21
|
+
return { synced: false, reason: 'no package.json' }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
25
|
+
if (pkg.name === packageDefaults.packageName) {
|
|
26
|
+
return { synced: false, reason: 'core package' }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const declared = readDeclaredCoreVersion(pkg)
|
|
30
|
+
if (!declared) {
|
|
31
|
+
return { synced: false, reason: 'no core dependency' }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const current = normalizePinnedVersion(declared)
|
|
35
|
+
if (current === targetVersion) {
|
|
36
|
+
return { synced: false, reason: 'up-to-date', declared, current }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (dryRun) {
|
|
40
|
+
return { synced: true, dryRun: true, declared, current, targetVersion }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const { packageManager } = getRuntimeTooling(detectCliHostRuntime())
|
|
44
|
+
execSync(`${packageManager} add ${packageDefaults.packageName}@${targetVersion}`, {
|
|
45
|
+
cwd: root,
|
|
46
|
+
stdio: 'inherit',
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
return { synced: true, declared, current, targetVersion }
|
|
50
|
+
}
|
package/x/bin/main-cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { registerDoctorCommand } from './commands/doctor.mjs'
|
|
|
8
8
|
import { registerProjectCommands } from './commands/project.mjs'
|
|
9
9
|
import { registerTmpCommand } from './commands/tmp.mjs'
|
|
10
10
|
import { registerSyncCommand } from './commands/sync.mjs'
|
|
11
|
-
import { registerProjectsCommand } from './commands/projects.mjs'
|
|
11
|
+
import { registerProjectsCommand, registerWorkspacesCommand } from './commands/projects.mjs'
|
|
12
12
|
import { registerTagCommand, registerVersionCommand } from './commands/release.mjs'
|
|
13
13
|
import { registerHooksCommand } from './commands/hooks.mjs'
|
|
14
14
|
import { printBanner, shouldShowBanner } from './helpers/banner.mjs'
|
|
@@ -67,6 +67,7 @@ registerTagCommand(cli, cliContext)
|
|
|
67
67
|
registerDoctorCommand(cli, cliContext)
|
|
68
68
|
registerTmpCommand(cli, cliContext)
|
|
69
69
|
registerSyncCommand(cli, cliContext)
|
|
70
|
+
registerWorkspacesCommand(cli, cliContext)
|
|
70
71
|
registerProjectsCommand(cli, cliContext)
|
|
71
72
|
registerHooksCommand(cli, cliContext)
|
|
72
73
|
registerProjectCommands(cli, cliContext)
|
|
@@ -121,11 +121,42 @@ export function assertNpmPackClean(root = process.cwd()) {
|
|
|
121
121
|
return dryRun
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
function parseNamedExportBlock(source) {
|
|
125
|
+
const match = source.match(/export\s*\{([^}]+)\}/s)
|
|
126
|
+
if (!match) return []
|
|
127
|
+
return match[1]
|
|
128
|
+
.split(',')
|
|
129
|
+
.map((part) => part.trim())
|
|
130
|
+
.filter(Boolean)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function assertCliGeneratedExports(root = process.cwd()) {
|
|
134
|
+
const wrapperPath = path.join(root, 'x/bin/helpers/tmp-schema.mjs')
|
|
135
|
+
const generatedPath = path.join(root, 'x/bin/helpers/.generated/tmp-schema.mjs')
|
|
136
|
+
if (!fs.existsSync(wrapperPath) || !fs.existsSync(generatedPath)) {
|
|
137
|
+
throw new PublishGuardError('CLI tmp-schema wrapper or .generated/tmp-schema.mjs missing — run build first')
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const wrapper = fs.readFileSync(wrapperPath, 'utf8')
|
|
141
|
+
const generated = fs.readFileSync(generatedPath, 'utf8')
|
|
142
|
+
const names = parseNamedExportBlock(wrapper)
|
|
143
|
+
|
|
144
|
+
for (const name of names) {
|
|
145
|
+
const provides = new RegExp(`\\b${name}\\b`).test(generated)
|
|
146
|
+
if (!provides) {
|
|
147
|
+
throw new PublishGuardError(
|
|
148
|
+
`x/bin/helpers/tmp-schema.mjs re-exports '${name}' but .generated/tmp-schema.mjs does not provide it — run xry build`,
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
124
154
|
export function runPublishGuards(root = process.cwd(), { strictDisk = false } = {}) {
|
|
125
155
|
const pkg = readPackage(root)
|
|
126
156
|
assertFilesListNoSource(pkg)
|
|
127
157
|
assertFilesListHasDist(pkg)
|
|
128
158
|
assertMainExportsPointToDist(pkg)
|
|
159
|
+
assertCliGeneratedExports(root)
|
|
129
160
|
assertDistTree(root)
|
|
130
161
|
assertNpmPackClean(root)
|
|
131
162
|
if (strictDisk) {
|