@forge/tunnel 2.2.1-next.12 → 2.2.1-next.14
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 +21 -0
- package/out/tunnelling/command/interactors/function-change-watcher.d.ts.map +1 -1
- package/out/tunnelling/command/interactors/function-change-watcher.js +8 -17
- package/out/tunnelling/servers/dev-server.d.ts +3 -4
- package/out/tunnelling/servers/dev-server.d.ts.map +1 -1
- package/out/tunnelling/servers/dev-server.js +13 -36
- package/out/tunnelling/servers/native-ui-tunnel-server.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @forge/tunnel
|
|
2
2
|
|
|
3
|
+
## 2.2.1-next.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a36488fc: Bundle Node runtime wrapper using Webpack
|
|
8
|
+
- Updated dependencies [b7428f75]
|
|
9
|
+
- Updated dependencies [a36488fc]
|
|
10
|
+
- Updated dependencies [8d0dc104]
|
|
11
|
+
- Updated dependencies [bbca9bed]
|
|
12
|
+
- @forge/cli-shared@3.5.0-next.5
|
|
13
|
+
- @forge/bundler@4.2.0-next.9
|
|
14
|
+
- @forge/runtime@3.0.0-next.6
|
|
15
|
+
|
|
16
|
+
## 2.2.1-next.13
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [1ad9503]
|
|
21
|
+
- @forge/bundler@4.1.1-next.8
|
|
22
|
+
- @forge/cli-shared@3.4.1-next.4
|
|
23
|
+
|
|
3
24
|
## 2.2.1-next.12
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-change-watcher.d.ts","sourceRoot":"","sources":["../../../../src/tunnelling/command/interactors/function-change-watcher.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAG1C,OAAO,EAAE,UAAU,EAA8B,MAAM,
|
|
1
|
+
{"version":3,"file":"function-change-watcher.d.ts","sourceRoot":"","sources":["../../../../src/tunnelling/command/interactors/function-change-watcher.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAG1C,OAAO,EAAE,UAAU,EAA8B,MAAM,EAAiB,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAML,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,qBAAqB;IACpC,aAAa,CAAC,WAAW,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE;AASD,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC,qBAAa,iBAAkB,YAAW,qBAAqB;IAI3D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAN/B,OAAO,CAAC,YAAY,CAA8C;gBAG/C,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,eAAe,EACzB,YAAY,EAAE,YAAY;YAG/B,mBAAmB;IAuBpB,aAAa,CAAC,WAAW,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA8CxD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C,OAAO,CAAC,YAAY,CAElB;YAEY,8BAA8B;YAU9B,mBAAmB;CAiBlC"}
|
|
@@ -77,33 +77,24 @@ class LocalFunctionHost {
|
|
|
77
77
|
async stopWatching() {
|
|
78
78
|
runtime_1.InvocationEventEmitter.removeAllListeners();
|
|
79
79
|
}
|
|
80
|
-
async initializeSandboxForDefinition(srcPath,
|
|
81
|
-
const parts = handler.split('.');
|
|
82
|
-
if (parts.length !== 2) {
|
|
83
|
-
throw new cli_shared_1.ValidationError(cli_shared_1.Text.tunnel.error.handler.format(handler));
|
|
84
|
-
}
|
|
85
|
-
const [mod, func] = parts;
|
|
80
|
+
async initializeSandboxForDefinition(srcPath, { module, func }) {
|
|
86
81
|
return await (0, runtime_1.initializeSandbox)({
|
|
87
82
|
appPath: srcPath,
|
|
88
|
-
modName:
|
|
83
|
+
modName: module,
|
|
89
84
|
handler: func,
|
|
90
85
|
timeout: exports.INVOCATION_TIMEOUT,
|
|
91
86
|
isolateMemory: exports.MEMORY_LIMIT
|
|
92
87
|
});
|
|
93
88
|
}
|
|
94
89
|
async initializeSandboxes(srcPath) {
|
|
95
|
-
var _a;
|
|
96
90
|
try {
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const uniqueHandlers = Array.from(new Set(handlers));
|
|
101
|
-
const promises = uniqueHandlers.map(async (handler) => {
|
|
91
|
+
const handlers = await this.configFile.getAppHandlers();
|
|
92
|
+
const sandboxes = {};
|
|
93
|
+
await Promise.all(handlers.map(async (handler) => {
|
|
102
94
|
const sandbox = await this.initializeSandboxForDefinition(srcPath, handler);
|
|
103
|
-
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
util_1.SandboxesContainer.updateSandboxes(resolveds.reduce((acc, obj) => Object.assign(acc, obj), {}));
|
|
95
|
+
sandboxes[`${handler.module}.${handler.func}`] = sandbox;
|
|
96
|
+
}));
|
|
97
|
+
util_1.SandboxesContainer.updateSandboxes(sandboxes);
|
|
107
98
|
}
|
|
108
99
|
catch (error) {
|
|
109
100
|
this.logger.error(error);
|
|
@@ -4,6 +4,7 @@ import { URL } from 'url';
|
|
|
4
4
|
import { ConfigFile, Logger } from '@forge/cli-shared';
|
|
5
5
|
import { ExternalRequestBody } from '@forge/runtime';
|
|
6
6
|
import { Permissions, Remotes } from '@forge/manifest';
|
|
7
|
+
import { BundlerOutput } from '@forge/bundler';
|
|
7
8
|
export interface WatchHooks<T = any> {
|
|
8
9
|
onBuildWillStart: () => Promise<void>;
|
|
9
10
|
onBuildFinished: (err: Error | null, result?: T) => Promise<void>;
|
|
@@ -11,7 +12,7 @@ export interface WatchHooks<T = any> {
|
|
|
11
12
|
export interface DevelopmentServer {
|
|
12
13
|
start(port?: number, permissions?: Permissions, remotes?: Remotes): Promise<StartDevServerResult>;
|
|
13
14
|
stop(): Promise<void>;
|
|
14
|
-
compileAndWatch
|
|
15
|
+
compileAndWatch(hooks: WatchHooks<BundlerOutput>): Promise<any>;
|
|
15
16
|
}
|
|
16
17
|
export interface StartDevServerResult {
|
|
17
18
|
port: number;
|
|
@@ -33,10 +34,8 @@ export declare class LocalDevelopmentServer implements DevelopmentServer {
|
|
|
33
34
|
constructor(invocationService: InvocationService, logger: Logger, configFile: ConfigFile);
|
|
34
35
|
start(port?: number, permissions?: Permissions, remotes?: Remotes): Promise<StartDevServerResult>;
|
|
35
36
|
stop(): Promise<void>;
|
|
36
|
-
compileAndWatch
|
|
37
|
+
compileAndWatch({ onBuildWillStart, onBuildFinished }: WatchHooks<BundlerOutput>): Promise<BundlerOutput | undefined>;
|
|
37
38
|
getApp(): express.Application;
|
|
38
39
|
handleInvocation: express.Handler;
|
|
39
|
-
private getEntryPoints;
|
|
40
|
-
private getRuntimeCompiler;
|
|
41
40
|
}
|
|
42
41
|
//# sourceMappingURL=dev-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../../src/tunnelling/servers/dev-server.ts"],"names":[],"mappings":";AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../../src/tunnelling/servers/dev-server.ts"],"names":[],"mappings":";AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAY,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAe,MAAM,gBAAgB,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EACL,aAAa,EAKd,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,GAAG;IACjC,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,eAAe,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnE;AACD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAClG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACjE;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,iBAAiB,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,GAAG,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACrE;AAED,qBAAa,sBAAuB,YAAW,iBAAiB;IAO5D,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAR7B,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,OAAO,CAAsB;gBAGlB,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU;IAQ5B,KAAK,CAAC,IAAI,SAAI,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAe5F,IAAI;IAUJ,eAAe,CAAC,EAC3B,gBAAgB,EAChB,eAAe,EAChB,EAAE,UAAU,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAiD1D,MAAM,IAAI,OAAO,CAAC,WAAW;IAI7B,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAsCtC;CACH"}
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LocalDevelopmentServer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const express_1 = tslib_1.__importDefault(require("express"));
|
|
6
|
-
const
|
|
6
|
+
const bundler_1 = require("@forge/bundler");
|
|
7
7
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
8
8
|
const runtime_1 = require("@forge/runtime");
|
|
9
9
|
const __1 = require("../");
|
|
10
10
|
const util_1 = require("../util");
|
|
11
|
-
const
|
|
11
|
+
const bundler_2 = require("@forge/bundler");
|
|
12
12
|
class LocalDevelopmentServer {
|
|
13
13
|
constructor(invocationService, logger, configFile) {
|
|
14
14
|
this.invocationService = invocationService;
|
|
@@ -44,36 +44,6 @@ class LocalDevelopmentServer {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
this.getEntryPoints = async () => {
|
|
48
|
-
const handlers = await this.configFile.getAppHandlers();
|
|
49
|
-
const currentDirectory = process.cwd();
|
|
50
|
-
const entryPoints = [];
|
|
51
|
-
for (const handler of handlers) {
|
|
52
|
-
entryPoints.push({
|
|
53
|
-
name: handler,
|
|
54
|
-
path: path_1.default.join(currentDirectory, 'src', handler)
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return entryPoints;
|
|
58
|
-
};
|
|
59
|
-
this.getRuntimeCompiler = async () => {
|
|
60
|
-
const entryPoints = await this.getEntryPoints();
|
|
61
|
-
if (!entryPoints.length) {
|
|
62
|
-
return {
|
|
63
|
-
compiler: undefined,
|
|
64
|
-
entryPoints
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const config = (0, bundler_1.getSandboxedRuntimeBuildConfig)(entryPoints, {
|
|
68
|
-
isWatchMode: true,
|
|
69
|
-
isDebugMode: (0, __1.isInspectorEnabled)(),
|
|
70
|
-
appDirectory: process.cwd()
|
|
71
|
-
});
|
|
72
|
-
return {
|
|
73
|
-
compiler: (0, bundler_1.getCompiler)(config),
|
|
74
|
-
entryPoints
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
47
|
this.app = (0, express_1.default)();
|
|
78
48
|
this.app.use(express_1.default.json({ limit: '6mb' }));
|
|
79
49
|
this.app.post(`/:fnKey`, this.handleInvocation);
|
|
@@ -99,10 +69,17 @@ class LocalDevelopmentServer {
|
|
|
99
69
|
await new Promise((resolve, reject) => server.close((err) => (err ? reject(err) : resolve())));
|
|
100
70
|
}
|
|
101
71
|
async compileAndWatch({ onBuildWillStart, onBuildFinished }) {
|
|
102
|
-
const
|
|
103
|
-
|
|
72
|
+
const handlers = await this.configFile.getAppHandlers();
|
|
73
|
+
const entryPoints = (0, bundler_1.getEntryPoints)(handlers);
|
|
74
|
+
if (!entryPoints.length) {
|
|
104
75
|
return;
|
|
105
76
|
}
|
|
77
|
+
const config = (0, bundler_2.getSandboxedRuntimeBuildConfig)(entryPoints, {
|
|
78
|
+
isWatchMode: true,
|
|
79
|
+
isDebugMode: (0, __1.isInspectorEnabled)(),
|
|
80
|
+
appDirectory: process.cwd()
|
|
81
|
+
});
|
|
82
|
+
const compiler = (0, bundler_2.getCompiler)(config);
|
|
106
83
|
let isFirstRun = true;
|
|
107
84
|
compiler.hooks.watchRun.tapAsync('watchRun', async (_, watchRunCallback) => {
|
|
108
85
|
if (!isFirstRun) {
|
|
@@ -113,9 +90,9 @@ class LocalDevelopmentServer {
|
|
|
113
90
|
return new Promise((resolve, reject) => {
|
|
114
91
|
compiler.watch({ poll: 1000 }, async (compilerError, stats) => {
|
|
115
92
|
try {
|
|
116
|
-
(0,
|
|
93
|
+
(0, bundler_2.handleWebpackCompilationResult)(compilerError, stats);
|
|
117
94
|
this.logger.info(cli_shared_1.LogColor.trace(cli_shared_1.Text.tunnel.functionsBundlingSucceeded));
|
|
118
|
-
const bundle = (0,
|
|
95
|
+
const bundle = (0, bundler_2.getInMemoryBundle)(config);
|
|
119
96
|
if (!isFirstRun) {
|
|
120
97
|
await onBuildFinished(null, bundle);
|
|
121
98
|
}
|
|
@@ -12,7 +12,7 @@ class NativeUITunnelServer extends resource_tunnel_server_1.ResourceTunnelServer
|
|
|
12
12
|
super(tunnelArgs);
|
|
13
13
|
this.tunnelArgs = tunnelArgs;
|
|
14
14
|
const { key, path, port, permissions, remotes } = tunnelArgs;
|
|
15
|
-
const entrypoint = { name: key, path };
|
|
15
|
+
const entrypoint = { name: key, path, functions: [] };
|
|
16
16
|
const config = (0, bundler_1.getNativeUiBuildConfig)([entrypoint]);
|
|
17
17
|
const compiler = (0, bundler_1.getCompiler)(Object.assign(Object.assign({}, config), { infrastructureLogging: {
|
|
18
18
|
level: 'error'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/tunnel",
|
|
3
|
-
"version": "2.2.1-next.
|
|
3
|
+
"version": "2.2.1-next.14",
|
|
4
4
|
"description": "Tunnel functionality for Forge CLI",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"postbuild": "chmod +x out/*.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@forge/bundler": "4.
|
|
20
|
-
"@forge/cli-shared": "3.
|
|
19
|
+
"@forge/bundler": "4.2.0-next.9",
|
|
20
|
+
"@forge/cli-shared": "3.5.0-next.5",
|
|
21
21
|
"@forge/csp": "^2.1.0",
|
|
22
22
|
"@forge/isolated-vm": "4.0.0-next.0",
|
|
23
|
-
"@forge/runtime": "3.0.0-next.
|
|
23
|
+
"@forge/runtime": "3.0.0-next.6",
|
|
24
24
|
"express": "^4.17.1",
|
|
25
25
|
"express-intercept": "^0.8.10",
|
|
26
26
|
"http-proxy-middleware": "^1.0.6",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"webpack-dev-server": "^4.11.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@forge/manifest": "^4.5.3-next.
|
|
35
|
+
"@forge/manifest": "^4.5.3-next.1",
|
|
36
36
|
"@types/express": "^4.17.2",
|
|
37
37
|
"@types/jest": "^29.1.2",
|
|
38
38
|
"@types/node": "^12.12.63",
|