@capawesome/cli 1.10.0 → 1.11.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 +7 -0
- package/dist/commands/apps/channels/get.js +106 -0
- package/dist/index.js +1 -0
- package/dist/services/app-channels.js +24 -0
- package/dist/utils/http-client.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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
|
+
## [1.11.0](https://github.com/capawesome-team/cli/compare/v1.10.0...v1.11.0) (2025-05-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add `apps:channels:get` command ([308a68d](https://github.com/capawesome-team/cli/commit/308a68d47492a554e8d56d61b29cde1c7bee1ff7))
|
|
11
|
+
|
|
5
12
|
## [1.10.0](https://github.com/capawesome-team/cli/compare/v1.9.0...v1.10.0) (2025-05-02)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
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 app_channels_1 = __importDefault(require("../../../services/app-channels"));
|
|
18
|
+
const authorization_service_1 = __importDefault(require("../../../services/authorization-service"));
|
|
19
|
+
const error_1 = require("../../../utils/error");
|
|
20
|
+
exports.default = (0, citty_1.defineCommand)({
|
|
21
|
+
meta: {
|
|
22
|
+
description: 'Update an existing app channel.',
|
|
23
|
+
},
|
|
24
|
+
args: {
|
|
25
|
+
appId: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'ID of the app.',
|
|
28
|
+
},
|
|
29
|
+
channelId: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'ID of the channel.',
|
|
32
|
+
},
|
|
33
|
+
json: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
description: 'Output in JSON format.',
|
|
36
|
+
},
|
|
37
|
+
name: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: 'Name of the channel.',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
if (!authorization_service_1.default.hasAuthorizationToken()) {
|
|
44
|
+
consola_1.default.error('You must be logged in to run this command.');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
let appId = ctx.args.appId;
|
|
48
|
+
let channelId = ctx.args.channelId;
|
|
49
|
+
let json = ctx.args.json;
|
|
50
|
+
// Convert json to boolean
|
|
51
|
+
if (typeof json === 'string') {
|
|
52
|
+
json = json.toLowerCase() === 'true';
|
|
53
|
+
}
|
|
54
|
+
let name = ctx.args.name;
|
|
55
|
+
if (!appId) {
|
|
56
|
+
consola_1.default.error('You must provide an app ID.');
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
if (!channelId && !name) {
|
|
60
|
+
consola_1.default.error('You must provide a channel ID or name.');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
let channel;
|
|
65
|
+
if (channelId) {
|
|
66
|
+
channel = yield app_channels_1.default.findOneById({
|
|
67
|
+
appId,
|
|
68
|
+
id: channelId,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else if (name) {
|
|
72
|
+
const foundChannels = yield app_channels_1.default.findAll({
|
|
73
|
+
appId,
|
|
74
|
+
name,
|
|
75
|
+
});
|
|
76
|
+
channel = foundChannels[0];
|
|
77
|
+
}
|
|
78
|
+
if (!channel) {
|
|
79
|
+
consola_1.default.error('Channel not found.');
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
if (json) {
|
|
83
|
+
console.log(JSON.stringify({
|
|
84
|
+
id: channel.id,
|
|
85
|
+
name: channel.name,
|
|
86
|
+
totalAppBundleLimit: channel.totalAppBundleLimit,
|
|
87
|
+
appId: channel.appId,
|
|
88
|
+
}, null, 2));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
console.table({
|
|
92
|
+
id: channel.id,
|
|
93
|
+
name: channel.name,
|
|
94
|
+
totalAppBundleLimit: channel.totalAppBundleLimit,
|
|
95
|
+
appId: channel.appId,
|
|
96
|
+
});
|
|
97
|
+
consola_1.default.success('Channel retrieved successfully.');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
102
|
+
consola_1.default.error(message);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,7 @@ const main = (0, citty_1.defineCommand)({
|
|
|
67
67
|
'apps:bundles:update': Promise.resolve().then(() => __importStar(require('./commands/apps/bundles/update'))).then((mod) => mod.default),
|
|
68
68
|
'apps:channels:create': Promise.resolve().then(() => __importStar(require('./commands/apps/channels/create'))).then((mod) => mod.default),
|
|
69
69
|
'apps:channels:delete': Promise.resolve().then(() => __importStar(require('./commands/apps/channels/delete'))).then((mod) => mod.default),
|
|
70
|
+
'apps:channels:get': Promise.resolve().then(() => __importStar(require('./commands/apps/channels/get'))).then((mod) => mod.default),
|
|
70
71
|
'apps:channels:update': Promise.resolve().then(() => __importStar(require('./commands/apps/channels/update'))).then((mod) => mod.default),
|
|
71
72
|
'apps:devices:delete': Promise.resolve().then(() => __importStar(require('./commands/apps/devices/delete'))).then((mod) => mod.default),
|
|
72
73
|
'manifests:generate': Promise.resolve().then(() => __importStar(require('./commands/manifests/generate'))).then((mod) => mod.default),
|
|
@@ -49,6 +49,30 @@ class AppChannelsServiceImpl {
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
+
findAll(data) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const queryParams = new URLSearchParams();
|
|
55
|
+
if (data.name) {
|
|
56
|
+
queryParams.append('name', data.name);
|
|
57
|
+
}
|
|
58
|
+
const response = yield this.httpClient.get(`/v1/apps/${data.appId}/channels?${queryParams}`, {
|
|
59
|
+
headers: {
|
|
60
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return response.data;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
findOneById(data) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const response = yield this.httpClient.get(`/v1/apps/${data.appId}/channels/${data.id}`, {
|
|
69
|
+
headers: {
|
|
70
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return response.data;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
52
76
|
update(dto) {
|
|
53
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
78
|
const response = yield this.httpClient.patch(`/v1/apps/${dto.appId}/channels/${dto.appChannelId}`, dto, {
|
package/package.json
CHANGED