@apimatic/cli 1.1.0-beta.9 → 1.2.0
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 +117 -14
- package/lib/actions/portal/copilot.d.ts +1 -0
- package/lib/actions/portal/copilot.js +12 -12
- package/lib/actions/portal/copilot.js.map +1 -1
- package/lib/actions/portal/generate.js +7 -1
- package/lib/actions/portal/generate.js.map +1 -1
- package/lib/actions/portal/quickstart.d.ts +1 -0
- package/lib/actions/portal/quickstart.js +79 -10
- package/lib/actions/portal/quickstart.js.map +1 -1
- package/lib/actions/portal/serve.d.ts +1 -0
- package/lib/actions/portal/serve.js +77 -20
- package/lib/actions/portal/serve.js.map +1 -1
- package/lib/actions/portal/toc/new-toc.js +8 -20
- package/lib/actions/portal/toc/new-toc.js.map +1 -1
- package/lib/actions/publishing/profile/list.d.ts +11 -0
- package/lib/actions/publishing/profile/list.js +29 -0
- package/lib/actions/publishing/profile/list.js.map +1 -0
- package/lib/actions/sdk/generate.d.ts +9 -5
- package/lib/actions/sdk/generate.js +74 -46
- package/lib/actions/sdk/generate.js.map +1 -1
- package/lib/actions/sdk/merge-source-tree.d.ts +12 -0
- package/lib/actions/sdk/merge-source-tree.js +78 -0
- package/lib/actions/sdk/merge-source-tree.js.map +1 -0
- package/lib/actions/sdk/publish/interactive.d.ts +13 -0
- package/lib/actions/sdk/publish/interactive.js +105 -0
- package/lib/actions/sdk/publish/interactive.js.map +1 -0
- package/lib/actions/sdk/publish/non-interactive.d.ts +14 -0
- package/lib/actions/sdk/publish/non-interactive.js +101 -0
- package/lib/actions/sdk/publish/non-interactive.js.map +1 -0
- package/lib/actions/sdk/publish.d.ts +18 -0
- package/lib/actions/sdk/publish.js +56 -0
- package/lib/actions/sdk/publish.js.map +1 -0
- package/lib/actions/sdk/quickstart.d.ts +1 -0
- package/lib/actions/sdk/quickstart.js +19 -2
- package/lib/actions/sdk/quickstart.js.map +1 -1
- package/lib/actions/sdk/save-changes.d.ts +8 -0
- package/lib/actions/sdk/save-changes.js +93 -0
- package/lib/actions/sdk/save-changes.js.map +1 -0
- package/lib/application/portal/recipe/recipe-generator.js +14 -29
- package/lib/application/portal/recipe/recipe-generator.js.map +1 -1
- package/lib/application/portal/toc/toc-structure-generator.d.ts +3 -19
- package/lib/application/portal/toc/toc-structure-generator.js +43 -33
- package/lib/application/portal/toc/toc-structure-generator.js.map +1 -1
- package/lib/commands/portal/recipe/new.js +2 -2
- package/lib/commands/portal/recipe/new.js.map +1 -1
- package/lib/commands/portal/serve.js +3 -3
- package/lib/commands/portal/serve.js.map +1 -1
- package/lib/commands/portal/toc/new.js +2 -2
- package/lib/commands/portal/toc/new.js.map +1 -1
- package/lib/commands/publishing/profile/list.d.ts +9 -0
- package/lib/commands/publishing/profile/list.js +28 -0
- package/lib/commands/publishing/profile/list.js.map +1 -0
- package/lib/commands/quickstart.js +1 -1
- package/lib/commands/quickstart.js.map +1 -1
- package/lib/commands/sdk/generate.d.ts +6 -2
- package/lib/commands/sdk/generate.js +35 -9
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/commands/sdk/publish.d.ts +18 -0
- package/lib/commands/sdk/publish.js +73 -0
- package/lib/commands/sdk/publish.js.map +1 -0
- package/lib/commands/sdk/save-changes.d.ts +14 -0
- package/lib/commands/sdk/save-changes.js +51 -0
- package/lib/commands/sdk/save-changes.js.map +1 -0
- package/lib/hooks/not-found.js +1 -1
- package/lib/hooks/not-found.js.map +1 -1
- package/lib/infrastructure/debounce-service.js +3 -0
- package/lib/infrastructure/debounce-service.js.map +1 -1
- package/lib/infrastructure/env-info.d.ts +2 -0
- package/lib/infrastructure/env-info.js +23 -12
- package/lib/infrastructure/env-info.js.map +1 -1
- package/lib/infrastructure/file-service.d.ts +9 -0
- package/lib/infrastructure/file-service.js +94 -5
- package/lib/infrastructure/file-service.js.map +1 -1
- package/lib/infrastructure/git-service.d.ts +14 -0
- package/lib/infrastructure/git-service.js +90 -0
- package/lib/infrastructure/git-service.js.map +1 -0
- package/lib/infrastructure/launcher-service.d.ts +5 -0
- package/lib/infrastructure/launcher-service.js +35 -2
- package/lib/infrastructure/launcher-service.js.map +1 -1
- package/lib/infrastructure/os-extensions.d.ts +2 -0
- package/lib/infrastructure/os-extensions.js +6 -0
- package/lib/infrastructure/os-extensions.js.map +1 -0
- package/lib/infrastructure/service-error.d.ts +14 -2
- package/lib/infrastructure/service-error.js +26 -9
- package/lib/infrastructure/service-error.js.map +1 -1
- package/lib/infrastructure/services/api-service.d.ts +1 -0
- package/lib/infrastructure/services/api-service.js +26 -2
- package/lib/infrastructure/services/api-service.js.map +1 -1
- package/lib/infrastructure/services/portal-service.d.ts +11 -2
- package/lib/infrastructure/services/portal-service.js +123 -18
- package/lib/infrastructure/services/portal-service.js.map +1 -1
- package/lib/infrastructure/services/publishing-api-service.d.ts +19 -0
- package/lib/infrastructure/services/publishing-api-service.js +111 -0
- package/lib/infrastructure/services/publishing-api-service.js.map +1 -0
- package/lib/infrastructure/services/validation-service.d.ts +21 -0
- package/lib/infrastructure/services/validation-service.js +94 -4
- package/lib/infrastructure/services/validation-service.js.map +1 -1
- package/lib/infrastructure/zip-service.d.ts +2 -2
- package/lib/infrastructure/zip-service.js +46 -25
- package/lib/infrastructure/zip-service.js.map +1 -1
- package/lib/prompts/format.d.ts +0 -2
- package/lib/prompts/format.js +0 -31
- package/lib/prompts/format.js.map +1 -1
- package/lib/prompts/portal/generate.d.ts +1 -1
- package/lib/prompts/portal/generate.js +9 -3
- package/lib/prompts/portal/generate.js.map +1 -1
- package/lib/prompts/portal/quickstart.d.ts +11 -2
- package/lib/prompts/portal/quickstart.js +80 -13
- package/lib/prompts/portal/quickstart.js.map +1 -1
- package/lib/prompts/portal/serve.d.ts +4 -0
- package/lib/prompts/portal/serve.js +20 -1
- package/lib/prompts/portal/serve.js.map +1 -1
- package/lib/prompts/portal/toc/new-toc.d.ts +2 -2
- package/lib/prompts/portal/toc/new-toc.js +3 -3
- package/lib/prompts/portal/toc/new-toc.js.map +1 -1
- package/lib/prompts/prompt.d.ts +6 -0
- package/lib/prompts/prompt.js +45 -0
- package/lib/prompts/prompt.js.map +1 -1
- package/lib/prompts/publishing/profile/list.d.ts +9 -0
- package/lib/prompts/publishing/profile/list.js +27 -0
- package/lib/prompts/publishing/profile/list.js.map +1 -0
- package/lib/prompts/sdk/generate.d.ts +7 -3
- package/lib/prompts/sdk/generate.js +25 -13
- package/lib/prompts/sdk/generate.js.map +1 -1
- package/lib/prompts/sdk/merge-source-tree.d.ts +22 -0
- package/lib/prompts/sdk/merge-source-tree.js +90 -0
- package/lib/prompts/sdk/merge-source-tree.js.map +1 -0
- package/lib/prompts/sdk/publish/interactive.d.ts +30 -0
- package/lib/prompts/sdk/publish/interactive.js +139 -0
- package/lib/prompts/sdk/publish/interactive.js.map +1 -0
- package/lib/prompts/sdk/publish/non-interactive.d.ts +27 -0
- package/lib/prompts/sdk/publish/non-interactive.js +97 -0
- package/lib/prompts/sdk/publish/non-interactive.js.map +1 -0
- package/lib/prompts/sdk/publish.d.ts +12 -0
- package/lib/prompts/sdk/publish.js +16 -0
- package/lib/prompts/sdk/publish.js.map +1 -0
- package/lib/prompts/sdk/quickstart.d.ts +4 -1
- package/lib/prompts/sdk/quickstart.js +30 -13
- package/lib/prompts/sdk/quickstart.js.map +1 -1
- package/lib/prompts/sdk/save-changes.d.ts +21 -0
- package/lib/prompts/sdk/save-changes.js +84 -0
- package/lib/prompts/sdk/save-changes.js.map +1 -0
- package/lib/types/api/account.d.ts +1 -0
- package/lib/types/build/build.d.ts +82 -2
- package/lib/types/build/build.js +161 -0
- package/lib/types/build/build.js.map +1 -1
- package/lib/types/build-context.d.ts +14 -1
- package/lib/types/build-context.js +82 -4
- package/lib/types/build-context.js.map +1 -1
- package/lib/types/events/sdk-changes-saved.d.ts +8 -0
- package/lib/types/events/sdk-changes-saved.js +11 -0
- package/lib/types/events/sdk-changes-saved.js.map +1 -0
- package/lib/types/events/sdk-changes-tracked.d.ts +8 -0
- package/lib/types/events/sdk-changes-tracked.js +11 -0
- package/lib/types/events/sdk-changes-tracked.js.map +1 -0
- package/lib/types/events/sdk-conflicts-resolved.d.ts +8 -0
- package/lib/types/events/sdk-conflicts-resolved.js +11 -0
- package/lib/types/events/sdk-conflicts-resolved.js.map +1 -0
- package/lib/types/events/sdk-publish-validation-failed.d.ts +5 -0
- package/lib/types/events/sdk-publish-validation-failed.js +8 -0
- package/lib/types/events/sdk-publish-validation-failed.js.map +1 -0
- package/lib/types/file/directory.d.ts +10 -1
- package/lib/types/file/directory.js +63 -5
- package/lib/types/file/directory.js.map +1 -1
- package/lib/types/file/directoryPath.js.map +1 -1
- package/lib/types/file/urlPath.d.ts +4 -0
- package/lib/types/file/urlPath.js +9 -0
- package/lib/types/file/urlPath.js.map +1 -1
- package/lib/types/merge-source-tree-context.d.ts +28 -0
- package/lib/types/merge-source-tree-context.js +63 -0
- package/lib/types/merge-source-tree-context.js.map +1 -0
- package/lib/types/package-settings-context.d.ts +10 -0
- package/lib/types/package-settings-context.js +20 -0
- package/lib/types/package-settings-context.js.map +1 -0
- package/lib/types/publish/package-settings-configuration.d.ts +74 -0
- package/lib/types/publish/package-settings-configuration.js +2 -0
- package/lib/types/publish/package-settings-configuration.js.map +1 -0
- package/lib/types/publish/profile-id.d.ts +10 -0
- package/lib/types/publish/profile-id.js +22 -0
- package/lib/types/publish/profile-id.js.map +1 -0
- package/lib/types/publish/publishing-profile.d.ts +26 -0
- package/lib/types/publish/publishing-profile.js +154 -0
- package/lib/types/publish/publishing-profile.js.map +1 -0
- package/lib/types/publish/publishing-profiles.d.ts +12 -0
- package/lib/types/publish/publishing-profiles.js +36 -0
- package/lib/types/publish/publishing-profiles.js.map +1 -0
- package/lib/types/publish/version.d.ts +7 -0
- package/lib/types/publish/version.js +17 -0
- package/lib/types/publish/version.js.map +1 -0
- package/lib/types/publish-api/publish-log.d.ts +20 -0
- package/lib/types/publish-api/publish-log.js +2 -0
- package/lib/types/publish-api/publish-log.js.map +1 -0
- package/lib/types/publish-api/publishing-info.d.ts +4 -0
- package/lib/types/publish-api/publishing-info.js +2 -0
- package/lib/types/publish-api/publishing-info.js.map +1 -0
- package/lib/types/publish-api/publishing-profile-item.d.ts +190 -0
- package/lib/types/publish-api/publishing-profile-item.js +6 -0
- package/lib/types/publish-api/publishing-profile-item.js.map +1 -0
- package/lib/types/save-changes-context.d.ts +17 -0
- package/lib/types/save-changes-context.js +42 -0
- package/lib/types/save-changes-context.js.map +1 -0
- package/lib/types/sdk/generate.d.ts +18 -0
- package/lib/types/sdk/generate.js +25 -0
- package/lib/types/sdk/generate.js.map +1 -1
- package/lib/types/sdk-context.d.ts +5 -4
- package/lib/types/sdk-context.js +26 -13
- package/lib/types/sdk-context.js.map +1 -1
- package/lib/types/sdl/sdl.d.ts +0 -28
- package/lib/types/sdl/sdl.js +1 -128
- package/lib/types/sdl/sdl.js.map +1 -1
- package/lib/types/spec-context.js.map +1 -1
- package/lib/types/temp-context.js.map +1 -1
- package/lib/types/toc/toc-components.d.ts +37 -0
- package/lib/types/toc/toc-components.js +97 -0
- package/lib/types/toc/toc-components.js.map +1 -0
- package/lib/types/toc/toc.d.ts +11 -0
- package/lib/utils/string-utils.d.ts +0 -1
- package/lib/utils/string-utils.js +0 -42
- package/lib/utils/string-utils.js.map +1 -1
- package/package.json +28 -20
- package/lib/types/versioned-build-context.d.ts +0 -15
- package/lib/types/versioned-build-context.js +0 -28
- package/lib/types/versioned-build-context.js.map +0 -1
|
@@ -1,39 +1,60 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import yazl from 'yazl';
|
|
3
|
+
import AdmZip from 'adm-zip';
|
|
4
4
|
export class ZipService {
|
|
5
5
|
async archive(sourceDir, outputZipPath) {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
|
+
const zipfile = new yazl.ZipFile();
|
|
8
|
+
const addDirectory = (dir, relativePrefix) => {
|
|
9
|
+
for (const entry of fs.readdirSync(dir.toString(), { withFileTypes: true })) {
|
|
10
|
+
const fullPath = dir.join(entry.name);
|
|
11
|
+
// Always use forward slashes as metadataPath — zip format requires it
|
|
12
|
+
const metadataPath = relativePrefix ? `${relativePrefix}/${entry.name}` : entry.name;
|
|
13
|
+
if (entry.isDirectory()) {
|
|
14
|
+
addDirectory(fullPath, metadataPath);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
zipfile.addFile(fullPath.toString(), metadataPath);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
addDirectory(sourceDir, '');
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
return reject(err);
|
|
26
|
+
}
|
|
27
|
+
zipfile.end();
|
|
7
28
|
const output = fs.createWriteStream(outputZipPath.toString());
|
|
8
|
-
|
|
9
|
-
output.on(
|
|
10
|
-
|
|
11
|
-
archive.pipe(output);
|
|
12
|
-
archive.directory(sourceDir.toString(), false); // false: don't nest under folder
|
|
13
|
-
archive.finalize();
|
|
29
|
+
zipfile.outputStream.pipe(output);
|
|
30
|
+
output.on('close', resolve);
|
|
31
|
+
output.on('error', reject);
|
|
14
32
|
});
|
|
15
33
|
}
|
|
16
34
|
async unArchive(sourceFile, destinationDirectory) {
|
|
17
35
|
const MAX_FILES = 100000;
|
|
18
36
|
const MAX_SIZE = 1000000000; // 1 GB
|
|
19
|
-
|
|
37
|
+
// adm-zip extracts synchronously, with no per-entry read streams. This
|
|
38
|
+
// avoids a hang on Node 22+ where yauzl/fd-slicer (used by extract-zip)
|
|
39
|
+
// builds STORED-entry read streams that deliver every byte but never emit
|
|
40
|
+
// `end`, leaving the extraction promise pending forever — even though all
|
|
41
|
+
// files have already been written to disk — which crashes the CLI with
|
|
42
|
+
// "unsettled top-level await" / exit code 13.
|
|
43
|
+
const zip = new AdmZip(sourceFile.toString());
|
|
44
|
+
const entries = zip.getEntries();
|
|
45
|
+
if (entries.length > MAX_FILES) {
|
|
46
|
+
throw new Error('Reached max. file count');
|
|
47
|
+
}
|
|
48
|
+
// header.size is the uncompressed size declared in the zip headers, so it
|
|
49
|
+
// might not be trustworthy — kept as a cheap guard against zip bombs.
|
|
20
50
|
let totalSize = 0;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (fileCount > MAX_FILES) {
|
|
26
|
-
throw new Error("Reached max. file count");
|
|
27
|
-
}
|
|
28
|
-
// The uncompressedSize comes from the zip headers, so it might not be trustworthy.
|
|
29
|
-
// Alternatively, calculate the size from the readStream.
|
|
30
|
-
let entrySize = entry.uncompressedSize;
|
|
31
|
-
totalSize += entrySize;
|
|
32
|
-
if (totalSize > MAX_SIZE) {
|
|
33
|
-
throw new Error("Reached max. size");
|
|
34
|
-
}
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
totalSize += entry.header.size;
|
|
53
|
+
if (totalSize > MAX_SIZE) {
|
|
54
|
+
throw new Error('Reached max. size');
|
|
35
55
|
}
|
|
36
|
-
}
|
|
56
|
+
}
|
|
57
|
+
zip.extractAllTo(destinationDirectory.toString(), /* overwrite */ true);
|
|
37
58
|
}
|
|
38
59
|
}
|
|
39
60
|
//# sourceMappingURL=zip-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-service.js","sourceRoot":"","sources":["../../src/infrastructure/zip-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"zip-service.js","sourceRoot":"","sources":["../../src/infrastructure/zip-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,SAAS,CAAC;AAI7B,MAAM,OAAO,UAAU;IACd,KAAK,CAAC,OAAO,CAAC,SAAwB,EAAE,aAAuB;QACpE,OAAO,IAAI,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AAE,MAAM,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,UAAoB,EAAE,oBAAmC;QAC9E,MAAM,SAAS,GAAG,MAAO,CAAC;QAC1B,MAAM,QAAQ,GAAG,UAAa,CAAC,CAAC,OAAO;QAEvC,uEAAuE;QACvE,wEAAwE;QACxE,0EAA0E;QAC1E,0EAA0E;QAC1E,uEAAuE;QACvE,8CAA8C;QAC9C,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAEjC,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QACD,0EAA0E;QAC1E,sEAAsE;QACtE,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;YAC/B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QAED,GAAG,CAAC,YAAY,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;CACF"}
|
package/lib/prompts/format.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ActionResult } from "../actions/action-result.js";
|
|
2
|
-
import { Directory } from "../types/file/directory.js";
|
|
3
2
|
import { DirectoryPath } from "../types/file/directoryPath.js";
|
|
4
3
|
import { FilePath } from "../types/file/filePath.js";
|
|
5
4
|
export declare const format: {
|
|
@@ -20,7 +19,6 @@ export declare const format: {
|
|
|
20
19
|
};
|
|
21
20
|
export declare function intro(text: string): void;
|
|
22
21
|
export declare function outro<T>(result: ActionResult<T>): void;
|
|
23
|
-
export declare function getDirectoryTree(dir: Directory, prefix?: string, isLast?: boolean): string;
|
|
24
22
|
export interface LeafNode {
|
|
25
23
|
name: string;
|
|
26
24
|
description?: string;
|
package/lib/prompts/format.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import pc from "picocolors";
|
|
2
2
|
import { intro as i, outro as o } from '@clack/prompts';
|
|
3
|
-
import { Directory } from "../types/file/directory.js";
|
|
4
3
|
export const format = {
|
|
5
4
|
// Core element types
|
|
6
5
|
var: (text) => pc.magenta(`'${text}'`),
|
|
@@ -35,36 +34,6 @@ export function outro(result) {
|
|
|
35
34
|
o(outroMessage);
|
|
36
35
|
process.exitCode = exitCode;
|
|
37
36
|
}
|
|
38
|
-
export function getDirectoryTree(dir, prefix = "", isLast = true) {
|
|
39
|
-
const folderDescription = {
|
|
40
|
-
spec: "# Contains all API definition files",
|
|
41
|
-
content: "# Includes custom documentation pages in Markdown",
|
|
42
|
-
static: "# Includes all static files, such as images, GIFs, and PDFs"
|
|
43
|
-
};
|
|
44
|
-
const fileDescriptions = {
|
|
45
|
-
"toc.yml": "# Controls the structure of the side navigation bar in the API portal",
|
|
46
|
-
"APIMATIC-BUILD.json": "# Defines all configurations for the API portal, including programming languages and themes"
|
|
47
|
-
};
|
|
48
|
-
const pointer = isLast ? "└─ " : "├─ ";
|
|
49
|
-
const folderName = dir.directoryPath.leafName();
|
|
50
|
-
const description = folderDescription[folderName] ? format.description(folderDescription[folderName]) : "";
|
|
51
|
-
let output = `${prefix}${pointer}${folderName}${description ? " " + description : ""}\n`;
|
|
52
|
-
const items = dir.items;
|
|
53
|
-
const newPrefix = prefix + (isLast ? " " : "| ");
|
|
54
|
-
items.forEach((item, index) => {
|
|
55
|
-
const last = index === items.length - 1;
|
|
56
|
-
if (item instanceof Directory) {
|
|
57
|
-
output += getDirectoryTree(item, newPrefix, last);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const filePointer = last ? "└─ " : "├─ ";
|
|
61
|
-
const fileName = item.toString();
|
|
62
|
-
const fileDescription = fileDescriptions[fileName] ? format.description(fileDescriptions[fileName]) : "";
|
|
63
|
-
output += `${newPrefix}${filePointer}${fileName}${fileDescription ? " " + fileDescription : ""}\n`;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return output;
|
|
67
|
-
}
|
|
68
37
|
export function getTree(dir, prefix = "", isLast = true) {
|
|
69
38
|
const pointer = isLast ? "└─ " : "├─ ";
|
|
70
39
|
const folderName = dir.name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/prompts/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/prompts/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAKxD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,qBAAqB;IACrB,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,CAAC;IAC9C,IAAI,EAAE,CAAC,IAA8B,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC;IAC9D,GAAG,EAAE,CAAC,GAAW,EAAE,GAAG,IAAc,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC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
9
9
|
portalDirectoryNotEmpty(): void;
|
|
10
10
|
generatePortal(fn: Promise<Result<NodeJS.ReadableStream, ServiceError | NodeJS.ReadableStream>>): Promise<Result<NodeJS.ReadableStream, NodeJS.ReadableStream | ServiceError>>;
|
|
11
11
|
portalGenerationError(error: string): void;
|
|
12
|
-
|
|
12
|
+
portalGenerationSdkMergeFailed(sdkMergeFailedErrors: string[]): void;
|
|
13
13
|
portalGenerationErrorWithReport(reportPath: FilePath): void;
|
|
14
14
|
portalGenerated(portal: DirectoryPath): void;
|
|
15
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isCancel, confirm, log } from "@clack/prompts";
|
|
2
2
|
import { format as f } from "../format.js";
|
|
3
|
-
import { withSpinner } from "../prompt.js";
|
|
3
|
+
import { noteWrapped, withSpinner } from "../prompt.js";
|
|
4
4
|
export class PortalGeneratePrompts {
|
|
5
5
|
async overwritePortal(directory) {
|
|
6
6
|
const overwrite = await confirm({
|
|
@@ -30,8 +30,14 @@ export class PortalGeneratePrompts {
|
|
|
30
30
|
portalGenerationError(error) {
|
|
31
31
|
log.error(error);
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
log.error(
|
|
33
|
+
portalGenerationSdkMergeFailed(sdkMergeFailedErrors) {
|
|
34
|
+
log.error(`Saved changes couldn't be applied to one or more SDKs.`);
|
|
35
|
+
const language = sdkMergeFailedErrors.length === 1 ? sdkMergeFailedErrors[0] : "<language>";
|
|
36
|
+
log.error(`Merge conflicts found in:\n- ${sdkMergeFailedErrors.join("\n- ")}`);
|
|
37
|
+
const message = `Review and resolve the conflicts first by running:
|
|
38
|
+
'${f.cmdAlt("apimatic", "sdk", "generate")} ${f.flag("language", language)}'
|
|
39
|
+
After resolving merge conflicts, retry ${f.cmdAlt("apimatic", "portal", "generate")}.`;
|
|
40
|
+
noteWrapped(message, "Next Steps");
|
|
35
41
|
}
|
|
36
42
|
portalGenerationErrorWithReport(reportPath) {
|
|
37
43
|
const message = `An error occurred during portal generation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/prompts/portal/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/prompts/portal/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,OAAO,qBAAqB;IACzB,KAAK,CAAC,eAAe,CAAC,SAAwB;QACnD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;YAC9B,OAAO,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,0CAA0C;YACvF,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEM,qBAAqB,CAAC,SAAwB;QACnD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,kDAAkD,CAAC,CAAC,IAAI,CAChH,SAAS,CACV,EAAE,CAAC;QACJ,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,iBAAiB,CAAC,SAAwB;QAC/C,MAAM,OAAO,GAAG,OAAO,CA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,CAAC;IAEM,eAAe,CAAC,MAAqB;QAC1C,GAAG,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;CACF"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
|
+
import { Language } from "../../types/sdk/generate.js";
|
|
2
3
|
import { UrlPath } from "../../types/file/urlPath.js";
|
|
3
4
|
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
4
5
|
import { ServiceError } from "../../infrastructure/service-error.js";
|
|
5
6
|
import { Directory } from "../../types/file/directory.js";
|
|
6
7
|
import { ResourceInput } from "../../types/file/resource-input.js";
|
|
7
8
|
import { FileDownloadResponse } from "../../infrastructure/services/file-download-service.js";
|
|
8
|
-
import { UnallowedFeaturesResponse } from "../../infrastructure/services/validation-service.js";
|
|
9
|
+
import { BuildFilePruneReport, UnallowedFeaturesResponse } from "../../infrastructure/services/validation-service.js";
|
|
9
10
|
export declare class PortalQuickstartPrompts {
|
|
10
11
|
importSpecStep(): void;
|
|
11
12
|
specPathPrompt(defaultSpecUrl: UrlPath): Promise<ResourceInput | undefined>;
|
|
@@ -17,8 +18,12 @@ export declare class PortalQuickstartPrompts {
|
|
|
17
18
|
splitSpecDetected(unallowed: UnallowedFeaturesResponse): void;
|
|
18
19
|
stripUnallowedFeaturesStep(unallowed: UnallowedFeaturesResponse): void;
|
|
19
20
|
selectLanguagesStep(): void;
|
|
20
|
-
selectLanguagesPrompt(): Promise<string[] | undefined>;
|
|
21
|
+
selectLanguagesPrompt(allowedLanguages: Language[]): Promise<string[] | undefined>;
|
|
22
|
+
httpOnlyPortalOnPlan(): void;
|
|
23
|
+
onPremGenerationNotAllowedOnPlan(): void;
|
|
24
|
+
private languagesNotOnPlanNote;
|
|
21
25
|
noLanguagesSelected(): void;
|
|
26
|
+
buildFilePruned(report: BuildFilePruneReport): void;
|
|
22
27
|
selectInputDirectoryStep(): void;
|
|
23
28
|
inputDirectoryPathPrompt(): Promise<DirectoryPath | undefined>;
|
|
24
29
|
inputDirectoryPathDoesNotExist(inputDirectory: DirectoryPath): void;
|
|
@@ -28,6 +33,10 @@ export declare class PortalQuickstartPrompts {
|
|
|
28
33
|
downloadSpecFile(fn: Promise<Result<FileDownloadResponse, ServiceError>>): Promise<Result<FileDownloadResponse, ServiceError>>;
|
|
29
34
|
nextSteps(): void;
|
|
30
35
|
serviceError(serviceError: ServiceError): void;
|
|
36
|
+
selectCopilotKey(keys: string[]): Promise<string | undefined>;
|
|
37
|
+
noCopilotKeySelected(): void;
|
|
38
|
+
accountInfoFetchFailed(serviceError: ServiceError): void;
|
|
39
|
+
copilotEnabled(key: string): void;
|
|
31
40
|
printDirectoryStructure(inputDirectory: DirectoryPath, directory: Directory): void;
|
|
32
41
|
specValidationFailed(): void;
|
|
33
42
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isCancel, log, multiselect, select, text } from "@clack/prompts";
|
|
2
|
+
import { LANGUAGE_CHOICES } from "../../types/sdk/generate.js";
|
|
2
3
|
import { format as f, getTree } from "../format.js";
|
|
3
4
|
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
4
5
|
import { removeQuotes } from "../../utils/string-utils.js";
|
|
@@ -6,6 +7,7 @@ import { createResourceInputFromInput } from "../../types/file/resource-input.js
|
|
|
6
7
|
import { noteWrapped, withSpinner } from "../prompt.js";
|
|
7
8
|
const vscodeExtensionUrl = "https://marketplace.visualstudio.com/items?itemName=apimatic-developers.apimatic-for-vscode";
|
|
8
9
|
const referenceDocumentationUrl = "https://docs.apimatic.io/cli-getting-started/advanced-portal-setup";
|
|
10
|
+
const pricingUrl = "https://www.apimatic.io/pricing";
|
|
9
11
|
export class PortalQuickstartPrompts {
|
|
10
12
|
importSpecStep() {
|
|
11
13
|
log.info(`Step 1 of 4: Import your OpenAPI Definition`);
|
|
@@ -69,7 +71,7 @@ export class PortalQuickstartPrompts {
|
|
|
69
71
|
"To continue:",
|
|
70
72
|
"- Remove these components from your API Specification and re-run this command.",
|
|
71
73
|
"- Combine your split API Specification files into a single file. We can automatically remove unsupported components from single-file specs.",
|
|
72
|
-
|
|
74
|
+
`- Upgrade your subscription to unlock additional features: ${f.link(pricingUrl)}`
|
|
73
75
|
].join("\n");
|
|
74
76
|
log.info(message);
|
|
75
77
|
}
|
|
@@ -87,26 +89,24 @@ export class PortalQuickstartPrompts {
|
|
|
87
89
|
endpointMessage,
|
|
88
90
|
"",
|
|
89
91
|
"You won't see these components in the generated SDKs or documentation.",
|
|
90
|
-
|
|
92
|
+
`Want to keep them? Upgrade your subscription to unlock additional features: ${f.link(pricingUrl)}`
|
|
91
93
|
].join("\n");
|
|
92
94
|
log.info(message);
|
|
93
95
|
}
|
|
94
96
|
selectLanguagesStep() {
|
|
95
97
|
log.info(`Step 3 of 4: Select programming languages`);
|
|
96
98
|
}
|
|
97
|
-
async selectLanguagesPrompt() {
|
|
99
|
+
async selectLanguagesPrompt(allowedLanguages) {
|
|
100
|
+
const allowed = new Set(allowedLanguages);
|
|
101
|
+
const available = LANGUAGE_CHOICES.filter(({ value }) => allowed.has(value));
|
|
102
|
+
const excluded = LANGUAGE_CHOICES.filter(({ value }) => !allowed.has(value));
|
|
103
|
+
if (excluded.length > 0) {
|
|
104
|
+
log.info(this.languagesNotOnPlanNote(excluded.map(({ label }) => label)));
|
|
105
|
+
}
|
|
98
106
|
const languages = (await multiselect({
|
|
99
107
|
message: "Your API Portal will contain SDKs and SDK Documentation in the following Languages (HTTP is enabled by default). Press enter to continue with all languages, or use the arrow keys and space to customize your selection:",
|
|
100
|
-
options:
|
|
101
|
-
|
|
102
|
-
{ label: "Ruby", value: "ruby" },
|
|
103
|
-
{ label: "Python", value: "python" },
|
|
104
|
-
{ label: "Java", value: "java" },
|
|
105
|
-
{ label: "C#", value: "csharp" },
|
|
106
|
-
{ label: "PHP", value: "php" },
|
|
107
|
-
{ label: "Go", value: "go" }
|
|
108
|
-
],
|
|
109
|
-
initialValues: ["typescript", "ruby", "python", "java", "csharp", "php", "go"],
|
|
108
|
+
options: available.map(({ label, value }) => ({ label, value })),
|
|
109
|
+
initialValues: available.map(({ value }) => value),
|
|
110
110
|
required: false
|
|
111
111
|
}));
|
|
112
112
|
if (isCancel(languages)) {
|
|
@@ -114,9 +114,54 @@ export class PortalQuickstartPrompts {
|
|
|
114
114
|
}
|
|
115
115
|
return ["http", ...languages];
|
|
116
116
|
}
|
|
117
|
+
httpOnlyPortalOnPlan() {
|
|
118
|
+
const message = [
|
|
119
|
+
"Your current subscription plan doesn't include any SDK languages, so the portal will contain HTTP documentation only.",
|
|
120
|
+
`Upgrade your subscription to unlock SDK languages: ${f.link(pricingUrl)}`
|
|
121
|
+
].join("\n");
|
|
122
|
+
log.warn(message);
|
|
123
|
+
}
|
|
124
|
+
onPremGenerationNotAllowedOnPlan() {
|
|
125
|
+
const message = [
|
|
126
|
+
"Your current subscription plan doesn't include on-prem generation.",
|
|
127
|
+
`Upgrade your subscription to get started: ${f.link(pricingUrl)}`
|
|
128
|
+
].join("\n");
|
|
129
|
+
log.warn(message);
|
|
130
|
+
}
|
|
131
|
+
languagesNotOnPlanNote(languages) {
|
|
132
|
+
return [
|
|
133
|
+
`The following languages aren't included in your current subscription plan`,
|
|
134
|
+
...languages.map((language) => ` • ${language}`),
|
|
135
|
+
"",
|
|
136
|
+
`Upgrade your subscription to unlock them: ${f.link(pricingUrl)}`
|
|
137
|
+
].join("\n");
|
|
138
|
+
}
|
|
117
139
|
noLanguagesSelected() {
|
|
118
140
|
log.error("No programming languages were selected.");
|
|
119
141
|
}
|
|
142
|
+
buildFilePruned(report) {
|
|
143
|
+
const removed = [];
|
|
144
|
+
if (report.removedLanguages.length > 0) {
|
|
145
|
+
removed.push(`SDK languages: ${report.removedLanguages.join(", ")}`);
|
|
146
|
+
}
|
|
147
|
+
if (report.removedApiCopilot) {
|
|
148
|
+
removed.push("API Copilot");
|
|
149
|
+
}
|
|
150
|
+
if (report.removedAiIntegration) {
|
|
151
|
+
removed.push("AI context plugins (Cursor / VS Code / Claude Code)");
|
|
152
|
+
}
|
|
153
|
+
if (removed.length === 0) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const message = [
|
|
157
|
+
"Some portal features aren't on your current subscription plan and were removed before generation:",
|
|
158
|
+
"",
|
|
159
|
+
...removed.map((item) => ` • ${item}`),
|
|
160
|
+
"",
|
|
161
|
+
`Upgrade your subscription to unlock these: ${f.link(pricingUrl)}`
|
|
162
|
+
].join("\n");
|
|
163
|
+
log.warn(message);
|
|
164
|
+
}
|
|
120
165
|
selectInputDirectoryStep() {
|
|
121
166
|
log.info(`Step 4 of 4: Generate source files for Docs as Code`);
|
|
122
167
|
}
|
|
@@ -157,6 +202,28 @@ ${f.link(referenceDocumentationUrl)}`;
|
|
|
157
202
|
serviceError(serviceError) {
|
|
158
203
|
log.error(serviceError.errorMessage);
|
|
159
204
|
}
|
|
205
|
+
async selectCopilotKey(keys) {
|
|
206
|
+
const selectedKey = await select({
|
|
207
|
+
message: "Select an API Copilot key for this portal:",
|
|
208
|
+
maxItems: 10,
|
|
209
|
+
options: keys.map((key) => ({ value: key, label: key }))
|
|
210
|
+
});
|
|
211
|
+
if (isCancel(selectedKey)) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
return selectedKey;
|
|
215
|
+
}
|
|
216
|
+
noCopilotKeySelected() {
|
|
217
|
+
log.error("No API Copilot key was selected.");
|
|
218
|
+
}
|
|
219
|
+
accountInfoFetchFailed(serviceError) {
|
|
220
|
+
log.error(`Failed to fetch your account information. ${serviceError.errorMessage}`);
|
|
221
|
+
}
|
|
222
|
+
copilotEnabled(key) {
|
|
223
|
+
const message = `API Copilot is enabled with key ${f.var(key)}. ` +
|
|
224
|
+
`Any existing AI context associated with this key will be overwritten when the portal is generated.`;
|
|
225
|
+
log.warn(message);
|
|
226
|
+
}
|
|
160
227
|
printDirectoryStructure(inputDirectory, directory) {
|
|
161
228
|
const heading = `${f.var("src")} directory containing source files created at ${f.path(inputDirectory)}\n`;
|
|
162
229
|
const message = getTree(directory.toTreeNode());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/prompts/portal/quickstart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/prompts/portal/quickstart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAY,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,EAAE,4BAA4B,EAAiB,MAAM,oCAAoC,CAAC;AAEjG,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMxD,MAAM,kBAAkB,GACtB,6FAA6F,CAAC;AAChG,MAAM,yBAAyB,GAAG,oEAAoE,CAAC;AACvG,MAAM,UAAU,GAAG,iCAAiC,CAAC;AAErD,MAAM,OAAO,uBAAuB;IAC3B,cAAc;QACnB,GAAG,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IAC1D,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,cAAuB;QACjD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;YACtB,OAAO,EAAE,wEAAwE;YACjF,WAAW,EAAE,4FAA4F;YACzG,YAAY,EAAE,cAAc,CAAC,QAAQ,EAAE;YAEvC,Q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EAAE,SAAoB;QAChF,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;QAC3G,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;QAChD,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC;IAC9B,CAAC;IAEM,oBAAoB;QACzB,GAAG,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;IAChF,CAAC;CACF"}
|
|
@@ -2,6 +2,10 @@ import { UrlPath } from "../../types/file/urlPath.js";
|
|
|
2
2
|
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
3
3
|
export declare class PortalServePrompts {
|
|
4
4
|
usingFallbackPort(currentPort: number, availablePort: number): void;
|
|
5
|
+
serverStartFailed(port: number): void;
|
|
6
|
+
noPortalSource(buildDirectory: DirectoryPath): void;
|
|
7
|
+
invalidBuildConfig(buildDirectory: DirectoryPath): void;
|
|
8
|
+
baseUrlPortUpdated(updatedUrl: UrlPath): void;
|
|
5
9
|
portalServed(urlPath: UrlPath): void;
|
|
6
10
|
promptForExit(): void;
|
|
7
11
|
changesDetected(): void;
|
|
@@ -4,9 +4,28 @@ import { once } from "events";
|
|
|
4
4
|
import { noteWrapped } from "../prompt.js";
|
|
5
5
|
export class PortalServePrompts {
|
|
6
6
|
usingFallbackPort(currentPort, availablePort) {
|
|
7
|
-
const message = `Port ${f.var(currentPort.toString())} is already in use.
|
|
7
|
+
const message = `Port ${f.var(currentPort.toString())} is already in use. The portal will use port ${f.var(availablePort.toString())} instead.`;
|
|
8
8
|
log.step(message);
|
|
9
9
|
}
|
|
10
|
+
serverStartFailed(port) {
|
|
11
|
+
const message = `Could not start the portal server on port ${f.var(port.toString())}; ` +
|
|
12
|
+
`it may have just been taken by another process. Please try again.`;
|
|
13
|
+
log.error(message);
|
|
14
|
+
}
|
|
15
|
+
noPortalSource(buildDirectory) {
|
|
16
|
+
const message = `No portal source found at ${f.path(buildDirectory)}. ` +
|
|
17
|
+
`Run ${f.cmdAlt("apimatic", "portal", "quickstart")} to set one up.`;
|
|
18
|
+
log.error(message);
|
|
19
|
+
}
|
|
20
|
+
invalidBuildConfig(buildDirectory) {
|
|
21
|
+
const message = `Could not read the build configuration in ${f.path(buildDirectory)}. ` +
|
|
22
|
+
`Ensure ${f.var("APIMATIC-BUILD.json")} exists and is valid JSON.`;
|
|
23
|
+
log.error(message);
|
|
24
|
+
}
|
|
25
|
+
baseUrlPortUpdated(updatedUrl) {
|
|
26
|
+
const message = `Updated the base URL in ${f.var("APIMATIC-BUILD.json")} to ${f.var(updatedUrl.toString())} to match the serve port.`;
|
|
27
|
+
log.info(message);
|
|
28
|
+
}
|
|
10
29
|
portalServed(urlPath) {
|
|
11
30
|
const message = `The portal is running at ${f.link(urlPath.toString())}`;
|
|
12
31
|
log.message(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/prompts/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,kBAAkB;IACtB,iBAAiB,CAAC,WAAmB,EAAE,aAAqB;QACjE,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/prompts/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,MAAM,IAAI,CAAC,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Q,EAAE,CAAC,2BAA2B,CAAC;QACtI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAEM,YAAY,CAAC,OAAgB;QAClC,MAAM,OAAO,GAAG,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;QACzE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAEM,aAAa;QAClB,MAAM,OAAO,GAAG,kCAAkC,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAEM,eAAe;QACpB,MAAM,OAAO,GAAG,qBAAqB,CAAC;QACtC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAEM,YAAY;QACjB,MAAM,OAAO,GAAG,iJAAiJ,CAAC,CAAC,GAAG,CACpK,qBAAqB,CACtB,EAAE,CAAC;QACJ,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEM,gBAAgB,CAAC,YAA2B;QACjD,WAAW,CACT;;yBAEmB,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,EACzD,MAAM,CACP,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -2,7 +2,7 @@ import { FilePath } from "../../../types/file/filePath.js";
|
|
|
2
2
|
import { Result } from "neverthrow";
|
|
3
3
|
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
4
4
|
import { ServiceError } from "../../../infrastructure/service-error.js";
|
|
5
|
-
import {
|
|
5
|
+
import { TocData } from "../../../types/toc/toc-components.js";
|
|
6
6
|
export declare class PortalNewTocPrompts {
|
|
7
7
|
overwriteToc(tocPath: FilePath): Promise<boolean>;
|
|
8
8
|
fallingBackToDefault(): void;
|
|
@@ -10,6 +10,6 @@ export declare class PortalNewTocPrompts {
|
|
|
10
10
|
logError(message: string): void;
|
|
11
11
|
contentDirectoryNotFound(contentFolderPath: DirectoryPath): void;
|
|
12
12
|
invalidBuildDirectory(directory: DirectoryPath): void;
|
|
13
|
-
|
|
13
|
+
extractTocData(fn: Promise<Result<TocData, ServiceError>>, expandEndpoints: boolean, expandModels: boolean, expandWebhooks: boolean, expandCallbacks: boolean): Promise<Result<TocData, ServiceError>>;
|
|
14
14
|
tocCreated(tocPath: FilePath): void;
|
|
15
15
|
}
|
|
@@ -28,7 +28,7 @@ export class PortalNewTocPrompts {
|
|
|
28
28
|
const message = `The ${f.var("src")} directory is either empty or invalid: ${f.path(directory)}`;
|
|
29
29
|
log.error(message);
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
extractTocData(fn, expandEndpoints, expandModels, expandWebhooks, expandCallbacks) {
|
|
32
32
|
const components = [
|
|
33
33
|
expandEndpoints && "Endpoint groups",
|
|
34
34
|
expandModels && "Models",
|
|
@@ -36,8 +36,8 @@ export class PortalNewTocPrompts {
|
|
|
36
36
|
expandCallbacks && "Callbacks"
|
|
37
37
|
]
|
|
38
38
|
.filter(Boolean)
|
|
39
|
-
.join(" and ");
|
|
40
|
-
return withSpinner(`Extracting ${components}`, `${components} extracted`, `${components} extraction
|
|
39
|
+
.join(" and ") || "TOC data";
|
|
40
|
+
return withSpinner(`Extracting ${components}`, `${components} extracted`, `${components} extraction Failed`, fn);
|
|
41
41
|
}
|
|
42
42
|
tocCreated(tocPath) {
|
|
43
43
|
log.info(`The TOC file successfully created at: ${f.path(tocPath)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-toc.js","sourceRoot":"","sources":["../../../../src/prompts/portal/toc/new-toc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,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,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,cAAc,CACnB,EAA0C,EAC1C,eAAwB,EACxB,YAAqB,EACrB,cAAuB,EACvB,eAAwB;QAExB,MAAM,UAAU,GAAG;YACjB,eAAe,IAAI,iBAAiB;YACpC,YAAY,IAAI,QAAQ;YACxB,cAAc,IAAI,UAAU;YAC5B,eAAe,IAAI,WAAW;SAC/B;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC;QAE/B,OAAO,WAAW,CAAC,cAAc,UAAU,EAAE,EAAE,GAAG,UAAU,YAAY,EAAE,GAAG,UAAU,oBAAoB,EAAE,EAAE,CAAC,CAAC;IACnH,CAAC;IAEM,UAAU,CAAC,OAAiB;QACjC,GAAG,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;CACF"}
|
package/lib/prompts/prompt.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
2
|
export declare function withSpinner<T, E>(intro: string, success: string, failure: string, fn: Promise<Result<T, E>>): Promise<Result<T, E>>;
|
|
3
3
|
export declare const noteWrapped: (message: string, title: string) => void;
|
|
4
|
+
export declare function buildTableWithHeading(groups: {
|
|
5
|
+
heading: string;
|
|
6
|
+
rows: string[][];
|
|
7
|
+
}[], headers: string[], columnStyles?: ColumnStyle[]): string;
|
|
8
|
+
type ColumnStyle = 'primary' | 'secondary' | 'item';
|
|
9
|
+
export {};
|
package/lib/prompts/prompt.js
CHANGED
|
@@ -34,4 +34,49 @@ export const noteWrapped = (message, title) => {
|
|
|
34
34
|
note(message, title, opts);
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
export function buildTableWithHeading(groups, headers, columnStyles) {
|
|
38
|
+
return groups
|
|
39
|
+
.map((group) => `${pc.bold(pc.white(group.heading))}\n${buildTable(headers, group.rows, true, columnStyles)}`)
|
|
40
|
+
.join('\n\n');
|
|
41
|
+
}
|
|
42
|
+
function buildTable(headers, rows, rowSeparators = false, columnStyles) {
|
|
43
|
+
const COL_PAD = 2;
|
|
44
|
+
const MIN_COL_WIDTH = 4;
|
|
45
|
+
const coloredHeaders = headers.map((h) => pc.bold(pc.white(h)));
|
|
46
|
+
let widths = headers.map((h, i) => Math.max(stripAnsi(h).length, ...rows.map((r) => stripAnsi(r[i]).length)) + COL_PAD);
|
|
47
|
+
const terminalColumns = getColumns(process.stdout) || 80;
|
|
48
|
+
const totalWidth = 1 + 3 * headers.length + widths.reduce((a, b) => a + b, 0);
|
|
49
|
+
if (totalWidth > terminalColumns) {
|
|
50
|
+
const availableWidth = terminalColumns - 1 - 3 * headers.length;
|
|
51
|
+
const naturalTotal = widths.reduce((a, b) => a + b, 0);
|
|
52
|
+
widths = widths.map((w) => Math.max(MIN_COL_WIDTH, Math.floor((w / naturalTotal) * availableWidth)));
|
|
53
|
+
}
|
|
54
|
+
const columnStyleMap = {
|
|
55
|
+
primary: (text) => pc.magenta(text),
|
|
56
|
+
secondary: (text) => pc.dim(text),
|
|
57
|
+
item: (text) => pc.cyan(text)
|
|
58
|
+
};
|
|
59
|
+
const divider = (l, m, r) => pc.gray(l + widths.map((w) => '─'.repeat(w + 2)).join(m) + r);
|
|
60
|
+
const renderRow = (cells, applyStyles = false) => pc.gray('│') +
|
|
61
|
+
cells
|
|
62
|
+
.map((cell, i) => {
|
|
63
|
+
const styled = applyStyles && (columnStyles === null || columnStyles === void 0 ? void 0 : columnStyles[i]) ? columnStyleMap[columnStyles[i]](cell) : cell;
|
|
64
|
+
return ` ${pad(styled, widths[i])} ` + pc.gray('│');
|
|
65
|
+
})
|
|
66
|
+
.join('');
|
|
67
|
+
const lines = [divider('┌', '┬', '┐'), renderRow(coloredHeaders), divider('├', '┼', '┤')];
|
|
68
|
+
rows.forEach((row, i) => {
|
|
69
|
+
lines.push(renderRow(row, true));
|
|
70
|
+
if (rowSeparators) {
|
|
71
|
+
lines.push(i < rows.length - 1 ? divider('├', '┼', '┤') : divider('└', '┴', '┘'));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (!rowSeparators)
|
|
75
|
+
lines.push(divider('└', '┴', '┘'));
|
|
76
|
+
return lines.join('\n');
|
|
77
|
+
}
|
|
78
|
+
/** Pad `text` to `width` visible characters (ANSI-safe). */
|
|
79
|
+
function pad(text, width) {
|
|
80
|
+
return text + ' '.repeat(Math.max(0, width - stripAnsi(text).length));
|
|
81
|
+
}
|
|
37
82
|
//# sourceMappingURL=prompt.js.map
|