@forge/cli 4.5.2 → 5.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/npm-shrinkwrap.json +295 -18
- package/out/command-line/command.d.ts.map +1 -1
- package/out/command-line/command.js +5 -4
- package/out/command-line/controller/feedback-controller.d.ts.map +1 -1
- package/out/command-line/controller/feedback-controller.js +2 -2
- package/out/command-line/controller/install-controller.d.ts.map +1 -1
- package/out/command-line/controller/install-controller.js +8 -5
- package/out/command-line/controller/tunnel-controller.js +1 -1
- package/out/command-line/dependency-injection.d.ts +1 -0
- package/out/command-line/dependency-injection.d.ts.map +1 -1
- package/out/command-line/dependency-injection.js +11 -7
- package/out/command-line/register-authentication-command.d.ts.map +1 -1
- package/out/command-line/register-authentication-command.js +8 -6
- package/out/installations/graphql-client.d.ts +13 -12
- package/out/installations/graphql-client.d.ts.map +1 -1
- package/out/installations/graphql-client.js +48 -88
- 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 +112 -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/service/tunnel-service.d.ts +4 -12
- package/out/service/tunnel-service.d.ts.map +1 -1
- package/package.json +5 -8
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudIdTranslator = exports.InvalidAtlassianSiteError = void 0;
|
|
4
|
+
const cs_ari_1 = require("@forge/util/packages/cs-ari");
|
|
5
|
+
const cli_shared_1 = require("@forge/cli-shared");
|
|
6
|
+
class InvalidAtlassianSiteError extends Error {
|
|
7
|
+
constructor(url) {
|
|
8
|
+
super(cli_shared_1.Text.install.error.invalidAtlassianSite(url));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.InvalidAtlassianSiteError = InvalidAtlassianSiteError;
|
|
12
|
+
const RESOURCE_TYPE = 'site';
|
|
13
|
+
const tenantContextsToCloudId = (url, contexts) => {
|
|
14
|
+
if (!contexts.length) {
|
|
15
|
+
throw new InvalidAtlassianSiteError(url);
|
|
16
|
+
}
|
|
17
|
+
const context = contexts[0];
|
|
18
|
+
if (!context || !context.cloudId) {
|
|
19
|
+
throw new InvalidAtlassianSiteError(url);
|
|
20
|
+
}
|
|
21
|
+
return context.cloudId;
|
|
22
|
+
};
|
|
23
|
+
const tenantToHostname = (tenantInfo) => {
|
|
24
|
+
if (!tenantInfo) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return tenantInfo.hostName || null;
|
|
28
|
+
};
|
|
29
|
+
class CloudIdTranslator {
|
|
30
|
+
constructor(graphqlClient) {
|
|
31
|
+
this.graphqlClient = graphqlClient;
|
|
32
|
+
}
|
|
33
|
+
ariBelongsToProduct(ari) {
|
|
34
|
+
return ari.resourceType === RESOURCE_TYPE;
|
|
35
|
+
}
|
|
36
|
+
async buildInstallationContext(product, site) {
|
|
37
|
+
const cloudId = await this.getCloudId(site);
|
|
38
|
+
const ari = new cs_ari_1.ResourceIdentifier({
|
|
39
|
+
resourceOwner: product.toLowerCase(),
|
|
40
|
+
resourceType: RESOURCE_TYPE,
|
|
41
|
+
resourceId: cloudId
|
|
42
|
+
});
|
|
43
|
+
return ari;
|
|
44
|
+
}
|
|
45
|
+
async getSitesForResourceAris(aris) {
|
|
46
|
+
const MAX_CLOUD_IDS_AT_ONCE = 20;
|
|
47
|
+
const cloudIds = [...new Set(aris.map((ari) => ari.resourceId))];
|
|
48
|
+
const cloudIdsChunks = [];
|
|
49
|
+
for (let i = 0; i < cloudIds.length; i += MAX_CLOUD_IDS_AT_ONCE) {
|
|
50
|
+
cloudIdsChunks.push(cloudIds.slice(i, i + MAX_CLOUD_IDS_AT_ONCE));
|
|
51
|
+
}
|
|
52
|
+
const query = `
|
|
53
|
+
query forge_cli_getHostnameForTenantContexts($cloudIds: [ID!]!) {
|
|
54
|
+
tenantContexts(cloudIds: $cloudIds) {
|
|
55
|
+
hostName
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
const results = await Promise.all(cloudIdsChunks.map((cloudIdsChunk) => this.graphqlClient.query(query, {
|
|
60
|
+
cloudIds: cloudIdsChunk
|
|
61
|
+
})));
|
|
62
|
+
const tenantContexts = [].concat(...results.map((result) => result.tenantContexts || []));
|
|
63
|
+
const cloudIdToHostname = {};
|
|
64
|
+
const ariToHostname = {};
|
|
65
|
+
cloudIds.forEach((cloudId, index) => {
|
|
66
|
+
const maybeHostname = tenantToHostname(tenantContexts[index]);
|
|
67
|
+
cloudIdToHostname[cloudId] = maybeHostname || cloudId;
|
|
68
|
+
});
|
|
69
|
+
aris.forEach((ari) => {
|
|
70
|
+
ariToHostname[ari.toString()] = cloudIdToHostname[ari.resourceId];
|
|
71
|
+
});
|
|
72
|
+
return ariToHostname;
|
|
73
|
+
}
|
|
74
|
+
async getCloudId(site) {
|
|
75
|
+
const query = `
|
|
76
|
+
query forge_cli_getCloudIfForTenantContexts($hostNames: [String!]) {
|
|
77
|
+
tenantContexts(hostNames: $hostNames) {
|
|
78
|
+
cloudId
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
const result = await this.graphqlClient.query(query, {
|
|
83
|
+
hostNames: [site.hostname]
|
|
84
|
+
});
|
|
85
|
+
const tenantContexts = result.tenantContexts || [];
|
|
86
|
+
return tenantContextsToCloudId(site, tenantContexts);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.CloudIdTranslator = CloudIdTranslator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/installations/site-translation/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./bitbucket"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./cloudid-products"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./site-translation"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { URL } from 'url';
|
|
3
|
+
import { Ari } from '@forge/util/packages/cs-ari';
|
|
4
|
+
export interface SiteTranslator {
|
|
5
|
+
buildInstallationContext: (product: string, site: URL) => Promise<Ari>;
|
|
6
|
+
getSitesForResourceAris: (ari: ResourcefulAri[]) => Promise<Record<string, string>>;
|
|
7
|
+
ariBelongsToProduct: (ari: ResourcefulAri) => boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ResourcefulAri extends Ari {
|
|
10
|
+
resourceId: string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=site-translation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-translation.d.ts","sourceRoot":"","sources":["../../../src/installations/site-translation/site-translation.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,wBAAwB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAEvE,uBAAuB,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpF,mBAAmB,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC;CACvD;AAED,MAAM,WAAW,cAAe,SAAQ,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HiddenError, PersonalApiCredentialsValidated } from '@forge/cli-shared';
|
|
1
|
+
import { HiddenError, PersonalApiCredentials, PersonalApiCredentialsValidated } from '@forge/cli-shared';
|
|
2
2
|
import { spawn } from 'cross-spawn';
|
|
3
3
|
import { DockerService } from './docker-service';
|
|
4
4
|
import { ConfigFilePortFindingService } from './port-finding-service';
|
|
@@ -14,7 +14,7 @@ export declare abstract class TunnelService {
|
|
|
14
14
|
protected readonly configFilePortFindingService: ConfigFilePortFindingService;
|
|
15
15
|
constructor(configFilePortFindingService: ConfigFilePortFindingService);
|
|
16
16
|
abstract run(tunnelOptions: TunnelOptions, creds: PersonalApiCredentialsValidated, debugEnabled: boolean, onError?: (err: Error) => void): Promise<void>;
|
|
17
|
-
protected getDockerOptions(tunnelOptions: TunnelOptions, debugEnabled: boolean, { email, token }:
|
|
17
|
+
protected getDockerOptions(tunnelOptions: TunnelOptions, debugEnabled: boolean, { email, token }: PersonalApiCredentials): Promise<string[]>;
|
|
18
18
|
protected getPortOptions(port: number, resourcePorts: Record<string, number>, cspReporterPort: number | undefined): string[];
|
|
19
19
|
protected getResourcePortEnvVarOption(resourcePorts: Record<string, number>): string[];
|
|
20
20
|
protected getUserEnvironmentVariablesOptions(): string[];
|
|
@@ -28,21 +28,13 @@ export declare abstract class TunnelService {
|
|
|
28
28
|
protected getVolumeOptions(): string[];
|
|
29
29
|
}
|
|
30
30
|
export declare class LocalTunnelService extends TunnelService {
|
|
31
|
-
run(tunnelOptions: TunnelOptions, creds:
|
|
32
|
-
email: string;
|
|
33
|
-
token: string;
|
|
34
|
-
accountId: string;
|
|
35
|
-
}, debugEnabled: boolean, onError: (err: Error) => void): Promise<void>;
|
|
31
|
+
run(tunnelOptions: TunnelOptions, creds: PersonalApiCredentials, debugEnabled: boolean, onError: (err: Error) => void): Promise<void>;
|
|
36
32
|
}
|
|
37
33
|
export declare class DockerTunnelService extends TunnelService {
|
|
38
34
|
private readonly dockerService;
|
|
39
35
|
private readonly analyticsService;
|
|
40
36
|
constructor(configFilePortFindingService: ConfigFilePortFindingService, dockerService: DockerService, analyticsService: TunnelAnalyticsService);
|
|
41
|
-
run(tunnelOptions: TunnelOptions, creds:
|
|
42
|
-
email: string;
|
|
43
|
-
token: string;
|
|
44
|
-
accountId: string;
|
|
45
|
-
}, debugEnabled: boolean): Promise<void>;
|
|
37
|
+
run(tunnelOptions: TunnelOptions, creds: PersonalApiCredentialsValidated, debugEnabled: boolean): Promise<void>;
|
|
46
38
|
bootstrapDocker(): Promise<ReturnType<typeof spawn>>;
|
|
47
39
|
private validateDockerVersion;
|
|
48
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel-service.d.ts","sourceRoot":"","sources":["../../src/service/tunnel-service.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"tunnel-service.d.ts","sourceRoot":"","sources":["../../src/service/tunnel-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,sBAAsB,EACtB,+BAA+B,EAChC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAOpC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,MAAM,WAAW,aAAa;IAC5B,K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IAAI,MAAM,EAAE;CAavC;AAED,qBAAa,kBAAmB,SAAQ,aAAa;IACtC,GAAG,CACd,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,sBAAsB,EAC7B,YAAY,EAAE,OAAO,EACrB,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,GAC5B,OAAO,CAAC,IAAI,CAAC;CA0BjB;AAED,qBAAa,mBAAoB,SAAQ,aAAa;IAGlD,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;gBAFjC,4BAA4B,EAAE,4BAA4B,EACzC,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,sBAAsB;IAK9C,GAAG,CACd,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,+BAA+B,EACtC,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,IAAI,CAAC;IA2BH,eAAe,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;YAKnD,qBAAqB;CASpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-next.1",
|
|
4
4
|
"description": "A command line interface for managing Atlassian-hosted apps",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"postinstall": "node -e \"process.exitCode = fs.existsSync('./out/bin/postinstall.js')\" || node ./out/bin/postinstall.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@forge/bundler": "3.0.
|
|
22
|
-
"@forge/cli-shared": "
|
|
21
|
+
"@forge/bundler": "3.0.12-next.1",
|
|
22
|
+
"@forge/cli-shared": "3.0.0-next.1",
|
|
23
23
|
"@forge/csp": "^1.11.0",
|
|
24
|
-
"@forge/lint": "3.2.
|
|
25
|
-
"@forge/manifest": "4.0.0",
|
|
24
|
+
"@forge/lint": "3.2.3-next.1",
|
|
25
|
+
"@forge/manifest": "4.1.0-next.0",
|
|
26
26
|
"@forge/util": "1.2.0",
|
|
27
27
|
"ajv": "^6.12.5",
|
|
28
28
|
"archiver": "^5.2.0",
|
|
@@ -75,9 +75,6 @@
|
|
|
75
75
|
"jest-fixtures": "^0.6.0",
|
|
76
76
|
"memfs": "^3.4.1"
|
|
77
77
|
},
|
|
78
|
-
"optionalDependencies": {
|
|
79
|
-
"keytar": "^7.0.0"
|
|
80
|
-
},
|
|
81
78
|
"engines": {
|
|
82
79
|
"node": ">=12.13.1"
|
|
83
80
|
}
|