Skip to content

Commit b9e1c96

Browse files
committed
feat(custom): improve custom platform support
- Add support for JSON manifest files - Improve regex for custom variable extraction - Handle different assignment operators (=, =>, :) - Create dedicated CustomUpdaterService - Improve error handling for custom platform
1 parent a1255b8 commit b9e1c96

9 files changed

Lines changed: 195 additions & 110 deletions

File tree

dist/index.js

Lines changed: 114 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* universal-version-bump v0.12.2
2+
* universal-version-bump v0.13.0
33
* Universal Version Bump
44
*
55
* Description: A GitHub Action to automatically bump versions across any app (Node, Python, PHP, Docker, etc.)
66
* Author: Taj <[email protected]>
77
* Homepage: https://github.com/taj54/universal-version-bump#readme
88
* License: MIT
9-
* Generated on Mon, 01 Sep 2025 13:33:59 GMT
9+
* Generated on Tue, 02 Sep 2025 13:11:06 GMT
1010
*/
1111
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
1212
/******/ var __webpack_modules__ = ({
@@ -7564,12 +7564,12 @@ const { safeRe: re, t } = __nccwpck_require__(6211)
75647564
const cmp = __nccwpck_require__(5618)
75657565
const debug = __nccwpck_require__(7611)
75667566
const SemVer = __nccwpck_require__(4839)
7567-
const Range = __nccwpck_require__(6093)
7567+
const Range = __nccwpck_require__(8474)
75687568

75697569

75707570
/***/ }),
75717571

7572-
/***/ 6093:
7572+
/***/ 8474:
75737573
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
75747574

75757575
"use strict";
@@ -8941,7 +8941,7 @@ module.exports = rsort
89418941
"use strict";
89428942

89438943

8944-
const Range = __nccwpck_require__(6093)
8944+
const Range = __nccwpck_require__(8474)
89458945
const satisfies = (version, range, options) => {
89468946
try {
89478947
range = new Range(range, options)
@@ -9019,7 +9019,7 @@ const lte = __nccwpck_require__(3353)
90199019
const cmp = __nccwpck_require__(5618)
90209020
const coerce = __nccwpck_require__(3597)
90219021
const Comparator = __nccwpck_require__(863)
9022-
const Range = __nccwpck_require__(6093)
9022+
const Range = __nccwpck_require__(8474)
90239023
const satisfies = __nccwpck_require__(9751)
90249024
const toComparators = __nccwpck_require__(2258)
90259025
const maxSatisfying = __nccwpck_require__(9269)
@@ -9506,7 +9506,7 @@ module.exports = gtr
95069506
"use strict";
95079507

95089508

9509-
const Range = __nccwpck_require__(6093)
9509+
const Range = __nccwpck_require__(8474)
95109510
const intersects = (r1, r2, options) => {
95119511
r1 = new Range(r1, options)
95129512
r2 = new Range(r2, options)
@@ -9538,7 +9538,7 @@ module.exports = ltr
95389538

95399539

95409540
const SemVer = __nccwpck_require__(4839)
9541-
const Range = __nccwpck_require__(6093)
9541+
const Range = __nccwpck_require__(8474)
95429542

95439543
const maxSatisfying = (versions, range, options) => {
95449544
let max = null
@@ -9573,7 +9573,7 @@ module.exports = maxSatisfying
95739573

95749574

95759575
const SemVer = __nccwpck_require__(4839)
9576-
const Range = __nccwpck_require__(6093)
9576+
const Range = __nccwpck_require__(8474)
95779577
const minSatisfying = (versions, range, options) => {
95789578
let min = null
95799579
let minSV = null
@@ -9607,7 +9607,7 @@ module.exports = minSatisfying
96079607

96089608

96099609
const SemVer = __nccwpck_require__(4839)
9610-
const Range = __nccwpck_require__(6093)
9610+
const Range = __nccwpck_require__(8474)
96119611
const gt = __nccwpck_require__(5283)
96129612

96139613
const minVersion = (range, loose) => {
@@ -9680,7 +9680,7 @@ module.exports = minVersion
96809680
const SemVer = __nccwpck_require__(4839)
96819681
const Comparator = __nccwpck_require__(863)
96829682
const { ANY } = Comparator
9683-
const Range = __nccwpck_require__(6093)
9683+
const Range = __nccwpck_require__(8474)
96849684
const satisfies = __nccwpck_require__(9751)
96859685
const gt = __nccwpck_require__(5283)
96869686
const lt = __nccwpck_require__(6108)
@@ -9824,7 +9824,7 @@ module.exports = (versions, range, options) => {
98249824
"use strict";
98259825

98269826

9827-
const Range = __nccwpck_require__(6093)
9827+
const Range = __nccwpck_require__(8474)
98289828
const Comparator = __nccwpck_require__(863)
98299829
const { ANY } = Comparator
98309830
const satisfies = __nccwpck_require__(9751)
@@ -10081,7 +10081,7 @@ module.exports = subset
1008110081
"use strict";
1008210082

1008310083

10084-
const Range = __nccwpck_require__(6093)
10084+
const Range = __nccwpck_require__(8474)
1008510085

1008610086
// Mostly just for testing and legacy API reasons
1008710087
const toComparators = (range, options) =>
@@ -10099,7 +10099,7 @@ module.exports = toComparators
1009910099
"use strict";
1010010100

1010110101

10102-
const Range = __nccwpck_require__(6093)
10102+
const Range = __nccwpck_require__(8474)
1010310103
const validRange = (range, options) => {
1010410104
try {
1010510105
// Return '*' instead of '' so that truthiness works.
@@ -33076,6 +33076,45 @@ class ChangelogService {
3307633076
exports.ChangelogService = ChangelogService;
3307733077

3307833078

33079+
/***/ }),
33080+
33081+
/***/ 2267:
33082+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
33083+
33084+
"use strict";
33085+
33086+
Object.defineProperty(exports, "__esModule", ({ value: true }));
33087+
exports.CustomUpdaterService = void 0;
33088+
const errors_1 = __nccwpck_require__(4830);
33089+
const updaters_1 = __nccwpck_require__(1384);
33090+
/**
33091+
* Service for handling custom version updates.
33092+
*/
33093+
class CustomUpdaterService {
33094+
/**
33095+
* Updates the version for the specified bump targets.
33096+
* @param releaseType The type of release (major, minor, patch).
33097+
* @param bumpTargets The targets to bump.
33098+
* @returns The new version string.
33099+
*/
33100+
updateCustomVersions(releaseType, bumpTargets) {
33101+
if (bumpTargets.length === 0) {
33102+
throw new errors_1.VersionBumpError('No bump_targets provided for custom platform.');
33103+
}
33104+
let lastBumpedVersion = '';
33105+
for (const target of bumpTargets) {
33106+
if (!target.path || !target.variable) {
33107+
throw new errors_1.VersionBumpError('Invalid bump_target provided for custom platform.');
33108+
}
33109+
const customUpdater = new updaters_1.CustomUpdater(target.path, target.variable);
33110+
lastBumpedVersion = customUpdater.bumpVersion(releaseType);
33111+
}
33112+
return lastBumpedVersion;
33113+
}
33114+
}
33115+
exports.CustomUpdaterService = CustomUpdaterService;
33116+
33117+
3307933118
/***/ }),
3308033119

3308133120
/***/ 8743:
@@ -33274,6 +33313,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
3327433313
__exportStar(__nccwpck_require__(9104), exports);
3327533314
__exportStar(__nccwpck_require__(8743), exports);
3327633315
__exportStar(__nccwpck_require__(5417), exports);
33316+
__exportStar(__nccwpck_require__(2267), exports);
3327733317

3327833318

3327933319
/***/ }),
@@ -33286,7 +33326,7 @@ __exportStar(__nccwpck_require__(5417), exports);
3328633326
Object.defineProperty(exports, "__esModule", ({ value: true }));
3328733327
exports.UpdaterService = void 0;
3328833328
const errors_1 = __nccwpck_require__(4830);
33289-
const customUpdater_1 = __nccwpck_require__(5432);
33329+
const customUpdaterService_1 = __nccwpck_require__(2267);
3329033330
/**
3329133331
* Service for managing version updates.
3329233332
*/
@@ -33325,15 +33365,8 @@ class UpdaterService {
3332533365
*/
3332633366
updateVersion(platform, releaseType, bumpTargets = []) {
3332733367
if (platform === 'custom') {
33328-
if (bumpTargets.length === 0) {
33329-
throw new errors_1.VersionBumpError('No bump_targets provided for custom platform.');
33330-
}
33331-
let lastBumpedVersion = '';
33332-
for (const target of bumpTargets) {
33333-
const customUpdater = new customUpdater_1.CustomUpdater(target.path, target.variable);
33334-
lastBumpedVersion = customUpdater.bumpVersion(releaseType);
33335-
}
33336-
return lastBumpedVersion;
33368+
const customUpdaterService = new customUpdaterService_1.CustomUpdaterService();
33369+
return customUpdaterService.updateCustomVersions(releaseType, bumpTargets);
3333733370
}
3333833371
else {
3333933372
const updater = this.updaterRegistry.getUpdater(platform);
@@ -33409,10 +33442,19 @@ class CustomUpdater {
3340933442
return this.currentVersion;
3341033443
}
3341133444
try {
33412-
const regex = new RegExp(`"${this.variableName}"\\s*:\\s*["']((?:[0-9]+\\.){2}[0-9]+(?:-[a-zA-Z0-9_.-]+)?(?:\\+[a-zA-Z0-9_.-]+)?)["']`);
33413-
this.currentVersion = this.manifestParser.getVersion(this.filePath, 'regex', {
33414-
regex,
33415-
});
33445+
const lastPath = this.filePath.split('/').pop() || '';
33446+
const extension = lastPath.split('.').pop() || '';
33447+
if (extension === 'json') {
33448+
this.currentVersion = this.manifestParser.getVersion(this.filePath, 'json', {
33449+
jsonPath: [this.variableName],
33450+
});
33451+
}
33452+
else {
33453+
const regex = new RegExp(`(${this.variableName}\\s*(=|=>|:)\\s*['"])([0-9]+\\.[0-9]+\\.[0-9]+(?:-[a-zA-Z0-9_.-]+)?(?:\\+[a-zA-Z0-9_.-]+)?)(['"])`);
33454+
this.currentVersion = this.manifestParser.getVersion(this.filePath, 'regex', {
33455+
regex,
33456+
});
33457+
}
3341633458
return this.currentVersion;
3341733459
}
3341833460
catch (error) {
@@ -33427,7 +33469,7 @@ class CustomUpdater {
3342733469
}
3342833470
const newVersion = (0, utils_1.calculateNextVersion)(oldVersion, releaseType);
3342933471
// eslint-disable-next-line no-useless-escape
33430-
const regexReplace = new RegExp(`("${this.variableName}"\\s*:\\s*["'])([0-9]+\\.[0-9]+\\.[0-9]+(?:-[a-zA-Z0-9_.-]+)?(?:\\+[a-zA-Z0-9_.-]+)?)(["'])`);
33472+
const regexReplace = new RegExp(`(${this.variableName}\\s*(=|=>|:)\\s*['"])([0-9]+\\.[0-9]+\\.[0-9]+(?:-[a-zA-Z0-9_.-]+)?(?:\\+[a-zA-Z0-9_.-]+)?)(['"])`);
3343133473
this.manifestParser.updateVersion(this.filePath, newVersion, 'regex', {
3343233474
regexReplace,
3343333475
});
@@ -33899,12 +33941,42 @@ exports.RustUpdater = RustUpdater;
3389933941

3390033942
"use strict";
3390133943

33902-
var __importDefault = (this && this.__importDefault) || function (mod) {
33903-
return (mod && mod.__esModule) ? mod : { "default": mod };
33904-
};
33944+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
33945+
if (k2 === undefined) k2 = k;
33946+
var desc = Object.getOwnPropertyDescriptor(m, k);
33947+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
33948+
desc = { enumerable: true, get: function() { return m[k]; } };
33949+
}
33950+
Object.defineProperty(o, k2, desc);
33951+
}) : (function(o, m, k, k2) {
33952+
if (k2 === undefined) k2 = k;
33953+
o[k2] = m[k];
33954+
}));
33955+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
33956+
Object.defineProperty(o, "default", { enumerable: true, value: v });
33957+
}) : function(o, v) {
33958+
o["default"] = v;
33959+
});
33960+
var __importStar = (this && this.__importStar) || (function () {
33961+
var ownKeys = function(o) {
33962+
ownKeys = Object.getOwnPropertyNames || function (o) {
33963+
var ar = [];
33964+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33965+
return ar;
33966+
};
33967+
return ownKeys(o);
33968+
};
33969+
return function (mod) {
33970+
if (mod && mod.__esModule) return mod;
33971+
var result = {};
33972+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33973+
__setModuleDefault(result, mod);
33974+
return result;
33975+
};
33976+
})();
3390533977
Object.defineProperty(exports, "__esModule", ({ value: true }));
3390633978
exports.FileHandler = void 0;
33907-
const fs_1 = __importDefault(__nccwpck_require__(9896));
33979+
const fs = __importStar(__nccwpck_require__(9896));
3390833980
const errors_1 = __nccwpck_require__(4830);
3390933981
/**
3391033982
* Utility class for handling file operations.
@@ -33917,7 +33989,7 @@ class FileHandler {
3391733989
* @returns True if the file exists, false otherwise.
3391833990
*/
3391933991
fileExists(filePath) {
33920-
return fs_1.default.existsSync(filePath);
33992+
return fs.existsSync(filePath);
3392133993
}
3392233994
/**
3392333995
* Reads the contents of a file.
@@ -33928,15 +34000,15 @@ class FileHandler {
3392834000
if (!this.fileExists(filePath)) {
3392934001
throw new errors_1.FileNotFoundError(`File not found: ${filePath}`);
3393034002
}
33931-
return fs_1.default.readFileSync(filePath, 'utf8');
34003+
return fs.readFileSync(filePath, 'utf-8');
3393234004
}
3393334005
/**
3393434006
* Writes the contents to a file.
3393534007
* @param filePath The path to the file.
3393634008
* @param content The content to write to the file.
3393734009
*/
3393834010
writeFile(filePath, content) {
33939-
fs_1.default.writeFileSync(filePath, content);
34011+
fs.writeFileSync(filePath, content);
3394034012
}
3394134013
/**
3394234014
* Reads the contents of a directory.
@@ -33948,7 +34020,7 @@ class FileHandler {
3394834020
if (!this.fileExists(dirPath)) {
3394934021
throw new errors_1.FileNotFoundError(`Directory not found: ${dirPath}`);
3395034022
}
33951-
return fs_1.default.readdirSync(dirPath);
34023+
return fs.readdirSync(dirPath);
3395234024
}
3395334025
}
3395434026
exports.FileHandler = FileHandler;
@@ -34020,6 +34092,7 @@ function safeParseJSON(str) {
3402034092
Object.defineProperty(exports, "__esModule", ({ value: true }));
3402134093
exports.ManifestParser = void 0;
3402234094
const errors_1 = __nccwpck_require__(4830);
34095+
const jsonUtils_1 = __nccwpck_require__(8396);
3402334096
/**
3402434097
* Utility class for parsing and updating manifest files.
3402534098
*/
@@ -34052,7 +34125,7 @@ class ManifestParser {
3405234125
if (type === 'json') {
3405334126
let data;
3405434127
try {
34055-
data = JSON.parse(content);
34128+
data = (0, jsonUtils_1.safeParseJSON)(content);
3405634129
}
3405734130
catch (e) {
3405834131
throw new errors_1.InvalidManifestError(`Invalid JSON in ${manifestPath}: ${e instanceof Error ? e.message : String(e)}`);
@@ -34279,7 +34352,7 @@ module.exports = require("node:crypto");
3427934352

3428034353
/***/ }),
3428134354

34282-
/***/ 8474:
34355+
/***/ 6093:
3428334356
/***/ ((module) => {
3428434357

3428534358
"use strict";
@@ -34642,7 +34715,7 @@ module.exports = Dicer
3464234715
"use strict";
3464334716

3464434717

34645-
const EventEmitter = (__nccwpck_require__(8474).EventEmitter)
34718+
const EventEmitter = (__nccwpck_require__(6093).EventEmitter)
3464634719
const inherits = (__nccwpck_require__(7975).inherits)
3464734720
const getLimit = __nccwpck_require__(1954)
3464834721

@@ -34797,7 +34870,7 @@ module.exports = PartStream
3479734870
* Based heavily on the Streaming Boyer-Moore-Horspool C++ implementation
3479834871
* by Hongli Lai at: https://github.com/FooBarWidget/boyer-moore-horspool
3479934872
*/
34800-
const EventEmitter = (__nccwpck_require__(8474).EventEmitter)
34873+
const EventEmitter = (__nccwpck_require__(6093).EventEmitter)
3480134874
const inherits = (__nccwpck_require__(7975).inherits)
3480234875

3480334876
function SBMH (needle) {

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/customUpdaterService.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ export class CustomUpdaterService {
2424
if (!target.path || !target.variable) {
2525
throw new VersionBumpError('Invalid bump_target provided for custom platform.');
2626
}
27-
const lastPath = target.path.split('/').pop();
28-
console.log(lastPath);
2927
const customUpdater = new CustomUpdater(target.path, target.variable);
3028
lastBumpedVersion = customUpdater.bumpVersion(releaseType);
3129
}

src/updaters/customUpdater.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@ export class CustomUpdater implements UpdaterInterface {
2929
}
3030

3131
try {
32-
const regex: RegExp = new RegExp(
33-
`(${this.variableName}\\s*(=|=>|:)\\s*['"])([0-9]+\\.[0-9]+\\.[0-9]+(?:-[a-zA-Z0-9_.-]+)?(?:\\+[a-zA-Z0-9_.-]+)?)(['"])`,
34-
);
35-
this.currentVersion = this.manifestParser.getVersion(this.filePath, 'regex', {
36-
regex,
37-
});
32+
const lastPath = this.filePath.split('/').pop() || '';
33+
const extension = lastPath.split('.').pop() || '';
34+
if (extension === 'json') {
35+
this.currentVersion = this.manifestParser.getVersion(this.filePath, 'json', {
36+
jsonPath: [this.variableName],
37+
});
38+
} else {
39+
const regex: RegExp = new RegExp(
40+
`(${this.variableName}\\s*(=|=>|:)\\s*['"])([0-9]+\\.[0-9]+\\.[0-9]+(?:-[a-zA-Z0-9_.-]+)?(?:\\+[a-zA-Z0-9_.-]+)?)(['"])`,
41+
);
42+
this.currentVersion = this.manifestParser.getVersion(this.filePath, 'regex', {
43+
regex,
44+
});
45+
}
3846
return this.currentVersion;
3947
} catch (error) {
4048
core.debug(`Could not read or parse version from ${this.filePath}: ${error}`);

0 commit comments

Comments
 (0)