@capawesome/cli 1.14.0 → 2.0.1
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 +34 -0
- package/README.md +7 -3
- package/dist/commands/apps/bundles/create.js +206 -239
- package/dist/commands/apps/bundles/create.test.js +276 -0
- package/dist/commands/apps/bundles/delete.js +35 -60
- package/dist/commands/apps/bundles/delete.test.js +139 -0
- package/dist/commands/apps/bundles/update.js +61 -89
- package/dist/commands/apps/bundles/update.test.js +141 -0
- package/dist/commands/apps/channels/create.js +45 -75
- package/dist/commands/apps/channels/create.test.js +119 -0
- package/dist/commands/apps/channels/delete.js +46 -69
- package/dist/commands/apps/channels/delete.test.js +141 -0
- package/dist/commands/apps/channels/get.js +52 -94
- package/dist/commands/apps/channels/get.test.js +135 -0
- package/dist/commands/apps/channels/list.js +37 -82
- package/dist/commands/apps/channels/list.test.js +121 -0
- package/dist/commands/apps/channels/update.js +39 -83
- package/dist/commands/apps/channels/update.test.js +138 -0
- package/dist/commands/apps/create.js +28 -53
- package/dist/commands/apps/create.test.js +117 -0
- package/dist/commands/apps/delete.js +29 -50
- package/dist/commands/apps/delete.test.js +120 -0
- package/dist/commands/apps/devices/delete.js +35 -60
- package/dist/commands/apps/devices/delete.test.js +139 -0
- package/dist/commands/doctor.js +12 -29
- package/dist/commands/doctor.test.js +52 -0
- package/dist/commands/login.js +50 -71
- package/dist/commands/login.test.js +116 -0
- package/dist/commands/logout.js +13 -31
- package/dist/commands/logout.test.js +47 -0
- package/dist/commands/manifests/generate.js +20 -38
- package/dist/commands/manifests/generate.test.js +60 -0
- package/dist/commands/organizations/create.js +25 -0
- package/dist/commands/organizations/create.test.js +80 -0
- package/dist/commands/whoami.js +20 -31
- package/dist/commands/whoami.test.js +30 -0
- package/dist/config/consts.js +4 -5
- package/dist/config/index.js +1 -17
- package/dist/index.js +59 -80
- package/dist/services/app-bundle-files.js +117 -136
- package/dist/services/app-bundles.js +22 -41
- package/dist/services/app-channels.js +54 -77
- package/dist/services/app-devices.js +10 -25
- package/dist/services/apps.js +25 -43
- package/dist/services/authorization-service.js +4 -8
- package/dist/services/config.js +15 -28
- package/dist/services/organizations.js +19 -26
- package/dist/services/session-code.js +7 -22
- package/dist/services/sessions.js +13 -30
- package/dist/services/update.js +17 -55
- package/dist/services/users.js +11 -26
- package/dist/types/app-bundle-file.js +1 -2
- package/dist/types/app-bundle.js +1 -2
- package/dist/types/app-channel.js +1 -2
- package/dist/types/app-device.js +1 -2
- package/dist/types/app.js +1 -2
- package/dist/types/index.js +8 -24
- package/dist/types/npm-package.js +1 -2
- package/dist/types/organization.js +1 -2
- package/dist/types/session-code.js +1 -2
- package/dist/types/session.js +1 -2
- package/dist/types/user.js +1 -2
- package/dist/utils/buffer.js +12 -43
- package/dist/utils/error.js +24 -14
- package/dist/utils/file.js +22 -41
- package/dist/utils/hash.js +3 -39
- package/dist/utils/http-client.js +27 -53
- package/dist/utils/manifest.js +11 -24
- package/dist/utils/private-key.js +23 -0
- package/dist/utils/prompt.js +9 -26
- package/dist/utils/signature.js +3 -39
- package/dist/utils/user-config.js +12 -0
- package/dist/utils/zip.js +11 -27
- package/package.json +22 -9
- package/dist/utils/ci.js +0 -7
- package/dist/utils/userConfig.js +0 -16
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import authorizationService from '../../services/authorization-service.js';
|
|
2
|
+
import organizationsService from '../../services/organizations.js';
|
|
3
|
+
import { prompt } from '../../utils/prompt.js';
|
|
4
|
+
import { defineCommand, defineOptions } from '@robingenz/zli';
|
|
5
|
+
import consola from 'consola';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export default defineCommand({
|
|
8
|
+
description: 'Create a new organization.',
|
|
9
|
+
options: defineOptions(z.object({
|
|
10
|
+
name: z.string().optional().describe('Name of the organization.'),
|
|
11
|
+
})),
|
|
12
|
+
action: async (options, args) => {
|
|
13
|
+
let { name } = options;
|
|
14
|
+
if (!authorizationService.hasAuthorizationToken()) {
|
|
15
|
+
consola.error('You must be logged in to run this command.');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
if (!name) {
|
|
19
|
+
name = await prompt('Enter the name of the organization:', { type: 'text' });
|
|
20
|
+
}
|
|
21
|
+
const response = await organizationsService.create({ name });
|
|
22
|
+
consola.success('Organization created successfully.');
|
|
23
|
+
consola.info(`Organization ID: ${response.id}`);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { DEFAULT_API_BASE_URL } from '../../config/consts.js';
|
|
2
|
+
import authorizationService from '../../services/authorization-service.js';
|
|
3
|
+
import { prompt } from '../../utils/prompt.js';
|
|
4
|
+
import userConfig from '../../utils/user-config.js';
|
|
5
|
+
import consola from 'consola';
|
|
6
|
+
import nock from 'nock';
|
|
7
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
8
|
+
import createOrganizationCommand from './create.js';
|
|
9
|
+
// Mock dependencies
|
|
10
|
+
vi.mock('@/utils/user-config.js');
|
|
11
|
+
vi.mock('@/utils/prompt.js');
|
|
12
|
+
vi.mock('@/services/authorization-service.js');
|
|
13
|
+
vi.mock('consola');
|
|
14
|
+
describe('organizations-create', () => {
|
|
15
|
+
const mockUserConfig = vi.mocked(userConfig);
|
|
16
|
+
const mockPrompt = vi.mocked(prompt);
|
|
17
|
+
const mockConsola = vi.mocked(consola);
|
|
18
|
+
const mockAuthorizationService = vi.mocked(authorizationService);
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.clearAllMocks();
|
|
21
|
+
mockUserConfig.read.mockReturnValue({ token: 'test-token' });
|
|
22
|
+
mockAuthorizationService.getCurrentAuthorizationToken.mockReturnValue('test-token');
|
|
23
|
+
mockAuthorizationService.hasAuthorizationToken.mockReturnValue(true);
|
|
24
|
+
vi.spyOn(process, 'exit').mockImplementation((code) => {
|
|
25
|
+
throw new Error(`Process exited with code ${code}`);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
nock.cleanAll();
|
|
30
|
+
vi.restoreAllMocks();
|
|
31
|
+
});
|
|
32
|
+
it('should create organization with provided name', async () => {
|
|
33
|
+
const organizationName = 'Test Organization';
|
|
34
|
+
const organizationId = 'org-456';
|
|
35
|
+
const testToken = 'test-token';
|
|
36
|
+
const options = { name: organizationName };
|
|
37
|
+
const scope = nock(DEFAULT_API_BASE_URL)
|
|
38
|
+
.post('/v1/organizations', { name: organizationName })
|
|
39
|
+
.matchHeader('Authorization', `Bearer ${testToken}`)
|
|
40
|
+
.reply(201, { id: organizationId, name: organizationName });
|
|
41
|
+
await createOrganizationCommand.action(options, undefined);
|
|
42
|
+
expect(scope.isDone()).toBe(true);
|
|
43
|
+
expect(mockConsola.success).toHaveBeenCalledWith('Organization created successfully.');
|
|
44
|
+
expect(mockConsola.info).toHaveBeenCalledWith(`Organization ID: ${organizationId}`);
|
|
45
|
+
});
|
|
46
|
+
it('should prompt for organization name when not provided', async () => {
|
|
47
|
+
const promptedOrganizationName = 'Prompted Organization';
|
|
48
|
+
const organizationId = 'org-456';
|
|
49
|
+
const testToken = 'test-token';
|
|
50
|
+
const options = {};
|
|
51
|
+
const scope = nock(DEFAULT_API_BASE_URL)
|
|
52
|
+
.post('/v1/organizations', { name: promptedOrganizationName })
|
|
53
|
+
.matchHeader('Authorization', `Bearer ${testToken}`)
|
|
54
|
+
.reply(201, { id: organizationId, name: promptedOrganizationName });
|
|
55
|
+
mockPrompt.mockResolvedValueOnce(promptedOrganizationName);
|
|
56
|
+
await createOrganizationCommand.action(options, undefined);
|
|
57
|
+
expect(scope.isDone()).toBe(true);
|
|
58
|
+
expect(mockPrompt).toHaveBeenCalledWith('Enter the name of the organization:', { type: 'text' });
|
|
59
|
+
expect(mockConsola.success).toHaveBeenCalledWith('Organization created successfully.');
|
|
60
|
+
expect(mockConsola.info).toHaveBeenCalledWith(`Organization ID: ${organizationId}`);
|
|
61
|
+
});
|
|
62
|
+
it('should exit when not logged in', async () => {
|
|
63
|
+
const organizationName = 'Test Organization';
|
|
64
|
+
const options = { name: organizationName };
|
|
65
|
+
mockAuthorizationService.hasAuthorizationToken.mockReturnValue(false);
|
|
66
|
+
await expect(createOrganizationCommand.action(options, undefined)).rejects.toThrow('Process exited with code 1');
|
|
67
|
+
expect(mockConsola.error).toHaveBeenCalledWith('You must be logged in to run this command.');
|
|
68
|
+
});
|
|
69
|
+
it('should handle API error during creation', async () => {
|
|
70
|
+
const organizationName = 'Test Organization';
|
|
71
|
+
const testToken = 'test-token';
|
|
72
|
+
const options = { name: organizationName };
|
|
73
|
+
const scope = nock(DEFAULT_API_BASE_URL)
|
|
74
|
+
.post('/v1/organizations', { name: organizationName })
|
|
75
|
+
.matchHeader('Authorization', `Bearer ${testToken}`)
|
|
76
|
+
.reply(400, { message: 'Organization name already exists' });
|
|
77
|
+
await expect(createOrganizationCommand.action(options, undefined)).rejects.toThrow();
|
|
78
|
+
expect(scope.isDone()).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
});
|
package/dist/commands/whoami.js
CHANGED
|
@@ -1,41 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const citty_1 = require("citty");
|
|
16
|
-
const consola_1 = __importDefault(require("consola"));
|
|
17
|
-
const users_1 = __importDefault(require("../services/users"));
|
|
18
|
-
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
19
|
-
exports.default = (0, citty_1.defineCommand)({
|
|
20
|
-
meta: {
|
|
21
|
-
name: 'whoami',
|
|
22
|
-
description: 'Show current user',
|
|
23
|
-
},
|
|
24
|
-
run: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
const { token } = userConfig_1.default.read();
|
|
1
|
+
import usersService from '../services/users.js';
|
|
2
|
+
import userConfig from '../utils/user-config.js';
|
|
3
|
+
import { defineCommand } from '@robingenz/zli';
|
|
4
|
+
import { AxiosError } from 'axios';
|
|
5
|
+
import consola from 'consola';
|
|
6
|
+
export default defineCommand({
|
|
7
|
+
description: 'Show current user',
|
|
8
|
+
action: async (options, args) => {
|
|
9
|
+
const { token } = userConfig.read();
|
|
26
10
|
if (token) {
|
|
27
11
|
try {
|
|
28
|
-
const user =
|
|
29
|
-
|
|
12
|
+
const user = await usersService.me();
|
|
13
|
+
consola.info(`Logged in as ${user.email}.`);
|
|
30
14
|
}
|
|
31
15
|
catch (error) {
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
if (error instanceof AxiosError && error.response?.status === 401) {
|
|
17
|
+
consola.error('Token is invalid. Please sign in again.');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
34
23
|
}
|
|
35
24
|
}
|
|
36
25
|
else {
|
|
37
|
-
|
|
26
|
+
consola.error('Not logged in.');
|
|
38
27
|
process.exit(1);
|
|
39
28
|
}
|
|
40
|
-
}
|
|
29
|
+
},
|
|
41
30
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DEFAULT_API_BASE_URL } from '../config/consts.js';
|
|
2
|
+
import userConfig from '../utils/user-config.js';
|
|
3
|
+
import nock from 'nock';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import whoamiCommand from './whoami.js';
|
|
6
|
+
// Mock only the dependencies we need to control
|
|
7
|
+
vi.mock('@/utils/user-config.js');
|
|
8
|
+
describe('whoami', () => {
|
|
9
|
+
const mockUserConfig = vi.mocked(userConfig);
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
vi.clearAllMocks();
|
|
12
|
+
vi.spyOn(process, 'exit').mockImplementation(() => undefined);
|
|
13
|
+
});
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
nock.cleanAll();
|
|
16
|
+
vi.restoreAllMocks();
|
|
17
|
+
});
|
|
18
|
+
it('should send Bearer token in Authorization header when checking current user', async () => {
|
|
19
|
+
const testToken = 'user-token-456';
|
|
20
|
+
// Mock userConfig.read to return our test token
|
|
21
|
+
mockUserConfig.read.mockReturnValue({ token: testToken });
|
|
22
|
+
// Set up nock to intercept the /v1/users/me request
|
|
23
|
+
const scope = nock(DEFAULT_API_BASE_URL)
|
|
24
|
+
.get('/v1/users/me')
|
|
25
|
+
.matchHeader('Authorization', `Bearer ${testToken}`)
|
|
26
|
+
.reply(200, { id: 'user-456', email: 'user@example.com' });
|
|
27
|
+
await whoamiCommand.action({}, undefined);
|
|
28
|
+
expect(scope.isDone()).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
});
|
package/dist/config/consts.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.MAX_CONCURRENT_UPLOADS = 20;
|
|
1
|
+
export const DEFAULT_API_BASE_URL = 'https://api.cloud.capawesome.io';
|
|
2
|
+
export const DEFAULT_CONSOLE_BASE_URL = 'https://console.cloud.capawesome.io';
|
|
3
|
+
export const MANIFEST_JSON_FILE_NAME = 'capawesome-live-update-manifest.json'; // Do NOT change this!
|
|
4
|
+
export const MAX_CONCURRENT_UPLOADS = 20;
|
package/dist/config/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./consts"), exports);
|
|
1
|
+
export * from './consts.js';
|
package/dist/index.js
CHANGED
|
@@ -1,81 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const Sentry = __importStar(require("@sentry/node"));
|
|
40
|
-
const citty_1 = require("citty");
|
|
41
|
-
const consola_1 = __importDefault(require("consola"));
|
|
42
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
43
|
-
const config_1 = __importDefault(require("./services/config"));
|
|
44
|
-
const update_1 = __importDefault(require("./services/update"));
|
|
45
|
-
const error_1 = require("./utils/error");
|
|
46
|
-
const main = (0, citty_1.defineCommand)({
|
|
2
|
+
import configService from './services/config.js';
|
|
3
|
+
import updateService from './services/update.js';
|
|
4
|
+
import { getMessageFromUnknownError } from './utils/error.js';
|
|
5
|
+
import { defineConfig, processConfig, ZliError } from '@robingenz/zli';
|
|
6
|
+
import * as Sentry from '@sentry/node';
|
|
7
|
+
import consola from 'consola';
|
|
8
|
+
import pkg from '../package.json' with { type: 'json' };
|
|
9
|
+
const config = defineConfig({
|
|
47
10
|
meta: {
|
|
48
|
-
name:
|
|
49
|
-
version:
|
|
50
|
-
description:
|
|
51
|
-
},
|
|
52
|
-
setup() {
|
|
53
|
-
// No op
|
|
11
|
+
name: pkg.name,
|
|
12
|
+
version: pkg.version,
|
|
13
|
+
description: pkg.description,
|
|
54
14
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
'apps:
|
|
64
|
-
'apps:
|
|
65
|
-
'apps:
|
|
66
|
-
'apps:
|
|
67
|
-
'apps:
|
|
68
|
-
'apps:channels:
|
|
69
|
-
'apps:channels:
|
|
70
|
-
'apps:
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'apps:devices:delete': Promise.resolve().then(() => __importStar(require('./commands/apps/devices/delete'))).then((mod) => mod.default),
|
|
74
|
-
'manifests:generate': Promise.resolve().then(() => __importStar(require('./commands/manifests/generate'))).then((mod) => mod.default),
|
|
15
|
+
commands: {
|
|
16
|
+
whoami: await import('./commands/whoami.js').then((mod) => mod.default),
|
|
17
|
+
login: await import('./commands/login.js').then((mod) => mod.default),
|
|
18
|
+
logout: await import('./commands/logout.js').then((mod) => mod.default),
|
|
19
|
+
doctor: await import('./commands/doctor.js').then((mod) => mod.default),
|
|
20
|
+
'apps:create': await import('./commands/apps/create.js').then((mod) => mod.default),
|
|
21
|
+
'apps:delete': await import('./commands/apps/delete.js').then((mod) => mod.default),
|
|
22
|
+
'apps:bundles:create': await import('./commands/apps/bundles/create.js').then((mod) => mod.default),
|
|
23
|
+
'apps:bundles:delete': await import('./commands/apps/bundles/delete.js').then((mod) => mod.default),
|
|
24
|
+
'apps:bundles:update': await import('./commands/apps/bundles/update.js').then((mod) => mod.default),
|
|
25
|
+
'apps:channels:create': await import('./commands/apps/channels/create.js').then((mod) => mod.default),
|
|
26
|
+
'apps:channels:delete': await import('./commands/apps/channels/delete.js').then((mod) => mod.default),
|
|
27
|
+
'apps:channels:get': await import('./commands/apps/channels/get.js').then((mod) => mod.default),
|
|
28
|
+
'apps:channels:list': await import('./commands/apps/channels/list.js').then((mod) => mod.default),
|
|
29
|
+
'apps:channels:update': await import('./commands/apps/channels/update.js').then((mod) => mod.default),
|
|
30
|
+
'apps:devices:delete': await import('./commands/apps/devices/delete.js').then((mod) => mod.default),
|
|
31
|
+
'manifests:generate': await import('./commands/manifests/generate.js').then((mod) => mod.default),
|
|
32
|
+
'organizations:create': await import('./commands/organizations/create.js').then((mod) => mod.default),
|
|
75
33
|
},
|
|
76
34
|
});
|
|
77
|
-
const captureException = (error) =>
|
|
78
|
-
|
|
35
|
+
const captureException = async (error) => {
|
|
36
|
+
// Check if the error is from the CLI itself
|
|
37
|
+
if (error instanceof ZliError) {
|
|
38
|
+
// Ignore CLI errors like "No command found."
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const environment = await configService.getValueForKey('ENVIRONMENT');
|
|
79
42
|
if (environment !== 'production') {
|
|
80
43
|
return;
|
|
81
44
|
}
|
|
@@ -83,19 +46,35 @@ const captureException = (error) => __awaiter(void 0, void 0, void 0, function*
|
|
|
83
46
|
dsn: 'https://19f30f2ec4b91899abc33818568ceb42@o4507446340747264.ingest.de.sentry.io/4508506426966096',
|
|
84
47
|
});
|
|
85
48
|
Sentry.captureException(error);
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
49
|
+
await Sentry.close();
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
if (!process.argv.includes('@capawesome/cli')) {
|
|
53
|
+
consola.warn('The `capawesome` command is deprecated. Please use `@capawesome/cli` instead.');
|
|
54
|
+
}
|
|
55
|
+
const result = processConfig(config, process.argv.slice(2));
|
|
56
|
+
await result.command.action(result.options, result.args);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
89
59
|
try {
|
|
90
|
-
|
|
60
|
+
await captureException(error).catch(() => {
|
|
91
61
|
// No op
|
|
92
62
|
});
|
|
93
63
|
// Print the error message
|
|
94
|
-
const message =
|
|
95
|
-
|
|
64
|
+
const message = getMessageFromUnknownError(error);
|
|
65
|
+
consola.error(message);
|
|
96
66
|
}
|
|
97
67
|
finally {
|
|
68
|
+
// Suggest opening an issue
|
|
69
|
+
consola.log('If you think this is a bug, please open an issue at:');
|
|
70
|
+
consola.log(' https://github.com/capawesome-team/cli/issues/new/choose');
|
|
71
|
+
// Check for updates
|
|
72
|
+
await updateService.checkForUpdate();
|
|
98
73
|
// Exit with a non-zero code
|
|
99
74
|
process.exit(1);
|
|
100
75
|
}
|
|
101
|
-
}
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
// Check for updates
|
|
79
|
+
await updateService.checkForUpdate();
|
|
80
|
+
}
|