@forge/cli 0.0.0-experimental-383053a → 0.0.0-experimental-3b4aabe
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 +3872 -7
- package/README.md +18 -19
- package/npm-shrinkwrap.json +3100 -3556
- package/out/analytics-client/analytics-client.d.ts +3 -1
- package/out/analytics-client/analytics-client.d.ts.map +1 -1
- package/out/analytics-client/analytics-client.js +5 -1
- package/out/autocomplete/autocomplete-config.json +232 -212
- package/out/autocomplete/index.d.ts.map +1 -1
- package/out/autocomplete/index.js +12 -8
- 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 +5 -1
- package/out/autocomplete/types.d.ts.map +1 -1
- package/out/autocomplete/util.d.ts +1 -1
- package/out/autocomplete/util.d.ts.map +1 -1
- package/out/autocomplete/util.js +3 -3
- package/out/bin/cli.js +0 -2
- package/out/bin/postinstall.js +10 -1
- package/out/command-line/anon-user-id.js +6 -10
- package/out/command-line/command.d.ts +28 -8
- package/out/command-line/command.d.ts.map +1 -1
- package/out/command-line/command.js +190 -49
- 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 +2 -1
- package/out/command-line/controller/autocomplete-controller.d.ts.map +1 -1
- package/out/command-line/controller/autocomplete-controller.js +29 -3
- package/out/command-line/controller/deploy-controller.d.ts +13 -2
- package/out/command-line/controller/deploy-controller.d.ts.map +1 -1
- package/out/command-line/controller/deploy-controller.js +79 -5
- 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 +5 -4
- package/out/command-line/controller/install-controller.d.ts.map +1 -1
- package/out/command-line/controller/install-controller.js +31 -56
- package/out/command-line/controller/lint-controller.js +1 -1
- package/out/command-line/controller/pre-command-controller.d.ts +8 -1
- package/out/command-line/controller/pre-command-controller.d.ts.map +1 -1
- package/out/command-line/controller/pre-command-controller.js +22 -2
- package/out/command-line/controller/prerequisites-controller.d.ts +11 -0
- package/out/command-line/controller/prerequisites-controller.d.ts.map +1 -0
- package/out/command-line/controller/prerequisites-controller.js +34 -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/dependency-injection.d.ts +13 -3
- package/out/command-line/dependency-injection.d.ts.map +1 -1
- package/out/command-line/dependency-injection.js +53 -22
- package/out/command-line/index.d.ts +2 -38
- package/out/command-line/index.d.ts.map +1 -1
- package/out/command-line/index.js +22 -43
- package/out/command-line/register-app-commands.d.ts.map +1 -1
- package/out/command-line/register-app-commands.js +2 -12
- package/out/command-line/register-authentication-command.d.ts.map +1 -1
- package/out/command-line/register-authentication-command.js +1 -16
- package/out/command-line/register-autocomplete-commands.d.ts +0 -2
- package/out/command-line/register-autocomplete-commands.d.ts.map +1 -1
- package/out/command-line/register-autocomplete-commands.js +2 -9
- package/out/command-line/register-deployment-commands.d.ts +8 -0
- package/out/command-line/register-deployment-commands.d.ts.map +1 -1
- package/out/command-line/register-deployment-commands.js +1 -0
- package/out/command-line/register-environment-variables-commands.d.ts +1 -1
- package/out/command-line/register-environment-variables-commands.d.ts.map +1 -1
- package/out/command-line/register-environment-variables-commands.js +27 -10
- package/out/command-line/register-installation-commands.d.ts +4 -1
- package/out/command-line/register-installation-commands.d.ts.map +1 -1
- package/out/command-line/register-installation-commands.js +39 -23
- package/out/command-line/register-log-commands.d.ts +1 -0
- package/out/command-line/register-log-commands.d.ts.map +1 -1
- package/out/command-line/register-log-commands.js +26 -3
- 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 +43 -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 +37 -0
- package/out/command-line/register-webtrigger-commands.d.ts.map +1 -1
- package/out/command-line/register-webtrigger-commands.js +9 -11
- package/out/command-line/unique-machine-id.d.ts +1 -0
- package/out/command-line/unique-machine-id.d.ts.map +1 -1
- package/out/command-line/unique-machine-id.js +3 -12
- package/out/command-line/version-info.d.ts +1 -0
- package/out/command-line/version-info.d.ts.map +1 -1
- package/out/command-line/version-info.js +3 -2
- 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 +7 -1
- package/out/command-line/view/deploy-view.d.ts.map +1 -1
- package/out/command-line/view/deploy-view.js +25 -3
- package/out/command-line/view/install-view.d.ts +5 -3
- package/out/command-line/view/install-view.d.ts.map +1 -1
- package/out/command-line/view/install-view.js +19 -10
- package/out/command-line/view/lint-view.d.ts +3 -2
- package/out/command-line/view/lint-view.d.ts.map +1 -1
- package/out/command-line/view/lint-view.js +3 -0
- package/out/command-line/view/lite-lint-view.d.ts +3 -2
- package/out/command-line/view/lite-lint-view.d.ts.map +1 -1
- package/out/command-line/view/lite-lint-view.js +3 -0
- package/out/command-line/view/settings-view.d.ts +8 -0
- package/out/command-line/view/settings-view.d.ts.map +1 -0
- package/out/command-line/view/settings-view.js +21 -0
- package/out/deploy/deployer/deploy-monitor-graphql-client.js +1 -1
- package/out/deploy/deployer/deployer.d.ts.map +1 -1
- package/out/deploy/deployer/deployer.js +17 -1
- package/out/deploy/deployer/trigger-deploy-graphql-client.d.ts.map +1 -1
- package/out/deploy/deployer/trigger-deploy-graphql-client.js +9 -6
- package/out/deploy/packager/archiver.d.ts +3 -2
- package/out/deploy/packager/archiver.d.ts.map +1 -1
- package/out/deploy/packager/archiver.js +10 -2
- package/out/deploy/packager/packager.d.ts.map +1 -1
- package/out/deploy/packager/packager.js +20 -20
- package/out/deploy/uploader/artifact-graphql-client.d.ts.map +1 -1
- package/out/deploy/uploader/artifact-graphql-client.js +12 -9
- package/out/environment-variables/graphql-client.d.ts +1 -1
- package/out/environment-variables/graphql-client.d.ts.map +1 -1
- package/out/environment-variables/graphql-client.js +19 -13
- package/out/environment-variables/list-environment-variables.d.ts +2 -2
- package/out/environment-variables/list-environment-variables.d.ts.map +1 -1
- package/out/installations/graphql-client.d.ts +19 -13
- package/out/installations/graphql-client.d.ts.map +1 -1
- package/out/installations/graphql-client.js +168 -61
- package/out/installations/install-app-site.d.ts +2 -12
- package/out/installations/install-app-site.d.ts.map +1 -1
- package/out/installations/install-app-site.js +3 -14
- package/out/installations/uninstall-app.d.ts +5 -3
- package/out/installations/uninstall-app.d.ts.map +1 -1
- package/out/installations/uninstall-app.js +7 -7
- 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 +12 -0
- package/out/providers/graphql-client.d.ts.map +1 -0
- package/out/providers/graphql-client.js +47 -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/installation-service.d.ts +13 -13
- package/out/service/installation-service.d.ts.map +1 -1
- package/out/service/installation-service.js +38 -23
- package/out/service/lint-service.d.ts +2 -2
- package/out/service/lint-service.d.ts.map +1 -1
- package/out/service/lint-service.js +3 -3
- package/out/service/lite-lint-service.d.ts +3 -3
- package/out/service/lite-lint-service.d.ts.map +1 -1
- package/out/service/lite-lint-service.js +2 -2
- 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 +4 -4
- package/out/service/resource-packaging-service.d.ts.map +1 -1
- package/out/service/resource-packaging-service.js +9 -22
- package/out/service/tunnel-service.d.ts +6 -2
- package/out/service/tunnel-service.d.ts.map +1 -1
- package/out/service/tunnel-service.js +53 -12
- package/out/webtrigger/get-webtrigger-url.d.ts +10 -4
- package/out/webtrigger/get-webtrigger-url.d.ts.map +1 -1
- package/out/webtrigger/get-webtrigger-url.js +11 -18
- 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 +3 -1
- package/out/workers/analytics-message-worker.d.ts.map +1 -1
- package/out/workers/analytics-message-worker.js +9 -2
- package/out/workers/forge-cli-workers.js +6 -1
- package/package.json +19 -18
- package/out/bin/preinstall.d.ts +0 -3
- package/out/bin/preinstall.d.ts.map +0 -1
- package/out/bin/preinstall.js +0 -9
- package/out/command-line/cli-prerequisites.d.ts +0 -3
- package/out/command-line/cli-prerequisites.d.ts.map +0 -1
- package/out/command-line/cli-prerequisites.js +0 -37
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphqlClient = void 0;
|
|
4
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
5
|
+
class GraphqlClient {
|
|
6
|
+
constructor(graphqlClient) {
|
|
7
|
+
this.graphqlClient = graphqlClient;
|
|
8
|
+
}
|
|
9
|
+
async getLatestMigrationKeys(appId, environmentKey) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const query = `
|
|
12
|
+
query forge_cli_getMigrationKeys($id: ID!, $key: String!) {
|
|
13
|
+
app(id: $id) {
|
|
14
|
+
environmentByKey(key: $key) {
|
|
15
|
+
id
|
|
16
|
+
versions(first: 1) {
|
|
17
|
+
edges {
|
|
18
|
+
node {
|
|
19
|
+
isLatest
|
|
20
|
+
migrationKeys {
|
|
21
|
+
jira
|
|
22
|
+
confluence
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
marketplaceApp {
|
|
29
|
+
appKey
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const result = await this.graphqlClient.query(query, {
|
|
35
|
+
id: appId,
|
|
36
|
+
key: environmentKey
|
|
37
|
+
});
|
|
38
|
+
if (!result.app) {
|
|
39
|
+
throw new cli_shared_1.MissingAppError();
|
|
40
|
+
}
|
|
41
|
+
if (!result.app.environmentByKey) {
|
|
42
|
+
throw new cli_shared_1.MissingAppEnvironmentError();
|
|
43
|
+
}
|
|
44
|
+
const mpacAppKey = (_a = result.app.marketplaceApp) === null || _a === void 0 ? void 0 : _a.appKey;
|
|
45
|
+
const versions = result.app.environmentByKey.versions;
|
|
46
|
+
let migrationKeys;
|
|
47
|
+
for (const edge of (versions === null || versions === void 0 ? void 0 : versions.edges) || []) {
|
|
48
|
+
if (edge) {
|
|
49
|
+
migrationKeys = (_b = edge.node) === null || _b === void 0 ? void 0 : _b.migrationKeys;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { migrationKeys, mpacAppKey };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.GraphqlClient = GraphqlClient;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AppConfigProvider } from '@forge/cli-shared';
|
|
2
|
+
export interface ProviderDetails {
|
|
3
|
+
environment: string;
|
|
4
|
+
providerKey: string;
|
|
5
|
+
clientSecret: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AppProviderDetails extends ProviderDetails {
|
|
8
|
+
appId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ConfigureProviderClient {
|
|
11
|
+
configureProvider(details: AppProviderDetails): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare class ConfigureProviderCommand {
|
|
14
|
+
private readonly client;
|
|
15
|
+
private readonly getAppConfig;
|
|
16
|
+
constructor(client: ConfigureProviderClient, getAppConfig: AppConfigProvider);
|
|
17
|
+
execute(details: ProviderDetails): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=configure-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure-provider.d.ts","sourceRoot":"","sources":["../../src/providers/configure-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/D;AAED,qBAAa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAA2B,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAA9D,MAAM,EAAE,uBAAuB,EAAmB,YAAY,EAAE,iBAAiB;IAEjG,OAAO,CAAC,OAAO,EAAE,eAAe;CAO9C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigureProviderCommand = void 0;
|
|
4
|
+
class ConfigureProviderCommand {
|
|
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.configureProvider(Object.assign(Object.assign({}, details), { appId }));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ConfigureProviderCommand = ConfigureProviderCommand;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GraphQLClient } from '@forge/cli-shared';
|
|
2
|
+
import { AppProviderDetails, ConfigureProviderClient } from './configure-provider';
|
|
3
|
+
export declare class MissingAppError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export declare class MissingAppEnvironmentError extends Error {
|
|
6
|
+
}
|
|
7
|
+
export declare class GraphqlClient implements ConfigureProviderClient {
|
|
8
|
+
private readonly graphqlClient;
|
|
9
|
+
constructor(graphqlClient: GraphQLClient);
|
|
10
|
+
configureProvider(details: AppProviderDetails): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=graphql-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/providers/graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAwB,MAAM,mBAAmB,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,qBAAa,eAAgB,SAAQ,KAAK;CAAG;AAC7C,qBAAa,0BAA2B,SAAQ,KAAK;CAAG;AAExD,qBAAa,aAAc,YAAW,uBAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAE5C,iBAAiB,CAAC,OAAO,EAAE,kBAAkB;CA0C3D"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphqlClient = exports.MissingAppEnvironmentError = exports.MissingAppError = void 0;
|
|
4
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
5
|
+
class MissingAppError extends Error {
|
|
6
|
+
}
|
|
7
|
+
exports.MissingAppError = MissingAppError;
|
|
8
|
+
class MissingAppEnvironmentError extends Error {
|
|
9
|
+
}
|
|
10
|
+
exports.MissingAppEnvironmentError = MissingAppEnvironmentError;
|
|
11
|
+
class GraphqlClient {
|
|
12
|
+
constructor(graphqlClient) {
|
|
13
|
+
this.graphqlClient = graphqlClient;
|
|
14
|
+
}
|
|
15
|
+
async configureProvider(details) {
|
|
16
|
+
const mutation = `
|
|
17
|
+
mutation forge_cli_setExternalAuthCredentials($input: SetExternalAuthCredentialsInput!) {
|
|
18
|
+
setExternalAuthCredentials(input: $input) {
|
|
19
|
+
success
|
|
20
|
+
errors {
|
|
21
|
+
message
|
|
22
|
+
extensions {
|
|
23
|
+
errorType
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const { response: { setExternalAuthCredentials: { success, errors } }, requestId } = await this.graphqlClient.mutate(mutation, {
|
|
30
|
+
input: {
|
|
31
|
+
environment: {
|
|
32
|
+
appId: details.appId,
|
|
33
|
+
key: details.environment
|
|
34
|
+
},
|
|
35
|
+
serviceKey: details.providerKey,
|
|
36
|
+
credentials: {
|
|
37
|
+
clientSecret: details.clientSecret
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const error = cli_shared_1.getError(errors);
|
|
42
|
+
if (!success) {
|
|
43
|
+
throw new cli_shared_1.GraphQlMutationError(`${error.message} (requestId: ${requestId || 'unknown'})`, error.code);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.GraphqlClient = GraphqlClient;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CachedConf } from '@forge/cli-shared';
|
|
2
|
+
export declare class CachedConfigService {
|
|
3
|
+
private readonly cachedConf;
|
|
4
|
+
constructor(cachedConf: CachedConf);
|
|
5
|
+
getAnalyticsPreferences(): boolean | undefined;
|
|
6
|
+
setAnalyticsPreferences(preference: boolean): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=cached-config-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cached-config-service.d.ts","sourceRoot":"","sources":["../../src/service/cached-config-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAE5C,uBAAuB,IAAI,OAAO,GAAG,SAAS;IAI9C,uBAAuB,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI;CAG1D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CachedConfigService = void 0;
|
|
4
|
+
const ANALYTICS_PREFERENCES_KEY = 'analytics-preferences';
|
|
5
|
+
class CachedConfigService {
|
|
6
|
+
constructor(cachedConf) {
|
|
7
|
+
this.cachedConf = cachedConf;
|
|
8
|
+
}
|
|
9
|
+
getAnalyticsPreferences() {
|
|
10
|
+
return this.cachedConf.get(ANALYTICS_PREFERENCES_KEY);
|
|
11
|
+
}
|
|
12
|
+
setAnalyticsPreferences(preference) {
|
|
13
|
+
this.cachedConf.set(ANALYTICS_PREFERENCES_KEY, preference);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.CachedConfigService = CachedConfigService;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { AppConfigProvider, AppEnvironment } from '@forge/cli-shared';
|
|
3
|
-
import { AppInstallSiteDetails } from '../installations/install-app-site';
|
|
4
3
|
import { URL } from 'url';
|
|
4
|
+
import { AppInstallSiteDetails } from '../installations/install-app-site';
|
|
5
5
|
export interface Installation {
|
|
6
6
|
id: string;
|
|
7
7
|
product: string;
|
|
8
8
|
site: string;
|
|
9
9
|
environmentKey: string;
|
|
10
|
+
context: string;
|
|
10
11
|
version: {
|
|
11
12
|
isLatest: boolean;
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
export interface AppInstallation {
|
|
15
|
-
name: string;
|
|
16
16
|
installations: Installation[];
|
|
17
17
|
}
|
|
18
|
-
export interface
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export interface AppEnvironmentVersionPermissions {
|
|
19
|
+
scopes: string[];
|
|
20
|
+
egressAddresses: string[];
|
|
21
21
|
}
|
|
22
|
-
export interface
|
|
23
|
-
|
|
22
|
+
export interface AppEnvironmentPermissions extends AppEnvironmentVersionPermissions {
|
|
23
|
+
addedScopes: string[];
|
|
24
24
|
}
|
|
25
25
|
interface InstallationFilterOptions {
|
|
26
26
|
site?: string;
|
|
@@ -29,10 +29,10 @@ interface InstallationFilterOptions {
|
|
|
29
29
|
}
|
|
30
30
|
export interface ListAppInstallationsClient {
|
|
31
31
|
listInstallations(appId: string): Promise<Installation[]>;
|
|
32
|
-
|
|
32
|
+
getVersions(appId: string, environmentKey: string, firstN: number): Promise<AppEnvironment['versions']>;
|
|
33
33
|
}
|
|
34
34
|
export interface UpgradeAppInstallationsClient {
|
|
35
|
-
upgradeInstallation({ site, product, environmentKey, appId }: AppInstallSiteDetails): Promise<
|
|
35
|
+
upgradeInstallation({ site, product, environmentKey, appId }: AppInstallSiteDetails): Promise<void>;
|
|
36
36
|
}
|
|
37
37
|
export declare class InstallationService {
|
|
38
38
|
private readonly getAppConfig;
|
|
@@ -41,11 +41,11 @@ export declare class InstallationService {
|
|
|
41
41
|
constructor(getAppConfig: AppConfigProvider, listInstallationsClient: ListAppInstallationsClient, upgradeAppInstallationsClient: UpgradeAppInstallationsClient);
|
|
42
42
|
private filterInstallations;
|
|
43
43
|
listAppInstallations(filter?: InstallationFilterOptions): Promise<AppInstallation>;
|
|
44
|
-
|
|
44
|
+
listNonTechnicalAppInstallations(filter?: InstallationFilterOptions): Promise<AppInstallation>;
|
|
45
45
|
hasOutdatedProductInstallation(environment: string): Promise<boolean>;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
upgradeInstallation(site: URL, product: string, environmentKey: string, appId: string): Promise<boolean>;
|
|
47
|
+
private getPermissionsFromAppEnvironmentVersion;
|
|
48
|
+
getAppEnvironmentPermissions(appId: string, environmentKey: string): Promise<AppEnvironmentPermissions | undefined>;
|
|
49
49
|
}
|
|
50
50
|
export {};
|
|
51
51
|
//# sourceMappingURL=installation-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installation-service.d.ts","sourceRoot":"","sources":["../../src/service/installation-service.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"installation-service.d.ts","sourceRoot":"","sources":["../../src/service/installation-service.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EAQf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,QAAQ,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,gCAAgC;IAC/C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,yBAA0B,SAAQ,gCAAgC;IACjF,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,UAAU,yBAAyB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAC1D,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;CACzG;AAED,MAAM,WAAW,6BAA6B;IAC5C,mBAAmB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrG;AAKD,qBAAa,mBAAmB;IAE5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,6BAA6B;gBAF7B,YAAY,EAAE,iBAAiB,EAC/B,uBAAuB,EAAE,0BAA0B,EACnD,6BAA6B,EAAE,6BAA6B;IAG/E,OAAO,CAAC,mBAAmB;IAiBd,oBAAoB,CAAC,MAAM,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,eAAe,CAAC;IAOlF,gCAAgC,CAAC,MAAM,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,eAAe,CAAC;IAU9F,8BAA8B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOrE,mBAAmB,CAC9B,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC;IAkBnB,OAAO,CAAC,uCAAuC;IAgBlC,4BAA4B,CACvC,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC;CAyBlD"}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InstallationService = void 0;
|
|
4
4
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
5
|
-
const
|
|
6
|
-
const url_1 = require("url");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
7
6
|
const graphql_client_1 = require("../installations/graphql-client");
|
|
8
7
|
const IDENTITY_PRODUCT_NAME = 'identity';
|
|
8
|
+
const JIRA_SERVICE_DESK_PRODUCT_NAME = 'jira-servicedesk';
|
|
9
9
|
class InstallationService {
|
|
10
10
|
constructor(getAppConfig, listInstallationsClient, upgradeAppInstallationsClient) {
|
|
11
11
|
this.getAppConfig = getAppConfig;
|
|
@@ -24,51 +24,66 @@ class InstallationService {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
async listAppInstallations(filter) {
|
|
27
|
-
const { id: appId
|
|
27
|
+
const { id: appId } = await this.getAppConfig();
|
|
28
28
|
const installations = await this.listInstallationsClient.listInstallations(appId);
|
|
29
|
-
return {
|
|
29
|
+
return { installations: this.filterInstallations(installations, Object.assign({}, filter)) };
|
|
30
30
|
}
|
|
31
|
-
async
|
|
32
|
-
const {
|
|
33
|
-
return {
|
|
31
|
+
async listNonTechnicalAppInstallations(filter) {
|
|
32
|
+
const { installations } = await this.listAppInstallations(filter);
|
|
33
|
+
return {
|
|
34
|
+
installations: installations.filter(({ product }) => product !== IDENTITY_PRODUCT_NAME && product !== JIRA_SERVICE_DESK_PRODUCT_NAME)
|
|
35
|
+
};
|
|
34
36
|
}
|
|
35
37
|
async hasOutdatedProductInstallation(environment) {
|
|
36
|
-
const { installations } = await this.
|
|
38
|
+
const { installations } = await this.listNonTechnicalAppInstallations({
|
|
37
39
|
environment
|
|
38
40
|
});
|
|
39
41
|
return installations.some((installation) => !installation.version.isLatest);
|
|
40
42
|
}
|
|
41
|
-
addRedirectUrl(authorizationUrl) {
|
|
42
|
-
const url = new url_1.URL(authorizationUrl);
|
|
43
|
-
url.searchParams.append('redirectUrl', install_app_site_1.REDIRECT_URL_3LO);
|
|
44
|
-
return url.toString();
|
|
45
|
-
}
|
|
46
43
|
async upgradeInstallation(site, product, environmentKey, appId) {
|
|
47
44
|
try {
|
|
48
|
-
|
|
45
|
+
await this.upgradeAppInstallationsClient.upgradeInstallation({
|
|
49
46
|
site,
|
|
50
47
|
product,
|
|
51
48
|
environmentKey,
|
|
52
49
|
appId
|
|
53
50
|
});
|
|
54
|
-
|
|
55
|
-
result.authorizationUrl = this.addRedirectUrl(result.authorizationUrl);
|
|
56
|
-
}
|
|
57
|
-
return result;
|
|
51
|
+
return false;
|
|
58
52
|
}
|
|
59
53
|
catch (e) {
|
|
60
54
|
if (e.code === graphql_client_1.ALREADY_UPGRADED_CODE) {
|
|
61
|
-
return
|
|
62
|
-
alreadyUpdated: true
|
|
63
|
-
};
|
|
55
|
+
return true;
|
|
64
56
|
}
|
|
65
57
|
else {
|
|
66
58
|
throw e;
|
|
67
59
|
}
|
|
68
60
|
}
|
|
69
61
|
}
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
getPermissionsFromAppEnvironmentVersion(appEnvironmentVersion) {
|
|
63
|
+
const permissions = appEnvironmentVersion === null || appEnvironmentVersion === void 0 ? void 0 : appEnvironmentVersion.permissions[0];
|
|
64
|
+
if (!permissions) {
|
|
65
|
+
return { scopes: [], egressAddresses: [] };
|
|
66
|
+
}
|
|
67
|
+
const scopes = permissions.scopes.map((s) => s.key);
|
|
68
|
+
const egressAddresses = (permissions === null || permissions === void 0 ? void 0 : permissions.egress) ? cli_shared_1.flatMap(permissions.egress, ({ addresses }) => addresses !== null && addresses !== void 0 ? addresses : []) : [];
|
|
69
|
+
return { scopes, egressAddresses };
|
|
70
|
+
}
|
|
71
|
+
async getAppEnvironmentPermissions(appId, environmentKey) {
|
|
72
|
+
const versionDetails = await this.listInstallationsClient.getVersions(appId, environmentKey, 2);
|
|
73
|
+
const versions = versionDetails === null || versionDetails === void 0 ? void 0 : versionDetails.nodes;
|
|
74
|
+
if (!versions || versions.length === 0)
|
|
75
|
+
return;
|
|
76
|
+
const [{ scopes }, oldVersion] = versions.map((appEnvironmentVersion) => this.getPermissionsFromAppEnvironmentVersion(appEnvironmentVersion));
|
|
77
|
+
if (!oldVersion) {
|
|
78
|
+
return {
|
|
79
|
+
scopes,
|
|
80
|
+
egressAddresses: [],
|
|
81
|
+
addedScopes: scopes
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const { scopes: oldScopes } = oldVersion;
|
|
85
|
+
const addedScopes = lodash_1.difference(scopes, oldScopes);
|
|
86
|
+
return { scopes, egressAddresses: [], addedScopes };
|
|
72
87
|
}
|
|
73
88
|
}
|
|
74
89
|
exports.InstallationService = InstallationService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ConfigFile, FileSystemReader } from '@forge/cli-shared';
|
|
3
|
-
import { LintFixState, LintResult, ProblemCount } from '@forge/lint';
|
|
3
|
+
import { LintFixState, LintResult, LintLogger, ProblemCount } from '@forge/lint';
|
|
4
4
|
interface LintOptions {
|
|
5
5
|
fix?: boolean;
|
|
6
6
|
}
|
|
@@ -13,7 +13,7 @@ export declare class LintService {
|
|
|
13
13
|
private readonly configFile;
|
|
14
14
|
private readonly fileSystemReader;
|
|
15
15
|
constructor(configFile: ConfigFile, fileSystemReader: FileSystemReader);
|
|
16
|
-
run(environment: string, { fix }: LintOptions, directory?: string, lintFunction?: (filesToLint: string[], manifest: import("@forge/manifest").ManifestSchema, environment: string, parseFunction?: ((filepath: string, parser: (code: string,
|
|
16
|
+
run(environment: string, { fix }: LintOptions, logger: LintLogger, directory?: string, lintFunction?: (filesToLint: string[], manifest: import("@forge/manifest").ManifestSchema, environment: string, logger: Pick<import("@forge/cli-shared/src").Logger, "info">, parseFunction?: ((filepath: string, parser: (code: string, filepath: string, parseOptions?: Partial<import("@forge/lint").ParseOptions> | undefined) => Promise<import("@forge/lint").ASTParseResult>, readFilePromise?: typeof import("fs").readFile.__promisify__ | undefined) => Promise<import("@forge/lint").LintInput>) | undefined, linters?: import("@forge/lint").LinterInterface[] | undefined) => Promise<LintResult[]>): Promise<RunResult>;
|
|
17
17
|
private fix;
|
|
18
18
|
problemCount(lintResults: LintResult[]): ProblemCount;
|
|
19
19
|
private failedScopesFromLintResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint-service.d.ts","sourceRoot":"","sources":["../../src/service/lint-service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsB,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAEL,YAAY,EACZ,UAAU,EAGV,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,UAAU,WAAW;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,UAAU,SAAS;IACjB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAED,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAEzC,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,UAAU;IAAc,OAAO,CAAC,QAAQ,CAAC,gBAAgB;gBAAzD,UAAU,EAAE,UAAU,EAAmB,gBAAgB,EAAE,gBAAgB;IAE3F,GAAG,CACd,WAAW,EAAE,MAAM,EACnB,EAAE,GAAG,EAAE,EAAE,WAAW,EACpB,SAAS,SAAoB,EAC7B,YAAY,
|
|
1
|
+
{"version":3,"file":"lint-service.d.ts","sourceRoot":"","sources":["../../src/service/lint-service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsB,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAEL,YAAY,EACZ,UAAU,EAGV,UAAU,EACV,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,UAAU,WAAW;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,UAAU,SAAS;IACjB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAED,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAEzC,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,UAAU;IAAc,OAAO,CAAC,QAAQ,CAAC,gBAAgB;gBAAzD,UAAU,EAAE,UAAU,EAAmB,gBAAgB,EAAE,gBAAgB;IAE3F,GAAG,CACd,WAAW,EAAE,MAAM,EACnB,EAAE,GAAG,EAAE,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,EAClB,SAAS,SAAoB,EAC7B,YAAY,okBAAO,GAClB,OAAO,CAAC,SAAS,CAAC;YAYP,GAAG;IASV,YAAY,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,YAAY;IAI5D,OAAO,CAAC,0BAA0B;IAI3B,YAAY,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE;CAOzD"}
|
|
@@ -9,10 +9,10 @@ class LintService {
|
|
|
9
9
|
this.configFile = configFile;
|
|
10
10
|
this.fileSystemReader = fileSystemReader;
|
|
11
11
|
}
|
|
12
|
-
async run(environment, { fix }, directory = exports.DEFAULT_DIRECTORY, lintFunction = lint_1.lint) {
|
|
12
|
+
async run(environment, { fix }, logger, directory = exports.DEFAULT_DIRECTORY, lintFunction = lint_1.lint) {
|
|
13
13
|
const exclude = [...(await cli_shared_1.listGitIgnoreFiles(this.fileSystemReader)), '.git', 'node_modules'];
|
|
14
14
|
const filesToLint = await this.fileSystemReader.recursiveReadDir(directory, exclude);
|
|
15
|
-
const lintResults = await lintFunction(filesToLint, await this.configFile.readConfig(), environment);
|
|
15
|
+
const lintResults = await lintFunction(filesToLint, await this.configFile.readConfig(), environment, logger);
|
|
16
16
|
if (fix) {
|
|
17
17
|
return { lintResults, fixResults: await this.fix(lintResults) };
|
|
18
18
|
}
|
|
@@ -26,7 +26,7 @@ class LintService {
|
|
|
26
26
|
return lint_1.problemCount(lintResults);
|
|
27
27
|
}
|
|
28
28
|
failedScopesFromLintResult({ errors, warnings }) {
|
|
29
|
-
return Array.from(lint_1.
|
|
29
|
+
return Array.from(lint_1.findMissingPermissions(errors, warnings, 'missingPermission'));
|
|
30
30
|
}
|
|
31
31
|
failedScopes(lintResults) {
|
|
32
32
|
return lintResults.reduce((acc, lintResult) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LintResult } from '@forge/lint';
|
|
1
|
+
import { LintLogger, LintResult } from '@forge/lint';
|
|
2
2
|
export declare class LiteLintService {
|
|
3
3
|
private readonly lintService;
|
|
4
4
|
private readonly problemCounter;
|
|
5
|
-
constructor(lintService?: (linter?: import("@forge/lint").LinterInterface | undefined) => Promise<LintResult[]>, problemCounter?: (lintResults: LintResult[]) => import("@forge/lint").ProblemCount);
|
|
6
|
-
run(checkSchema: boolean): Promise<LintResult[]>;
|
|
5
|
+
constructor(lintService?: (logger: Pick<import("@forge/cli-shared/src").Logger, "info">, linter?: import("@forge/lint").LinterInterface | undefined) => Promise<LintResult[]>, problemCounter?: (lintResults: LintResult[]) => import("@forge/lint").ProblemCount);
|
|
6
|
+
run(checkSchema: boolean, logger: LintLogger): Promise<LintResult[]>;
|
|
7
7
|
private filterResults;
|
|
8
8
|
hasErrors(report: LintResult[]): boolean;
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lite-lint-service.d.ts","sourceRoot":"","sources":["../../src/service/lite-lint-service.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"lite-lint-service.d.ts","sourceRoot":"","sources":["../../src/service/lite-lint-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,UAAU,EAAgB,UAAU,EAAE,MAAM,aAAa,CAAC;AAG7E,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,WAAW;IAAa,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAAvD,WAAW,sJAAW,EAAmB,cAAc,oEAAe;IAEtF,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAKjF,OAAO,CAAC,aAAa;IASd,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO;CAGhD"}
|
|
@@ -8,8 +8,8 @@ class LiteLintService {
|
|
|
8
8
|
this.lintService = lintService;
|
|
9
9
|
this.problemCounter = problemCounter;
|
|
10
10
|
}
|
|
11
|
-
async run(checkSchema) {
|
|
12
|
-
const report = await this.lintService();
|
|
11
|
+
async run(checkSchema, logger) {
|
|
12
|
+
const report = await this.lintService(logger);
|
|
13
13
|
return this.filterResults(report, checkSchema);
|
|
14
14
|
}
|
|
15
15
|
filterResults(report, checkSchema) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AppConfigProvider } from 'packages/forge-cli-shared/src/apps';
|
|
2
|
+
export declare type MigrationKeys = {
|
|
3
|
+
jira?: string;
|
|
4
|
+
confluence?: string;
|
|
5
|
+
};
|
|
6
|
+
export interface AppEnvironmentMigrationKeys {
|
|
7
|
+
migrationKeys?: MigrationKeys | null;
|
|
8
|
+
mpacAppKey?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface GetMigrationKeysClient {
|
|
11
|
+
getLatestMigrationKeys(appId: string, environmentKey: string): Promise<AppEnvironmentMigrationKeys>;
|
|
12
|
+
}
|
|
13
|
+
export declare class MigrationKeysService {
|
|
14
|
+
private readonly migrationKeysClient;
|
|
15
|
+
private readonly getAppConfig;
|
|
16
|
+
constructor(migrationKeysClient: GetMigrationKeysClient, getAppConfig: AppConfigProvider);
|
|
17
|
+
getMigrationKeysForAppEnvironment(environmentKey: string): Promise<AppEnvironmentMigrationKeys>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=migration-keys-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-keys-service.d.ts","sourceRoot":"","sources":["../../src/service/migration-keys-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,oBAAY,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AACF,MAAM,WAAW,2BAA2B;IAC1C,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AACD,MAAM,WAAW,sBAAsB;IACrC,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;CACrG;AAED,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,mBAAmB,EAAE,sBAAsB,EAC3C,YAAY,EAAE,iBAAiB;IAGrC,iCAAiC,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAI7G"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MigrationKeysService = void 0;
|
|
4
|
+
class MigrationKeysService {
|
|
5
|
+
constructor(migrationKeysClient, getAppConfig) {
|
|
6
|
+
this.migrationKeysClient = migrationKeysClient;
|
|
7
|
+
this.getAppConfig = getAppConfig;
|
|
8
|
+
}
|
|
9
|
+
async getMigrationKeysForAppEnvironment(environmentKey) {
|
|
10
|
+
const { id: appId } = await this.getAppConfig();
|
|
11
|
+
return await this.migrationKeysClient.getLatestMigrationKeys(appId, environmentKey);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.MigrationKeysService = MigrationKeysService;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConfigFile } from '@forge/cli-shared';
|
|
2
|
+
export interface PortFindingService {
|
|
3
|
+
findPorts(minPort?: number): Promise<Record<string, number>>;
|
|
4
|
+
findPortAfter(portsTaken: number[]): Promise<number | undefined>;
|
|
5
|
+
}
|
|
6
|
+
export declare class ConfigFilePortFindingService implements PortFindingService {
|
|
7
|
+
private readonly configFile;
|
|
8
|
+
constructor(configFile: ConfigFile);
|
|
9
|
+
findPorts(minPort?: number): Promise<Record<string, number>>;
|
|
10
|
+
findPortAfter(portsTaken: number[]): Promise<number | undefined>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=port-finding-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port-finding-service.d.ts","sourceRoot":"","sources":["../../src/service/port-finding-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM/C,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7D,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAClE;AAED,qBAAa,4BAA6B,YAAW,kBAAkB;IACzD,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEtC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAuB5D,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAM9E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigFilePortFindingService = void 0;
|
|
4
|
+
const portfinder_1 = require("portfinder");
|
|
5
|
+
const util_1 = require("util");
|
|
6
|
+
const getPortsPromise = util_1.promisify(portfinder_1.getPorts);
|
|
7
|
+
class ConfigFilePortFindingService {
|
|
8
|
+
constructor(configFile) {
|
|
9
|
+
this.configFile = configFile;
|
|
10
|
+
}
|
|
11
|
+
async findPorts(minPort) {
|
|
12
|
+
const resources = await this.configFile.getResources();
|
|
13
|
+
const resourceKeys = resources.map((resource) => resource.key);
|
|
14
|
+
if (!resourceKeys.length)
|
|
15
|
+
return {};
|
|
16
|
+
const portOptions = {};
|
|
17
|
+
if (minPort) {
|
|
18
|
+
portOptions['port'] = minPort + 1;
|
|
19
|
+
}
|
|
20
|
+
const ports = await getPortsPromise(resourceKeys.length, portOptions);
|
|
21
|
+
const portMap = {};
|
|
22
|
+
resourceKeys.forEach((resourceKey, idx) => {
|
|
23
|
+
portMap[resourceKey] = ports[idx];
|
|
24
|
+
});
|
|
25
|
+
return portMap;
|
|
26
|
+
}
|
|
27
|
+
async findPortAfter(portsTaken) {
|
|
28
|
+
if (!portsTaken.length)
|
|
29
|
+
return undefined;
|
|
30
|
+
const max = Math.max(...portsTaken);
|
|
31
|
+
return (await getPortsPromise(1, { port: max + 1 }))[0];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ConfigFilePortFindingService = ConfigFilePortFindingService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Modules } from '@forge/manifest';
|
|
2
|
-
import { FileSystemReader, ResourceDetails } from '@forge/cli-shared';
|
|
2
|
+
import { FileSystemReader, ResourceDetails, BridgeScriptService, IframeResizerScriptService } from '@forge/cli-shared';
|
|
3
3
|
import { Archiver } from '../deploy';
|
|
4
4
|
export declare class ResourceDirectoryMissingError extends Error {
|
|
5
5
|
constructor(key: string, dir: string);
|
|
@@ -32,11 +32,11 @@ export declare class ResourcePackagingService {
|
|
|
32
32
|
private readonly archiverFactory;
|
|
33
33
|
private readonly fileSystemReader;
|
|
34
34
|
private readonly appDir;
|
|
35
|
-
|
|
35
|
+
private readonly bridgeScriptService;
|
|
36
|
+
private readonly iframeResizerScriptService;
|
|
37
|
+
constructor(archiverFactory: () => Archiver, fileSystemReader: FileSystemReader, appDir: string, bridgeScriptService: BridgeScriptService, iframeResizerScriptService: IframeResizerScriptService);
|
|
36
38
|
private getResourcesInformation;
|
|
37
39
|
private transformRelativeResourcePathsToAbsolute;
|
|
38
|
-
private createBridgeCoreScriptTag;
|
|
39
|
-
private injectBridgeCore;
|
|
40
40
|
private processFile;
|
|
41
41
|
private validateResourceContents;
|
|
42
42
|
private assertDirectoryIncludesEntrypoint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-packaging-service.d.ts","sourceRoot":"","sources":["../../src/service/resource-packaging-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"resource-packaging-service.d.ts","sourceRoot":"","sources":["../../src/service/resource-packaging-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAChB,eAAe,EAGf,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAKrC,qBAAa,6BAA8B,SAAQ,KAAK;gBAC1C,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAGrC;AAED,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAGrC;AAeD,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,qBAAa,4BAA6B,SAAQ,KAAK;;CAItD;AAED,qBAAa,0BAA2B,SAAQ,KAAK;;CAIpD;AAED,qBAAa,kCAAmC,SAAQ,KAAK;gBAC/C,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAGnD;AAED,qBAAa,oCAAqC,SAAQ,KAAK;gBACjD,WAAW,EAAE,MAAM;CAGhC;AAED,qBAAa,wBAAwB;IAEjC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,0BAA0B;gBAJ1B,eAAe,EAAE,MAAM,QAAQ,EAC/B,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,mBAAmB,EACxC,0BAA0B,EAAE,0BAA0B;YAG3D,uBAAuB;IAerC,OAAO,CAAC,wCAAwC;IAIhD,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,iCAAiC;YAM3B,qBAAqB;IAatB,YAAY,CAAC,SAAS,EAAE,eAAe,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAiCtG"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ResourcePackagingService = exports.DetailedMalformedHtmlEntrypointError = exports.DetailedMissingHtmlEntrypointError = exports.MissingHtmlEntrypointError = exports.MalformedHtmlEntrypointError = exports.ResourceDirectoryEmptyError = exports.ResourceDirectoryMissingError = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
6
5
|
const path_1 = require("path");
|
|
7
6
|
const hidefile_1 = require("hidefile");
|
|
8
|
-
const cheerio_1 = tslib_1.__importDefault(require("cheerio"));
|
|
9
7
|
const CUSTOM_UI_ENTRYPOINT = 'index.html';
|
|
10
|
-
const BRIDGE_CORE_CDN_PATH = 'global-bridge.js';
|
|
11
|
-
const GLOBAL_FORGE_INSTALL_ID = 'forge';
|
|
12
8
|
class ResourceDirectoryMissingError extends Error {
|
|
13
9
|
constructor(key, dir) {
|
|
14
10
|
super(cli_shared_1.Text.error.resourceDirectoryMissing(key, dir));
|
|
@@ -46,10 +42,12 @@ class DetailedMalformedHtmlEntrypointError extends Error {
|
|
|
46
42
|
}
|
|
47
43
|
exports.DetailedMalformedHtmlEntrypointError = DetailedMalformedHtmlEntrypointError;
|
|
48
44
|
class ResourcePackagingService {
|
|
49
|
-
constructor(archiverFactory, fileSystemReader, appDir) {
|
|
45
|
+
constructor(archiverFactory, fileSystemReader, appDir, bridgeScriptService, iframeResizerScriptService) {
|
|
50
46
|
this.archiverFactory = archiverFactory;
|
|
51
47
|
this.fileSystemReader = fileSystemReader;
|
|
52
48
|
this.appDir = appDir;
|
|
49
|
+
this.bridgeScriptService = bridgeScriptService;
|
|
50
|
+
this.iframeResizerScriptService = iframeResizerScriptService;
|
|
53
51
|
}
|
|
54
52
|
async getResourcesInformation(resources) {
|
|
55
53
|
return await Promise.all(resources.map(async ({ key, directory, resourceType }) => {
|
|
@@ -66,25 +64,14 @@ class ResourcePackagingService {
|
|
|
66
64
|
transformRelativeResourcePathsToAbsolute(appDir, resources) {
|
|
67
65
|
return resources.map(({ key, path, resourceType }) => ({ key, directory: path_1.join(appDir, path), resourceType }));
|
|
68
66
|
}
|
|
69
|
-
createBridgeCoreScriptTag() {
|
|
70
|
-
const env = cli_shared_1.getEnvironment(cli_shared_1.CDNEnvironments);
|
|
71
|
-
return `<script src="https://${GLOBAL_FORGE_INSTALL_ID}.cdn.${env}.atlassian-dev.net/${BRIDGE_CORE_CDN_PATH}"></script>`;
|
|
72
|
-
}
|
|
73
|
-
injectBridgeCore(content) {
|
|
74
|
-
const $ = cheerio_1.default.load(content);
|
|
75
|
-
if ($('html').length === 0)
|
|
76
|
-
throw new MalformedHtmlEntrypointError();
|
|
77
|
-
let head = $('head');
|
|
78
|
-
if (head.length === 0) {
|
|
79
|
-
$('html').prepend('<head></head>');
|
|
80
|
-
head = $('head');
|
|
81
|
-
}
|
|
82
|
-
head.prepend(this.createBridgeCoreScriptTag());
|
|
83
|
-
return Buffer.from($.html());
|
|
84
|
-
}
|
|
85
67
|
processFile(filePath, content) {
|
|
86
68
|
if (filePath === CUSTOM_UI_ENTRYPOINT) {
|
|
87
|
-
|
|
69
|
+
const contentWithIframeResizerScript = this.iframeResizerScriptService.injectIframeResizer(content, () => {
|
|
70
|
+
throw new MalformedHtmlEntrypointError();
|
|
71
|
+
});
|
|
72
|
+
return this.bridgeScriptService.injectBridgeCore(contentWithIframeResizerScript, () => {
|
|
73
|
+
throw new MalformedHtmlEntrypointError();
|
|
74
|
+
});
|
|
88
75
|
}
|
|
89
76
|
return content;
|
|
90
77
|
}
|