@xrystal/core 3.55.88 → 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 CHANGED
@@ -55,9 +55,9 @@ npm install @xrystal/core
55
55
 
56
56
  ## Release (npm) / Yayın (npm)
57
57
 
58
- **EN:** Bump with `xry version patch` (etc.), commit, then ship with `xry version release` (aliases: `xry release`, `xry tag`). That runs 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).
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 version patch` ile bump, commit, sonra `xry version release` ile yayınla (`xry release` / `xry tag` alias). 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).
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.88",
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",
@@ -13,12 +13,9 @@ import {
13
13
  runCalverTagPush,
14
14
  assertCalverFormat,
15
15
  detectCalverEnv,
16
- bumpCalverPatch,
17
16
  gitTagFromCalver,
18
17
  } from '../scripts/calver.mjs'
19
- import { bumpSemverLevel, resolveReleaseMode } from '../scripts/release-bump.mjs'
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
 
@@ -60,34 +57,16 @@ function attachShipOptions(cmd) {
60
57
  .option('--skip-prepare', 'Skip lint, test, and build (core only)')
61
58
  }
62
59
 
63
- function writePackageVersion(root, version) {
64
- const pkgPath = path.join(root, 'package.json')
65
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
66
- pkg.version = version
67
- fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`)
68
- }
69
-
70
60
  function runVersionBump({ cliName, level, dryRun }) {
71
61
  try {
72
62
  const { root } = requireServiceRoot(process.cwd(), { cliName, command: `version ${level}` })
73
- const mode = resolveReleaseMode(root)
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(next))
65
+ console.log(chalk.bold(result.nextVersion))
86
66
  return
87
67
  }
88
- writePackageVersion(root, next)
89
- console.log(chalk.green(`package.json → ${next}`))
90
- console.log(chalk.gray(`Commit package.json, then: ${cliName} version release`))
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,8 +80,8 @@ 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 repos: patch only)',
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 }))
@@ -142,7 +121,7 @@ export function registerTagCommand(cli, opts) {
142
121
  export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
143
122
  const version = cli
144
123
  .command('version')
145
- .description('Bump package.json (patch|minor|major) or full ship (version release)')
124
+ .description('Bump + commit package.json (patch|minor|major) or full ship (version release)')
146
125
 
147
126
  registerVersionBumpSubcommands(version, { cliName })
148
127
  registerVersionReleaseSubcommand(version, { cliName })
@@ -82,12 +82,12 @@ function commandGroups() {
82
82
  {
83
83
  title: t('sections.release'),
84
84
  items: [
85
- { cmd: 'version patch', desc: 'Bump package.json only — core SemVer · service CalVer pN' },
86
- { cmd: 'version minor|major', desc: 'Bump only — @xrystal/core SemVer' },
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
87
  {
88
88
  cmd: 'version release',
89
89
  aliases: 'release · tag',
90
- desc: 'Full ship — validate, prepare, push v*/CalVer, CI npm publish',
90
+ desc: 'Full ship — tag + push committed version → GitHub / CI npm or image',
91
91
  },
92
92
  ],
93
93
  },
@@ -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('Commit package.json before tagging.')
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
- function printCoreNextSteps(version) {
46
- console.log(chalk.gray('\nNext (core / npm):'))
47
- console.log(` git add package.json && git commit -m "Bump library version"`)
48
- console.log(` bun run release`)
49
- console.log(chalk.dim(` or: xry version release → ships v${version}\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
- function printServiceNextSteps(version) {
53
- const tag = gitTagFromCalver(version)
54
- console.log(chalk.gray('\nNext (service / GHCR):'))
55
- console.log(` git add package.json && git commit -m "Bump image version"`)
56
- console.log(` git push origin <branch>`)
57
- console.log(` bun run release`)
58
- console.log(chalk.dim(` or: xry version release → pushes ${tag} → CI\n`))
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
- async function main() {
62
- const args = process.argv.slice(2)
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
- if (!level || !['patch', 'minor', 'major'].includes(level)) {
67
- console.error('Usage: release-bump.mjs patch|minor|major')
68
- console.error(' SemVer: core or service with 2.0.x in package.json')
69
- console.error(' CalVer: default service — patch only (26.11.11-dev-pN)')
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
- const root = resolveProjectRoot()
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
- writePackageVersion(root, nextVersion)
102
-
103
- if (isCorePackageProject(root)) {
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
 
@@ -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\nCommit the version bump first, then run version release again.`
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\nCommit package.json before tagging.`
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