Skip to content

Commit da2a77c

Browse files
committed
refactor(updater): remove custom bump targets
- Removed custom bump targets feature. - Simplified updateVersion function. - Removed CustomUpdater class. - Improved error handling. - Updated documentation.
1 parent 4b261d4 commit da2a77c

1 file changed

Lines changed: 8 additions & 118 deletions

File tree

dist/index.js

Lines changed: 8 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Author: Taj <[email protected]>
77
* Homepage: https://github.com/taj54/universal-version-bump#readme
88
* License: MIT
9-
* Generated on Fri, 29 Aug 2025 12:57:13 GMT
9+
* Generated on Fri, 29 Aug 2025 17:28:44 GMT
1010
*/
1111
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
1212
/******/ var __webpack_modules__ = ({
@@ -32667,13 +32667,12 @@ var __importStar = (this && this.__importStar) || (function () {
3266732667
};
3266832668
})();
3266932669
Object.defineProperty(exports, "__esModule", ({ value: true }));
32670-
exports.BUMP_TARGETS = exports.TARGET_PATH = exports.GIT_TAG = exports.TARGET_PLATFORM = exports.RELEASE_TYPE = void 0;
32670+
exports.TARGET_PATH = exports.GIT_TAG = exports.TARGET_PLATFORM = exports.RELEASE_TYPE = void 0;
3267132671
const core = __importStar(__nccwpck_require__(9999));
3267232672
exports.RELEASE_TYPE = (core.getInput('release_type') || 'patch');
3267332673
exports.TARGET_PLATFORM = core.getInput('target_platform');
3267432674
exports.GIT_TAG = core.getInput('git_tag') === 'true';
3267532675
exports.TARGET_PATH = core.getInput('target_path') || '.';
32676-
exports.BUMP_TARGETS = JSON.parse(core.getInput('bump_targets') || '[]');
3267732676

3267832677

3267932678
/***/ }),
@@ -32802,8 +32801,7 @@ async function run() {
3280232801
const { updaterService, gitService, changelogService } = await initializeServices();
3280332802
const platform = updaterService.getPlatform(targetPlatform);
3280432803
core.info(`Detected platform: ${platform}`);
32805-
const bumpTargets = JSON.parse(config_1.BUMP_TARGETS);
32806-
const version = updaterService.updateVersion(platform, releaseType, bumpTargets);
32804+
const version = updaterService.updateVersion(platform, releaseType);
3280732805
core.setOutput('new_version', version);
3280832806
// Generate and update changelog
3280932807
const latestTag = await gitService.getLatestTag();
@@ -33268,7 +33266,6 @@ __exportStar(__nccwpck_require__(5417), exports);
3326833266
Object.defineProperty(exports, "__esModule", ({ value: true }));
3326933267
exports.UpdaterService = void 0;
3327033268
const errors_1 = __nccwpck_require__(4830);
33271-
const customUpdater_1 = __nccwpck_require__(5432);
3327233269
/**
3327333270
* Service for managing version updates.
3327433271
*/
@@ -33305,124 +33302,17 @@ class UpdaterService {
3330533302
* @param releaseType The type of release (major, minor, patch).
3330633303
* @returns The new version string.
3330733304
*/
33308-
updateVersion(platform, releaseType, bumpTargets = []) {
33309-
if (platform === 'custom') {
33310-
if (bumpTargets.length === 0) {
33311-
throw new errors_1.VersionBumpError('No bump_targets provided for custom platform.');
33312-
}
33313-
let lastBumpedVersion = '';
33314-
for (const target of bumpTargets) {
33315-
const customUpdater = new customUpdater_1.CustomUpdater(target.path, target.variable);
33316-
lastBumpedVersion = customUpdater.bumpVersion(releaseType);
33317-
}
33318-
return lastBumpedVersion;
33319-
}
33320-
else {
33321-
const updater = this.updaterRegistry.getUpdater(platform);
33322-
if (!updater) {
33323-
throw new errors_1.VersionBumpError(`No updater found for platform: ${platform}`);
33324-
}
33325-
return updater.bumpVersion(releaseType);
33305+
updateVersion(platform, releaseType) {
33306+
const updater = this.updaterRegistry.getUpdater(platform);
33307+
if (!updater) {
33308+
throw new errors_1.VersionBumpError(`No updater found for platform: ${platform}`);
3332633309
}
33310+
return updater.bumpVersion(releaseType);
3332733311
}
3332833312
}
3332933313
exports.UpdaterService = UpdaterService;
3333033314

3333133315

33332-
/***/ }),
33333-
33334-
/***/ 5432:
33335-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
33336-
33337-
"use strict";
33338-
33339-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
33340-
if (k2 === undefined) k2 = k;
33341-
var desc = Object.getOwnPropertyDescriptor(m, k);
33342-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
33343-
desc = { enumerable: true, get: function() { return m[k]; } };
33344-
}
33345-
Object.defineProperty(o, k2, desc);
33346-
}) : (function(o, m, k, k2) {
33347-
if (k2 === undefined) k2 = k;
33348-
o[k2] = m[k];
33349-
}));
33350-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
33351-
Object.defineProperty(o, "default", { enumerable: true, value: v });
33352-
}) : function(o, v) {
33353-
o["default"] = v;
33354-
});
33355-
var __importStar = (this && this.__importStar) || (function () {
33356-
var ownKeys = function(o) {
33357-
ownKeys = Object.getOwnPropertyNames || function (o) {
33358-
var ar = [];
33359-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33360-
return ar;
33361-
};
33362-
return ownKeys(o);
33363-
};
33364-
return function (mod) {
33365-
if (mod && mod.__esModule) return mod;
33366-
var result = {};
33367-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33368-
__setModuleDefault(result, mod);
33369-
return result;
33370-
};
33371-
})();
33372-
Object.defineProperty(exports, "__esModule", ({ value: true }));
33373-
exports.CustomUpdater = void 0;
33374-
const core = __importStar(__nccwpck_require__(9999));
33375-
const versionUtil_1 = __nccwpck_require__(2431);
33376-
const fileHandler_1 = __nccwpck_require__(1013);
33377-
const manifestParser_1 = __nccwpck_require__(2521);
33378-
class CustomUpdater {
33379-
constructor(filePath, variableName) {
33380-
this.platform = 'custom';
33381-
this.currentVersion = null;
33382-
this.filePath = filePath;
33383-
this.variableName = variableName;
33384-
this.fileHandler = new fileHandler_1.FileHandler();
33385-
this.manifestParser = new manifestParser_1.ManifestParser(this.fileHandler);
33386-
}
33387-
canHandle() {
33388-
// This updater is explicitly called, so it can always handle if constructed.
33389-
return true;
33390-
}
33391-
getCurrentVersion() {
33392-
if (this.currentVersion) {
33393-
return this.currentVersion;
33394-
}
33395-
try {
33396-
// eslint-disable-next-line no-useless-escape
33397-
const regex = new RegExp(`(${this.variableName}\s*=\s*['"]?)([\\d.]+)(['"]?)`);
33398-
this.currentVersion = this.manifestParser.getVersion(this.filePath, 'regex', {
33399-
regex: regex,
33400-
});
33401-
return this.currentVersion;
33402-
}
33403-
catch (error) {
33404-
core.debug(`Could not read or parse version from ${this.filePath}: ${error}`);
33405-
}
33406-
return null;
33407-
}
33408-
bumpVersion(releaseType) {
33409-
const oldVersion = this.getCurrentVersion();
33410-
if (!oldVersion) {
33411-
throw new Error(`Could not find current version for variable '${this.variableName}' in file '${this.filePath}'`);
33412-
}
33413-
const newVersion = (0, versionUtil_1.calculateNextVersion)(oldVersion, releaseType);
33414-
// eslint-disable-next-line no-useless-escape
33415-
const regexReplace = new RegExp(`(${this.variableName}\s*=\s*['"]?)${oldVersion}(['"]?)`);
33416-
this.manifestParser.updateVersion(this.filePath, newVersion, 'regex', {
33417-
regexReplace: regexReplace,
33418-
});
33419-
core.info(`Bumped ${this.variableName} in ${this.filePath} from ${oldVersion} to ${newVersion}`);
33420-
return newVersion;
33421-
}
33422-
}
33423-
exports.CustomUpdater = CustomUpdater;
33424-
33425-
3342633316
/***/ }),
3342733317

3342833318
/***/ 553:

0 commit comments

Comments
 (0)