@apimatic/cli 1.5.0 → 2.0.0-beta.2
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/LICENSE +21 -0
- package/README.md +128 -212
- package/apimatic.schema.json +550 -0
- package/lib/actions/action-result.js +3 -0
- package/lib/actions/action-result.js.map +1 -1
- package/lib/actions/api/transform.js +36 -33
- package/lib/actions/api/transform.js.map +1 -1
- package/lib/actions/api/validate.d.ts +9 -6
- package/lib/actions/api/validate.js +44 -38
- package/lib/actions/api/validate.js.map +1 -1
- package/lib/actions/auth/login.js +7 -4
- package/lib/actions/auth/login.js.map +1 -1
- package/lib/actions/auth/logout.js +2 -1
- package/lib/actions/auth/logout.js.map +1 -1
- package/lib/actions/auth/status.js +5 -3
- package/lib/actions/auth/status.js.map +1 -1
- package/lib/actions/plugin/generate.d.ts +5 -1
- package/lib/actions/plugin/generate.js +83 -56
- package/lib/actions/plugin/generate.js.map +1 -1
- package/lib/actions/plugin/publish.d.ts +2 -1
- package/lib/actions/plugin/publish.js +34 -37
- package/lib/actions/plugin/publish.js.map +1 -1
- package/lib/actions/plugin/record-metadata.d.ts +3 -2
- package/lib/actions/plugin/record-metadata.js +33 -30
- package/lib/actions/plugin/record-metadata.js.map +1 -1
- package/lib/actions/portal/generate.d.ts +8 -6
- package/lib/actions/portal/generate.js +50 -61
- package/lib/actions/portal/generate.js.map +1 -1
- package/lib/actions/portal/prepare-project.d.ts +25 -0
- package/lib/actions/portal/prepare-project.js +68 -0
- package/lib/actions/portal/prepare-project.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +21 -6
- package/lib/actions/portal/serve.js +170 -153
- package/lib/actions/portal/serve.js.map +1 -1
- package/lib/actions/publishing/profile/list.js +4 -2
- package/lib/actions/publishing/profile/list.js.map +1 -1
- package/lib/actions/quickstart.d.ts +23 -5
- package/lib/actions/quickstart.js +221 -21
- package/lib/actions/quickstart.js.map +1 -1
- package/lib/actions/sdk/generate.d.ts +4 -7
- package/lib/actions/sdk/generate.js +53 -93
- package/lib/actions/sdk/generate.js.map +1 -1
- package/lib/actions/sdk/publish/interactive.d.ts +4 -3
- package/lib/actions/sdk/publish/interactive.js +96 -97
- package/lib/actions/sdk/publish/interactive.js.map +1 -1
- package/lib/actions/sdk/publish/non-interactive.d.ts +4 -2
- package/lib/actions/sdk/publish/non-interactive.js +91 -90
- package/lib/actions/sdk/publish/non-interactive.js.map +1 -1
- package/lib/actions/sdk/publish.d.ts +3 -2
- package/lib/actions/sdk/publish.js +55 -53
- package/lib/actions/sdk/publish.js.map +1 -1
- package/lib/actions/sdk/record-published-sdk.d.ts +14 -0
- package/lib/actions/sdk/record-published-sdk.js +57 -0
- package/lib/actions/sdk/record-published-sdk.js.map +1 -0
- package/lib/client-utils/auth-manager.js +1 -1
- package/lib/client-utils/auth-manager.js.map +1 -1
- package/lib/commands/api/transform.d.ts +1 -1
- package/lib/commands/api/transform.js +44 -40
- package/lib/commands/api/transform.js.map +1 -1
- package/lib/commands/api/validate.js +16 -16
- package/lib/commands/api/validate.js.map +1 -1
- package/lib/commands/auth/login.js +14 -15
- package/lib/commands/auth/login.js.map +1 -1
- package/lib/commands/auth/logout.js +5 -6
- package/lib/commands/auth/logout.js.map +1 -1
- package/lib/commands/auth/status.js +4 -5
- package/lib/commands/auth/status.js.map +1 -1
- package/lib/commands/plugin/generate.d.ts +3 -3
- package/lib/commands/plugin/generate.js +20 -20
- package/lib/commands/plugin/generate.js.map +1 -1
- package/lib/commands/plugin/publish.js +18 -18
- package/lib/commands/plugin/publish.js.map +1 -1
- package/lib/commands/portal/generate.d.ts +9 -8
- package/lib/commands/portal/generate.js +36 -27
- package/lib/commands/portal/generate.js.map +1 -1
- package/lib/commands/portal/serve.d.ts +7 -9
- package/lib/commands/portal/serve.js +41 -44
- package/lib/commands/portal/serve.js.map +1 -1
- package/lib/commands/publishing/profile/list.js +8 -12
- package/lib/commands/publishing/profile/list.js.map +1 -1
- package/lib/commands/quickstart.d.ts +5 -5
- package/lib/commands/quickstart.js +18 -24
- package/lib/commands/quickstart.js.map +1 -1
- package/lib/commands/sdk/generate.d.ts +5 -7
- package/lib/commands/sdk/generate.js +58 -70
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/commands/sdk/publish.d.ts +6 -7
- package/lib/commands/sdk/publish.js +66 -60
- package/lib/commands/sdk/publish.js.map +1 -1
- package/lib/hooks/node-version.d.ts +3 -0
- package/lib/hooks/node-version.js +12 -0
- package/lib/hooks/node-version.js.map +1 -0
- package/lib/hooks/not-found.js +2 -3
- package/lib/hooks/not-found.js.map +1 -1
- package/lib/hooks/utils.d.ts +4 -2
- package/lib/hooks/utils.js +2 -2
- package/lib/hooks/utils.js.map +1 -1
- package/lib/infrastructure/env-info.d.ts +3 -0
- package/lib/infrastructure/env-info.js +13 -6
- package/lib/infrastructure/env-info.js.map +1 -1
- package/lib/infrastructure/file-service.d.ts +35 -8
- package/lib/infrastructure/file-service.js +149 -53
- package/lib/infrastructure/file-service.js.map +1 -1
- package/lib/infrastructure/file-watch-service.d.ts +40 -0
- package/lib/infrastructure/file-watch-service.js +167 -0
- package/lib/infrastructure/file-watch-service.js.map +1 -0
- package/lib/infrastructure/generation-status-poller.d.ts +8 -7
- package/lib/infrastructure/generation-status-poller.js +20 -12
- package/lib/infrastructure/generation-status-poller.js.map +1 -1
- package/lib/infrastructure/launcher-service.js +6 -6
- package/lib/infrastructure/launcher-service.js.map +1 -1
- package/lib/infrastructure/network-service.d.ts +3 -0
- package/lib/infrastructure/network-service.js +15 -1
- package/lib/infrastructure/network-service.js.map +1 -1
- package/lib/infrastructure/portal-build-service.d.ts +19 -0
- package/lib/infrastructure/portal-build-service.js +58 -0
- package/lib/infrastructure/portal-build-service.js.map +1 -0
- package/lib/infrastructure/portal-dev-server-service.d.ts +29 -0
- package/lib/infrastructure/portal-dev-server-service.js +135 -0
- package/lib/infrastructure/portal-dev-server-service.js.map +1 -0
- package/lib/infrastructure/portal-pages-service.d.ts +17 -0
- package/lib/infrastructure/portal-pages-service.js +103 -0
- package/lib/infrastructure/portal-pages-service.js.map +1 -0
- package/lib/infrastructure/portal-project-service.d.ts +77 -0
- package/lib/infrastructure/portal-project-service.js +309 -0
- package/lib/infrastructure/portal-project-service.js.map +1 -0
- package/lib/infrastructure/service-error.d.ts +1 -0
- package/lib/infrastructure/service-error.js +39 -41
- package/lib/infrastructure/service-error.js.map +1 -1
- package/lib/infrastructure/services/api-client-factory.js +15 -13
- package/lib/infrastructure/services/api-client-factory.js.map +1 -1
- package/lib/infrastructure/services/api-service.d.ts +7 -5
- package/lib/infrastructure/services/api-service.js +28 -20
- package/lib/infrastructure/services/api-service.js.map +1 -1
- package/lib/infrastructure/services/auth-service.js +4 -9
- package/lib/infrastructure/services/auth-service.js.map +1 -1
- package/lib/infrastructure/services/file-download-service.js +3 -3
- package/lib/infrastructure/services/file-download-service.js.map +1 -1
- package/lib/infrastructure/services/plugin-service.d.ts +1 -8
- package/lib/infrastructure/services/plugin-service.js +11 -22
- package/lib/infrastructure/services/plugin-service.js.map +1 -1
- package/lib/infrastructure/services/portal-artifacts-service.d.ts +44 -0
- package/lib/infrastructure/services/portal-artifacts-service.js +268 -0
- package/lib/infrastructure/services/portal-artifacts-service.js.map +1 -0
- package/lib/infrastructure/services/portal-authorization-service.d.ts +22 -0
- package/lib/infrastructure/services/portal-authorization-service.js +23 -0
- package/lib/infrastructure/services/portal-authorization-service.js.map +1 -0
- package/lib/infrastructure/services/publishing-api-service.d.ts +1 -1
- package/lib/infrastructure/services/publishing-api-service.js +11 -15
- package/lib/infrastructure/services/publishing-api-service.js.map +1 -1
- package/lib/infrastructure/services/sdk-generation-service.d.ts +21 -0
- package/lib/infrastructure/services/sdk-generation-service.js +118 -0
- package/lib/infrastructure/services/sdk-generation-service.js.map +1 -0
- package/lib/infrastructure/services/telemetry-service.js +5 -4
- package/lib/infrastructure/services/telemetry-service.js.map +1 -1
- package/lib/infrastructure/services/transformation-service.js +29 -32
- package/lib/infrastructure/services/transformation-service.js.map +1 -1
- package/lib/infrastructure/services/validation-service.d.ts +12 -53
- package/lib/infrastructure/services/validation-service.js +24 -199
- package/lib/infrastructure/services/validation-service.js.map +1 -1
- package/lib/infrastructure/timer-extensions.d.ts +2 -0
- package/lib/infrastructure/timer-extensions.js +10 -0
- package/lib/infrastructure/timer-extensions.js.map +1 -0
- package/lib/infrastructure/tmp-extensions.d.ts +31 -1
- package/lib/infrastructure/tmp-extensions.js +86 -3
- package/lib/infrastructure/tmp-extensions.js.map +1 -1
- package/lib/infrastructure/zip-service.js +2 -2
- package/lib/infrastructure/zip-service.js.map +1 -1
- package/lib/prompts/api/validate.d.ts +6 -7
- package/lib/prompts/api/validate.js +12 -12
- package/lib/prompts/api/validate.js.map +1 -1
- package/lib/prompts/format.d.ts +4 -0
- package/lib/prompts/format.js +5 -0
- package/lib/prompts/format.js.map +1 -1
- package/lib/prompts/plugin/generate.d.ts +17 -12
- package/lib/prompts/plugin/generate.js +94 -44
- package/lib/prompts/plugin/generate.js.map +1 -1
- package/lib/prompts/plugin/publish.d.ts +2 -1
- package/lib/prompts/plugin/publish.js +8 -7
- package/lib/prompts/plugin/publish.js.map +1 -1
- package/lib/prompts/plugin/record-metadata.d.ts +1 -0
- package/lib/prompts/plugin/record-metadata.js +10 -7
- package/lib/prompts/plugin/record-metadata.js.map +1 -1
- package/lib/prompts/portal/artifacts.d.ts +8 -0
- package/lib/prompts/portal/artifacts.js +26 -0
- package/lib/prompts/portal/artifacts.js.map +1 -0
- package/lib/prompts/portal/authorization.d.ts +6 -0
- package/lib/prompts/portal/authorization.js +29 -0
- package/lib/prompts/portal/authorization.js.map +1 -0
- package/lib/prompts/portal/code-samples.d.ts +1 -0
- package/lib/prompts/portal/code-samples.js +9 -0
- package/lib/prompts/portal/code-samples.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +14 -9
- package/lib/prompts/portal/generate.js +48 -26
- package/lib/prompts/portal/generate.js.map +1 -1
- package/lib/prompts/portal/prepare-project.d.ts +20 -0
- package/lib/prompts/portal/prepare-project.js +36 -0
- package/lib/prompts/portal/prepare-project.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +32 -12
- package/lib/prompts/portal/serve.js +100 -39
- package/lib/prompts/portal/serve.js.map +1 -1
- package/lib/prompts/portal/source.d.ts +26 -0
- package/lib/prompts/portal/source.js +253 -0
- package/lib/prompts/portal/source.js.map +1 -0
- package/lib/prompts/prompt.d.ts +11 -3
- package/lib/prompts/prompt.js +39 -15
- package/lib/prompts/prompt.js.map +1 -1
- package/lib/prompts/quickstart.d.ts +46 -3
- package/lib/prompts/quickstart.js +193 -12
- package/lib/prompts/quickstart.js.map +1 -1
- package/lib/prompts/sdk/generate.d.ts +15 -13
- package/lib/prompts/sdk/generate.js +29 -32
- package/lib/prompts/sdk/generate.js.map +1 -1
- package/lib/prompts/sdk/publish/interactive.d.ts +10 -6
- package/lib/prompts/sdk/publish/interactive.js +26 -24
- package/lib/prompts/sdk/publish/interactive.js.map +1 -1
- package/lib/prompts/sdk/publish/non-interactive.d.ts +2 -1
- package/lib/prompts/sdk/publish/non-interactive.js +5 -4
- package/lib/prompts/sdk/publish/non-interactive.js.map +1 -1
- package/lib/prompts/sdk/publish.d.ts +3 -3
- package/lib/prompts/sdk/publish.js +13 -17
- package/lib/prompts/sdk/publish.js.map +1 -1
- package/lib/prompts/sdk/record-published-sdk.d.ts +7 -0
- package/lib/prompts/sdk/record-published-sdk.js +26 -0
- package/lib/prompts/sdk/record-published-sdk.js.map +1 -0
- package/lib/types/apimatic-config/document.d.ts +68 -0
- package/lib/types/apimatic-config/document.js +161 -0
- package/lib/types/apimatic-config/document.js.map +1 -0
- package/lib/types/apimatic-config/languages-block.d.ts +39 -0
- package/lib/types/apimatic-config/languages-block.js +58 -0
- package/lib/types/apimatic-config/languages-block.js.map +1 -0
- package/lib/types/apimatic-config-context.d.ts +48 -0
- package/lib/types/apimatic-config-context.js +121 -0
- package/lib/types/apimatic-config-context.js.map +1 -0
- package/lib/types/build/build.d.ts +1 -89
- package/lib/types/build/build.js +6 -161
- package/lib/types/build/build.js.map +1 -1
- package/lib/types/events/domain-event.js +3 -0
- package/lib/types/events/domain-event.js.map +1 -1
- package/lib/types/events/quickstart-completed.js +3 -3
- package/lib/types/events/quickstart-completed.js.map +1 -1
- package/lib/types/events/quickstart-initiated.js +3 -3
- package/lib/types/events/quickstart-initiated.js.map +1 -1
- package/lib/types/events/sdk-publish-validation-failed.js +1 -1
- package/lib/types/events/sdk-publish-validation-failed.js.map +1 -1
- package/lib/types/file/directory.d.ts +4 -9
- package/lib/types/file/directory.js +17 -65
- package/lib/types/file/directory.js.map +1 -1
- package/lib/types/file/directoryPath.d.ts +17 -0
- package/lib/types/file/directoryPath.js +47 -2
- package/lib/types/file/directoryPath.js.map +1 -1
- package/lib/types/file/fileName.d.ts +8 -0
- package/lib/types/file/fileName.js +28 -6
- package/lib/types/file/fileName.js.map +1 -1
- package/lib/types/file/filePath.d.ts +18 -2
- package/lib/types/file/filePath.js +39 -4
- package/lib/types/file/filePath.js.map +1 -1
- package/lib/types/file/resource-input.js +1 -2
- package/lib/types/file/resource-input.js.map +1 -1
- package/lib/types/file/urlPath.js +2 -1
- package/lib/types/file/urlPath.js.map +1 -1
- package/lib/types/flags-provider.js +22 -22
- package/lib/types/flags-provider.js.map +1 -1
- package/lib/types/package-settings-context.js +2 -1
- package/lib/types/package-settings-context.js.map +1 -1
- package/lib/types/plugin/plugin-config.d.ts +10 -50
- package/lib/types/plugin/plugin-config.js +7 -1
- package/lib/types/plugin/plugin-config.js.map +1 -1
- package/lib/types/plugin-config-context.d.ts +30 -37
- package/lib/types/plugin-config-context.js +108 -139
- package/lib/types/plugin-config-context.js.map +1 -1
- package/lib/types/plugin-context.js +3 -2
- package/lib/types/plugin-context.js.map +1 -1
- package/lib/types/portal/code-samples.d.ts +27 -0
- package/lib/types/portal/code-samples.js +67 -0
- package/lib/types/portal/code-samples.js.map +1 -0
- package/lib/types/portal/config/ai-config.d.ts +15 -0
- package/lib/types/portal/config/ai-config.js +26 -0
- package/lib/types/portal/config/ai-config.js.map +1 -0
- package/lib/types/portal/config/brand-config.d.ts +55 -0
- package/lib/types/portal/config/brand-config.js +105 -0
- package/lib/types/portal/config/brand-config.js.map +1 -0
- package/lib/types/portal/config/color.d.ts +19 -0
- package/lib/types/portal/config/color.js +43 -0
- package/lib/types/portal/config/color.js.map +1 -0
- package/lib/types/portal/config/fields.d.ts +23 -0
- package/lib/types/portal/config/fields.js +67 -0
- package/lib/types/portal/config/fields.js.map +1 -0
- package/lib/types/portal/config/link.d.ts +18 -0
- package/lib/types/portal/config/link.js +72 -0
- package/lib/types/portal/config/link.js.map +1 -0
- package/lib/types/portal/config/navigation-config.d.ts +13 -0
- package/lib/types/portal/config/navigation-config.js +30 -0
- package/lib/types/portal/config/navigation-config.js.map +1 -0
- package/lib/types/portal/config/site-config.d.ts +32 -0
- package/lib/types/portal/config/site-config.js +88 -0
- package/lib/types/portal/config/site-config.js.map +1 -0
- package/lib/types/portal/config/static-asset.d.ts +25 -0
- package/lib/types/portal/config/static-asset.js +77 -0
- package/lib/types/portal/config/static-asset.js.map +1 -0
- package/lib/types/portal/content-notices.d.ts +20 -0
- package/lib/types/portal/content-notices.js +2 -0
- package/lib/types/portal/content-notices.js.map +1 -0
- package/lib/types/portal/content-tree.d.ts +103 -0
- package/lib/types/portal/content-tree.js +344 -0
- package/lib/types/portal/content-tree.js.map +1 -0
- package/lib/types/portal/endpoint.d.ts +6 -0
- package/lib/types/portal/endpoint.js +12 -0
- package/lib/types/portal/endpoint.js.map +1 -0
- package/lib/types/portal/generated-pages.d.ts +68 -0
- package/lib/types/portal/generated-pages.js +111 -0
- package/lib/types/portal/generated-pages.js.map +1 -0
- package/lib/types/portal/generation-status.d.ts +31 -0
- package/lib/types/portal/generation-status.js +26 -0
- package/lib/types/portal/generation-status.js.map +1 -0
- package/lib/types/portal/openapi-document.d.ts +48 -0
- package/lib/types/portal/openapi-document.js +138 -0
- package/lib/types/portal/openapi-document.js.map +1 -0
- package/lib/types/portal/page-fragments.d.ts +13 -0
- package/lib/types/portal/page-fragments.js +24 -0
- package/lib/types/portal/page-fragments.js.map +1 -0
- package/lib/types/portal/page-template.d.ts +15 -0
- package/lib/types/portal/page-template.js +64 -0
- package/lib/types/portal/page-template.js.map +1 -0
- package/lib/types/portal/page.d.ts +24 -0
- package/lib/types/portal/page.js +100 -0
- package/lib/types/portal/page.js.map +1 -0
- package/lib/types/portal/portal-artifacts.d.ts +25 -0
- package/lib/types/portal/portal-artifacts.js +30 -0
- package/lib/types/portal/portal-artifacts.js.map +1 -0
- package/lib/types/portal/portal-config.d.ts +69 -0
- package/lib/types/portal/portal-config.js +105 -0
- package/lib/types/portal/portal-config.js.map +1 -0
- package/lib/types/portal/portal-downloads.d.ts +8 -0
- package/lib/types/portal/portal-downloads.js +14 -0
- package/lib/types/portal/portal-downloads.js.map +1 -0
- package/lib/types/portal/portal-languages.d.ts +15 -0
- package/lib/types/portal/portal-languages.js +45 -0
- package/lib/types/portal/portal-languages.js.map +1 -0
- package/lib/types/portal/portal-navigation.d.ts +65 -0
- package/lib/types/portal/portal-navigation.js +217 -0
- package/lib/types/portal/portal-navigation.js.map +1 -0
- package/lib/types/portal/portal-sdk.d.ts +15 -0
- package/lib/types/portal/portal-sdk.js +28 -0
- package/lib/types/portal/portal-sdk.js.map +1 -0
- package/lib/types/portal/portal-source.d.ts +129 -0
- package/lib/types/portal/portal-source.js +2 -0
- package/lib/types/portal/portal-source.js.map +1 -0
- package/lib/types/portal/portal-stylesheet.d.ts +19 -0
- package/lib/types/portal/portal-stylesheet.js +40 -0
- package/lib/types/portal/portal-stylesheet.js.map +1 -0
- package/lib/types/portal/portal-tabs.d.ts +33 -0
- package/lib/types/portal/portal-tabs.js +38 -0
- package/lib/types/portal/portal-tabs.js.map +1 -0
- package/lib/types/portal/preview-config.d.ts +20 -0
- package/lib/types/portal/preview-config.js +32 -0
- package/lib/types/portal/preview-config.js.map +1 -0
- package/lib/types/portal/preview-content.d.ts +18 -0
- package/lib/types/portal/preview-content.js +50 -0
- package/lib/types/portal/preview-content.js.map +1 -0
- package/lib/types/portal/published-package.d.ts +12 -0
- package/lib/types/portal/published-package.js +35 -0
- package/lib/types/portal/published-package.js.map +1 -0
- package/lib/types/portal/unknown-fields.d.ts +5 -0
- package/lib/types/portal/unknown-fields.js +10 -0
- package/lib/types/portal/unknown-fields.js.map +1 -0
- package/lib/types/portal-context.d.ts +38 -6
- package/lib/types/portal-context.js +71 -24
- package/lib/types/portal-context.js.map +1 -1
- package/lib/types/portal-source-context.d.ts +77 -0
- package/lib/types/portal-source-context.js +408 -0
- package/lib/types/portal-source-context.js.map +1 -0
- package/lib/types/project-context.d.ts +49 -0
- package/lib/types/project-context.js +151 -0
- package/lib/types/project-context.js.map +1 -0
- package/lib/types/project-layout.d.ts +9 -0
- package/lib/types/project-layout.js +10 -0
- package/lib/types/project-layout.js.map +1 -0
- package/lib/types/publish/package-settings-configuration.d.ts +2 -0
- package/lib/types/publish/profile-id.js +1 -0
- package/lib/types/publish/profile-id.js.map +1 -1
- package/lib/types/publish/publishing-profile.d.ts +3 -1
- package/lib/types/publish/publishing-profile.js +33 -15
- package/lib/types/publish/publishing-profile.js.map +1 -1
- package/lib/types/publish/publishing-profiles.js +2 -1
- package/lib/types/publish/publishing-profiles.js.map +1 -1
- package/lib/types/publish/version.js +1 -0
- package/lib/types/publish/version.js.map +1 -1
- package/lib/types/resource-context.js +3 -2
- package/lib/types/resource-context.js.map +1 -1
- package/lib/types/sdk/generate.d.ts +22 -16
- package/lib/types/sdk/generate.js +64 -41
- package/lib/types/sdk/generate.js.map +1 -1
- package/lib/types/sdk/stability-choice.d.ts +12 -0
- package/lib/types/sdk/stability-choice.js +24 -0
- package/lib/types/sdk/stability-choice.js.map +1 -0
- package/lib/types/sdk-context.d.ts +4 -5
- package/lib/types/sdk-context.js +10 -18
- package/lib/types/sdk-context.js.map +1 -1
- package/lib/types/spec-context.d.ts +5 -4
- package/lib/types/spec-context.js +9 -8
- package/lib/types/spec-context.js.map +1 -1
- package/lib/types/temp-context.d.ts +1 -1
- package/lib/types/temp-context.js +5 -4
- package/lib/types/temp-context.js.map +1 -1
- package/lib/types/transform-context.d.ts +9 -5
- package/lib/types/transform-context.js +21 -18
- package/lib/types/transform-context.js.map +1 -1
- package/lib/utils/error-utils.d.ts +2 -0
- package/lib/utils/error-utils.js +5 -0
- package/lib/utils/error-utils.js.map +1 -0
- package/lib/utils/json-utils.d.ts +2 -0
- package/lib/utils/json-utils.js +4 -0
- package/lib/utils/json-utils.js.map +1 -0
- package/lib/utils/string-utils.d.ts +8 -1
- package/lib/utils/string-utils.js +13 -26
- package/lib/utils/string-utils.js.map +1 -1
- package/lib/utils/utils.d.ts +1 -3
- package/lib/utils/utils.js +12 -40
- package/lib/utils/utils.js.map +1 -1
- package/oclif.manifest.json +154 -442
- package/package.json +47 -25
- package/portal-pages/context-plugin.mdx +26 -0
- package/portal-pages/sdk.mdx +8 -0
- package/portal-pages/sdks.mdx +11 -0
- package/portal-template/NOTICE +37 -0
- package/portal-template/downloads.ts +41 -0
- package/portal-template/generated-pages-reload.ts +51 -0
- package/portal-template/package.json +11 -0
- package/portal-template/portal-config.ts +32 -0
- package/portal-template/prerender-pages.ts +81 -0
- package/portal-template/spec-reload.ts +26 -0
- package/portal-template/src/components/api-page.tsx +15 -0
- package/portal-template/src/components/code-block.tsx +9 -0
- package/portal-template/src/components/command-block.tsx +50 -0
- package/portal-template/src/components/example-layout.tsx +99 -0
- package/portal-template/src/components/logos.tsx +127 -0
- package/portal-template/src/components/mdx.tsx +28 -0
- package/portal-template/src/components/not-found.tsx +11 -0
- package/portal-template/src/components/plugin-install.tsx +22 -0
- package/portal-template/src/components/plugin-support.tsx +53 -0
- package/portal-template/src/components/sdk-actions.tsx +79 -0
- package/portal-template/src/components/sdk-cards.tsx +100 -0
- package/portal-template/src/components/search.tsx +41 -0
- package/portal-template/src/components/usage-tabs.tsx +92 -0
- package/portal-template/src/lib/code-samples.server.ts +40 -0
- package/portal-template/src/lib/code-samples.ts +43 -0
- package/portal-template/src/lib/code-titles.ts +29 -0
- package/portal-template/src/lib/install-command.ts +13 -0
- package/portal-template/src/lib/json.ts +5 -0
- package/portal-template/src/lib/layout.shared.tsx +41 -0
- package/portal-template/src/lib/layout.tsx +16 -0
- package/portal-template/src/lib/llms.server.ts +54 -0
- package/portal-template/src/lib/media-adapters.ts +34 -0
- package/portal-template/src/lib/navigation.ts +406 -0
- package/portal-template/src/lib/openapi-bundle.server.ts +343 -0
- package/portal-template/src/lib/openapi-filter.ts +191 -0
- package/portal-template/src/lib/openapi-labels.ts +15 -0
- package/portal-template/src/lib/openapi-methods.ts +12 -0
- package/portal-template/src/lib/openapi-section.server.ts +280 -0
- package/portal-template/src/lib/openapi-slim.ts +202 -0
- package/portal-template/src/lib/openapi.server.ts +16 -0
- package/portal-template/src/lib/portal-types.ts +36 -0
- package/portal-template/src/lib/portal.server.ts +13 -0
- package/portal-template/src/lib/portal.ts +11 -0
- package/portal-template/src/lib/rehype-code-titles.ts +53 -0
- package/portal-template/src/lib/request-examples.ts +72 -0
- package/portal-template/src/lib/seo.ts +21 -0
- package/portal-template/src/lib/shared.ts +51 -0
- package/portal-template/src/lib/shiki-bundle.ts +104 -0
- package/portal-template/src/lib/sitemap.server.ts +20 -0
- package/portal-template/src/lib/source.server.ts +27 -0
- package/portal-template/src/lib/source.ts +49 -0
- package/portal-template/src/lib/tabs.ts +37 -0
- package/portal-template/src/router.tsx +12 -0
- package/portal-template/src/routes/$.tsx +194 -0
- package/portal-template/src/routes/__root.tsx +56 -0
- package/portal-template/src/routes/api/search[.]json.ts +9 -0
- package/portal-template/src/routes/llms-full[.]txt.ts +10 -0
- package/portal-template/src/routes/llms[.]txt.ts +10 -0
- package/portal-template/src/routes/robots[.]txt.ts +10 -0
- package/portal-template/src/routes/sitemap[.]xml.ts +10 -0
- package/portal-template/src/routes/spa-shell.tsx +7 -0
- package/portal-template/src/routes/{$}[.]md.ts +21 -0
- package/portal-template/src/styles/app.css +33 -0
- package/portal-template/tsconfig.json +26 -0
- package/portal-template/vite.config.ts +68 -0
- package/lib/actions/plugin/record-sdk.d.ts +0 -14
- package/lib/actions/plugin/record-sdk.js +0 -60
- package/lib/actions/plugin/record-sdk.js.map +0 -1
- package/lib/actions/portal/copilot.d.ts +0 -17
- package/lib/actions/portal/copilot.js +0 -89
- package/lib/actions/portal/copilot.js.map +0 -1
- package/lib/actions/portal/quickstart.d.ts +0 -18
- package/lib/actions/portal/quickstart.js +0 -238
- package/lib/actions/portal/quickstart.js.map +0 -1
- package/lib/actions/portal/recipe/new-recipe.d.ts +0 -15
- package/lib/actions/portal/recipe/new-recipe.js +0 -177
- package/lib/actions/portal/recipe/new-recipe.js.map +0 -1
- package/lib/actions/portal/toc/new-toc.d.ts +0 -21
- package/lib/actions/portal/toc/new-toc.js +0 -95
- package/lib/actions/portal/toc/new-toc.js.map +0 -1
- package/lib/actions/sdk/merge-source-tree.d.ts +0 -12
- package/lib/actions/sdk/merge-source-tree.js +0 -78
- package/lib/actions/sdk/merge-source-tree.js.map +0 -1
- package/lib/actions/sdk/quickstart.d.ts +0 -18
- package/lib/actions/sdk/quickstart.js +0 -188
- package/lib/actions/sdk/quickstart.js.map +0 -1
- package/lib/actions/sdk/save-changes.d.ts +0 -8
- package/lib/actions/sdk/save-changes.js +0 -93
- package/lib/actions/sdk/save-changes.js.map +0 -1
- package/lib/application/portal/recipe/portal-recipe.d.ts +0 -8
- package/lib/application/portal/recipe/portal-recipe.js +0 -33
- package/lib/application/portal/recipe/portal-recipe.js.map +0 -1
- package/lib/application/portal/recipe/recipe-generator.d.ts +0 -21
- package/lib/application/portal/recipe/recipe-generator.js +0 -130
- package/lib/application/portal/recipe/recipe-generator.js.map +0 -1
- package/lib/application/portal/toc/toc-content-parser.d.ts +0 -5
- package/lib/application/portal/toc/toc-content-parser.js +0 -44
- package/lib/application/portal/toc/toc-content-parser.js.map +0 -1
- package/lib/application/portal/toc/toc-structure-generator.d.ts +0 -11
- package/lib/application/portal/toc/toc-structure-generator.js +0 -165
- package/lib/application/portal/toc/toc-structure-generator.js.map +0 -1
- package/lib/commands/portal/copilot.d.ts +0 -13
- package/lib/commands/portal/copilot.js +0 -34
- package/lib/commands/portal/copilot.js.map +0 -1
- package/lib/commands/portal/recipe/new.d.ts +0 -12
- package/lib/commands/portal/recipe/new.js +0 -45
- package/lib/commands/portal/recipe/new.js.map +0 -1
- package/lib/commands/portal/toc/new.d.ts +0 -16
- package/lib/commands/portal/toc/new.js +0 -68
- package/lib/commands/portal/toc/new.js.map +0 -1
- package/lib/commands/sdk/save-changes.d.ts +0 -14
- package/lib/commands/sdk/save-changes.js +0 -51
- package/lib/commands/sdk/save-changes.js.map +0 -1
- package/lib/infrastructure/debounce-service.d.ts +0 -10
- package/lib/infrastructure/debounce-service.js +0 -55
- package/lib/infrastructure/debounce-service.js.map +0 -1
- package/lib/infrastructure/services/portal-service.d.ts +0 -43
- package/lib/infrastructure/services/portal-service.js +0 -337
- package/lib/infrastructure/services/portal-service.js.map +0 -1
- package/lib/prompts/plugin/record-sdk.d.ts +0 -9
- package/lib/prompts/plugin/record-sdk.js +0 -40
- package/lib/prompts/plugin/record-sdk.js.map +0 -1
- package/lib/prompts/portal/copilot.d.ts +0 -18
- package/lib/prompts/portal/copilot.js +0 -82
- package/lib/prompts/portal/copilot.js.map +0 -1
- package/lib/prompts/portal/quickstart.d.ts +0 -42
- package/lib/prompts/portal/quickstart.js +0 -243
- package/lib/prompts/portal/quickstart.js.map +0 -1
- package/lib/prompts/portal/recipe/new-recipe.d.ts +0 -29
- package/lib/prompts/portal/recipe/new-recipe.js +0 -165
- package/lib/prompts/portal/recipe/new-recipe.js.map +0 -1
- package/lib/prompts/portal/toc/new-toc.d.ts +0 -16
- package/lib/prompts/portal/toc/new-toc.js +0 -50
- package/lib/prompts/portal/toc/new-toc.js.map +0 -1
- package/lib/prompts/sdk/merge-source-tree.d.ts +0 -22
- package/lib/prompts/sdk/merge-source-tree.js +0 -90
- package/lib/prompts/sdk/merge-source-tree.js.map +0 -1
- package/lib/prompts/sdk/quickstart.d.ts +0 -38
- package/lib/prompts/sdk/quickstart.js +0 -196
- package/lib/prompts/sdk/quickstart.js.map +0 -1
- package/lib/prompts/sdk/save-changes.d.ts +0 -21
- package/lib/prompts/sdk/save-changes.js +0 -84
- package/lib/prompts/sdk/save-changes.js.map +0 -1
- package/lib/types/build-context.d.ts +0 -26
- package/lib/types/build-context.js +0 -111
- package/lib/types/build-context.js.map +0 -1
- package/lib/types/events/recipe-creation-failed.d.ts +0 -5
- package/lib/types/events/recipe-creation-failed.js +0 -8
- package/lib/types/events/recipe-creation-failed.js.map +0 -1
- package/lib/types/events/sdk-changes-saved.d.ts +0 -8
- package/lib/types/events/sdk-changes-saved.js +0 -11
- package/lib/types/events/sdk-changes-saved.js.map +0 -1
- package/lib/types/events/sdk-changes-tracked.d.ts +0 -8
- package/lib/types/events/sdk-changes-tracked.js +0 -11
- package/lib/types/events/sdk-changes-tracked.js.map +0 -1
- package/lib/types/events/sdk-conflicts-resolved.d.ts +0 -8
- package/lib/types/events/sdk-conflicts-resolved.js +0 -11
- package/lib/types/events/sdk-conflicts-resolved.js.map +0 -1
- package/lib/types/events/toc-creation-failed.d.ts +0 -5
- package/lib/types/events/toc-creation-failed.js +0 -8
- package/lib/types/events/toc-creation-failed.js.map +0 -1
- package/lib/types/merge-source-tree-context.d.ts +0 -28
- package/lib/types/merge-source-tree-context.js +0 -63
- package/lib/types/merge-source-tree-context.js.map +0 -1
- package/lib/types/plugin/language-entry.d.ts +0 -9
- package/lib/types/plugin/language-entry.js +0 -64
- package/lib/types/plugin/language-entry.js.map +0 -1
- package/lib/types/recipe/recipe.d.ts +0 -22
- package/lib/types/recipe/recipe.js +0 -6
- package/lib/types/recipe/recipe.js.map +0 -1
- package/lib/types/recipe-context.d.ts +0 -9
- package/lib/types/recipe-context.js +0 -26
- package/lib/types/recipe-context.js.map +0 -1
- package/lib/types/save-changes-context.d.ts +0 -17
- package/lib/types/save-changes-context.js +0 -42
- package/lib/types/save-changes-context.js.map +0 -1
- package/lib/types/sdl/sdl.d.ts +0 -10
- package/lib/types/sdl/sdl.js +0 -18
- package/lib/types/sdl/sdl.js.map +0 -1
- package/lib/types/toc/toc-components.d.ts +0 -36
- package/lib/types/toc/toc-components.js +0 -94
- package/lib/types/toc/toc-components.js.map +0 -1
- package/lib/types/toc/toc.d.ts +0 -67
- package/lib/types/toc/toc.js +0 -2
- package/lib/types/toc/toc.js.map +0 -1
- package/lib/types/toc-context.d.ts +0 -12
- package/lib/types/toc-context.js +0 -26
- package/lib/types/toc-context.js.map +0 -1
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { Status } from '@apimatic/sdk';
|
|
2
2
|
import { err, ok } from 'neverthrow';
|
|
3
|
+
import { REQUEST_TIMEOUT_MS } from '../config/axios-config.js';
|
|
4
|
+
import { replaceHTML } from '../utils/utils.js';
|
|
3
5
|
import { ServiceError } from './service-error.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
import { sleep } from './timer-extensions.js';
|
|
7
|
+
export const TIMING_DEFAULTS = {
|
|
8
|
+
pollIntervalMs: 3000,
|
|
9
|
+
// Past `/portal-artifacts`' own 25-minute limit, so the user reads the server's overrun message.
|
|
10
|
+
generationTimeoutMs: 30 * 60 * 1000,
|
|
11
|
+
requestTimeoutMs: REQUEST_TIMEOUT_MS
|
|
12
|
+
};
|
|
11
13
|
export async function pollUntilCompleted({ pollIntervalMs, fetchStatus, timeout, formatValidationError = formatValidationErrors }) {
|
|
12
14
|
const deadline = Date.now() + timeout.budgetMs;
|
|
13
15
|
for (;;) {
|
|
14
|
-
await
|
|
16
|
+
await sleep(pollIntervalMs);
|
|
15
17
|
const statusResult = await fetchStatus();
|
|
16
18
|
if (statusResult.isErr()) {
|
|
17
19
|
return err(statusResult.error);
|
|
@@ -29,7 +31,7 @@ export async function pollUntilCompleted({ pollIntervalMs, fetchStatus, timeout,
|
|
|
29
31
|
}
|
|
30
32
|
if (status === Status.SubscriptionError) {
|
|
31
33
|
const message = Object.values(asMessages(errors)).flat()[0];
|
|
32
|
-
return err(ServiceError.forbidden('Access denied to resource.' + (message ? '\n
|
|
34
|
+
return err(ServiceError.forbidden('Access denied to resource.' + (message ? '\n' + bulleted([message]) : '')));
|
|
33
35
|
}
|
|
34
36
|
// Every other status keeps the run alive rather than ending it: an endpoint reporting
|
|
35
37
|
// its own in-flight vocabulary is healthy, and the plugin orchestrator reports
|
|
@@ -41,16 +43,22 @@ export async function pollUntilCompleted({ pollIntervalMs, fetchStatus, timeout,
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
46
|
+
/** Each message under a bullet of its own, any further line of it indented beneath. */
|
|
47
|
+
export const bulleted = (messages) => messages.map((message) => `- ${message.replaceAll('\n', '\n ')}`).join('\n');
|
|
44
48
|
export const formatValidationErrors = (errors) => {
|
|
45
49
|
const messages = Object.values(errors).flat();
|
|
46
|
-
return 'One or more validation errors occurred.' + (messages.length ? '\n
|
|
50
|
+
return 'One or more validation errors occurred.' + (messages.length ? '\n' + bulleted(messages) : '');
|
|
47
51
|
};
|
|
48
52
|
const timedOutMessage = (label, budgetMs) => {
|
|
49
|
-
const minutes = Math.floor(budgetMs /
|
|
53
|
+
const minutes = Math.floor(budgetMs / 60_000);
|
|
50
54
|
if (minutes < 1) {
|
|
51
55
|
return `${label} timed out.`;
|
|
52
56
|
}
|
|
53
57
|
return `${label} timed out after ${minutes} ${minutes === 1 ? 'minute' : 'minutes'}.`;
|
|
54
58
|
};
|
|
55
|
-
|
|
59
|
+
// The server writes its messages as HTML; the terminal gets their text.
|
|
60
|
+
const asMessages = (errors) => Object.fromEntries(Object.entries(errors ?? {}).map(([key, messages]) => [
|
|
61
|
+
key,
|
|
62
|
+
(Array.isArray(messages) ? messages : [messages]).map((message) => replaceHTML(String(message)))
|
|
63
|
+
]));
|
|
56
64
|
//# sourceMappingURL=generation-status-poller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generation-status-poller.js","sourceRoot":"","sources":["../../src/infrastructure/generation-status-poller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"generation-status-poller.js","sourceRoot":"","sources":["../../src/infrastructure/generation-status-poller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,cAAc,EAAE,IAAI;IACpB,iGAAiG;IACjG,mBAAmB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACnC,gBAAgB,EAAE,kBAAkB;CACrC,CAAC;AAwBF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAA6B,EACnE,cAAc,EACd,WAAW,EACX,OAAO,EACP,qBAAqB,GAAG,sBAAsB,EAC5B;IAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IAE/C,SAAS,CAAC;QACR,MAAM,KAAK,CAAC,cAAc,CAAC,CAAC;QAE5B,MAAM,YAAY,GAAG,MAAM,WAAW,EAAE,CAAC;QACzC,IAAI,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC;YACzB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AO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;CACjG,CAAC,CACH,CAAC"}
|
|
@@ -12,7 +12,7 @@ export class LauncherService {
|
|
|
12
12
|
await execa("code", args);
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
|
-
catch
|
|
15
|
+
catch {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -22,7 +22,7 @@ export class LauncherService {
|
|
|
22
22
|
await execa(command, ["code"]);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
|
-
catch
|
|
25
|
+
catch {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -32,7 +32,7 @@ export class LauncherService {
|
|
|
32
32
|
await execa("code", ["--new-window", "--wait", ...args]);
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
|
-
catch
|
|
35
|
+
catch {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -42,7 +42,7 @@ export class LauncherService {
|
|
|
42
42
|
try {
|
|
43
43
|
await execa("code", ["--wait", filePath.toString()]);
|
|
44
44
|
}
|
|
45
|
-
catch
|
|
45
|
+
catch {
|
|
46
46
|
// TODO: check for fallback (start)
|
|
47
47
|
if (process.platform === "win32") {
|
|
48
48
|
await execa("cmd", ["/c", "start", "/wait", "notepad", filePath.toString()], { stdio: "ignore" });
|
|
@@ -87,7 +87,7 @@ export class LauncherService {
|
|
|
87
87
|
const child = spawn(command, args, { stdio: "ignore", detached: true });
|
|
88
88
|
child.unref(); // Let it run without blocking
|
|
89
89
|
}
|
|
90
|
-
catch
|
|
90
|
+
catch {
|
|
91
91
|
// Silently ignore errors
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -97,7 +97,7 @@ export class LauncherService {
|
|
|
97
97
|
try {
|
|
98
98
|
return open(url.toString());
|
|
99
99
|
}
|
|
100
|
-
catch
|
|
100
|
+
catch {
|
|
101
101
|
// Silently ignore errors
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher-service.js","sourceRoot":"","sources":["../../src/infrastructure/launcher-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,MAAM,MAAM,UAAU,CAAC;AAG9B,MAAM,OAAO,eAAe;IACnB,KAAK,CAAC,eAAe,CAAC,aAA4B,EAAE,UAAoB;QAC7E,IAAI,MAAM;YAAE,OAAO,KAAK,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC/D,MAAM,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,
|
|
1
|
+
{"version":3,"file":"launcher-service.js","sourceRoot":"","sources":["../../src/infrastructure/launcher-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,MAAM,MAAM,UAAU,CAAC;AAG9B,MAAM,OAAO,eAAe;IACnB,KAAK,CAAC,eAAe,CAAC,aAA4B,EAAE,UAAoB;QAC7E,IAAI,MAAM;YAAE,OAAO,KAAK,CAAC;QACzB,IAAI,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AAC,CAAC;gBACvC,MAAM;YACR,KAAK,QAAQ;gBACX,OAAO,GAAG,MAAM,CAAC;gBACjB,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;gBACpB,MAAM;YACR;gBACE,OAAO,GAAG,UAAU,CAAC;gBACrB,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;gBACpB,MAAM;QACV,CAAC;QAED,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;YACxE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,8BAA8B;QAC/C,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;QAC3B,CAAC;IACH,CAAC;IAEM,gBAAgB,CAAC,GAAY;QAClC,IAAI,MAAM;YAAE,OAAO;QACnB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;QAC3B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { UrlPath } from '../types/file/urlPath.js';
|
|
1
2
|
export declare class NetworkService {
|
|
2
3
|
getServerPort(preferredPorts: number[]): Promise<number>;
|
|
4
|
+
/** True once any response, whatever its status, has arrived in full; false if it fails, is cut off or times out. */
|
|
5
|
+
answers(url: UrlPath, timeoutMs: number): Promise<boolean>;
|
|
3
6
|
}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import { finished } from 'node:stream/promises';
|
|
3
|
+
import getPort from 'get-port';
|
|
2
4
|
export class NetworkService {
|
|
3
5
|
async getServerPort(preferredPorts) {
|
|
4
6
|
return await getPort({ port: preferredPorts });
|
|
5
7
|
}
|
|
8
|
+
/** True once any response, whatever its status, has arrived in full; false if it fails, is cut off or times out. */
|
|
9
|
+
answers(url, timeoutMs) {
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
// An agent of its own: under NODE_USE_ENV_PROXY the global one sends even a loopback request to the proxy.
|
|
12
|
+
http
|
|
13
|
+
.get(url.toString(), { agent: false, signal: AbortSignal.timeout(timeoutMs) }, (response) => resolve(finished(response.resume())
|
|
14
|
+
.then(() => true)
|
|
15
|
+
.catch(() => false)))
|
|
16
|
+
.on('error', () => resolve(false));
|
|
17
|
+
// `http.get` throws, rather than failing the request, on a URL it cannot make, such as an https one.
|
|
18
|
+
}).catch(() => false);
|
|
19
|
+
}
|
|
6
20
|
}
|
|
7
21
|
//# sourceMappingURL=network-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-service.js","sourceRoot":"","sources":["../../src/infrastructure/network-service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"network-service.js","sourceRoot":"","sources":["../../src/infrastructure/network-service.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,OAAO,MAAM,UAAU,CAAC;AAG/B,MAAM,OAAO,cAAc;IAClB,KAAK,CAAC,aAAa,CAAC,cAAwB;QACjD,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,oHAAoH;IAC7G,OAAO,CAAC,GAAY,EAAE,SAAiB;QAC5C,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;YACtC,2GAA2G;YAC3G,IAAI;iBACD,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,EAAE,CAC1F,OAAO,CACL,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;iBACxB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;iBAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CACtB,CACF;iBACA,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACrC,qGAAqG;QACvG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
import { DirectoryPath } from '../types/file/directoryPath.js';
|
|
3
|
+
import { PortalProjectPaths } from './portal-project-service.js';
|
|
4
|
+
export interface PortalBuildFailure {
|
|
5
|
+
message: string;
|
|
6
|
+
/** Combined output of the build, written next to the portal so it can be reported. */
|
|
7
|
+
log: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PortalBuildResult {
|
|
10
|
+
/** Directory holding the finished static site. */
|
|
11
|
+
output: DirectoryPath;
|
|
12
|
+
pageCount: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class PortalBuildService {
|
|
15
|
+
private readonly fileService;
|
|
16
|
+
private readonly projectService;
|
|
17
|
+
build(project: PortalProjectPaths): Promise<Result<PortalBuildResult, PortalBuildFailure>>;
|
|
18
|
+
private countPages;
|
|
19
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { err, ok } from 'neverthrow';
|
|
3
|
+
import { FileName } from '../types/file/fileName.js';
|
|
4
|
+
import { FilePath } from '../types/file/filePath.js';
|
|
5
|
+
import { SHELL_FILE_NAME } from '../types/portal-context.js';
|
|
6
|
+
import { FileService } from './file-service.js';
|
|
7
|
+
import { CONTENT_COPY_DIRECTORY_NAME, PortalProjectService } from './portal-project-service.js';
|
|
8
|
+
export class PortalBuildService {
|
|
9
|
+
fileService = new FileService();
|
|
10
|
+
projectService = new PortalProjectService();
|
|
11
|
+
async build(project) {
|
|
12
|
+
const distDirectory = project.projectDirectory.join('dist');
|
|
13
|
+
await this.fileService.deleteDirectory(distDirectory);
|
|
14
|
+
// Run in a child process so a build crash or out-of-memory cannot take the CLI with it.
|
|
15
|
+
const result = await execa(process.execPath, [project.viteBinary.toString(), 'build'], {
|
|
16
|
+
cwd: project.projectDirectory.toString(),
|
|
17
|
+
env: this.projectService.childEnvironment(),
|
|
18
|
+
extendEnv: false,
|
|
19
|
+
all: true,
|
|
20
|
+
reject: false
|
|
21
|
+
});
|
|
22
|
+
const log = namingSource(result.all ?? '', project);
|
|
23
|
+
if (result.exitCode !== 0) {
|
|
24
|
+
return err({ message: 'The portal build failed.', log });
|
|
25
|
+
}
|
|
26
|
+
const output = distDirectory.join('client');
|
|
27
|
+
if (!(await this.fileService.fileExists(new FilePath(output, new FileName('index.html'))))) {
|
|
28
|
+
return err({ message: 'The portal build produced no home page.', log });
|
|
29
|
+
}
|
|
30
|
+
const pageCount = await this.countPages(output);
|
|
31
|
+
if (pageCount === null) {
|
|
32
|
+
return err({ message: 'The portal build output could not be read.', log });
|
|
33
|
+
}
|
|
34
|
+
if (pageCount === 0) {
|
|
35
|
+
return err({ message: 'The portal build produced no pages.', log });
|
|
36
|
+
}
|
|
37
|
+
return ok({ output, pageCount });
|
|
38
|
+
}
|
|
39
|
+
async countPages(output) {
|
|
40
|
+
try {
|
|
41
|
+
const directory = await this.fileService.getDirectory(output);
|
|
42
|
+
const isPage = (file) => file.name().hasExtension('.html') && !file.name().is(SHELL_FILE_NAME);
|
|
43
|
+
return directory.getAllFiles().filter(isPage).length;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// The build reads a copy of the pages, in a temporary directory; a reader knows each page by its place in the source.
|
|
51
|
+
function namingSource(log, { projectDirectory, contentSource }) {
|
|
52
|
+
if (contentSource === null) {
|
|
53
|
+
return log;
|
|
54
|
+
}
|
|
55
|
+
const copy = projectDirectory.join(CONTENT_COPY_DIRECTORY_NAME);
|
|
56
|
+
return log.replaceAll(copy.toString(), contentSource.toString()).replaceAll(copy.toPosix(), contentSource.toPosix());
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=portal-build-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-build-service.js","sourceRoot":"","sources":["../../src/infrastructure/portal-build-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAsB,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAcpH,MAAM,OAAO,kBAAkB;IACZ,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IAChC,cAAc,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAEtD,KAAK,CAAC,KAAK,CAAC,OAA2B;QAC5C,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5D,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QAEtD,wFAAwF;QACxF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE;YACrF,GAAG,EAAE,OAAO,CAAC,gBA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M,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC9D,MAAM,MAAM,GAAG,CAAC,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;YACzG,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QACvD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,sHAAsH;AACtH,SAAS,YAAY,CAAC,GAAW,EAAE,EAAE,gBAAgB,EAAE,aAAa,EAAsB;IACxF,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAChE,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;AACvH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
import { UrlPath } from '../types/file/urlPath.js';
|
|
3
|
+
import { PortalProjectPaths } from './portal-project-service.js';
|
|
4
|
+
export interface PortalDevServer {
|
|
5
|
+
url: UrlPath;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves with what the server printed after startup if it stops on its own, so the CLI
|
|
8
|
+
* stops advertising an address nothing is listening on.
|
|
9
|
+
*/
|
|
10
|
+
exited: Promise<string>;
|
|
11
|
+
/** Resolves once the server process has exited. */
|
|
12
|
+
stop: () => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export interface PortalDevServerFailure {
|
|
15
|
+
message: string;
|
|
16
|
+
log: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class PortalDevServerService {
|
|
19
|
+
private readonly projectService;
|
|
20
|
+
private readonly networkService;
|
|
21
|
+
start(project: PortalProjectPaths, port: number): Promise<Result<PortalDevServer, PortalDevServerFailure>>;
|
|
22
|
+
/**
|
|
23
|
+
* Keeps reading the server's output after startup: detaching lets the pipe fill and block
|
|
24
|
+
* the server once it has printed enough. Only the tail is kept, so a long session is bounded.
|
|
25
|
+
*/
|
|
26
|
+
private watchForExit;
|
|
27
|
+
private waitForUrl;
|
|
28
|
+
private terminate;
|
|
29
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
2
|
+
import { sleep } from './timer-extensions.js';
|
|
3
|
+
import { execa } from 'execa';
|
|
4
|
+
import { err, ok } from 'neverthrow';
|
|
5
|
+
import { UrlPath } from '../types/file/urlPath.js';
|
|
6
|
+
import { NetworkService } from './network-service.js';
|
|
7
|
+
import { PortalProjectService } from './portal-project-service.js';
|
|
8
|
+
/** A cold start compiles the portal from scratch: its address, and then its first page, each get this long. */
|
|
9
|
+
const STARTUP_TIMEOUT_MS = 3 * 60 * 1000;
|
|
10
|
+
/**
|
|
11
|
+
* How much of a running server's output is kept, in case it explains a crash. Counted in
|
|
12
|
+
* characters, not chunks: chunk size varies by platform and Node version, so the same output
|
|
13
|
+
* bounded at 64 chunks came to 4 KB on one runner and 280 KB on another.
|
|
14
|
+
*/
|
|
15
|
+
const OUTPUT_TAIL_BYTES = 64 * 1024;
|
|
16
|
+
/** How long the last of a dead server's output is waited for before reporting what arrived. */
|
|
17
|
+
const DRAIN_TIMEOUT_MS = 2000;
|
|
18
|
+
// Read after Vite's colour codes are stripped but not the line end, which proves the URL arrived whole.
|
|
19
|
+
const LOCAL_URL_PATTERN = /Local:\s*(https?:\/\/\S+?)\/?[ \t]*[\r\n]/i;
|
|
20
|
+
export class PortalDevServerService {
|
|
21
|
+
projectService = new PortalProjectService();
|
|
22
|
+
networkService = new NetworkService();
|
|
23
|
+
async start(project, port) {
|
|
24
|
+
// `--strictPort` makes Vite fail instead of silently moving to another port, so the
|
|
25
|
+
// URL reported to the user is always the one that was reserved.
|
|
26
|
+
const subprocess = execa(process.execPath,
|
|
27
|
+
// Bound explicitly to the IPv4 loopback. Left to itself the server listens on `::1`
|
|
28
|
+
// only while printing `localhost`, so wherever that name resolves to 127.0.0.1 the
|
|
29
|
+
// address the CLI reports refuses the connection although the preview is healthy.
|
|
30
|
+
[project.viteBinary.toString(), 'dev', '--port', String(port), '--strictPort', '--host', '127.0.0.1'], {
|
|
31
|
+
cwd: project.projectDirectory.toString(),
|
|
32
|
+
env: this.projectService.childEnvironment(),
|
|
33
|
+
extendEnv: false,
|
|
34
|
+
all: true,
|
|
35
|
+
buffer: false,
|
|
36
|
+
reject: false,
|
|
37
|
+
// Vite's dev server ignores SIGTERM while it is optimizing dependencies.
|
|
38
|
+
forceKillAfterDelay: 5000
|
|
39
|
+
});
|
|
40
|
+
const started = await this.waitForUrl(subprocess);
|
|
41
|
+
if (started.isErr()) {
|
|
42
|
+
await this.terminate(subprocess);
|
|
43
|
+
return err(started.error);
|
|
44
|
+
}
|
|
45
|
+
// Read from here, the log of a failed first page holds what explains it rather than the address banner.
|
|
46
|
+
const exited = this.watchForExit(subprocess);
|
|
47
|
+
// Vite compiles the portal on its first request, not at startup, so it is ready only once one is answered.
|
|
48
|
+
if (!(await this.networkService.answers(started.value, STARTUP_TIMEOUT_MS))) {
|
|
49
|
+
await this.terminate(subprocess);
|
|
50
|
+
return err({ message: 'The portal preview did not answer its first page.', log: await exited });
|
|
51
|
+
}
|
|
52
|
+
return ok({
|
|
53
|
+
url: started.value,
|
|
54
|
+
exited,
|
|
55
|
+
stop: () => this.terminate(subprocess)
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Keeps reading the server's output after startup: detaching lets the pipe fill and block
|
|
60
|
+
* the server once it has printed enough. Only the tail is kept, so a long session is bounded.
|
|
61
|
+
*/
|
|
62
|
+
watchForExit(subprocess) {
|
|
63
|
+
const tail = [];
|
|
64
|
+
let kept = 0;
|
|
65
|
+
const output = subprocess.all;
|
|
66
|
+
output?.on('data', (chunk) => {
|
|
67
|
+
const text = stripVTControlCharacters(chunk.toString());
|
|
68
|
+
tail.push(text);
|
|
69
|
+
kept += text.length;
|
|
70
|
+
// The last chunk always survives, however big: it most likely holds the exit message.
|
|
71
|
+
while (tail.length > 1 && kept > OUTPUT_TAIL_BYTES) {
|
|
72
|
+
kept -= tail.shift().length;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
// The process resolves before the last of its output is delivered, so waiting only on
|
|
76
|
+
// that loses the lines explaining the exit. Bounded, in case the stream never ends.
|
|
77
|
+
const drained = new Promise((resolve) => {
|
|
78
|
+
if (!output) {
|
|
79
|
+
resolve();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
output.once('end', resolve);
|
|
83
|
+
output.once('close', resolve);
|
|
84
|
+
output.once('error', resolve);
|
|
85
|
+
});
|
|
86
|
+
const collect = async () => {
|
|
87
|
+
// Cancelled once the output has arrived: `Promise.race` leaves the loser running, and
|
|
88
|
+
// a pending timer holds the event loop open. Nothing here calls process.exit(), so the
|
|
89
|
+
// timer alone kept `portal serve` alive for two seconds after Ctrl+C.
|
|
90
|
+
const expiry = new AbortController();
|
|
91
|
+
try {
|
|
92
|
+
await Promise.race([drained, sleep(DRAIN_TIMEOUT_MS, expiry.signal)]);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
expiry.abort();
|
|
96
|
+
}
|
|
97
|
+
return tail.join('');
|
|
98
|
+
};
|
|
99
|
+
return subprocess.then(collect, collect);
|
|
100
|
+
}
|
|
101
|
+
waitForUrl(subprocess) {
|
|
102
|
+
return new Promise((resolve) => {
|
|
103
|
+
let log = '';
|
|
104
|
+
let settled = false;
|
|
105
|
+
const onData = (chunk) => {
|
|
106
|
+
log += stripVTControlCharacters(chunk.toString());
|
|
107
|
+
const match = LOCAL_URL_PATTERN.exec(log);
|
|
108
|
+
if (match) {
|
|
109
|
+
settle(ok(new UrlPath(match[1])));
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const settle = (result) => {
|
|
113
|
+
if (settled)
|
|
114
|
+
return;
|
|
115
|
+
settled = true;
|
|
116
|
+
clearTimeout(timer);
|
|
117
|
+
// The server then runs until the user stops it; left attached, this would buffer
|
|
118
|
+
// every line it prints for the whole session.
|
|
119
|
+
subprocess.all?.off('data', onData);
|
|
120
|
+
resolve(result);
|
|
121
|
+
};
|
|
122
|
+
const timer = setTimeout(() => {
|
|
123
|
+
settle(err({ message: 'The portal preview did not start in time.', log }));
|
|
124
|
+
}, STARTUP_TIMEOUT_MS);
|
|
125
|
+
subprocess.all?.on('data', onData);
|
|
126
|
+
// A failed port bind or a broken config exits before ever printing a URL.
|
|
127
|
+
void subprocess.then(() => settle(err({ message: 'The portal preview stopped unexpectedly.', log })), () => settle(err({ message: 'The portal preview could not be started.', log })));
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async terminate(subprocess) {
|
|
131
|
+
subprocess.kill('SIGTERM');
|
|
132
|
+
await subprocess.catch(() => undefined);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=portal-dev-server-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-dev-server-service.js","sourceRoot":"","sources":["../../src/infrastructure/portal-dev-server-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAiB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAC7C,OAAO,EAA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CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
import { DirectoryPath } from '../types/file/directoryPath.js';
|
|
3
|
+
import { GeneratedPages } from '../types/portal/generated-pages.js';
|
|
4
|
+
/**
|
|
5
|
+
* Writes the pages the CLI generates into a directory of the build project, rendered from the
|
|
6
|
+
* templates the package ships. A file is written only when its contents change, and whatever
|
|
7
|
+
* the pages no longer call for is deleted, so under `portal serve` an edit reloads only what it
|
|
8
|
+
* changed; the answer says whether anything was written or deleted.
|
|
9
|
+
*/
|
|
10
|
+
export declare class PortalPagesService {
|
|
11
|
+
private readonly fileService;
|
|
12
|
+
write(directory: DirectoryPath, pages: GeneratedPages): Promise<Result<boolean, string>>;
|
|
13
|
+
private render;
|
|
14
|
+
private template;
|
|
15
|
+
/** Deletes every file and folder in the directory that the pages no longer call for. */
|
|
16
|
+
private removeStale;
|
|
17
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { err, ok } from 'neverthrow';
|
|
2
|
+
import { FileName } from '../types/file/fileName.js';
|
|
3
|
+
import { FilePath } from '../types/file/filePath.js';
|
|
4
|
+
import { NAVIGATION_FILE_NAME } from '../types/portal/portal-navigation.js';
|
|
5
|
+
import { PageTemplate } from '../types/portal/page-template.js';
|
|
6
|
+
import { errorMessage } from '../utils/error-utils.js';
|
|
7
|
+
import { envInfo } from './env-info.js';
|
|
8
|
+
import { FileService } from './file-service.js';
|
|
9
|
+
/** Shipped beside `portal-template/`, one `.mdx` file per template. */
|
|
10
|
+
const TEMPLATES_DIRECTORY_NAME = 'portal-pages';
|
|
11
|
+
/**
|
|
12
|
+
* Writes the pages the CLI generates into a directory of the build project, rendered from the
|
|
13
|
+
* templates the package ships. A file is written only when its contents change, and whatever
|
|
14
|
+
* the pages no longer call for is deleted, so under `portal serve` an edit reloads only what it
|
|
15
|
+
* changed; the answer says whether anything was written or deleted.
|
|
16
|
+
*/
|
|
17
|
+
export class PortalPagesService {
|
|
18
|
+
fileService = new FileService();
|
|
19
|
+
async write(directory, pages) {
|
|
20
|
+
const files = await this.render(directory, pages);
|
|
21
|
+
if (files.isErr()) {
|
|
22
|
+
return err(files.error);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
let changed = false;
|
|
26
|
+
for (const { file, contents } of files.value) {
|
|
27
|
+
if (await this.fileService.replaceContentsIfChanged(file, contents)) {
|
|
28
|
+
changed = true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const removed = await this.removeStale(directory, files.value);
|
|
32
|
+
return ok(changed || removed);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return err(errorMessage(error));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async render(directory, pages) {
|
|
39
|
+
const templates = new Map();
|
|
40
|
+
const files = [];
|
|
41
|
+
for (const page of pages.pages()) {
|
|
42
|
+
let template = templates.get(page.template);
|
|
43
|
+
if (template === undefined) {
|
|
44
|
+
const read = await this.template(page.template);
|
|
45
|
+
if (read.isErr()) {
|
|
46
|
+
return err(read.error);
|
|
47
|
+
}
|
|
48
|
+
template = read.value;
|
|
49
|
+
templates.set(page.template, template);
|
|
50
|
+
}
|
|
51
|
+
const rendered = template.render(page.data);
|
|
52
|
+
if (rendered.isErr()) {
|
|
53
|
+
return err(`A portal page template could not be filled. ${rendered.error}`);
|
|
54
|
+
}
|
|
55
|
+
const folder = directory.join(page.section.folder);
|
|
56
|
+
files.push({ folder, file: new FilePath(folder, page.fileName), contents: rendered.value });
|
|
57
|
+
}
|
|
58
|
+
for (const navigation of pages.navigationFiles()) {
|
|
59
|
+
const folder = directory.join(navigation.section.folder);
|
|
60
|
+
files.push({
|
|
61
|
+
folder,
|
|
62
|
+
file: new FilePath(folder, new FileName(NAVIGATION_FILE_NAME)),
|
|
63
|
+
contents: navigation.contents
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return ok(files);
|
|
67
|
+
}
|
|
68
|
+
async template(name) {
|
|
69
|
+
const fileName = new FileName(`${name}.mdx`);
|
|
70
|
+
const file = new FilePath(envInfo.packageRoot().join(TEMPLATES_DIRECTORY_NAME), fileName);
|
|
71
|
+
try {
|
|
72
|
+
return ok(new PageTemplate(fileName, await this.fileService.getContents(file)));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return err(`The portal page template '${fileName}' is missing from this installation. Reinstall the CLI and try again.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Deletes every file and folder in the directory that the pages no longer call for. */
|
|
79
|
+
async removeStale(directory, wanted) {
|
|
80
|
+
let removed = false;
|
|
81
|
+
for (const fileName of await this.fileService.getFileNames(directory)) {
|
|
82
|
+
await this.fileService.deleteFile(new FilePath(directory, fileName));
|
|
83
|
+
removed = true;
|
|
84
|
+
}
|
|
85
|
+
for (const folder of await this.fileService.getSubDirectoriesPaths(directory)) {
|
|
86
|
+
const inFolder = wanted.filter((candidate) => candidate.folder.isEqual(folder));
|
|
87
|
+
if (inFolder.length === 0) {
|
|
88
|
+
await this.fileService.deleteDirectory(folder);
|
|
89
|
+
removed = true;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
for (const fileName of await this.fileService.getFileNames(folder)) {
|
|
93
|
+
const file = new FilePath(folder, fileName);
|
|
94
|
+
if (!inFolder.some((candidate) => candidate.file.isEqual(file))) {
|
|
95
|
+
await this.fileService.deleteFile(file);
|
|
96
|
+
removed = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return removed;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=portal-pages-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-pages-service.js","sourceRoot":"","sources":["../../src/infrastructure/portal-pages-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,Q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