@forge/cli 6.17.0-next.29 → 6.17.1-next.8
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 +212 -0
- package/npm-shrinkwrap.json +281 -227
- package/out/service/tunnel-service.d.ts +15 -12
- package/out/service/tunnel-service.d.ts.map +1 -1
- package/out/service/tunnel-service.js +88 -99
- package/package.json +13 -13
|
@@ -30,25 +30,23 @@ export declare class InProcessTunnelService implements TunnelService {
|
|
|
30
30
|
constructor(ui: UI, startTunnelCommand: StartTunnelCommand, tunnelInteractor: TunnelInteractor, configFilePortFindingService: ConfigFilePortFindingService, analyticsService: TunnelAnalyticsService);
|
|
31
31
|
run(tunnelOptions: TunnelOptions, creds: PersonalApiCredentialsValidated, debugEnabled: boolean, onError?: (err: Error) => Promise<void>): Promise<void>;
|
|
32
32
|
}
|
|
33
|
+
interface EnvironmentVariable {
|
|
34
|
+
key: string;
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
33
37
|
declare abstract class TunnelServiceBase implements TunnelService {
|
|
34
38
|
protected readonly configFilePortFindingService: ConfigFilePortFindingService;
|
|
35
39
|
constructor(configFilePortFindingService: ConfigFilePortFindingService);
|
|
36
40
|
abstract run(tunnelOptions: TunnelOptions, creds: PersonalApiCredentialsValidated, debugEnabled: boolean, onError?: (err: Error) => Promise<void>): Promise<void>;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
[key: string]: string;
|
|
43
|
-
}): Record<string, string>;
|
|
44
|
-
protected transformDockerOptionsToEnvVars(options: string[]): {
|
|
45
|
-
[key: string]: string;
|
|
46
|
-
};
|
|
47
|
-
protected getInteractiveOptions(): string[];
|
|
48
|
-
protected getVolumeOptions(): string[];
|
|
41
|
+
getTunnelProcessEnvironment(tunnelOptions: TunnelOptions, debugEnabled: boolean, { email, token }: PersonalApiCredentials, port: number, cspReporterPort: number | undefined, resourcePorts: Record<string, number>): Promise<EnvironmentVariable[]>;
|
|
42
|
+
private getInspectorPortEnvironment;
|
|
43
|
+
private getCspReporterPortEnvironment;
|
|
44
|
+
private getResourcePortEnvironment;
|
|
45
|
+
private getUserEnvironmentVariables;
|
|
49
46
|
}
|
|
50
47
|
export declare class LocalTunnelService extends TunnelServiceBase {
|
|
51
48
|
run(tunnelOptions: TunnelOptions, creds: PersonalApiCredentialsValidated, debugEnabled: boolean, onError?: (err: Error) => Promise<void>): Promise<void>;
|
|
49
|
+
private formatEnvForLocalTunnel;
|
|
52
50
|
}
|
|
53
51
|
export declare class DockerTunnelService extends TunnelServiceBase {
|
|
54
52
|
private readonly dockerService;
|
|
@@ -57,6 +55,11 @@ export declare class DockerTunnelService extends TunnelServiceBase {
|
|
|
57
55
|
run(tunnelOptions: TunnelOptions, creds: PersonalApiCredentialsValidated, debugEnabled: boolean): Promise<void>;
|
|
58
56
|
bootstrapDocker(): Promise<ReturnType<typeof spawn>>;
|
|
59
57
|
private validateDockerVersion;
|
|
58
|
+
private getDockerPortOptions;
|
|
59
|
+
private formatEnvForDocker;
|
|
60
|
+
private getInteractiveOptions;
|
|
61
|
+
private getVolumeOptions;
|
|
62
|
+
private getDockerOptions;
|
|
60
63
|
}
|
|
61
64
|
export {};
|
|
62
65
|
//# sourceMappingURL=tunnel-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel-service.d.ts","sourceRoot":"","sources":["../../src/service/tunnel-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMpC,OAAO,EAIL,WAAW,EAEX,sBAAsB,EACtB,+BAA+B,EAG/B,EAAE,EACF,SAAS,EACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,4BAA4B,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ortFindingService) {
|
|
82
82
|
this.configFilePortFindingService = configFilePortFindingService;
|
|
83
83
|
}
|
|
84
|
-
async
|
|
84
|
+
async getTunnelProcessEnvironment(tunnelOptions, debugEnabled, { email, token }, port, cspReporterPort, resourcePorts) {
|
|
85
|
+
var _a;
|
|
85
86
|
try {
|
|
86
87
|
const graphqlGateway = (0, cli_shared_1.getGraphqlGateway)();
|
|
87
88
|
return [
|
|
88
|
-
'
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
'
|
|
92
|
-
'
|
|
93
|
-
|
|
94
|
-
`
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
`ENVIRONMENT_KEY=${tunnelOptions.environment || 'default'}`,
|
|
101
|
-
`--env`,
|
|
102
|
-
`TUNNEL_INSPECTOR_ENABLED=${!!tunnelOptions.debug}`,
|
|
103
|
-
`--env`,
|
|
104
|
-
`FORGE_GRAPHQL_GATEWAY=${graphqlGateway}`,
|
|
105
|
-
`--env`,
|
|
106
|
-
`VERBOSE_MODE=${debugEnabled}`,
|
|
107
|
-
`--env`,
|
|
108
|
-
`CLI_DETAILS=${JSON.stringify(cliDetails)}`,
|
|
109
|
-
`${exports.IMAGE_NAME}`
|
|
89
|
+
{ key: 'APP_FOLDER', value: '/app' },
|
|
90
|
+
{ key: 'FORGE_EMAIL', value: email },
|
|
91
|
+
{ key: 'FORGE_API_TOKEN', value: token },
|
|
92
|
+
{ key: 'ENVIRONMENT_KEY', value: (_a = tunnelOptions.environment) !== null && _a !== void 0 ? _a : 'default' },
|
|
93
|
+
{ key: 'TUNNEL_INSPECTOR_ENABLED', value: (!!tunnelOptions.debug).toString() },
|
|
94
|
+
{ key: 'FORGE_GRAPHQL_GATEWAY', value: graphqlGateway },
|
|
95
|
+
{ key: 'VERBOSE_MODE', value: `${debugEnabled}` },
|
|
96
|
+
{ key: 'CLI_DETAILS', value: JSON.stringify(cliDetails) },
|
|
97
|
+
...this.getInspectorPortEnvironment(port),
|
|
98
|
+
...this.getCspReporterPortEnvironment(cspReporterPort),
|
|
99
|
+
...this.getResourcePortEnvironment(resourcePorts),
|
|
100
|
+
...this.getUserEnvironmentVariables()
|
|
110
101
|
];
|
|
111
102
|
}
|
|
112
103
|
catch (e) {
|
|
113
104
|
throw new HiddenDockerTunnelError(false, "Couldn't populate docker options for tunneling");
|
|
114
105
|
}
|
|
115
106
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const addHostOption = os_1.default.platform() === 'linux' ? ['--add-host', 'host.docker.internal:host-gateway'] : [];
|
|
125
|
-
return [
|
|
126
|
-
`-p`,
|
|
127
|
-
`${port}:${port}`,
|
|
128
|
-
...resourcePortOptions,
|
|
129
|
-
...addHostOption,
|
|
130
|
-
...cspReporterPortOption,
|
|
131
|
-
`--env`,
|
|
132
|
-
`TUNNEL_INSPECTOR_PORT=${port}`
|
|
133
|
-
];
|
|
107
|
+
getInspectorPortEnvironment(port) {
|
|
108
|
+
return [{ key: 'TUNNEL_INSPECTOR_PORT', value: port.toString() }];
|
|
109
|
+
}
|
|
110
|
+
getCspReporterPortEnvironment(cspReporterPort) {
|
|
111
|
+
if (cspReporterPort) {
|
|
112
|
+
return [{ key: 'CSP_REPORTER_PORT', value: cspReporterPort.toString() }];
|
|
113
|
+
}
|
|
114
|
+
return [];
|
|
134
115
|
}
|
|
135
|
-
|
|
136
|
-
return [
|
|
116
|
+
getResourcePortEnvironment(resourcePorts) {
|
|
117
|
+
return [{ key: `RESOURCE_PORT_MAP`, value: JSON.stringify(resourcePorts) }];
|
|
137
118
|
}
|
|
138
|
-
|
|
139
|
-
const
|
|
119
|
+
getUserEnvironmentVariables() {
|
|
120
|
+
const vars = [];
|
|
140
121
|
Object.keys(process.env)
|
|
141
122
|
.filter((variable) => variable.startsWith('FORGE_USER_VAR_'))
|
|
142
123
|
.forEach((name) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return options;
|
|
146
|
-
}
|
|
147
|
-
addEnvVarsForLocalTunnel(env) {
|
|
148
|
-
return Object.assign(Object.assign({}, env), { PATH: process.env.PATH || '', FORCE_COLOR: '1' });
|
|
149
|
-
}
|
|
150
|
-
transformDockerOptionsToEnvVars(options) {
|
|
151
|
-
const envVarRegex = new RegExp('^(\\w+)=(.+)$', 'g');
|
|
152
|
-
const envVars = options.filter((opt) => envVarRegex.test(opt));
|
|
153
|
-
const envVarObj = {};
|
|
154
|
-
envVars.forEach((envVar) => {
|
|
155
|
-
envVarRegex.lastIndex = 0;
|
|
156
|
-
const [, key, val] = envVarRegex.exec(envVar);
|
|
157
|
-
envVarObj[key] = val;
|
|
124
|
+
var _a;
|
|
125
|
+
vars.push({ key: name, value: (_a = process.env[name]) !== null && _a !== void 0 ? _a : 'undefined' });
|
|
158
126
|
});
|
|
159
|
-
return
|
|
160
|
-
}
|
|
161
|
-
getInteractiveOptions() {
|
|
162
|
-
if (DISABLE_TTY) {
|
|
163
|
-
return [`-i`];
|
|
164
|
-
}
|
|
165
|
-
return [`-it`];
|
|
166
|
-
}
|
|
167
|
-
getVolumeOptions() {
|
|
168
|
-
const options = [`-v=${process.cwd()}:/app:cached`];
|
|
169
|
-
if (process.env.FORGE_DEV_DOCKER_TUNNEL) {
|
|
170
|
-
const monorepoRoot = (0, path_1.join)(__dirname, '../../../..');
|
|
171
|
-
options.push(`-v=${monorepoRoot}:/monorepo:cached`);
|
|
172
|
-
options.push(`-v=${monorepoRoot}/node_modules/ngrok/docker-bin:/monorepo/node_modules/ngrok/bin`);
|
|
173
|
-
}
|
|
174
|
-
if (process.env.FORGE_TUNNEL_MOUNT_DIRECTORIES) {
|
|
175
|
-
const mounts = process.env.FORGE_TUNNEL_MOUNT_DIRECTORIES.split(',');
|
|
176
|
-
mounts.forEach((mount) => {
|
|
177
|
-
options.push(`-v=${mount}:cached`);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
return options;
|
|
127
|
+
return vars;
|
|
181
128
|
}
|
|
182
129
|
}
|
|
183
130
|
class LocalTunnelService extends TunnelServiceBase {
|
|
184
131
|
async run(tunnelOptions, creds, debugEnabled, onError) {
|
|
185
|
-
const dockerOptions = await this.getDockerOptions(tunnelOptions, debugEnabled, creds);
|
|
186
132
|
const port = await (0, portfinder_1.getPortPromise)();
|
|
187
133
|
const resourcePorts = await this.configFilePortFindingService.findPorts();
|
|
188
134
|
const cspReporterPort = await this.configFilePortFindingService.findPortAfter(Object.values(resourcePorts));
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const resourcePortEnvVarOption = this.getResourcePortEnvVarOption(resourcePorts);
|
|
192
|
-
const env = this.addEnvVarsForLocalTunnel(this.transformDockerOptionsToEnvVars([
|
|
193
|
-
...dockerOptions,
|
|
194
|
-
...portOptions,
|
|
195
|
-
...envVariablesOptions,
|
|
196
|
-
...resourcePortEnvVarOption
|
|
197
|
-
]));
|
|
135
|
+
const environment = await this.getTunnelProcessEnvironment(tunnelOptions, debugEnabled, creds, port, cspReporterPort, resourcePorts);
|
|
136
|
+
const env = this.formatEnvForLocalTunnel(environment);
|
|
198
137
|
const process = (0, cross_spawn_1.spawn)('forge-tunnel', [], {
|
|
199
138
|
stdio: 'inherit',
|
|
200
139
|
env: Object.assign(Object.assign({}, env), { FORGE_DEV_TUNNEL: 'true' })
|
|
@@ -203,6 +142,12 @@ class LocalTunnelService extends TunnelServiceBase {
|
|
|
203
142
|
process.on('error', onError);
|
|
204
143
|
}
|
|
205
144
|
}
|
|
145
|
+
formatEnvForLocalTunnel(environment) {
|
|
146
|
+
return Object.assign({}, {
|
|
147
|
+
PATH: process.env.PATH || '',
|
|
148
|
+
FORCE_COLOR: '1'
|
|
149
|
+
}, ...environment.map(({ key, value }) => ({ [key]: value })));
|
|
150
|
+
}
|
|
206
151
|
}
|
|
207
152
|
exports.LocalTunnelService = LocalTunnelService;
|
|
208
153
|
class DockerTunnelService extends TunnelServiceBase {
|
|
@@ -214,22 +159,22 @@ class DockerTunnelService extends TunnelServiceBase {
|
|
|
214
159
|
async run(tunnelOptions, creds, debugEnabled) {
|
|
215
160
|
var _a;
|
|
216
161
|
await this.validateDockerVersion(creds, debugEnabled);
|
|
217
|
-
const dockerOptions = await this.getDockerOptions(
|
|
162
|
+
const dockerOptions = await this.getDockerOptions();
|
|
218
163
|
const port = await (0, portfinder_1.getPortPromise)();
|
|
219
164
|
const resourcePorts = await this.configFilePortFindingService.findPorts(port);
|
|
220
165
|
const cspReporterPort = await this.configFilePortFindingService.findPortAfter(Object.values(resourcePorts));
|
|
221
|
-
const
|
|
166
|
+
const environment = await this.getTunnelProcessEnvironment(tunnelOptions, debugEnabled, creds, port, cspReporterPort, resourcePorts);
|
|
167
|
+
const portOptions = this.getDockerPortOptions(port, resourcePorts, cspReporterPort);
|
|
222
168
|
const interactiveOptions = this.getInteractiveOptions();
|
|
223
169
|
const volumeOptions = this.getVolumeOptions();
|
|
224
|
-
const
|
|
225
|
-
const resourcePortEnvVarOption = this.getResourcePortEnvVarOption(resourcePorts);
|
|
170
|
+
const env = this.formatEnvForDocker(environment);
|
|
226
171
|
const docker = this.dockerService.runContainer([
|
|
227
172
|
...interactiveOptions,
|
|
228
173
|
...volumeOptions,
|
|
229
174
|
...portOptions,
|
|
230
|
-
...
|
|
231
|
-
...
|
|
232
|
-
|
|
175
|
+
...dockerOptions,
|
|
176
|
+
...env,
|
|
177
|
+
exports.IMAGE_NAME
|
|
233
178
|
]);
|
|
234
179
|
docker.on('exit', () => this.analyticsService.reportTunnelClosed(creds));
|
|
235
180
|
(_a = docker.stderr) === null || _a === void 0 ? void 0 : _a.on('data', (error) => {
|
|
@@ -262,5 +207,49 @@ class DockerTunnelService extends TunnelServiceBase {
|
|
|
262
207
|
throw new HiddenDockerTunnelError(true);
|
|
263
208
|
}
|
|
264
209
|
}
|
|
210
|
+
getDockerPortOptions(port, resourcePorts, cspReporterPort) {
|
|
211
|
+
const resourcePortOptions = (0, cli_shared_1.flatMap)(Object.values(resourcePorts), (resourcePort) => [
|
|
212
|
+
'-p',
|
|
213
|
+
`${resourcePort}:${resourcePort}`
|
|
214
|
+
]);
|
|
215
|
+
const cspReporterPortOption = [];
|
|
216
|
+
if (cspReporterPort) {
|
|
217
|
+
cspReporterPortOption.push('-p', `${cspReporterPort}:${cspReporterPort}`);
|
|
218
|
+
}
|
|
219
|
+
const addHostOption = os_1.default.platform() === 'linux' ? ['--add-host', 'host.docker.internal:host-gateway'] : [];
|
|
220
|
+
return [`-p`, `${port}:${port}`, ...resourcePortOptions, ...addHostOption, ...cspReporterPortOption];
|
|
221
|
+
}
|
|
222
|
+
formatEnvForDocker(environment) {
|
|
223
|
+
return (0, cli_shared_1.flatMap)(environment, ({ key, value }) => ['--env', `${key}=${value}`]);
|
|
224
|
+
}
|
|
225
|
+
getInteractiveOptions() {
|
|
226
|
+
if (DISABLE_TTY) {
|
|
227
|
+
return [`-i`];
|
|
228
|
+
}
|
|
229
|
+
return [`-it`];
|
|
230
|
+
}
|
|
231
|
+
getVolumeOptions() {
|
|
232
|
+
const options = [`-v=${process.cwd()}:/app:cached`];
|
|
233
|
+
if (process.env.FORGE_DEV_DOCKER_TUNNEL) {
|
|
234
|
+
const monorepoRoot = (0, path_1.join)(__dirname, '../../../..');
|
|
235
|
+
options.push(`-v=${monorepoRoot}:/monorepo:cached`);
|
|
236
|
+
options.push(`-v=${monorepoRoot}/node_modules/ngrok/docker-bin:/monorepo/node_modules/ngrok/bin`);
|
|
237
|
+
}
|
|
238
|
+
if (process.env.FORGE_TUNNEL_MOUNT_DIRECTORIES) {
|
|
239
|
+
const mounts = process.env.FORGE_TUNNEL_MOUNT_DIRECTORIES.split(',');
|
|
240
|
+
mounts.forEach((mount) => {
|
|
241
|
+
options.push(`-v=${mount}:cached`);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return options;
|
|
245
|
+
}
|
|
246
|
+
async getDockerOptions() {
|
|
247
|
+
try {
|
|
248
|
+
return ['--rm', `--name`, exports.CONTAINER_NAME, '--platform', 'linux/amd64'];
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
throw new HiddenDockerTunnelError(false, "Couldn't populate docker options for tunneling");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
265
254
|
}
|
|
266
255
|
exports.DockerTunnelService = DockerTunnelService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/cli",
|
|
3
|
-
"version": "6.17.
|
|
3
|
+
"version": "6.17.1-next.8",
|
|
4
4
|
"description": "A command line interface for managing Atlassian-hosted apps",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -18,20 +18,20 @@
|
|
|
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": "4.12.
|
|
22
|
-
"@forge/cli-shared": "3.18.
|
|
23
|
-
"@forge/egress": "1.2.
|
|
24
|
-
"@forge/lint": "3.6.
|
|
25
|
-
"@forge/manifest": "4.20.
|
|
26
|
-
"@forge/node-runtime": "0.1.
|
|
27
|
-
"@forge/runtime": "5.0.
|
|
28
|
-
"@forge/tunnel": "3.7.
|
|
21
|
+
"@forge/bundler": "4.12.1-next.6",
|
|
22
|
+
"@forge/cli-shared": "3.18.1-next.4",
|
|
23
|
+
"@forge/egress": "1.2.5-next.0",
|
|
24
|
+
"@forge/lint": "3.6.7-next.4",
|
|
25
|
+
"@forge/manifest": "4.20.1-next.1",
|
|
26
|
+
"@forge/node-runtime": "0.1.3-next.0",
|
|
27
|
+
"@forge/runtime": "5.0.2-next.0",
|
|
28
|
+
"@forge/tunnel": "3.7.1-next.6",
|
|
29
29
|
"@forge/util": "1.3.1",
|
|
30
|
-
"@sentry/node": "^7.
|
|
30
|
+
"@sentry/node": "^7.68.0",
|
|
31
31
|
"ajv": "^8.12.0",
|
|
32
32
|
"archiver": "^6.0.1",
|
|
33
33
|
"case": "^1.6.3",
|
|
34
|
-
"chalk": "^
|
|
34
|
+
"chalk": "^4.1.2",
|
|
35
35
|
"cheerio": "^0.22.0",
|
|
36
36
|
"cli-table3": "^0.6.3",
|
|
37
37
|
"command-exists": "^1.2.9",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dayjs": "^1.11.9",
|
|
41
41
|
"didyoumean": "^1.2.2",
|
|
42
42
|
"env-paths": "^2.2.1",
|
|
43
|
-
"form-data": "^
|
|
43
|
+
"form-data": "^4.0.0",
|
|
44
44
|
"fs-extra": "^8.1.0",
|
|
45
45
|
"hidefile": "^3.0.0",
|
|
46
46
|
"latest-version": "^6.0.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/js-yaml": "^3.12.7",
|
|
71
71
|
"@types/minimatch": "^3.0.5",
|
|
72
72
|
"@types/mkdirp": "^1.0.2",
|
|
73
|
-
"@types/node": "14.18.
|
|
73
|
+
"@types/node": "14.18.59",
|
|
74
74
|
"@types/node-fetch": "^2.6.4",
|
|
75
75
|
"@types/omelette": "^0.4.2",
|
|
76
76
|
"@types/semver": "^7.5.1",
|