Skip to content

Commit 0002fa8

Browse files
refactor: pin the Coana CLI version in the source (#1628)
The pinned Coana CLI version moves from the @coana-tech/cli devDependency, which rollup inlined at build time, to the COANA_CLI_VERSION constant in src/constants.mts. Coana is about to stop publishing to npm, so the pin can't stay a dependency, and the constant also has the same value in tests and in unbuilt runs, where the inlined value was empty. The bump-coana skill now edits the constant. Coana's release workflow has to bump it the same way.
1 parent 585506c commit 0002fa8

12 files changed

Lines changed: 33 additions & 75 deletions

File tree

‎.claude/skills/bump-coana/SKILL.md‎

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
name: bump-coana
3-
description: Bump @coana-tech/cli to a new version, update changelog, and create a PR. Use when user wants to upgrade Coana CLI, bump Coana version, or says "bump coana" with a version number.
3+
description: Bump the pinned Coana CLI to a new version, update changelog, and create a PR. Use when user wants to upgrade Coana CLI, bump Coana version, or says "bump coana" with a version number.
44
allowed-tools: Read, Edit, Write, Bash, Glob
55
user-invocable: true
66
---
77

88
# Bump Coana CLI Version
99

10-
Automates the process of upgrading the @coana-tech/cli dependency to a new version, including package.json updates, changelog entry, and PR creation.
10+
Automates the process of upgrading the pinned Coana CLI to a new version, including the pin, changelog entry, and PR creation.
1111

1212
## Input
1313

@@ -32,22 +32,21 @@ if [[ ! "$COANA_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
3232
fi
3333
```
3434

35-
### Step 2: Update package.json
35+
### Step 2: Update the pin
3636

37-
1. Read `package.json` in the repository root.
38-
2. Find the current `@coana-tech/cli` version in `devDependencies` and note it as `CURRENT_VERSION`.
39-
3. Update `@coana-tech/cli` to the new version.
40-
4. Write the updated `package.json`.
37+
1. Read `src/constants.mts`.
38+
2. Find the line `const COANA_CLI_VERSION = '<version>'` and note the version as `CURRENT_VERSION`.
39+
3. Replace the version on that line with the new one.
4140

42-
🚨 **Do NOT touch the top-level `version` field.** The release workflow owns it:
41+
🚨 **Do NOT touch `package.json`'s top-level `version` field.** The release workflow owns it:
4342
between releases the manifest holds the last released version, and
4443
`scripts/release/bump.mts` derives and writes the next one in-run. Hand-writing
4544
it invents a version that never releases and breaks the next release — a manifest
4645
already sitting on the version being released has no line for the bump to
4746
advance.
4847

4948
**Values to extract**:
50-
- `CURRENT_VERSION`: The old @coana-tech/cli version (for PR body)
49+
- `CURRENT_VERSION`: The old Coana CLI version (for PR body)
5150

5251
### Step 3: Update CHANGELOG.md
5352

@@ -87,28 +86,20 @@ if it finds one; hand-editing is what puts one there.)
8786
- Updated the Coana CLI to v `COANA_VERSION`.
8887
```
8988

90-
### Step 4: Update Lock File
91-
92-
```bash
93-
pnpm install
94-
```
95-
96-
This updates `pnpm-lock.yaml` with the new dependency version.
97-
98-
### Step 5: Create Branch and Commit
89+
### Step 4: Create Branch and Commit
9990

10091
```bash
10192
# Create branch
10293
git checkout -b "coana-$COANA_VERSION"
10394

10495
# Stage changes
105-
git add package.json CHANGELOG.md pnpm-lock.yaml
96+
git add src/constants.mts CHANGELOG.md
10697

10798
# Commit (skip pre-commit hooks with -n)
10899
git commit -n -m "upgrading coana to version $COANA_VERSION"
109100
```
110101

111-
### Step 6: Push and Create PR
102+
### Step 5: Push and Create PR
112103

113104
```bash
114105
# Push branch
@@ -117,7 +108,7 @@ git push -u origin "coana-$COANA_VERSION"
117108
# Create PR targeting v1.x branch
118109
gh pr create --base v1.x --title "upgrading coana to version $COANA_VERSION" --body "$(cat <<'EOF'
119110
## Summary
120-
- Upgrades @coana-tech/cli from CURRENT_VERSION to COANA_VERSION
111+
- Upgrades the Coana CLI from CURRENT_VERSION to COANA_VERSION
121112
122113
## Coana Changelog
123114
For details on what's included in this Coana release, see the [Coana Changelogs](https://docs.coana.tech/changelogs).
@@ -131,16 +122,15 @@ Replace `CURRENT_VERSION` and `COANA_VERSION` with actual values.
131122

132123
- Branch: `coana-<VERSION>` pushed to origin
133124
- PR: Created targeting `v1.x` branch
134-
- Files modified: `package.json` (the `@coana-tech/cli` devDependency only, never
135-
the top-level `version`), `CHANGELOG.md` (under `## [Unreleased]`), `pnpm-lock.yaml`
125+
- Files modified: `src/constants.mts` (the `COANA_CLI_VERSION` line only),
126+
`CHANGELOG.md` (under `## [Unreleased]`)
136127

137128
Report the PR URL to the user when complete.
138129

139130
## Error Handling
140131

141132
- **No version provided**: Ask user for the version number
142133
- **Invalid version format**: Report error with expected format
143-
- **pnpm install fails**: Check network connectivity and npm registry access
144134
- **PR creation fails**: Verify `gh` CLI is authenticated
145135

146136
## Important Notes

‎.config/rollup.base.config.mjs‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
} from '../scripts/utils/packages.js'
2424

2525
const {
26-
INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION,
2726
INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION,
2827
INLINED_SOCKET_CLI_HOMEPAGE,
2928
INLINED_SOCKET_CLI_LEGACY_BUILD,
@@ -192,13 +191,6 @@ export default function baseConfig(extendConfig = {}) {
192191
delimiters: ['(?<![\'"])\\b', '(?![\'"])'],
193192
preventAssignment: true,
194193
values: [
195-
[
196-
INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION,
197-
() =>
198-
JSON.stringify(
199-
getRootPkgJsonSync().devDependencies['@coana-tech/cli'],
200-
),
201-
],
202194
[
203195
INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION,
204196
() =>

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
"@babel/preset-typescript": "7.27.1",
106106
"@babel/runtime": "7.28.4",
107107
"@biomejs/biome": "2.2.4",
108-
"@coana-tech/cli": "15.12.9",
109108
"@cyclonedx/cdxgen": "12.1.2",
110109
"@dotenvx/dotenvx": "1.49.0",
111110
"@eslint/compat": "1.3.2",

‎pnpm-lock.yaml‎

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎scripts/constants.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ const {
1313
} = registryConstants
1414

1515
const CONSTANTS = 'constants'
16-
const INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION =
17-
'INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION'
1816
const INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION =
1917
'INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION'
2018
const INLINED_SOCKET_CLI_HOMEPAGE = 'INLINED_SOCKET_CLI_HOMEPAGE'
@@ -99,7 +97,6 @@ const constants = createConstantsObject(
9997
...registryConstantsAttribs.props,
10098
CONSTANTS,
10199
ENV: undefined,
102-
INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION,
103100
INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION,
104101
INLINED_SOCKET_CLI_HOMEPAGE,
105102
INLINED_SOCKET_CLI_LEGACY_BUILD,

‎src/commands/fix/cmd-fix.mts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { logger } from '@socketsecurity/registry/lib/logger'
1212

1313
import { handleFix } from './handle-fix.mts'
1414
import constants, {
15+
COANA_CLI_VERSION,
1516
ERROR_UNABLE_RESOLVE_ORG,
1617
FLAG_ID,
1718
} from '../../constants.mts'
@@ -73,7 +74,7 @@ const generalFlags: MeowFlags = {
7374
},
7475
fixVersion: {
7576
type: 'string',
76-
description: `Override the version of @coana-tech/cli used for fix analysis. Default: ${constants.ENV.INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION}.`,
77+
description: `Override the version of @coana-tech/cli used for fix analysis. Default: ${COANA_CLI_VERSION}.`,
7778
},
7879
applyFixes: {
7980
aliases: ['onlyCompute'],

‎src/commands/scan/perform-reachability-analysis.mts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import path from 'node:path'
66
import { logger } from '@socketsecurity/registry/lib/logger'
77

88
import { isOmittedReachValue } from './reachability-units.mts'
9-
import constants from '../../constants.mts'
9+
import constants, { COANA_CLI_VERSION } from '../../constants.mts'
1010
import { handleApiCall } from '../../utils/api.mts'
1111
import {
1212
extractTier1ReachabilityScanId,
@@ -303,9 +303,7 @@ export async function performReachabilityAnalysis(
303303
}
304304

305305
if (!coanaResult.ok) {
306-
const coanaVersion =
307-
reachabilityOptions.reachVersion ||
308-
constants.ENV.INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION
306+
const coanaVersion = reachabilityOptions.reachVersion || COANA_CLI_VERSION
309307
logger.error(
310308
`Coana reachability analysis failed. Version: ${coanaVersion}, target: ${analysisTarget}, cwd: ${cwd}`,
311309
)

‎src/commands/scan/perform-reachability-analysis.test.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ vi.mock('../../utils/terminal-link.mts', () => ({
7676
}))
7777

7878
vi.mock('../../constants.mts', () => ({
79+
COANA_CLI_VERSION: 'test',
7980
default: {
8081
DOT_SOCKET_DOT_FACTS_JSON: '.socket.facts.json',
81-
ENV: { INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION: 'test' },
8282
HTTP_STATUS_UNAUTHORIZED: 401,
8383
SOCKET_DEFAULT_BRANCH: 'socket-default-branch',
8484
SOCKET_DEFAULT_REPOSITORY: 'socket-default-repository',

‎src/commands/scan/reachability-flags.mts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import constants from '../../constants.mts'
1+
import { COANA_CLI_VERSION } from '../../constants.mts'
22
import { getReachabilityEcosystemChoices } from '../../utils/ecosystem.mts'
33

44
import type { MeowFlags } from '../../flags.mts'
@@ -12,7 +12,7 @@ export const DYNAMIC_SBOM_INFERENCE_DESCRIPTION =
1212
export const reachabilityFlags: MeowFlags = {
1313
reachVersion: {
1414
type: 'string',
15-
description: `Override the version of @coana-tech/cli used for reachability analysis. Default: ${constants.ENV.INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION}.`,
15+
description: `Override the version of @coana-tech/cli used for reachability analysis. Default: ${COANA_CLI_VERSION}.`,
1616
},
1717
reachAnalysisMemoryLimit: {
1818
type: 'string',

‎src/constants.mts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ export type ENV = Remap<
137137
GITHUB_REPOSITORY: string
138138
GITHUB_SERVER_URL: string
139139
GITHUB_TOKEN: string
140-
INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION: string
141140
INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION: string
142141
INLINED_SOCKET_CLI_HOMEPAGE: string
143142
INLINED_SOCKET_CLI_LEGACY_BUILD: string
@@ -193,6 +192,9 @@ const ALERT_TYPE_CVE = 'cve'
193192
const ALERT_TYPE_MEDIUM_CVE = 'mediumCVE'
194193
const ALERT_TYPE_MILD_CVE = 'mildCVE'
195194
const API_V0_URL = 'https://api.socket.dev/v0/'
195+
// The Coana CLI version Socket CLI runs by default. Coana's release workflow
196+
// rewrites this line in its bump PRs.
197+
const COANA_CLI_VERSION = '15.12.9'
196198
const CONFIG_KEY_API_BASE_URL = 'apiBaseUrl'
197199
const CONFIG_KEY_API_PROXY = 'apiProxy'
198200
const CONFIG_KEY_API_TOKEN = 'apiToken'
@@ -493,11 +495,6 @@ const LAZY_ENV = () => {
493495
// workflow.
494496
// https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#about-the-github_token-secret
495497
GITHUB_TOKEN,
496-
// Comp-time inlined @coana-tech/cli package version.
497-
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION']".
498-
INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION: envAsString(
499-
process.env['INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION'],
500-
),
501498
// Comp-time inlined @cyclonedx/cdxgen package version.
502499
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION']".
503500
INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION: envAsString(
@@ -1145,6 +1142,7 @@ export {
11451142
ALERT_TYPE_MEDIUM_CVE,
11461143
ALERT_TYPE_MILD_CVE,
11471144
API_V0_URL,
1145+
COANA_CLI_VERSION,
11481146
CONFIG_KEY_API_BASE_URL,
11491147
CONFIG_KEY_API_PROXY,
11501148
CONFIG_KEY_API_TOKEN,

0 commit comments

Comments
 (0)