@capawesome/cli 4.12.0 → 4.13.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [4.13.0](https://github.com/capawesome-team/cli/compare/v4.12.0...v4.13.0) (2026-06-09)
6
+
7
+
8
+ ### Features
9
+
10
+ * **cli:** add `--json` output to create and register commands ([#171](https://github.com/capawesome-team/cli/issues/171)) ([aa84e81](https://github.com/capawesome-team/cli/commit/aa84e81b9dcf564f9196af3c2b2d72ab7ccd755c))
11
+ * **deployments:** include app build data in `list` and `get` JSON output ([#170](https://github.com/capawesome-team/cli/issues/170)) ([d257dd4](https://github.com/capawesome-team/cli/commit/d257dd4bf87260bd703e7d26fb33509ef71227a5))
12
+ * **environments:** include variable and secret keys in get and list output ([#172](https://github.com/capawesome-team/cli/issues/172)) ([b75098b](https://github.com/capawesome-team/cli/commit/b75098b1f206e4896be1c225b0d04551f37cd35b))
13
+ * **liveupdates:** add `--json` output to `upload` and align JSON keys in `create` ([#169](https://github.com/capawesome-team/cli/issues/169)) ([e671294](https://github.com/capawesome-team/cli/commit/e671294770495aab06792cac354663f70c92a7b9))
14
+
5
15
  ## [4.12.0](https://github.com/capawesome-team/cli/compare/v4.11.0...v4.12.0) (2026-06-08)
6
16
 
7
17
 
@@ -15,6 +15,7 @@ export default defineCommand({
15
15
  options: defineOptions(z.object({
16
16
  appId: z.string().optional().describe('ID of the app.'),
17
17
  file: z.string().optional().describe('Path to the certificate file.'),
18
+ json: z.boolean().optional().describe('Output in JSON format.'),
18
19
  keyAlias: z.string().optional().describe('Key alias for the certificate.'),
19
20
  keyPassword: z.string().optional().describe('Key password for the certificate.'),
20
21
  name: z.string().optional().describe('Name of the certificate.'),
@@ -34,7 +35,7 @@ export default defineCommand({
34
35
  yes: z.boolean().optional().describe('Skip confirmation prompts.'),
35
36
  }), { y: 'yes' }),
36
37
  action: withAuth(async (options, args) => {
37
- let { appId, file, keyAlias, keyPassword, name, password, platform, provisioningProfile, type } = options;
38
+ let { appId, file, json, keyAlias, keyPassword, name, password, platform, provisioningProfile, type } = options;
38
39
  // 1. Select organization and app
39
40
  if (!appId) {
40
41
  if (!isInteractive()) {
@@ -183,7 +184,12 @@ export default defineCommand({
183
184
  appCertificateId: certificate.id,
184
185
  });
185
186
  }
186
- consola.info(`Certificate ID: ${certificate.id}`);
187
- consola.success('Certificate created successfully.');
187
+ if (json) {
188
+ console.log(JSON.stringify({ id: certificate.id }, null, 2));
189
+ }
190
+ else {
191
+ consola.info(`Certificate ID: ${certificate.id}`);
192
+ consola.success('Certificate created successfully.');
193
+ }
188
194
  }),
189
195
  });
@@ -20,11 +20,12 @@ export default defineCommand({
20
20
  .optional()
21
21
  .describe('The number of days until the channel is automatically deleted.'),
22
22
  ignoreErrors: z.boolean().optional().describe('Whether to ignore errors or not.'),
23
+ json: z.boolean().optional().describe('Output in JSON format.'),
23
24
  name: z.string().optional().describe('Name of the channel.'),
24
25
  protected: z.boolean().optional().describe('Whether to protect the channel or not. Default is `false`.'),
25
26
  })),
26
27
  action: withAuth(async (options, args) => {
27
- let { appId, expiresInDays, ignoreErrors, name, protected: _protected } = options;
28
+ let { appId, expiresInDays, ignoreErrors, json, name, protected: _protected } = options;
28
29
  if (expiresInDays) {
29
30
  consola.warn('The `--expires-in-days` option is deprecated and will be removed in a future version. Channel expiration is now managed by the data retention policy of your organization billing plan.');
30
31
  }
@@ -51,8 +52,13 @@ export default defineCommand({
51
52
  protected: _protected,
52
53
  name,
53
54
  });
54
- consola.info(`Channel ID: ${response.id}`);
55
- consola.success('Channel created successfully.');
55
+ if (json) {
56
+ console.log(JSON.stringify({ id: response.id }, null, 2));
57
+ }
58
+ else {
59
+ consola.info(`Channel ID: ${response.id}`);
60
+ consola.success('Channel created successfully.');
61
+ }
56
62
  }
57
63
  catch (error) {
58
64
  if (ignoreErrors) {
@@ -54,6 +54,26 @@ describe('apps-channels-create', () => {
54
54
  expect(mockConsola.success).toHaveBeenCalledWith('Channel created successfully.');
55
55
  expect(mockConsola.info).toHaveBeenCalledWith(`Channel ID: ${channelId}`);
56
56
  });
57
+ it('should output JSON when json flag is set', async () => {
58
+ const appId = 'app-123';
59
+ const channelName = 'production';
60
+ const channelId = 'channel-456';
61
+ const testToken = 'test-token';
62
+ const options = { appId, json: true, name: channelName };
63
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
64
+ const scope = nock(DEFAULT_API_BASE_URL)
65
+ .post(`/v1/apps/${appId}/channels`, {
66
+ appId,
67
+ name: channelName,
68
+ protected: undefined,
69
+ })
70
+ .matchHeader('Authorization', `Bearer ${testToken}`)
71
+ .reply(201, { id: channelId, name: channelName });
72
+ await createChannelCommand.action(options, undefined);
73
+ expect(scope.isDone()).toBe(true);
74
+ expect(logSpy).toHaveBeenCalledWith(JSON.stringify({ id: channelId }, null, 2));
75
+ expect(mockConsola.info).not.toHaveBeenCalled();
76
+ });
57
77
  it('should prompt for app when not provided', async () => {
58
78
  const channelName = 'staging';
59
79
  const orgId = 'org-1';
@@ -36,9 +36,10 @@ export default defineCommand({
36
36
  .boolean()
37
37
  .optional()
38
38
  .describe('Request an AI-powered failure summary (Capawesome Cloud Assist) if the deployment fails.'),
39
+ json: z.boolean().optional().describe('Output in JSON format.'),
39
40
  })),
40
41
  action: withAuth(async (options) => {
41
- let { appId, buildId, buildNumber, channel, destination } = options;
42
+ let { appId, buildId, buildNumber, channel, destination, json } = options;
42
43
  // Prompt for app ID if not provided
43
44
  if (!appId) {
44
45
  if (!isInteractive()) {
@@ -172,7 +173,9 @@ export default defineCommand({
172
173
  }),
173
174
  });
174
175
  consola.success('Deployment completed successfully.');
175
- process.exit(0);
176
+ }
177
+ if (json) {
178
+ console.log(JSON.stringify({ id: response.id }, null, 2));
176
179
  }
177
180
  }),
178
181
  });
@@ -23,7 +23,7 @@ export default defineCommand({
23
23
  const deployment = await appDeploymentsService.findOne({
24
24
  appId,
25
25
  appDeploymentId: deploymentId,
26
- relations: json ? 'job' : undefined,
26
+ relations: json ? 'appBuild,job' : undefined,
27
27
  });
28
28
  if (json) {
29
29
  console.log(JSON.stringify(deployment, null, 2));
@@ -33,7 +33,7 @@ export default defineCommand({
33
33
  appDestinationId: destinationId,
34
34
  limit,
35
35
  offset,
36
- relations: json ? 'job' : undefined,
36
+ relations: json ? 'appBuild,job' : undefined,
37
37
  });
38
38
  if (json) {
39
39
  console.log(JSON.stringify(foundDeployments, null, 2));
@@ -15,6 +15,7 @@ export default defineCommand({
15
15
  description: 'Create a new app destination.',
16
16
  options: defineOptions(z.object({
17
17
  appId: z.string().optional().describe('ID of the app.'),
18
+ json: z.boolean().optional().describe('Output in JSON format.'),
18
19
  name: z.string().optional().describe('Name of the destination.'),
19
20
  platform: z.enum(['android', 'ios']).optional().describe('Platform of the destination (android, ios).'),
20
21
  appleId: z.string().optional().describe('Apple ID for the destination.'),
@@ -33,7 +34,7 @@ export default defineCommand({
33
34
  googlePlayTrack: z.string().optional().describe('Google Play track for the destination.'),
34
35
  })),
35
36
  action: withAuth(async (options, args) => {
36
- let { appId, name, platform, appleId, appleAppId, appleTeamId, appleAppPassword, appleApiKeyFile, appleIssuerId, androidPackageName, androidBuildArtifactType, androidReleaseStatus, googleServiceAccountKeyFile, googlePlayTrack, } = options;
37
+ let { appId, json, name, platform, appleId, appleAppId, appleTeamId, appleAppPassword, appleApiKeyFile, appleIssuerId, androidPackageName, androidBuildArtifactType, androidReleaseStatus, googleServiceAccountKeyFile, googlePlayTrack, } = options;
37
38
  let appleApiKeyId;
38
39
  let appAppleApiKeyId;
39
40
  let appGoogleServiceAccountKeyId;
@@ -325,7 +326,12 @@ export default defineCommand({
325
326
  appGoogleServiceAccountKeyId,
326
327
  googlePlayTrack,
327
328
  });
328
- consola.info(`Destination ID: ${response.id}`);
329
- consola.success('Destination created successfully.');
329
+ if (json) {
330
+ console.log(JSON.stringify({ id: response.id }, null, 2));
331
+ }
332
+ else {
333
+ consola.info(`Destination ID: ${response.id}`);
334
+ consola.success('Destination created successfully.');
335
+ }
330
336
  }),
331
337
  });
@@ -9,10 +9,11 @@ export default defineCommand({
9
9
  description: 'Create a new environment.',
10
10
  options: defineOptions(z.object({
11
11
  appId: z.string().optional().describe('ID of the app.'),
12
+ json: z.boolean().optional().describe('Output in JSON format.'),
12
13
  name: z.string().optional().describe('Name of the environment.'),
13
14
  })),
14
15
  action: withAuth(async (options, args) => {
15
- let { appId, name } = options;
16
+ let { appId, json, name } = options;
16
17
  if (!appId) {
17
18
  if (!isInteractive()) {
18
19
  consola.error('You must provide an app ID when running in non-interactive environment.');
@@ -32,7 +33,12 @@ export default defineCommand({
32
33
  appId,
33
34
  name,
34
35
  });
35
- consola.info(`Environment ID: ${response.id}`);
36
- consola.success('Environment created successfully.');
36
+ if (json) {
37
+ console.log(JSON.stringify({ id: response.id }, null, 2));
38
+ }
39
+ else {
40
+ consola.info(`Environment ID: ${response.id}`);
41
+ consola.success('Environment created successfully.');
42
+ }
37
43
  }),
38
44
  });
@@ -39,12 +39,13 @@ export default defineCommand({
39
39
  options: environments.map((env) => ({ label: env.name, value: env.id })),
40
40
  });
41
41
  }
42
+ const relations = 'appEnvironmentVariables,appEnvironmentSecrets';
42
43
  let environment;
43
44
  if (environmentId) {
44
- environment = await appEnvironmentsService.findOneById({ appId, id: environmentId });
45
+ environment = await appEnvironmentsService.findOneById({ appId, id: environmentId, relations });
45
46
  }
46
47
  else if (name) {
47
- const environments = await appEnvironmentsService.findAll({ appId, name });
48
+ const environments = await appEnvironmentsService.findAll({ appId, name, relations });
48
49
  environment = environments[0];
49
50
  }
50
51
  if (!environment) {
@@ -55,7 +56,14 @@ export default defineCommand({
55
56
  console.log(JSON.stringify(environment, null, 2));
56
57
  }
57
58
  else {
58
- console.table(environment);
59
+ const { appEnvironmentVariables, appEnvironmentSecrets, ...rest } = environment;
60
+ console.table(rest);
61
+ if (appEnvironmentVariables?.length) {
62
+ console.table(appEnvironmentVariables.map(({ id, key, value }) => ({ id, key, value })));
63
+ }
64
+ if (appEnvironmentSecrets?.length) {
65
+ console.table(appEnvironmentSecrets.map(({ id, key }) => ({ id, key })));
66
+ }
59
67
  consola.success('Environment retrieved successfully.');
60
68
  }
61
69
  }),
@@ -25,6 +25,7 @@ export default defineCommand({
25
25
  }
26
26
  const environments = await appEnvironmentsService.findAll({
27
27
  appId,
28
+ relations: json ? 'appEnvironmentVariables,appEnvironmentSecrets' : undefined,
28
29
  limit,
29
30
  offset,
30
31
  });
@@ -33,6 +34,7 @@ export default defineCommand({
33
34
  }
34
35
  else {
35
36
  console.table(environments);
37
+ consola.info('Run with --json to include variable keys/values and secret keys.');
36
38
  consola.success('Environments retrieved successfully.');
37
39
  }
38
40
  }),
@@ -273,7 +273,7 @@ export default defineCommand({
273
273
  }
274
274
  // Deploy to channels
275
275
  const rolloutPercentage = (options.rolloutPercentage ?? 100) / 100;
276
- const deploymentIds = [];
276
+ const appDeploymentIds = [];
277
277
  for (const channelName of channel) {
278
278
  consola.start(`Creating deployment for channel "${channelName}"...`);
279
279
  const deployment = await appDeploymentsService.create({
@@ -282,7 +282,7 @@ export default defineCommand({
282
282
  appChannelName: channelName,
283
283
  rolloutPercentage,
284
284
  });
285
- deploymentIds.push(deployment.id);
285
+ appDeploymentIds.push(deployment.id);
286
286
  consola.info(`Deployment ID: ${deployment.id}`);
287
287
  consola.info(`Deployment URL: ${DEFAULT_CONSOLE_BASE_URL}/apps/${appId}/deployments/${deployment.id}`);
288
288
  consola.success('Deployment created successfully.');
@@ -290,9 +290,12 @@ export default defineCommand({
290
290
  // Output JSON if json flag is set
291
291
  if (json) {
292
292
  console.log(JSON.stringify({
293
- buildId: response.id,
294
- buildNumberAsString: response.numberAsString,
295
- deploymentIds,
293
+ appBuildId: response.id,
294
+ appBuildNumberAsString: response.numberAsString,
295
+ appDeploymentIds,
296
+ buildId: response.id, // Deprecated, use appBuildId instead
297
+ buildNumberAsString: response.numberAsString, // Deprecated, use appBuildNumberAsString instead
298
+ deploymentIds: appDeploymentIds, // Deprecated, use appDeploymentIds instead
296
299
  }, null, 2));
297
300
  }
298
301
  }),
@@ -244,6 +244,9 @@ describe('apps-liveupdates-create', () => {
244
244
  .reply(201, { id: deploymentId });
245
245
  await createCommand.action(options, undefined);
246
246
  expect(console.log).toHaveBeenCalledWith(JSON.stringify({
247
+ appBuildId: buildId,
248
+ appBuildNumberAsString: '42',
249
+ appDeploymentIds: [deploymentId],
247
250
  buildId,
248
251
  buildNumberAsString: '42',
249
252
  deploymentIds: [deploymentId],
@@ -81,6 +81,7 @@ export default defineCommand({
81
81
  .string()
82
82
  .optional()
83
83
  .describe('The exact iOS bundle version (`CFBundleVersion`) that the bundle does not support.'),
84
+ json: z.boolean().optional().describe('Output in JSON format.'),
84
85
  path: z.string().optional().describe('Path to zip file for code signing only.'),
85
86
  privateKey: z
86
87
  .string()
@@ -103,7 +104,7 @@ export default defineCommand({
103
104
  yes: z.boolean().optional().describe('Skip confirmation prompts.'),
104
105
  }), { y: 'yes' }),
105
106
  action: withAuth(async (options, args) => {
106
- let { androidEq, androidMax, androidMin, appId, channel, commitMessage, commitRef, commitSha, customProperty, expiresInDays, gitRef, iosEq, iosMax, iosMin, path, privateKey, rolloutPercentage, url, } = options;
107
+ let { androidEq, androidMax, androidMin, appId, channel, commitMessage, commitRef, commitSha, customProperty, expiresInDays, gitRef, iosEq, iosMax, iosMin, json, path, privateKey, rolloutPercentage, url, } = options;
107
108
  if (expiresInDays) {
108
109
  consola.warn('The `--expires-in-days` option is deprecated and will be removed in a future version. Bundle expiration is now managed by the data retention policy of your organization billing plan.');
109
110
  }
@@ -243,5 +244,11 @@ export default defineCommand({
243
244
  consola.info(`Deployment URL: ${DEFAULT_CONSOLE_BASE_URL}/apps/${appId}/deployments/${response.appDeploymentId}`);
244
245
  }
245
246
  consola.success('Live Update successfully registered.');
247
+ if (json) {
248
+ console.log(JSON.stringify({
249
+ appBuildId: response.appBuildId,
250
+ appBuildArtifactId: response.id,
251
+ }, null, 2));
252
+ }
246
253
  }),
247
254
  });
@@ -73,6 +73,34 @@ describe('apps-liveupdates-register', () => {
73
73
  expect(mockConsola.info).toHaveBeenCalledWith(`Bundle Artifact ID: ${bundleId}`);
74
74
  expect(mockConsola.success).toHaveBeenCalledWith('Live Update successfully registered.');
75
75
  });
76
+ it('should output JSON when json flag is set', async () => {
77
+ const appId = 'app-123';
78
+ const bundleUrl = 'https://example.com/bundle.zip';
79
+ const bundleId = 'bundle-456';
80
+ const appBuildId = 'build-789';
81
+ const testToken = 'test-token';
82
+ const options = {
83
+ appId,
84
+ url: bundleUrl,
85
+ rolloutPercentage: 1,
86
+ json: true,
87
+ yes: true,
88
+ };
89
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
90
+ nock(DEFAULT_API_BASE_URL)
91
+ .get(`/v1/apps/${appId}`)
92
+ .matchHeader('Authorization', `Bearer ${testToken}`)
93
+ .reply(200, { id: appId, name: 'Test App' });
94
+ nock(DEFAULT_API_BASE_URL)
95
+ .post(`/v1/apps/${appId}/bundles`)
96
+ .matchHeader('Authorization', `Bearer ${testToken}`)
97
+ .reply(201, { id: bundleId, appBuildId });
98
+ await registerCommand.action(options, undefined);
99
+ expect(logSpy).toHaveBeenCalledWith(JSON.stringify({
100
+ appBuildId,
101
+ appBuildArtifactId: bundleId,
102
+ }, null, 2));
103
+ });
76
104
  it('should pass gitRef to API when provided', async () => {
77
105
  const appId = 'app-123';
78
106
  const bundleUrl = 'https://example.com/bundle.zip';
@@ -92,6 +92,7 @@ export default defineCommand({
92
92
  .string()
93
93
  .optional()
94
94
  .describe('The exact iOS bundle version (`CFBundleVersion`) that the bundle does not support.'),
95
+ json: z.boolean().optional().describe('Output in JSON format.'),
95
96
  path: z
96
97
  .string()
97
98
  .optional()
@@ -116,7 +117,7 @@ export default defineCommand({
116
117
  yes: z.boolean().optional().describe('Skip confirmation prompt.'),
117
118
  }), { y: 'yes' }),
118
119
  action: withAuth(async (options, args) => {
119
- let { androidEq, androidMax, androidMin, appId, artifactType, channel, commitMessage, commitRef, commitSha, customProperty, expiresInDays, gitRef, iosEq, iosMax, iosMin, path, privateKey, rolloutPercentage, } = options;
120
+ let { androidEq, androidMax, androidMin, appId, artifactType, channel, commitMessage, commitRef, commitSha, customProperty, expiresInDays, gitRef, iosEq, iosMax, iosMin, json, path, privateKey, rolloutPercentage, } = options;
120
121
  if (expiresInDays) {
121
122
  consola.warn('The `--expires-in-days` option is deprecated and will be removed in a future version. Bundle expiration is now managed by the data retention policy of your organization billing plan.');
122
123
  }
@@ -289,6 +290,12 @@ export default defineCommand({
289
290
  consola.info(`Deployment URL: ${DEFAULT_CONSOLE_BASE_URL}/apps/${appId}/deployments/${updateBundleResponse.appDeploymentId}`);
290
291
  }
291
292
  consola.success('Live Update successfully uploaded.');
293
+ if (json) {
294
+ console.log(JSON.stringify({
295
+ appBuildId: createBundleResponse.appBuildId,
296
+ appBuildArtifactId: createBundleResponse.id,
297
+ }, null, 2));
298
+ }
292
299
  }),
293
300
  });
294
301
  const uploadFile = async (options) => {
@@ -180,6 +180,53 @@ describe('apps-liveupdates-upload', () => {
180
180
  expect(mockConsola.info).toHaveBeenCalledWith(`Build Artifact ID: ${bundleId}`);
181
181
  expect(mockConsola.success).toHaveBeenCalledWith('Live Update successfully uploaded.');
182
182
  });
183
+ it('should output JSON when json flag is set', async () => {
184
+ const appId = 'app-123';
185
+ const bundlePath = './dist';
186
+ const bundleId = 'bundle-456';
187
+ const appBuildId = 'build-789';
188
+ const testToken = 'test-token';
189
+ const testBuffer = Buffer.from('test');
190
+ const options = {
191
+ appId,
192
+ path: bundlePath,
193
+ artifactType: 'zip',
194
+ rollout: 1,
195
+ json: true,
196
+ };
197
+ mockIsReadable.mockResolvedValue(true);
198
+ mockIsDirectory.mockResolvedValue(true);
199
+ mockGetFilesInDirectoryAndSubdirectories.mockResolvedValue([
200
+ { href: 'index.html', mimeType: 'text/html', name: 'index.html', path: 'index.html' },
201
+ ]);
202
+ const mockZip = await import('../../../utils/zip.js');
203
+ const mockHash = await import('../../../utils/hash.js');
204
+ vi.mocked(mockZip.default.isZipped).mockReturnValue(false);
205
+ vi.mocked(mockZip.default.zipFolder).mockResolvedValue(testBuffer);
206
+ vi.mocked(mockHash.createHash).mockResolvedValue('test-hash');
207
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
208
+ nock(DEFAULT_API_BASE_URL)
209
+ .get(`/v1/apps/${appId}`)
210
+ .matchHeader('Authorization', `Bearer ${testToken}`)
211
+ .reply(200, { id: appId, name: 'Test App' });
212
+ nock(DEFAULT_API_BASE_URL)
213
+ .post(`/v1/apps/${appId}/bundles`)
214
+ .matchHeader('Authorization', `Bearer ${testToken}`)
215
+ .reply(201, { id: bundleId, appBuildId });
216
+ nock(DEFAULT_API_BASE_URL)
217
+ .post(`/v1/apps/${appId}/bundles/${bundleId}/files`)
218
+ .matchHeader('Authorization', `Bearer ${testToken}`)
219
+ .reply(201, { id: 'file-123' });
220
+ nock(DEFAULT_API_BASE_URL)
221
+ .patch(`/v1/apps/${appId}/bundles/${bundleId}`)
222
+ .matchHeader('Authorization', `Bearer ${testToken}`)
223
+ .reply(200, { id: bundleId });
224
+ await uploadCommand.action(options, undefined);
225
+ expect(logSpy).toHaveBeenCalledWith(JSON.stringify({
226
+ appBuildId,
227
+ appBuildArtifactId: bundleId,
228
+ }, null, 2));
229
+ });
183
230
  it('should handle private key file path', async () => {
184
231
  const appId = 'app-123';
185
232
  const bundlePath = './dist';
@@ -8,10 +8,11 @@ import { z } from 'zod';
8
8
  export default defineCommand({
9
9
  description: 'Create a new organization.',
10
10
  options: defineOptions(z.object({
11
+ json: z.boolean().optional().describe('Output in JSON format.'),
11
12
  name: z.string().optional().describe('Name of the organization.'),
12
13
  })),
13
14
  action: withAuth(async (options, args) => {
14
- let { name } = options;
15
+ let { json, name } = options;
15
16
  if (!name) {
16
17
  if (!isInteractive()) {
17
18
  consola.error('You must provide the organization name when running in non-interactive environment.');
@@ -20,7 +21,12 @@ export default defineCommand({
20
21
  name = await prompt('Enter the name of the organization:', { type: 'text' });
21
22
  }
22
23
  const response = await organizationsService.create({ name });
23
- consola.info(`Organization ID: ${response.id}`);
24
- consola.success('Organization created successfully.');
24
+ if (json) {
25
+ console.log(JSON.stringify({ id: response.id }, null, 2));
26
+ }
27
+ else {
28
+ consola.info(`Organization ID: ${response.id}`);
29
+ consola.success('Organization created successfully.');
30
+ }
25
31
  }),
26
32
  });
@@ -46,6 +46,21 @@ describe('organizations-create', () => {
46
46
  expect(mockConsola.success).toHaveBeenCalledWith('Organization created successfully.');
47
47
  expect(mockConsola.info).toHaveBeenCalledWith(`Organization ID: ${organizationId}`);
48
48
  });
49
+ it('should output JSON when json flag is set', async () => {
50
+ const organizationName = 'Test Organization';
51
+ const organizationId = 'org-456';
52
+ const testToken = 'test-token';
53
+ const options = { json: true, name: organizationName };
54
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
55
+ const scope = nock(DEFAULT_API_BASE_URL)
56
+ .post('/v1/organizations', { name: organizationName })
57
+ .matchHeader('Authorization', `Bearer ${testToken}`)
58
+ .reply(201, { id: organizationId, name: organizationName });
59
+ await createOrganizationCommand.action(options, undefined);
60
+ expect(scope.isDone()).toBe(true);
61
+ expect(logSpy).toHaveBeenCalledWith(JSON.stringify({ id: organizationId }, null, 2));
62
+ expect(mockConsola.info).not.toHaveBeenCalled();
63
+ });
49
64
  it('should prompt for organization name when not provided', async () => {
50
65
  const promptedOrganizationName = 'Prompted Organization';
51
66
  const organizationId = 'org-456';
@@ -37,6 +37,9 @@ class AppEnvironmentsServiceImpl {
37
37
  if (dto.name) {
38
38
  queryParams.append('name', dto.name);
39
39
  }
40
+ if (dto.relations) {
41
+ queryParams.append('relations', dto.relations);
42
+ }
40
43
  if (dto.limit) {
41
44
  queryParams.append('limit', dto.limit.toString());
42
45
  }
@@ -59,6 +62,7 @@ class AppEnvironmentsServiceImpl {
59
62
  headers: {
60
63
  Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
61
64
  },
65
+ params: dto.relations ? { relations: dto.relations } : undefined,
62
66
  });
63
67
  return response.data;
64
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/cli",
3
- "version": "4.12.0",
3
+ "version": "4.13.0",
4
4
  "description": "The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.",
5
5
  "type": "module",
6
6
  "scripts": {