@apimatic/cli 1.1.0-alpha.2 → 1.1.0-alpha.21
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/README.md +257 -101
- package/bin/run.js +5 -0
- package/lib/actions/action-result.d.ts +8 -0
- package/lib/actions/action-result.js +25 -0
- package/lib/actions/action-result.js.map +1 -0
- package/lib/actions/auth/login.d.ts +12 -0
- package/lib/actions/auth/login.js +63 -0
- package/lib/actions/auth/login.js.map +1 -0
- package/lib/actions/portal/copilot.d.ts +14 -0
- package/lib/actions/portal/copilot.js +79 -0
- package/lib/actions/portal/copilot.js.map +1 -0
- package/lib/actions/portal/generate.d.ts +14 -0
- package/lib/actions/portal/generate.js +66 -0
- package/lib/actions/portal/generate.js.map +1 -0
- package/lib/actions/portal/recipe/new-recipe.d.ts +24 -0
- package/lib/actions/portal/recipe/new-recipe.js +250 -0
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +14 -0
- package/lib/actions/portal/serve.js +24 -0
- package/lib/actions/portal/serve.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +20 -0
- package/lib/actions/portal/toc/new-toc.js +133 -0
- package/lib/actions/portal/toc/new-toc.js.map +1 -0
- package/lib/actions/sdk/generate.d.ts +14 -0
- package/lib/actions/sdk/generate.js +72 -0
- package/lib/actions/sdk/generate.js.map +1 -0
- package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
- package/lib/application/portal/recipe/portal-recipe.js +33 -0
- package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
- package/lib/application/portal/recipe/recipe-generator.d.ts +16 -0
- package/lib/application/portal/recipe/recipe-generator.js +147 -0
- package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
- package/lib/application/portal/serve/portal-watcher.d.ts +11 -0
- package/lib/application/portal/serve/portal-watcher.js +64 -0
- package/lib/application/portal/serve/portal-watcher.js.map +1 -0
- package/lib/application/portal/serve/serve-handler.d.ts +16 -0
- package/lib/application/portal/serve/serve-handler.js +91 -0
- package/lib/application/portal/serve/serve-handler.js.map +1 -0
- package/lib/application/portal/serve/watcher-handler.d.ts +10 -0
- package/lib/application/portal/serve/watcher-handler.js +51 -0
- package/lib/application/portal/serve/watcher-handler.js.map +1 -0
- package/lib/application/portal/toc/sdl-parser.d.ts +19 -0
- package/lib/application/portal/toc/sdl-parser.js +90 -0
- package/lib/application/portal/toc/sdl-parser.js.map +1 -0
- package/lib/application/portal/toc/toc-content-parser.d.ts +5 -0
- package/lib/application/portal/toc/toc-content-parser.js +44 -0
- package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
- package/lib/application/portal/toc/toc-structure-generator.d.ts +6 -0
- package/lib/application/portal/toc/toc-structure-generator.js +84 -0
- package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
- package/lib/client-utils/auth-manager.d.ts +8 -3
- package/lib/client-utils/auth-manager.js +23 -10
- package/lib/client-utils/auth-manager.js.map +1 -0
- package/lib/client-utils/sdk-client.d.ts +4 -9
- package/lib/client-utils/sdk-client.js +9 -87
- package/lib/client-utils/sdk-client.js.map +1 -0
- package/lib/commands/api/transform.d.ts +7 -7
- package/lib/commands/api/transform.js +46 -51
- package/lib/commands/api/transform.js.map +1 -0
- package/lib/commands/api/validate.d.ts +4 -4
- package/lib/commands/api/validate.js +35 -36
- package/lib/commands/api/validate.js.map +1 -0
- package/lib/commands/auth/login.d.ts +3 -2
- package/lib/commands/auth/login.js +22 -53
- package/lib/commands/auth/login.js.map +1 -0
- package/lib/commands/auth/logout.d.ts +1 -1
- package/lib/commands/auth/logout.js +8 -13
- package/lib/commands/auth/logout.js.map +1 -0
- package/lib/commands/auth/status.d.ts +1 -1
- package/lib/commands/auth/status.js +9 -13
- package/lib/commands/auth/status.js.map +1 -0
- package/lib/commands/portal/copilot.d.ts +13 -0
- package/lib/commands/portal/copilot.js +32 -0
- package/lib/commands/portal/copilot.js.map +1 -0
- package/lib/commands/portal/generate.d.ts +10 -8
- package/lib/commands/portal/generate.js +28 -107
- package/lib/commands/portal/generate.js.map +1 -0
- package/lib/commands/portal/quickstart.d.ts +10 -0
- package/lib/commands/portal/quickstart.js +114 -0
- package/lib/commands/portal/quickstart.js.map +1 -0
- package/lib/commands/portal/recipe/new.d.ts +10 -0
- package/lib/commands/portal/recipe/new.js +38 -0
- package/lib/commands/portal/recipe/new.js.map +1 -0
- package/lib/commands/portal/serve.d.ts +16 -0
- package/lib/commands/portal/serve.js +80 -0
- package/lib/commands/portal/serve.js.map +1 -0
- package/lib/commands/portal/toc/new.d.ts +14 -0
- package/lib/commands/portal/toc/new.js +52 -0
- package/lib/commands/portal/toc/new.js.map +1 -0
- package/lib/commands/sdk/generate.d.ts +9 -8
- package/lib/commands/sdk/generate.js +39 -128
- package/lib/commands/sdk/generate.js.map +1 -0
- package/lib/config/axios-config.d.ts +2 -0
- package/lib/config/axios-config.js +10 -0
- package/lib/config/axios-config.js.map +1 -0
- package/lib/config/env.d.ts +26 -1
- package/lib/config/env.js +27 -4
- package/lib/config/env.js.map +1 -0
- package/lib/controllers/api/transform.d.ts +1 -1
- package/lib/controllers/api/transform.js +23 -22
- package/lib/controllers/api/transform.js.map +1 -0
- package/lib/controllers/api/validate.d.ts +3 -3
- package/lib/controllers/api/validate.js +19 -12
- package/lib/controllers/api/validate.js.map +1 -0
- package/lib/controllers/portal/quickstart.d.ts +13 -0
- package/lib/controllers/portal/quickstart.js +214 -0
- package/lib/controllers/portal/quickstart.js.map +1 -0
- package/lib/hooks/not-found.d.ts +3 -0
- package/lib/hooks/not-found.js +52 -0
- package/lib/hooks/not-found.js.map +1 -0
- package/lib/hooks/utils.d.ts +5 -0
- package/lib/hooks/utils.js +51 -0
- package/lib/hooks/utils.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -0
- package/lib/infrastructure/api-client-utils.d.ts +6 -0
- package/lib/infrastructure/api-client-utils.js +34 -0
- package/lib/infrastructure/api-client-utils.js.map +1 -0
- package/lib/infrastructure/api-utils.d.ts +9 -0
- package/lib/infrastructure/api-utils.js +33 -0
- package/lib/infrastructure/api-utils.js.map +1 -0
- package/lib/infrastructure/env-info.d.ts +12 -0
- package/lib/infrastructure/env-info.js +58 -0
- package/lib/infrastructure/env-info.js.map +1 -0
- package/lib/infrastructure/file-service.d.ts +18 -0
- package/lib/infrastructure/file-service.js +76 -0
- package/lib/infrastructure/file-service.js.map +1 -0
- package/lib/infrastructure/launcher-service.d.ts +5 -0
- package/lib/infrastructure/launcher-service.js +47 -0
- package/lib/infrastructure/launcher-service.js.map +1 -0
- package/lib/infrastructure/services/api-service.d.ts +10 -0
- package/lib/infrastructure/services/api-service.js +55 -0
- package/lib/infrastructure/services/api-service.js.map +1 -0
- package/lib/infrastructure/services/auth-service.d.ts +11 -0
- package/lib/infrastructure/services/auth-service.js +35 -0
- package/lib/infrastructure/services/auth-service.js.map +1 -0
- package/lib/infrastructure/services/portal-service.d.ts +23 -0
- package/lib/infrastructure/services/portal-service.js +186 -0
- package/lib/infrastructure/services/portal-service.js.map +1 -0
- package/lib/infrastructure/services/telemetry-service.d.ts +8 -0
- package/lib/infrastructure/services/telemetry-service.js +40 -0
- package/lib/infrastructure/services/telemetry-service.js.map +1 -0
- package/lib/infrastructure/tmp-extensions.d.ts +2 -0
- package/lib/infrastructure/tmp-extensions.js +6 -0
- package/lib/infrastructure/tmp-extensions.js.map +1 -0
- package/lib/infrastructure/zip-service.d.ts +6 -0
- package/lib/infrastructure/zip-service.js +39 -0
- package/lib/infrastructure/zip-service.js.map +1 -0
- package/lib/prompts/auth/login.d.ts +5 -0
- package/lib/prompts/auth/login.js +13 -0
- package/lib/prompts/auth/login.js.map +1 -0
- package/lib/prompts/portal/common/base-prompts.d.ts +7 -0
- package/lib/prompts/portal/common/base-prompts.js +19 -0
- package/lib/prompts/portal/common/base-prompts.js.map +1 -0
- package/lib/prompts/portal/copilot.d.ts +14 -0
- package/lib/prompts/portal/copilot.js +71 -0
- package/lib/prompts/portal/copilot.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +11 -0
- package/lib/prompts/portal/generate.js +42 -0
- package/lib/prompts/portal/generate.js.map +1 -0
- package/lib/prompts/portal/quickstart.d.ts +30 -0
- package/lib/prompts/portal/quickstart.js +240 -0
- package/lib/prompts/portal/quickstart.js.map +1 -0
- package/lib/prompts/portal/recipe/new-recipe.d.ts +24 -0
- package/lib/prompts/portal/recipe/new-recipe.js +203 -0
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +4 -0
- package/lib/prompts/portal/serve.js +14 -0
- package/lib/prompts/portal/serve.js.map +1 -0
- package/lib/prompts/portal/toc/new-toc.d.ts +11 -0
- package/lib/prompts/portal/toc/new-toc.js +39 -0
- package/lib/prompts/portal/toc/new-toc.js.map +1 -0
- package/lib/prompts/sdk/generate.d.ts +11 -0
- package/lib/prompts/sdk/generate.js +42 -0
- package/lib/prompts/sdk/generate.js.map +1 -0
- package/lib/types/api/account.d.ts +10 -0
- package/lib/types/api/account.js +2 -0
- package/lib/types/api/account.js.map +1 -0
- package/lib/types/api/transform.d.ts +19 -4
- package/lib/types/api/transform.js +19 -4
- package/lib/types/api/transform.js.map +1 -0
- package/lib/types/api/validate.d.ts +3 -3
- package/lib/types/api/validate.js +2 -2
- package/lib/types/api/validate.js.map +1 -0
- package/lib/types/build/build.d.ts +14 -0
- package/lib/types/build/build.js +4 -0
- package/lib/types/build/build.js.map +1 -0
- package/lib/types/build-context.d.ts +13 -0
- package/lib/types/build-context.js +30 -0
- package/lib/types/build-context.js.map +1 -0
- package/lib/types/common/result.d.ts +17 -0
- package/lib/types/common/result.js +32 -0
- package/lib/types/common/result.js.map +1 -0
- package/lib/types/events/domain-event.d.ts +8 -0
- package/lib/types/events/domain-event.js +11 -0
- package/lib/types/events/domain-event.js.map +1 -0
- package/lib/types/events/quickstart-completed.d.ts +7 -0
- package/lib/types/events/quickstart-completed.js +10 -0
- package/lib/types/events/quickstart-completed.js.map +1 -0
- package/lib/types/events/quickstart-initiated.d.ts +7 -0
- package/lib/types/events/quickstart-initiated.js +10 -0
- package/lib/types/events/quickstart-initiated.js.map +1 -0
- package/lib/types/events/recipe-creation-failed.d.ts +5 -0
- package/lib/types/events/recipe-creation-failed.js +8 -0
- package/lib/types/events/recipe-creation-failed.js.map +1 -0
- package/lib/types/events/toc-creation-failed.d.ts +5 -0
- package/lib/types/events/toc-creation-failed.js +8 -0
- package/lib/types/events/toc-creation-failed.js.map +1 -0
- package/lib/types/file/directoryPath.d.ts +7 -0
- package/lib/types/file/directoryPath.js +16 -0
- package/lib/types/file/directoryPath.js.map +1 -0
- package/lib/types/file/fileName.d.ts +5 -0
- package/lib/types/file/fileName.js +9 -0
- package/lib/types/file/fileName.js.map +1 -0
- package/lib/types/file/filePath.d.ts +8 -0
- package/lib/types/file/filePath.js +11 -0
- package/lib/types/file/filePath.js.map +1 -0
- package/lib/types/flags-provider.d.ts +15 -0
- package/lib/types/flags-provider.js +34 -0
- package/lib/types/flags-provider.js.map +1 -0
- package/lib/types/portal/generate.d.ts +13 -9
- package/lib/types/portal/generate.js +3 -2
- package/lib/types/portal/generate.js.map +1 -0
- package/lib/types/portal/quickstart.d.ts +17 -0
- package/lib/types/portal/quickstart.js +2 -0
- package/lib/types/portal/quickstart.js.map +1 -0
- package/lib/types/portal/serve.d.ts +12 -0
- package/lib/types/portal/serve.js +2 -0
- package/lib/types/portal/serve.js.map +1 -0
- package/lib/types/portal-context.d.ts +11 -0
- package/lib/types/portal-context.js +28 -0
- package/lib/types/portal-context.js.map +1 -0
- package/lib/types/recipe/recipe.d.ts +37 -0
- package/lib/types/recipe/recipe.js +6 -0
- package/lib/types/recipe/recipe.js.map +1 -0
- package/lib/types/sdk/generate.d.ts +11 -10
- package/lib/types/sdk/generate.js +11 -12
- package/lib/types/sdk/generate.js.map +1 -0
- package/lib/types/sdk-context.d.ts +13 -0
- package/lib/types/sdk-context.js +28 -0
- package/lib/types/sdk-context.js.map +1 -0
- package/lib/types/sdl/sdl.d.ts +12 -0
- package/lib/types/sdl/sdl.js +2 -0
- package/lib/types/sdl/sdl.js.map +1 -0
- package/lib/types/spec-context.d.ts +7 -0
- package/lib/types/spec-context.js +12 -0
- package/lib/types/spec-context.js.map +1 -0
- package/lib/types/toc/toc.d.ts +31 -0
- package/lib/types/toc/toc.js +9 -0
- package/lib/types/toc/toc.js.map +1 -0
- package/lib/types/utils.d.ts +3 -3
- package/lib/types/utils.js +2 -2
- package/lib/types/utils.js.map +1 -0
- package/lib/utils/utils.d.ts +16 -7
- package/lib/utils/utils.js +142 -86
- package/lib/utils/utils.js.map +1 -0
- package/lib/validators/common/directoryValidator.d.ts +5 -0
- package/lib/validators/common/directoryValidator.js +22 -0
- package/lib/validators/common/directoryValidator.js.map +1 -0
- package/lib/validators/portal/serve-validator.d.ts +6 -0
- package/lib/validators/portal/serve-validator.js +15 -0
- package/lib/validators/portal/serve-validator.js.map +1 -0
- package/package.json +100 -43
- package/bin/run +0 -5
- package/lib/controllers/portal/generate.d.ts +0 -2
- package/lib/controllers/portal/generate.js +0 -49
- package/lib/controllers/sdk/generate.d.ts +0 -4
- package/lib/controllers/sdk/generate.js +0 -64
package/lib/types/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":""}
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { loggers, ValidationMessages } from "../types/utils.js";
|
|
2
|
+
export declare const createTempDirectory: () => Promise<string>;
|
|
3
|
+
export declare const clearDirectory: (folderPath: string) => Promise<void>;
|
|
4
|
+
interface DirectoryNode {
|
|
5
|
+
[key: string]: DirectoryNode | string | null | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare const directoryToJson: (dirPath: string, parentPath?: string) => DirectoryNode;
|
|
8
|
+
export declare const isValidUrl: (input: string) => boolean;
|
|
5
9
|
export declare const deleteFile: (filePath: string) => Promise<void>;
|
|
6
10
|
export declare const writeFileUsingReadableStream: (stream: NodeJS.ReadableStream, destinationPath: string) => Promise<unknown>;
|
|
7
11
|
/**
|
|
@@ -12,9 +16,14 @@ export declare const writeFileUsingReadableStream: (stream: NodeJS.ReadableStrea
|
|
|
12
16
|
* return {string}
|
|
13
17
|
*/
|
|
14
18
|
export declare const zipDirectory: (sourcePath: string, destinationPath: string) => Promise<string>;
|
|
15
|
-
export declare const startProgress: (title: string) => void;
|
|
16
|
-
export declare const stopProgress: (isError?: boolean) => void | null;
|
|
17
19
|
export declare const replaceHTML: (string: string) => string;
|
|
18
|
-
export declare const isJSONParsable: (json: string) => boolean;
|
|
19
20
|
export declare const getFileNameFromPath: (filePath: string) => string;
|
|
20
21
|
export declare const printValidationMessages: ({ warnings, errors, messages }: ValidationMessages, { log, warn, error }: loggers) => void;
|
|
22
|
+
export declare function parseStreamBodyToJson(body: NodeJS.ReadableStream): Promise<any>;
|
|
23
|
+
export declare const getMessageInOrangeColor: (message: string) => string;
|
|
24
|
+
export declare const getMessageInBlueColor: (message: string) => string;
|
|
25
|
+
export declare const getMessageInCyanColor: (message: string) => string;
|
|
26
|
+
export declare const getMessageInGreenColor: (message: string) => string;
|
|
27
|
+
export declare const getMessageInMagentaColor: (message: string) => string;
|
|
28
|
+
export declare const getMessageInRedColor: (message: string) => string;
|
|
29
|
+
export {};
|
package/lib/utils/utils.js
CHANGED
|
@@ -1,34 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { __asyncValues } from "tslib";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import fsExtra from "fs-extra";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import archiver from "archiver";
|
|
7
|
+
import stripTags from "striptags";
|
|
8
|
+
import colors from "picocolors";
|
|
9
|
+
export const createTempDirectory = async () => {
|
|
10
|
+
return fs.mkdtempSync(path.join(os.tmpdir(), "apimatic-cli-"));
|
|
11
|
+
};
|
|
12
|
+
export const clearDirectory = async (folderPath) => {
|
|
13
|
+
if (!fs.existsSync(folderPath)) {
|
|
14
|
+
throw new Error(`Directory ${folderPath} does not exist`);
|
|
15
|
+
}
|
|
16
|
+
const files = await fsExtra.readdir(folderPath);
|
|
17
|
+
for (const file of files) {
|
|
18
|
+
const filePath = path.join(folderPath, file);
|
|
19
|
+
await deleteFile(filePath);
|
|
20
|
+
}
|
|
21
|
+
await deleteFile(folderPath);
|
|
22
|
+
};
|
|
23
|
+
// TODO: Move to portal:quickstart command.
|
|
24
|
+
const descriptions = Object.entries({
|
|
25
|
+
"APIMATIC-BUILD.json": "# Defines all configurations for the API portal, including programming languages and themes",
|
|
26
|
+
spec: "# Contains all API definition files",
|
|
27
|
+
content: "# Includes custom documentation pages in Markdown",
|
|
28
|
+
"content/toc.yml": "# Controls the structure of the side navigation bar in the API portal",
|
|
29
|
+
static: "# Includes all static files, such as images, GIFs, and PDFs"
|
|
30
|
+
}).reduce((acc, [key, value]) => {
|
|
31
|
+
acc[path.normalize(key)] = value;
|
|
32
|
+
return acc;
|
|
33
|
+
}, {});
|
|
34
|
+
// TODO: Move to portal:quickstart command.
|
|
35
|
+
export const directoryToJson = (dirPath, parentPath = "") => {
|
|
36
|
+
const directoryStructure = {};
|
|
37
|
+
const items = fs.readdirSync(dirPath);
|
|
38
|
+
items.forEach((item) => {
|
|
39
|
+
if (item === ".git")
|
|
40
|
+
return; // Skip .git directory
|
|
41
|
+
const itemPath = path.join(dirPath, item);
|
|
42
|
+
const relativePath = path.join(parentPath, item);
|
|
43
|
+
const stats = fs.statSync(itemPath);
|
|
44
|
+
if (stats.isDirectory()) {
|
|
45
|
+
const subdirectoryStructure = directoryToJson(itemPath, relativePath);
|
|
46
|
+
const folderName = descriptions[path.normalize(relativePath)]
|
|
47
|
+
? `${item} : ${descriptions[path.normalize(relativePath)]}`
|
|
48
|
+
: item;
|
|
49
|
+
directoryStructure[folderName] = subdirectoryStructure;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
directoryStructure[descriptions[path.normalize(relativePath)] ? `${item} : ${descriptions[path.normalize(relativePath)]}` : item] = null;
|
|
53
|
+
}
|
|
19
54
|
});
|
|
55
|
+
return directoryStructure;
|
|
20
56
|
};
|
|
21
|
-
|
|
22
|
-
|
|
57
|
+
export const isValidUrl = (input) => {
|
|
58
|
+
if (!input) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const url = new URL(input);
|
|
63
|
+
if (!["http:", "https:"].includes(url.protocol)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (url.protocol === "file:" || fs.existsSync(input)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (!url.host) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
catch (_) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
23
77
|
};
|
|
24
|
-
|
|
25
|
-
return
|
|
78
|
+
export const deleteFile = async (filePath) => {
|
|
79
|
+
return await fsExtra.remove(filePath);
|
|
80
|
+
};
|
|
81
|
+
export const writeFileUsingReadableStream = (stream, destinationPath) => {
|
|
82
|
+
return new Promise((resolve) => {
|
|
26
83
|
const writeStream = fs.createWriteStream(destinationPath);
|
|
27
84
|
stream.pipe(writeStream);
|
|
28
|
-
writeStream.on("close", (
|
|
29
|
-
if (error) {
|
|
30
|
-
return reject(new Error("Couldn't zip the stream"));
|
|
31
|
-
}
|
|
85
|
+
writeStream.on("close", () => {
|
|
32
86
|
resolve("Zipped");
|
|
33
87
|
});
|
|
34
88
|
});
|
|
@@ -40,82 +94,84 @@ exports.writeFileUsingReadableStream = (stream, destinationPath) => {
|
|
|
40
94
|
* @param {destinationZipPath} path to generated zip
|
|
41
95
|
* return {string}
|
|
42
96
|
*/
|
|
43
|
-
|
|
97
|
+
export const zipDirectory = async (sourcePath, destinationPath) => {
|
|
44
98
|
// Check if the directory exists for the user or not
|
|
45
|
-
await
|
|
46
|
-
const zipPath = path.join(destinationPath, "target.zip");
|
|
99
|
+
await fsExtra.ensureDir(sourcePath);
|
|
100
|
+
const zipPath = path.join(destinationPath, ".target.zip");
|
|
47
101
|
const output = fs.createWriteStream(zipPath);
|
|
48
102
|
const archive = archiver("zip");
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// TODO: I didn't mean to say that we should create a fake progress bar when we
|
|
63
|
-
// set the requirements to include progress bar. You should get the download or
|
|
64
|
-
// upload progress by tracking how much of the steam has been read/written and
|
|
65
|
-
// compare that with the remaining size of the stream (in case of upload, you
|
|
66
|
-
// get size from the file size and in case of download, you get it from the
|
|
67
|
-
// content-type header). In case the progress can not be calculated, show a
|
|
68
|
-
// spinner.
|
|
69
|
-
exports.startProgress = (title) => {
|
|
70
|
-
progressBar = cli_ux_1.default.progress({
|
|
71
|
-
format: `${title} | {bar}`,
|
|
72
|
-
barCompleteChar: "\u2588",
|
|
73
|
-
barIncompleteChar: "\u2591"
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
archive.on("error", (err) => {
|
|
105
|
+
reject(new Error(err.message));
|
|
106
|
+
});
|
|
107
|
+
output.on("error", (err) => {
|
|
108
|
+
reject(new Error(err.message));
|
|
109
|
+
});
|
|
110
|
+
output.on("close", () => {
|
|
111
|
+
resolve(zipPath);
|
|
112
|
+
});
|
|
113
|
+
archive.pipe(output);
|
|
114
|
+
archive.directory(sourcePath, false);
|
|
115
|
+
archive.finalize().catch(reject);
|
|
74
116
|
});
|
|
75
|
-
progressBar.start();
|
|
76
|
-
const total = 100;
|
|
77
|
-
let count = 0;
|
|
78
|
-
const iv = setInterval(() => {
|
|
79
|
-
count++;
|
|
80
|
-
progressBar.update(count);
|
|
81
|
-
if (count === total - 1) {
|
|
82
|
-
clearInterval(iv);
|
|
83
|
-
}
|
|
84
|
-
}, 50);
|
|
85
117
|
};
|
|
86
|
-
|
|
87
|
-
if (isError) {
|
|
88
|
-
return progressBar ? progressBar.stop() : null;
|
|
89
|
-
}
|
|
90
|
-
progressBar.update(100);
|
|
91
|
-
return progressBar.stop();
|
|
92
|
-
};
|
|
93
|
-
exports.replaceHTML = (string) => {
|
|
118
|
+
export const replaceHTML = (string) => {
|
|
94
119
|
return stripTags(string);
|
|
95
120
|
};
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
JSON.parse(json);
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
catch (e) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
exports.getFileNameFromPath = (filePath) => {
|
|
121
|
+
export const getFileNameFromPath = (filePath) => {
|
|
106
122
|
return path.basename(filePath).split(".")[0];
|
|
107
123
|
};
|
|
108
|
-
|
|
124
|
+
export const printValidationMessages = ({ warnings, errors, messages }, { log, warn, error }) => {
|
|
109
125
|
warnings = warnings || [];
|
|
110
126
|
messages = messages || [];
|
|
111
127
|
const singleError = errors.join("\n") || "";
|
|
112
128
|
messages.forEach((message) => {
|
|
113
|
-
log(`Info: ${
|
|
129
|
+
log(`Info: ${replaceHTML(message)}`);
|
|
114
130
|
});
|
|
115
131
|
warnings.forEach((warning) => {
|
|
116
|
-
warn(
|
|
132
|
+
warn(replaceHTML(warning));
|
|
117
133
|
});
|
|
118
134
|
if (errors.length > 0) {
|
|
119
|
-
error(
|
|
135
|
+
error(replaceHTML(singleError));
|
|
120
136
|
}
|
|
121
137
|
};
|
|
138
|
+
export async function parseStreamBodyToJson(body) {
|
|
139
|
+
var _a, e_1, _b, _c;
|
|
140
|
+
const chunks = [];
|
|
141
|
+
try {
|
|
142
|
+
for (var _d = true, body_1 = __asyncValues(body), body_1_1; body_1_1 = await body_1.next(), _a = body_1_1.done, !_a; _d = true) {
|
|
143
|
+
_c = body_1_1.value;
|
|
144
|
+
_d = false;
|
|
145
|
+
const chunk = _c;
|
|
146
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
150
|
+
finally {
|
|
151
|
+
try {
|
|
152
|
+
if (!_d && !_a && (_b = body_1.return)) await _b.call(body_1);
|
|
153
|
+
}
|
|
154
|
+
finally { if (e_1) throw e_1.error; }
|
|
155
|
+
}
|
|
156
|
+
const text = Buffer.concat(chunks).toString("utf-8");
|
|
157
|
+
return JSON.parse(text);
|
|
158
|
+
}
|
|
159
|
+
export const getMessageInOrangeColor = (message) => {
|
|
160
|
+
return colors.yellow(message);
|
|
161
|
+
};
|
|
162
|
+
export const getMessageInBlueColor = (message) => {
|
|
163
|
+
return colors.blueBright(message);
|
|
164
|
+
};
|
|
165
|
+
export const getMessageInCyanColor = (message) => {
|
|
166
|
+
return colors.cyan(message);
|
|
167
|
+
};
|
|
168
|
+
export const getMessageInGreenColor = (message) => {
|
|
169
|
+
return colors.greenBright(message);
|
|
170
|
+
};
|
|
171
|
+
export const getMessageInMagentaColor = (message) => {
|
|
172
|
+
return colors.magentaBright(message);
|
|
173
|
+
};
|
|
174
|
+
export const getMessageInRedColor = (message) => {
|
|
175
|
+
return col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AC,OAAO,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAe,EAAE,EAAE;IACtD,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import fsExtra from "fs-extra";
|
|
2
|
+
import { readdirSync } from "fs";
|
|
3
|
+
import { Result } from "../../types/common/result.js";
|
|
4
|
+
export class DirectoryValidator {
|
|
5
|
+
validateSourceDirectory(sourceDir) {
|
|
6
|
+
if (!fsExtra.pathExistsSync(sourceDir)) {
|
|
7
|
+
return Result.failure(`The specified source directory does not exist: ${sourceDir}. Please provide a valid source directory to continue.`);
|
|
8
|
+
}
|
|
9
|
+
const sourceDirItems = this.getDirectoryItems(sourceDir);
|
|
10
|
+
if (sourceDirItems.length == 0) {
|
|
11
|
+
return Result.failure("The source directory is empty. Please ensure that the directory contains a valid build input.");
|
|
12
|
+
}
|
|
13
|
+
if (!sourceDirItems.some((item) => item.endsWith("APIMATIC-BUILD.json"))) {
|
|
14
|
+
return Result.failure("The source directory is missing the 'APIMATIC-BUILD.json' file. Please add a valid build config file to continue.");
|
|
15
|
+
}
|
|
16
|
+
return Result.success(`Source directory ${sourceDir} is valid.`);
|
|
17
|
+
}
|
|
18
|
+
getDirectoryItems(directoryPath) {
|
|
19
|
+
return readdirSync(directoryPath).filter((item) => !item.startsWith("."));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=directoryValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directoryValidator.js","sourceRoot":"","sources":["../../../src/validators/common/directoryValidator.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,MAAM,OAAO,kBAAkB;IACtB,uBAAuB,CAAC,SAAiB;QAC9C,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;YACvC,OAAO,MAAM,CAAC,OAAO,CACnB,kDAAkD,SAAS,wDAAwD,CACpH,CAAC;QACJ,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACzD,IAAI,cAAc,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC,OAAO,CACnB,+FAA+F,CAChG,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC;YACzE,OAAO,MAAM,CAAC,OAAO,CACnB,mHAAmH,CACpH,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,OAAO,CAAC,oBAAoB,SAAS,YAAY,CAAC,CAAC;IACnE,CAAC;IAEO,iBAAiB,CAAC,aAAqB;QAC7C,OAAO,WAAW,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5E,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from "../../types/common/result.js";
|
|
2
|
+
import { DirectoryValidator } from "../common/directoryValidator.js";
|
|
3
|
+
export class PortalServeValidator {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.directoryValidator = new DirectoryValidator();
|
|
6
|
+
}
|
|
7
|
+
async validateSourceDirectory(sourceDirectoryPath) {
|
|
8
|
+
const sourceDirectoryValidationResult = this.directoryValidator.validateSourceDirectory(sourceDirectoryPath);
|
|
9
|
+
if (sourceDirectoryValidationResult.isFailed()) {
|
|
10
|
+
return Result.failure(sourceDirectoryValidationResult.error);
|
|
11
|
+
}
|
|
12
|
+
return Result.success("Serve flags validated successfully.");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=serve-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve-validator.js","sourceRoot":"","sources":["../../../src/validators/portal/serve-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,OAAO,oBAAoB;IAG/B;QACE,IAAI,CAAC,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,mBAA2B;QAC9D,MAAM,+BAA+B,GAAG,IAAI,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;QAC7G,IAAI,+BAA+B,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC/C,OAAO,MAAM,CAAC,OAAO,CAAC,+BAA+B,CAAC,KAAM,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,MAAM,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apimatic/cli",
|
|
3
3
|
"description": "The official CLI for APIMatic.",
|
|
4
|
-
"version": "1.1.0-alpha.
|
|
4
|
+
"version": "1.1.0-alpha.21",
|
|
5
5
|
"author": "APIMatic",
|
|
6
6
|
"bin": {
|
|
7
|
-
"apimatic": "./bin/run"
|
|
7
|
+
"apimatic": "./bin/run.js"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/apimatic/apimatic-cli/issues",
|
|
11
|
+
"email": "support@apimatic.io"
|
|
8
12
|
},
|
|
9
|
-
"bugs": "https://github.com/apimatic/apimatic-cli/issues",
|
|
10
13
|
"publishConfig": {
|
|
11
14
|
"access": "public"
|
|
12
15
|
},
|
|
13
16
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
17
|
+
"node": ">=20.0.0"
|
|
15
18
|
},
|
|
16
19
|
"files": [
|
|
17
|
-
"
|
|
18
|
-
"
|
|
20
|
+
"./bin",
|
|
21
|
+
"./lib",
|
|
19
22
|
"/npm-shrinkwrap.json",
|
|
20
23
|
"/oclif.manifest.json"
|
|
21
24
|
],
|
|
22
25
|
"repository": "git://github.com/apimatic/apimatic-cli.git",
|
|
23
|
-
"homepage": "https://
|
|
26
|
+
"homepage": "https://docs.apimatic.io/apimatic-cli/intro-and-install/",
|
|
24
27
|
"keywords": [
|
|
25
28
|
"apimatic",
|
|
26
29
|
"cli",
|
|
@@ -30,76 +33,130 @@
|
|
|
30
33
|
"automation"
|
|
31
34
|
],
|
|
32
35
|
"license": "MIT",
|
|
36
|
+
"type": "module",
|
|
33
37
|
"main": "lib/index.js",
|
|
34
38
|
"types": "lib/index.d.ts",
|
|
35
39
|
"scripts": {
|
|
36
40
|
"build": "tsc -b",
|
|
37
41
|
"postpack": "rimraf oclif.manifest.json",
|
|
38
|
-
"posttest": "eslint . --ext .ts
|
|
39
|
-
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
42
|
+
"posttest": "eslint . --ext .ts",
|
|
40
43
|
"prettier": "prettier \"src/**/*.{js,ts}\"",
|
|
41
44
|
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
|
42
45
|
"lint": "eslint \"src/**/*.{js,ts}\"",
|
|
43
|
-
"lint:fix": "eslint --fix \"src/**/*.{js,ts}\" --quiet"
|
|
46
|
+
"lint:fix": "eslint --fix \"src/**/*.{js,ts}\" --quiet",
|
|
47
|
+
"test": "tsx node_modules/mocha/bin/_mocha --forbid-only \"test/**/*.test.ts\" --timeout 99999"
|
|
44
48
|
},
|
|
45
49
|
"dependencies": {
|
|
46
|
-
"@apimatic/sdk": "^0.0
|
|
47
|
-
"@
|
|
48
|
-
"@oclif/
|
|
49
|
-
"@oclif/plugin-autocomplete": "^
|
|
50
|
-
"@oclif/plugin-help": "^
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"axios": "^
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
50
|
+
"@apimatic/sdk": "^0.2.0-alpha.4",
|
|
51
|
+
"@clack/prompts": "1.0.0-alpha.1",
|
|
52
|
+
"@oclif/core": "^4.2.8",
|
|
53
|
+
"@oclif/plugin-autocomplete": "^3.2.24",
|
|
54
|
+
"@oclif/plugin-help": "^6.2.26",
|
|
55
|
+
"archiver": "^7.0.1",
|
|
56
|
+
"async-mutex": "^0.5.0",
|
|
57
|
+
"axios": "^1.8.1",
|
|
58
|
+
"chokidar": "^3.6.0",
|
|
59
|
+
"connect-livereload": "^0.6.1",
|
|
60
|
+
"execa": "^9.6.0",
|
|
61
|
+
"express": "^4.17.1",
|
|
62
|
+
"extract-zip": "^2.0.1",
|
|
63
|
+
"fast-levenshtein": "^3.0.0",
|
|
64
|
+
"file-type": "^15.0.0",
|
|
65
|
+
"form-data": "^4.0.2",
|
|
66
|
+
"fs-extra": "^11.3.0",
|
|
67
|
+
"get-port": "^7.1.0",
|
|
68
|
+
"livereload": "^0.9.3",
|
|
69
|
+
"neverthrow": "^8.2.0",
|
|
70
|
+
"open": "^8.4.0",
|
|
71
|
+
"prettier": "^2.8.8",
|
|
57
72
|
"striptags": "^3.2.0",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
73
|
+
"tmp-promise": "^3.0.3",
|
|
74
|
+
"treeify": "^1.1.0",
|
|
75
|
+
"tslib": "^2.8.1",
|
|
76
|
+
"uuid": "^11.1.0",
|
|
77
|
+
"yaml": "^2.8.0"
|
|
60
78
|
},
|
|
61
79
|
"devDependencies": {
|
|
62
80
|
"@commitlint/cli": "^15.0.0",
|
|
63
81
|
"@commitlint/config-conventional": "^15.0.0",
|
|
64
|
-
"@oclif/
|
|
65
|
-
"@
|
|
66
|
-
"@semantic-release/changelog": "^6.0.1",
|
|
82
|
+
"@oclif/test": "^4.1.13",
|
|
83
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
67
84
|
"@semantic-release/git": "^10.0.1",
|
|
68
85
|
"@types/archiver": "^5.1.1",
|
|
69
|
-
"@types/axios": "^0.14.0",
|
|
70
86
|
"@types/base-64": "^1.0.0",
|
|
71
|
-
"@types/chai": "^4.
|
|
87
|
+
"@types/chai": "^4.3.20",
|
|
88
|
+
"@types/connect-livereload": "^0.5.32",
|
|
89
|
+
"@types/express": "^4.17.23",
|
|
90
|
+
"@types/fast-levenshtein": "^0.0.4",
|
|
72
91
|
"@types/fs-extra": "^9.0.13",
|
|
92
|
+
"@types/livereload": "^0.9.5",
|
|
73
93
|
"@types/mocha": "^5.2.7",
|
|
74
|
-
"@types/
|
|
94
|
+
"@types/mock-fs": "^4.13.4",
|
|
95
|
+
"@types/node": "^20.17.50",
|
|
96
|
+
"@types/prettier": "^2.7.3",
|
|
97
|
+
"@types/sinon": "^17.0.4",
|
|
98
|
+
"@types/treeify": "^1.0.3",
|
|
75
99
|
"@types/unzipper": "^0.10.4",
|
|
76
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
77
|
-
"@typescript-eslint/parser": "^
|
|
78
|
-
"chai": "^4.
|
|
79
|
-
"eslint": "^
|
|
100
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
101
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
102
|
+
"chai": "^4.5.0",
|
|
103
|
+
"eslint": "^9.21.0",
|
|
80
104
|
"eslint-config-prettier": "^8.3.0",
|
|
81
105
|
"eslint-plugin-import": "^2.25.2",
|
|
82
|
-
"globby": "^10.0.2",
|
|
83
106
|
"husky": "^7.0.4",
|
|
84
107
|
"lint-staged": "^11.2.6",
|
|
85
|
-
"mocha": "^
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
108
|
+
"mocha": "^11.7.1",
|
|
109
|
+
"mock-fs": "^5.5.0",
|
|
110
|
+
"nock": "^14.0.4",
|
|
111
|
+
"nyc": "^17.1.0",
|
|
112
|
+
"oclif": "^4.17.34",
|
|
113
|
+
"rimraf": "^6.0.1",
|
|
114
|
+
"sinon": "^21.0.0",
|
|
115
|
+
"ts-node": "^10.9.2",
|
|
116
|
+
"tsx": "^4.20.3",
|
|
117
|
+
"typescript": "^5.2.2"
|
|
91
118
|
},
|
|
92
119
|
"oclif": {
|
|
93
120
|
"commands": "./lib/commands",
|
|
121
|
+
"dirname": "apimatic",
|
|
94
122
|
"bin": "apimatic",
|
|
123
|
+
"description": "The official CLI for APIMatic. \nTo get started with APIMatic's CLI using a step by step wizard, run 'apimatic portal:quickstart'.",
|
|
124
|
+
"hooks": {
|
|
125
|
+
"command_not_found": "./lib/hooks/not-found"
|
|
126
|
+
},
|
|
95
127
|
"plugins": [
|
|
96
128
|
"@oclif/plugin-autocomplete",
|
|
97
|
-
"@oclif/plugin-help"
|
|
98
|
-
|
|
99
|
-
|
|
129
|
+
"@oclif/plugin-help"
|
|
130
|
+
],
|
|
131
|
+
"topics": {
|
|
132
|
+
"api": {
|
|
133
|
+
"description": "Transform & Validate your API specifications."
|
|
134
|
+
},
|
|
135
|
+
"auth": {
|
|
136
|
+
"description": "Login using your APIMatic credentials, or view your authentication status."
|
|
137
|
+
},
|
|
138
|
+
"portal": {
|
|
139
|
+
"description": "Generate, download and serve an API Documentation portal for your APIs."
|
|
140
|
+
},
|
|
141
|
+
"sdk": {
|
|
142
|
+
"description": "Generate SDKs for your APIs in multiple languages."
|
|
143
|
+
},
|
|
144
|
+
"portal:toc": {
|
|
145
|
+
"description": "Generate a Table of Contents (TOC) file for your API documentation portal."
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"state": "Alpha"
|
|
100
149
|
},
|
|
101
150
|
"lint-staged": {
|
|
102
151
|
"*.js": "eslint --cache --fix",
|
|
103
152
|
"*.{js,ts}": "prettier --write"
|
|
153
|
+
},
|
|
154
|
+
"overrides": {
|
|
155
|
+
"inflight": "npm:lru-cache@^7.14.1",
|
|
156
|
+
"lodash.get": "npm:lodash@^4.17.21",
|
|
157
|
+
"@humanwhocodes/config-array": "npm:@eslint/config-array@latest",
|
|
158
|
+
"rimraf": "^6.0.1",
|
|
159
|
+
"glob": "^10.4.5",
|
|
160
|
+
"q": "npm:promise@^8.3.0"
|
|
104
161
|
}
|
|
105
162
|
}
|
package/bin/run
DELETED