@xrystal/core 3.55.87 → 3.55.89
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 +3 -3
- package/package.json +5 -4
- package/x/bin/commands/release.mjs +77 -65
- package/x/bin/helpers/cli-help.mjs +7 -3
- package/x/bin/helpers/project-context.mjs +1 -1
- package/x/bin/main-cli.js +2 -2
- package/x/bin/scripts/calver.mjs +2 -2
- package/x/bin/scripts/release-bump.mjs +87 -33
- package/x/bin/scripts/release-prepare.mjs +1 -1
- package/x/bin/scripts/tag.mjs +5 -1
- package/x/bin/scripts/version-check.mjs +2 -2
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
| **DTO & UX** | `@xrystal/dto`, i18n, request trace, logging | DTO, i18n, trace, log |
|
|
26
26
|
| **Data (optional)** | Redis, MongoDB, Kafka loaders | İsteğe bağlı Redis / Mongo / Kafka |
|
|
27
27
|
| **Realtime** | WebSocket / Socket.IO on the same pattern as HTTP | HTTP ile aynı kalıpta ws / Socket.IO |
|
|
28
|
-
| **CLI** | `xry dev`, `build`, `start`, `test`, `create`, `version`, `
|
|
28
|
+
| **CLI** | `xry dev`, `build`, `start`, `test`, `create`, `version`, `version release` | Geliştirme, build, scaffold, sürüm |
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
@@ -55,9 +55,9 @@ npm install @xrystal/core
|
|
|
55
55
|
|
|
56
56
|
## Release (npm) / Yayın (npm)
|
|
57
57
|
|
|
58
|
-
**EN:**
|
|
58
|
+
**EN:** `xry version patch` (also `minor` / `major`) bumps `package.json` and **commits that bump** (no tag). Then `xry version release` (aliases: `xry release`, `xry tag`) ships the committed version: full gates + SemVer `v*` push; GitHub Actions `publish.yml` publishes to npm with `--tag latest` via [Trusted Publishers](https://docs.npmjs.com/trusted-publishers) (OIDC). Housekeeping: `artifact.yml` (zip backups) and `clean.yml` (scheduled release pruning).
|
|
59
59
|
|
|
60
|
-
**TR:** `xry
|
|
60
|
+
**TR:** `xry version patch` (`minor` / `major`) `package.json` sürümünü yazar ve **o bump’ı commit eder** (tag yok). Sonra `xry version release` (`xry release` / `xry tag`) commit’lenmiş sürümü yayınlar: tam kapı + SemVer `v*` push; `publish.yml` npm’e `--tag latest` ve [Trusted Publisher](https://docs.npmjs.com/trusted-publishers) (OIDC) ile yazar. Bakım: `artifact.yml` (zip yedek), `clean.yml` (release temizliği).
|
|
61
61
|
|
|
62
62
|
## Further reading / Ek kaynak
|
|
63
63
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Yusuf Yasir KAYGUSUZ",
|
|
3
3
|
"name": "@xrystal/core",
|
|
4
|
-
"version": "3.55.
|
|
4
|
+
"version": "3.55.89",
|
|
5
5
|
"description": "Runtime framework and CLI for API services, frontends, and multi-repo workspaces",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"build:prod": "bun run release:prepare && node x/bin/scripts/clean-source-types.mjs",
|
|
84
84
|
"build:dev": "node x/bin/main-cli.js dev",
|
|
85
85
|
"start": "node x/bin/main-cli.js start",
|
|
86
|
+
"release": "node x/bin/scripts/tag.mjs",
|
|
86
87
|
"tag": "node x/bin/scripts/tag.mjs",
|
|
87
88
|
"version:patch": "node x/bin/scripts/release-bump.mjs patch",
|
|
88
89
|
"version:minor": "node x/bin/scripts/release-bump.mjs minor",
|
|
@@ -91,7 +92,7 @@
|
|
|
91
92
|
"hooks:install": "node x/bin/scripts/install-git-hooks.mjs"
|
|
92
93
|
},
|
|
93
94
|
"dependencies": {
|
|
94
|
-
"@xrystal/dto": "
|
|
95
|
+
"@xrystal/dto": "26.11.14-p5",
|
|
95
96
|
"awilix": "^12.0.5",
|
|
96
97
|
"chalk": "^5.6.2",
|
|
97
98
|
"commander": "^13.0.0",
|
|
@@ -100,12 +101,12 @@
|
|
|
100
101
|
"i18next-fs-backend": "^2.6.1",
|
|
101
102
|
"i18next-http-middleware": "^3.8.2",
|
|
102
103
|
"kafkajs": "^2.2.4",
|
|
103
|
-
"mongodb": "^6.20.0",
|
|
104
|
-
"redis": "^5.8.2",
|
|
105
104
|
"lodash": "^4.17.23",
|
|
105
|
+
"mongodb": "^6.20.0",
|
|
106
106
|
"ora": "^9.0.0",
|
|
107
107
|
"picocolors": "^1.1.1",
|
|
108
108
|
"qs": "^6.14.1",
|
|
109
|
+
"redis": "^5.8.2",
|
|
109
110
|
"soap": "^1.6.3",
|
|
110
111
|
"winston": "^3.19.0",
|
|
111
112
|
"winston-daily-rotate-file": "^5.0.0",
|
|
@@ -13,81 +13,60 @@ import {
|
|
|
13
13
|
runCalverTagPush,
|
|
14
14
|
assertCalverFormat,
|
|
15
15
|
detectCalverEnv,
|
|
16
|
-
bumpCalverPatch,
|
|
17
16
|
gitTagFromCalver,
|
|
18
17
|
} from '../scripts/calver.mjs'
|
|
19
|
-
import {
|
|
20
|
-
import fs from 'node:fs'
|
|
21
|
-
import path from 'node:path'
|
|
18
|
+
import { applyVersionBump } from '../scripts/release-bump.mjs'
|
|
22
19
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
23
20
|
import { CLI_PRIMARY_NAME, PACKAGE_NAME } from '../helpers/cli-identity.mjs'
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const version = getVersionState('HEAD', root).committed.version
|
|
44
|
-
const calverEnv = detectCalverEnv(version)
|
|
45
|
-
if (calverEnv) {
|
|
46
|
-
assertCalverFormat(version, calverEnv)
|
|
47
|
-
} else {
|
|
48
|
-
assertVersionFormat(version)
|
|
49
|
-
}
|
|
50
|
-
runCalverTagPush({ root, dryRun: options.dryRun })
|
|
51
|
-
}
|
|
52
|
-
if (!options.dryRun) {
|
|
53
|
-
console.log(chalk.green('\n✓ Tag pushed.\n'))
|
|
54
|
-
}
|
|
55
|
-
} catch (error) {
|
|
56
|
-
if (error?.name === 'CliContextError') exitOnCliContextError(error)
|
|
57
|
-
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
58
|
-
process.exit(1)
|
|
22
|
+
/** Full ship: version gates → prepare → push release tag → CI npm publish. */
|
|
23
|
+
async function runShipRelease({ cliName, commandLabel, options }) {
|
|
24
|
+
try {
|
|
25
|
+
const { root } = requireServiceRoot(process.cwd(), { cliName, command: commandLabel })
|
|
26
|
+
if (isCorePackageProject(root)) {
|
|
27
|
+
await runTagRelease({
|
|
28
|
+
dryRun: options.dryRun,
|
|
29
|
+
requireClean: options.strictClean,
|
|
30
|
+
skipPrepare: options.skipPrepare,
|
|
31
|
+
root,
|
|
32
|
+
})
|
|
33
|
+
} else {
|
|
34
|
+
const version = getVersionState('HEAD', root).committed.version
|
|
35
|
+
const calverEnv = detectCalverEnv(version)
|
|
36
|
+
if (calverEnv) {
|
|
37
|
+
assertCalverFormat(version, calverEnv)
|
|
38
|
+
} else {
|
|
39
|
+
assertVersionFormat(version)
|
|
59
40
|
}
|
|
60
|
-
|
|
41
|
+
runCalverTagPush({ root, dryRun: options.dryRun })
|
|
42
|
+
}
|
|
43
|
+
if (!options.dryRun) {
|
|
44
|
+
console.log(chalk.green('\n✓ Release shipped — CI publish should follow.\n'))
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (error?.name === 'CliContextError') exitOnCliContextError(error)
|
|
48
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
49
|
+
process.exit(1)
|
|
50
|
+
}
|
|
61
51
|
}
|
|
62
52
|
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
53
|
+
function attachShipOptions(cmd) {
|
|
54
|
+
return cmd
|
|
55
|
+
.option('--dry-run', 'Print commands without executing')
|
|
56
|
+
.option('--strict-clean', 'Require fully clean working tree (default: only package.json must be committed)')
|
|
57
|
+
.option('--skip-prepare', 'Skip lint, test, and build (core only)')
|
|
68
58
|
}
|
|
69
59
|
|
|
70
60
|
function runVersionBump({ cliName, level, dryRun }) {
|
|
71
61
|
try {
|
|
72
62
|
const { root } = requireServiceRoot(process.cwd(), { cliName, command: `version ${level}` })
|
|
73
|
-
const
|
|
74
|
-
const state = getVersionState('HEAD', root)
|
|
75
|
-
let next
|
|
76
|
-
if (mode === 'semver') {
|
|
77
|
-
next = bumpSemverLevel(state.disk.version, level)
|
|
78
|
-
} else {
|
|
79
|
-
if (level !== 'patch') {
|
|
80
|
-
throw new Error('CalVer — only patch. package.json SemVer (2.0.x) ise minor/major açılır.')
|
|
81
|
-
}
|
|
82
|
-
next = bumpCalverPatch(root).next
|
|
83
|
-
}
|
|
63
|
+
const result = applyVersionBump(root, level, { dryRun })
|
|
84
64
|
if (dryRun) {
|
|
85
|
-
console.log(chalk.bold(
|
|
65
|
+
console.log(chalk.bold(result.nextVersion))
|
|
86
66
|
return
|
|
87
67
|
}
|
|
88
|
-
|
|
89
|
-
console.log(chalk.
|
|
90
|
-
console.log(chalk.gray('Commit package.json, then: xry tag'))
|
|
68
|
+
console.log(chalk.green(`package.json → ${result.nextVersion} (committed)`))
|
|
69
|
+
console.log(chalk.gray(`Next: ${cliName} version release`))
|
|
91
70
|
} catch (error) {
|
|
92
71
|
if (error?.name === 'CliContextError') exitOnCliContextError(error)
|
|
93
72
|
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
@@ -101,18 +80,51 @@ function registerVersionBumpSubcommands(versionCmd, { cliName = CLI_PRIMARY_NAME
|
|
|
101
80
|
.command(level)
|
|
102
81
|
.description(
|
|
103
82
|
level === 'patch'
|
|
104
|
-
? 'Bump package.json — core SemVer · service CalVer pN'
|
|
105
|
-
: 'SemVer minor/major (CalVer
|
|
83
|
+
? 'Bump + commit package.json — core SemVer · service CalVer pN (no tag)'
|
|
84
|
+
: 'Bump + commit SemVer minor/major (CalVer: patch only; no tag)',
|
|
106
85
|
)
|
|
107
86
|
.option('--dry-run', 'Print next version only')
|
|
108
87
|
.action((options) => runVersionBump({ cliName, level, dryRun: options.dryRun }))
|
|
109
88
|
}
|
|
110
89
|
}
|
|
111
90
|
|
|
91
|
+
function registerVersionReleaseSubcommand(versionCmd, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
92
|
+
attachShipOptions(
|
|
93
|
+
versionCmd
|
|
94
|
+
.command('release')
|
|
95
|
+
.description(
|
|
96
|
+
`Full release: validate package.json, prepare, ship v* / CalVer (CI npm publish for ${packageDefaults.packageName})`,
|
|
97
|
+
),
|
|
98
|
+
).action(async (options) => {
|
|
99
|
+
await runShipRelease({ cliName, commandLabel: 'version release', options })
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Quiet top-level aliases of `version release`. */
|
|
104
|
+
export function registerReleaseAliases(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
105
|
+
const shipDesc = `Alias of ${cliName} version release — full ship (validate, prepare, push, CI publish)`
|
|
106
|
+
|
|
107
|
+
attachShipOptions(cli.command('release').description(shipDesc)).action(async (options) => {
|
|
108
|
+
await runShipRelease({ cliName, commandLabel: 'release', options })
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
attachShipOptions(cli.command('tag').description(shipDesc)).action(async (options) => {
|
|
112
|
+
await runShipRelease({ cliName, commandLabel: 'tag', options })
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** @deprecated Use registerReleaseAliases — kept for import compatibility. */
|
|
117
|
+
export function registerTagCommand(cli, opts) {
|
|
118
|
+
registerReleaseAliases(cli, opts)
|
|
119
|
+
}
|
|
120
|
+
|
|
112
121
|
export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
113
|
-
const version = cli
|
|
122
|
+
const version = cli
|
|
123
|
+
.command('version')
|
|
124
|
+
.description('Bump + commit package.json (patch|minor|major) or full ship (version release)')
|
|
114
125
|
|
|
115
126
|
registerVersionBumpSubcommands(version, { cliName })
|
|
127
|
+
registerVersionReleaseSubcommand(version, { cliName })
|
|
116
128
|
|
|
117
129
|
version
|
|
118
130
|
.command('show', { isDefault: true })
|
|
@@ -135,13 +147,13 @@ export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
135
147
|
console.log(` package.json (HEAD): ${chalk.bold(state.committed.version)}`)
|
|
136
148
|
const isCore = isCorePackageProject(root)
|
|
137
149
|
if (isCore) {
|
|
138
|
-
console.log(`
|
|
150
|
+
console.log(` release tag: ${chalk.bold(`v${state.committed.version}`)}`)
|
|
139
151
|
} else {
|
|
140
152
|
const cv = detectCalverEnv(state.committed.version)
|
|
141
153
|
const tagLine = cv
|
|
142
154
|
? chalk.bold(gitTagFromCalver(state.committed.version))
|
|
143
|
-
: chalk.gray(
|
|
144
|
-
console.log(`
|
|
155
|
+
: chalk.gray(`set CalVer in package.json, then ${cliName} version release`)
|
|
156
|
+
console.log(` release tag: ${tagLine}`)
|
|
145
157
|
}
|
|
146
158
|
console.log(` branch: ${state.branch}`)
|
|
147
159
|
console.log(` version match: ${state.versionMatch ? chalk.green('yes') : chalk.red('no')}`)
|
|
@@ -82,9 +82,13 @@ function commandGroups() {
|
|
|
82
82
|
{
|
|
83
83
|
title: t('sections.release'),
|
|
84
84
|
items: [
|
|
85
|
-
{ cmd: 'version patch', desc: 'Bump package.json — core SemVer · service CalVer pN' },
|
|
86
|
-
{ cmd: 'version minor|major', desc: '@xrystal/core
|
|
87
|
-
{
|
|
85
|
+
{ cmd: 'version patch', desc: 'Bump + commit package.json — core SemVer · service CalVer pN (no tag)' },
|
|
86
|
+
{ cmd: 'version minor|major', desc: 'Bump + commit SemVer — @xrystal/core (CalVer: patch only)' },
|
|
87
|
+
{
|
|
88
|
+
cmd: 'version release',
|
|
89
|
+
aliases: 'release · tag',
|
|
90
|
+
desc: 'Full ship — tag + push committed version → GitHub / CI npm or image',
|
|
91
|
+
},
|
|
88
92
|
],
|
|
89
93
|
},
|
|
90
94
|
]
|
|
@@ -61,7 +61,7 @@ export function resolveProjectContext(startDir = process.cwd()) {
|
|
|
61
61
|
selfMismatch: null,
|
|
62
62
|
schemaVersionExpected: TMP_SCHEMA_VERSION,
|
|
63
63
|
hints: [
|
|
64
|
-
'Global runtime library —
|
|
64
|
+
'Global runtime library — ship via xry version release',
|
|
65
65
|
'tmp global.type: core-library (not workspace / not api-service)',
|
|
66
66
|
'Consumers: bun add @xrystal/core && xry tmp in their repo',
|
|
67
67
|
],
|
package/x/bin/main-cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { registerProjectCommands } from './commands/project.mjs'
|
|
|
10
10
|
import { registerTmpCommand } from './commands/tmp.mjs'
|
|
11
11
|
import { registerSyncCommand } from './commands/sync.mjs'
|
|
12
12
|
import { registerProjectsCommand, registerWorkspacesCommand } from './commands/projects.mjs'
|
|
13
|
-
import {
|
|
13
|
+
import { registerReleaseAliases, registerVersionCommand } from './commands/release.mjs'
|
|
14
14
|
import { registerTelepresenceCommand } from './commands/telepresence.mjs'
|
|
15
15
|
import { registerHooksCommand } from './commands/hooks.mjs'
|
|
16
16
|
import { registerWatchCommand } from './commands/watch.mjs'
|
|
@@ -83,7 +83,7 @@ cli
|
|
|
83
83
|
|
|
84
84
|
registerCreateCommand(cli, cliContext)
|
|
85
85
|
registerVersionCommand(cli, cliContext)
|
|
86
|
-
|
|
86
|
+
registerReleaseAliases(cli, cliContext)
|
|
87
87
|
registerDoctorCommand(cli, cliContext)
|
|
88
88
|
registerTmpCommand(cli, cliContext)
|
|
89
89
|
registerProjectInfoCommand(cli, cliContext)
|
package/x/bin/scripts/calver.mjs
CHANGED
|
@@ -108,10 +108,10 @@ export function runCalverTagPush({ root, dryRun = false } = {}) {
|
|
|
108
108
|
const version = state.committed.version
|
|
109
109
|
|
|
110
110
|
if (!state.isPackageJsonClean) {
|
|
111
|
-
throw new Error('
|
|
111
|
+
throw new Error('package.json uncommitted — run `xry version patch` (or commit the bump) before tagging.')
|
|
112
112
|
}
|
|
113
113
|
if (!state.versionMatch) {
|
|
114
|
-
throw new Error('package.json on disk does not match HEAD — commit first.')
|
|
114
|
+
throw new Error('package.json on disk does not match HEAD — run `xry version patch` (or commit) first.')
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
const tagName = gitTagFromCalver(version)
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import fs from 'node:fs'
|
|
4
4
|
import path from 'node:path'
|
|
5
|
+
import { execFileSync } from 'node:child_process'
|
|
5
6
|
import chalk from 'chalk'
|
|
6
7
|
import { resolveProjectRoot } from '../helpers/project-root.mjs'
|
|
7
8
|
import { isCorePackageProject } from './release-prepare.mjs'
|
|
8
9
|
import { fileURLToPath } from 'node:url'
|
|
9
|
-
import { parseSemver, getVersionState, readDiskPackageJson } from './version-check.mjs'
|
|
10
|
+
import { parseSemver, getVersionState, readDiskPackageJson, run } from './version-check.mjs'
|
|
10
11
|
import { bumpCalverPatch, gitTagFromCalver, detectCalverEnv } from './calver.mjs'
|
|
12
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
11
13
|
|
|
12
14
|
/** @returns {'semver'|'calver'} */
|
|
13
15
|
export function resolveReleaseMode(root) {
|
|
@@ -42,37 +44,53 @@ export function bumpSemverLevel(version, level) {
|
|
|
42
44
|
throw new Error(`Unknown semver level: ${level}`)
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
console.log(chalk.dim(` git tag will be v${version} after commit\n`))
|
|
47
|
+
/** Commit message for a package.json version bump (includes version for release alignment). */
|
|
48
|
+
export function bumpCommitMessage(version, { isCore }) {
|
|
49
|
+
if (isCore) return `Release ${version} for npm publish.`
|
|
50
|
+
return `Release ${version} for image publish.`
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
53
|
+
/**
|
|
54
|
+
* Stage and commit only package.json after a version bump. No tags.
|
|
55
|
+
* Path-scoped so unrelated dirty files stay unstaged / uncommitted.
|
|
56
|
+
*/
|
|
57
|
+
export function commitPackageJsonBump(root, version, { isCore } = {}) {
|
|
58
|
+
try {
|
|
59
|
+
run('git rev-parse --git-dir', { root })
|
|
60
|
+
} catch {
|
|
61
|
+
throw new Error('Not a git repository — cannot commit version bump.')
|
|
62
|
+
}
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const dryRun = args.includes('--dry-run')
|
|
64
|
-
const level = args.find((a) => !a.startsWith('--'))?.toLowerCase()
|
|
64
|
+
const core = isCore ?? isCorePackageProject(root)
|
|
65
|
+
const message = bumpCommitMessage(version, { isCore: core })
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
process.exit(1)
|
|
67
|
+
run('git add -- package.json', { root })
|
|
68
|
+
const staged = run('git diff --cached --name-only -- package.json', { root })
|
|
69
|
+
if (!staged.trim()) {
|
|
70
|
+
throw new Error('Nothing to commit: package.json has no staged changes after bump.')
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
try {
|
|
74
|
+
execFileSync('git', ['commit', '-m', message, '--', 'package.json'], {
|
|
75
|
+
cwd: root,
|
|
76
|
+
stdio: 'inherit',
|
|
77
|
+
encoding: 'utf8',
|
|
78
|
+
})
|
|
79
|
+
} catch (error) {
|
|
80
|
+
throw new Error(`git commit failed for package.json bump: ${error.message}`)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return { version, message, isCore: core }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Bump package.json version and commit that file only (no tag).
|
|
88
|
+
* @returns {{ nextVersion: string, mode: 'semver'|'calver', calverEnv?: string, isCore: boolean, commit?: { version: string, message: string }, dryRun?: boolean }}
|
|
89
|
+
*/
|
|
90
|
+
export function applyVersionBump(root, level, { dryRun = false } = {}) {
|
|
74
91
|
const mode = resolveReleaseMode(root)
|
|
75
92
|
const state = getVersionState('HEAD', root)
|
|
93
|
+
const isCore = isCorePackageProject(root)
|
|
76
94
|
|
|
77
95
|
let nextVersion
|
|
78
96
|
let calverEnv
|
|
@@ -87,23 +105,59 @@ async function main() {
|
|
|
87
105
|
calverEnv = bumped.env
|
|
88
106
|
}
|
|
89
107
|
|
|
108
|
+
if (dryRun) {
|
|
109
|
+
return { nextVersion, mode, calverEnv, isCore, dryRun: true }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
writePackageVersion(root, nextVersion)
|
|
113
|
+
const commit = commitPackageJsonBump(root, nextVersion, { isCore })
|
|
114
|
+
return { nextVersion, mode, calverEnv, isCore, commit }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function printCoreNextSteps(version, cliName = CLI_PRIMARY_NAME) {
|
|
118
|
+
console.log(chalk.gray('\nNext (core / npm):'))
|
|
119
|
+
console.log(` ${cliName} version release`)
|
|
120
|
+
console.log(chalk.dim(` → ships v${version} (tag + push → CI npm publish)\n`))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function printServiceNextSteps(version, cliName = CLI_PRIMARY_NAME) {
|
|
124
|
+
const tag = gitTagFromCalver(version)
|
|
125
|
+
console.log(chalk.gray('\nNext (service / GHCR):'))
|
|
126
|
+
console.log(` ${cliName} version release`)
|
|
127
|
+
console.log(chalk.dim(` → pushes ${tag} → CI\n`))
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function main() {
|
|
131
|
+
const args = process.argv.slice(2)
|
|
132
|
+
const dryRun = args.includes('--dry-run')
|
|
133
|
+
const level = args.find((a) => !a.startsWith('--'))?.toLowerCase()
|
|
134
|
+
|
|
135
|
+
if (!level || !['patch', 'minor', 'major'].includes(level)) {
|
|
136
|
+
console.error('Usage: release-bump.mjs patch|minor|major')
|
|
137
|
+
console.error(' SemVer: core or service with 2.0.x in package.json')
|
|
138
|
+
console.error(' CalVer: default service — patch only (26.11.11-dev-pN)')
|
|
139
|
+
process.exit(1)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const root = resolveProjectRoot()
|
|
143
|
+
const result = applyVersionBump(root, level, { dryRun })
|
|
144
|
+
|
|
90
145
|
console.log(chalk.cyan(`\nRelease bump (${level})`))
|
|
91
146
|
console.log(` root: ${root}`)
|
|
92
|
-
console.log(` mode: ${mode}`)
|
|
93
|
-
if (calverEnv) console.log(` env: ${calverEnv} (branch / package.json)`)
|
|
94
|
-
console.log(` version: ${chalk.bold(nextVersion)}`)
|
|
147
|
+
console.log(` mode: ${result.mode}`)
|
|
148
|
+
if (result.calverEnv) console.log(` env: ${result.calverEnv} (branch / package.json)`)
|
|
149
|
+
console.log(` version: ${chalk.bold(result.nextVersion)}`)
|
|
95
150
|
|
|
96
151
|
if (dryRun) {
|
|
97
|
-
console.log(chalk.gray('[dry-run] no package.json write\n'))
|
|
152
|
+
console.log(chalk.gray('[dry-run] no package.json write / commit\n'))
|
|
98
153
|
return
|
|
99
154
|
}
|
|
100
155
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
printCoreNextSteps(nextVersion)
|
|
156
|
+
console.log(chalk.green(`✓ committed package.json → ${result.nextVersion}`))
|
|
157
|
+
if (result.isCore) {
|
|
158
|
+
printCoreNextSteps(result.nextVersion)
|
|
105
159
|
} else {
|
|
106
|
-
printServiceNextSteps(nextVersion)
|
|
160
|
+
printServiceNextSteps(result.nextVersion)
|
|
107
161
|
}
|
|
108
162
|
}
|
|
109
163
|
|
|
@@ -56,6 +56,6 @@ export function runReleasePrepare({ root = resolveProjectRoot(), dryRun = false,
|
|
|
56
56
|
run(step.cmd, { inherit: true, root })
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
console.log('\n✓ Ready to
|
|
59
|
+
console.log('\n✓ Ready to release. Pushing the release tag will trigger GitHub Actions npm publish.\n')
|
|
60
60
|
return { skipped: false }
|
|
61
61
|
}
|
package/x/bin/scripts/tag.mjs
CHANGED
|
@@ -9,7 +9,11 @@ const skipPrepare = process.argv.includes('--skip-prepare')
|
|
|
9
9
|
try {
|
|
10
10
|
const state = await runTagRelease({ dryRun, skipPrepare })
|
|
11
11
|
if (!dryRun) {
|
|
12
|
-
console.log(
|
|
12
|
+
console.log(
|
|
13
|
+
chalk.green(
|
|
14
|
+
`\n✓ Release ${state.tag.tagName} shipped — GitHub Publish workflow should trigger.\n`,
|
|
15
|
+
),
|
|
16
|
+
)
|
|
13
17
|
}
|
|
14
18
|
} catch (error) {
|
|
15
19
|
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
@@ -365,13 +365,13 @@ export function assertReadyToTag({ requireClean = false, root = getProjectRoot()
|
|
|
365
365
|
|
|
366
366
|
if (!state.isPackageJsonClean) {
|
|
367
367
|
throw new Error(
|
|
368
|
-
`package.json has uncommitted changes:\n${state.packageJsonDirty}\n\
|
|
368
|
+
`package.json has uncommitted changes:\n${state.packageJsonDirty}\n\nRun \`xry version patch\` (or commit the bump), then version release again.`
|
|
369
369
|
)
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
if (!state.versionMatch) {
|
|
373
373
|
throw new Error(
|
|
374
|
-
`package.json version mismatch:\n HEAD commit: ${state.committed.version}\n Disk: ${state.disk.version}\n\
|
|
374
|
+
`package.json version mismatch:\n HEAD commit: ${state.committed.version}\n Disk: ${state.disk.version}\n\nRun \`xry version patch\` (or commit package.json) before tagging.`
|
|
375
375
|
)
|
|
376
376
|
}
|
|
377
377
|
|