@capawesome/cli 2.1.4-dev.6aa4113.1756747591 → 2.1.4-dev.6aa4113.1756747593
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.
- package/dist/commands/mutate/version/get.js +17 -6
- package/dist/commands/mutate/version/hotfix.js +5 -5
- package/dist/commands/mutate/version/set.js +2 -4
- package/dist/commands/mutate/version/sync.js +2 -2
- package/dist/services/mutate/version.js +31 -8
- package/dist/utils/version.js +16 -10
- package/package.json +1 -1
|
@@ -12,23 +12,34 @@ export default defineCommand({
|
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
14
|
const firstVersion = versions[0].version;
|
|
15
|
-
|
|
15
|
+
// Check major.minor.patch synchronization for all platforms
|
|
16
|
+
const allVersionsInSync = versions.every((pv) => {
|
|
16
17
|
return (pv.version.major === firstVersion.major &&
|
|
17
18
|
pv.version.minor === firstVersion.minor &&
|
|
18
|
-
pv.version.patch === firstVersion.patch
|
|
19
|
-
pv.version.hotfix === firstVersion.hotfix);
|
|
19
|
+
pv.version.patch === firstVersion.patch);
|
|
20
20
|
});
|
|
21
|
-
|
|
21
|
+
// Check hotfix synchronization between iOS and Android
|
|
22
|
+
const iosVersion = versions.find((pv) => pv.platform === 'ios');
|
|
23
|
+
const androidVersion = versions.find((pv) => pv.platform === 'android');
|
|
24
|
+
let hotfixInSync = true;
|
|
25
|
+
if (iosVersion && androidVersion) {
|
|
26
|
+
const iosHotfix = iosVersion.version.hotfix || 0;
|
|
27
|
+
const androidHotfix = androidVersion.version.hotfix || 0;
|
|
28
|
+
hotfixInSync = iosHotfix === androidHotfix;
|
|
29
|
+
}
|
|
30
|
+
if (!allVersionsInSync || !hotfixInSync) {
|
|
22
31
|
consola.error('Versions are not synchronized across platforms:');
|
|
23
32
|
versions.forEach((pv) => {
|
|
24
33
|
const versionStr = versionToString(pv.version);
|
|
25
|
-
const hotfixStr = pv.version.hotfix
|
|
34
|
+
const hotfixStr = pv.platform !== 'web' && pv.version.hotfix ? ` (hotfix: ${pv.version.hotfix})` : '';
|
|
26
35
|
consola.log(` ${pv.platform}: ${versionStr}${hotfixStr} (${pv.source})`);
|
|
27
36
|
});
|
|
28
37
|
process.exit(1);
|
|
29
38
|
}
|
|
30
39
|
const versionStr = versionToString(firstVersion);
|
|
31
|
-
|
|
40
|
+
// Show hotfix if iOS or Android has one
|
|
41
|
+
const platformWithHotfix = versions.find((pv) => pv.platform !== 'web' && pv.version.hotfix && pv.version.hotfix > 0);
|
|
42
|
+
const hotfixStr = platformWithHotfix ? ` (hotfix: ${platformWithHotfix.version.hotfix})` : '';
|
|
32
43
|
consola.success(`Version: ${versionStr}${hotfixStr}`);
|
|
33
44
|
versions.forEach((pv) => {
|
|
34
45
|
consola.log(` ${pv.platform}: ${pv.source}`);
|
|
@@ -8,12 +8,12 @@ export default defineCommand({
|
|
|
8
8
|
try {
|
|
9
9
|
const currentVersion = await versionService.ensureVersionsInSync();
|
|
10
10
|
const newVersion = incrementHotfix(currentVersion);
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
consola.info(`Incrementing hotfix version
|
|
11
|
+
const versionStr = versionToString(currentVersion);
|
|
12
|
+
const currentHotfix = currentVersion.hotfix || 0;
|
|
13
|
+
const newHotfix = newVersion.hotfix || 0;
|
|
14
|
+
consola.info(`Incrementing hotfix for version ${versionStr} (${currentHotfix} -> ${newHotfix})...`);
|
|
15
15
|
await versionService.setVersion(newVersion);
|
|
16
|
-
consola.success(`Hotfix
|
|
16
|
+
consola.success(`Hotfix incremented for version ${versionStr} (now ${newHotfix})`);
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
19
|
consola.error(error instanceof Error ? error.message : String(error));
|
|
@@ -5,12 +5,10 @@ import consola from 'consola';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
export default defineCommand({
|
|
7
7
|
description: 'Set the version of the app in all relevant files',
|
|
8
|
-
args: z.
|
|
9
|
-
version: z.string(),
|
|
10
|
-
}),
|
|
8
|
+
args: z.tuple([z.string().describe('Version')]),
|
|
11
9
|
action: async (_options, args) => {
|
|
12
10
|
try {
|
|
13
|
-
const version = parseVersion(args
|
|
11
|
+
const version = parseVersion(args[0]);
|
|
14
12
|
consola.info(`Setting version to ${versionToString(version)}...`);
|
|
15
13
|
await versionService.setVersion(version);
|
|
16
14
|
consola.success(`Version set to ${versionToString(version)}`);
|
|
@@ -15,11 +15,11 @@ export default defineCommand({
|
|
|
15
15
|
consola.info('Current versions:');
|
|
16
16
|
versions.forEach((pv) => {
|
|
17
17
|
const versionStr = versionToString(pv.version);
|
|
18
|
-
const hotfixStr = pv.version.hotfix
|
|
18
|
+
const hotfixStr = pv.platform !== 'web' && pv.version.hotfix ? ` (hotfix: ${pv.version.hotfix})` : '';
|
|
19
19
|
consola.log(` ${pv.platform}: ${versionStr}${hotfixStr}`);
|
|
20
20
|
});
|
|
21
21
|
const highestVersionStr = versionToString(highestVersion);
|
|
22
|
-
const hotfixStr = highestVersion.hotfix
|
|
22
|
+
const hotfixStr = highestVersion.hotfix ? ` (hotfix: ${highestVersion.hotfix})` : '';
|
|
23
23
|
consola.info(`Syncing all platforms to highest version: ${highestVersionStr}${hotfixStr}...`);
|
|
24
24
|
await versionService.setVersion(highestVersion);
|
|
25
25
|
consola.success(`All platforms synced to version ${highestVersionStr}${hotfixStr}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { compareVersions, parseBuildNumber, parseVersion, versionToBuildNumber, versionToString, } from '../../utils/version.js';
|
|
1
2
|
import { MobileProject } from '@trapezedev/project';
|
|
2
3
|
import { existsSync, readFileSync } from 'fs';
|
|
3
4
|
import { join } from 'path';
|
|
4
|
-
import { compareVersions, parseBuildNumber, parseVersion, versionToBuildNumber, versionToString, versionsEqual, } from '../../utils/version.js';
|
|
5
5
|
export class VersionService {
|
|
6
6
|
projectPath;
|
|
7
7
|
constructor(projectPath = process.cwd()) {
|
|
@@ -38,7 +38,7 @@ export class VersionService {
|
|
|
38
38
|
if (!project.ios) {
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
|
-
const iosProject =
|
|
41
|
+
const iosProject = project.ios.getPbxProject();
|
|
42
42
|
if (!iosProject) {
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
@@ -97,6 +97,7 @@ export class VersionService {
|
|
|
97
97
|
if (!packageJson.version) {
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
|
+
// Web only has version string, no build number (hotfix will always be 0)
|
|
100
101
|
const version = parseVersion(packageJson.version);
|
|
101
102
|
return {
|
|
102
103
|
platform: 'web',
|
|
@@ -148,6 +149,7 @@ export class VersionService {
|
|
|
148
149
|
if (existsSync(packageJsonPath)) {
|
|
149
150
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
150
151
|
packageJson.version = versionString;
|
|
152
|
+
// Web only stores version string, not build number
|
|
151
153
|
const fs = await import('fs/promises');
|
|
152
154
|
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
153
155
|
}
|
|
@@ -155,16 +157,37 @@ export class VersionService {
|
|
|
155
157
|
}
|
|
156
158
|
async ensureVersionsInSync() {
|
|
157
159
|
const versions = await this.getAllVersions();
|
|
158
|
-
|
|
160
|
+
const firstVersion = versions && versions[0] ? versions[0].version : null;
|
|
161
|
+
if (!firstVersion) {
|
|
159
162
|
throw new Error('No platform versions found');
|
|
160
163
|
}
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
// Check major.minor.patch synchronization for all platforms
|
|
165
|
+
const allVersionsInSync = versions.every((pv) => pv.version.major === firstVersion.major &&
|
|
166
|
+
pv.version.minor === firstVersion.minor &&
|
|
167
|
+
pv.version.patch === firstVersion.patch);
|
|
168
|
+
if (!allVersionsInSync) {
|
|
169
|
+
const versionStrings = versions.map((pv) => {
|
|
170
|
+
const versionStr = versionToString(pv.version);
|
|
171
|
+
const hotfixStr = pv.platform !== 'web' && pv.version.hotfix ? ` (hotfix: ${pv.version.hotfix})` : '';
|
|
172
|
+
return `${pv.platform}: ${versionStr}${hotfixStr} (${pv.source})`;
|
|
173
|
+
});
|
|
165
174
|
throw new Error(`Versions are not synchronized across platforms:\n${versionStrings.join('\n')}`);
|
|
166
175
|
}
|
|
167
|
-
|
|
176
|
+
// Check hotfix synchronization between iOS and Android only
|
|
177
|
+
const iosVersion = versions.find((pv) => pv.platform === 'ios');
|
|
178
|
+
const androidVersion = versions.find((pv) => pv.platform === 'android');
|
|
179
|
+
if (iosVersion && androidVersion) {
|
|
180
|
+
const iosHotfix = iosVersion.version.hotfix || 0;
|
|
181
|
+
const androidHotfix = androidVersion.version.hotfix || 0;
|
|
182
|
+
if (iosHotfix !== androidHotfix) {
|
|
183
|
+
throw new Error(`Hotfix versions are not synchronized between iOS and Android:\n` +
|
|
184
|
+
`iOS: ${versionToString(iosVersion.version)} (hotfix: ${iosHotfix})\n` +
|
|
185
|
+
`Android: ${versionToString(androidVersion.version)} (hotfix: ${androidHotfix})`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Return version with hotfix from iOS or Android if available
|
|
189
|
+
const versionWithHotfix = versions.find((pv) => pv.platform !== 'web' && pv.version.hotfix && pv.version.hotfix > 0);
|
|
190
|
+
return versionWithHotfix ? versionWithHotfix.version : firstVersion;
|
|
168
191
|
}
|
|
169
192
|
async getHighestVersion() {
|
|
170
193
|
const versions = await this.getAllVersions();
|
package/dist/utils/version.js
CHANGED
|
@@ -12,7 +12,7 @@ export const parseVersion = (versionString) => {
|
|
|
12
12
|
if (major < 0 || minor < 0 || patch < 0) {
|
|
13
13
|
throw new Error(`Invalid version format: ${versionString}. Version parts must be non-negative.`);
|
|
14
14
|
}
|
|
15
|
-
return { major, minor, patch
|
|
15
|
+
return { major, minor, patch };
|
|
16
16
|
};
|
|
17
17
|
export const parseBuildNumber = (buildNumber) => {
|
|
18
18
|
const buildStr = buildNumber.toString();
|
|
@@ -37,38 +37,39 @@ export const versionToBuildNumber = (version) => {
|
|
|
37
37
|
const majorStr = version.major.toString();
|
|
38
38
|
const minor = version.minor.toString().padStart(3, '0');
|
|
39
39
|
const patch = version.patch.toString().padStart(2, '0');
|
|
40
|
-
const hotfix = version.hotfix.toString().padStart(2, '0');
|
|
40
|
+
const hotfix = (version.hotfix || 0).toString().padStart(2, '0');
|
|
41
41
|
if (version.minor > 999) {
|
|
42
42
|
throw new Error(`Minor version ${version.minor} exceeds maximum value of 999`);
|
|
43
43
|
}
|
|
44
44
|
if (version.patch > 99) {
|
|
45
45
|
throw new Error(`Patch version ${version.patch} exceeds maximum value of 99`);
|
|
46
46
|
}
|
|
47
|
-
if (version.hotfix > 99) {
|
|
47
|
+
if (version.hotfix && version.hotfix > 99) {
|
|
48
48
|
throw new Error(`Hotfix version ${version.hotfix} exceeds maximum value of 99`);
|
|
49
49
|
}
|
|
50
50
|
return parseInt(`${majorStr}${minor}${patch}${hotfix}`, 10);
|
|
51
51
|
};
|
|
52
52
|
export const incrementMajor = (version) => {
|
|
53
53
|
const newMajor = version.major + 1;
|
|
54
|
-
return { major: newMajor, minor: 0, patch: 0
|
|
54
|
+
return { major: newMajor, minor: 0, patch: 0 };
|
|
55
55
|
};
|
|
56
56
|
export const incrementMinor = (version) => {
|
|
57
57
|
const newMinor = version.minor + 1;
|
|
58
58
|
if (newMinor > 999) {
|
|
59
59
|
throw new Error(`Cannot increment minor version: would exceed maximum value of 999`);
|
|
60
60
|
}
|
|
61
|
-
return {
|
|
61
|
+
return { major: version.major, minor: newMinor, patch: 0 };
|
|
62
62
|
};
|
|
63
63
|
export const incrementPatch = (version) => {
|
|
64
64
|
const newPatch = version.patch + 1;
|
|
65
65
|
if (newPatch > 99) {
|
|
66
66
|
throw new Error(`Cannot increment patch version: would exceed maximum value of 99`);
|
|
67
67
|
}
|
|
68
|
-
return {
|
|
68
|
+
return { major: version.major, minor: version.minor, patch: newPatch };
|
|
69
69
|
};
|
|
70
70
|
export const incrementHotfix = (version) => {
|
|
71
|
-
const
|
|
71
|
+
const currentHotfix = version.hotfix || 0;
|
|
72
|
+
const newHotfix = currentHotfix + 1;
|
|
72
73
|
if (newHotfix > 99) {
|
|
73
74
|
throw new Error(`Cannot increment hotfix version: would exceed maximum value of 99`);
|
|
74
75
|
}
|
|
@@ -81,10 +82,15 @@ export const compareVersions = (v1, v2) => {
|
|
|
81
82
|
return v1.minor - v2.minor;
|
|
82
83
|
if (v1.patch !== v2.patch)
|
|
83
84
|
return v1.patch - v2.patch;
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
const h1 = v1.hotfix || 0;
|
|
86
|
+
const h2 = v2.hotfix || 0;
|
|
87
|
+
if (h1 !== h2)
|
|
88
|
+
return h1 - h2;
|
|
86
89
|
return 0;
|
|
87
90
|
};
|
|
88
|
-
export const versionsEqual = (v1, v2) => {
|
|
91
|
+
export const versionsEqual = (v1, v2, ignoreHotfix = false) => {
|
|
92
|
+
if (ignoreHotfix) {
|
|
93
|
+
return v1.major === v2.major && v1.minor === v2.minor && v1.patch === v2.patch;
|
|
94
|
+
}
|
|
89
95
|
return compareVersions(v1, v2) === 0;
|
|
90
96
|
};
|
package/package.json
CHANGED