Skip to content

Commit 567f971

Browse files
theoephraimclaude
andcommitted
Replace version-info helpers with global consts injected via define
Uses globals.d.ts for type declarations, bunfig.toml [define] for local dev/tests, and tsdown define for production builds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent efb2e7c commit 567f971

7 files changed

Lines changed: 28 additions & 15 deletions

File tree

packages/bumpy/bunfig.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# these global vars will be bundled at build time by tsdown
2+
# this just injects them for running `bun test` or running the ts code directly via bun
3+
[define]
4+
"__BUMPY_VERSION__" = "'dev'"
5+
"__BUMPY_WEBSITE_URL__" = "'https://github.com/dmno-dev/bumpy'"

packages/bumpy/src/cli.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { findRoot } from './core/config.ts';
44
import { log, colorize } from './utils/logger.ts';
5-
import { getVersion, getWebsiteUrl } from './version-info.ts';
65

76
const args = process.argv.slice(2);
87
const command = args[0];
@@ -153,7 +152,7 @@ async function main() {
153152

154153
case '--version':
155154
case '-v':
156-
console.log(`bumpy ${getVersion()}`);
155+
console.log(`bumpy ${__BUMPY_VERSION__}`);
157156
break;
158157

159158
case 'help':
@@ -176,7 +175,7 @@ async function main() {
176175

177176
function printHelp() {
178177
console.log(`
179-
${colorize(`🐸 bumpy v${getVersion()}`, 'bold')} - Modern monorepo versioning
178+
${colorize(`🐸 bumpy v${__BUMPY_VERSION__}`, 'bold')} - Modern monorepo versioning
180179
181180
Usage: bumpy <command> [options]
182181
@@ -229,7 +228,7 @@ function printHelp() {
229228
AI setup options:
230229
--target <tool> Target AI tool: opencode, cursor, codex
231230
232-
${colorize(getWebsiteUrl(), 'dim')}
231+
${colorize(__BUMPY_WEBSITE_URL__, 'dim')}
233232
`);
234233
}
235234

packages/bumpy/src/commands/ci.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function formatReleasePlanComment(plan: ReleasePlan, changesetCount: number): st
224224
}
225225

226226
lines.push('---');
227-
lines.push('_This comment is maintained by [bumpy](https://github.com/dmno-dev/bumpy)._');
227+
lines.push(`_This comment is maintained by [bumpy](${__BUMPY_WEBSITE_URL__})._`);
228228
return lines.join('\n');
229229
}
230230

@@ -236,7 +236,7 @@ function formatNoChangesetsComment(): string {
236236
'bumpy add',
237237
'```\n',
238238
'---',
239-
'_This comment is maintained by [bumpy](https://github.com/dmno-dev/bumpy)._',
239+
`_This comment is maintained by [bumpy](${__BUMPY_WEBSITE_URL__})._`,
240240
].join('\n');
241241
}
242242

packages/bumpy/src/commands/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function initCommand(rootDir: string): Promise<void> {
2323
// Write a README explaining the directory
2424
await writeText(
2525
resolve(bumpyDir, 'README.md'),
26-
`# 🐸 Bumpy\n\nThis directory is used by [bumpy](https://github.com/dmno-dev/bumpy) to manage versioning.\n\nChangeset files (\`.md\`) in this directory describe pending version bumps.\nRun \`bumpy add\` to create a new changeset.\n`,
26+
`# 🐸 Bumpy\n\nThis directory is used by [bumpy](${__BUMPY_WEBSITE_URL__}) to manage versioning.\n\nChangeset files (\`.md\`) in this directory describe pending version bumps.\nRun \`bumpy add\` to create a new changeset.\n`,
2727
);
2828

2929
log.success('Initialized .bumpy/ directory');

packages/bumpy/src/globals.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// for local dev and runing tests, these are set by bunfig.toml
2+
// at build time they are loaded via varlock and injected via tsdown
3+
4+
/**
5+
* current version number ("1.2.3") - pulled from package.json
6+
*
7+
* Injected at build time by tsdown, or via bunfig.toml when running from source
8+
* */
9+
declare const __BUMPY_VERSION__: string;
10+
/**
11+
* docs website url
12+
*
13+
* Injected at build time by tsdown, or via bunfig.toml when running from source
14+
* */
15+
declare const __BUMPY_WEBSITE_URL__: string;

packages/bumpy/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ export const DEFAULT_CONFIG: BumpyConfig = {
141141
title: '🐸 Versioned release',
142142
branch: 'bumpy/version-packages',
143143
preamble: [
144-
'<img src="https://raw.githubusercontent.com/dmno-dev/bumpy/main/images/frog-talking.png" alt="bumpy" width="60" align="left" style="image-rendering: pixelated;" />',
144+
`<a href="${__BUMPY_WEBSITE_URL__}"><img src="https://raw.githubusercontent.com/dmno-dev/bumpy/main/images/frog-talking.png" alt="bumpy" width="60" align="left" style="image-rendering: pixelated;" alt="Hi! I'm bumpy!" /></a>`,
145145
'',
146-
'This PR was created and will be kept in sync by [bumpy](https://github.com/dmno-dev/bumpy) based on your .bumpy changeset files. Merge it when you are ready to release the packages listed below:',
146+
`This PR was created and will be kept in sync by [bumpy](${__BUMPY_WEBSITE_URL__}) based on your .bumpy changeset files. Merge it when you are ready to release the packages listed below:`,
147147
'<br clear="left" />',
148148
].join('\n'),
149149
},

packages/bumpy/src/version-info.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)