@reliverse/bump 2.2.10 → 2.3.1

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.
Files changed (3) hide show
  1. package/README.md +603 -603
  2. package/dist/mod.js +6 -2
  3. package/package.json +14 -14
package/README.md CHANGED
@@ -1,603 +1,603 @@
1
- # 🪸 reliverse bump • powerful version bumping
2
-
3
- > @reliverse/bump is a powerful version bumping tool for javascript and typescript libraries.
4
-
5
- [sponsor](https://github.com/sponsors/blefnk) — [discord](https://discord.gg/pb8ukbwpsj) — [repo](https://github.com/reliverse/bump) — [npm](https://npmjs.com/@reliverse/bump) — [docs](https://docs.reliverse.org/reliverse/bump)
6
-
7
- ## Installation
8
-
9
- ```bash
10
- # bun — pnpm — yarn — npm
11
- bun add -D @reliverse/bump
12
- ```
13
-
14
- ## Features
15
-
16
- - šŸ¤– **Interactive Mode**: Just run and follow the prompts
17
- - šŸ”„ **Non-Interactive Mode**: Works in CI environments without TTY
18
- - šŸŽÆ **Smart Detection**: Finds version patterns in your files using regex
19
- - šŸ”„ **Multiple Files**: Update versions in many files at once
20
- - šŸ› ļø **File Type Support**: Handles both package.json and TypeScript files
21
- - šŸŽ® **Custom Versions**: Want a specific version or need to downgrade? No problem!
22
- - šŸ“ **Custom Source**: Use a different file as version source
23
- - šŸ” **Dry Run**: Preview changes before applying them
24
- - šŸ”’ **Version Validation**: Ensures all versions are valid semver
25
- - šŸ“Š **Version Analysis**: Detects mismatches and compares version differences
26
- - šŸŽÆ **Range Satisfaction**: Check if versions satisfy semver ranges
27
- - ⚔ **Fast & Lightweight**: Built with performance in mind
28
- - šŸ›”ļø **Error Handling**: Comprehensive error checking and reporting
29
- - šŸ”’ **Bump Disable Management**: Programmatic control of version bumping
30
-
31
- ## Quick Start
32
-
33
- ### Interactive Mode
34
-
35
- Just run:
36
-
37
- ```bash
38
- bun rse bump
39
- ```
40
-
41
- That's it! Follow the prompts to:
42
-
43
- 1. Choose which files to update
44
- 2. Select how you want to bump the version
45
- 3. See what changes will be made
46
-
47
- ### Programmatic Mode
48
-
49
- ```ts
50
- import { bumpVersionWithAnalysis } from "@reliverse/bump";
51
-
52
- // Patch bump
53
- await bumpVersionWithAnalysis(
54
- "patch", // bumpType: "patch" | "minor" | "major" | "auto" | "manual"
55
- ["package.json"], // files to bump
56
- { dryRun: false }, // options
57
- );
58
-
59
- // Manual version with bumpSet from config
60
- await bumpVersionWithAnalysis(
61
- "manual", // bumpType
62
- ["package.json"], // files to bump
63
- { dryRun: false }, // options
64
- "1.2.3", // bumpSet from dler.ts
65
- );
66
-
67
- // Manual version with customVersion
68
- await bumpVersionWithAnalysis(
69
- "manual", // bumpType
70
- ["package.json"], // files to bump
71
- {
72
- dryRun: false,
73
- customVersion: "1.2.3" // overrides bumpSet if provided
74
- },
75
- );
76
- ```
77
-
78
- ### CLI Mode
79
-
80
- CLI is available via [Dler CLI](https://github.com/reliverse/dler) by Reliverse.
81
-
82
- ```bash
83
- # Basic usage examples
84
- bun rse bump --bumpType patch --files package.json src/version.ts
85
- bun rse bump --bumpType minor --dryRun # Preview changes
86
- bun rse bump --bumpType major --mainFile package.json
87
- bun rse bump --bumpType auto --mainFile package.json --files package.json dler.ts
88
- bun rse bump --bumpType manual --customVersion 2.0.0 --mainFile package.json
89
-
90
- # Advanced usage
91
- bun rse bump \
92
- --bumpType manual \
93
- --customVersion 1.0.1 \
94
- --dryRun \
95
- --mainFile package.json \
96
- --verbose \
97
- --files "package.json dler.ts"
98
-
99
- # Available options
100
- --dev # Run in dev mode
101
- --bumpType # Type of bump: patch|minor|major|auto|manual
102
- --customVersion # Set specific version (with manual mode)
103
- --dryRun # Preview changes without applying
104
- --mainFile # Version source file (default: package.json)
105
- --verbose # Show detailed logs
106
- --files # Files to bump (space or comma-separated)
107
- --disableBump # Disable bumping (useful for CI)
108
- ```
109
-
110
- ## Advanced Features
111
-
112
- ### Version Analysis
113
-
114
- The tool performs deep analysis of your files to:
115
-
116
- - Detect version mismatches across files
117
- - Validate semver format
118
- - Identify unsupported file types
119
- - Provide detailed analysis reports
120
-
121
- ### Smart Version Detection
122
-
123
- - Automatically detects version patterns in different file types
124
- - Supports multiple version formats (quotes, assignments, etc.)
125
- - Preserves original formatting when updating versions
126
-
127
- ### CI/CD Integration
128
-
129
- - Special handling for CI environments
130
- - Non-interactive mode for automated workflows
131
- - Configurable through environment variables
132
- - Support for automated version bumping
133
-
134
- ### Configuration Management
135
-
136
- - Flexible configuration through `dler.ts`
137
- - Support for custom version sources
138
- - Configurable file patterns
139
- - Version bump control flags
140
-
141
- ### Error Prevention
142
-
143
- - Validates all version changes
144
- - Prevents invalid semver versions
145
- - Checks for version mismatches
146
- - Provides detailed error messages
147
-
148
- ### Version Bump Control
149
-
150
- - **Bump Handler**: Advanced version bumping with:
151
- - Support for auto-patch, auto-minor, auto-major modes
152
- - Custom version setting capability
153
- - Dry run support for previewing changes
154
- - Automatic version validation
155
- - Configurable file filtering
156
- - Detailed logging of version changes
157
-
158
- - **Bump Disable Management**:
159
- - Programmatic control of version bumping
160
- - Integration with common publish pause
161
- - Automatic configuration file updates
162
- - Support for both TypeScript and JavaScript configs
163
- - Graceful handling of missing config files
164
- - Non-blocking error handling
165
-
166
- ## Advanced Programmatic Example
167
-
168
- ```ts
169
- import {
170
- bumpVersionWithAnalysis,
171
- analyzeFiles,
172
- getCurrentVersion,
173
- type BumpMode,
174
- type FileAnalysis
175
- } from "@reliverse/bump";
176
-
177
- // First analyze files
178
- const currentVersion = await getCurrentVersion("package.json");
179
- const fileAnalysis = await analyzeFiles(
180
- [
181
- "package.json",
182
- "src/version.ts",
183
- "dler.ts"
184
- ],
185
- currentVersion
186
- );
187
-
188
- // Filter supported files
189
- const supportedFiles = fileAnalysis
190
- .filter(f => f.supported)
191
- .map(f => f.file);
192
-
193
- // Then bump versions
194
- await bumpVersionWithAnalysis(
195
- "patch", // bumpType
196
- supportedFiles, // only supported files
197
- {
198
- dryRun: true, // preview only
199
- verbose: true, // show detailed logs
200
- }
201
- );
202
- ```
203
-
204
- ### Configuration Types
205
-
206
- ```ts
207
- type BumpMode = "patch" | "minor" | "major" | "auto" | "manual";
208
-
209
- type BumpOptions = {
210
- dryRun?: boolean;
211
- verbose?: boolean;
212
- customVersion?: string;
213
- };
214
-
215
- type FileAnalysis = {
216
- file: string;
217
- supported: boolean;
218
- detectedVersion: string | null;
219
- versionMismatch: boolean;
220
- reason: string;
221
- fileType: "package.json" | "typescript" | "unknown";
222
- };
223
- ```
224
-
225
- ### Additional Utility Functions
226
-
227
- ```ts
228
- // Check if version bumping is currently disabled
229
- await isBumpDisabled(): Promise<boolean>
230
-
231
- // Set bumpDisable flag to a specific value
232
- await setBumpDisabledValueTo(value: boolean): Promise<void>
233
-
234
- // Update any field in dler.ts
235
- await updateDlerConfig(field: string, value: any): Promise<void>
236
-
237
- // Get current version from a file
238
- await getCurrentVersion(filePath?: string, field?: string): Promise<string>
239
-
240
- // Get package name from a file
241
- await getPackageName(filePath?: string, field?: string): Promise<string>
242
-
243
- // Get package author from a file
244
- await getPackageAuthor(filePath?: string, field?: string): Promise<string>
245
-
246
- // Compare two versions
247
- compareVersions(version1: string, version2: string): number
248
-
249
- // Get latest version from an array of versions
250
- getLatestVersion(versions: string[]): string | null
251
-
252
- // Check if a version is a prerelease
253
- isPrerelease(version: string): boolean
254
-
255
- // Check if a version satisfies a range
256
- satisfiesRange(version: string, range: string): boolean
257
-
258
- // Parse semver into components
259
- parseSemver(version: string): [number, number, number]
260
-
261
- // Validate semver format
262
- isValidSemver(version: string): boolean
263
- ```
264
-
265
- ## Configuration
266
-
267
- ### CLI Options
268
-
269
- ```bash
270
- Options:
271
- --bumpMode <mode> Mode: patch, minor, major, auto, manual
272
- --customVersion <ver> Set specific version (with manual mode)
273
- --mainFile <file> Version source file (default: package.json)
274
- --dryRun Preview changes without applying
275
- --disableBump Disable bumping (useful for CI)
276
- --dev Run in dev mode
277
- ```
278
-
279
- ### Using with `dler.ts`
280
-
281
- Create a `dler.ts` to configure default behavior:
282
-
283
- ```ts
284
- import { defineConfig } from "@reliverse/dler";
285
-
286
- export default defineConfig({
287
- bumpFilter: [
288
- "package.json",
289
- "src/version.ts",
290
- ],
291
- bumpMode: "patch",
292
- bumpDisable: false,
293
- });
294
- ```
295
-
296
- ## Advanced Usage
297
-
298
- ```ts
299
- // src/cli.ts
300
- import { relinka } from "@reliverse/relinka";
301
- import {
302
- runMain,
303
- defineCommand,
304
- defineArgs,
305
- selectPrompt,
306
- inputPrompt,
307
- startPrompt,
308
- endPrompt,
309
- } from "@reliverse/rempts";
310
- import path from "node:path";
311
- import semver from "semver";
312
-
313
- import {
314
- bumpVersionWithAnalysis,
315
- getCurrentVersion,
316
- getFilesFromConfigOrDefault,
317
- getConfigFromDler,
318
- type BumpMode,
319
- validateBumpConfig,
320
- getDefaultBumpMode,
321
- handleNonInteractiveSession,
322
- handleInteractiveSession,
323
- type SessionConfig,
324
- } from "./mod.js";
325
-
326
- const bumpTypes: BumpMode[] = ["patch", "minor", "major", "auto", "manual"];
327
-
328
- const main = defineCommand({
329
- meta: {
330
- name: "bump",
331
- description:
332
- "Allows you to bump the version of your project interactively.",
333
- },
334
- args: defineArgs({
335
- dev: {
336
- type: "boolean",
337
- description: "Runs the CLI in dev mode",
338
- },
339
- bumpType: {
340
- type: "string",
341
- description: "The type of version bump to perform",
342
- allowed: bumpTypes,
343
- },
344
- customVersion: {
345
- type: "string",
346
- description: "Custom version to set (only used with manual bump type)",
347
- },
348
- disableBump: {
349
- type: "boolean",
350
- description: "Disables the bump (this is useful for CI)",
351
- },
352
- files: {
353
- type: "string",
354
- description:
355
- 'Files to bump (comma or space-separated, or quoted: "package.json dler.ts")',
356
- default: "",
357
- },
358
- dryRun: {
359
- type: "boolean",
360
- description: "Preview changes without writing files",
361
- },
362
- mainFile: {
363
- type: "string",
364
- description:
365
- "The file to use as version source (defaults to package.json)",
366
- default: "package.json",
367
- },
368
- verbose: {
369
- type: "boolean",
370
- description: "Enable verbose output",
371
- },
372
- }),
373
- async run({ args }) {
374
- const isCI = process.env.CI === "true";
375
- const isNonInteractive = !process.stdout.isTTY;
376
- const dryRun = !!args.dryRun;
377
- const verbose = !!args.verbose;
378
- const mainFile = args.mainFile;
379
- const customVersion = args.customVersion;
380
-
381
- // Read current versions
382
- let bleumpVersion = "unknown";
383
- let projectVersion = "unknown";
384
- try {
385
- const bleumpPkg = await import("../package.json", {
386
- assert: { type: "json" },
387
- });
388
- bleumpVersion = bleumpPkg.default.version || "unknown";
389
- projectVersion = await getCurrentVersion(mainFile);
390
- } catch (e) {
391
- relinka("warn", `Could not read package versions: ${e}`);
392
- }
393
-
394
- await showStartPrompt(args.dev, bleumpVersion);
395
-
396
- // Get files to bump - handle multiple parsing scenarios
397
- let filesToBumpArr: string[] = [];
398
-
399
- // Handle files from --files flag with improved parsing
400
- if (args.files) {
401
- // handle both comma and space separation, plus remaining CLI args
402
- const filesFromFlag = args.files
403
- .split(/[,\s]+/) // split on comma or whitespace
404
- .map((f) => f.trim())
405
- .filter(Boolean);
406
-
407
- // also check if there are additional file arguments after known flags
408
- const remainingArgs = process.argv.slice(2);
409
- const knownFlags = [
410
- "--dev",
411
- "--bumpType",
412
- "--customVersion",
413
- "--disableBump",
414
- "--files",
415
- "--dryRun",
416
- "--mainFile",
417
- "--verbose",
418
- ];
419
-
420
- // find files that appear after --files but aren't flags
421
- const filesIndex = remainingArgs.findIndex((arg) => arg === "--files");
422
- if (filesIndex !== -1) {
423
- for (let i = filesIndex + 2; i < remainingArgs.length; i++) {
424
- const arg = remainingArgs[i];
425
- if (arg.startsWith("--") || knownFlags.includes(arg)) break;
426
- if (!filesFromFlag.includes(arg)) {
427
- filesFromFlag.push(arg);
428
- }
429
- }
430
- }
431
-
432
- filesToBumpArr = filesFromFlag;
433
- }
434
-
435
- // If no files specified, use defaults
436
- if (filesToBumpArr.length === 0) {
437
- filesToBumpArr = await getFilesFromConfigOrDefault();
438
- }
439
-
440
- // Ensure mainFile is in the list (using absolute path)
441
- if (!filesToBumpArr.includes(mainFile)) {
442
- filesToBumpArr.unshift(mainFile);
443
- }
444
-
445
- // Remove duplicates while preserving order
446
- filesToBumpArr = [...new Set(filesToBumpArr)];
447
-
448
- // Get bump type and other settings from config
449
- const dlerConfig = await getConfigFromDler();
450
- let effectiveBumpMode = args.bumpType as BumpMode;
451
-
452
- // Apply config settings if not overridden by CLI args
453
- if (!effectiveBumpMode && dlerConfig.bumpMode) {
454
- effectiveBumpMode = dlerConfig.bumpMode;
455
- }
456
- if (!effectiveBumpMode) {
457
- effectiveBumpMode = getDefaultBumpMode(isCI, isNonInteractive);
458
- }
459
-
460
- // Override disableBump from config if not set via CLI
461
- if (!args.disableBump && dlerConfig.bumpDisable) {
462
- args.disableBump = true;
463
- }
464
-
465
- const sessionConfig: SessionConfig = {
466
- isCI,
467
- isNonInteractive,
468
- mainFile,
469
- filesToBump: filesToBumpArr,
470
- options: { dryRun, verbose, customVersion },
471
- bumpType: effectiveBumpMode,
472
- };
473
-
474
- if (verbose) {
475
- relinka("info", "Configuration:");
476
- relinka("log", ` Bump Type: ${effectiveBumpMode}`);
477
- relinka("log", ` Custom Version: ${customVersion || "none"}`);
478
- relinka("log", ` Dry Run: ${dryRun}`);
479
- relinka("log", ` Main File: ${mainFile}`);
480
- relinka("log", ` Files to Bump (${filesToBumpArr.length}):`);
481
- for (const file of filesToBumpArr) {
482
- relinka("log", ` ${file}`);
483
- }
484
- relinka("log", ` Current Version: ${projectVersion}`);
485
- }
486
-
487
- if (args.disableBump) {
488
- relinka(
489
- "log",
490
- "Bump disabled (--disableBump flag set or configured in dler.ts)",
491
- );
492
- process.exit(0);
493
- }
494
-
495
- try {
496
- if (isCI || isNonInteractive) {
497
- await handleNonInteractiveSession(sessionConfig);
498
- } else {
499
- await handleInteractiveSession(sessionConfig, projectVersion);
500
-
501
- // Get bump type from user if not provided
502
- if (!args.bumpType) {
503
- effectiveBumpMode = (await selectPrompt({
504
- title: `Select a bump type (current: ${projectVersion} from ${path.relative(process.cwd(), mainFile)})`,
505
- options: [
506
- {
507
- value: "patch",
508
- label: `patch (${projectVersion} → ${semver.inc(projectVersion, "patch")})`,
509
- },
510
- {
511
- value: "minor",
512
- label: `minor (${projectVersion} → ${semver.inc(projectVersion, "minor")})`,
513
- },
514
- {
515
- value: "major",
516
- label: `major (${projectVersion} → ${semver.inc(projectVersion, "major")})`,
517
- },
518
- {
519
- value: "auto",
520
- label: "auto (automatically determine bump type)",
521
- },
522
- {
523
- value: "manual",
524
- label: "manual (enter your own version)",
525
- },
526
- ],
527
- })) as BumpMode;
528
-
529
- // If manual selected, prompt for the version
530
- if (effectiveBumpMode === "manual") {
531
- const newCustomVersion = await inputPrompt({
532
- title: "Enter the version number",
533
- content: "Must be a valid semver (e.g., 1.2.3)",
534
- defaultValue: projectVersion,
535
- validate: (input: string) => {
536
- if (!semver.valid(input)) {
537
- return "Please enter a valid semver version (e.g., 1.2.3)";
538
- }
539
- return true;
540
- },
541
- });
542
- sessionConfig.options.customVersion = newCustomVersion;
543
- }
544
- }
545
-
546
- sessionConfig.bumpType = effectiveBumpMode;
547
- validateBumpConfig(
548
- effectiveBumpMode,
549
- sessionConfig.options.customVersion,
550
- );
551
- await bumpVersionWithAnalysis(
552
- effectiveBumpMode,
553
- filesToBumpArr,
554
- sessionConfig.options,
555
- dlerConfig.bumpSet,
556
- );
557
- }
558
- } catch (error) {
559
- relinka("error", error instanceof Error ? error.message : String(error));
560
- process.exit(1);
561
- }
562
-
563
- relinka("log", " ");
564
- await showEndPrompt();
565
- },
566
- });
567
-
568
- await runMain(main);
569
-
570
- async function showStartPrompt(isDev: boolean, currentVersion: string) {
571
- await startPrompt({
572
- titleColor: "inverse",
573
- clearConsole: false,
574
- packageName: "bleump",
575
- packageVersion: currentVersion,
576
- isDev,
577
- });
578
- }
579
-
580
- async function showEndPrompt() {
581
- await endPrompt({
582
- title:
583
- "ā¤ļø Please support bleump: https://github.com/sponsors/blefnk\n│ šŸ“ Feedback: https://github.com/blefnk/bleump/issues",
584
- titleColor: "dim",
585
- });
586
- }
587
- ```
588
-
589
- ## Coming Soon
590
-
591
- - [ ] šŸ¤– Auto-commit and push
592
- - [ ] šŸ“ Smart commit messages
593
- - [ ] šŸ“‹ Changelog generation
594
- - [ ] šŸ”„ More version patterns
595
- - [ ] šŸ·ļø Auto-tagging
596
-
597
- ## Contributing
598
-
599
- Got ideas? Found a bug? We'd love your help! Check out our [issues](https://github.com/reliverse/bleump/issues) or submit a PR.
600
-
601
- ## License
602
-
603
- MIT Ā© [Nazar Kornienko (blefnk)](https://github.com/blefnk), [Reliverse](https://github.com/reliverse)
1
+ # 🪸 reliverse bump • powerful version bumping
2
+
3
+ > @reliverse/bump is a powerful version bumping tool for javascript and typescript libraries.
4
+
5
+ [sponsor](https://github.com/sponsors/blefnk) — [discord](https://discord.gg/pb8ukbwpsj) — [repo](https://github.com/reliverse/bump) — [npm](https://npmjs.com/@reliverse/bump) — [docs](https://docs.reliverse.org/reliverse/bump)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ # bun — pnpm — yarn — npm
11
+ bun add -D @reliverse/bump
12
+ ```
13
+
14
+ ## Features
15
+
16
+ - šŸ¤– **Interactive Mode**: Just run and follow the prompts
17
+ - šŸ”„ **Non-Interactive Mode**: Works in CI environments without TTY
18
+ - šŸŽÆ **Smart Detection**: Finds version patterns in your files using regex
19
+ - šŸ”„ **Multiple Files**: Update versions in many files at once
20
+ - šŸ› ļø **File Type Support**: Handles both package.json and TypeScript files
21
+ - šŸŽ® **Custom Versions**: Want a specific version or need to downgrade? No problem!
22
+ - šŸ“ **Custom Source**: Use a different file as version source
23
+ - šŸ” **Dry Run**: Preview changes before applying them
24
+ - šŸ”’ **Version Validation**: Ensures all versions are valid semver
25
+ - šŸ“Š **Version Analysis**: Detects mismatches and compares version differences
26
+ - šŸŽÆ **Range Satisfaction**: Check if versions satisfy semver ranges
27
+ - ⚔ **Fast & Lightweight**: Built with performance in mind
28
+ - šŸ›”ļø **Error Handling**: Comprehensive error checking and reporting
29
+ - šŸ”’ **Bump Disable Management**: Programmatic control of version bumping
30
+
31
+ ## Quick Start
32
+
33
+ ### Interactive Mode
34
+
35
+ Just run:
36
+
37
+ ```bash
38
+ bun rse bump
39
+ ```
40
+
41
+ That's it! Follow the prompts to:
42
+
43
+ 1. Choose which files to update
44
+ 2. Select how you want to bump the version
45
+ 3. See what changes will be made
46
+
47
+ ### Programmatic Mode
48
+
49
+ ```ts
50
+ import { bumpVersionWithAnalysis } from "@reliverse/bump";
51
+
52
+ // Patch bump
53
+ await bumpVersionWithAnalysis(
54
+ "patch", // bumpType: "patch" | "minor" | "major" | "auto" | "manual"
55
+ ["package.json"], // files to bump
56
+ { dryRun: false }, // options
57
+ );
58
+
59
+ // Manual version with bumpSet from config
60
+ await bumpVersionWithAnalysis(
61
+ "manual", // bumpType
62
+ ["package.json"], // files to bump
63
+ { dryRun: false }, // options
64
+ "1.2.3", // bumpSet from dler.ts
65
+ );
66
+
67
+ // Manual version with customVersion
68
+ await bumpVersionWithAnalysis(
69
+ "manual", // bumpType
70
+ ["package.json"], // files to bump
71
+ {
72
+ dryRun: false,
73
+ customVersion: "1.2.3" // overrides bumpSet if provided
74
+ },
75
+ );
76
+ ```
77
+
78
+ ### CLI Mode
79
+
80
+ CLI is available via [Dler CLI](https://github.com/reliverse/dler) by Reliverse.
81
+
82
+ ```bash
83
+ # Basic usage examples
84
+ bun rse bump --bumpType patch --files package.json src/version.ts
85
+ bun rse bump --bumpType minor --dryRun # Preview changes
86
+ bun rse bump --bumpType major --mainFile package.json
87
+ bun rse bump --bumpType auto --mainFile package.json --files package.json dler.ts
88
+ bun rse bump --bumpType manual --customVersion 2.0.0 --mainFile package.json
89
+
90
+ # Advanced usage
91
+ bun rse bump \
92
+ --bumpType manual \
93
+ --customVersion 1.0.1 \
94
+ --dryRun \
95
+ --mainFile package.json \
96
+ --verbose \
97
+ --files "package.json dler.ts"
98
+
99
+ # Available options
100
+ --dev # Run in dev mode
101
+ --bumpType # Type of bump: patch|minor|major|auto|manual
102
+ --customVersion # Set specific version (with manual mode)
103
+ --dryRun # Preview changes without applying
104
+ --mainFile # Version source file (default: package.json)
105
+ --verbose # Show detailed logs
106
+ --files # Files to bump (space or comma-separated)
107
+ --disableBump # Disable bumping (useful for CI)
108
+ ```
109
+
110
+ ## Advanced Features
111
+
112
+ ### Version Analysis
113
+
114
+ The tool performs deep analysis of your files to:
115
+
116
+ - Detect version mismatches across files
117
+ - Validate semver format
118
+ - Identify unsupported file types
119
+ - Provide detailed analysis reports
120
+
121
+ ### Smart Version Detection
122
+
123
+ - Automatically detects version patterns in different file types
124
+ - Supports multiple version formats (quotes, assignments, etc.)
125
+ - Preserves original formatting when updating versions
126
+
127
+ ### CI/CD Integration
128
+
129
+ - Special handling for CI environments
130
+ - Non-interactive mode for automated workflows
131
+ - Configurable through environment variables
132
+ - Support for automated version bumping
133
+
134
+ ### Configuration Management
135
+
136
+ - Flexible configuration through `dler.ts`
137
+ - Support for custom version sources
138
+ - Configurable file patterns
139
+ - Version bump control flags
140
+
141
+ ### Error Prevention
142
+
143
+ - Validates all version changes
144
+ - Prevents invalid semver versions
145
+ - Checks for version mismatches
146
+ - Provides detailed error messages
147
+
148
+ ### Version Bump Control
149
+
150
+ - **Bump Handler**: Advanced version bumping with:
151
+ - Support for auto-patch, auto-minor, auto-major modes
152
+ - Custom version setting capability
153
+ - Dry run support for previewing changes
154
+ - Automatic version validation
155
+ - Configurable file filtering
156
+ - Detailed logging of version changes
157
+
158
+ - **Bump Disable Management**:
159
+ - Programmatic control of version bumping
160
+ - Integration with common publish pause
161
+ - Automatic configuration file updates
162
+ - Support for both TypeScript and JavaScript configs
163
+ - Graceful handling of missing config files
164
+ - Non-blocking error handling
165
+
166
+ ## Advanced Programmatic Example
167
+
168
+ ```ts
169
+ import {
170
+ bumpVersionWithAnalysis,
171
+ analyzeFiles,
172
+ getCurrentVersion,
173
+ type BumpMode,
174
+ type FileAnalysis
175
+ } from "@reliverse/bump";
176
+
177
+ // First analyze files
178
+ const currentVersion = await getCurrentVersion("package.json");
179
+ const fileAnalysis = await analyzeFiles(
180
+ [
181
+ "package.json",
182
+ "src/version.ts",
183
+ "dler.ts"
184
+ ],
185
+ currentVersion
186
+ );
187
+
188
+ // Filter supported files
189
+ const supportedFiles = fileAnalysis
190
+ .filter(f => f.supported)
191
+ .map(f => f.file);
192
+
193
+ // Then bump versions
194
+ await bumpVersionWithAnalysis(
195
+ "patch", // bumpType
196
+ supportedFiles, // only supported files
197
+ {
198
+ dryRun: true, // preview only
199
+ verbose: true, // show detailed logs
200
+ }
201
+ );
202
+ ```
203
+
204
+ ### Configuration Types
205
+
206
+ ```ts
207
+ type BumpMode = "patch" | "minor" | "major" | "auto" | "manual";
208
+
209
+ type BumpOptions = {
210
+ dryRun?: boolean;
211
+ verbose?: boolean;
212
+ customVersion?: string;
213
+ };
214
+
215
+ type FileAnalysis = {
216
+ file: string;
217
+ supported: boolean;
218
+ detectedVersion: string | null;
219
+ versionMismatch: boolean;
220
+ reason: string;
221
+ fileType: "package.json" | "typescript" | "unknown";
222
+ };
223
+ ```
224
+
225
+ ### Additional Utility Functions
226
+
227
+ ```ts
228
+ // Check if version bumping is currently disabled
229
+ await isBumpDisabled(): Promise<boolean>
230
+
231
+ // Set bumpDisable flag to a specific value
232
+ await setBumpDisabledValueTo(value: boolean): Promise<void>
233
+
234
+ // Update any field in dler.ts
235
+ await updateDlerConfig(field: string, value: any): Promise<void>
236
+
237
+ // Get current version from a file
238
+ await getCurrentVersion(filePath?: string, field?: string): Promise<string>
239
+
240
+ // Get package name from a file
241
+ await getPackageName(filePath?: string, field?: string): Promise<string>
242
+
243
+ // Get package author from a file
244
+ await getPackageAuthor(filePath?: string, field?: string): Promise<string>
245
+
246
+ // Compare two versions
247
+ compareVersions(version1: string, version2: string): number
248
+
249
+ // Get latest version from an array of versions
250
+ getLatestVersion(versions: string[]): string | null
251
+
252
+ // Check if a version is a prerelease
253
+ isPrerelease(version: string): boolean
254
+
255
+ // Check if a version satisfies a range
256
+ satisfiesRange(version: string, range: string): boolean
257
+
258
+ // Parse semver into components
259
+ parseSemver(version: string): [number, number, number]
260
+
261
+ // Validate semver format
262
+ isValidSemver(version: string): boolean
263
+ ```
264
+
265
+ ## Configuration
266
+
267
+ ### CLI Options
268
+
269
+ ```bash
270
+ Options:
271
+ --bumpMode <mode> Mode: patch, minor, major, auto, manual
272
+ --customVersion <ver> Set specific version (with manual mode)
273
+ --mainFile <file> Version source file (default: package.json)
274
+ --dryRun Preview changes without applying
275
+ --disableBump Disable bumping (useful for CI)
276
+ --dev Run in dev mode
277
+ ```
278
+
279
+ ### Using with `dler.ts`
280
+
281
+ Create a `dler.ts` to configure default behavior:
282
+
283
+ ```ts
284
+ import { defineConfig } from "@reliverse/dler";
285
+
286
+ export default defineConfig({
287
+ bumpFilter: [
288
+ "package.json",
289
+ "src/version.ts",
290
+ ],
291
+ bumpMode: "patch",
292
+ bumpDisable: false,
293
+ });
294
+ ```
295
+
296
+ ## Advanced Usage
297
+
298
+ ```ts
299
+ // src/cli.ts
300
+ import { relinka } from "@reliverse/relinka";
301
+ import {
302
+ runMain,
303
+ defineCommand,
304
+ defineArgs,
305
+ selectPrompt,
306
+ inputPrompt,
307
+ startPrompt,
308
+ endPrompt,
309
+ } from "rempts";
310
+ import path from "node:path";
311
+ import semver from "semver";
312
+
313
+ import {
314
+ bumpVersionWithAnalysis,
315
+ getCurrentVersion,
316
+ getFilesFromConfigOrDefault,
317
+ getConfigFromDler,
318
+ type BumpMode,
319
+ validateBumpConfig,
320
+ getDefaultBumpMode,
321
+ handleNonInteractiveSession,
322
+ handleInteractiveSession,
323
+ type SessionConfig,
324
+ } from "./mod.js";
325
+
326
+ const bumpTypes: BumpMode[] = ["patch", "minor", "major", "auto", "manual"];
327
+
328
+ const main = defineCommand({
329
+ meta: {
330
+ name: "bump",
331
+ description:
332
+ "Allows you to bump the version of your project interactively.",
333
+ },
334
+ args: defineArgs({
335
+ dev: {
336
+ type: "boolean",
337
+ description: "Runs the CLI in dev mode",
338
+ },
339
+ bumpType: {
340
+ type: "string",
341
+ description: "The type of version bump to perform",
342
+ allowed: bumpTypes,
343
+ },
344
+ customVersion: {
345
+ type: "string",
346
+ description: "Custom version to set (only used with manual bump type)",
347
+ },
348
+ disableBump: {
349
+ type: "boolean",
350
+ description: "Disables the bump (this is useful for CI)",
351
+ },
352
+ files: {
353
+ type: "string",
354
+ description:
355
+ 'Files to bump (comma or space-separated, or quoted: "package.json dler.ts")',
356
+ default: "",
357
+ },
358
+ dryRun: {
359
+ type: "boolean",
360
+ description: "Preview changes without writing files",
361
+ },
362
+ mainFile: {
363
+ type: "string",
364
+ description:
365
+ "The file to use as version source (defaults to package.json)",
366
+ default: "package.json",
367
+ },
368
+ verbose: {
369
+ type: "boolean",
370
+ description: "Enable verbose output",
371
+ },
372
+ }),
373
+ async run({ args }) {
374
+ const isCI = process.env.CI === "true";
375
+ const isNonInteractive = !process.stdout.isTTY;
376
+ const dryRun = !!args.dryRun;
377
+ const verbose = !!args.verbose;
378
+ const mainFile = args.mainFile;
379
+ const customVersion = args.customVersion;
380
+
381
+ // Read current versions
382
+ let bleumpVersion = "unknown";
383
+ let projectVersion = "unknown";
384
+ try {
385
+ const bleumpPkg = await import("../package.json", {
386
+ assert: { type: "json" },
387
+ });
388
+ bleumpVersion = bleumpPkg.default.version || "unknown";
389
+ projectVersion = await getCurrentVersion(mainFile);
390
+ } catch (e) {
391
+ relinka("warn", `Could not read package versions: ${e}`);
392
+ }
393
+
394
+ await showStartPrompt(args.dev, bleumpVersion);
395
+
396
+ // Get files to bump - handle multiple parsing scenarios
397
+ let filesToBumpArr: string[] = [];
398
+
399
+ // Handle files from --files flag with improved parsing
400
+ if (args.files) {
401
+ // handle both comma and space separation, plus remaining CLI args
402
+ const filesFromFlag = args.files
403
+ .split(/[,\s]+/) // split on comma or whitespace
404
+ .map((f) => f.trim())
405
+ .filter(Boolean);
406
+
407
+ // also check if there are additional file arguments after known flags
408
+ const remainingArgs = process.argv.slice(2);
409
+ const knownFlags = [
410
+ "--dev",
411
+ "--bumpType",
412
+ "--customVersion",
413
+ "--disableBump",
414
+ "--files",
415
+ "--dryRun",
416
+ "--mainFile",
417
+ "--verbose",
418
+ ];
419
+
420
+ // find files that appear after --files but aren't flags
421
+ const filesIndex = remainingArgs.findIndex((arg) => arg === "--files");
422
+ if (filesIndex !== -1) {
423
+ for (let i = filesIndex + 2; i < remainingArgs.length; i++) {
424
+ const arg = remainingArgs[i];
425
+ if (arg.startsWith("--") || knownFlags.includes(arg)) break;
426
+ if (!filesFromFlag.includes(arg)) {
427
+ filesFromFlag.push(arg);
428
+ }
429
+ }
430
+ }
431
+
432
+ filesToBumpArr = filesFromFlag;
433
+ }
434
+
435
+ // If no files specified, use defaults
436
+ if (filesToBumpArr.length === 0) {
437
+ filesToBumpArr = await getFilesFromConfigOrDefault();
438
+ }
439
+
440
+ // Ensure mainFile is in the list (using absolute path)
441
+ if (!filesToBumpArr.includes(mainFile)) {
442
+ filesToBumpArr.unshift(mainFile);
443
+ }
444
+
445
+ // Remove duplicates while preserving order
446
+ filesToBumpArr = [...new Set(filesToBumpArr)];
447
+
448
+ // Get bump type and other settings from config
449
+ const dlerConfig = await getConfigFromDler();
450
+ let effectiveBumpMode = args.bumpType as BumpMode;
451
+
452
+ // Apply config settings if not overridden by CLI args
453
+ if (!effectiveBumpMode && dlerConfig.bumpMode) {
454
+ effectiveBumpMode = dlerConfig.bumpMode;
455
+ }
456
+ if (!effectiveBumpMode) {
457
+ effectiveBumpMode = getDefaultBumpMode(isCI, isNonInteractive);
458
+ }
459
+
460
+ // Override disableBump from config if not set via CLI
461
+ if (!args.disableBump && dlerConfig.bumpDisable) {
462
+ args.disableBump = true;
463
+ }
464
+
465
+ const sessionConfig: SessionConfig = {
466
+ isCI,
467
+ isNonInteractive,
468
+ mainFile,
469
+ filesToBump: filesToBumpArr,
470
+ options: { dryRun, verbose, customVersion },
471
+ bumpType: effectiveBumpMode,
472
+ };
473
+
474
+ if (verbose) {
475
+ relinka("info", "Configuration:");
476
+ relinka("log", ` Bump Type: ${effectiveBumpMode}`);
477
+ relinka("log", ` Custom Version: ${customVersion || "none"}`);
478
+ relinka("log", ` Dry Run: ${dryRun}`);
479
+ relinka("log", ` Main File: ${mainFile}`);
480
+ relinka("log", ` Files to Bump (${filesToBumpArr.length}):`);
481
+ for (const file of filesToBumpArr) {
482
+ relinka("log", ` ${file}`);
483
+ }
484
+ relinka("log", ` Current Version: ${projectVersion}`);
485
+ }
486
+
487
+ if (args.disableBump) {
488
+ relinka(
489
+ "log",
490
+ "Bump disabled (--disableBump flag set or configured in dler.ts)",
491
+ );
492
+ process.exit(0);
493
+ }
494
+
495
+ try {
496
+ if (isCI || isNonInteractive) {
497
+ await handleNonInteractiveSession(sessionConfig);
498
+ } else {
499
+ await handleInteractiveSession(sessionConfig, projectVersion);
500
+
501
+ // Get bump type from user if not provided
502
+ if (!args.bumpType) {
503
+ effectiveBumpMode = (await selectPrompt({
504
+ title: `Select a bump type (current: ${projectVersion} from ${path.relative(process.cwd(), mainFile)})`,
505
+ options: [
506
+ {
507
+ value: "patch",
508
+ label: `patch (${projectVersion} → ${semver.inc(projectVersion, "patch")})`,
509
+ },
510
+ {
511
+ value: "minor",
512
+ label: `minor (${projectVersion} → ${semver.inc(projectVersion, "minor")})`,
513
+ },
514
+ {
515
+ value: "major",
516
+ label: `major (${projectVersion} → ${semver.inc(projectVersion, "major")})`,
517
+ },
518
+ {
519
+ value: "auto",
520
+ label: "auto (automatically determine bump type)",
521
+ },
522
+ {
523
+ value: "manual",
524
+ label: "manual (enter your own version)",
525
+ },
526
+ ],
527
+ })) as BumpMode;
528
+
529
+ // If manual selected, prompt for the version
530
+ if (effectiveBumpMode === "manual") {
531
+ const newCustomVersion = await inputPrompt({
532
+ title: "Enter the version number",
533
+ content: "Must be a valid semver (e.g., 1.2.3)",
534
+ defaultValue: projectVersion,
535
+ validate: (input: string) => {
536
+ if (!semver.valid(input)) {
537
+ return "Please enter a valid semver version (e.g., 1.2.3)";
538
+ }
539
+ return true;
540
+ },
541
+ });
542
+ sessionConfig.options.customVersion = newCustomVersion;
543
+ }
544
+ }
545
+
546
+ sessionConfig.bumpType = effectiveBumpMode;
547
+ validateBumpConfig(
548
+ effectiveBumpMode,
549
+ sessionConfig.options.customVersion,
550
+ );
551
+ await bumpVersionWithAnalysis(
552
+ effectiveBumpMode,
553
+ filesToBumpArr,
554
+ sessionConfig.options,
555
+ dlerConfig.bumpSet,
556
+ );
557
+ }
558
+ } catch (error) {
559
+ relinka("error", error instanceof Error ? error.message : String(error));
560
+ process.exit(1);
561
+ }
562
+
563
+ relinka("log", " ");
564
+ await showEndPrompt();
565
+ },
566
+ });
567
+
568
+ await runMain(main);
569
+
570
+ async function showStartPrompt(isDev: boolean, currentVersion: string) {
571
+ await startPrompt({
572
+ titleColor: "inverse",
573
+ clearConsole: false,
574
+ packageName: "bleump",
575
+ packageVersion: currentVersion,
576
+ isDev,
577
+ });
578
+ }
579
+
580
+ async function showEndPrompt() {
581
+ await endPrompt({
582
+ title:
583
+ "ā¤ļø Please support bleump: https://github.com/sponsors/blefnk\n│ šŸ“ Feedback: https://github.com/blefnk/bleump/issues",
584
+ titleColor: "dim",
585
+ });
586
+ }
587
+ ```
588
+
589
+ ## Coming Soon
590
+
591
+ - [ ] šŸ¤– Auto-commit and push
592
+ - [ ] šŸ“ Smart commit messages
593
+ - [ ] šŸ“‹ Changelog generation
594
+ - [ ] šŸ”„ More version patterns
595
+ - [ ] šŸ·ļø Auto-tagging
596
+
597
+ ## Contributing
598
+
599
+ Got ideas? Found a bug? We'd love your help! Check out our [issues](https://github.com/reliverse/bleump/issues) or submit a PR.
600
+
601
+ ## License
602
+
603
+ MIT Ā© [Nazar Kornienko (blefnk)](https://github.com/blefnk), [Reliverse](https://github.com/reliverse)
package/dist/mod.js CHANGED
@@ -39,7 +39,11 @@ export function getReleaseType(version) {
39
39
  if (!parsed) {
40
40
  return null;
41
41
  }
42
- if (parsed.major > 0) return "major";
43
- if (parsed.minor > 0) return "minor";
42
+ if (parsed.major > 0) {
43
+ return "major";
44
+ }
45
+ if (parsed.minor > 0) {
46
+ return "minor";
47
+ }
44
48
  return "patch";
45
49
  }
package/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "@reliverse/bump",
3
+ "version": "2.3.1",
4
+ "private": false,
3
5
  "description": "Bump utils for Reliverse ecosystem",
6
+ "keywords": [
7
+ "bump",
8
+ "dler"
9
+ ],
10
+ "license": "MIT",
4
11
  "author": "reliverse",
5
- "version": "2.2.10",
6
- "private": false,
12
+ "files": [
13
+ "dist",
14
+ "package.json"
15
+ ],
7
16
  "type": "module",
8
17
  "exports": {
9
18
  ".": {
@@ -11,19 +20,10 @@
11
20
  "default": "./dist/mod.js"
12
21
  }
13
22
  },
14
- "dependencies": {
15
- "semver": "^7.7.3"
16
- },
17
- "keywords": [
18
- "dler",
19
- "bump"
20
- ],
21
23
  "publishConfig": {
22
24
  "access": "public"
23
25
  },
24
- "files": [
25
- "dist",
26
- "package.json"
27
- ],
28
- "license": "MIT"
26
+ "dependencies": {
27
+ "semver": "^7.7.3"
28
+ }
29
29
  }