@xrystal/core 3.55.66 → 3.55.67
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 +4 -2
- package/package.json +5 -2
- package/x/bin/commands/release.mjs +76 -18
- package/x/bin/helpers/cli-help.mjs +3 -1
- package/x/bin/main-cli.js +3 -6
- package/x/bin/scripts/calver.mjs +130 -0
- package/x/bin/scripts/release-bump.mjs +117 -0
package/README.md
CHANGED
|
@@ -269,6 +269,8 @@ bun run dev
|
|
|
269
269
|
| `xry test` | Run `x/tests` | `x/tests` çalıştır |
|
|
270
270
|
| `xry doctor` | CLI, runtime, package health | CLI, runtime, paket uyumu |
|
|
271
271
|
| `xry tag` | **This repo only** — tag + npm publish (`@xrystal/core`) | **Sadece core** — servislerde çalışmaz / git tag yok |
|
|
272
|
+
| `bun run release:patch` | SemVer **veya** CalVer — `version` şeklinden (default servis = CalVer) | `26.11.11-dev-pN` → CalVer; `2.0.32` → SemVer |
|
|
273
|
+
| `bun run release:minor` | `version` SemVer ise (core + eski servis) | CalVer’de yok |
|
|
272
274
|
|
|
273
275
|
---
|
|
274
276
|
|
|
@@ -877,9 +879,9 @@ class ChatController extends Controller {
|
|
|
877
879
|
|
|
878
880
|
## Maintainer note / Geliştirici notu
|
|
879
881
|
|
|
880
|
-
**EN:**
|
|
882
|
+
**EN:** Core: `bun run release:patch` (SemVer) → commit → `xry tag` (npm). **Services:** same `release:patch` (next CalVer `pN` from branch) → commit → `xry tag` (git tag → GHCR). No `release:dev` — env = `dev` / `staging` / `prod` branch.
|
|
881
883
|
|
|
882
884
|
|
|
883
885
|
**npm CI (`E401` / invalid token):** GitHub → repo **Settings → Environments → NPM** → secret **`TOKEN`** = [npm Granular Access Token](https://www.npmjs.com/settings/~youruser/tokens) with **Publish** on package `@xrystal/core` (or whole `@xrystal` scope). Classic automation tokens that bypass 2FA are being restricted — prefer **Granular** + **Publish**. After rotate: re-run failed **Publish Core Library NPM** workflow or push empty commit / re-tag. Stage flow: workflow runs `npm stage publish` → approve on npmjs.com (`npm stage list` / Approve with 2FA).
|
|
884
886
|
|
|
885
|
-
**TR:**
|
|
887
|
+
**TR:** Core + servis: `bun run release:patch` → commit → `bun run tag` (`xry tag`). Serviste patch = CalVer `dev-pN` / `stag-pN` / prod günü.
|
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.67",
|
|
5
5
|
"description": "Runtime framework and CLI for API services, frontends, and multi-repo workspaces",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -84,6 +84,9 @@
|
|
|
84
84
|
"build:dev": "node x/bin/main-cli.js dev",
|
|
85
85
|
"start": "node x/bin/main-cli.js start",
|
|
86
86
|
"tag": "node x/bin/scripts/tag.mjs",
|
|
87
|
+
"release:patch": "node x/bin/scripts/release-bump.mjs patch",
|
|
88
|
+
"release:minor": "node x/bin/scripts/release-bump.mjs minor",
|
|
89
|
+
"release:major": "node x/bin/scripts/release-bump.mjs major",
|
|
87
90
|
"version:check": "node x/bin/scripts/version-check.mjs",
|
|
88
91
|
"hooks:install": "node x/bin/scripts/install-git-hooks.mjs"
|
|
89
92
|
},
|
|
@@ -123,4 +126,4 @@
|
|
|
123
126
|
"typescript": "~5.9.3",
|
|
124
127
|
"typescript-eslint": "^8.62.1"
|
|
125
128
|
}
|
|
126
|
-
}
|
|
129
|
+
}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
import { readCliPackageJson, readProjectPackageJson } from '../helpers/project-root.mjs'
|
|
3
3
|
import { requireServiceRoot, exitOnCliContextError, CliContextError } from '../helpers/cli-context-guard.mjs'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
assertVersionFormat,
|
|
6
|
+
compareSemver,
|
|
7
|
+
getVersionState,
|
|
8
|
+
resolveVersionBaseline,
|
|
9
|
+
runTagRelease,
|
|
10
|
+
} from '../scripts/version-check.mjs'
|
|
5
11
|
import { isCorePackageProject } from '../scripts/release-prepare.mjs'
|
|
12
|
+
import { runCalverTagPush, assertCalverFormat, detectCalverEnv, bumpCalverPatch } from '../scripts/calver.mjs'
|
|
13
|
+
import { bumpSemverLevel, resolveReleaseMode } from '../scripts/release-bump.mjs'
|
|
14
|
+
import fs from 'node:fs'
|
|
15
|
+
import path from 'node:path'
|
|
6
16
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
7
17
|
import { CLI_PRIMARY_NAME, PACKAGE_NAME } from '../helpers/cli-identity.mjs'
|
|
8
18
|
|
|
@@ -16,24 +26,23 @@ export function registerTagCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
16
26
|
.action(async (options) => {
|
|
17
27
|
try {
|
|
18
28
|
const { root } = requireServiceRoot(process.cwd(), { cliName, command: 'tag' })
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
29
|
+
if (isCorePackageProject(root)) {
|
|
30
|
+
await runTagRelease({
|
|
31
|
+
dryRun: options.dryRun,
|
|
32
|
+
requireClean: options.strictClean,
|
|
33
|
+
skipPrepare: options.skipPrepare,
|
|
34
|
+
root,
|
|
35
|
+
})
|
|
36
|
+
} else {
|
|
37
|
+
const version = getVersionState('HEAD', root).committed.version
|
|
38
|
+
const calverEnv = detectCalverEnv(version)
|
|
39
|
+
if (calverEnv) {
|
|
40
|
+
assertCalverFormat(version, calverEnv)
|
|
41
|
+
} else {
|
|
42
|
+
assertVersionFormat(version)
|
|
43
|
+
}
|
|
44
|
+
runCalverTagPush({ root, dryRun: options.dryRun })
|
|
30
45
|
}
|
|
31
|
-
await runTagRelease({
|
|
32
|
-
dryRun: options.dryRun,
|
|
33
|
-
requireClean: options.strictClean,
|
|
34
|
-
skipPrepare: options.skipPrepare,
|
|
35
|
-
root,
|
|
36
|
-
})
|
|
37
46
|
if (!options.dryRun) {
|
|
38
47
|
console.log(chalk.green('\n✓ Tag pushed.\n'))
|
|
39
48
|
}
|
|
@@ -45,6 +54,55 @@ export function registerTagCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
45
54
|
})
|
|
46
55
|
}
|
|
47
56
|
|
|
57
|
+
function writePackageVersion(root, version) {
|
|
58
|
+
const pkgPath = path.join(root, 'package.json')
|
|
59
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
60
|
+
pkg.version = version
|
|
61
|
+
fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function registerReleaseBumpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
65
|
+
const bump = cli.command('release').description('Bump package.json (core SemVer · service CalVer patch)')
|
|
66
|
+
|
|
67
|
+
for (const level of ['patch', 'minor', 'major']) {
|
|
68
|
+
bump
|
|
69
|
+
.command(level)
|
|
70
|
+
.description(
|
|
71
|
+
level === 'patch'
|
|
72
|
+
? 'SemVer or CalVer patch (from package.json version shape)'
|
|
73
|
+
: 'SemVer minor/major (CalVer repos: patch only)',
|
|
74
|
+
)
|
|
75
|
+
.option('--dry-run', 'Print next version only')
|
|
76
|
+
.action((options) => {
|
|
77
|
+
try {
|
|
78
|
+
const { root } = requireServiceRoot(process.cwd(), { cliName, command: `release ${level}` })
|
|
79
|
+
const mode = resolveReleaseMode(root)
|
|
80
|
+
const state = getVersionState('HEAD', root)
|
|
81
|
+
let next
|
|
82
|
+
if (mode === 'semver') {
|
|
83
|
+
next = bumpSemverLevel(state.disk.version, level)
|
|
84
|
+
} else {
|
|
85
|
+
if (level !== 'patch') {
|
|
86
|
+
throw new Error('CalVer — only patch. package.json SemVer (2.0.x) ise minor/major açılır.')
|
|
87
|
+
}
|
|
88
|
+
next = bumpCalverPatch(root).next
|
|
89
|
+
}
|
|
90
|
+
if (options.dryRun) {
|
|
91
|
+
console.log(chalk.bold(next))
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
writePackageVersion(root, next)
|
|
95
|
+
console.log(chalk.green(`package.json → ${next}`))
|
|
96
|
+
console.log(chalk.gray('Commit package.json, then: xry tag'))
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (error?.name === 'CliContextError') exitOnCliContextError(error)
|
|
99
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
100
|
+
process.exit(1)
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
48
106
|
export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
49
107
|
cli
|
|
50
108
|
.command('version')
|
|
@@ -77,7 +77,9 @@ function commandGroups() {
|
|
|
77
77
|
{
|
|
78
78
|
title: t('sections.release'),
|
|
79
79
|
items: [
|
|
80
|
-
{ cmd: '
|
|
80
|
+
{ cmd: 'release patch', desc: 'Bump package.json — core SemVer · service CalVer pN' },
|
|
81
|
+
{ cmd: 'release minor|major', desc: '@xrystal/core SemVer only' },
|
|
82
|
+
{ cmd: 'tag', desc: 'Core npm publish · service v<CalVer> git tag' },
|
|
81
83
|
],
|
|
82
84
|
},
|
|
83
85
|
]
|
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 { registerTagCommand, registerVersionCommand } from './commands/release.mjs'
|
|
13
|
+
import { registerTagCommand, registerVersionCommand, registerReleaseBumpCommand } 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,6 +83,7 @@ cli
|
|
|
83
83
|
|
|
84
84
|
registerCreateCommand(cli, cliContext)
|
|
85
85
|
registerVersionCommand(cli, cliContext)
|
|
86
|
+
registerReleaseBumpCommand(cli, cliContext)
|
|
86
87
|
registerTagCommand(cli, cliContext)
|
|
87
88
|
registerDoctorCommand(cli, cliContext)
|
|
88
89
|
registerTmpCommand(cli, cliContext)
|
|
@@ -98,11 +99,7 @@ registerTelepresenceCommand(cli, cliContext)
|
|
|
98
99
|
registerProjectCommands(cli, cliContext)
|
|
99
100
|
|
|
100
101
|
cli.parseAsync(process.argv).catch((error) => {
|
|
101
|
-
|
|
102
|
-
if (error instanceof Error && error.name === 'InfraPreflightFailed') {
|
|
103
|
-
process.exit(1)
|
|
104
|
-
}
|
|
105
|
-
console.error(chalk.red(`\n✗ ${message}\n`))
|
|
102
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
106
103
|
process.exit(1)
|
|
107
104
|
})
|
|
108
105
|
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process'
|
|
2
|
+
import { getVersionState, readDiskPackageJson, run } from './version-check.mjs'
|
|
3
|
+
|
|
4
|
+
const CALVER_RELEASE = /^(\d{2})\.(\d{2})\.(\d{2})$/
|
|
5
|
+
const CALVER_DEV = /^(\d{2})\.(\d{2})\.(\d{2})-dev-p(\d+)$/
|
|
6
|
+
const CALVER_STAG = /^(\d{2})\.(\d{2})\.(\d{2})-stag-p(\d+)$/
|
|
7
|
+
|
|
8
|
+
export function utcCalverDate() {
|
|
9
|
+
const d = new Date()
|
|
10
|
+
const yy = String(d.getUTCFullYear()).slice(-2)
|
|
11
|
+
const mm = String(d.getUTCMonth() + 1).padStart(2, '0')
|
|
12
|
+
const dd = String(d.getUTCDate()).padStart(2, '0')
|
|
13
|
+
return `${yy}.${mm}.${dd}`
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function runGit(cmd, root) {
|
|
17
|
+
return execSync(cmd, { cwd: root, encoding: 'utf8', stdio: 'pipe' }).trim()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function gitTagExists(tagName, root) {
|
|
21
|
+
try {
|
|
22
|
+
runGit(`git rev-parse refs/tags/${tagName}^{commit}`, root)
|
|
23
|
+
return true
|
|
24
|
+
} catch {
|
|
25
|
+
try {
|
|
26
|
+
return runGit(`git ls-remote --tags origin refs/tags/${tagName}`, root).length > 0
|
|
27
|
+
} catch {
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function detectCalverEnv(version) {
|
|
34
|
+
const v = String(version).trim()
|
|
35
|
+
if (CALVER_DEV.test(v)) return 'dev'
|
|
36
|
+
if (CALVER_STAG.test(v)) return 'stag'
|
|
37
|
+
if (CALVER_RELEASE.test(v)) return 'prod'
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function assertCalverFormat(version, env) {
|
|
42
|
+
const v = String(version).trim()
|
|
43
|
+
if (env === 'prod' && !CALVER_RELEASE.test(v)) {
|
|
44
|
+
throw new Error(`Invalid prod CalVer "${v}" — expected YY.MM.DD`)
|
|
45
|
+
}
|
|
46
|
+
if (env === 'dev' && !CALVER_DEV.test(v)) {
|
|
47
|
+
throw new Error(`Invalid dev CalVer "${v}" — expected YY.MM.DD-dev-pN`)
|
|
48
|
+
}
|
|
49
|
+
if (env === 'stag' && !CALVER_STAG.test(v)) {
|
|
50
|
+
throw new Error(`Invalid stag CalVer "${v}" — expected YY.MM.DD-stag-pN`)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {'dev'|'stag'|'prod'} env
|
|
56
|
+
*/
|
|
57
|
+
/** Branch or current package.json CalVer suffix → dev | stag | prod */
|
|
58
|
+
export function resolveCalverEnv(root = process.cwd()) {
|
|
59
|
+
const branch = getVersionState('HEAD', root).branch
|
|
60
|
+
if (branch === 'dev') return 'dev'
|
|
61
|
+
if (branch === 'staging') return 'stag'
|
|
62
|
+
if (branch === 'prod') return 'prod'
|
|
63
|
+
|
|
64
|
+
const fromPkg = detectCalverEnv(readDiskPackageJson(root).version)
|
|
65
|
+
if (fromPkg) return fromPkg
|
|
66
|
+
|
|
67
|
+
throw new Error(
|
|
68
|
+
`Cannot infer CalVer env — checkout dev | staging | prod, or set package.json to YY.MM.DD-dev-pN / -stag-pN / YY.MM.DD.`,
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Next image tag for current env (patch step = next free pN on UTC day). */
|
|
73
|
+
export function bumpCalverPatch(root = process.cwd()) {
|
|
74
|
+
const env = resolveCalverEnv(root)
|
|
75
|
+
const next = nextCalverVersion(env, root)
|
|
76
|
+
assertCalverFormat(next, env)
|
|
77
|
+
return { next, env }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function nextCalverVersion(env, root = process.cwd()) {
|
|
81
|
+
const date = utcCalverDate()
|
|
82
|
+
if (env === 'prod') {
|
|
83
|
+
const version = date
|
|
84
|
+
const tagName = `v${version}`
|
|
85
|
+
if (gitTagExists(tagName, root)) {
|
|
86
|
+
throw new Error(`Git tag ${tagName} already exists — prod release is one tag per UTC day`)
|
|
87
|
+
}
|
|
88
|
+
return version
|
|
89
|
+
}
|
|
90
|
+
const mid = env === 'dev' ? '-dev-p' : '-stag-p'
|
|
91
|
+
let n = 1
|
|
92
|
+
while (gitTagExists(`v${date}${mid}${n}`, root)) {
|
|
93
|
+
n += 1
|
|
94
|
+
}
|
|
95
|
+
return `${date}${mid}${n}`
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function gitTagFromCalver(version) {
|
|
99
|
+
return version.startsWith('v') ? version : `v${version}`
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function runCalverTagPush({ root, dryRun = false } = {}) {
|
|
103
|
+
const state = getVersionState('HEAD', root)
|
|
104
|
+
const version = state.committed.version
|
|
105
|
+
|
|
106
|
+
if (!state.isPackageJsonClean) {
|
|
107
|
+
throw new Error('Commit package.json before tagging.')
|
|
108
|
+
}
|
|
109
|
+
if (!state.versionMatch) {
|
|
110
|
+
throw new Error('package.json on disk does not match HEAD — commit first.')
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const tagName = gitTagFromCalver(version)
|
|
114
|
+
if (gitTagExists(tagName, root)) {
|
|
115
|
+
throw new Error(`Tag ${tagName} already exists.`)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const branch = state.branch
|
|
119
|
+
if (dryRun) {
|
|
120
|
+
console.log(`[dry-run] git tag ${tagName}`)
|
|
121
|
+
console.log(`[dry-run] git push origin ${branch}`)
|
|
122
|
+
console.log(`[dry-run] git push origin ${tagName}`)
|
|
123
|
+
return { version, tagName, branch }
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
run(`git tag ${tagName}`, { inherit: true, root })
|
|
127
|
+
run(`git push origin ${branch}`, { inherit: true, root })
|
|
128
|
+
run(`git push origin ${tagName}`, { inherit: true, root })
|
|
129
|
+
return { version, tagName, branch }
|
|
130
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import chalk from 'chalk'
|
|
6
|
+
import { resolveProjectRoot } from '../helpers/project-root.mjs'
|
|
7
|
+
import { isCorePackageProject } from './release-prepare.mjs'
|
|
8
|
+
import { fileURLToPath } from 'node:url'
|
|
9
|
+
import { parseSemver, getVersionState, readDiskPackageJson } from './version-check.mjs'
|
|
10
|
+
import { bumpCalverPatch, gitTagFromCalver, detectCalverEnv } from './calver.mjs'
|
|
11
|
+
|
|
12
|
+
/** @returns {'semver'|'calver'} */
|
|
13
|
+
export function resolveReleaseMode(root) {
|
|
14
|
+
if (isCorePackageProject(root)) return 'semver'
|
|
15
|
+
const version = readDiskPackageJson(root).version
|
|
16
|
+
if (detectCalverEnv(version)) return 'calver'
|
|
17
|
+
if (parseSemver(version)) return 'semver'
|
|
18
|
+
return 'calver'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function writePackageVersion(root, version) {
|
|
22
|
+
const pkgPath = path.join(root, 'package.json')
|
|
23
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
24
|
+
pkg.version = version
|
|
25
|
+
fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function bumpSemverLevel(version, level) {
|
|
29
|
+
const p = parseSemver(version)
|
|
30
|
+
if (!p) {
|
|
31
|
+
throw new Error(`Cannot bump non-semver version "${version}"`)
|
|
32
|
+
}
|
|
33
|
+
if (level === 'patch') {
|
|
34
|
+
return `${p.major}.${p.minor}.${p.patch + 1}`
|
|
35
|
+
}
|
|
36
|
+
if (level === 'minor') {
|
|
37
|
+
return `${p.major}.${p.minor + 1}.0`
|
|
38
|
+
}
|
|
39
|
+
if (level === 'major') {
|
|
40
|
+
return `${p.major + 1}.0.0`
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`Unknown semver level: ${level}`)
|
|
43
|
+
}
|
|
44
|
+
|
|
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 tag`)
|
|
49
|
+
console.log(chalk.dim(` git tag will be v${version} after commit\n`))
|
|
50
|
+
}
|
|
51
|
+
|
|
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 tag`)
|
|
58
|
+
console.log(chalk.dim(` pushes ${tag} → CI\n`))
|
|
59
|
+
}
|
|
60
|
+
|
|
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()
|
|
65
|
+
|
|
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)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const root = resolveProjectRoot()
|
|
74
|
+
const mode = resolveReleaseMode(root)
|
|
75
|
+
const state = getVersionState('HEAD', root)
|
|
76
|
+
|
|
77
|
+
let nextVersion
|
|
78
|
+
let calverEnv
|
|
79
|
+
if (mode === 'semver') {
|
|
80
|
+
nextVersion = bumpSemverLevel(state.disk.version, level)
|
|
81
|
+
} else {
|
|
82
|
+
if (level !== 'patch') {
|
|
83
|
+
throw new Error('CalVer in package.json — only release:patch. (SemVer için version örn. 2.0.32)')
|
|
84
|
+
}
|
|
85
|
+
const bumped = bumpCalverPatch(root)
|
|
86
|
+
nextVersion = bumped.next
|
|
87
|
+
calverEnv = bumped.env
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log(chalk.cyan(`\nRelease bump (${level})`))
|
|
91
|
+
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)}`)
|
|
95
|
+
|
|
96
|
+
if (dryRun) {
|
|
97
|
+
console.log(chalk.gray('[dry-run] no package.json write\n'))
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
writePackageVersion(root, nextVersion)
|
|
102
|
+
|
|
103
|
+
if (isCorePackageProject(root)) {
|
|
104
|
+
printCoreNextSteps(nextVersion)
|
|
105
|
+
} else {
|
|
106
|
+
printServiceNextSteps(nextVersion)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const isMain = process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
|
111
|
+
|
|
112
|
+
if (isMain) {
|
|
113
|
+
main().catch((error) => {
|
|
114
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
115
|
+
process.exit(1)
|
|
116
|
+
})
|
|
117
|
+
}
|