Skip to content

Commit 62060f6

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 62060f6

13 files changed

Lines changed: 50 additions & 16 deletions

File tree

.env.schema

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This env file uses @env-spec - see https://varlock.dev/env-spec for more info
2+
#
3+
# @defaultRequired=infer @defaultSensitive=false
4+
# @generateTypes(lang=ts, path=env.d.ts)
5+
# ----------
6+
7+
# Public URL for the bumpy website/docs
8+
# @type=url
9+
BUMPY_WEBSITE_URL=https://github.com/dmno-dev/bumpy

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
1414

1515
.env.local
1616
.env.*.local
17+
env.d.ts
1718

1819
*.tsbuildinfo
1920

bun.lock

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@varlock/bumpy": "workspace:*",
2323
"lefthook": "^2.1.5",
2424
"oxfmt": "^0.45.0",
25-
"oxlint": "^1.60.0"
25+
"oxlint": "^1.60.0",
26+
"varlock": "^0.8.1"
2627
}
2728
}

packages/bumpy/.env.schema

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# @generateTypes(lang=ts, path=env.d.ts)
2+
#
3+
# @import(../../.env.schema)
4+
# ----------

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;

0 commit comments

Comments
 (0)