@capawesome/cli 1.9.0 → 1.10.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,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.10.0](https://github.com/capawesome-team/cli/compare/v1.9.0...v1.10.0) (2025-05-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **apps:channels:** add update channel command ([8e93c85](https://github.com/capawesome-team/cli/commit/8e93c851e8b868cb608432dd76c52f149838e6b7))
|
|
11
|
+
|
|
5
12
|
## [1.9.0](https://github.com/capawesome-team/cli/compare/v1.8.1...v1.9.0) (2025-04-17)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -0,0 +1,95 @@
|
|
|
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 apps_1 = __importDefault(require("../../../services/apps"));
|
|
19
|
+
const authorization_service_1 = __importDefault(require("../../../services/authorization-service"));
|
|
20
|
+
const error_1 = require("../../../utils/error");
|
|
21
|
+
const prompt_1 = require("../../../utils/prompt");
|
|
22
|
+
exports.default = (0, citty_1.defineCommand)({
|
|
23
|
+
meta: {
|
|
24
|
+
description: 'Update an existing app channel.',
|
|
25
|
+
},
|
|
26
|
+
args: {
|
|
27
|
+
appId: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'ID of the app.',
|
|
30
|
+
},
|
|
31
|
+
channelId: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'ID of the channel.',
|
|
34
|
+
},
|
|
35
|
+
bundleLimit: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Maximum number of bundles that can be assigned to the channel. If more bundles are assigned, the oldest bundles will be automatically deleted.',
|
|
38
|
+
},
|
|
39
|
+
name: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Name of the channel.',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
if (!authorization_service_1.default.hasAuthorizationToken()) {
|
|
46
|
+
consola_1.default.error('You must be logged in to run this command.');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
let appId = ctx.args.appId;
|
|
50
|
+
let bundleLimitAsString = ctx.args.bundleLimit;
|
|
51
|
+
let channelId = ctx.args.channelId;
|
|
52
|
+
let name = ctx.args.name;
|
|
53
|
+
// Validate the bundle limit
|
|
54
|
+
let bundleLimit;
|
|
55
|
+
if (bundleLimitAsString) {
|
|
56
|
+
bundleLimit = parseInt(bundleLimitAsString, 10);
|
|
57
|
+
if (isNaN(bundleLimit)) {
|
|
58
|
+
consola_1.default.error('The bundle limit must be a number.');
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (!appId) {
|
|
63
|
+
const apps = yield apps_1.default.findAll();
|
|
64
|
+
if (!apps.length) {
|
|
65
|
+
consola_1.default.error('You must create an app before updating a channel.');
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
|
|
69
|
+
appId = yield (0, prompt_1.prompt)('Which app do you want to update the channel for?', {
|
|
70
|
+
type: 'select',
|
|
71
|
+
options: apps.map((app) => ({ label: app.name, value: app.id })),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (!channelId) {
|
|
75
|
+
channelId = yield (0, prompt_1.prompt)('Enter the channel ID:', {
|
|
76
|
+
type: 'text',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Update channel
|
|
80
|
+
try {
|
|
81
|
+
yield app_channels_1.default.update({
|
|
82
|
+
appId,
|
|
83
|
+
appChannelId: channelId,
|
|
84
|
+
name,
|
|
85
|
+
totalAppBundleLimit: bundleLimit,
|
|
86
|
+
});
|
|
87
|
+
consola_1.default.success('Channel updated successfully.');
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const message = (0, error_1.getMessageFromUnknownError)(error);
|
|
91
|
+
consola_1.default.error(message);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
}),
|
|
95
|
+
});
|
package/dist/commands/whoami.js
CHANGED
|
@@ -22,16 +22,11 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
22
22
|
description: 'Show current user',
|
|
23
23
|
},
|
|
24
24
|
run: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
var _a, _b;
|
|
26
25
|
const { token } = userConfig_1.default.read();
|
|
27
26
|
if (token) {
|
|
28
27
|
try {
|
|
29
28
|
const user = yield users_1.default.me();
|
|
30
|
-
|
|
31
|
-
const userProviderProfile = user.userProviderProfiles[0]
|
|
32
|
-
? ((_a = user.userProviderProfiles[0]) === null || _a === void 0 ? void 0 : _a.provider) + ':' + ((_b = user.userProviderProfiles[0]) === null || _b === void 0 ? void 0 : _b.providerUsername)
|
|
33
|
-
: null;
|
|
34
|
-
consola_1.default.info(`Logged in as ${email || userProviderProfile || '?'}.`);
|
|
29
|
+
consola_1.default.info(`Logged in as ${user.email}.`);
|
|
35
30
|
}
|
|
36
31
|
catch (error) {
|
|
37
32
|
consola_1.default.error('Token is invalid. Please sign in again.');
|
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:update': Promise.resolve().then(() => __importStar(require('./commands/apps/channels/update'))).then((mod) => mod.default),
|
|
70
71
|
'apps:devices:delete': Promise.resolve().then(() => __importStar(require('./commands/apps/devices/delete'))).then((mod) => mod.default),
|
|
71
72
|
'manifests:generate': Promise.resolve().then(() => __importStar(require('./commands/manifests/generate'))).then((mod) => mod.default),
|
|
72
73
|
},
|
|
@@ -49,6 +49,16 @@ class AppChannelsServiceImpl {
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
+
update(dto) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const response = yield this.httpClient.patch(`/v1/apps/${dto.appId}/channels/${dto.appChannelId}`, dto, {
|
|
55
|
+
headers: {
|
|
56
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
return response.data;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
63
|
const appChannelsService = new AppChannelsServiceImpl(http_client_1.default);
|
|
54
64
|
exports.default = appChannelsService;
|
package/package.json
CHANGED