@capawesome/cli 0.0.4 → 0.0.6
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 +20 -0
- package/dist/commands/apps/bundles/create.js +32 -3
- package/dist/commands/apps/bundles/delete.js +0 -5
- package/dist/commands/apps/channels/create.js +0 -5
- package/dist/commands/apps/channels/delete.js +0 -5
- package/dist/commands/apps/create.js +0 -5
- package/dist/commands/apps/delete.js +0 -5
- package/dist/commands/apps/devices/delete.js +0 -5
- package/dist/commands/login.js +41 -23
- package/dist/commands/logout.js +1 -4
- package/dist/commands/whoami.js +11 -4
- package/dist/services/authorization-service.js +1 -5
- package/dist/services/users.js +36 -0
- package/dist/types/index.js +1 -0
- package/dist/types/user.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
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.6](https://github.com/capawesome-team/cli/compare/v0.0.5...v0.0.6) (2024-05-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **bundles:** add new min and max options ([#1](https://github.com/capawesome-team/cli/issues/1)) ([41d4bad](https://github.com/capawesome-team/cli/commit/41d4badadafc4b5989d22200e58f09efe01ebeec))
|
|
11
|
+
|
|
12
|
+
## [0.0.5](https://github.com/capawesome-team/cli/compare/v0.0.4...v0.0.5) (2024-05-02)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **login:** add `--token` option ([2cdd649](https://github.com/capawesome-team/cli/commit/2cdd649bec96fbdb8a43e16a08b256b16a98a662))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* allow execution of commands in ci ([4ce7ea6](https://github.com/capawesome-team/cli/commit/4ce7ea6e23c5cb15543df8a215274287134682e8))
|
|
23
|
+
* read user config in ci ([f404989](https://github.com/capawesome-team/cli/commit/f4049890e5ebac15af5491d4ee04e7fcb6e15235))
|
|
24
|
+
|
|
5
25
|
## [0.0.4](https://github.com/capawesome-team/cli/compare/v0.0.3...v0.0.4) (2024-04-30)
|
|
6
26
|
|
|
7
27
|
|
|
@@ -27,9 +27,13 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
27
27
|
description: 'Create a new app bundle.',
|
|
28
28
|
},
|
|
29
29
|
args: {
|
|
30
|
-
|
|
30
|
+
androidMax: {
|
|
31
31
|
type: 'string',
|
|
32
|
-
description: '
|
|
32
|
+
description: 'The maximum Android version code (`versionCode`) that the bundle supports.',
|
|
33
|
+
},
|
|
34
|
+
androidMin: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'The minimum Android version code (`versionCode`) that the bundle supports.',
|
|
33
37
|
},
|
|
34
38
|
appId: {
|
|
35
39
|
type: 'string',
|
|
@@ -39,6 +43,18 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
39
43
|
type: 'string',
|
|
40
44
|
description: 'Channel to associate the bundle with.',
|
|
41
45
|
},
|
|
46
|
+
path: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'Path to the bundle to upload. Must be a folder (e.g. `www` or `dist`) or a zip file.',
|
|
49
|
+
},
|
|
50
|
+
iosMax: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: 'The maximum iOS bundle version (`CFBundleVersion`) that the bundle supports.',
|
|
53
|
+
},
|
|
54
|
+
iosMin: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'The minimum iOS bundle version (`CFBundleVersion`) that the bundle supports.',
|
|
57
|
+
},
|
|
42
58
|
},
|
|
43
59
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
60
|
var _a, _b, _c;
|
|
@@ -46,8 +62,9 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
46
62
|
consola_1.default.error('You must be logged in to run this command.');
|
|
47
63
|
return;
|
|
48
64
|
}
|
|
49
|
-
|
|
65
|
+
const { androidMax, androidMin, iosMax, iosMin } = ctx.args;
|
|
50
66
|
let appId = ctx.args.appId;
|
|
67
|
+
let path = ctx.args.path;
|
|
51
68
|
let channelName = ctx.args.channel;
|
|
52
69
|
if (!path) {
|
|
53
70
|
path = yield (0, prompt_1.prompt)('Enter the path to the app bundle:', {
|
|
@@ -86,6 +103,18 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
86
103
|
if (channelName) {
|
|
87
104
|
formData.append('channelName', channelName);
|
|
88
105
|
}
|
|
106
|
+
if (androidMax) {
|
|
107
|
+
formData.append('maxAndroidAppVersionCode', androidMax);
|
|
108
|
+
}
|
|
109
|
+
if (androidMin) {
|
|
110
|
+
formData.append('minAndroidAppVersionCode', androidMin);
|
|
111
|
+
}
|
|
112
|
+
if (iosMax) {
|
|
113
|
+
formData.append('maxIosAppVersionCode', iosMax);
|
|
114
|
+
}
|
|
115
|
+
if (iosMin) {
|
|
116
|
+
formData.append('minIosAppVersionCode', iosMin);
|
|
117
|
+
}
|
|
89
118
|
consola_1.default.start('Uploading...');
|
|
90
119
|
// Upload the bundle
|
|
91
120
|
try {
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const axios_1 = require("axios");
|
|
18
|
-
const ci_1 = require("../../../utils/ci");
|
|
19
18
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
19
|
const prompt_1 = require("../../../utils/prompt");
|
|
21
20
|
const app_bundle_1 = __importDefault(require("../../../services/app-bundle"));
|
|
@@ -35,10 +34,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
35
34
|
},
|
|
36
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
36
|
var _a;
|
|
38
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
39
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
37
|
let appId = ctx.args.appId;
|
|
43
38
|
if (!appId) {
|
|
44
39
|
const apps = yield apps_1.default.findAll();
|
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
|
-
const ci_1 = require("../../../utils/ci");
|
|
17
16
|
const consola_1 = __importDefault(require("consola"));
|
|
18
17
|
const prompt_1 = require("../../../utils/prompt");
|
|
19
18
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
@@ -35,10 +34,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
35
34
|
},
|
|
36
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
36
|
var _a;
|
|
38
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
39
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
37
|
let appId = ctx.args.appId;
|
|
43
38
|
if (!appId) {
|
|
44
39
|
const apps = yield apps_1.default.findAll();
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const axios_1 = require("axios");
|
|
18
|
-
const ci_1 = require("../../../utils/ci");
|
|
19
18
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
19
|
const prompt_1 = require("../../../utils/prompt");
|
|
21
20
|
const app_channel_1 = __importDefault(require("../../../services/app-channel"));
|
|
@@ -35,10 +34,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
35
34
|
},
|
|
36
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
36
|
var _a;
|
|
38
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
39
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
37
|
let appId = ctx.args.appId;
|
|
43
38
|
if (!appId) {
|
|
44
39
|
const apps = yield apps_1.default.findAll();
|
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
|
-
const ci_1 = require("../../utils/ci");
|
|
17
16
|
const consola_1 = __importDefault(require("consola"));
|
|
18
17
|
const prompt_1 = require("../../utils/prompt");
|
|
19
18
|
const apps_1 = __importDefault(require("../../services/apps"));
|
|
@@ -30,10 +29,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
30
29
|
},
|
|
31
30
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
31
|
var _a;
|
|
33
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
34
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
32
|
let name = ctx.args.name;
|
|
38
33
|
if (!name) {
|
|
39
34
|
name = yield (0, prompt_1.prompt)('Enter the name of the app:', { type: 'text' });
|
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
|
-
const ci_1 = require("../../utils/ci");
|
|
17
16
|
const consola_1 = __importDefault(require("consola"));
|
|
18
17
|
const prompt_1 = require("../../utils/prompt");
|
|
19
18
|
const apps_1 = __importDefault(require("../../services/apps"));
|
|
@@ -30,10 +29,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
30
29
|
},
|
|
31
30
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
31
|
var _a;
|
|
33
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
34
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
32
|
let appId = ctx.args.appId;
|
|
38
33
|
if (!appId) {
|
|
39
34
|
const apps = yield apps_1.default.findAll();
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const axios_1 = require("axios");
|
|
18
|
-
const ci_1 = require("../../../utils/ci");
|
|
19
18
|
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
19
|
const prompt_1 = require("../../../utils/prompt");
|
|
21
20
|
const app_device_1 = __importDefault(require("../../../services/app-device"));
|
|
@@ -35,10 +34,6 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
35
34
|
},
|
|
36
35
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
36
|
var _a;
|
|
38
|
-
if ((0, ci_1.isRunningInCi)()) {
|
|
39
|
-
consola_1.default.error('This command is not supported in CI environments.');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
37
|
let appId = ctx.args.appId;
|
|
43
38
|
if (!appId) {
|
|
44
39
|
const apps = yield apps_1.default.findAll();
|
package/dist/commands/login.js
CHANGED
|
@@ -18,37 +18,55 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
18
18
|
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
19
19
|
const config_1 = require("../config");
|
|
20
20
|
const prompt_1 = require("../utils/prompt");
|
|
21
|
-
const
|
|
21
|
+
const users_1 = __importDefault(require("../services/users"));
|
|
22
22
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
23
|
meta: {
|
|
24
24
|
name: 'login',
|
|
25
25
|
description: 'Sign in to the Capawesome Cloud Console.',
|
|
26
26
|
},
|
|
27
|
+
args: {
|
|
28
|
+
token: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'Token to use for authentication.',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
27
33
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const email = yield (0, prompt_1.prompt)('Enter your email:', { type: 'text' });
|
|
33
|
-
const password = yield (0, prompt_1.passwordPrompt)('Enter your password:');
|
|
34
|
-
consola_1.default.start('Logging in...');
|
|
35
|
-
let sessionId;
|
|
36
|
-
try {
|
|
37
|
-
const sessionResponse = yield axios_1.default.post(`${config_1.API_URL}/sessions`, {
|
|
38
|
-
email: email,
|
|
39
|
-
password: password,
|
|
34
|
+
let token = ctx.args.token;
|
|
35
|
+
if (token) {
|
|
36
|
+
userConfig_1.default.write({
|
|
37
|
+
token: token,
|
|
40
38
|
});
|
|
41
|
-
|
|
39
|
+
try {
|
|
40
|
+
yield users_1.default.me();
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
userConfig_1.default.write({});
|
|
44
|
+
consola_1.default.error('Invalid token.');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
consola_1.default.success(`Successfully signed in.`);
|
|
42
48
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
else {
|
|
50
|
+
const email = yield (0, prompt_1.prompt)('Enter your email:', { type: 'text' });
|
|
51
|
+
const password = yield (0, prompt_1.passwordPrompt)('Enter your password:');
|
|
52
|
+
consola_1.default.start('Logging in...');
|
|
53
|
+
let sessionId;
|
|
54
|
+
try {
|
|
55
|
+
const sessionResponse = yield axios_1.default.post(`${config_1.API_URL}/sessions`, {
|
|
56
|
+
email: email,
|
|
57
|
+
password: password,
|
|
58
|
+
});
|
|
59
|
+
sessionId = sessionResponse.data.id;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
consola_1.default.error('Invalid email or password.');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const tokenResponse = yield axios_1.default.post(`${config_1.API_URL}/tokens`, { name: 'Capawesome CLI' }, { headers: { Authorization: `Bearer ${sessionId}` } });
|
|
66
|
+
userConfig_1.default.write({
|
|
67
|
+
token: tokenResponse.data.token,
|
|
68
|
+
});
|
|
69
|
+
consola_1.default.success(`Successfully signed in.`);
|
|
46
70
|
}
|
|
47
|
-
const tokenResponse = yield axios_1.default.post(`${config_1.API_URL}/tokens`, { name: 'Capawesome CLI' }, { headers: { Authorization: `Bearer ${sessionId}` } });
|
|
48
|
-
userConfig_1.default.write({
|
|
49
|
-
username: email,
|
|
50
|
-
token: tokenResponse.data.token,
|
|
51
|
-
});
|
|
52
|
-
consola_1.default.success(`Successfully signed in.`);
|
|
53
71
|
}),
|
|
54
72
|
});
|
package/dist/commands/logout.js
CHANGED
|
@@ -22,10 +22,7 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
22
22
|
},
|
|
23
23
|
args: {},
|
|
24
24
|
run: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
|
|
26
|
-
delete config.username;
|
|
27
|
-
delete config.token;
|
|
28
|
-
userConfig_1.default.write(config);
|
|
25
|
+
userConfig_1.default.write({});
|
|
29
26
|
consola_1.default.success('Successfully signed out.');
|
|
30
27
|
}),
|
|
31
28
|
});
|
package/dist/commands/whoami.js
CHANGED
|
@@ -15,18 +15,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
17
|
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
18
|
+
const users_1 = __importDefault(require("../services/users"));
|
|
18
19
|
exports.default = (0, citty_1.defineCommand)({
|
|
19
20
|
meta: {
|
|
20
21
|
name: 'whoami',
|
|
21
22
|
description: 'Show current user',
|
|
22
23
|
},
|
|
23
24
|
run: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
const {
|
|
25
|
-
if (
|
|
26
|
-
|
|
25
|
+
const { token } = userConfig_1.default.read();
|
|
26
|
+
if (token) {
|
|
27
|
+
try {
|
|
28
|
+
const user = yield users_1.default.me();
|
|
29
|
+
consola_1.default.info(`Logged in as ${user.email}.`);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
consola_1.default.error('Token is invalid. Please sign in again.');
|
|
33
|
+
}
|
|
27
34
|
}
|
|
28
35
|
else {
|
|
29
|
-
consola_1.default.
|
|
36
|
+
consola_1.default.error('Not logged in.');
|
|
30
37
|
}
|
|
31
38
|
}),
|
|
32
39
|
});
|
|
@@ -3,17 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ci_1 = require("../utils/ci");
|
|
7
6
|
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
8
7
|
class AuthorizationServiceImpl {
|
|
9
8
|
constructor(userConfig) {
|
|
10
9
|
this.userConfig = userConfig;
|
|
11
10
|
}
|
|
12
11
|
getCurrentAuthorizationToken() {
|
|
13
|
-
|
|
14
|
-
return process.env.CAPAWESOME_TOKEN || null;
|
|
15
|
-
}
|
|
16
|
-
return this.userConfig.read().token || null;
|
|
12
|
+
return this.userConfig.read().token || process.env.CAPAWESOME_TOKEN || null;
|
|
17
13
|
}
|
|
18
14
|
hasAuthorizationToken() {
|
|
19
15
|
return !!this.getCurrentAuthorizationToken();
|
|
@@ -0,0 +1,36 @@
|
|
|
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 http_client_1 = __importDefault(require("../utils/http-client"));
|
|
16
|
+
const authorization_service_1 = __importDefault(require("./authorization-service"));
|
|
17
|
+
class UsersServiceImpl {
|
|
18
|
+
constructor(httpClient) {
|
|
19
|
+
this.httpClient = httpClient;
|
|
20
|
+
}
|
|
21
|
+
me() {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const response = yield this.httpClient.get('/users/me', {
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${authorization_service_1.default.getCurrentAuthorizationToken()}`,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (!response.success) {
|
|
29
|
+
throw response.error;
|
|
30
|
+
}
|
|
31
|
+
return response.data;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const usersService = new UsersServiceImpl(http_client_1.default);
|
|
36
|
+
exports.default = usersService;
|
package/dist/types/index.js
CHANGED