@forge/tunnel 6.1.0-next.4 → 6.1.0-next.6
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 +19 -0
- package/out/servers/dev-server.d.ts +2 -0
- package/out/servers/dev-server.d.ts.map +1 -1
- package/out/servers/dev-server.js +42 -23
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @forge/tunnel
|
|
2
2
|
|
|
3
|
+
## 6.1.0-next.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [924b093]
|
|
8
|
+
- @forge/cli-shared@8.5.0-next.6
|
|
9
|
+
- @forge/bundler@6.1.4-next.6
|
|
10
|
+
|
|
11
|
+
## 6.1.0-next.5
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 7e13ccd: Add support for multi-service tunnelling
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @forge/bundler@6.1.4-next.5
|
|
20
|
+
- @forge/cli-shared@8.5.0-next.5
|
|
21
|
+
|
|
3
22
|
## 6.1.0-next.4
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -40,5 +40,7 @@ export declare class LocalDevelopmentServer implements DevelopmentServer {
|
|
|
40
40
|
compileAndWatch(watch: BundlerWatch, tunnelOptions?: TunnelOptions): Promise<BundlerOutput>;
|
|
41
41
|
getApp(): express.Application;
|
|
42
42
|
handleInvocation: express.Handler;
|
|
43
|
+
configureProxyMiddleware: express.Handler;
|
|
44
|
+
private getServicePort;
|
|
43
45
|
}
|
|
44
46
|
//# sourceMappingURL=dev-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/servers/dev-server.ts"],"names":[],"mappings":";;AAAA,OAAO,IAAI,MAAM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CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,2BAA2B;IAT9C,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,UAAU,CAA0B;gBAGzB,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,cAAc,EAC9B,2BAA2B,EAAE,2BAA2B;IAe9D,KAAK,CAAC,IAAI,SAAI,EAAE,YAAY,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAY9F,IAAI;IAIJ,eAAe,CAC1B,KAAK,EAAE,YAAY,EACnB,aAAa,GAAE,aAA2C,GACzD,OAAO,CAAC,aAAa,CAAC;IA8BlB,MAAM,IAAI,OAAO,CAAC,WAAW;IAI7B,gBAAgB,EAAE,OAAO,CAAC,OAAO,CA4BtC;IAEK,wBAAwB,EAAE,OAAO,CAAC,OAAO,CAoC9C;YAQY,cAAc;CAU7B"}
|
|
@@ -8,6 +8,7 @@ const cli_shared_1 = require("@forge/cli-shared");
|
|
|
8
8
|
const runtime_1 = require("@forge/runtime");
|
|
9
9
|
const util_1 = require("../util");
|
|
10
10
|
const http_proxy_middleware_1 = require("http-proxy-middleware");
|
|
11
|
+
const DEFAULT_FORGE_SERVICE_PORT = 7071;
|
|
11
12
|
async function stopServer(server) {
|
|
12
13
|
if (!server) {
|
|
13
14
|
return;
|
|
@@ -37,29 +38,7 @@ class LocalDevelopmentServer {
|
|
|
37
38
|
this.app.disable('x-powered-by');
|
|
38
39
|
this.app.disable('etag');
|
|
39
40
|
this.app.post(`/:fnKey`, express_1.default.json({ limit: '6mb' }), this.handleInvocation);
|
|
40
|
-
|
|
41
|
-
this.app.use(/^\/forge\/.*\/.*/, (0, http_proxy_middleware_1.createProxyMiddleware)({
|
|
42
|
-
target: `http://localhost:${FORGE_SERVICE_PORT}`,
|
|
43
|
-
pathRewrite: { '^/forge/[^/]*': '' },
|
|
44
|
-
logLevel: 'info',
|
|
45
|
-
logProvider: () => {
|
|
46
|
-
return {
|
|
47
|
-
log: this.logger.trace,
|
|
48
|
-
debug: this.logger.trace,
|
|
49
|
-
info: this.logger.trace,
|
|
50
|
-
warn: this.logger.warn,
|
|
51
|
-
error: this.logger.error
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
onProxyReq: (proxyReq) => {
|
|
55
|
-
this.logger.info(cli_shared_1.Text.tunnel.container.invoke(proxyReq, FORGE_SERVICE_PORT));
|
|
56
|
-
},
|
|
57
|
-
onError: (err, _, res) => {
|
|
58
|
-
const message = cli_shared_1.Text.tunnel.container.error(err.code ?? err.message);
|
|
59
|
-
this.logger.warn(message);
|
|
60
|
-
res.status(500).send(message);
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
41
|
+
this.app.use(/^\/forge\/.*--.*\/.*/, this.configureProxyMiddleware);
|
|
63
42
|
}
|
|
64
43
|
async start(port = 0, _permissions, _remotes) {
|
|
65
44
|
this.httpServer = await new Promise((resolve, reject) => {
|
|
@@ -121,5 +100,45 @@ class LocalDevelopmentServer {
|
|
|
121
100
|
}
|
|
122
101
|
}
|
|
123
102
|
};
|
|
103
|
+
configureProxyMiddleware = async (req, res, next) => {
|
|
104
|
+
const serviceKey = req.originalUrl.match(/^\/forge\/(.*)--.*\/.*/)?.[1];
|
|
105
|
+
const port = await this.getServicePort(serviceKey);
|
|
106
|
+
if (!port || port < 1024 || port > 49152) {
|
|
107
|
+
this.logger.error(new Error(`Invalid tunnel port value for service ${serviceKey}. The 'tunnel:port' must be an integer between 1024 and 49152. Update your manifest.yml and try again.`));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
(0, http_proxy_middleware_1.createProxyMiddleware)({
|
|
111
|
+
target: `http://localhost:${port}`,
|
|
112
|
+
pathRewrite: { '^/forge/[^/]*': '' },
|
|
113
|
+
logLevel: 'info',
|
|
114
|
+
logProvider: () => {
|
|
115
|
+
return {
|
|
116
|
+
log: this.logger.trace,
|
|
117
|
+
debug: this.logger.trace,
|
|
118
|
+
info: this.logger.trace,
|
|
119
|
+
warn: this.logger.warn,
|
|
120
|
+
error: this.logger.error
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
onProxyReq: (proxyReq) => {
|
|
124
|
+
this.logger.info(cli_shared_1.Text.tunnel.container.invoke(proxyReq, port));
|
|
125
|
+
},
|
|
126
|
+
onError: (err, _, res) => {
|
|
127
|
+
const message = cli_shared_1.Text.tunnel.container.error(err.code ?? err.message);
|
|
128
|
+
this.logger.warn(message);
|
|
129
|
+
res.status(500).send(message);
|
|
130
|
+
}
|
|
131
|
+
})(req, res, next);
|
|
132
|
+
};
|
|
133
|
+
async getServicePort(serviceKey) {
|
|
134
|
+
if (serviceKey) {
|
|
135
|
+
const { services } = await this.configFile.readConfig();
|
|
136
|
+
if (services) {
|
|
137
|
+
const defaultPort = services[0].tunnel?.port ?? DEFAULT_FORGE_SERVICE_PORT;
|
|
138
|
+
const index = services.findIndex((service) => service.key === serviceKey);
|
|
139
|
+
return services[index].tunnel?.port ?? defaultPort + index;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
124
143
|
}
|
|
125
144
|
exports.LocalDevelopmentServer = LocalDevelopmentServer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/tunnel",
|
|
3
|
-
"version": "6.1.0-next.
|
|
3
|
+
"version": "6.1.0-next.6",
|
|
4
4
|
"description": "Tunnel functionality for Forge CLI",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"compile": "tsc -b -v"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@forge/bundler": "6.1.4-next.
|
|
15
|
-
"@forge/cli-shared": "8.5.0-next.
|
|
14
|
+
"@forge/bundler": "6.1.4-next.6",
|
|
15
|
+
"@forge/cli-shared": "8.5.0-next.6",
|
|
16
16
|
"@forge/csp": "5.0.0",
|
|
17
17
|
"@forge/runtime": "6.0.3",
|
|
18
18
|
"cheerio": "^1.1.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@atlassian/xen-test-util": "^4.2.0",
|
|
34
|
-
"@forge/manifest": "10.4.0-next.
|
|
34
|
+
"@forge/manifest": "10.4.0-next.3",
|
|
35
35
|
"@types/express": "^4.17.21",
|
|
36
36
|
"@types/jest": "^29.5.14",
|
|
37
37
|
"@types/node": "20.19.1",
|