Skip to content

Commit 8a68ccf

Browse files
committed
feat: Centralize action configuration in a dedicated module
Introduces a new src/config/index.ts module to centralize the retrieval of GitHub Action inputs. This refactoring separates configuration logic from the main application flow in src/index.ts, improving modularity and maintainability. The action inputs elease_type, arget_platform, and git_tag are now read within src/config/index.ts and exported as constants (RELEASE_TYPE, TARGET_PLATFORM, GIT_TAG). Additionally, this commit includes formatting and minor refactoring changes in various updater and service files, which were likely auto-applied by linting/formatting tools.
1 parent 9972df0 commit 8a68ccf

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/config/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import * as core from '@actions/core';
2+
import semver from 'semver';
3+
4+
export const RELEASE_TYPE = (core.getInput('release_type') || 'patch') as semver.ReleaseType;
5+
export const TARGET_PLATFORM = core.getInput('target_platform');
6+
export const GIT_TAG = core.getInput('git_tag') === 'true';

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as core from '@actions/core';
2-
import semver from 'semver';
31
import { UpdaterService, GitService } from './services';
42
import {
53
DockerUpdater,
@@ -10,11 +8,13 @@ import {
108
RustUpdater,
119
} from './updaters';
1210
import { PlatformDetectionError, VersionBumpError } from './errors';
11+
import { RELEASE_TYPE, TARGET_PLATFORM, GIT_TAG } from './config';
12+
import * as core from '@actions/core';
1313

1414
async function run() {
1515
try {
16-
const releaseType = (core.getInput('release_type') || 'patch') as semver.ReleaseType;
17-
const targetPlatform = core.getInput('target_platform');
16+
const releaseType = RELEASE_TYPE;
17+
const targetPlatform = TARGET_PLATFORM;
1818

1919
const updaters = [
2020
new NodeUpdater(),
@@ -34,7 +34,7 @@ async function run() {
3434
core.setOutput('new_version', version);
3535

3636
// Git Commit & Tag
37-
const gitTag = core.getInput('git_tag') === 'true';
37+
const gitTag = GIT_TAG;
3838
await gitService.configureGitUser();
3939
await gitService.commitChanges(`chore: bump version to ${version}`);
4040
if (gitTag) {

src/services/updaterService.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ export class UpdaterService {
1313
if (targetPlatform) {
1414
const updater = this.updaters.find((u) => u.platform === targetPlatform);
1515
if (!updater) {
16-
throw new PlatformDetectionError(`Specified platform "${targetPlatform}" is not supported.`);
16+
throw new PlatformDetectionError(
17+
`Specified platform "${targetPlatform}" is not supported.`,
18+
);
1719
}
1820
return updater.platform;
1921
}
2022

2123
const detectedUpdater = this.updaters.find((u) => u.canHandle());
2224
if (!detectedUpdater) {
23-
throw new PlatformDetectionError('Could not detect platform. Please specify target_platform input if auto-detection fails.');
25+
throw new PlatformDetectionError(
26+
'Could not detect platform. Please specify target_platform input if auto-detection fails.',
27+
);
2428
}
2529
return detectedUpdater.platform;
2630
}

0 commit comments

Comments
 (0)