@forge/cli 0.0.0-experimental-034f51a → 0.0.0-experimental-c8e9749
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1110 -2
- package/npm-shrinkwrap.json +13389 -0
- package/out/analytics-client/analytics-client.d.ts +36 -0
- package/out/analytics-client/analytics-client.d.ts.map +1 -0
- package/out/analytics-client/analytics-client.js +140 -0
- package/out/analytics-client/analytics-message-handler.d.ts +21 -0
- package/out/analytics-client/analytics-message-handler.d.ts.map +1 -0
- package/out/analytics-client/analytics-message-handler.js +43 -0
- package/out/autocomplete/autocomplete-config.json +243 -0
- package/out/autocomplete/index.d.ts +5 -0
- package/out/autocomplete/index.d.ts.map +1 -0
- package/out/autocomplete/index.js +41 -0
- package/out/autocomplete/isSupportedShell.d.ts +2 -0
- package/out/autocomplete/isSupportedShell.d.ts.map +1 -0
- package/out/autocomplete/isSupportedShell.js +11 -0
- package/out/autocomplete/types.d.ts +14 -0
- package/out/autocomplete/types.d.ts.map +1 -0
- package/out/autocomplete/types.js +2 -0
- package/out/autocomplete/util.d.ts +6 -0
- package/out/autocomplete/util.d.ts.map +1 -0
- package/out/autocomplete/util.js +15 -0
- package/out/bin/cli.d.ts +1 -0
- package/out/bin/cli.d.ts.map +1 -1
- package/out/bin/cli.js +4 -1
- package/out/bin/postinstall.d.ts +2 -0
- package/out/bin/postinstall.d.ts.map +1 -0
- package/out/bin/postinstall.js +23 -0
- package/out/command-line/anon-user-id.d.ts +3 -0
- package/out/command-line/anon-user-id.d.ts.map +1 -0
- package/out/command-line/anon-user-id.js +17 -0
- package/out/command-line/command.d.ts +80 -0
- package/out/command-line/command.d.ts.map +1 -0
- package/out/command-line/command.js +408 -0
- package/out/command-line/controller/assertUnreachable.d.ts +2 -0
- package/out/command-line/controller/assertUnreachable.d.ts.map +1 -0
- package/out/command-line/controller/assertUnreachable.js +7 -0
- package/out/command-line/controller/autocomplete-controller.d.ts +12 -0
- package/out/command-line/controller/autocomplete-controller.d.ts.map +1 -0
- package/out/command-line/controller/autocomplete-controller.js +54 -0
- package/out/command-line/controller/deploy-controller.d.ts +42 -0
- package/out/command-line/controller/deploy-controller.d.ts.map +1 -0
- package/out/command-line/controller/deploy-controller.js +139 -0
- package/out/command-line/controller/feedback-controller.d.ts +9 -0
- package/out/command-line/controller/feedback-controller.d.ts.map +1 -0
- package/out/command-line/controller/feedback-controller.js +19 -0
- package/out/command-line/controller/getNodeVersion.d.ts +2 -0
- package/out/command-line/controller/getNodeVersion.d.ts.map +1 -0
- package/out/command-line/controller/getNodeVersion.js +7 -0
- package/out/command-line/controller/install-controller.d.ts +35 -0
- package/out/command-line/controller/install-controller.d.ts.map +1 -0
- package/out/command-line/controller/install-controller.js +157 -0
- package/out/command-line/controller/lint-controller.d.ts +9 -0
- package/out/command-line/controller/lint-controller.d.ts.map +1 -0
- package/out/command-line/controller/lint-controller.js +20 -0
- package/out/command-line/controller/pre-command-controller.d.ts +25 -0
- package/out/command-line/controller/pre-command-controller.d.ts.map +1 -0
- package/out/command-line/controller/pre-command-controller.js +57 -0
- package/out/command-line/controller/prerequisites-controller.d.ts +15 -0
- package/out/command-line/controller/prerequisites-controller.d.ts.map +1 -0
- package/out/command-line/controller/prerequisites-controller.js +41 -0
- package/out/command-line/controller/settings-controller.d.ts +19 -0
- package/out/command-line/controller/settings-controller.d.ts.map +1 -0
- package/out/command-line/controller/settings-controller.js +48 -0
- package/out/command-line/controller/stubController.d.ts +9 -0
- package/out/command-line/controller/stubController.d.ts.map +1 -0
- package/out/command-line/controller/stubController.js +15 -0
- package/out/command-line/controller/tunnel-controller.d.ts +14 -0
- package/out/command-line/controller/tunnel-controller.d.ts.map +1 -0
- package/out/command-line/controller/tunnel-controller.js +43 -0
- package/out/command-line/dependency-injection.d.ts +76 -0
- package/out/command-line/dependency-injection.d.ts.map +1 -0
- package/out/command-line/dependency-injection.js +211 -0
- package/out/command-line/environment.d.ts +2 -0
- package/out/command-line/environment.d.ts.map +1 -0
- package/out/command-line/environment.js +16 -0
- package/out/command-line/errors.d.ts +6 -0
- package/out/command-line/errors.d.ts.map +1 -0
- package/out/command-line/errors.js +12 -0
- package/out/command-line/index.d.ts +5 -0
- package/out/command-line/index.d.ts.map +1 -0
- package/out/command-line/index.js +73 -0
- package/out/command-line/register-app-commands.d.ts +10 -0
- package/out/command-line/register-app-commands.d.ts.map +1 -0
- package/out/command-line/register-app-commands.js +128 -0
- package/out/command-line/register-authentication-command.d.ts +16 -0
- package/out/command-line/register-authentication-command.d.ts.map +1 -0
- package/out/command-line/register-authentication-command.js +94 -0
- package/out/command-line/register-autocomplete-commands.d.ts +3 -0
- package/out/command-line/register-autocomplete-commands.d.ts.map +1 -0
- package/out/command-line/register-autocomplete-commands.js +14 -0
- package/out/command-line/register-contributors-commands.d.ts +3 -0
- package/out/command-line/register-contributors-commands.d.ts.map +1 -0
- package/out/command-line/register-contributors-commands.js +134 -0
- package/out/command-line/register-deployment-commands.d.ts +22 -0
- package/out/command-line/register-deployment-commands.d.ts.map +1 -0
- package/out/command-line/register-deployment-commands.js +16 -0
- package/out/command-line/register-environment-variables-commands.d.ts +3 -0
- package/out/command-line/register-environment-variables-commands.d.ts.map +1 -0
- package/out/command-line/register-environment-variables-commands.js +103 -0
- package/out/command-line/register-feedback-commands.d.ts +3 -0
- package/out/command-line/register-feedback-commands.d.ts.map +1 -0
- package/out/command-line/register-feedback-commands.js +32 -0
- package/out/command-line/register-installation-commands.d.ts +6 -0
- package/out/command-line/register-installation-commands.d.ts.map +1 -0
- package/out/command-line/register-installation-commands.js +143 -0
- package/out/command-line/register-lint-command.d.ts +8 -0
- package/out/command-line/register-lint-command.d.ts.map +1 -0
- package/out/command-line/register-lint-command.js +16 -0
- package/out/command-line/register-log-commands.d.ts +4 -0
- package/out/command-line/register-log-commands.d.ts.map +1 -0
- package/out/command-line/register-log-commands.js +139 -0
- package/out/command-line/register-providers-commands.d.ts +3 -0
- package/out/command-line/register-providers-commands.d.ts.map +1 -0
- package/out/command-line/register-providers-commands.js +44 -0
- package/out/command-line/register-settings-commands.d.ts +3 -0
- package/out/command-line/register-settings-commands.d.ts.map +1 -0
- package/out/command-line/register-settings-commands.js +39 -0
- package/out/command-line/register-tunnel-commands.d.ts +3 -0
- package/out/command-line/register-tunnel-commands.d.ts.map +1 -0
- package/out/command-line/register-tunnel-commands.js +15 -0
- package/out/command-line/register-webtrigger-commands.d.ts +3 -0
- package/out/command-line/register-webtrigger-commands.d.ts.map +1 -0
- package/out/command-line/register-webtrigger-commands.js +56 -0
- package/out/command-line/sentry.d.ts +4 -0
- package/out/command-line/sentry.d.ts.map +1 -0
- package/out/command-line/sentry.js +16 -0
- package/out/command-line/unique-machine-id.d.ts +3 -0
- package/out/command-line/unique-machine-id.d.ts.map +1 -0
- package/out/command-line/unique-machine-id.js +19 -0
- package/out/command-line/version-info.d.ts +9 -0
- package/out/command-line/version-info.d.ts.map +1 -0
- package/out/command-line/version-info.js +42 -0
- package/out/command-line/view/analytics-settings-view.d.ts +7 -0
- package/out/command-line/view/analytics-settings-view.d.ts.map +1 -0
- package/out/command-line/view/analytics-settings-view.js +18 -0
- package/out/command-line/view/deploy-view.d.ts +21 -0
- package/out/command-line/view/deploy-view.d.ts.map +1 -0
- package/out/command-line/view/deploy-view.js +58 -0
- package/out/command-line/view/install-view.d.ts +18 -0
- package/out/command-line/view/install-view.d.ts.map +1 -0
- package/out/command-line/view/install-view.js +56 -0
- package/out/command-line/view/lint-view.d.ts +12 -0
- package/out/command-line/view/lint-view.d.ts.map +1 -0
- package/out/command-line/view/lint-view.js +31 -0
- package/out/command-line/view/lite-lint-view.d.ts +10 -0
- package/out/command-line/view/lite-lint-view.d.ts.map +1 -0
- package/out/command-line/view/lite-lint-view.js +18 -0
- package/out/command-line/view/settings-view.d.ts +10 -0
- package/out/command-line/view/settings-view.d.ts.map +1 -0
- package/out/command-line/view/settings-view.js +26 -0
- package/out/command-line/view/tunnel-view.d.ts +20 -0
- package/out/command-line/view/tunnel-view.d.ts.map +1 -0
- package/out/command-line/view/tunnel-view.js +92 -0
- package/out/contributors/add-contributor.d.ts +17 -0
- package/out/contributors/add-contributor.d.ts.map +1 -0
- package/out/contributors/add-contributor.js +14 -0
- package/out/contributors/graphql-client.d.ts +14 -0
- package/out/contributors/graphql-client.d.ts.map +1 -0
- package/out/contributors/graphql-client.js +113 -0
- package/out/contributors/list-contributors.d.ts +18 -0
- package/out/contributors/list-contributors.d.ts.map +1 -0
- package/out/contributors/list-contributors.js +14 -0
- package/out/contributors/remove-contributors.d.ts +18 -0
- package/out/contributors/remove-contributors.d.ts.map +1 -0
- package/out/contributors/remove-contributors.js +14 -0
- package/out/deploy/deployer/deploy-monitor-graphql-client.d.ts +24 -0
- package/out/deploy/deployer/deploy-monitor-graphql-client.d.ts.map +1 -0
- package/out/deploy/deployer/deploy-monitor-graphql-client.js +57 -0
- package/out/deploy/deployer/deployer.d.ts +40 -0
- package/out/deploy/deployer/deployer.d.ts.map +1 -0
- package/out/deploy/deployer/deployer.js +187 -0
- package/out/deploy/deployer/index.d.ts +4 -0
- package/out/deploy/deployer/index.d.ts.map +1 -0
- package/out/deploy/deployer/index.js +6 -0
- package/out/deploy/deployer/trigger-deploy-graphql-client.d.ts +19 -0
- package/out/deploy/deployer/trigger-deploy-graphql-client.d.ts.map +1 -0
- package/out/deploy/deployer/trigger-deploy-graphql-client.js +49 -0
- package/out/deploy/index.d.ts +5 -0
- package/out/deploy/index.d.ts.map +1 -0
- package/out/deploy/index.js +7 -0
- package/out/deploy/package-upload-deploy.d.ts +20 -0
- package/out/deploy/package-upload-deploy.d.ts.map +1 -0
- package/out/deploy/package-upload-deploy.js +37 -0
- package/out/deploy/packager/archiver.d.ts +27 -0
- package/out/deploy/packager/archiver.d.ts.map +1 -0
- package/out/deploy/packager/archiver.js +76 -0
- package/out/deploy/packager/index.d.ts +3 -0
- package/out/deploy/packager/index.d.ts.map +1 -0
- package/out/deploy/packager/index.js +5 -0
- package/out/deploy/packager/nativeui-bundler.d.ts +12 -0
- package/out/deploy/packager/nativeui-bundler.d.ts.map +1 -0
- package/out/deploy/packager/nativeui-bundler.js +34 -0
- package/out/deploy/packager/packager.d.ts +32 -0
- package/out/deploy/packager/packager.d.ts.map +1 -0
- package/out/deploy/packager/packager.js +21 -0
- package/out/deploy/packager/runtime-bundler.d.ts +15 -0
- package/out/deploy/packager/runtime-bundler.d.ts.map +1 -0
- package/out/deploy/packager/runtime-bundler.js +53 -0
- package/out/deploy/uploader/artifact-graphql-client.d.ts +26 -0
- package/out/deploy/uploader/artifact-graphql-client.d.ts.map +1 -0
- package/out/deploy/uploader/artifact-graphql-client.js +100 -0
- package/out/deploy/uploader/index.d.ts +3 -0
- package/out/deploy/uploader/index.d.ts.map +1 -0
- package/out/deploy/uploader/index.js +5 -0
- package/out/deploy/uploader/uploader.d.ts +19 -0
- package/out/deploy/uploader/uploader.d.ts.map +1 -0
- package/out/deploy/uploader/uploader.js +43 -0
- package/out/environment-variables/delete-environment-variable.d.ts +18 -0
- package/out/environment-variables/delete-environment-variable.d.ts.map +1 -0
- package/out/environment-variables/delete-environment-variable.js +14 -0
- package/out/environment-variables/graphql-client.d.ts +16 -0
- package/out/environment-variables/graphql-client.d.ts.map +1 -0
- package/out/environment-variables/graphql-client.js +113 -0
- package/out/environment-variables/list-environment-variables.d.ts +22 -0
- package/out/environment-variables/list-environment-variables.d.ts.map +1 -0
- package/out/environment-variables/list-environment-variables.js +14 -0
- package/out/environment-variables/set-environment-variable.d.ts +20 -0
- package/out/environment-variables/set-environment-variable.d.ts.map +1 -0
- package/out/environment-variables/set-environment-variable.js +14 -0
- package/out/installations/graphql-client.d.ts +75 -0
- package/out/installations/graphql-client.d.ts.map +1 -0
- package/out/installations/graphql-client.js +423 -0
- package/out/installations/install-app-site.d.ts +21 -0
- package/out/installations/install-app-site.d.ts.map +1 -0
- package/out/installations/install-app-site.js +19 -0
- package/out/installations/shared.d.ts +5 -0
- package/out/installations/shared.d.ts.map +1 -0
- package/out/installations/shared.js +20 -0
- package/out/installations/site-translation/bitbucket.d.ts +24 -0
- package/out/installations/site-translation/bitbucket.d.ts.map +1 -0
- package/out/installations/site-translation/bitbucket.js +113 -0
- package/out/installations/site-translation/cloudid-products.d.ts +17 -0
- package/out/installations/site-translation/cloudid-products.d.ts.map +1 -0
- package/out/installations/site-translation/cloudid-products.js +89 -0
- package/out/installations/site-translation/index.d.ts +4 -0
- package/out/installations/site-translation/index.d.ts.map +1 -0
- package/out/installations/site-translation/index.js +6 -0
- package/out/installations/site-translation/site-translation.d.ts +12 -0
- package/out/installations/site-translation/site-translation.d.ts.map +1 -0
- package/out/installations/site-translation/site-translation.js +2 -0
- package/out/installations/uninstall-app.d.ts +25 -0
- package/out/installations/uninstall-app.d.ts.map +1 -0
- package/out/installations/uninstall-app.js +43 -0
- package/out/migration-keys/graphql-client.d.ts +8 -0
- package/out/migration-keys/graphql-client.d.ts.map +1 -0
- package/out/migration-keys/graphql-client.js +55 -0
- package/out/providers/configure-provider.d.ts +19 -0
- package/out/providers/configure-provider.d.ts.map +1 -0
- package/out/providers/configure-provider.js +14 -0
- package/out/providers/graphql-client.d.ts +8 -0
- package/out/providers/graphql-client.d.ts.map +1 -0
- package/out/providers/graphql-client.js +45 -0
- package/out/service/cached-config-service.d.ts +8 -0
- package/out/service/cached-config-service.d.ts.map +1 -0
- package/out/service/cached-config-service.js +16 -0
- package/out/service/command-suggestion-service.d.ts +4 -0
- package/out/service/command-suggestion-service.d.ts.map +1 -0
- package/out/service/command-suggestion-service.js +17 -0
- package/out/service/docker-service.d.ts +24 -0
- package/out/service/docker-service.d.ts.map +1 -0
- package/out/service/docker-service.js +71 -0
- package/out/service/installation-service.d.ts +51 -0
- package/out/service/installation-service.d.ts.map +1 -0
- package/out/service/installation-service.js +91 -0
- package/out/service/lint-service.d.ts +23 -0
- package/out/service/lint-service.d.ts.map +1 -0
- package/out/service/lint-service.js +39 -0
- package/out/service/lite-lint-service.d.ts +10 -0
- package/out/service/lite-lint-service.d.ts.map +1 -0
- package/out/service/lite-lint-service.js +27 -0
- package/out/service/migration-keys-service.d.ts +19 -0
- package/out/service/migration-keys-service.d.ts.map +1 -0
- package/out/service/migration-keys-service.js +14 -0
- package/out/service/port-finding-service.d.ts +12 -0
- package/out/service/port-finding-service.d.ts.map +1 -0
- package/out/service/port-finding-service.js +34 -0
- package/out/service/resource-packaging-service.d.ts +46 -0
- package/out/service/resource-packaging-service.d.ts.map +1 -0
- package/out/service/resource-packaging-service.js +132 -0
- package/out/service/resources-uploader-service.d.ts +16 -0
- package/out/service/resources-uploader-service.d.ts.map +1 -0
- package/out/service/resources-uploader-service.js +39 -0
- package/out/service/tunnel-analytics-service.d.ts +11 -0
- package/out/service/tunnel-analytics-service.d.ts.map +1 -0
- package/out/service/tunnel-analytics-service.js +24 -0
- package/out/service/tunnel-service.d.ts +41 -0
- package/out/service/tunnel-service.d.ts.map +1 -0
- package/out/service/tunnel-service.js +196 -0
- package/out/storage/local-file-storage.d.ts +17 -0
- package/out/storage/local-file-storage.d.ts.map +1 -0
- package/out/storage/local-file-storage.js +53 -0
- package/out/webtrigger/get-webtrigger-url.d.ts +27 -0
- package/out/webtrigger/get-webtrigger-url.d.ts.map +1 -0
- package/out/webtrigger/get-webtrigger-url.js +26 -0
- package/out/webtrigger/graphql-client.d.ts +14 -0
- package/out/webtrigger/graphql-client.d.ts.map +1 -0
- package/out/webtrigger/graphql-client.js +52 -0
- package/out/workers/analytics-message-worker.d.ts +12 -0
- package/out/workers/analytics-message-worker.d.ts.map +1 -0
- package/out/workers/analytics-message-worker.js +29 -0
- package/out/workers/forge-cli-workers.d.ts +2 -0
- package/out/workers/forge-cli-workers.d.ts.map +1 -0
- package/out/workers/forge-cli-workers.js +21 -0
- package/out/workers/tunnel-clean-up-worker.d.ts +8 -0
- package/out/workers/tunnel-clean-up-worker.d.ts.map +1 -0
- package/out/workers/tunnel-clean-up-worker.js +31 -0
- package/out/workers/version-check-worker.d.ts +8 -0
- package/out/workers/version-check-worker.d.ts.map +1 -0
- package/out/workers/version-check-worker.js +20 -0
- package/out/workers/worker-info.d.ts +8 -0
- package/out/workers/worker-info.d.ts.map +1 -0
- package/out/workers/worker-info.js +15 -0
- package/out/workers/worker.d.ts +6 -0
- package/out/workers/worker.d.ts.map +1 -0
- package/out/workers/worker.js +9 -0
- package/out/workers/workers-starter.d.ts +5 -0
- package/out/workers/workers-starter.d.ts.map +1 -0
- package/out/workers/workers-starter.js +22 -0
- package/package.json +60 -5
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SetEnvironmentVariableCommand = void 0;
|
|
4
|
+
class SetEnvironmentVariableCommand {
|
|
5
|
+
constructor(client, getAppConfig) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
this.getAppConfig = getAppConfig;
|
|
8
|
+
}
|
|
9
|
+
async execute(details) {
|
|
10
|
+
const { id: appId } = await this.getAppConfig();
|
|
11
|
+
await this.client.setEnvironmentVariable(Object.assign(Object.assign({}, details), { appId }));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.SetEnvironmentVariableCommand = SetEnvironmentVariableCommand;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { AppEnvironment, AppUninstallationInput, GraphQLClient, GraphQlMutationError, Pause, BaseError, UserError } from '@forge/cli-shared';
|
|
2
|
+
import { AppInstallSiteDetails, InstallAppClient } from './install-app-site';
|
|
3
|
+
import { Installation, ListAppInstallationsClient, UpgradeAppInstallationsClient } from '../service/installation-service';
|
|
4
|
+
import { UninstallAppClient, UninstallAppOutput } from './uninstall-app';
|
|
5
|
+
import { SiteTranslator } from './site-translation';
|
|
6
|
+
export declare const UNINSTALLATION_EVENT_POLL_INTERVAL = 500;
|
|
7
|
+
export declare const ALREADY_UPGRADED_CODE = "INSTALLATION_ALREADY_UPGRADED";
|
|
8
|
+
export declare class PermissionDeniedError extends GraphQlMutationError {
|
|
9
|
+
constructor(requestId: string | undefined, appId: string | undefined, statusCode: number | undefined);
|
|
10
|
+
}
|
|
11
|
+
export declare class AlreadyInstalledError extends GraphQlMutationError {
|
|
12
|
+
constructor(requestId: string | undefined, statusCode: number | undefined);
|
|
13
|
+
}
|
|
14
|
+
export declare class InstallationError extends GraphQlMutationError {
|
|
15
|
+
constructor(message: string, { requestId, code, statusCode }: {
|
|
16
|
+
requestId: string | undefined;
|
|
17
|
+
code: string | undefined;
|
|
18
|
+
statusCode: number | undefined;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export declare class UpgradeError extends GraphQlMutationError {
|
|
22
|
+
constructor(message: string, { requestId, code, statusCode }: {
|
|
23
|
+
requestId: string | undefined;
|
|
24
|
+
code: string | undefined;
|
|
25
|
+
statusCode: number | undefined;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export declare class EnvironmentNotFoundError extends Error {
|
|
29
|
+
}
|
|
30
|
+
export declare class MissingTaskIdError extends Error {
|
|
31
|
+
}
|
|
32
|
+
export declare class InstallationRequestFailedError extends BaseError {
|
|
33
|
+
private readonly userError;
|
|
34
|
+
readonly code?: string | undefined;
|
|
35
|
+
constructor(userError: boolean, code?: string | undefined, message?: string);
|
|
36
|
+
isUserError(): boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare class MissingAppError extends UserError {
|
|
39
|
+
}
|
|
40
|
+
export declare class MissingAppEnvironmentError extends Error {
|
|
41
|
+
}
|
|
42
|
+
export declare class MissingAppUninstallTask extends Error {
|
|
43
|
+
}
|
|
44
|
+
export declare class InstallationNotFoundError extends UserError {
|
|
45
|
+
}
|
|
46
|
+
export declare class UnknownSiteWithoutResourceIdError extends Error {
|
|
47
|
+
constructor();
|
|
48
|
+
}
|
|
49
|
+
export declare class InstallationsGraphqlClient implements InstallAppClient, ListAppInstallationsClient, UninstallAppClient, UpgradeAppInstallationsClient {
|
|
50
|
+
private readonly graphqlClient;
|
|
51
|
+
private readonly cloudIdTranslator;
|
|
52
|
+
private readonly bitbucketTranslator;
|
|
53
|
+
private readonly pause;
|
|
54
|
+
SITE_RESOURCE_TYPE: string;
|
|
55
|
+
WORKSPACE_RESOURCE_TYPE: string;
|
|
56
|
+
static buildInstallationContext(product: string, resourceId: string, resourceType: string): string;
|
|
57
|
+
constructor(graphqlClient: GraphQLClient, cloudIdTranslator: SiteTranslator, bitbucketTranslator: SiteTranslator, pause: Pause);
|
|
58
|
+
private buildInstallationContext;
|
|
59
|
+
private getProductTranslation;
|
|
60
|
+
installAppIntoSite({ environmentKey, site, product, appId }: AppInstallSiteDetails): Promise<void>;
|
|
61
|
+
upgradeInstallation({ site, product, environmentKey, appId }: AppInstallSiteDetails): Promise<void>;
|
|
62
|
+
private monitorAppInstallOrUpgrade;
|
|
63
|
+
uninstallApp(input: AppUninstallationInput): Promise<boolean>;
|
|
64
|
+
uninstallMultipleApps(apps: AppUninstallationInput[]): Promise<Partial<UninstallAppOutput>[]>;
|
|
65
|
+
listInstallations(appId: string): Promise<Installation[]>;
|
|
66
|
+
getInstallation(appId: string, installationId: string): Promise<Installation>;
|
|
67
|
+
private getAppInstallationTask;
|
|
68
|
+
private monitorUninstallApp;
|
|
69
|
+
private getResourceArisForProduct;
|
|
70
|
+
private getCombinedHostnameMap;
|
|
71
|
+
private resolveInstallationsHostnames;
|
|
72
|
+
private getAllInstallations;
|
|
73
|
+
getVersions(appId: string, environmentKey: string, firstN?: number): Promise<AppEnvironment['versions']>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=graphql-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/installations/graphql-client.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstallationsGraphqlClient = exports.UnknownSiteWithoutResourceIdError = exports.InstallationNotFoundError = exports.MissingAppUninstallTask = exports.MissingAppEnvironmentError = exports.MissingAppError = exports.InstallationRequestFailedError = exports.MissingTaskIdError = exports.EnvironmentNotFoundError = exports.UpgradeError = exports.InstallationError = exports.AlreadyInstalledError = exports.PermissionDeniedError = exports.ALREADY_UPGRADED_CODE = exports.UNINSTALLATION_EVENT_POLL_INTERVAL = void 0;
|
|
4
|
+
const cs_ari_1 = require("@forge/util/packages/cs-ari");
|
|
5
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
6
|
+
exports.UNINSTALLATION_EVENT_POLL_INTERVAL = 500;
|
|
7
|
+
exports.ALREADY_UPGRADED_CODE = 'INSTALLATION_ALREADY_UPGRADED';
|
|
8
|
+
const ALREADY_INSTALLED_CODE = 'APP_ALREADY_INSTALLED';
|
|
9
|
+
const PERMISSION_DENIED = 'PERMISSION_DENIED';
|
|
10
|
+
class PermissionDeniedError extends cli_shared_1.GraphQlMutationError {
|
|
11
|
+
constructor(requestId = 'unknown', appId = 'unknown', statusCode) {
|
|
12
|
+
super(cli_shared_1.Text.install.error.permissionsDeniedInstructions(requestId, appId), {
|
|
13
|
+
requestId,
|
|
14
|
+
code: PERMISSION_DENIED,
|
|
15
|
+
statusCode
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.PermissionDeniedError = PermissionDeniedError;
|
|
20
|
+
class AlreadyInstalledError extends cli_shared_1.GraphQlMutationError {
|
|
21
|
+
constructor(requestId, statusCode) {
|
|
22
|
+
super(cli_shared_1.Text.install.error.alreadyInstalledError, { requestId, code: ALREADY_INSTALLED_CODE, statusCode });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.AlreadyInstalledError = AlreadyInstalledError;
|
|
26
|
+
class InstallationError extends cli_shared_1.GraphQlMutationError {
|
|
27
|
+
constructor(message, { requestId, code, statusCode }) {
|
|
28
|
+
super(cli_shared_1.Text.install.error.serverSideInstallationError(message), { requestId, code, statusCode });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.InstallationError = InstallationError;
|
|
32
|
+
class UpgradeError extends cli_shared_1.GraphQlMutationError {
|
|
33
|
+
constructor(message, { requestId, code, statusCode }) {
|
|
34
|
+
super(cli_shared_1.Text.upgrade.error.serverSideInstallationError(message), { requestId, code, statusCode });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.UpgradeError = UpgradeError;
|
|
38
|
+
class EnvironmentNotFoundError extends Error {
|
|
39
|
+
}
|
|
40
|
+
exports.EnvironmentNotFoundError = EnvironmentNotFoundError;
|
|
41
|
+
class MissingTaskIdError extends Error {
|
|
42
|
+
}
|
|
43
|
+
exports.MissingTaskIdError = MissingTaskIdError;
|
|
44
|
+
class InstallationRequestFailedError extends cli_shared_1.BaseError {
|
|
45
|
+
constructor(userError, code, message) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.userError = userError;
|
|
48
|
+
this.code = code;
|
|
49
|
+
}
|
|
50
|
+
isUserError() {
|
|
51
|
+
return this.userError;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.InstallationRequestFailedError = InstallationRequestFailedError;
|
|
55
|
+
class MissingAppError extends cli_shared_1.UserError {
|
|
56
|
+
}
|
|
57
|
+
exports.MissingAppError = MissingAppError;
|
|
58
|
+
class MissingAppEnvironmentError extends Error {
|
|
59
|
+
}
|
|
60
|
+
exports.MissingAppEnvironmentError = MissingAppEnvironmentError;
|
|
61
|
+
class MissingAppUninstallTask extends Error {
|
|
62
|
+
}
|
|
63
|
+
exports.MissingAppUninstallTask = MissingAppUninstallTask;
|
|
64
|
+
class InstallationNotFoundError extends cli_shared_1.UserError {
|
|
65
|
+
}
|
|
66
|
+
exports.InstallationNotFoundError = InstallationNotFoundError;
|
|
67
|
+
class UnknownSiteWithoutResourceIdError extends Error {
|
|
68
|
+
constructor() {
|
|
69
|
+
super(cli_shared_1.Text.installList.noResourceId);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.UnknownSiteWithoutResourceIdError = UnknownSiteWithoutResourceIdError;
|
|
73
|
+
class InstallationsGraphqlClient {
|
|
74
|
+
constructor(graphqlClient, cloudIdTranslator, bitbucketTranslator, pause) {
|
|
75
|
+
this.graphqlClient = graphqlClient;
|
|
76
|
+
this.cloudIdTranslator = cloudIdTranslator;
|
|
77
|
+
this.bitbucketTranslator = bitbucketTranslator;
|
|
78
|
+
this.pause = pause;
|
|
79
|
+
this.SITE_RESOURCE_TYPE = 'site';
|
|
80
|
+
this.WORKSPACE_RESOURCE_TYPE = 'workspace';
|
|
81
|
+
}
|
|
82
|
+
static buildInstallationContext(product, resourceId, resourceType) {
|
|
83
|
+
const ari = new cs_ari_1.ResourceIdentifier({
|
|
84
|
+
resourceOwner: product.toLowerCase(),
|
|
85
|
+
resourceType: resourceType,
|
|
86
|
+
resourceId: resourceId
|
|
87
|
+
});
|
|
88
|
+
return ari.toString();
|
|
89
|
+
}
|
|
90
|
+
async buildInstallationContext(product, site) {
|
|
91
|
+
const ari = await this.getProductTranslation(product).buildInstallationContext(product, site);
|
|
92
|
+
return ari.toString();
|
|
93
|
+
}
|
|
94
|
+
getProductTranslation(product) {
|
|
95
|
+
if (product && (0, cli_shared_1.isBitbucketProduct)(product)) {
|
|
96
|
+
return this.bitbucketTranslator;
|
|
97
|
+
}
|
|
98
|
+
return this.cloudIdTranslator;
|
|
99
|
+
}
|
|
100
|
+
async installAppIntoSite({ environmentKey, site, product, appId }) {
|
|
101
|
+
const installationContext = await this.buildInstallationContext(product, site);
|
|
102
|
+
const query = `
|
|
103
|
+
mutation forge_cli_installApplication($input: AppInstallationInput!) {
|
|
104
|
+
installApp(input: $input) {
|
|
105
|
+
success
|
|
106
|
+
taskId
|
|
107
|
+
errors {
|
|
108
|
+
message
|
|
109
|
+
extensions {
|
|
110
|
+
errorType
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
const variables = {
|
|
117
|
+
input: {
|
|
118
|
+
installationContext,
|
|
119
|
+
appId,
|
|
120
|
+
environmentKey,
|
|
121
|
+
async: true
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const { response: { installApp: { success, taskId, errors } }, requestId } = await this.graphqlClient.mutate(query, variables);
|
|
125
|
+
const error = (0, cli_shared_1.getError)(errors);
|
|
126
|
+
if (!success) {
|
|
127
|
+
if (error.code === ALREADY_INSTALLED_CODE) {
|
|
128
|
+
throw new AlreadyInstalledError(requestId, error.statusCode);
|
|
129
|
+
}
|
|
130
|
+
if (error.code === PERMISSION_DENIED) {
|
|
131
|
+
throw new PermissionDeniedError(requestId, (0, cs_ari_1.parse)(appId).resourceId, error.statusCode);
|
|
132
|
+
}
|
|
133
|
+
throw new InstallationError(`${error.message} (requestId: ${requestId || 'unknown'})`, {
|
|
134
|
+
requestId,
|
|
135
|
+
code: error.code,
|
|
136
|
+
statusCode: error.statusCode
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (!taskId) {
|
|
140
|
+
throw new MissingTaskIdError(error.message);
|
|
141
|
+
}
|
|
142
|
+
await this.monitorAppInstallOrUpgrade(taskId);
|
|
143
|
+
}
|
|
144
|
+
async upgradeInstallation({ site, product, environmentKey, appId }) {
|
|
145
|
+
const installationContext = await this.buildInstallationContext(product, site);
|
|
146
|
+
const query = `
|
|
147
|
+
mutation forge_cli_upgradeApplication($input: AppInstallationUpgradeInput!) {
|
|
148
|
+
upgradeApp(input: $input) {
|
|
149
|
+
success
|
|
150
|
+
taskId
|
|
151
|
+
errors {
|
|
152
|
+
message
|
|
153
|
+
extensions {
|
|
154
|
+
errorType
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
`;
|
|
160
|
+
const variables = {
|
|
161
|
+
input: {
|
|
162
|
+
installationContext,
|
|
163
|
+
appId,
|
|
164
|
+
environmentKey,
|
|
165
|
+
async: true
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const { response: { upgradeApp: { success, errors, taskId } }, requestId } = await this.graphqlClient.mutate(query, variables);
|
|
169
|
+
const error = (0, cli_shared_1.getError)(errors);
|
|
170
|
+
if (!success) {
|
|
171
|
+
throw new UpgradeError(`${error.message} (requestId: ${requestId || 'unknown'})`, {
|
|
172
|
+
requestId,
|
|
173
|
+
code: error.code,
|
|
174
|
+
statusCode: error.statusCode
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (!taskId) {
|
|
178
|
+
throw new MissingTaskIdError(error.message);
|
|
179
|
+
}
|
|
180
|
+
await this.monitorAppInstallOrUpgrade(taskId);
|
|
181
|
+
}
|
|
182
|
+
async monitorAppInstallOrUpgrade(taskId) {
|
|
183
|
+
var _a, _b, _c, _d;
|
|
184
|
+
let status = cli_shared_1.AppTaskState.Pending;
|
|
185
|
+
while (status !== cli_shared_1.AppTaskState.Complete) {
|
|
186
|
+
const { state, errors } = await this.getAppInstallationTask(taskId);
|
|
187
|
+
status = state;
|
|
188
|
+
if (status === cli_shared_1.AppTaskState.Failed) {
|
|
189
|
+
const error = errors === null || errors === void 0 ? void 0 : errors[0];
|
|
190
|
+
const statusCode = (_a = error === null || error === void 0 ? void 0 : error.extensions) === null || _a === void 0 ? void 0 : _a.statusCode;
|
|
191
|
+
const isUserError = statusCode && statusCode >= 400 && statusCode < 500 ? true : false;
|
|
192
|
+
const code = (_c = (_b = error === null || error === void 0 ? void 0 : error.extensions) === null || _b === void 0 ? void 0 : _b.errorType) !== null && _c !== void 0 ? _c : undefined;
|
|
193
|
+
throw new InstallationRequestFailedError(isUserError, code, (_d = error === null || error === void 0 ? void 0 : error.message) !== null && _d !== void 0 ? _d : undefined);
|
|
194
|
+
}
|
|
195
|
+
if (status !== cli_shared_1.AppTaskState.Complete)
|
|
196
|
+
await this.pause(exports.UNINSTALLATION_EVENT_POLL_INTERVAL);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async uninstallApp(input) {
|
|
200
|
+
const query = `
|
|
201
|
+
mutation forge_cli_uninstallApplication($input: AppUninstallationInput!) {
|
|
202
|
+
uninstallApp(input: $input) {
|
|
203
|
+
success
|
|
204
|
+
taskId
|
|
205
|
+
errors {
|
|
206
|
+
message
|
|
207
|
+
extensions {
|
|
208
|
+
errorType
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
`;
|
|
214
|
+
const { response: { uninstallApp: { success, errors, taskId } }, requestId } = await this.graphqlClient.mutate(query, { input });
|
|
215
|
+
const error = (0, cli_shared_1.getError)(errors);
|
|
216
|
+
if (!success) {
|
|
217
|
+
throw new cli_shared_1.GraphQlMutationError(`${error.message} (requestId: ${requestId || 'unknown'})`, {
|
|
218
|
+
requestId,
|
|
219
|
+
code: error.code,
|
|
220
|
+
statusCode: error.statusCode
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return this.monitorUninstallApp(taskId);
|
|
224
|
+
}
|
|
225
|
+
async uninstallMultipleApps(apps) {
|
|
226
|
+
const uninstallsResult = [];
|
|
227
|
+
for (const app of apps) {
|
|
228
|
+
try {
|
|
229
|
+
const [success] = await Promise.all([
|
|
230
|
+
this.uninstallApp(app),
|
|
231
|
+
new Promise((resolve) => setTimeout(resolve, 1000))
|
|
232
|
+
]);
|
|
233
|
+
uninstallsResult.push(Object.assign(Object.assign({}, app), { successful: success }));
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
uninstallsResult.push(Object.assign(Object.assign({}, app), { successful: false }));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return uninstallsResult;
|
|
240
|
+
}
|
|
241
|
+
async listInstallations(appId) {
|
|
242
|
+
const installations = await this.getAllInstallations(appId);
|
|
243
|
+
return await this.resolveInstallationsHostnames(installations);
|
|
244
|
+
}
|
|
245
|
+
async getInstallation(appId, installationId) {
|
|
246
|
+
const installations = await this.listInstallations(appId);
|
|
247
|
+
const matchedInstallation = installations.find(({ id }) => id === installationId);
|
|
248
|
+
if (matchedInstallation) {
|
|
249
|
+
return matchedInstallation;
|
|
250
|
+
}
|
|
251
|
+
throw new InstallationNotFoundError(cli_shared_1.Text.installationId.errors.notFound(installationId));
|
|
252
|
+
}
|
|
253
|
+
async getAppInstallationTask(taskId) {
|
|
254
|
+
const query = `
|
|
255
|
+
query forge_cli_getInstallationTask($id: ID!) {
|
|
256
|
+
appInstallationTask(id: $id) {
|
|
257
|
+
state
|
|
258
|
+
errors {
|
|
259
|
+
message
|
|
260
|
+
extensions {
|
|
261
|
+
errorType
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
`;
|
|
267
|
+
const { appInstallationTask } = await this.graphqlClient.query(query, {
|
|
268
|
+
id: taskId
|
|
269
|
+
});
|
|
270
|
+
if (!appInstallationTask) {
|
|
271
|
+
throw new MissingAppUninstallTask(cli_shared_1.Text.uninstall.missingUninstallTask);
|
|
272
|
+
}
|
|
273
|
+
const { state, errors } = appInstallationTask;
|
|
274
|
+
return {
|
|
275
|
+
errors,
|
|
276
|
+
state
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
async monitorUninstallApp(taskId) {
|
|
280
|
+
let status = cli_shared_1.AppTaskState.Pending;
|
|
281
|
+
while (status !== cli_shared_1.AppTaskState.Complete) {
|
|
282
|
+
const { state } = await this.getAppInstallationTask(taskId);
|
|
283
|
+
status = state;
|
|
284
|
+
if (status === cli_shared_1.AppTaskState.Failed) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
if (status !== cli_shared_1.AppTaskState.Complete)
|
|
288
|
+
await this.pause(exports.UNINSTALLATION_EVENT_POLL_INTERVAL);
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
getResourceArisForProduct(installationContexts, condition) {
|
|
293
|
+
return [...new Set(installationContexts.filter((context) => condition(context)))];
|
|
294
|
+
}
|
|
295
|
+
async getCombinedHostnameMap(installationContexts) {
|
|
296
|
+
const bitbucketAris = this.getResourceArisForProduct(installationContexts, this.bitbucketTranslator.ariBelongsToProduct);
|
|
297
|
+
const workspaceAriToHostname = await this.bitbucketTranslator.getSitesForResourceAris(bitbucketAris);
|
|
298
|
+
const cloudIdAris = this.getResourceArisForProduct(installationContexts, this.cloudIdTranslator.ariBelongsToProduct);
|
|
299
|
+
const siteAriToHostname = await this.cloudIdTranslator.getSitesForResourceAris(cloudIdAris);
|
|
300
|
+
const combinedAriToHostname = Object.assign(Object.assign({}, siteAriToHostname), workspaceAriToHostname);
|
|
301
|
+
return combinedAriToHostname;
|
|
302
|
+
}
|
|
303
|
+
async resolveInstallationsHostnames(installations) {
|
|
304
|
+
if (!installations.length) {
|
|
305
|
+
return [];
|
|
306
|
+
}
|
|
307
|
+
const installationContexts = installations.map(({ installation }) => {
|
|
308
|
+
const context = (0, cs_ari_1.parse)(installation.installationContext);
|
|
309
|
+
const resourceId = context.resourceId;
|
|
310
|
+
if (!resourceId) {
|
|
311
|
+
throw new UnknownSiteWithoutResourceIdError();
|
|
312
|
+
}
|
|
313
|
+
return context;
|
|
314
|
+
});
|
|
315
|
+
const combinedAriToHostname = await this.getCombinedHostnameMap(installationContexts);
|
|
316
|
+
return installationContexts.map((context, i) => {
|
|
317
|
+
const { environment, installation } = installations[i];
|
|
318
|
+
const site = combinedAriToHostname[context.toString()];
|
|
319
|
+
return {
|
|
320
|
+
id: installation.id,
|
|
321
|
+
product: context.resourceOwner,
|
|
322
|
+
environmentKey: environment,
|
|
323
|
+
context: installation.installationContext,
|
|
324
|
+
site,
|
|
325
|
+
version: installation.version || {
|
|
326
|
+
isLatest: false
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
async getAllInstallations(appId) {
|
|
332
|
+
var _a, _b;
|
|
333
|
+
const query = `
|
|
334
|
+
query forge_cli_getEcosystemInstallationsByApp($filter: AppInstallationsByAppFilter!, $first: Int, $after: String) {
|
|
335
|
+
ecosystem {
|
|
336
|
+
appInstallationsByApp(filter: $filter, first: $first, after: $after) {
|
|
337
|
+
nodes {
|
|
338
|
+
id
|
|
339
|
+
installationContext
|
|
340
|
+
version {
|
|
341
|
+
isLatest
|
|
342
|
+
}
|
|
343
|
+
appEnvironment {
|
|
344
|
+
key
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
pageInfo {
|
|
348
|
+
hasNextPage
|
|
349
|
+
endCursor
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
`;
|
|
355
|
+
const output = [];
|
|
356
|
+
let cursor = undefined;
|
|
357
|
+
let hasNext = undefined;
|
|
358
|
+
do {
|
|
359
|
+
const result = (await this.graphqlClient.query(query, {
|
|
360
|
+
filter: {
|
|
361
|
+
apps: {
|
|
362
|
+
ids: [appId]
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
first: 100,
|
|
366
|
+
after: cursor
|
|
367
|
+
}));
|
|
368
|
+
if (!((_b = (_a = result === null || result === void 0 ? void 0 : result.ecosystem) === null || _a === void 0 ? void 0 : _a.appInstallationsByApp) === null || _b === void 0 ? void 0 : _b.nodes)) {
|
|
369
|
+
throw new MissingAppError();
|
|
370
|
+
}
|
|
371
|
+
const { nodes, pageInfo } = result.ecosystem.appInstallationsByApp;
|
|
372
|
+
for (const node of nodes) {
|
|
373
|
+
if (node) {
|
|
374
|
+
if (!node.appEnvironment) {
|
|
375
|
+
throw new MissingAppEnvironmentError();
|
|
376
|
+
}
|
|
377
|
+
output.push({
|
|
378
|
+
environment: node.appEnvironment.key,
|
|
379
|
+
installation: node
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
cursor = pageInfo.endCursor;
|
|
384
|
+
hasNext = pageInfo.hasNextPage;
|
|
385
|
+
} while (hasNext && cursor);
|
|
386
|
+
return output;
|
|
387
|
+
}
|
|
388
|
+
async getVersions(appId, environmentKey, firstN = 1) {
|
|
389
|
+
const query = `
|
|
390
|
+
query forge_cli_getApplicationEnvironmentLatestVersions($appId: ID!, $environmentKey: String!, $firstN: Int!) {
|
|
391
|
+
app(id: $appId) {
|
|
392
|
+
environmentByKey(key: $environmentKey) {
|
|
393
|
+
versions(first: $firstN) {
|
|
394
|
+
nodes {
|
|
395
|
+
permissions {
|
|
396
|
+
egress {
|
|
397
|
+
addresses
|
|
398
|
+
}
|
|
399
|
+
scopes {
|
|
400
|
+
key
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
`;
|
|
409
|
+
const result = await this.graphqlClient.query(query, {
|
|
410
|
+
appId,
|
|
411
|
+
environmentKey,
|
|
412
|
+
firstN
|
|
413
|
+
});
|
|
414
|
+
if (!result.app) {
|
|
415
|
+
throw new MissingAppError();
|
|
416
|
+
}
|
|
417
|
+
if (!result.app.environmentByKey) {
|
|
418
|
+
throw new EnvironmentNotFoundError();
|
|
419
|
+
}
|
|
420
|
+
return result.app.environmentByKey.versions;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
exports.InstallationsGraphqlClient = InstallationsGraphqlClient;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { URL } from 'url';
|
|
3
|
+
import { AppConfigProvider } from '@forge/cli-shared';
|
|
4
|
+
export interface TriggerAppSiteInstallDetails {
|
|
5
|
+
site: URL;
|
|
6
|
+
product: string;
|
|
7
|
+
environmentKey: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AppInstallSiteDetails extends TriggerAppSiteInstallDetails {
|
|
10
|
+
appId: string;
|
|
11
|
+
}
|
|
12
|
+
export interface InstallAppClient {
|
|
13
|
+
installAppIntoSite(appInstallDetails: AppInstallSiteDetails): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare class InstallAppSiteCommand {
|
|
16
|
+
private readonly getAppConfig;
|
|
17
|
+
private readonly installAppClient;
|
|
18
|
+
constructor(getAppConfig: AppConfigProvider, installAppClient: InstallAppClient);
|
|
19
|
+
execute({ environmentKey, site, product }: TriggerAppSiteInstallDetails): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=install-app-site.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-app-site.d.ts","sourceRoot":"","sources":["../../src/installations/install-app-site.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAsB,SAAQ,4BAA4B;IACzE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,CAAC,iBAAiB,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7E;AAED,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAAqB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;gBAAlE,YAAY,EAAE,iBAAiB,EAAmB,gBAAgB,EAAE,gBAAgB;IAEpG,OAAO,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,4BAA4B;CASrF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstallAppSiteCommand = void 0;
|
|
4
|
+
class InstallAppSiteCommand {
|
|
5
|
+
constructor(getAppConfig, installAppClient) {
|
|
6
|
+
this.getAppConfig = getAppConfig;
|
|
7
|
+
this.installAppClient = installAppClient;
|
|
8
|
+
}
|
|
9
|
+
async execute({ environmentKey, site, product }) {
|
|
10
|
+
const { id: appId } = await this.getAppConfig();
|
|
11
|
+
return await this.installAppClient.installAppIntoSite({
|
|
12
|
+
appId,
|
|
13
|
+
environmentKey,
|
|
14
|
+
site,
|
|
15
|
+
product
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.InstallAppSiteCommand = InstallAppSiteCommand;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Installation } from '../service/installation-service';
|
|
2
|
+
export declare class UninstallAppError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export declare const getHangingIdentityInstallationsFromSite: (allInstallations: Installation[], remainingApps: Installation[], sites: Set<string>) => Installation[];
|
|
5
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/installations/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,qBAAa,iBAAkB,SAAQ,KAAK;CAAG;AAE/C,eAAO,MAAM,uCAAuC,qBAChC,YAAY,EAAE,iBACjB,YAAY,EAAE,SACtB,IAAI,MAAM,CAAC,KACjB,YAAY,EAkBd,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHangingIdentityInstallationsFromSite = exports.UninstallAppError = void 0;
|
|
4
|
+
class UninstallAppError extends Error {
|
|
5
|
+
}
|
|
6
|
+
exports.UninstallAppError = UninstallAppError;
|
|
7
|
+
const getHangingIdentityInstallationsFromSite = (allInstallations, remainingApps, sites) => {
|
|
8
|
+
const hangingIdentityInstalls = [];
|
|
9
|
+
sites.forEach((site) => {
|
|
10
|
+
const shouldUninstallIdentity = remainingApps.filter((app) => app.site === site).length === 0;
|
|
11
|
+
if (shouldUninstallIdentity) {
|
|
12
|
+
const identityInstall = allInstallations.find((install) => install.site === site && install.product === 'identity');
|
|
13
|
+
if (identityInstall) {
|
|
14
|
+
hangingIdentityInstalls.push(identityInstall);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return hangingIdentityInstalls;
|
|
19
|
+
};
|
|
20
|
+
exports.getHangingIdentityInstallationsFromSite = getHangingIdentityInstallationsFromSite;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SiteTranslator, ResourcefulAri } from './site-translation';
|
|
3
|
+
import { URL } from 'url';
|
|
4
|
+
import { Ari } from '@forge/util/packages/cs-ari';
|
|
5
|
+
export declare class InvalidWorkspaceError extends Error {
|
|
6
|
+
constructor(url: URL);
|
|
7
|
+
}
|
|
8
|
+
export declare class InvalidResponseError extends Error {
|
|
9
|
+
constructor(url: URL);
|
|
10
|
+
}
|
|
11
|
+
export declare const getBitbucketEndpoint: () => string;
|
|
12
|
+
export declare class BitbucketTranslator implements SiteTranslator {
|
|
13
|
+
ariBelongsToProduct(ari: ResourcefulAri): boolean;
|
|
14
|
+
buildInstallationContext(product: string, site: URL): Promise<Ari>;
|
|
15
|
+
getSitesForResourceAris(aris: ResourcefulAri[]): Promise<Record<string, string>>;
|
|
16
|
+
private getWorkspaceId;
|
|
17
|
+
getWorkspaceUrl(workspaceId: string): Promise<URL | null>;
|
|
18
|
+
private decorateWorkspaceId;
|
|
19
|
+
private extractWorkspaceId;
|
|
20
|
+
private buildFetchUrl;
|
|
21
|
+
private extractWorkspaceName;
|
|
22
|
+
private buildWorkspaceUrl;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=bitbucket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitbucket.d.ts","sourceRoot":"","sources":["../../../src/installations/site-translation/bitbucket.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAsB,MAAM,6BAA6B,CAAC;AAGtE,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,GAAG,EAAE,GAAG;CAGrB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,GAAG,EAAE,GAAG;CAGrB;AAOD,eAAO,MAAM,oBAAoB,QAAO,MAEvC,CAAC;AAEF,qBAAa,mBAAoB,YAAW,cAAc;IACjD,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO;IAI3C,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAUlE,uBAAuB,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAc/E,cAAc;IAwBf,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAsBtE,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,iBAAiB;CAG1B"}
|