@capawesome/cli 0.0.2 → 0.0.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/CHANGELOG.md +15 -0
- package/dist/commands/apps/bundles/create.js +17 -10
- package/dist/commands/apps/bundles/delete.js +2 -2
- package/dist/commands/apps/channels/create.js +4 -3
- package/dist/commands/apps/channels/delete.js +2 -2
- package/dist/commands/apps/create.js +1 -1
- package/dist/commands/apps/delete.js +1 -1
- package/dist/commands/apps/devices/delete.js +2 -2
- package/dist/{service → services}/app-bundle.js +7 -6
- package/dist/{service → services}/app-channel.js +7 -6
- package/package.json +1 -1
- /package/dist/{service → services}/app-device.js +0 -0
- /package/dist/{service → services}/apps.js +0 -0
- /package/dist/{service → services}/authorization-service.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
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
|
+
## [0.0.4](https://github.com/capawesome-team/cli/compare/v0.0.3...v0.0.4) (2024-04-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **apps:** improve error message for `apps:bundles:create` ([79dc82c](https://github.com/capawesome-team/cli/commit/79dc82ce7ce7600fa3885f42b4af73a368e3249a))
|
|
11
|
+
|
|
12
|
+
## [0.0.3](https://github.com/capawesome-team/cli/compare/v0.0.2...v0.0.3) (2024-04-27)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **apps:** return bundle ID on create ([8a02925](https://github.com/capawesome-team/cli/commit/8a02925aba7580d0f96284f56478f279e84bfade))
|
|
18
|
+
* **apps:** return channel ID on create ([afec871](https://github.com/capawesome-team/cli/commit/afec8719685fc022586b78792801df575d9bf0a7))
|
|
19
|
+
|
|
5
20
|
## [0.0.2](https://github.com/capawesome-team/cli/compare/v0.0.1...v0.0.2) (2024-04-25)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -19,9 +19,9 @@ const axios_1 = require("axios");
|
|
|
19
19
|
const zip_1 = __importDefault(require("../../../utils/zip"));
|
|
20
20
|
const form_data_1 = __importDefault(require("form-data"));
|
|
21
21
|
const node_fs_1 = require("node:fs");
|
|
22
|
-
const authorization_service_1 = __importDefault(require("../../../
|
|
23
|
-
const apps_1 = __importDefault(require("../../../
|
|
24
|
-
const app_bundle_1 = __importDefault(require("../../../
|
|
22
|
+
const authorization_service_1 = __importDefault(require("../../../services/authorization-service"));
|
|
23
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
24
|
+
const app_bundle_1 = __importDefault(require("../../../services/app-bundle"));
|
|
25
25
|
exports.default = (0, citty_1.defineCommand)({
|
|
26
26
|
meta: {
|
|
27
27
|
description: 'Create a new app bundle.',
|
|
@@ -29,7 +29,7 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
29
29
|
args: {
|
|
30
30
|
path: {
|
|
31
31
|
type: 'string',
|
|
32
|
-
description: 'Path to the bundle to upload. Must be a folder or zip file',
|
|
32
|
+
description: 'Path to the bundle to upload. Must be a folder (e.g. `www` or `dist`) or a zip file.',
|
|
33
33
|
},
|
|
34
34
|
appId: {
|
|
35
35
|
type: 'string',
|
|
@@ -41,7 +41,7 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
var _a;
|
|
44
|
+
var _a, _b, _c;
|
|
45
45
|
if (!authorization_service_1.default.hasAuthorizationToken()) {
|
|
46
46
|
consola_1.default.error('You must be logged in to run this command.');
|
|
47
47
|
return;
|
|
@@ -83,21 +83,28 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
83
83
|
const zipBuffer = yield zip_1.default.zipFolder(path);
|
|
84
84
|
formData.append('file', zipBuffer, { filename: 'bundle.zip' });
|
|
85
85
|
}
|
|
86
|
-
consola_1.default.start('Uploading...');
|
|
87
86
|
if (channelName) {
|
|
88
87
|
formData.append('channelName', channelName);
|
|
89
88
|
}
|
|
89
|
+
consola_1.default.start('Uploading...');
|
|
90
90
|
// Upload the bundle
|
|
91
91
|
try {
|
|
92
|
-
yield app_bundle_1.default.create({ appId: appId, formData: formData });
|
|
92
|
+
const response = yield app_bundle_1.default.create({ appId: appId, formData: formData });
|
|
93
93
|
consola_1.default.success('Bundle successfully created.');
|
|
94
|
+
consola_1.default.info(`Bundle ID: ${response.id}`);
|
|
94
95
|
}
|
|
95
96
|
catch (error) {
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
const defaultErrorMessage = 'Failed to create bundle.';
|
|
98
|
+
if (error instanceof axios_1.AxiosError) {
|
|
99
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
100
|
+
consola_1.default.error('Your token is no longer valid. Please sign in again.');
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
consola_1.default.error(((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) || defaultErrorMessage);
|
|
104
|
+
}
|
|
98
105
|
}
|
|
99
106
|
else {
|
|
100
|
-
consola_1.default.error(
|
|
107
|
+
consola_1.default.error(defaultErrorMessage);
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
110
|
}),
|
|
@@ -16,9 +16,9 @@ const citty_1 = require("citty");
|
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const axios_1 = require("axios");
|
|
18
18
|
const ci_1 = require("../../../utils/ci");
|
|
19
|
-
const apps_1 = __importDefault(require("../../../
|
|
19
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
20
|
const prompt_1 = require("../../../utils/prompt");
|
|
21
|
-
const app_bundle_1 = __importDefault(require("../../../
|
|
21
|
+
const app_bundle_1 = __importDefault(require("../../../services/app-bundle"));
|
|
22
22
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
23
|
meta: {
|
|
24
24
|
description: 'Delete an app bundle.',
|
|
@@ -16,9 +16,9 @@ const citty_1 = require("citty");
|
|
|
16
16
|
const ci_1 = require("../../../utils/ci");
|
|
17
17
|
const consola_1 = __importDefault(require("consola"));
|
|
18
18
|
const prompt_1 = require("../../../utils/prompt");
|
|
19
|
-
const apps_1 = __importDefault(require("../../../
|
|
19
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
20
|
const axios_1 = require("axios");
|
|
21
|
-
const app_channel_1 = __importDefault(require("../../../
|
|
21
|
+
const app_channel_1 = __importDefault(require("../../../services/app-channel"));
|
|
22
22
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
23
|
meta: {
|
|
24
24
|
description: 'Create a new app channel.',
|
|
@@ -53,11 +53,12 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
53
53
|
name = yield (0, prompt_1.prompt)('Enter the name of the channel:', { type: 'text' });
|
|
54
54
|
}
|
|
55
55
|
try {
|
|
56
|
-
yield app_channel_1.default.create({
|
|
56
|
+
const response = yield app_channel_1.default.create({
|
|
57
57
|
appId,
|
|
58
58
|
name,
|
|
59
59
|
});
|
|
60
60
|
consola_1.default.success('Channel created successfully.');
|
|
61
|
+
consola_1.default.info(`Channel ID: ${response.id}`);
|
|
61
62
|
}
|
|
62
63
|
catch (error) {
|
|
63
64
|
if (error instanceof axios_1.AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
@@ -16,9 +16,9 @@ const citty_1 = require("citty");
|
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const axios_1 = require("axios");
|
|
18
18
|
const ci_1 = require("../../../utils/ci");
|
|
19
|
-
const apps_1 = __importDefault(require("../../../
|
|
19
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
20
|
const prompt_1 = require("../../../utils/prompt");
|
|
21
|
-
const app_channel_1 = __importDefault(require("../../../
|
|
21
|
+
const app_channel_1 = __importDefault(require("../../../services/app-channel"));
|
|
22
22
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
23
|
meta: {
|
|
24
24
|
description: 'Delete an app channel.',
|
|
@@ -16,7 +16,7 @@ const citty_1 = require("citty");
|
|
|
16
16
|
const ci_1 = require("../../utils/ci");
|
|
17
17
|
const consola_1 = __importDefault(require("consola"));
|
|
18
18
|
const prompt_1 = require("../../utils/prompt");
|
|
19
|
-
const apps_1 = __importDefault(require("../../
|
|
19
|
+
const apps_1 = __importDefault(require("../../services/apps"));
|
|
20
20
|
const axios_1 = require("axios");
|
|
21
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
22
22
|
meta: {
|
|
@@ -16,7 +16,7 @@ const citty_1 = require("citty");
|
|
|
16
16
|
const ci_1 = require("../../utils/ci");
|
|
17
17
|
const consola_1 = __importDefault(require("consola"));
|
|
18
18
|
const prompt_1 = require("../../utils/prompt");
|
|
19
|
-
const apps_1 = __importDefault(require("../../
|
|
19
|
+
const apps_1 = __importDefault(require("../../services/apps"));
|
|
20
20
|
const axios_1 = require("axios");
|
|
21
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
22
22
|
meta: {
|
|
@@ -16,9 +16,9 @@ const citty_1 = require("citty");
|
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const axios_1 = require("axios");
|
|
18
18
|
const ci_1 = require("../../../utils/ci");
|
|
19
|
-
const apps_1 = __importDefault(require("../../../
|
|
19
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
20
|
const prompt_1 = require("../../../utils/prompt");
|
|
21
|
-
const app_device_1 = __importDefault(require("../../../
|
|
21
|
+
const app_device_1 = __importDefault(require("../../../services/app-device"));
|
|
22
22
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
23
|
meta: {
|
|
24
24
|
description: 'Delete an app device.',
|
|
@@ -20,23 +20,24 @@ class AppBundlesServiceImpl {
|
|
|
20
20
|
}
|
|
21
21
|
create(data) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const
|
|
23
|
+
const response = yield this.httpClient.post(`/apps/${data.appId}/bundles`, data.formData, {
|
|
24
24
|
headers: Object.assign({ Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}` }, data.formData.getHeaders()),
|
|
25
25
|
});
|
|
26
|
-
if (!
|
|
27
|
-
throw
|
|
26
|
+
if (!response.success) {
|
|
27
|
+
throw response.error;
|
|
28
28
|
}
|
|
29
|
+
return response.data;
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
delete(data) {
|
|
32
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const
|
|
34
|
+
const response = yield this.httpClient.delete(`/apps/${data.appId}/bundles/${data.bundleId}`, {
|
|
34
35
|
headers: {
|
|
35
36
|
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
36
37
|
},
|
|
37
38
|
});
|
|
38
|
-
if (!
|
|
39
|
-
throw
|
|
39
|
+
if (!response.success) {
|
|
40
|
+
throw response.error;
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
43
|
}
|
|
@@ -20,19 +20,20 @@ class AppChannelsServiceImpl {
|
|
|
20
20
|
}
|
|
21
21
|
create(dto) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const
|
|
23
|
+
const response = yield this.httpClient.post(`/apps/${dto.appId}/channels`, dto, {
|
|
24
24
|
headers: {
|
|
25
25
|
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
|
-
if (!
|
|
29
|
-
throw
|
|
28
|
+
if (!response.success) {
|
|
29
|
+
throw response.error;
|
|
30
30
|
}
|
|
31
|
+
return response.data;
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
delete(data) {
|
|
34
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const
|
|
36
|
+
const response = yield this.httpClient.delete(`/apps/${data.appId}/channels`, {
|
|
36
37
|
headers: {
|
|
37
38
|
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
38
39
|
},
|
|
@@ -40,8 +41,8 @@ class AppChannelsServiceImpl {
|
|
|
40
41
|
name: data.name,
|
|
41
42
|
},
|
|
42
43
|
});
|
|
43
|
-
if (!
|
|
44
|
-
throw
|
|
44
|
+
if (!response.success) {
|
|
45
|
+
throw response.error;
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|