Skip to content

Commit b8b5ed3

Browse files
committed
fix: clean prerelease suffixes before semver padding in parseVersion to match deployments (e.g. 2.10.2-dev-01 -> 2.10.2)
1 parent ca29c2a commit b8b5ed3

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

README.ko.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Microsoft 공식 CodePush 서비스는 아시아 지역에서 속도가 느린
1212
- Node.js v24.6.0
1313
- npm install -g install @shm-open/code-push-cli
1414
- data, storage 이름으로 디렉토리 생성후 서버 구동
15+
- 앱테스터 semver 포맷 지원을 위해 parseVersion 유틸함수 일부 수정 → cleanVersion 선행
16+
> e.g., '2.10.2-stg-01' → '2.10.2'
1517
1618
## 이 포크(Fork)에 대하여
1719

src/core/services/client-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ class ClientManager {
193193
if (_.isEmpty(dep)) {
194194
throw new AppError('Not found deployment, check deployment key is right.');
195195
}
196+
logger.info('updateCheck.beforeParseVersion', { version: appVersion });
196197
const version = parseVersion(appVersion);
197-
logger.info('updateCheck.parsedVersion', { version });
198+
logger.info('updateCheck.afterParseVersion', { version });
198199
return DeploymentsVersions.findAll({
199200
where: {
200201
deployment_id: dep.id,

src/core/utils/common.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,26 @@ import { config } from '../config';
1313

1414
const streamPipeline = util.promisify(pipeline);
1515

16+
function cleanVersion(versionNo?: string) {
17+
if (typeof versionNo !== 'string') {
18+
return versionNo as any;
19+
}
20+
// 2.10.2-dev-01 -> 2.10.2
21+
return versionNo.replace(/-.*$/, '');
22+
}
23+
24+
/**
25+
* SEMVER 스트링을 마이너와 패치 부분 자리수가 늘어난 스트링으로 변환
26+
* - 다수의 패치 횟수 보장을 위한 작업
27+
*/
1628
export function parseVersion(versionNo: string) {
1729
let version = '0';
1830
let data = null;
19-
if ((data = versionNo.match(/^([0-9]{1,3}).([0-9]{1,5}).([0-9]{1,10})$/))) {
31+
const normalized = cleanVersion(versionNo);
32+
if ((data = normalized.match(/^([0-9]{1,3}).([0-9]{1,5}).([0-9]{1,10})$/))) {
2033
// "1.2.3"
2134
version = data[1] + _.padStart(data[2], 5, '0') + _.padStart(data[3], 10, '0');
22-
} else if ((data = versionNo.match(/^([0-9]{1,3}).([0-9]{1,5})$/))) {
35+
} else if ((data = normalized.match(/^([0-9]{1,3}).([0-9]{1,5})$/))) {
2336
// "1.2"
2437
version = data[1] + _.padStart(data[2], 5, '0') + _.padStart('0', 10, '0');
2538
}

0 commit comments

Comments
 (0)