@capawesome/cli 1.13.2 → 1.14.0-dev.3b0fc7e.1755934102
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 +7 -3
- package/dist/commands/apps/bundles/create.js +218 -234
- package/dist/commands/apps/bundles/create.test.js +276 -0
- package/dist/commands/apps/bundles/delete.js +47 -55
- package/dist/commands/apps/bundles/delete.test.js +139 -0
- package/dist/commands/apps/bundles/update.js +73 -84
- package/dist/commands/apps/bundles/update.test.js +141 -0
- package/dist/commands/apps/channels/create.js +57 -70
- package/dist/commands/apps/channels/create.test.js +119 -0
- package/dist/commands/apps/channels/delete.js +58 -64
- package/dist/commands/apps/channels/delete.test.js +141 -0
- package/dist/commands/apps/channels/get.js +52 -94
- package/dist/commands/apps/channels/get.test.js +135 -0
- package/dist/commands/apps/channels/list.js +37 -82
- package/dist/commands/apps/channels/list.test.js +121 -0
- package/dist/commands/apps/channels/update.js +50 -77
- package/dist/commands/apps/channels/update.test.js +138 -0
- package/dist/commands/apps/create.js +39 -42
- package/dist/commands/apps/create.test.js +117 -0
- package/dist/commands/apps/delete.js +41 -45
- package/dist/commands/apps/delete.test.js +120 -0
- package/dist/commands/apps/devices/delete.js +47 -55
- package/dist/commands/apps/devices/delete.test.js +139 -0
- package/dist/commands/doctor.js +12 -29
- package/dist/commands/doctor.test.js +52 -0
- package/dist/commands/login.js +50 -71
- package/dist/commands/login.test.js +116 -0
- package/dist/commands/logout.js +13 -31
- package/dist/commands/logout.test.js +47 -0
- package/dist/commands/manifests/generate.js +20 -38
- package/dist/commands/manifests/generate.test.js +60 -0
- package/dist/commands/organizations/create.js +25 -0
- package/dist/commands/organizations/create.test.js +80 -0
- package/dist/commands/whoami.js +20 -31
- package/dist/commands/whoami.test.js +30 -0
- package/dist/config/consts.js +4 -5
- package/dist/config/index.js +1 -17
- package/dist/index.js +54 -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 +25 -41
- package/dist/services/authorization-service.js +4 -8
- package/dist/services/config.js +15 -28
- package/dist/services/organizations.js +26 -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 +12 -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/private-key.js +23 -0
- package/dist/utils/prompt.js +9 -26
- package/dist/utils/signature.js +3 -39
- package/dist/utils/user-config.js +12 -0
- package/dist/utils/zip.js +11 -27
- package/package.json +22 -9
- package/dist/utils/ci.js +0 -7
- package/dist/utils/userConfig.js +0 -16
package/dist/services/users.js
CHANGED
|
@@ -1,33 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 http_client_1 = __importDefault(require("../utils/http-client"));
|
|
16
|
-
const authorization_service_1 = __importDefault(require("./authorization-service"));
|
|
1
|
+
import httpClient from '../utils/http-client.js';
|
|
2
|
+
import authorizationService from '../services/authorization-service.js';
|
|
17
3
|
class UsersServiceImpl {
|
|
4
|
+
httpClient;
|
|
18
5
|
constructor(httpClient) {
|
|
19
6
|
this.httpClient = httpClient;
|
|
20
7
|
}
|
|
21
|
-
me() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
return response.data;
|
|
8
|
+
async me() {
|
|
9
|
+
const response = await this.httpClient.get('/v1/users/me', {
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${authorizationService.getCurrentAuthorizationToken()}`,
|
|
12
|
+
},
|
|
29
13
|
});
|
|
14
|
+
return response.data;
|
|
30
15
|
}
|
|
31
16
|
}
|
|
32
|
-
const usersService = new UsersServiceImpl(
|
|
33
|
-
|
|
17
|
+
const usersService = new UsersServiceImpl(httpClient);
|
|
18
|
+
export default usersService;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types/app-bundle.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types/app-device.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types/app.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types/index.js
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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("./app"), exports);
|
|
18
|
-
__exportStar(require("./app-bundle"), exports);
|
|
19
|
-
__exportStar(require("./app-channel"), exports);
|
|
20
|
-
__exportStar(require("./app-device"), exports);
|
|
21
|
-
__exportStar(require("./session"), exports);
|
|
22
|
-
__exportStar(require("./session-code"), exports);
|
|
23
|
-
__exportStar(require("./user"), exports);
|
|
1
|
+
export * from './app-bundle.js';
|
|
2
|
+
export * from './app-channel.js';
|
|
3
|
+
export * from './app-device.js';
|
|
4
|
+
export * from './app.js';
|
|
5
|
+
export * from './organization.js';
|
|
6
|
+
export * from './session-code.js';
|
|
7
|
+
export * from './session.js';
|
|
8
|
+
export * from './user.js';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -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,10 @@ const createBufferFromReadStream = (data) => __awaiter(void 0, void 0, void 0, f
|
|
|
53
17
|
});
|
|
54
18
|
data.on('error', reject);
|
|
55
19
|
});
|
|
56
|
-
}
|
|
57
|
-
|
|
20
|
+
};
|
|
21
|
+
export const createBufferFromString = (content) => {
|
|
22
|
+
return Buffer.from(content, 'utf8');
|
|
23
|
+
};
|
|
24
|
+
export const isPrivateKeyContent = (input) => {
|
|
25
|
+
return input.includes('-----BEGIN') && input.includes('PRIVATE KEY-----');
|
|
26
|
+
};
|
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
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const formatPrivateKey = (privateKey) => {
|
|
2
|
+
// Extract the header, key data, and footer using regex that preserves spaces
|
|
3
|
+
const beginMatch = privateKey.match(/-----BEGIN [^-]+ ?-----/);
|
|
4
|
+
const endMatch = privateKey.match(/-----END [^-]+ ?-----/);
|
|
5
|
+
if (!beginMatch || !endMatch) {
|
|
6
|
+
return privateKey; // Return as-is if not properly formatted PEM
|
|
7
|
+
}
|
|
8
|
+
const header = beginMatch[0];
|
|
9
|
+
const footer = endMatch[0];
|
|
10
|
+
// Remove all whitespace from the entire key, then find the positions
|
|
11
|
+
const cleanKey = privateKey.replace(/\s/g, '');
|
|
12
|
+
const cleanHeader = header.replace(/\s/g, '');
|
|
13
|
+
const cleanFooter = footer.replace(/\s/g, '');
|
|
14
|
+
const headerEnd = cleanKey.indexOf(cleanHeader) + cleanHeader.length;
|
|
15
|
+
const footerStart = cleanKey.indexOf(cleanFooter);
|
|
16
|
+
if (headerEnd >= footerStart) {
|
|
17
|
+
return privateKey; // Return as-is if structure is invalid
|
|
18
|
+
}
|
|
19
|
+
const keyData = cleanKey.substring(headerEnd, footerStart);
|
|
20
|
+
// Split the key data into 64-character lines
|
|
21
|
+
const formattedKeyData = keyData.match(/.{1,64}/g)?.join('\n') || keyData;
|
|
22
|
+
return `${header}\n${formattedKeyData}\n${footer}`;
|
|
23
|
+
};
|
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
|
+
};
|