@capawesome/cli 0.0.12 → 0.0.14
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 +1 -1
- package/dist/commands/apps/channels/delete.js +3 -3
- package/dist/commands/login.js +21 -18
- package/dist/commands/whoami.js +7 -2
- package/dist/index.js +7 -0
- package/dist/services/update.js +60 -0
- package/dist/types/npm-package.js +2 -0
- package/dist/utils/http-client.js +8 -4
- package/package.json +4 -2
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.14](https://github.com/capawesome-team/cli/compare/v0.0.13...v0.0.14) (2024-09-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **apps:** typo ([c65ca99](https://github.com/capawesome-team/cli/commit/c65ca99289b333ddb79d3ade0db33cb4571e860d))
|
|
11
|
+
* **whoami:** support oauth provider ([7b80a7b](https://github.com/capawesome-team/cli/commit/7b80a7b3c5aa3d8dea6c77cf30a8bfae10961e36))
|
|
12
|
+
|
|
13
|
+
## [0.0.13](https://github.com/capawesome-team/cli/compare/v0.0.12...v0.0.13) (2024-08-20)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* print notice if new version is available ([#7](https://github.com/capawesome-team/cli/issues/7)) ([db88dc3](https://github.com/capawesome-team/cli/commit/db88dc356f6f6f5f73444e341ab749ae68cfdf6a)), closes [#2](https://github.com/capawesome-team/cli/issues/2)
|
|
19
|
+
|
|
5
20
|
## [0.0.12](https://github.com/capawesome-team/cli/compare/v0.0.11...v0.0.12) (2024-07-25)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -93,7 +93,7 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
93
93
|
}
|
|
94
94
|
if (!appId) {
|
|
95
95
|
const apps = yield apps_1.default.findAll();
|
|
96
|
-
if (
|
|
96
|
+
if (apps.length === 0) {
|
|
97
97
|
consola_1.default.error('You must create an app before creating a bundle.');
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
|
-
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
18
|
-
const prompt_1 = require("../../../utils/prompt");
|
|
19
17
|
const app_channels_1 = __importDefault(require("../../../services/app-channels"));
|
|
18
|
+
const apps_1 = __importDefault(require("../../../services/apps"));
|
|
20
19
|
const error_1 = require("../../../utils/error");
|
|
20
|
+
const prompt_1 = require("../../../utils/prompt");
|
|
21
21
|
exports.default = (0, citty_1.defineCommand)({
|
|
22
22
|
meta: {
|
|
23
23
|
description: 'Delete an app channel.',
|
|
@@ -37,7 +37,7 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
37
37
|
if (!appId) {
|
|
38
38
|
const apps = yield apps_1.default.findAll();
|
|
39
39
|
if (!apps.length) {
|
|
40
|
-
consola_1.default.error('You must create an app before deleting a
|
|
40
|
+
consola_1.default.error('You must create an app before deleting a channel.');
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
|
package/dist/commands/login.js
CHANGED
|
@@ -12,13 +12,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
15
16
|
const citty_1 = require("citty");
|
|
16
17
|
const consola_1 = __importDefault(require("consola"));
|
|
17
|
-
const axios_1 = __importDefault(require("axios"));
|
|
18
|
-
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
19
18
|
const config_1 = require("../config");
|
|
20
|
-
const prompt_1 = require("../utils/prompt");
|
|
21
19
|
const users_1 = __importDefault(require("../services/users"));
|
|
20
|
+
const prompt_1 = require("../utils/prompt");
|
|
21
|
+
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
22
22
|
exports.default = (0, citty_1.defineCommand)({
|
|
23
23
|
meta: {
|
|
24
24
|
name: 'login',
|
|
@@ -32,21 +32,8 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
32
32
|
},
|
|
33
33
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
34
|
let token = ctx.args.token;
|
|
35
|
-
if (token) {
|
|
36
|
-
|
|
37
|
-
token: token,
|
|
38
|
-
});
|
|
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.`);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
35
|
+
if (token === undefined) {
|
|
36
|
+
consola_1.default.warn('If you have signed up via an OAuth provider, please sign in using the `--token` argument.');
|
|
50
37
|
const email = yield (0, prompt_1.prompt)('Enter your email:', { type: 'text' });
|
|
51
38
|
const password = yield (0, prompt_1.passwordPrompt)('Enter your password:');
|
|
52
39
|
consola_1.default.start('Logging in...');
|
|
@@ -68,5 +55,21 @@ exports.default = (0, citty_1.defineCommand)({
|
|
|
68
55
|
});
|
|
69
56
|
consola_1.default.success(`Successfully signed in.`);
|
|
70
57
|
}
|
|
58
|
+
else if (token.length === 0) {
|
|
59
|
+
consola_1.default.error('Please provide a valid token. You can create a token at https://cloud.capawesome.io/settings/tokens.');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
userConfig_1.default.write({
|
|
63
|
+
token: token,
|
|
64
|
+
});
|
|
65
|
+
try {
|
|
66
|
+
yield users_1.default.me();
|
|
67
|
+
consola_1.default.success(`Successfully signed in.`);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
userConfig_1.default.write({});
|
|
71
|
+
consola_1.default.error('Invalid token. Please provide a valid token. You can create a token at https://cloud.capawesome.io/settings/tokens.');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
71
74
|
}),
|
|
72
75
|
});
|
package/dist/commands/whoami.js
CHANGED
|
@@ -14,19 +14,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const citty_1 = require("citty");
|
|
16
16
|
const consola_1 = __importDefault(require("consola"));
|
|
17
|
-
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
18
17
|
const users_1 = __importDefault(require("../services/users"));
|
|
18
|
+
const userConfig_1 = __importDefault(require("../utils/userConfig"));
|
|
19
19
|
exports.default = (0, citty_1.defineCommand)({
|
|
20
20
|
meta: {
|
|
21
21
|
name: 'whoami',
|
|
22
22
|
description: 'Show current user',
|
|
23
23
|
},
|
|
24
24
|
run: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
var _a, _b;
|
|
25
26
|
const { token } = userConfig_1.default.read();
|
|
26
27
|
if (token) {
|
|
27
28
|
try {
|
|
28
29
|
const user = yield users_1.default.me();
|
|
29
|
-
|
|
30
|
+
const email = user.email;
|
|
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 || '?'}.`);
|
|
30
35
|
}
|
|
31
36
|
catch (error) {
|
|
32
37
|
consola_1.default.error('Token is invalid. Please sign in again.');
|
package/dist/index.js
CHANGED
|
@@ -29,12 +29,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
const citty_1 = require("citty");
|
|
31
31
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
32
|
+
const update_1 = __importDefault(require("./services/update"));
|
|
32
33
|
const main = (0, citty_1.defineCommand)({
|
|
33
34
|
meta: {
|
|
34
35
|
name: package_json_1.default.name,
|
|
35
36
|
version: package_json_1.default.version,
|
|
36
37
|
description: package_json_1.default.description,
|
|
37
38
|
},
|
|
39
|
+
setup() {
|
|
40
|
+
// No op
|
|
41
|
+
},
|
|
42
|
+
cleanup() {
|
|
43
|
+
return update_1.default.checkForUpdate();
|
|
44
|
+
},
|
|
38
45
|
subCommands: {
|
|
39
46
|
whoami: Promise.resolve().then(() => __importStar(require('./commands/whoami'))).then((mod) => mod.default),
|
|
40
47
|
login: Promise.resolve().then(() => __importStar(require('./commands/login'))).then((mod) => mod.default),
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const consola_1 = __importDefault(require("consola"));
|
|
39
|
+
const semver = __importStar(require("semver"));
|
|
40
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
41
|
+
const http_client_1 = __importDefault(require("../utils/http-client"));
|
|
42
|
+
class UpdateServiceImpl {
|
|
43
|
+
constructor(httpClient) {
|
|
44
|
+
this.httpClient = httpClient;
|
|
45
|
+
}
|
|
46
|
+
checkForUpdate() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const response = yield this.httpClient.get(`https://registry.npmjs.org/${package_json_1.default.name}/latest`);
|
|
49
|
+
if (!response.success) {
|
|
50
|
+
throw response.error;
|
|
51
|
+
}
|
|
52
|
+
const latestVersion = response.data.version;
|
|
53
|
+
if (semver.gt(latestVersion, package_json_1.default.version)) {
|
|
54
|
+
consola_1.default.warn(`New version of Capawesome CLI available: ${package_json_1.default.name}@${latestVersion}. Please update to receive the latest features and bug fixes.`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const updateService = new UpdateServiceImpl(http_client_1.default);
|
|
60
|
+
exports.default = updateService;
|
|
@@ -18,7 +18,8 @@ class HttpClientImpl {
|
|
|
18
18
|
delete(url, config) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
21
|
+
const urlWithHost = url.startsWith('http') ? url : config_1.API_URL + url;
|
|
22
|
+
const res = yield axios_1.default.delete(urlWithHost, config);
|
|
22
23
|
return {
|
|
23
24
|
success: true,
|
|
24
25
|
status: res.status,
|
|
@@ -37,7 +38,8 @@ class HttpClientImpl {
|
|
|
37
38
|
get(url, config) {
|
|
38
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
40
|
try {
|
|
40
|
-
const
|
|
41
|
+
const urlWithHost = url.startsWith('http') ? url : config_1.API_URL + url;
|
|
42
|
+
const res = yield axios_1.default.get(urlWithHost, config);
|
|
41
43
|
return {
|
|
42
44
|
success: true,
|
|
43
45
|
status: res.status,
|
|
@@ -56,7 +58,8 @@ class HttpClientImpl {
|
|
|
56
58
|
patch(url, data, config) {
|
|
57
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
60
|
try {
|
|
59
|
-
const
|
|
61
|
+
const urlWithHost = url.startsWith('http') ? url : config_1.API_URL + url;
|
|
62
|
+
const res = yield axios_1.default.patch(urlWithHost, data, config);
|
|
60
63
|
return {
|
|
61
64
|
success: true,
|
|
62
65
|
status: res.status,
|
|
@@ -75,7 +78,8 @@ class HttpClientImpl {
|
|
|
75
78
|
post(url, data, config) {
|
|
76
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
80
|
try {
|
|
78
|
-
const
|
|
81
|
+
const urlWithHost = url.startsWith('http') ? url : config_1.API_URL + url;
|
|
82
|
+
const res = yield axios_1.default.post(urlWithHost, data, config);
|
|
79
83
|
return {
|
|
80
84
|
success: true,
|
|
81
85
|
status: res.status,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capawesome/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf ./dist && tsc",
|
|
@@ -46,12 +46,14 @@
|
|
|
46
46
|
"citty": "0.1.6",
|
|
47
47
|
"consola": "3.2.3",
|
|
48
48
|
"form-data": "4.0.0",
|
|
49
|
-
"rc9": "2.1.1"
|
|
49
|
+
"rc9": "2.1.1",
|
|
50
|
+
"semver": "7.6.3"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@ionic/prettier-config": "4.0.0",
|
|
53
54
|
"@types/archiver": "6.0.2",
|
|
54
55
|
"@types/node": "20.11.30",
|
|
56
|
+
"@types/semver": "7.5.8",
|
|
55
57
|
"commit-and-tag-version": "12.4.0",
|
|
56
58
|
"prettier": "3.2.5",
|
|
57
59
|
"rimraf": "5.0.5",
|