@apimatic/cli 0.0.0-alpha.4 → 1.0.0-beta.1
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 +308 -130
- package/bin/run.js +5 -0
- package/lib/actions/action-result.d.ts +13 -0
- package/lib/actions/action-result.js +44 -0
- package/lib/actions/action-result.js.map +1 -0
- package/lib/actions/api/transform.d.ts +15 -0
- package/lib/actions/api/transform.js +48 -0
- package/lib/actions/api/transform.js.map +1 -0
- package/lib/actions/api/validate.d.ts +12 -0
- package/lib/actions/api/validate.js +41 -0
- package/lib/actions/api/validate.js.map +1 -0
- package/lib/actions/auth/login.d.ts +13 -0
- package/lib/actions/auth/login.js +55 -0
- package/lib/actions/auth/login.js.map +1 -0
- package/lib/actions/auth/logout.d.ts +8 -0
- package/lib/actions/auth/logout.js +15 -0
- package/lib/actions/auth/logout.js.map +1 -0
- package/lib/actions/auth/status.d.ts +11 -0
- package/lib/actions/auth/status.js +26 -0
- package/lib/actions/auth/status.js.map +1 -0
- package/lib/actions/portal/copilot.d.ts +16 -0
- package/lib/actions/portal/copilot.js +89 -0
- package/lib/actions/portal/copilot.js.map +1 -0
- package/lib/actions/portal/generate.d.ts +13 -0
- package/lib/actions/portal/generate.js +59 -0
- package/lib/actions/portal/generate.js.map +1 -0
- package/lib/actions/portal/quickstart.d.ts +16 -0
- package/lib/actions/portal/quickstart.js +145 -0
- package/lib/actions/portal/quickstart.js.map +1 -0
- package/lib/actions/portal/recipe/new-recipe.d.ts +15 -0
- package/lib/actions/portal/recipe/new-recipe.js +176 -0
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +16 -0
- package/lib/actions/portal/serve.js +119 -0
- package/lib/actions/portal/serve.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +21 -0
- package/lib/actions/portal/toc/new-toc.js +97 -0
- package/lib/actions/portal/toc/new-toc.js.map +1 -0
- package/lib/actions/sdk/generate.d.ts +13 -0
- package/lib/actions/sdk/generate.js +47 -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 +21 -0
- package/lib/application/portal/recipe/recipe-generator.js +146 -0
- package/lib/application/portal/recipe/recipe-generator.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 +26 -14
- package/lib/client-utils/auth-manager.js.map +1 -0
- package/lib/commands/api/transform.d.ts +11 -8
- package/lib/commands/api/transform.js +52 -105
- package/lib/commands/api/transform.js.map +1 -0
- package/lib/commands/api/validate.d.ts +8 -5
- package/lib/commands/api/validate.js +31 -63
- package/lib/commands/api/validate.js.map +1 -0
- package/lib/commands/auth/login.d.ts +4 -2
- package/lib/commands/auth/login.js +26 -51
- package/lib/commands/auth/login.js.map +1 -0
- package/lib/commands/auth/logout.d.ts +4 -2
- package/lib/commands/auth/logout.js +14 -20
- package/lib/commands/auth/logout.js.map +1 -0
- package/lib/commands/auth/status.d.ts +2 -1
- package/lib/commands/auth/status.js +18 -20
- package/lib/commands/auth/status.js.map +1 -0
- package/lib/commands/portal/copilot.d.ts +13 -0
- package/lib/commands/portal/copilot.js +34 -0
- package/lib/commands/portal/copilot.js.map +1 -0
- package/lib/commands/portal/generate.d.ts +9 -8
- package/lib/commands/portal/generate.js +31 -97
- package/lib/commands/portal/generate.js.map +1 -0
- package/lib/commands/portal/quickstart.d.ts +9 -0
- package/lib/commands/portal/quickstart.js +37 -0
- package/lib/commands/portal/quickstart.js.map +1 -0
- package/lib/commands/portal/recipe/new.d.ts +12 -0
- package/lib/commands/portal/recipe/new.js +46 -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 +54 -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 +61 -0
- package/lib/commands/portal/toc/new.js.map +1 -0
- package/lib/commands/sdk/generate.d.ts +11 -9
- package/lib/commands/sdk/generate.js +48 -122
- 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/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-utils.d.ts +9 -0
- package/lib/infrastructure/api-utils.js +34 -0
- package/lib/infrastructure/api-utils.js.map +1 -0
- package/lib/infrastructure/debounce-service.d.ts +10 -0
- package/lib/infrastructure/debounce-service.js +52 -0
- package/lib/infrastructure/debounce-service.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 +23 -0
- package/lib/infrastructure/file-service.js +117 -0
- package/lib/infrastructure/file-service.js.map +1 -0
- package/lib/infrastructure/launcher-service.d.ts +7 -0
- package/lib/infrastructure/launcher-service.js +51 -0
- package/lib/infrastructure/launcher-service.js.map +1 -0
- package/lib/infrastructure/network-service.d.ts +3 -0
- package/lib/infrastructure/network-service.js +7 -0
- package/lib/infrastructure/network-service.js.map +1 -0
- package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
- package/lib/infrastructure/services/api-client-factory.js +20 -0
- package/lib/infrastructure/services/api-client-factory.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 +37 -0
- package/lib/infrastructure/services/auth-service.js.map +1 -0
- package/lib/infrastructure/services/file-download-service.d.ts +15 -0
- package/lib/infrastructure/services/file-download-service.js +104 -0
- package/lib/infrastructure/services/file-download-service.js.map +1 -0
- package/lib/infrastructure/services/portal-service.d.ts +21 -0
- package/lib/infrastructure/services/portal-service.js +157 -0
- package/lib/infrastructure/services/portal-service.js.map +1 -0
- package/lib/infrastructure/services/telemetry-service.d.ts +9 -0
- package/lib/infrastructure/services/telemetry-service.js +38 -0
- package/lib/infrastructure/services/telemetry-service.js.map +1 -0
- package/lib/infrastructure/services/transformation-service.d.ts +23 -0
- package/lib/infrastructure/services/transformation-service.js +56 -0
- package/lib/infrastructure/services/transformation-service.js.map +1 -0
- package/lib/infrastructure/services/validation-service.d.ts +17 -0
- package/lib/infrastructure/services/validation-service.js +49 -0
- package/lib/infrastructure/services/validation-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/api/transform.d.ts +11 -0
- package/lib/prompts/api/transform.js +30 -0
- package/lib/prompts/api/transform.js.map +1 -0
- package/lib/prompts/api/validate.d.ts +12 -0
- package/lib/prompts/api/validate.js +41 -0
- package/lib/prompts/api/validate.js.map +1 -0
- package/lib/prompts/auth/login.d.ts +10 -0
- package/lib/prompts/auth/login.js +22 -0
- package/lib/prompts/auth/login.js.map +1 -0
- package/lib/prompts/auth/logout.d.ts +3 -0
- package/lib/prompts/auth/logout.js +7 -0
- package/lib/prompts/auth/logout.js.map +1 -0
- package/lib/prompts/auth/status.d.ts +8 -0
- package/lib/prompts/auth/status.js +21 -0
- package/lib/prompts/auth/status.js.map +1 -0
- package/lib/prompts/format.d.ts +33 -0
- package/lib/prompts/format.js +99 -0
- package/lib/prompts/format.js.map +1 -0
- package/lib/prompts/portal/copilot.d.ts +18 -0
- package/lib/prompts/portal/copilot.js +82 -0
- package/lib/prompts/portal/copilot.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +13 -0
- package/lib/prompts/portal/generate.js +41 -0
- package/lib/prompts/portal/generate.js.map +1 -0
- package/lib/prompts/portal/quickstart.d.ts +31 -0
- package/lib/prompts/portal/quickstart.js +146 -0
- package/lib/prompts/portal/quickstart.js.map +1 -0
- package/lib/prompts/portal/recipe/new-recipe.d.ts +29 -0
- package/lib/prompts/portal/recipe/new-recipe.js +165 -0
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +11 -0
- package/lib/prompts/portal/serve.js +33 -0
- package/lib/prompts/portal/serve.js.map +1 -0
- package/lib/prompts/portal/toc/new-toc.d.ts +15 -0
- package/lib/prompts/portal/toc/new-toc.js +37 -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 +36 -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 +17 -17
- package/lib/types/api/transform.js +21 -6
- package/lib/types/api/transform.js.map +1 -0
- package/lib/types/build/build.d.ts +22 -0
- package/lib/types/build/build.js +7 -0
- package/lib/types/build/build.js.map +1 -0
- package/lib/types/build-context.d.ts +17 -0
- package/lib/types/build-context.js +47 -0
- package/lib/types/build-context.js.map +1 -0
- package/lib/types/common/command-metadata.d.ts +4 -0
- package/lib/types/common/command-metadata.js +2 -0
- package/lib/types/common/command-metadata.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/directory.d.ts +17 -0
- package/lib/types/file/directory.js +86 -0
- package/lib/types/file/directory.js.map +1 -0
- package/lib/types/file/directoryPath.d.ts +9 -0
- package/lib/types/file/directoryPath.js +22 -0
- package/lib/types/file/directoryPath.js.map +1 -0
- package/lib/types/file/fileName.d.ts +7 -0
- package/lib/types/file/fileName.js +21 -0
- package/lib/types/file/fileName.js.map +1 -0
- package/lib/types/file/filePath.d.ts +10 -0
- package/lib/types/file/filePath.js +32 -0
- package/lib/types/file/filePath.js.map +1 -0
- package/lib/types/file/resource-input.d.ts +5 -0
- package/lib/types/file/resource-input.js +42 -0
- package/lib/types/file/resource-input.js.map +1 -0
- package/lib/types/file/urlPath.d.ts +6 -0
- package/lib/types/file/urlPath.js +22 -0
- package/lib/types/file/urlPath.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-context.d.ts +13 -0
- package/lib/types/portal-context.js +38 -0
- package/lib/types/portal-context.js.map +1 -0
- package/lib/types/recipe/recipe.d.ts +22 -0
- package/lib/types/recipe/recipe.js +6 -0
- package/lib/types/recipe/recipe.js.map +1 -0
- package/lib/types/recipe-context.d.ts +8 -0
- package/lib/types/recipe-context.js +21 -0
- package/lib/types/recipe-context.js.map +1 -0
- package/lib/types/resource-context.d.ts +12 -0
- package/lib/types/resource-context.js +30 -0
- package/lib/types/resource-context.js.map +1 -0
- package/lib/types/sdk/generate.d.ts +9 -21
- package/lib/types/sdk/generate.js +25 -12
- package/lib/types/sdk/generate.js.map +1 -0
- package/lib/types/sdk-context.d.ts +14 -0
- package/lib/types/sdk-context.js +32 -0
- package/lib/types/sdk-context.js.map +1 -0
- package/lib/types/sdl/sdl.d.ts +21 -0
- package/lib/types/sdl/sdl.js +47 -0
- package/lib/types/sdl/sdl.js.map +1 -0
- package/lib/types/spec-context.d.ts +10 -0
- package/lib/types/spec-context.js +17 -0
- package/lib/types/spec-context.js.map +1 -0
- package/lib/types/temp-context.d.ts +11 -0
- package/lib/types/temp-context.js +27 -0
- package/lib/types/temp-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/toc-context.d.ts +12 -0
- package/lib/types/toc-context.js +26 -0
- package/lib/types/toc-context.js.map +1 -0
- package/lib/types/transform-context.d.ts +13 -0
- package/lib/types/transform-context.js +30 -0
- package/lib/types/transform-context.js.map +1 -0
- package/lib/types/utils.d.ts +1 -6
- package/lib/types/utils.js +2 -2
- package/lib/types/utils.js.map +1 -0
- package/lib/utils/string-utils.d.ts +1 -0
- package/lib/utils/string-utils.js +10 -0
- package/lib/utils/string-utils.js.map +1 -0
- package/lib/utils/utils.d.ts +2 -18
- package/lib/utils/utils.js +33 -116
- package/lib/utils/utils.js.map +1 -0
- package/package.json +101 -44
- package/bin/run +0 -5
- package/lib/client-utils/sdk-client.d.ts +0 -23
- package/lib/client-utils/sdk-client.js +0 -119
- package/lib/config/env.d.ts +0 -1
- package/lib/config/env.js +0 -4
- package/lib/controllers/api/transform.d.ts +0 -5
- package/lib/controllers/api/transform.js +0 -49
- package/lib/controllers/api/validate.d.ts +0 -3
- package/lib/controllers/api/validate.js +0 -22
- 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/api/validate.d.ts +0 -12
- package/lib/types/api/validate.js +0 -2
- package/lib/types/portal/generate.d.ts +0 -9
- package/lib/types/portal/generate.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/actions/portal/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F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I,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;oBACtB,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;gBAC/B,CAAC;gBACD,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAxIA,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;CAuIF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
2
|
+
import { CommandMetadata } from "../../../types/common/command-metadata.js";
|
|
3
|
+
import { ActionResult } from "../../action-result.js";
|
|
4
|
+
export declare class PortalRecipeAction {
|
|
5
|
+
private readonly configDirectory;
|
|
6
|
+
private readonly commandMetadata;
|
|
7
|
+
private readonly prompts;
|
|
8
|
+
private readonly launcherService;
|
|
9
|
+
private readonly fileService;
|
|
10
|
+
private readonly portalService;
|
|
11
|
+
constructor(configDirectory: DirectoryPath, commandMetadata: CommandMetadata);
|
|
12
|
+
execute(buildDirectory: DirectoryPath, name?: string): Promise<ActionResult>;
|
|
13
|
+
private promptForContent;
|
|
14
|
+
private getTocStructure;
|
|
15
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { PortalRecipePrompts } from "../../../prompts/portal/recipe/new-recipe.js";
|
|
2
|
+
import { StepType } from "../../../types/recipe/recipe.js";
|
|
3
|
+
import { PortalService } from "../../../infrastructure/services/portal-service.js";
|
|
4
|
+
import { getEndpointDescription, getEndpointGroupsFromSdl } from "../../../types/sdl/sdl.js";
|
|
5
|
+
import { ActionResult } from "../../action-result.js";
|
|
6
|
+
import { TocContext } from "../../../types/toc-context.js";
|
|
7
|
+
import { FileName } from "../../../types/file/fileName.js";
|
|
8
|
+
import { PortalRecipe } from "../../../application/portal/recipe/portal-recipe.js";
|
|
9
|
+
import { PortalRecipeGenerator } from "../../../application/portal/recipe/recipe-generator.js";
|
|
10
|
+
import { BuildContext } from "../../../types/build-context.js";
|
|
11
|
+
import { ContentContext } from "../toc/new-toc.js";
|
|
12
|
+
import { SpecContext } from "../../../types/spec-context.js";
|
|
13
|
+
import { LauncherService } from "../../../infrastructure/launcher-service.js";
|
|
14
|
+
import { FileService } from "../../../infrastructure/file-service.js";
|
|
15
|
+
import { FilePath } from "../../../types/file/filePath.js";
|
|
16
|
+
import { withDirPath } from "../../../infrastructure/tmp-extensions.js";
|
|
17
|
+
import { TempContext } from "../../../types/temp-context.js";
|
|
18
|
+
import { RecipeContext } from "../../../types/recipe-context.js";
|
|
19
|
+
export class PortalRecipeAction {
|
|
20
|
+
constructor(configDirectory, commandMetadata) {
|
|
21
|
+
this.configDirectory = configDirectory;
|
|
22
|
+
this.commandMetadata = commandMetadata;
|
|
23
|
+
this.prompts = new PortalRecipePrompts();
|
|
24
|
+
this.launcherService = new LauncherService();
|
|
25
|
+
this.fileService = new FileService();
|
|
26
|
+
this.portalService = new PortalService();
|
|
27
|
+
}
|
|
28
|
+
async execute(buildDirectory, name) {
|
|
29
|
+
this.prompts.displayWelcomeMessage();
|
|
30
|
+
const buildContext = new BuildContext(buildDirectory);
|
|
31
|
+
if (!(await buildContext.validate())) {
|
|
32
|
+
this.prompts.invalidBuildDirectory(buildDirectory);
|
|
33
|
+
return ActionResult.failed();
|
|
34
|
+
}
|
|
35
|
+
const recipeName = name !== null && name !== void 0 ? name : (await this.prompts.recipeNamePrompt());
|
|
36
|
+
if (!recipeName) {
|
|
37
|
+
this.prompts.recipeNameEmpty();
|
|
38
|
+
return ActionResult.cancelled();
|
|
39
|
+
}
|
|
40
|
+
const contentDirectory = buildDirectory.join("content");
|
|
41
|
+
const contentContext = new ContentContext(contentDirectory);
|
|
42
|
+
if (!(await contentContext.exists())) {
|
|
43
|
+
this.prompts.contentFolderNotFound();
|
|
44
|
+
return ActionResult.failed();
|
|
45
|
+
}
|
|
46
|
+
const specDirectory = buildDirectory.join("spec");
|
|
47
|
+
const specContext = new SpecContext(specDirectory);
|
|
48
|
+
if (!(await specContext.validate())) {
|
|
49
|
+
this.prompts.specFileEmptyInvalid();
|
|
50
|
+
return ActionResult.failed();
|
|
51
|
+
}
|
|
52
|
+
// Setup TOC context
|
|
53
|
+
const tocContext = new TocContext(contentDirectory);
|
|
54
|
+
const tocData = await tocContext.parseTocData();
|
|
55
|
+
// Setup recipe context
|
|
56
|
+
const recipeContext = new RecipeContext(recipeName);
|
|
57
|
+
const recipeFileName = recipeContext.getRecipeName();
|
|
58
|
+
// Check if the recipe already exists
|
|
59
|
+
const recipeAlreadyExists = recipeContext.exists(tocData, recipeName, recipeFileName);
|
|
60
|
+
if (recipeAlreadyExists && !(await this.prompts.overwriteApiRecipeInTocPrompt(recipeName))) {
|
|
61
|
+
return ActionResult.cancelled();
|
|
62
|
+
}
|
|
63
|
+
// Build the recipe
|
|
64
|
+
const recipe = new PortalRecipe(recipeName);
|
|
65
|
+
let stepIndex = 0;
|
|
66
|
+
this.prompts.displayStepsInformation();
|
|
67
|
+
let endpointGroups;
|
|
68
|
+
do {
|
|
69
|
+
const stepType = await this.prompts.stepTypeSelectionPrompt();
|
|
70
|
+
if (!stepType)
|
|
71
|
+
return ActionResult.cancelled();
|
|
72
|
+
const stepName = await this.prompts.stepNamePrompt(`Step ${++stepIndex}`);
|
|
73
|
+
if (!stepName)
|
|
74
|
+
return ActionResult.cancelled();
|
|
75
|
+
switch (stepType) {
|
|
76
|
+
case StepType.Content: {
|
|
77
|
+
const contentResult = await this.promptForContent();
|
|
78
|
+
recipe.addContentStep(stepName, contentResult);
|
|
79
|
+
this.prompts.displayStepAddedSuccessfullyMessage();
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case StepType.Endpoint: {
|
|
83
|
+
if (!endpointGroups) {
|
|
84
|
+
const sdlResult = await withDirPath(async (tempDirectory) => {
|
|
85
|
+
const tempContext = new TempContext(tempDirectory);
|
|
86
|
+
const specZipPath = await tempContext.zip(specDirectory);
|
|
87
|
+
const specFileStream = await this.fileService.getStream(specZipPath);
|
|
88
|
+
try {
|
|
89
|
+
return await this.prompts.generateSdl(this.portalService.generateSdl(specFileStream, this.configDirectory, this.commandMetadata));
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
specFileStream.close();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
if (sdlResult.isErr()) {
|
|
96
|
+
this.prompts.serviceError(sdlResult.error);
|
|
97
|
+
return ActionResult.failed();
|
|
98
|
+
}
|
|
99
|
+
endpointGroups = getEndpointGroupsFromSdl(sdlResult.value);
|
|
100
|
+
}
|
|
101
|
+
const endpointGroupName = await this.prompts.endpointGroupNamePrompt(endpointGroups);
|
|
102
|
+
if (!endpointGroupName)
|
|
103
|
+
return ActionResult.cancelled();
|
|
104
|
+
const endpointName = await this.prompts.endpointNamePrompt(endpointGroups, endpointGroupName);
|
|
105
|
+
if (!endpointName)
|
|
106
|
+
return ActionResult.cancelled();
|
|
107
|
+
const defaultDescription = getEndpointDescription(endpointGroups, endpointGroupName, endpointName);
|
|
108
|
+
const description = await this.prompts.endpointDescriptionPrompt(defaultDescription);
|
|
109
|
+
if (!description)
|
|
110
|
+
return ActionResult.cancelled();
|
|
111
|
+
recipe.addEndpointStep(stepName, description, endpointGroupName, endpointName);
|
|
112
|
+
this.prompts.displayStepAddedSuccessfullyMessage();
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} while (await this.prompts.addAnotherStepSelectionPrompt());
|
|
117
|
+
const serializableRecipe = recipe.toSerializableRecipe();
|
|
118
|
+
// Generate the recipe
|
|
119
|
+
const recipeGenerator = new PortalRecipeGenerator();
|
|
120
|
+
await recipeGenerator.createRecipe(serializableRecipe, tocData, tocContext.tocPath, recipeName, recipeFileName, buildContext, buildDirectory);
|
|
121
|
+
const tocStructure = this.getTocStructure(recipeFileName);
|
|
122
|
+
this.prompts.recipeCreated();
|
|
123
|
+
this.prompts.displayRecipeStructure(tocStructure);
|
|
124
|
+
this.prompts.nextSteps();
|
|
125
|
+
return ActionResult.success();
|
|
126
|
+
}
|
|
127
|
+
async promptForContent() {
|
|
128
|
+
return await withDirPath(async (tempDir) => {
|
|
129
|
+
const tempFile = new FilePath(tempDir, new FileName(`recipe-markdown-content.md`));
|
|
130
|
+
const defaultContent = "# The Heading Goes Here\n\n" +
|
|
131
|
+
"This is placeholder text for your API Recipe content step. " +
|
|
132
|
+
"Feel free to edit this. Save your changes and then close the file once you're done.";
|
|
133
|
+
await this.fileService.writeContents(tempFile, defaultContent);
|
|
134
|
+
this.prompts.openRecipeMarkdownEditor();
|
|
135
|
+
await this.launcherService.openInEditor(tempFile);
|
|
136
|
+
const fileContent = await this.fileService.getContents(tempFile);
|
|
137
|
+
return fileContent.replace(/\r\n|\r/g, "\n");
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
getTocStructure(recipeFileName) {
|
|
141
|
+
return {
|
|
142
|
+
name: "src",
|
|
143
|
+
items: [
|
|
144
|
+
{
|
|
145
|
+
name: "content",
|
|
146
|
+
items: [
|
|
147
|
+
{
|
|
148
|
+
name: "toc.yml",
|
|
149
|
+
description: "# Contains the API Recipes group with a new page for your API recipe"
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "static",
|
|
155
|
+
items: [
|
|
156
|
+
{
|
|
157
|
+
name: "scripts",
|
|
158
|
+
items: [
|
|
159
|
+
{
|
|
160
|
+
name: "recipes",
|
|
161
|
+
items: [
|
|
162
|
+
{
|
|
163
|
+
name: `${recipeFileName}`,
|
|
164
|
+
description: "# Generated recipe script file containing all of the steps"
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=new-recipe.js.map
|
|
@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,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { ActionResult } from "../action-result.js";
|
|
3
|
+
import { CommandMetadata } from "../../types/common/command-metadata.js";
|
|
4
|
+
export declare class PortalServeAction {
|
|
5
|
+
private readonly prompts;
|
|
6
|
+
private readonly networkService;
|
|
7
|
+
private readonly launcherService;
|
|
8
|
+
private readonly application;
|
|
9
|
+
private readonly configDir;
|
|
10
|
+
private readonly commandMetadata;
|
|
11
|
+
private readonly authKey;
|
|
12
|
+
private isPortalServed;
|
|
13
|
+
constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata, authKey?: string | null);
|
|
14
|
+
execute(buildDirectory: DirectoryPath, portalDirectory: DirectoryPath, port: number, openInBrowser: boolean, hotReload: boolean, onAfterServe?: () => void): Promise<ActionResult>;
|
|
15
|
+
private clearStandardInput;
|
|
16
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createServer as createLiveReloadServer } from "livereload";
|
|
2
|
+
import connectLiveReload from "connect-livereload";
|
|
3
|
+
import express from "express";
|
|
4
|
+
import chokidar from "chokidar";
|
|
5
|
+
import crypto from "crypto";
|
|
6
|
+
import { Mutex } from "async-mutex";
|
|
7
|
+
import { PortalServePrompts } from "../../prompts/portal/serve.js";
|
|
8
|
+
import { ActionResult } from "../action-result.js";
|
|
9
|
+
import { GenerateAction } from "./generate.js";
|
|
10
|
+
import { NetworkService } from "../../infrastructure/network-service.js";
|
|
11
|
+
import { UrlPath } from "../../types/file/urlPath.js";
|
|
12
|
+
import { LauncherService } from "../../infrastructure/launcher-service.js";
|
|
13
|
+
import { DebounceService } from "../../infrastructure/debounce-service.js";
|
|
14
|
+
export class PortalServeAction {
|
|
15
|
+
constructor(configDir, commandMetadata, authKey = null) {
|
|
16
|
+
this.prompts = new PortalServePrompts();
|
|
17
|
+
this.networkService = new NetworkService();
|
|
18
|
+
this.launcherService = new LauncherService();
|
|
19
|
+
this.application = express();
|
|
20
|
+
this.isPortalServed = false;
|
|
21
|
+
this.configDir = configDir;
|
|
22
|
+
this.commandMetadata = commandMetadata;
|
|
23
|
+
this.authKey = authKey;
|
|
24
|
+
}
|
|
25
|
+
async execute(buildDirectory, portalDirectory, port, openInBrowser, hotReload, onAfterServe) {
|
|
26
|
+
const generatePortalAction = new GenerateAction(this.configDir, this.commandMetadata, this.authKey);
|
|
27
|
+
const result = await generatePortalAction.execute(buildDirectory, portalDirectory, true, false);
|
|
28
|
+
if (result.isFailed()) {
|
|
29
|
+
return ActionResult.failed();
|
|
30
|
+
}
|
|
31
|
+
const servePort = await this.networkService.getServerPort([port, 3000, 3001, 3002]);
|
|
32
|
+
if (servePort != port && !onAfterServe) {
|
|
33
|
+
this.prompts.usingFallbackPort(port, servePort);
|
|
34
|
+
}
|
|
35
|
+
const liveReloadPort = await this.networkService.getServerPort([35729, 35730, 35731, 35732]);
|
|
36
|
+
const liveReloadServer = createLiveReloadServer({ port: liveReloadPort });
|
|
37
|
+
const server = this.application
|
|
38
|
+
.use(connectLiveReload())
|
|
39
|
+
.use(express.static(portalDirectory.toString(), { extensions: ["html"] }))
|
|
40
|
+
.listen(servePort);
|
|
41
|
+
const portalUrl = new UrlPath(`http://localhost:${servePort}`);
|
|
42
|
+
this.prompts.portalServed(portalUrl);
|
|
43
|
+
if (openInBrowser) {
|
|
44
|
+
await this.launcherService.openUrlInBrowser(portalUrl);
|
|
45
|
+
}
|
|
46
|
+
this.prompts.promptForExit();
|
|
47
|
+
if (!hotReload) {
|
|
48
|
+
if (onAfterServe) {
|
|
49
|
+
onAfterServe();
|
|
50
|
+
}
|
|
51
|
+
this.clearStandardInput();
|
|
52
|
+
await this.prompts.blockExecution();
|
|
53
|
+
liveReloadServer.close();
|
|
54
|
+
server.close();
|
|
55
|
+
return ActionResult.success();
|
|
56
|
+
}
|
|
57
|
+
this.prompts.hotReloadEnabled(buildDirectory);
|
|
58
|
+
const watcher = chokidar.watch(buildDirectory.toString(), {
|
|
59
|
+
ignored: [/(^|[/\\])\..+/],
|
|
60
|
+
ignoreInitial: true,
|
|
61
|
+
persistent: true,
|
|
62
|
+
awaitWriteFinish: true,
|
|
63
|
+
atomic: true
|
|
64
|
+
});
|
|
65
|
+
const deletedDirectories = new Set();
|
|
66
|
+
// TODO: Verify if we need mutex and eventQueue after refactoring.
|
|
67
|
+
const eventQueue = new Map();
|
|
68
|
+
const mutex = new Mutex();
|
|
69
|
+
const debounceService = new DebounceService();
|
|
70
|
+
watcher
|
|
71
|
+
.on("all", async (event, path) => {
|
|
72
|
+
// triggers folder deletion as a single event
|
|
73
|
+
if (event == "unlinkDir") {
|
|
74
|
+
deletedDirectories.add(path);
|
|
75
|
+
}
|
|
76
|
+
if (event == "unlink") {
|
|
77
|
+
for (const dir of deletedDirectories) {
|
|
78
|
+
if (path.startsWith(dir)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const eventId = `${Date.now()}-${crypto.randomUUID()}`;
|
|
84
|
+
await mutex.runExclusive(async () => {
|
|
85
|
+
eventQueue.clear();
|
|
86
|
+
eventQueue.set(eventId, path);
|
|
87
|
+
});
|
|
88
|
+
await debounceService.batchSingleRequest(async () => {
|
|
89
|
+
this.prompts.changesDetected();
|
|
90
|
+
// TODO: Verify if this is needed.
|
|
91
|
+
if (!eventQueue.has(eventId)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
await generatePortalAction.execute(buildDirectory, portalDirectory, true, false, false);
|
|
95
|
+
liveReloadServer.refresh(portalDirectory.toString());
|
|
96
|
+
this.clearStandardInput();
|
|
97
|
+
});
|
|
98
|
+
})
|
|
99
|
+
.on("error", async () => {
|
|
100
|
+
this.prompts.watcherError();
|
|
101
|
+
});
|
|
102
|
+
// Wait for SIGINT or SIGTERM
|
|
103
|
+
this.clearStandardInput();
|
|
104
|
+
await this.prompts.blockExecution();
|
|
105
|
+
await watcher.close();
|
|
106
|
+
debounceService.close();
|
|
107
|
+
liveReloadServer.close();
|
|
108
|
+
server.close();
|
|
109
|
+
return ActionResult.success();
|
|
110
|
+
}
|
|
111
|
+
// This clears the standard input to allow interrupts like CTRL+C to work properly.
|
|
112
|
+
clearStandardInput() {
|
|
113
|
+
if (process.platform !== "darwin" && process.stdin.isTTY) {
|
|
114
|
+
process.stdin.setRawMode(false);
|
|
115
|
+
process.stdin.pause();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/actions/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,OAAoB,MAAM,SAAS,CAAC;AAC3C,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAE3E,MAAM,OAAO,iBAAiB;IAU5B,YAAmB,SAAwB,EAAE,eAAgC,EAAE,UAAyB,IAAI;QAT3F,YAAO,GAAuB,IAAI,kBAAkB,EAAE,CAAC;QACvD,mBAAc,GAAmB,IAAI,c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AAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;aACD,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;YACtB,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEL,6BAA6B;QAC7B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAEpC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QACtB,eAAe,CAAC,KAAK,EAAE,CAAC;QAExB,gBAAgB,CAAC,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;IAED,mFAAmF;IAC3E,kBAAkB;QACxB,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACzD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAChC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TocGroup } from "../../../types/toc/toc.js";
|
|
2
|
+
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
3
|
+
import { CommandMetadata } from "../../../types/common/command-metadata.js";
|
|
4
|
+
import { ActionResult } from "../../action-result.js";
|
|
5
|
+
export declare class ContentContext {
|
|
6
|
+
private readonly contentDirectory;
|
|
7
|
+
private readonly fileService;
|
|
8
|
+
constructor(contentDirectory: DirectoryPath);
|
|
9
|
+
exists(): Promise<boolean>;
|
|
10
|
+
extractContentGroups(): Promise<TocGroup[]>;
|
|
11
|
+
}
|
|
12
|
+
export declare class PortalNewTocAction {
|
|
13
|
+
private readonly configDirectory;
|
|
14
|
+
private readonly commandMetadata;
|
|
15
|
+
private readonly prompts;
|
|
16
|
+
private readonly tocGenerator;
|
|
17
|
+
private readonly fileService;
|
|
18
|
+
private readonly portalService;
|
|
19
|
+
constructor(configDirectory: DirectoryPath, commandMetadata: CommandMetadata);
|
|
20
|
+
execute(buildDirectory: DirectoryPath, tocDirectory?: DirectoryPath, force?: boolean, expandEndpoints?: boolean, expandModels?: boolean): Promise<ActionResult>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ok } from "neverthrow";
|
|
2
|
+
import { PortalNewTocPrompts } from "../../../prompts/portal/toc/new-toc.js";
|
|
3
|
+
import { TocStructureGenerator } from "../../../application/portal/toc/toc-structure-generator.js";
|
|
4
|
+
import { ActionResult } from "../../action-result.js";
|
|
5
|
+
import { TocContext } from "../../../types/toc-context.js";
|
|
6
|
+
import { FileService } from "../../../infrastructure/file-service.js";
|
|
7
|
+
import { BuildContext } from "../../../types/build-context.js";
|
|
8
|
+
import { getEndpointGroupsAndModels } from "../../../types/sdl/sdl.js";
|
|
9
|
+
import { withDirPath } from "../../../infrastructure/tmp-extensions.js";
|
|
10
|
+
import { TempContext } from "../../../types/temp-context.js";
|
|
11
|
+
import { PortalService } from "../../../infrastructure/services/portal-service.js";
|
|
12
|
+
export class ContentContext {
|
|
13
|
+
constructor(contentDirectory) {
|
|
14
|
+
this.contentDirectory = contentDirectory;
|
|
15
|
+
this.fileService = new FileService();
|
|
16
|
+
}
|
|
17
|
+
async exists() {
|
|
18
|
+
return this.fileService.directoryExists(this.contentDirectory);
|
|
19
|
+
}
|
|
20
|
+
async extractContentGroups() {
|
|
21
|
+
const directory = await this.fileService.getDirectory(this.contentDirectory);
|
|
22
|
+
return await directory.parseContentFolder(this.contentDirectory);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class PortalNewTocAction {
|
|
26
|
+
constructor(configDirectory, commandMetadata) {
|
|
27
|
+
this.configDirectory = configDirectory;
|
|
28
|
+
this.commandMetadata = commandMetadata;
|
|
29
|
+
this.prompts = new PortalNewTocPrompts();
|
|
30
|
+
this.tocGenerator = new TocStructureGenerator();
|
|
31
|
+
this.fileService = new FileService();
|
|
32
|
+
this.portalService = new PortalService();
|
|
33
|
+
}
|
|
34
|
+
async execute(buildDirectory, tocDirectory, force = false, expandEndpoints = false, expandModels = false) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
// Validate build directory
|
|
37
|
+
const buildContext = new BuildContext(buildDirectory);
|
|
38
|
+
if (!(await buildContext.validate())) {
|
|
39
|
+
this.prompts.invalidBuildDirectory(buildDirectory);
|
|
40
|
+
return ActionResult.failed();
|
|
41
|
+
}
|
|
42
|
+
const buildConfig = await buildContext.getBuildFileContents();
|
|
43
|
+
const contentDirectory = buildDirectory.join((_b = (_a = buildConfig.generatePortal) === null || _a === void 0 ? void 0 : _a.contentFolder) !== null && _b !== void 0 ? _b : "content");
|
|
44
|
+
const tocDir = tocDirectory !== null && tocDirectory !== void 0 ? tocDirectory : contentDirectory;
|
|
45
|
+
const tocContext = new TocContext(tocDir);
|
|
46
|
+
if (!force && (await tocContext.exists()) && !(await this.prompts.overwriteToc(tocContext.tocPath))) {
|
|
47
|
+
this.prompts.tocFileAlreadyExists();
|
|
48
|
+
return ActionResult.cancelled();
|
|
49
|
+
}
|
|
50
|
+
let sdlComponents = { endpointGroups: new Map(), models: [] };
|
|
51
|
+
if (expandEndpoints || expandModels) {
|
|
52
|
+
const specDirectory = buildDirectory.join("spec");
|
|
53
|
+
if (!(await this.fileService.directoryExists(specDirectory))) {
|
|
54
|
+
this.prompts.fallingBackToDefault();
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const sdlResult = await withDirPath(async (tempDirectory) => {
|
|
58
|
+
const tempContext = new TempContext(tempDirectory);
|
|
59
|
+
const specZipPath = await tempContext.zip(specDirectory);
|
|
60
|
+
const specFileStream = await this.fileService.getStream(specZipPath);
|
|
61
|
+
try {
|
|
62
|
+
const result = await this.prompts.extractEndpointGroupsAndModels(this.portalService.generateSdl(specFileStream, this.configDirectory, this.commandMetadata));
|
|
63
|
+
if (result.isErr()) {
|
|
64
|
+
this.prompts.fallingBackToDefault();
|
|
65
|
+
return ok({ endpointGroups: new Map(), models: [] });
|
|
66
|
+
}
|
|
67
|
+
return ok(getEndpointGroupsAndModels(result.value));
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
specFileStream.close();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
if (sdlResult.isErr()) {
|
|
74
|
+
this.prompts.logError(sdlResult.error);
|
|
75
|
+
return ActionResult.failed();
|
|
76
|
+
}
|
|
77
|
+
sdlComponents = sdlResult.value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const contentContext = new ContentContext(contentDirectory);
|
|
81
|
+
const contentExists = await contentContext.exists();
|
|
82
|
+
let contentGroups;
|
|
83
|
+
if (!contentExists) {
|
|
84
|
+
this.prompts.contentDirectoryNotFound(contentDirectory);
|
|
85
|
+
contentGroups = [];
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
contentGroups = await contentContext.extractContentGroups();
|
|
89
|
+
}
|
|
90
|
+
const toc = this.tocGenerator.createTocStructure(sdlComponents.endpointGroups, sdlComponents.models, expandEndpoints, expandModels, contentGroups);
|
|
91
|
+
const yamlString = this.tocGenerator.transformToYaml(toc);
|
|
92
|
+
const tocFilePath = await tocContext.save(yamlString);
|
|
93
|
+
this.prompts.tocCreated(tocFilePath);
|
|
94
|
+
return ActionResult.success();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=new-toc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-toc.js","sourceRoot":"","sources":["../../../../src/actions/portal/toc/new-toc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,EAAE,EAAU,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MA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,CAAC;YAClC,CAAC;QACH,CAAC;QACD,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,gBAAgB,CAAC,CAAC;QAC5D,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,CAAC;QAEpD,IAAI,aAAyB,CAAC;QAC9B,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;YACxD,aAAa,GAAG,EAAE,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,MAAM,cAAc,CAAC,oBAAoB,EAAE,CAAC;QAC9D,CAAC;QAGD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAC9C,aAAa,CAAC,cAAc,EAC5B,aAAa,CAAC,MAAM,EACpB,eAAe,EACf,YAAY,EACZ,aAAa,CACd,CAAC;QAEF,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAGtD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;QAEpC,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { ActionResult } from "../action-result.js";
|
|
3
|
+
import { CommandMetadata } from "../../types/common/command-metadata.js";
|
|
4
|
+
import { Language } from "../../types/sdk/generate.js";
|
|
5
|
+
export declare class GenerateAction {
|
|
6
|
+
private readonly prompts;
|
|
7
|
+
private readonly portalService;
|
|
8
|
+
private readonly configDir;
|
|
9
|
+
private readonly commandMetadata;
|
|
10
|
+
private readonly authKey;
|
|
11
|
+
constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata, authKey?: string | null);
|
|
12
|
+
readonly execute: (specDirectory: DirectoryPath, sdkDirectory: DirectoryPath, language: Language, force: boolean, zipSdk: boolean) => Promise<ActionResult>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { PortalService } from "../../infrastructure/services/portal-service.js";
|
|
2
|
+
import { ActionResult } from "../action-result.js";
|
|
3
|
+
import { withDirPath } from "../../infrastructure/tmp-extensions.js";
|
|
4
|
+
import { SdkContext } from "../../types/sdk-context.js";
|
|
5
|
+
import { SpecContext } from "../../types/spec-context.js";
|
|
6
|
+
import { SdkGeneratePrompts } from "../../prompts/sdk/generate.js";
|
|
7
|
+
import { TempContext } from "../../types/temp-context.js";
|
|
8
|
+
export class GenerateAction {
|
|
9
|
+
constructor(configDir, commandMetadata, authKey = null) {
|
|
10
|
+
this.prompts = new SdkGeneratePrompts();
|
|
11
|
+
this.portalService = new PortalService();
|
|
12
|
+
this.execute = async (specDirectory, sdkDirectory, language, force, zipSdk) => {
|
|
13
|
+
if (specDirectory.isEqual(sdkDirectory)) {
|
|
14
|
+
this.prompts.sameSpecAndSdkDir(specDirectory);
|
|
15
|
+
return ActionResult.failed();
|
|
16
|
+
}
|
|
17
|
+
const specContext = new SpecContext(specDirectory);
|
|
18
|
+
if (!(await specContext.validate())) {
|
|
19
|
+
this.prompts.invalidSpecDirectory(specDirectory);
|
|
20
|
+
return ActionResult.failed();
|
|
21
|
+
}
|
|
22
|
+
const sdkContext = new SdkContext(sdkDirectory, language);
|
|
23
|
+
if (!force && (await sdkContext.exists()) && !(await this.prompts.overwriteSdk(sdkContext.sdkLanguageDirectory))) {
|
|
24
|
+
this.prompts.destinationDirNotEmpty();
|
|
25
|
+
return ActionResult.cancelled();
|
|
26
|
+
}
|
|
27
|
+
return await withDirPath(async (tempDirectory) => {
|
|
28
|
+
const tempContext = new TempContext(tempDirectory);
|
|
29
|
+
const specZipPath = await tempContext.zip(specDirectory);
|
|
30
|
+
const response = await this.prompts.generateSDK(this.portalService.generateSdk(specZipPath, language, this.configDir, this.commandMetadata, this.authKey));
|
|
31
|
+
// TODO: this should be service error
|
|
32
|
+
if (response.isErr()) {
|
|
33
|
+
this.prompts.logGenerationError(response.error);
|
|
34
|
+
return ActionResult.failed();
|
|
35
|
+
}
|
|
36
|
+
const tempSdkFilePath = await tempContext.save(response.value);
|
|
37
|
+
const sdkLanguageDirectory = await sdkContext.save(tempSdkFilePath, zipSdk);
|
|
38
|
+
this.prompts.sdkGenerated(sdkLanguageDirectory);
|
|
39
|
+
return ActionResult.success();
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
this.configDir = configDir;
|
|
43
|
+
this.commandMetadata = commandMetadata;
|
|
44
|
+
this.authKey = authKey;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/actions/sdk/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,MAAM,OAAO,cAAc;IAOzB,YAAY,SAAwB,EAAE,eAAgC,EAAE,UAAyB,IAAI;QANpF,YAAO,GAAuB,IAAI,kBAAkB,EAAE,CAAC;QACvD,kBAAa,GAAkB,IAAI,aAAa,EAAE,CAAC;QAWpD,YAAO,GAAG,KAAK,EAC7B,aAA4B,EAC5B,YAA2B,EAC3B,QAAkB,EAClB,KAAc,EACd,MAAe,EACQ,E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IAAI,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;oBACrB,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAChD,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;gBAC/B,CAAC;gBAED,MAAM,eAAe,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAC/D,MAAM,oBAAoB,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;gBAE5E,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;gBAEhD,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAlDA,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CAgDF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SerializableRecipe } from "../../../types/recipe/recipe.js";
|
|
2
|
+
export declare class PortalRecipe {
|
|
3
|
+
private readonly recipe;
|
|
4
|
+
constructor(name: string);
|
|
5
|
+
addContentStep(key: string, content: string): void;
|
|
6
|
+
addEndpointStep(key: string, description: string, endpointGroupName: string, endpointName: string): void;
|
|
7
|
+
toSerializableRecipe(): SerializableRecipe;
|
|
8
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StepType } from "../../../types/recipe/recipe.js";
|
|
2
|
+
export class PortalRecipe {
|
|
3
|
+
constructor(name) {
|
|
4
|
+
this.recipe = {
|
|
5
|
+
name,
|
|
6
|
+
steps: []
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
addContentStep(key, content) {
|
|
10
|
+
this.recipe.steps.push({
|
|
11
|
+
key,
|
|
12
|
+
name: key, //TODO: Check if key is required
|
|
13
|
+
type: StepType.Content,
|
|
14
|
+
config: { content }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
addEndpointStep(key, description, endpointGroupName, endpointName) {
|
|
18
|
+
const endpointPermalink = `$e/${[endpointGroupName, endpointName].map(encodeURIComponent).join("/")}`;
|
|
19
|
+
this.recipe.steps.push({
|
|
20
|
+
key,
|
|
21
|
+
name: key, //TODO: Check if key is required
|
|
22
|
+
type: StepType.Endpoint,
|
|
23
|
+
config: {
|
|
24
|
+
description,
|
|
25
|
+
endpointPermalink
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
toSerializableRecipe() {
|
|
30
|
+
return this.recipe;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=portal-recipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-recipe.js","sourceRoot":"","sources":["../../../../src/application/portal/recipe/portal-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE/E,MAAM,OAAO,YAAY;IAGvB,YAAY,IAAY;QACtB,IAAI,CAAC,MAAM,GAAG;YACZ,IAAI;YACJ,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,GAAW,EAAE,OAAe;QACzC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;YACrB,GAAG;YACH,IAAI,EAAE,GAAG,EAAE,gCAAgC;YAC3C,IAAI,EAAE,QAAQ,CAAC,OAAO;YACtB,MAAM,EAAE,EAAE,OAAO,EAAE;SACpB,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,GAAW,EAAE,WAAmB,EAAE,iBAAyB,EAAE,YAAoB;QAC/F,MAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACtG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;YACrB,GAAG;YACH,IAAI,EAAE,GAAG,EAAE,gCAAgC;YAC3C,IAAI,EAAE,QAAQ,CAAC,QAAQ;YACvB,MAAM,EAAE;gBACN,WAAW;gBACX,iBAAiB;aAClB;SACF,CAAC,CAAC;IACL,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SerializableRecipe } from "../../../types/recipe/recipe.js";
|
|
2
|
+
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
3
|
+
import { Toc } from "../../../types/toc/toc.js";
|
|
4
|
+
import { FilePath } from "../../../types/file/filePath.js";
|
|
5
|
+
import { FileName } from "../../../types/file/fileName.js";
|
|
6
|
+
import { BuildContext } from "../../../types/build-context.js";
|
|
7
|
+
export declare class PortalRecipeGenerator {
|
|
8
|
+
private readonly fileService;
|
|
9
|
+
createRecipe(recipe: SerializableRecipe, tocFileContent: Toc, tocFilePath: FilePath, recipeName: string, recipeFileName: FileName, buildContext: BuildContext, buildDirectory: DirectoryPath): Promise<void>;
|
|
10
|
+
private addRecipeToToc;
|
|
11
|
+
private registerRecipeInBuildConfigFile;
|
|
12
|
+
private createMarkdownFile;
|
|
13
|
+
private createScriptFromRecipe;
|
|
14
|
+
private saveGeneratedRecipeScriptToBuildDirectory;
|
|
15
|
+
private generateVerifyFunction;
|
|
16
|
+
private addContentStepToScript;
|
|
17
|
+
private addEndpointStepToScript;
|
|
18
|
+
private getMarkdownFileContent;
|
|
19
|
+
private formatScript;
|
|
20
|
+
private toPascalCase;
|
|
21
|
+
}
|