@capawesome/cli 0.0.13 → 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 CHANGED
@@ -2,6 +2,14 @@
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
+
5
13
  ## [0.0.13](https://github.com/capawesome-team/cli/compare/v0.0.12...v0.0.13) (2024-08-20)
6
14
 
7
15
 
@@ -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 bundle.');
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
@@ -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
- userConfig_1.default.write({
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
  });
@@ -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
- consola_1.default.info(`Logged in as ${user.email}.`);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/cli",
3
- "version": "0.0.13",
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",