@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.
- package/CHANGELOG.md +7 -0
- package/README.md +3 -3
- package/dist/commands/apps/bundles/create.js +206 -232
- package/dist/commands/apps/bundles/delete.js +42 -47
- package/dist/commands/apps/bundles/update.js +69 -72
- package/dist/commands/apps/channels/create.js +47 -70
- package/dist/commands/apps/channels/delete.js +53 -56
- package/dist/commands/apps/channels/get.js +27 -61
- package/dist/commands/apps/channels/list.js +26 -63
- package/dist/commands/apps/channels/update.js +48 -67
- package/dist/commands/apps/create.js +38 -38
- package/dist/commands/apps/delete.js +39 -40
- package/dist/commands/apps/devices/delete.js +42 -47
- package/dist/commands/doctor.js +12 -29
- package/dist/commands/login.js +48 -69
- package/dist/commands/logout.js +13 -31
- package/dist/commands/manifests/generate.js +20 -38
- package/dist/commands/whoami.js +13 -30
- package/dist/config/consts.js +2 -5
- package/dist/config/index.js +1 -17
- package/dist/index.js +50 -80
- package/dist/services/app-bundle-files.js +117 -136
- package/dist/services/app-bundles.js +22 -41
- package/dist/services/app-channels.js +54 -77
- package/dist/services/app-devices.js +10 -25
- package/dist/services/apps.js +24 -41
- package/dist/services/authorization-service.js +4 -8
- package/dist/services/config.js +14 -28
- package/dist/services/organizations.js +18 -0
- package/dist/services/session-code.js +7 -22
- package/dist/services/sessions.js +13 -30
- package/dist/services/update.js +17 -55
- package/dist/services/users.js +11 -26
- package/dist/types/app-bundle-file.js +1 -2
- package/dist/types/app-bundle.js +1 -2
- package/dist/types/app-channel.js +1 -2
- package/dist/types/app-device.js +1 -2
- package/dist/types/app.js +1 -2
- package/dist/types/index.js +8 -23
- package/dist/types/npm-package.js +1 -2
- package/dist/types/organization.js +1 -0
- package/dist/types/session-code.js +1 -2
- package/dist/types/session.js +1 -2
- package/dist/types/user.js +1 -2
- package/dist/utils/buffer.js +6 -43
- package/dist/utils/error.js +24 -14
- package/dist/utils/file.js +22 -41
- package/dist/utils/hash.js +3 -39
- package/dist/utils/http-client.js +27 -53
- package/dist/utils/manifest.js +11 -24
- package/dist/utils/prompt.js +9 -26
- package/dist/utils/signature.js +3 -39
- package/dist/utils/userConfig.js +5 -9
- package/dist/utils/zip.js +11 -27
- package/package.json +15 -8
- package/dist/utils/ci.js +0 -7
|
@@ -1,74 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
46
|
+
deviceId = await prompt('Enter the device ID:', {
|
|
52
47
|
type: 'text',
|
|
53
48
|
});
|
|
54
49
|
}
|
|
55
|
-
const confirmed =
|
|
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
|
-
|
|
57
|
+
await appDevicesService.delete({
|
|
63
58
|
appId,
|
|
64
59
|
deviceId,
|
|
65
60
|
});
|
|
66
|
-
|
|
61
|
+
consola.success('Device deleted successfully.');
|
|
67
62
|
}
|
|
68
63
|
catch (error) {
|
|
69
|
-
const message =
|
|
70
|
-
|
|
64
|
+
const message = getMessageFromUnknownError(error);
|
|
65
|
+
consola.error(message);
|
|
71
66
|
process.exit(1);
|
|
72
67
|
}
|
|
73
|
-
}
|
|
68
|
+
},
|
|
74
69
|
});
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,34 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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: ${
|
|
13
|
+
`CLI version: ${pkg.version}`,
|
|
31
14
|
`OS: ${osInfo.distro} ${osInfo.release} ${osInfo.codename ? `(${osInfo.codename})` : ''}`,
|
|
32
15
|
].join('\n'));
|
|
33
|
-
}
|
|
16
|
+
},
|
|
34
17
|
});
|
package/dist/commands/login.js
CHANGED
|
@@ -1,46 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
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 =
|
|
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 } =
|
|
53
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
44
|
+
consola.start('Opening browser...');
|
|
65
45
|
const authorizationUrl = `${consoleBaseUrl}/login/device`;
|
|
66
46
|
try {
|
|
67
|
-
(
|
|
47
|
+
open(authorizationUrl);
|
|
68
48
|
}
|
|
69
49
|
catch (error) {
|
|
70
|
-
|
|
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
|
-
|
|
74
|
-
const sessionId =
|
|
53
|
+
consola.start('Waiting for authentication...');
|
|
54
|
+
const sessionId = await createSession(deviceCode);
|
|
75
55
|
if (!sessionId) {
|
|
76
|
-
|
|
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 =
|
|
62
|
+
sessionIdOrToken = await prompt('Please provide your authentication token:', {
|
|
83
63
|
type: 'text',
|
|
84
64
|
});
|
|
85
65
|
if (!sessionIdOrToken) {
|
|
86
|
-
|
|
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
|
-
|
|
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
|
-
|
|
98
|
-
|
|
77
|
+
consola.start('Signing in...');
|
|
78
|
+
userConfig.write({
|
|
99
79
|
token: sessionIdOrToken,
|
|
100
80
|
});
|
|
101
81
|
try {
|
|
102
|
-
|
|
103
|
-
|
|
82
|
+
await usersService.me();
|
|
83
|
+
consola.success(`Successfully signed in.`);
|
|
104
84
|
}
|
|
105
85
|
catch (error) {
|
|
106
|
-
|
|
107
|
-
let message =
|
|
108
|
-
if (error instanceof
|
|
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
|
-
|
|
91
|
+
consola.error(message);
|
|
112
92
|
process.exit(1);
|
|
113
93
|
}
|
|
114
|
-
}
|
|
94
|
+
},
|
|
115
95
|
});
|
|
116
|
-
const createSession = (deviceCode) =>
|
|
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 =
|
|
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
|
|
110
|
+
if (error instanceof AxiosError && error.response?.status === 400) {
|
|
132
111
|
// Session not ready yet, wait and try again
|
|
133
112
|
attempts++;
|
|
134
|
-
|
|
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
|
+
};
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
+
await sessionsService.delete({ id: token }).catch(() => { });
|
|
30
12
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
13
|
+
userConfig.write({});
|
|
14
|
+
consola.success('Successfully signed out.');
|
|
15
|
+
},
|
|
34
16
|
});
|
|
@@ -1,51 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 =
|
|
15
|
+
path = await prompt('Enter the path to the web assets folder:', {
|
|
34
16
|
type: 'text',
|
|
35
17
|
});
|
|
36
18
|
if (!path) {
|
|
37
|
-
|
|
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 =
|
|
24
|
+
const pathExists = await fileExistsAtPath(path);
|
|
43
25
|
if (!pathExists) {
|
|
44
|
-
|
|
26
|
+
consola.error(`The path does not exist.`);
|
|
45
27
|
process.exit(1);
|
|
46
28
|
}
|
|
47
29
|
// Generate the manifest file
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
30
|
+
await generateManifestJson(path);
|
|
31
|
+
consola.success('Manifest file generated.');
|
|
32
|
+
},
|
|
51
33
|
});
|
package/dist/commands/whoami.js
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 =
|
|
29
|
-
|
|
11
|
+
const user = await usersService.me();
|
|
12
|
+
consola.info(`Logged in as ${user.email}.`);
|
|
30
13
|
}
|
|
31
14
|
catch (error) {
|
|
32
|
-
|
|
15
|
+
consola.error('Token is invalid. Please sign in again.');
|
|
33
16
|
process.exit(1);
|
|
34
17
|
}
|
|
35
18
|
}
|
|
36
19
|
else {
|
|
37
|
-
|
|
20
|
+
consola.error('Not logged in.');
|
|
38
21
|
process.exit(1);
|
|
39
22
|
}
|
|
40
|
-
}
|
|
23
|
+
},
|
|
41
24
|
});
|
package/dist/config/consts.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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;
|
package/dist/config/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
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';
|