@capawesome/cli 4.1.0-dev.f5ef8ba.1771047437 → 4.2.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/commands/apps/builds/cancel.js +6 -41
  3. package/dist/commands/apps/builds/create.js +10 -55
  4. package/dist/commands/apps/builds/download.js +6 -41
  5. package/dist/commands/apps/builds/logs.js +6 -41
  6. package/dist/commands/apps/channels/create.js +6 -36
  7. package/dist/commands/apps/channels/create.test.js +5 -15
  8. package/dist/commands/apps/channels/delete.js +6 -36
  9. package/dist/commands/apps/channels/delete.test.js +6 -18
  10. package/dist/commands/apps/channels/get.js +3 -7
  11. package/dist/commands/apps/channels/list.js +6 -36
  12. package/dist/commands/apps/channels/list.test.js +4 -1
  13. package/dist/commands/apps/channels/pause.js +6 -40
  14. package/dist/commands/apps/channels/resume.js +6 -40
  15. package/dist/commands/apps/channels/update.js +6 -36
  16. package/dist/commands/apps/channels/update.test.js +14 -31
  17. package/dist/commands/apps/create.js +5 -23
  18. package/dist/commands/apps/create.test.js +13 -31
  19. package/dist/commands/apps/delete.js +6 -35
  20. package/dist/commands/apps/delete.test.js +11 -35
  21. package/dist/commands/apps/deployments/cancel.js +6 -41
  22. package/dist/commands/apps/deployments/create.js +6 -41
  23. package/dist/commands/apps/deployments/logs.js +6 -41
  24. package/dist/commands/apps/devices/delete.js +6 -36
  25. package/dist/commands/apps/devices/delete.test.js +14 -36
  26. package/dist/commands/apps/environments/create.js +6 -36
  27. package/dist/commands/apps/environments/delete.js +6 -36
  28. package/dist/commands/apps/environments/list.js +6 -36
  29. package/dist/commands/apps/environments/set.js +6 -36
  30. package/dist/commands/apps/environments/unset.js +6 -36
  31. package/dist/commands/apps/liveupdates/register.js +6 -40
  32. package/dist/commands/apps/liveupdates/register.test.js +2 -1
  33. package/dist/commands/apps/liveupdates/rollback.js +6 -41
  34. package/dist/commands/apps/liveupdates/rollout.js +6 -41
  35. package/dist/commands/apps/liveupdates/set-native-versions.js +3 -7
  36. package/dist/commands/apps/liveupdates/upload.js +6 -40
  37. package/dist/commands/apps/liveupdates/upload.test.js +2 -1
  38. package/dist/commands/organizations/create.js +3 -7
  39. package/dist/commands/organizations/create.test.js +3 -1
  40. package/dist/utils/auth.js +27 -0
  41. package/dist/utils/prompt.js +56 -11
  42. package/dist/utils/signature.js +2 -1
  43. package/package.json +6 -2
@@ -1,4 +1,3 @@
1
- import { password as clackPassword } from '@clack/prompts';
2
1
  import consola from 'consola';
3
2
  export const prompt = async (message, options) => {
4
3
  options = { ...(options || {}), cancel: 'symbol' };
@@ -9,15 +8,61 @@ export const prompt = async (message, options) => {
9
8
  }
10
9
  return response;
11
10
  };
12
- /**
13
- * This is a workaround to support password prompts.
14
- *
15
- * @see https://github.com/unjs/consola/issues/285
16
- */
17
- export const passwordPrompt = async (message) => {
18
- const result = await clackPassword({ message });
19
- if (typeof result === 'symbol') {
20
- process.exit(0);
11
+ export const promptOrganizationSelection = async (options) => {
12
+ const organizationsService = await import('../services/organizations.js').then((mod) => mod.default);
13
+ let organizations = await organizationsService.findAll();
14
+ if (organizations.length === 0) {
15
+ if (options?.allowCreate) {
16
+ const shouldCreate = await prompt('No organizations found. Do you want to create one now?', {
17
+ type: 'confirm',
18
+ initial: true,
19
+ });
20
+ if (shouldCreate) {
21
+ await (await import('../commands/organizations/create.js').then((mod) => mod.default)).action({}, undefined);
22
+ organizations = await organizationsService.findAll();
23
+ }
24
+ else {
25
+ process.exit(1);
26
+ }
27
+ }
28
+ else {
29
+ consola.error('No organizations found. Please create one first.');
30
+ process.exit(1);
31
+ }
32
+ }
33
+ // @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
34
+ const organizationId = await prompt('Which organization do you want to use?', {
35
+ type: 'select',
36
+ options: organizations.map((organization) => ({ label: organization.name, value: organization.id })),
37
+ });
38
+ return organizationId;
39
+ };
40
+ export const promptAppSelection = async (organizationId, options) => {
41
+ const appsService = await import('../services/apps.js').then((mod) => mod.default);
42
+ let apps = await appsService.findAll({ organizationId });
43
+ if (apps.length === 0) {
44
+ if (options?.allowCreate) {
45
+ const shouldCreate = await prompt('No apps found. Do you want to create one now?', {
46
+ type: 'confirm',
47
+ initial: true,
48
+ });
49
+ if (shouldCreate) {
50
+ await (await import('../commands/apps/create.js').then((mod) => mod.default)).action({ organizationId }, undefined);
51
+ apps = await appsService.findAll({ organizationId });
52
+ }
53
+ else {
54
+ process.exit(1);
55
+ }
56
+ }
57
+ else {
58
+ consola.error('No apps found. Please create one first.');
59
+ process.exit(1);
60
+ }
21
61
  }
22
- return result;
62
+ // @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
63
+ const appId = await prompt('Which app do you want to use?', {
64
+ type: 'select',
65
+ options: apps.map((app) => ({ label: app.name, value: app.id })),
66
+ });
67
+ return appId;
23
68
  };
@@ -1,7 +1,8 @@
1
1
  export const createSignature = async (privateKey, data) => {
2
2
  const crypto = await import('crypto');
3
+ const privateKeyObject = crypto.createPrivateKey(privateKey);
3
4
  const sign = crypto.createSign('sha256');
4
5
  sign.update(data);
5
6
  sign.end();
6
- return sign.sign(privateKey).toString('base64');
7
+ return sign.sign(privateKeyObject).toString('base64');
7
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/cli",
3
- "version": "4.1.0-dev.f5ef8ba.1771047437",
3
+ "version": "4.2.0",
4
4
  "description": "The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -51,6 +51,10 @@
51
51
  "url": "https://opencollective.com/capawesome"
52
52
  }
53
53
  ],
54
+ "overrides": {
55
+ "glob": "13.0.6",
56
+ "minimatch": "10.2.2"
57
+ },
54
58
  "dependencies": {
55
59
  "@clack/prompts": "0.7.0",
56
60
  "@robingenz/zli": "0.2.0",
@@ -67,7 +71,7 @@
67
71
  "open": "10.2.0",
68
72
  "rc9": "2.1.2",
69
73
  "semver": "7.6.3",
70
- "systeminformation": "5.28.5",
74
+ "systeminformation": "5.31.1",
71
75
  "zod": "4.0.17"
72
76
  },
73
77
  "devDependencies": {