@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types/session.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types/user.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/utils/buffer.js
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.createBufferFromReadStream = exports.createBufferFromPath = void 0;
|
|
36
|
-
const createBufferFromPath = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
const fs = yield Promise.resolve().then(() => __importStar(require('fs')));
|
|
1
|
+
export const createBufferFromPath = async (path) => {
|
|
2
|
+
const fs = await import('fs');
|
|
38
3
|
const stream = fs.createReadStream(path);
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const createBufferFromReadStream = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4
|
+
return createBufferFromReadStream(stream);
|
|
5
|
+
};
|
|
6
|
+
export const createBufferFromReadStream = async (data) => {
|
|
43
7
|
const chunks = [];
|
|
44
8
|
return new Promise((resolve, reject) => {
|
|
45
9
|
data.on('readable', () => {
|
|
@@ -53,5 +17,4 @@ const createBufferFromReadStream = (data) => __awaiter(void 0, void 0, void 0, f
|
|
|
53
17
|
});
|
|
54
18
|
data.on('error', reject);
|
|
55
19
|
});
|
|
56
|
-
}
|
|
57
|
-
exports.createBufferFromReadStream = createBufferFromReadStream;
|
|
20
|
+
};
|
package/dist/utils/error.js
CHANGED
|
@@ -1,32 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const axios_1 = require("axios");
|
|
5
|
-
const getMessageFromUnknownError = (error) => {
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { ZodError } from 'zod';
|
|
3
|
+
export const getMessageFromUnknownError = (error) => {
|
|
6
4
|
let message = 'An unknown error has occurred.';
|
|
7
|
-
if (error instanceof
|
|
5
|
+
if (error instanceof AxiosError) {
|
|
8
6
|
message = getErrorMessageFromAxiosError(error);
|
|
9
7
|
}
|
|
8
|
+
else if (error instanceof ZodError) {
|
|
9
|
+
message = getErrorMessageFromZodError(error);
|
|
10
|
+
}
|
|
10
11
|
else if (error instanceof Error) {
|
|
11
12
|
message = error.message;
|
|
12
13
|
}
|
|
13
14
|
return message;
|
|
14
15
|
};
|
|
15
|
-
exports.getMessageFromUnknownError = getMessageFromUnknownError;
|
|
16
16
|
const getErrorMessageFromAxiosError = (error) => {
|
|
17
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
18
17
|
let message = 'An unknown network error has occurred.';
|
|
19
|
-
if (
|
|
18
|
+
if (error.response?.status === 401) {
|
|
20
19
|
message = 'Your token is no longer valid. Please sign in again.';
|
|
21
20
|
}
|
|
22
|
-
else if (
|
|
23
|
-
message =
|
|
21
|
+
else if (error.response?.status === 403) {
|
|
22
|
+
message = 'You do not have permission to access this resource.';
|
|
23
|
+
}
|
|
24
|
+
else if (error.response?.data?.message) {
|
|
25
|
+
message = error.response?.data?.message;
|
|
24
26
|
}
|
|
25
|
-
else if (
|
|
26
|
-
message = (
|
|
27
|
+
else if (error.response?.data?.error?.issues[0]?.message) {
|
|
28
|
+
message = (error.response?.data).error.issues[0].message;
|
|
27
29
|
}
|
|
28
|
-
else if (
|
|
30
|
+
else if (error.response?.data && typeof error.response?.data === 'string') {
|
|
29
31
|
message = error.response.data;
|
|
30
32
|
}
|
|
31
33
|
return message;
|
|
32
34
|
};
|
|
35
|
+
const getErrorMessageFromZodError = (error) => {
|
|
36
|
+
let message = 'An unknown validation error has occurred. Please check your input.';
|
|
37
|
+
const firstIssue = error.issues[0];
|
|
38
|
+
if (firstIssue) {
|
|
39
|
+
message = firstIssue.message;
|
|
40
|
+
}
|
|
41
|
+
return message;
|
|
42
|
+
};
|
package/dist/utils/file.js
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
exports.writeFile = exports.isDirectory = exports.fileExistsAtPath = exports.getFilesInDirectoryAndSubdirectories = void 0;
|
|
16
|
-
const fs_1 = __importDefault(require("fs"));
|
|
17
|
-
const mime_1 = __importDefault(require("mime"));
|
|
18
|
-
const path_1 = __importDefault(require("path"));
|
|
19
|
-
const getFilesInDirectoryAndSubdirectories = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import mime from 'mime';
|
|
3
|
+
import pathModule from 'path';
|
|
4
|
+
export const getFilesInDirectoryAndSubdirectories = async (path) => {
|
|
20
5
|
const files = [];
|
|
21
|
-
const walk = (directory) =>
|
|
22
|
-
const dirEntries =
|
|
6
|
+
const walk = async (directory) => {
|
|
7
|
+
const dirEntries = await fs.promises.readdir(directory, { withFileTypes: true }).catch(() => []);
|
|
23
8
|
for (const dirEntry of dirEntries) {
|
|
24
|
-
const fullPath =
|
|
9
|
+
const fullPath = pathModule.join(directory, dirEntry.name);
|
|
25
10
|
if (dirEntry.isDirectory()) {
|
|
26
|
-
|
|
11
|
+
await walk(fullPath);
|
|
27
12
|
}
|
|
28
13
|
else {
|
|
29
|
-
let pathToReplace =
|
|
14
|
+
let pathToReplace = pathModule.normalize(path);
|
|
30
15
|
// Remove the leading './' from the path
|
|
31
16
|
if (pathToReplace.startsWith('./')) {
|
|
32
17
|
pathToReplace = pathToReplace.replace('./', '');
|
|
@@ -40,36 +25,33 @@ const getFilesInDirectoryAndSubdirectories = (path) => __awaiter(void 0, void 0,
|
|
|
40
25
|
}
|
|
41
26
|
files.push({
|
|
42
27
|
href,
|
|
43
|
-
mimeType:
|
|
28
|
+
mimeType: mime.getType(dirEntry.name) || 'application/octet-stream',
|
|
44
29
|
name: dirEntry.name,
|
|
45
30
|
path: fullPath,
|
|
46
31
|
});
|
|
47
32
|
}
|
|
48
33
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
34
|
+
};
|
|
35
|
+
await walk(path);
|
|
51
36
|
return files;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const fileExistsAtPath = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
};
|
|
38
|
+
export const fileExistsAtPath = async (path) => {
|
|
55
39
|
return new Promise((resolve) => {
|
|
56
|
-
|
|
40
|
+
fs.access(path, fs.constants.F_OK, (err) => {
|
|
57
41
|
resolve(!err);
|
|
58
42
|
});
|
|
59
43
|
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const isDirectory = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
};
|
|
45
|
+
export const isDirectory = async (path) => {
|
|
63
46
|
return new Promise((resolve) => {
|
|
64
|
-
|
|
47
|
+
fs.lstat(path, (err, stats) => {
|
|
65
48
|
resolve(stats.isDirectory());
|
|
66
49
|
});
|
|
67
50
|
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const writeFile = (path, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
};
|
|
52
|
+
export const writeFile = async (path, data) => {
|
|
71
53
|
return new Promise((resolve, reject) => {
|
|
72
|
-
|
|
54
|
+
fs.writeFile(path, data, (err) => {
|
|
73
55
|
if (err) {
|
|
74
56
|
reject(err);
|
|
75
57
|
}
|
|
@@ -78,5 +60,4 @@ const writeFile = (path, data) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
78
60
|
}
|
|
79
61
|
});
|
|
80
62
|
});
|
|
81
|
-
}
|
|
82
|
-
exports.writeFile = writeFile;
|
|
63
|
+
};
|
package/dist/utils/hash.js
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.createHash = void 0;
|
|
36
|
-
const createHash = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
const crypto = yield Promise.resolve().then(() => __importStar(require('crypto')));
|
|
1
|
+
export const createHash = async (data) => {
|
|
2
|
+
const crypto = await import('crypto');
|
|
38
3
|
return crypto.createHash('sha256').update(data).digest('hex');
|
|
39
|
-
}
|
|
40
|
-
exports.createHash = createHash;
|
|
4
|
+
};
|
|
@@ -1,61 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 = __importDefault(require("axios"));
|
|
16
|
-
const package_json_1 = require("../../package.json");
|
|
17
|
-
const config_1 = __importDefault(require("../services/config"));
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import pkg from '../../package.json' with { type: 'json' };
|
|
3
|
+
import configService from '../services/config.js';
|
|
18
4
|
class HttpClientImpl {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
baseHeaders = {
|
|
6
|
+
'User-Agent': `Capawesome CLI v${pkg.version}`,
|
|
7
|
+
};
|
|
8
|
+
async delete(url, config) {
|
|
9
|
+
const baseUrl = await configService.getValueForKey('API_BASE_URL');
|
|
10
|
+
const urlWithHost = url.startsWith('http') ? url : baseUrl + url;
|
|
11
|
+
return axios.delete(urlWithHost, { ...config, headers: { ...this.baseHeaders, ...config?.headers } });
|
|
23
12
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return axios_1.default.delete(urlWithHost, Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, this.baseHeaders), config === null || config === void 0 ? void 0 : config.headers) }));
|
|
29
|
-
});
|
|
13
|
+
async get(url, config) {
|
|
14
|
+
const baseUrl = await configService.getValueForKey('API_BASE_URL');
|
|
15
|
+
const urlWithHost = url.startsWith('http') ? url : baseUrl + url;
|
|
16
|
+
return axios.get(urlWithHost, { ...config, headers: { ...this.baseHeaders, ...config?.headers } });
|
|
30
17
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return axios_1.default.get(urlWithHost, Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, this.baseHeaders), config === null || config === void 0 ? void 0 : config.headers) }));
|
|
36
|
-
});
|
|
18
|
+
async patch(url, data, config) {
|
|
19
|
+
const baseUrl = await configService.getValueForKey('API_BASE_URL');
|
|
20
|
+
const urlWithHost = url.startsWith('http') ? url : baseUrl + url;
|
|
21
|
+
return axios.patch(urlWithHost, data, { ...config, headers: { ...this.baseHeaders, ...config?.headers } });
|
|
37
22
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return axios_1.default.patch(urlWithHost, data, Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, this.baseHeaders), config === null || config === void 0 ? void 0 : config.headers) }));
|
|
43
|
-
});
|
|
23
|
+
async post(url, data, config) {
|
|
24
|
+
const baseUrl = await configService.getValueForKey('API_BASE_URL');
|
|
25
|
+
const urlWithHost = url.startsWith('http') ? url : baseUrl + url;
|
|
26
|
+
return axios.post(urlWithHost, data, { ...config, headers: { ...this.baseHeaders, ...config?.headers } });
|
|
44
27
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return axios_1.default.post(urlWithHost, data, Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, this.baseHeaders), config === null || config === void 0 ? void 0 : config.headers) }));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
put(url, data, config) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const baseUrl = yield config_1.default.getValueForKey('API_BASE_URL');
|
|
55
|
-
const urlWithHost = url.startsWith('http') ? url : baseUrl + url;
|
|
56
|
-
return axios_1.default.put(urlWithHost, data, Object.assign(Object.assign({}, config), { headers: Object.assign(Object.assign({}, this.baseHeaders), config === null || config === void 0 ? void 0 : config.headers) }));
|
|
57
|
-
});
|
|
28
|
+
async put(url, data, config) {
|
|
29
|
+
const baseUrl = await configService.getValueForKey('API_BASE_URL');
|
|
30
|
+
const urlWithHost = url.startsWith('http') ? url : baseUrl + url;
|
|
31
|
+
return axios.put(urlWithHost, data, { ...config, headers: { ...this.baseHeaders, ...config?.headers } });
|
|
58
32
|
}
|
|
59
33
|
}
|
|
60
34
|
let httpClient = new HttpClientImpl();
|
|
61
|
-
|
|
35
|
+
export default httpClient;
|
package/dist/utils/manifest.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.generateManifestJson = void 0;
|
|
13
|
-
const config_1 = require("../config");
|
|
14
|
-
const buffer_1 = require("./buffer");
|
|
15
|
-
const file_1 = require("./file");
|
|
16
|
-
const hash_1 = require("./hash");
|
|
17
|
-
const ignoreFiles = ['.DS_Store', config_1.MANIFEST_JSON_FILE_NAME];
|
|
18
|
-
const generateManifestJson = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1
|
+
import { MANIFEST_JSON_FILE_NAME } from '../config/index.js';
|
|
2
|
+
import { createBufferFromPath } from './buffer.js';
|
|
3
|
+
import { getFilesInDirectoryAndSubdirectories, writeFile } from './file.js';
|
|
4
|
+
import { createHash } from './hash.js';
|
|
5
|
+
const ignoreFiles = ['.DS_Store', MANIFEST_JSON_FILE_NAME];
|
|
6
|
+
export const generateManifestJson = async (path) => {
|
|
19
7
|
const manifestItems = [];
|
|
20
8
|
// Get all files
|
|
21
|
-
const files =
|
|
9
|
+
const files = await getFilesInDirectoryAndSubdirectories(path);
|
|
22
10
|
// Iterate over each file
|
|
23
11
|
for (const [index, file] of files.entries()) {
|
|
24
|
-
const fileBuffer =
|
|
25
|
-
const checksum =
|
|
12
|
+
const fileBuffer = await createBufferFromPath(file.path);
|
|
13
|
+
const checksum = await createHash(fileBuffer);
|
|
26
14
|
const sizeInBytes = fileBuffer.byteLength;
|
|
27
15
|
// Skip ignored files
|
|
28
16
|
if (ignoreFiles.includes(file.name)) {
|
|
@@ -35,6 +23,5 @@ const generateManifestJson = (path) => __awaiter(void 0, void 0, void 0, functio
|
|
|
35
23
|
});
|
|
36
24
|
}
|
|
37
25
|
// Write the manifest file
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
exports.generateManifestJson = generateManifestJson;
|
|
26
|
+
writeFile(`${path}/${MANIFEST_JSON_FILE_NAME}`, JSON.stringify(manifestItems, null, 2));
|
|
27
|
+
};
|
package/dist/utils/prompt.js
CHANGED
|
@@ -1,40 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
exports.passwordPrompt = exports.prompt = void 0;
|
|
16
|
-
const prompts_1 = require("@clack/prompts");
|
|
17
|
-
const consola_1 = __importDefault(require("consola"));
|
|
18
|
-
const prompt = (message, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
options = Object.assign(Object.assign({}, (options || {})), { cancel: 'symbol' });
|
|
20
|
-
const response = yield consola_1.default.prompt(message, options);
|
|
1
|
+
import { password as clackPassword } from '@clack/prompts';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
export const prompt = async (message, options) => {
|
|
4
|
+
options = { ...(options || {}), cancel: 'symbol' };
|
|
5
|
+
const response = await consola.prompt(message, options);
|
|
21
6
|
// See https://github.com/unjs/consola/pull/325#issue-2751614453
|
|
22
7
|
if (response === Symbol.for('cancel')) {
|
|
23
8
|
process.exit(0);
|
|
24
9
|
}
|
|
25
10
|
return response;
|
|
26
|
-
}
|
|
27
|
-
exports.prompt = prompt;
|
|
11
|
+
};
|
|
28
12
|
/**
|
|
29
13
|
* This is a workaround to support password prompts.
|
|
30
14
|
*
|
|
31
15
|
* @see https://github.com/unjs/consola/issues/285
|
|
32
16
|
*/
|
|
33
|
-
const passwordPrompt = (message) =>
|
|
34
|
-
const result =
|
|
17
|
+
export const passwordPrompt = async (message) => {
|
|
18
|
+
const result = await clackPassword({ message });
|
|
35
19
|
if (typeof result === 'symbol') {
|
|
36
20
|
process.exit(0);
|
|
37
21
|
}
|
|
38
22
|
return result;
|
|
39
|
-
}
|
|
40
|
-
exports.passwordPrompt = passwordPrompt;
|
|
23
|
+
};
|
package/dist/utils/signature.js
CHANGED
|
@@ -1,43 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.createSignature = void 0;
|
|
36
|
-
const createSignature = (privateKey, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
const crypto = yield Promise.resolve().then(() => __importStar(require('crypto')));
|
|
1
|
+
export const createSignature = async (privateKey, data) => {
|
|
2
|
+
const crypto = await import('crypto');
|
|
38
3
|
const sign = crypto.createSign('sha256');
|
|
39
4
|
sign.update(data);
|
|
40
5
|
sign.end();
|
|
41
6
|
return sign.sign(privateKey).toString('base64');
|
|
42
|
-
}
|
|
43
|
-
exports.createSignature = createSignature;
|
|
7
|
+
};
|
package/dist/utils/userConfig.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rc9_1 = require("rc9");
|
|
1
|
+
import { readUser, writeUser } from 'rc9';
|
|
4
2
|
class UserConfigImpl {
|
|
5
|
-
|
|
6
|
-
this.file = '.capawesome';
|
|
7
|
-
}
|
|
3
|
+
file = '.capawesome';
|
|
8
4
|
read() {
|
|
9
|
-
return
|
|
5
|
+
return readUser({ name: this.file });
|
|
10
6
|
}
|
|
11
7
|
write(config) {
|
|
12
|
-
|
|
8
|
+
writeUser(config, { name: this.file });
|
|
13
9
|
}
|
|
14
10
|
}
|
|
15
11
|
const userConfig = new UserConfigImpl();
|
|
16
|
-
|
|
12
|
+
export default userConfig;
|
package/dist/utils/zip.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
|
|
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 archiver_1 = __importDefault(require("archiver"));
|
|
1
|
+
import archiver from 'archiver';
|
|
16
2
|
class ZipImpl {
|
|
17
|
-
zipFolder(sourceFolder) {
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
archive.finalize();
|
|
27
|
-
});
|
|
3
|
+
async zipFolder(sourceFolder) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
6
|
+
const buffers = [];
|
|
7
|
+
archive.on('data', (data) => buffers.push(data));
|
|
8
|
+
archive.on('error', (err) => reject(err));
|
|
9
|
+
archive.on('end', () => resolve(Buffer.concat(buffers)));
|
|
10
|
+
archive.directory(sourceFolder, false);
|
|
11
|
+
archive.finalize();
|
|
28
12
|
});
|
|
29
13
|
}
|
|
30
14
|
isZipped(path) {
|
|
@@ -32,4 +16,4 @@ class ZipImpl {
|
|
|
32
16
|
}
|
|
33
17
|
}
|
|
34
18
|
const zip = new ZipImpl();
|
|
35
|
-
|
|
19
|
+
export default zip;
|