@capawesome/cli 2.1.4-dev.6aa4113.1756747591 → 2.1.4

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/index.js CHANGED
@@ -33,13 +33,6 @@ const config = defineConfig({
33
33
  'apps:channels:update': await import('./commands/apps/channels/update.js').then((mod) => mod.default),
34
34
  'apps:devices:delete': await import('./commands/apps/devices/delete.js').then((mod) => mod.default),
35
35
  'manifests:generate': await import('./commands/manifests/generate.js').then((mod) => mod.default),
36
- 'mutate:version:get': await import('./commands/mutate/version/get.js').then((mod) => mod.default),
37
- 'mutate:version:set': await import('./commands/mutate/version/set.js').then((mod) => mod.default),
38
- 'mutate:version:major': await import('./commands/mutate/version/major.js').then((mod) => mod.default),
39
- 'mutate:version:minor': await import('./commands/mutate/version/minor.js').then((mod) => mod.default),
40
- 'mutate:version:patch': await import('./commands/mutate/version/patch.js').then((mod) => mod.default),
41
- 'mutate:version:hotfix': await import('./commands/mutate/version/hotfix.js').then((mod) => mod.default),
42
- 'mutate:version:sync': await import('./commands/mutate/version/sync.js').then((mod) => mod.default),
43
36
  'organizations:create': await import('./commands/organizations/create.js').then((mod) => mod.default),
44
37
  },
45
38
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/cli",
3
- "version": "2.1.4-dev.6aa4113.1756747591",
3
+ "version": "2.1.4",
4
4
  "description": "The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -55,7 +55,6 @@
55
55
  "@clack/prompts": "0.7.0",
56
56
  "@robingenz/zli": "0.1.5",
57
57
  "@sentry/node": "8.55.0",
58
- "@trapezedev/project": "7.1.3",
59
58
  "archiver": "7.0.1",
60
59
  "axios": "1.8.4",
61
60
  "axios-retry": "4.5.0",
@@ -1,42 +0,0 @@
1
- import versionService from '../../../services/mutate/version.js';
2
- import { versionToString } from '../../../utils/version.js';
3
- import { defineCommand } from '@robingenz/zli';
4
- import consola from 'consola';
5
- export default defineCommand({
6
- description: 'Get the version of the app from all relevant files',
7
- action: async () => {
8
- try {
9
- const versions = await versionService.getAllVersions();
10
- if (versions.length === 0) {
11
- consola.error('No platform versions found');
12
- process.exit(1);
13
- }
14
- const firstVersion = versions[0].version;
15
- const allInSync = versions.every((pv) => {
16
- return (pv.version.major === firstVersion.major &&
17
- pv.version.minor === firstVersion.minor &&
18
- pv.version.patch === firstVersion.patch &&
19
- pv.version.hotfix === firstVersion.hotfix);
20
- });
21
- if (!allInSync) {
22
- consola.error('Versions are not synchronized across platforms:');
23
- versions.forEach((pv) => {
24
- const versionStr = versionToString(pv.version);
25
- const hotfixStr = pv.version.hotfix > 0 ? ` (hotfix: ${pv.version.hotfix})` : '';
26
- consola.log(` ${pv.platform}: ${versionStr}${hotfixStr} (${pv.source})`);
27
- });
28
- process.exit(1);
29
- }
30
- const versionStr = versionToString(firstVersion);
31
- const hotfixStr = firstVersion.hotfix > 0 ? ` (hotfix: ${firstVersion.hotfix})` : '';
32
- consola.success(`Version: ${versionStr}${hotfixStr}`);
33
- versions.forEach((pv) => {
34
- consola.log(` ${pv.platform}: ${pv.source}`);
35
- });
36
- }
37
- catch (error) {
38
- consola.error(error instanceof Error ? error.message : String(error));
39
- process.exit(1);
40
- }
41
- },
42
- });
@@ -1,23 +0,0 @@
1
- import versionService from '../../../services/mutate/version.js';
2
- import { incrementHotfix, versionToString } from '../../../utils/version.js';
3
- import { defineCommand } from '@robingenz/zli';
4
- import consola from 'consola';
5
- export default defineCommand({
6
- description: 'Increment the hotfix version of the app in all relevant files',
7
- action: async () => {
8
- try {
9
- const currentVersion = await versionService.ensureVersionsInSync();
10
- const newVersion = incrementHotfix(currentVersion);
11
- const currentVersionStr = versionToString(currentVersion);
12
- const newVersionStr = versionToString(newVersion);
13
- const hotfixInfo = `(hotfix: ${currentVersion.hotfix} -> ${newVersion.hotfix})`;
14
- consola.info(`Incrementing hotfix version from ${currentVersionStr} to ${newVersionStr} ${hotfixInfo}...`);
15
- await versionService.setVersion(newVersion);
16
- consola.success(`Hotfix version incremented to ${newVersionStr} (hotfix: ${newVersion.hotfix})`);
17
- }
18
- catch (error) {
19
- consola.error(error instanceof Error ? error.message : String(error));
20
- process.exit(1);
21
- }
22
- },
23
- });
@@ -1,20 +0,0 @@
1
- import versionService from '../../../services/mutate/version.js';
2
- import { incrementMajor, versionToString } from '../../../utils/version.js';
3
- import { defineCommand } from '@robingenz/zli';
4
- import consola from 'consola';
5
- export default defineCommand({
6
- description: 'Increment the major version of the app in all relevant files',
7
- action: async () => {
8
- try {
9
- const currentVersion = await versionService.ensureVersionsInSync();
10
- const newVersion = incrementMajor(currentVersion);
11
- consola.info(`Incrementing major version from ${versionToString(currentVersion)} to ${versionToString(newVersion)}...`);
12
- await versionService.setVersion(newVersion);
13
- consola.success(`Major version incremented to ${versionToString(newVersion)}`);
14
- }
15
- catch (error) {
16
- consola.error(error instanceof Error ? error.message : String(error));
17
- process.exit(1);
18
- }
19
- },
20
- });
@@ -1,20 +0,0 @@
1
- import versionService from '../../../services/mutate/version.js';
2
- import { incrementMinor, versionToString } from '../../../utils/version.js';
3
- import { defineCommand } from '@robingenz/zli';
4
- import consola from 'consola';
5
- export default defineCommand({
6
- description: 'Increment the minor version of the app in all relevant files',
7
- action: async () => {
8
- try {
9
- const currentVersion = await versionService.ensureVersionsInSync();
10
- const newVersion = incrementMinor(currentVersion);
11
- consola.info(`Incrementing minor version from ${versionToString(currentVersion)} to ${versionToString(newVersion)}...`);
12
- await versionService.setVersion(newVersion);
13
- consola.success(`Minor version incremented to ${versionToString(newVersion)}`);
14
- }
15
- catch (error) {
16
- consola.error(error instanceof Error ? error.message : String(error));
17
- process.exit(1);
18
- }
19
- },
20
- });
@@ -1,20 +0,0 @@
1
- import versionService from '../../../services/mutate/version.js';
2
- import { incrementPatch, versionToString } from '../../../utils/version.js';
3
- import { defineCommand } from '@robingenz/zli';
4
- import consola from 'consola';
5
- export default defineCommand({
6
- description: 'Increment the patch version of the app in all relevant files',
7
- action: async () => {
8
- try {
9
- const currentVersion = await versionService.ensureVersionsInSync();
10
- const newVersion = incrementPatch(currentVersion);
11
- consola.info(`Incrementing patch version from ${versionToString(currentVersion)} to ${versionToString(newVersion)}...`);
12
- await versionService.setVersion(newVersion);
13
- consola.success(`Patch version incremented to ${versionToString(newVersion)}`);
14
- }
15
- catch (error) {
16
- consola.error(error instanceof Error ? error.message : String(error));
17
- process.exit(1);
18
- }
19
- },
20
- });
@@ -1,23 +0,0 @@
1
- import versionService from '../../../services/mutate/version.js';
2
- import { parseVersion, versionToString } from '../../../utils/version.js';
3
- import { defineCommand } from '@robingenz/zli';
4
- import consola from 'consola';
5
- import { z } from 'zod';
6
- export default defineCommand({
7
- description: 'Set the version of the app in all relevant files',
8
- args: z.object({
9
- version: z.string(),
10
- }),
11
- action: async (_options, args) => {
12
- try {
13
- const version = parseVersion(args.version);
14
- consola.info(`Setting version to ${versionToString(version)}...`);
15
- await versionService.setVersion(version);
16
- consola.success(`Version set to ${versionToString(version)}`);
17
- }
18
- catch (error) {
19
- consola.error(error instanceof Error ? error.message : String(error));
20
- process.exit(1);
21
- }
22
- },
23
- });
@@ -1,32 +0,0 @@
1
- import versionService from '../../../services/mutate/version.js';
2
- import { versionToString } from '../../../utils/version.js';
3
- import { defineCommand } from '@robingenz/zli';
4
- import consola from 'consola';
5
- export default defineCommand({
6
- description: 'Set the highest version number among all platforms in all relevant files',
7
- action: async () => {
8
- try {
9
- const versions = await versionService.getAllVersions();
10
- if (versions.length === 0) {
11
- consola.error('No platform versions found');
12
- process.exit(1);
13
- }
14
- const highestVersion = await versionService.getHighestVersion();
15
- consola.info('Current versions:');
16
- versions.forEach((pv) => {
17
- const versionStr = versionToString(pv.version);
18
- const hotfixStr = pv.version.hotfix > 0 ? ` (hotfix: ${pv.version.hotfix})` : '';
19
- consola.log(` ${pv.platform}: ${versionStr}${hotfixStr}`);
20
- });
21
- const highestVersionStr = versionToString(highestVersion);
22
- const hotfixStr = highestVersion.hotfix > 0 ? ` (hotfix: ${highestVersion.hotfix})` : '';
23
- consola.info(`Syncing all platforms to highest version: ${highestVersionStr}${hotfixStr}...`);
24
- await versionService.setVersion(highestVersion);
25
- consola.success(`All platforms synced to version ${highestVersionStr}${hotfixStr}`);
26
- }
27
- catch (error) {
28
- consola.error(error instanceof Error ? error.message : String(error));
29
- process.exit(1);
30
- }
31
- },
32
- });
@@ -1,183 +0,0 @@
1
- import { MobileProject } from '@trapezedev/project';
2
- import { existsSync, readFileSync } from 'fs';
3
- import { join } from 'path';
4
- import { compareVersions, parseBuildNumber, parseVersion, versionToBuildNumber, versionToString, versionsEqual, } from '../../utils/version.js';
5
- export class VersionService {
6
- projectPath;
7
- constructor(projectPath = process.cwd()) {
8
- this.projectPath = projectPath;
9
- }
10
- async getAllVersions() {
11
- const versions = [];
12
- const iosVersion = await this.getIosVersion();
13
- if (iosVersion) {
14
- versions.push(iosVersion);
15
- }
16
- const androidVersion = await this.getAndroidVersion();
17
- if (androidVersion) {
18
- versions.push(androidVersion);
19
- }
20
- const webVersion = await this.getWebVersion();
21
- if (webVersion) {
22
- versions.push(webVersion);
23
- }
24
- return versions;
25
- }
26
- async getIosVersion() {
27
- const iosPath = join(this.projectPath, 'ios');
28
- if (!existsSync(iosPath)) {
29
- return null;
30
- }
31
- try {
32
- const project = new MobileProject(this.projectPath, {
33
- ios: {
34
- path: 'ios/App',
35
- },
36
- });
37
- await project.load();
38
- if (!project.ios) {
39
- return null;
40
- }
41
- const iosProject = await project.ios.getPbxProject();
42
- if (!iosProject) {
43
- return null;
44
- }
45
- const buildNumber = await project.ios.getBuild(null, null);
46
- if (!buildNumber) {
47
- return null;
48
- }
49
- const version = parseBuildNumber(buildNumber);
50
- return {
51
- platform: 'ios',
52
- version,
53
- source: 'ios/App/App.xcodeproj/project.pbxproj',
54
- };
55
- }
56
- catch (error) {
57
- return null;
58
- }
59
- }
60
- async getAndroidVersion() {
61
- const androidPath = join(this.projectPath, 'android');
62
- if (!existsSync(androidPath)) {
63
- return null;
64
- }
65
- try {
66
- const project = new MobileProject(this.projectPath, {
67
- android: {
68
- path: 'android',
69
- },
70
- });
71
- await project.load();
72
- if (!project.android) {
73
- return null;
74
- }
75
- const versionCode = await project.android.getVersionCode();
76
- if (!versionCode) {
77
- return null;
78
- }
79
- const version = parseBuildNumber(versionCode);
80
- return {
81
- platform: 'android',
82
- version,
83
- source: 'android/app/build.gradle',
84
- };
85
- }
86
- catch (error) {
87
- return null;
88
- }
89
- }
90
- async getWebVersion() {
91
- const packageJsonPath = join(this.projectPath, 'package.json');
92
- if (!existsSync(packageJsonPath)) {
93
- return null;
94
- }
95
- try {
96
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
97
- if (!packageJson.version) {
98
- return null;
99
- }
100
- const version = parseVersion(packageJson.version);
101
- return {
102
- platform: 'web',
103
- version,
104
- source: 'package.json',
105
- };
106
- }
107
- catch (error) {
108
- return null;
109
- }
110
- }
111
- async setVersion(version) {
112
- const iosPath = join(this.projectPath, 'ios');
113
- const androidPath = join(this.projectPath, 'android');
114
- const packageJsonPath = join(this.projectPath, 'package.json');
115
- const project = new MobileProject(this.projectPath, {
116
- ios: existsSync(iosPath)
117
- ? {
118
- path: 'ios/App',
119
- }
120
- : undefined,
121
- android: existsSync(androidPath)
122
- ? {
123
- path: 'android',
124
- }
125
- : undefined,
126
- });
127
- await project.load();
128
- const versionString = versionToString(version);
129
- const buildNumber = versionToBuildNumber(version);
130
- if (project.ios) {
131
- await project.ios.setVersion(null, null, versionString);
132
- await project.ios.setBuild(null, null, buildNumber.toString());
133
- const infoPlistPath = await project.ios.getInfoPlist(null, null);
134
- if (infoPlistPath) {
135
- const infoPlist = await project.ios.getPlistFile(infoPlistPath);
136
- if (infoPlist) {
137
- await infoPlist.set({
138
- CFBundleShortVersionString: versionString,
139
- CFBundleVersion: buildNumber.toString(),
140
- });
141
- }
142
- }
143
- }
144
- if (project.android) {
145
- await project.android.setVersionName(versionString);
146
- await project.android.setVersionCode(buildNumber);
147
- }
148
- if (existsSync(packageJsonPath)) {
149
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
150
- packageJson.version = versionString;
151
- const fs = await import('fs/promises');
152
- await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
153
- }
154
- await project.commit();
155
- }
156
- async ensureVersionsInSync() {
157
- const versions = await this.getAllVersions();
158
- if (versions.length === 0) {
159
- throw new Error('No platform versions found');
160
- }
161
- const firstVersion = versions[0].version;
162
- const allInSync = versions.every((pv) => versionsEqual(pv.version, firstVersion));
163
- if (!allInSync) {
164
- const versionStrings = versions.map((pv) => `${pv.platform}: ${versionToString(pv.version)} (${pv.source})`);
165
- throw new Error(`Versions are not synchronized across platforms:\n${versionStrings.join('\n')}`);
166
- }
167
- return firstVersion;
168
- }
169
- async getHighestVersion() {
170
- const versions = await this.getAllVersions();
171
- if (versions.length === 0) {
172
- throw new Error('No platform versions found');
173
- }
174
- let highest = versions[0];
175
- for (const current of versions) {
176
- if (compareVersions(current.version, highest.version) > 0) {
177
- highest = current;
178
- }
179
- }
180
- return highest.version;
181
- }
182
- }
183
- export default new VersionService();
@@ -1,90 +0,0 @@
1
- export const parseVersion = (versionString) => {
2
- const parts = versionString.split('.');
3
- if (parts.length !== 3) {
4
- throw new Error(`Invalid version format: ${versionString}. Expected format: major.minor.patch`);
5
- }
6
- const major = parseInt(parts[0] || '0', 10);
7
- const minor = parseInt(parts[1] || '0', 10);
8
- const patch = parseInt(parts[2] || '0', 10);
9
- if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
10
- throw new Error(`Invalid version format: ${versionString}. Version parts must be numbers.`);
11
- }
12
- if (major < 0 || minor < 0 || patch < 0) {
13
- throw new Error(`Invalid version format: ${versionString}. Version parts must be non-negative.`);
14
- }
15
- return { major, minor, patch, hotfix: 0 };
16
- };
17
- export const parseBuildNumber = (buildNumber) => {
18
- const buildStr = buildNumber.toString();
19
- // Build number format: [major][minor:3][patch:2][hotfix:2]
20
- // The last 7 digits are always minor(3) + patch(2) + hotfix(2)
21
- if (buildStr.length < 8) {
22
- throw new Error(`Invalid build number: ${buildNumber}. Build number must be at least 8 digits.`);
23
- }
24
- const fixedPartStart = buildStr.length - 7;
25
- const major = parseInt(buildStr.substring(0, fixedPartStart), 10);
26
- const minor = parseInt(buildStr.substring(fixedPartStart, fixedPartStart + 3), 10);
27
- const patch = parseInt(buildStr.substring(fixedPartStart + 3, fixedPartStart + 5), 10);
28
- const hotfix = parseInt(buildStr.substring(fixedPartStart + 5, fixedPartStart + 7), 10);
29
- return { major, minor, patch, hotfix };
30
- };
31
- export const versionToString = (version) => {
32
- return `${version.major}.${version.minor}.${version.patch}`;
33
- };
34
- export const versionToBuildNumber = (version) => {
35
- // Build number format: [major][minor:3][patch:2][hotfix:2]
36
- // Major version has no limit and uses as many digits as needed
37
- const majorStr = version.major.toString();
38
- const minor = version.minor.toString().padStart(3, '0');
39
- const patch = version.patch.toString().padStart(2, '0');
40
- const hotfix = version.hotfix.toString().padStart(2, '0');
41
- if (version.minor > 999) {
42
- throw new Error(`Minor version ${version.minor} exceeds maximum value of 999`);
43
- }
44
- if (version.patch > 99) {
45
- throw new Error(`Patch version ${version.patch} exceeds maximum value of 99`);
46
- }
47
- if (version.hotfix > 99) {
48
- throw new Error(`Hotfix version ${version.hotfix} exceeds maximum value of 99`);
49
- }
50
- return parseInt(`${majorStr}${minor}${patch}${hotfix}`, 10);
51
- };
52
- export const incrementMajor = (version) => {
53
- const newMajor = version.major + 1;
54
- return { major: newMajor, minor: 0, patch: 0, hotfix: 0 };
55
- };
56
- export const incrementMinor = (version) => {
57
- const newMinor = version.minor + 1;
58
- if (newMinor > 999) {
59
- throw new Error(`Cannot increment minor version: would exceed maximum value of 999`);
60
- }
61
- return { ...version, minor: newMinor, patch: 0, hotfix: 0 };
62
- };
63
- export const incrementPatch = (version) => {
64
- const newPatch = version.patch + 1;
65
- if (newPatch > 99) {
66
- throw new Error(`Cannot increment patch version: would exceed maximum value of 99`);
67
- }
68
- return { ...version, patch: newPatch, hotfix: 0 };
69
- };
70
- export const incrementHotfix = (version) => {
71
- const newHotfix = version.hotfix + 1;
72
- if (newHotfix > 99) {
73
- throw new Error(`Cannot increment hotfix version: would exceed maximum value of 99`);
74
- }
75
- return { ...version, hotfix: newHotfix };
76
- };
77
- export const compareVersions = (v1, v2) => {
78
- if (v1.major !== v2.major)
79
- return v1.major - v2.major;
80
- if (v1.minor !== v2.minor)
81
- return v1.minor - v2.minor;
82
- if (v1.patch !== v2.patch)
83
- return v1.patch - v2.patch;
84
- if (v1.hotfix !== v2.hotfix)
85
- return v1.hotfix - v2.hotfix;
86
- return 0;
87
- };
88
- export const versionsEqual = (v1, v2) => {
89
- return compareVersions(v1, v2) === 0;
90
- };