@capawesome/cli 1.13.2 → 1.14.0-dev.8c382fa.1755584275

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +3 -3
  3. package/dist/commands/apps/bundles/create.js +206 -232
  4. package/dist/commands/apps/bundles/delete.js +42 -47
  5. package/dist/commands/apps/bundles/update.js +69 -72
  6. package/dist/commands/apps/channels/create.js +47 -70
  7. package/dist/commands/apps/channels/delete.js +53 -56
  8. package/dist/commands/apps/channels/get.js +27 -61
  9. package/dist/commands/apps/channels/list.js +26 -63
  10. package/dist/commands/apps/channels/update.js +48 -67
  11. package/dist/commands/apps/create.js +38 -38
  12. package/dist/commands/apps/delete.js +39 -40
  13. package/dist/commands/apps/devices/delete.js +42 -47
  14. package/dist/commands/doctor.js +12 -29
  15. package/dist/commands/login.js +48 -69
  16. package/dist/commands/logout.js +13 -31
  17. package/dist/commands/manifests/generate.js +20 -38
  18. package/dist/commands/whoami.js +13 -30
  19. package/dist/config/consts.js +2 -5
  20. package/dist/config/index.js +1 -17
  21. package/dist/index.js +50 -80
  22. package/dist/services/app-bundle-files.js +117 -136
  23. package/dist/services/app-bundles.js +22 -41
  24. package/dist/services/app-channels.js +54 -77
  25. package/dist/services/app-devices.js +10 -25
  26. package/dist/services/apps.js +24 -41
  27. package/dist/services/authorization-service.js +4 -8
  28. package/dist/services/config.js +14 -28
  29. package/dist/services/organizations.js +18 -0
  30. package/dist/services/session-code.js +7 -22
  31. package/dist/services/sessions.js +13 -30
  32. package/dist/services/update.js +17 -55
  33. package/dist/services/users.js +11 -26
  34. package/dist/types/app-bundle-file.js +1 -2
  35. package/dist/types/app-bundle.js +1 -2
  36. package/dist/types/app-channel.js +1 -2
  37. package/dist/types/app-device.js +1 -2
  38. package/dist/types/app.js +1 -2
  39. package/dist/types/index.js +8 -23
  40. package/dist/types/npm-package.js +1 -2
  41. package/dist/types/organization.js +1 -0
  42. package/dist/types/session-code.js +1 -2
  43. package/dist/types/session.js +1 -2
  44. package/dist/types/user.js +1 -2
  45. package/dist/utils/buffer.js +6 -43
  46. package/dist/utils/error.js +24 -14
  47. package/dist/utils/file.js +22 -41
  48. package/dist/utils/hash.js +3 -39
  49. package/dist/utils/http-client.js +27 -53
  50. package/dist/utils/manifest.js +11 -24
  51. package/dist/utils/prompt.js +9 -26
  52. package/dist/utils/signature.js +3 -39
  53. package/dist/utils/userConfig.js +5 -9
  54. package/dist/utils/zip.js +11 -27
  55. package/package.json +15 -8
  56. package/dist/utils/ci.js +0 -7
@@ -1,74 +1,69 @@
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_devices_1 = __importDefault(require("../../../services/app-devices"));
18
- const apps_1 = __importDefault(require("../../../services/apps"));
19
- const error_1 = require("../../../utils/error");
20
- const prompt_1 = require("../../../utils/prompt");
21
- exports.default = (0, citty_1.defineCommand)({
22
- meta: {
23
- description: 'Delete an app device.',
24
- },
25
- args: {
26
- appId: {
27
- type: 'string',
28
- description: 'ID of the app.',
29
- },
30
- deviceId: {
31
- type: 'string',
32
- description: 'ID of the device.',
33
- },
34
- },
35
- run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
36
- let appId = ctx.args.appId;
1
+ import { defineCommand, defineOptions } from '@robingenz/zli';
2
+ import consola from 'consola';
3
+ import { z } from 'zod';
4
+ import appDevicesService from '../../../services/app-devices.js';
5
+ import appsService from '../../../services/apps.js';
6
+ import organizationsService from '../../../services/organizations.js';
7
+ import { getMessageFromUnknownError } from '../../../utils/error.js';
8
+ import { prompt } from '../../../utils/prompt.js';
9
+ export default defineCommand({
10
+ description: 'Delete an app device.',
11
+ options: defineOptions(z.object({
12
+ appId: z.string().optional().describe('ID of the app.'),
13
+ deviceId: z.string().optional().describe('ID of the device.'),
14
+ })),
15
+ action: async (options, args) => {
16
+ let { appId, deviceId } = options;
37
17
  if (!appId) {
38
- const apps = yield apps_1.default.findAll();
18
+ const organizations = await organizationsService.findAll();
19
+ if (organizations.length === 0) {
20
+ consola.error('You must create an organization before deleting a device.');
21
+ process.exit(1);
22
+ }
23
+ // @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
24
+ const organizationId = await prompt('Select the organization of the app from which you want to delete a device.', {
25
+ type: 'select',
26
+ options: organizations.map((organization) => ({ label: organization.name, value: organization.id })),
27
+ });
28
+ if (!organizationId) {
29
+ consola.error('You must select the organization of an app from which you want to delete a device.');
30
+ process.exit(1);
31
+ }
32
+ const apps = await appsService.findAll({
33
+ organizationId,
34
+ });
39
35
  if (!apps.length) {
40
- consola_1.default.error('You must create an app before deleting a device.');
36
+ consola.error('You must create an app before deleting a device.');
41
37
  process.exit(1);
42
38
  }
43
39
  // @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
44
- appId = yield (0, prompt_1.prompt)('Which app do you want to delete the device from?', {
40
+ appId = await prompt('Which app do you want to delete the device from?', {
45
41
  type: 'select',
46
42
  options: apps.map((app) => ({ label: app.name, value: app.id })),
47
43
  });
48
44
  }
49
- let deviceId = ctx.args.deviceId;
50
45
  if (!deviceId) {
51
- deviceId = yield (0, prompt_1.prompt)('Enter the device ID:', {
46
+ deviceId = await prompt('Enter the device ID:', {
52
47
  type: 'text',
53
48
  });
54
49
  }
55
- const confirmed = yield (0, prompt_1.prompt)('Are you sure you want to delete this device?', {
50
+ const confirmed = await prompt('Are you sure you want to delete this device?', {
56
51
  type: 'confirm',
57
52
  });
58
53
  if (!confirmed) {
59
54
  return;
60
55
  }
61
56
  try {
62
- yield app_devices_1.default.delete({
57
+ await appDevicesService.delete({
63
58
  appId,
64
59
  deviceId,
65
60
  });
66
- consola_1.default.success('Device deleted successfully.');
61
+ consola.success('Device deleted successfully.');
67
62
  }
68
63
  catch (error) {
69
- const message = (0, error_1.getMessageFromUnknownError)(error);
70
- consola_1.default.error(message);
64
+ const message = getMessageFromUnknownError(error);
65
+ consola.error(message);
71
66
  process.exit(1);
72
67
  }
73
- }),
68
+ },
74
69
  });
@@ -1,34 +1,17 @@
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 package_json_1 = __importDefault(require("../../package.json"));
18
- const systeminformation_1 = __importDefault(require("systeminformation"));
19
- exports.default = (0, citty_1.defineCommand)({
20
- meta: {
21
- name: 'doctor',
22
- description: 'Prints out neccessary information for debugging',
23
- },
24
- run: () => __awaiter(void 0, void 0, void 0, function* () {
25
- const osInfo = yield systeminformation_1.default.osInfo();
26
- const versions = yield systeminformation_1.default.versions('npm, node');
27
- consola_1.default.box([
1
+ import { defineCommand } from '@robingenz/zli';
2
+ import consola from 'consola';
3
+ import systeminformation from 'systeminformation';
4
+ import pkg from '../../package.json' with { type: 'json' };
5
+ export default defineCommand({
6
+ description: 'Prints out neccessary information for debugging',
7
+ action: async (options, args) => {
8
+ const osInfo = await systeminformation.osInfo();
9
+ const versions = await systeminformation.versions('npm, node');
10
+ consola.box([
28
11
  `NodeJS version: ${versions.node}`,
29
12
  `NPM version: ${versions.npm}`,
30
- `CLI version: ${package_json_1.default.version}`,
13
+ `CLI version: ${pkg.version}`,
31
14
  `OS: ${osInfo.distro} ${osInfo.release} ${osInfo.codename ? `(${osInfo.codename})` : ''}`,
32
15
  ].join('\n'));
33
- }),
16
+ },
34
17
  });
@@ -1,46 +1,26 @@
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 axios_1 = require("axios");
16
- const citty_1 = require("citty");
17
- const consola_1 = __importDefault(require("consola"));
18
- const open_1 = __importDefault(require("open"));
19
- const config_1 = __importDefault(require("../services/config"));
20
- const session_code_1 = __importDefault(require("../services/session-code"));
21
- const sessions_1 = __importDefault(require("../services/sessions"));
22
- const users_1 = __importDefault(require("../services/users"));
23
- const error_1 = require("../utils/error");
24
- const prompt_1 = require("../utils/prompt");
25
- const userConfig_1 = __importDefault(require("../utils/userConfig"));
26
- exports.default = (0, citty_1.defineCommand)({
27
- meta: {
28
- name: 'login',
29
- description: 'Sign in to the Capawesome Cloud Console.',
30
- },
31
- args: {
32
- token: {
33
- type: 'string',
34
- description: 'Token to use for authentication.',
35
- },
36
- },
37
- run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
38
- var _a;
39
- const consoleBaseUrl = yield config_1.default.getValueForKey('CONSOLE_BASE_URL');
40
- let sessionIdOrToken = ctx.args.token;
1
+ import { defineCommand, defineOptions } from '@robingenz/zli';
2
+ import { AxiosError } from 'axios';
3
+ import consola from 'consola';
4
+ import open from 'open';
5
+ import { z } from 'zod';
6
+ import configService from '../services/config.js';
7
+ import sessionCodesService from '../services/session-code.js';
8
+ import sessionsService from '../services/sessions.js';
9
+ import usersService from '../services/users.js';
10
+ import { getMessageFromUnknownError } from '../utils/error.js';
11
+ import { prompt } from '../utils/prompt.js';
12
+ import userConfig from '../utils/userConfig.js';
13
+ export default defineCommand({
14
+ description: 'Sign in to the Capawesome Cloud Console.',
15
+ options: defineOptions(z.object({
16
+ token: z.string().optional().describe('Token to use for authentication.'),
17
+ })),
18
+ action: async (options, args) => {
19
+ const consoleBaseUrl = await configService.getValueForKey('CONSOLE_BASE_URL');
20
+ let { token: sessionIdOrToken } = options;
41
21
  if (sessionIdOrToken === undefined) {
42
22
  // @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
43
- const authenticationMethod = yield (0, prompt_1.prompt)('How would you like to authenticate Capawesome CLI?', {
23
+ const authenticationMethod = await prompt('How would you like to authenticate Capawesome CLI?', {
44
24
  type: 'select',
45
25
  options: [
46
26
  { label: 'Login with a web browser', value: 'browser' },
@@ -49,89 +29,88 @@ exports.default = (0, citty_1.defineCommand)({
49
29
  });
50
30
  if (authenticationMethod === 'browser') {
51
31
  // Create a session code
52
- const { id: deviceCode, code: userCode } = yield session_code_1.default.create();
53
- consola_1.default.box(`Copy your one-time code: ${userCode.slice(0, 4)}-${userCode.slice(4)}`);
32
+ const { id: deviceCode, code: userCode } = await sessionCodesService.create();
33
+ consola.box(`Copy your one-time code: ${userCode.slice(0, 4)}-${userCode.slice(4)}`);
54
34
  // Prompt the user to open the authorization URL in their browser
55
- const shouldProceed = yield (0, prompt_1.prompt)(`Select Yes to continue in your browser or No to cancel the authentication.`, {
35
+ const shouldProceed = await prompt(`Select Yes to continue in your browser or No to cancel the authentication.`, {
56
36
  type: 'confirm',
57
37
  initial: true,
58
38
  });
59
39
  if (!shouldProceed) {
60
- consola_1.default.error('Authentication cancelled.');
40
+ consola.error('Authentication cancelled.');
61
41
  process.exit(1);
62
42
  }
63
43
  // Open the authorization URL in the user's default browser
64
- consola_1.default.start('Opening browser...');
44
+ consola.start('Opening browser...');
65
45
  const authorizationUrl = `${consoleBaseUrl}/login/device`;
66
46
  try {
67
- (0, open_1.default)(authorizationUrl);
47
+ open(authorizationUrl);
68
48
  }
69
49
  catch (error) {
70
- consola_1.default.warn(`Could not open browser automatically. Please open the following URL manually: ${authorizationUrl}`);
50
+ consola.warn(`Could not open browser automatically. Please open the following URL manually: ${authorizationUrl}`);
71
51
  }
72
52
  // Wait for the user to authenticate
73
- consola_1.default.start('Waiting for authentication...');
74
- const sessionId = yield createSession(deviceCode);
53
+ consola.start('Waiting for authentication...');
54
+ const sessionId = await createSession(deviceCode);
75
55
  if (!sessionId) {
76
- consola_1.default.error('Authentication timed out. Please try again.');
56
+ consola.error('Authentication timed out. Please try again.');
77
57
  process.exit(1);
78
58
  }
79
59
  sessionIdOrToken = sessionId;
80
60
  }
81
61
  else {
82
- sessionIdOrToken = yield (0, prompt_1.prompt)('Please provide your authentication token:', {
62
+ sessionIdOrToken = await prompt('Please provide your authentication token:', {
83
63
  type: 'text',
84
64
  });
85
65
  if (!sessionIdOrToken) {
86
- consola_1.default.error('Token must be provided.');
66
+ consola.error('Token must be provided.');
87
67
  process.exit(1);
88
68
  }
89
69
  }
90
70
  }
91
71
  else if (sessionIdOrToken.length === 0) {
92
72
  // No token provided
93
- consola_1.default.error(`Please provide a valid token. You can create a token at ${consoleBaseUrl}/settings/tokens.`);
73
+ consola.error(`Please provide a valid token. You can create a token at ${consoleBaseUrl}/settings/tokens.`);
94
74
  process.exit(1);
95
75
  }
96
76
  // Sign in with the provided token
97
- consola_1.default.start('Signing in...');
98
- userConfig_1.default.write({
77
+ consola.start('Signing in...');
78
+ userConfig.write({
99
79
  token: sessionIdOrToken,
100
80
  });
101
81
  try {
102
- yield users_1.default.me();
103
- consola_1.default.success(`Successfully signed in.`);
82
+ await usersService.me();
83
+ consola.success(`Successfully signed in.`);
104
84
  }
105
85
  catch (error) {
106
- userConfig_1.default.write({});
107
- let message = (0, error_1.getMessageFromUnknownError)(error);
108
- if (error instanceof axios_1.AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
86
+ userConfig.write({});
87
+ let message = getMessageFromUnknownError(error);
88
+ if (error instanceof AxiosError && error.response?.status === 401) {
109
89
  message = `Invalid token. Please provide a valid token. You can create a token at ${consoleBaseUrl}/settings/tokens.`;
110
90
  }
111
- consola_1.default.error(message);
91
+ consola.error(message);
112
92
  process.exit(1);
113
93
  }
114
- }),
94
+ },
115
95
  });
116
- const createSession = (deviceCode) => __awaiter(void 0, void 0, void 0, function* () {
117
- var _a;
96
+ const createSession = async (deviceCode) => {
118
97
  const maxAttempts = 20;
119
98
  const interval = 3 * 1000; // 3 seconds
120
99
  let attempts = 0;
121
100
  let sessionId = null;
122
101
  while (attempts < maxAttempts && sessionId === null) {
123
102
  try {
124
- const response = yield sessions_1.default.create({
103
+ const response = await sessionsService.create({
125
104
  code: deviceCode,
126
105
  provider: 'code',
127
106
  });
128
107
  sessionId = response.id;
129
108
  }
130
109
  catch (error) {
131
- if (error instanceof axios_1.AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 400) {
110
+ if (error instanceof AxiosError && error.response?.status === 400) {
132
111
  // Session not ready yet, wait and try again
133
112
  attempts++;
134
- yield new Promise((resolve) => setTimeout(resolve, interval));
113
+ await new Promise((resolve) => setTimeout(resolve, interval));
135
114
  }
136
115
  else {
137
116
  throw error;
@@ -139,4 +118,4 @@ const createSession = (deviceCode) => __awaiter(void 0, void 0, void 0, function
139
118
  }
140
119
  }
141
120
  return sessionId;
142
- });
121
+ };
@@ -1,34 +1,16 @@
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 authorization_service_1 = __importDefault(require("../services/authorization-service"));
18
- const sessions_1 = __importDefault(require("../services/sessions"));
19
- const userConfig_1 = __importDefault(require("../utils/userConfig"));
20
- exports.default = (0, citty_1.defineCommand)({
21
- meta: {
22
- name: 'logout',
23
- description: 'Sign out from the Capawesome Cloud Console.',
24
- },
25
- args: {},
26
- run: () => __awaiter(void 0, void 0, void 0, function* () {
27
- const token = authorization_service_1.default.getCurrentAuthorizationToken();
1
+ import { defineCommand } from '@robingenz/zli';
2
+ import consola from 'consola';
3
+ import authorizationService from '../services/authorization-service.js';
4
+ import sessionsService from '../services/sessions.js';
5
+ import userConfig from '../utils/userConfig.js';
6
+ export default defineCommand({
7
+ description: 'Sign out from the Capawesome Cloud Console.',
8
+ action: async (options, args) => {
9
+ const token = authorizationService.getCurrentAuthorizationToken();
28
10
  if (token && !token.startsWith('ca_')) {
29
- yield sessions_1.default.delete({ id: token }).catch(() => { });
11
+ await sessionsService.delete({ id: token }).catch(() => { });
30
12
  }
31
- userConfig_1.default.write({});
32
- consola_1.default.success('Successfully signed out.');
33
- }),
13
+ userConfig.write({});
14
+ consola.success('Successfully signed out.');
15
+ },
34
16
  });
@@ -1,51 +1,33 @@
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 file_1 = require("../../utils/file");
18
- const manifest_1 = require("../../utils/manifest");
19
- const prompt_1 = require("../../utils/prompt");
20
- exports.default = (0, citty_1.defineCommand)({
21
- meta: {
22
- description: 'Generate a manifest file.',
23
- },
24
- args: {
25
- path: {
26
- type: 'string',
27
- description: 'Path to the web assets folder (e.g. `www` or `dist`).',
28
- },
29
- },
30
- run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
31
- let path = ctx.args.path;
1
+ import { defineCommand, defineOptions } from '@robingenz/zli';
2
+ import consola from 'consola';
3
+ import { z } from 'zod';
4
+ import { fileExistsAtPath } from '../../utils/file.js';
5
+ import { generateManifestJson } from '../../utils/manifest.js';
6
+ import { prompt } from '../../utils/prompt.js';
7
+ export default defineCommand({
8
+ description: 'Generate a manifest file.',
9
+ options: defineOptions(z.object({
10
+ path: z.string().optional().describe('Path to the web assets folder (e.g. `www` or `dist`).'),
11
+ })),
12
+ action: async (options, args) => {
13
+ let path = options.path;
32
14
  if (!path) {
33
- path = yield (0, prompt_1.prompt)('Enter the path to the web assets folder:', {
15
+ path = await prompt('Enter the path to the web assets folder:', {
34
16
  type: 'text',
35
17
  });
36
18
  if (!path) {
37
- consola_1.default.error('You must provide a path to the web assets folder.');
19
+ consola.error('You must provide a path to the web assets folder.');
38
20
  process.exit(1);
39
21
  }
40
22
  }
41
23
  // Check if the path exists
42
- const pathExists = yield (0, file_1.fileExistsAtPath)(path);
24
+ const pathExists = await fileExistsAtPath(path);
43
25
  if (!pathExists) {
44
- consola_1.default.error(`The path does not exist.`);
26
+ consola.error(`The path does not exist.`);
45
27
  process.exit(1);
46
28
  }
47
29
  // Generate the manifest file
48
- yield (0, manifest_1.generateManifestJson)(path);
49
- consola_1.default.success('Manifest file generated.');
50
- }),
30
+ await generateManifestJson(path);
31
+ consola.success('Manifest file generated.');
32
+ },
51
33
  });
@@ -1,41 +1,24 @@
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 users_1 = __importDefault(require("../services/users"));
18
- const userConfig_1 = __importDefault(require("../utils/userConfig"));
19
- exports.default = (0, citty_1.defineCommand)({
20
- meta: {
21
- name: 'whoami',
22
- description: 'Show current user',
23
- },
24
- run: () => __awaiter(void 0, void 0, void 0, function* () {
25
- const { token } = userConfig_1.default.read();
1
+ import { defineCommand } from '@robingenz/zli';
2
+ import consola from 'consola';
3
+ import usersService from '../services/users.js';
4
+ import userConfig from '../utils/userConfig.js';
5
+ export default defineCommand({
6
+ description: 'Show current user',
7
+ action: async (options, args) => {
8
+ const { token } = userConfig.read();
26
9
  if (token) {
27
10
  try {
28
- const user = yield users_1.default.me();
29
- consola_1.default.info(`Logged in as ${user.email}.`);
11
+ const user = await usersService.me();
12
+ consola.info(`Logged in as ${user.email}.`);
30
13
  }
31
14
  catch (error) {
32
- consola_1.default.error('Token is invalid. Please sign in again.');
15
+ consola.error('Token is invalid. Please sign in again.');
33
16
  process.exit(1);
34
17
  }
35
18
  }
36
19
  else {
37
- consola_1.default.error('Not logged in.');
20
+ consola.error('Not logged in.');
38
21
  process.exit(1);
39
22
  }
40
- }),
23
+ },
41
24
  });
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAX_CONCURRENT_UPLOADS = exports.MANIFEST_JSON_FILE_NAME = void 0;
4
- exports.MANIFEST_JSON_FILE_NAME = 'capawesome-live-update-manifest.json'; // Do NOT change this!
5
- exports.MAX_CONCURRENT_UPLOADS = 20;
1
+ export const MANIFEST_JSON_FILE_NAME = 'capawesome-live-update-manifest.json'; // Do NOT change this!
2
+ export const MAX_CONCURRENT_UPLOADS = 20;
@@ -1,17 +1 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./consts"), exports);
1
+ export * from './consts.js';