@forge/tunnel 5.5.0-next.13 → 5.5.0-next.15
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/command/interactors/function-change-watcher.d.ts +1 -7
- package/out/command/interactors/function-change-watcher.d.ts.map +1 -1
- package/out/command/interactors/function-change-watcher.js +20 -38
- package/out/command/interactors/multi-compiler-watcher.d.ts +4 -2
- package/out/command/interactors/multi-compiler-watcher.d.ts.map +1 -1
- package/out/command/interactors/multi-compiler-watcher.js +11 -23
- package/out/command/interactors/tunnel-interactor.d.ts.map +1 -1
- package/out/command/interactors/tunnel-interactor.js +17 -19
- package/out/command/start-tunnel-command.d.ts +2 -1
- package/out/command/start-tunnel-command.d.ts.map +1 -1
- package/out/command/start-tunnel-command.js +2 -1
- package/out/servers/dev-server.d.ts +2 -2
- package/out/servers/dev-server.d.ts.map +1 -1
- package/out/servers/dev-server.js +10 -7
- package/out/servers/native-ui-tunnel-server.d.ts +1 -0
- package/out/servers/native-ui-tunnel-server.d.ts.map +1 -1
- package/out/servers/native-ui-tunnel-server.js +3 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @forge/tunnel
|
|
2
2
|
|
|
3
|
+
## 5.5.0-next.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @forge/bundler@4.19.0-next.15
|
|
8
|
+
- @forge/cli-shared@5.5.0-next.14
|
|
9
|
+
|
|
10
|
+
## 5.5.0-next.14
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- ac1a61b: Bundle files on disk instead of memory
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [ac1a61b]
|
|
19
|
+
- @forge/cli-shared@5.5.0-next.13
|
|
20
|
+
- @forge/bundler@4.19.0-next.14
|
|
21
|
+
|
|
3
22
|
## 5.5.0-next.13
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -5,12 +5,6 @@ export interface FunctionChangeWatcher {
|
|
|
5
5
|
startWatching(bundledCode: BundlerOutput, tunnelOptions: TunnelOptions): Promise<void>;
|
|
6
6
|
stopWatching(): Promise<void>;
|
|
7
7
|
}
|
|
8
|
-
export interface Bundle {
|
|
9
|
-
bundleFilePath: string;
|
|
10
|
-
bundleFileContent: string;
|
|
11
|
-
bundleFileSourceMapPath: string;
|
|
12
|
-
bundleFileSourceMap?: string;
|
|
13
|
-
}
|
|
14
8
|
export declare const MEMORY_LIMIT = 256;
|
|
15
9
|
export declare class LocalFunctionHost implements FunctionChangeWatcher {
|
|
16
10
|
private readonly configFile;
|
|
@@ -19,7 +13,7 @@ export declare class LocalFunctionHost implements FunctionChangeWatcher {
|
|
|
19
13
|
private readonly createSandbox;
|
|
20
14
|
private snapshotLogs;
|
|
21
15
|
constructor(configFile: ConfigFile, logger: Logger, snapshot: SnapshotCreator | null, createSandbox: (cfg: SandboxConfig) => Promise<Sandbox>);
|
|
22
|
-
private
|
|
16
|
+
private generateSnapshot;
|
|
23
17
|
startWatching(bundledCode: BundlerOutput, tunnelOptions?: TunnelOptions): Promise<void>;
|
|
24
18
|
stopWatching(): Promise<void>;
|
|
25
19
|
private onRuntimeLog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-change-watcher.d.ts","sourceRoot":"","sources":["../../../src/command/interactors/function-change-watcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"function-change-watcher.d.ts","sourceRoot":"","sources":["../../../src/command/interactors/function-change-watcher.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EAGV,MAAM,EAGN,aAAa,EAEd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAIL,OAAO,EACP,aAAa,EACb,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,qBAAqB;IACpC,aAAa,CAAC,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvF,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAED,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,aAAa;IANhC,OAAO,CAAC,YAAY,CAA8C;gBAG/C,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,eAAe,GAAG,IAAI,EAChC,aAAa,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC;YAG5D,gBAAgB;IAgBjB,aAAa,CACxB,WAAW,EAAE,aAAa,EAC1B,aAAa,GAAE,aAA2C,GACzD,OAAO,CAAC,IAAI,CAAC;IA2CH,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C,OAAO,CAAC,YAAY,CAElB;YAEY,mBAAmB;WAwBnB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa;CAY7F"}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LocalFunctionHost = exports.MEMORY_LIMIT = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = tslib_1.
|
|
6
|
-
const
|
|
7
|
-
const tmp_1 = tslib_1.__importDefault(require("tmp"));
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const promises_1 = require("fs/promises");
|
|
8
7
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
9
8
|
const runtime_1 = require("@forge/runtime");
|
|
10
9
|
const util_1 = require("../../util");
|
|
@@ -21,52 +20,35 @@ class LocalFunctionHost {
|
|
|
21
20
|
this.snapshot = snapshot;
|
|
22
21
|
this.createSandbox = createSandbox;
|
|
23
22
|
}
|
|
24
|
-
async
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (!this.snapshot) {
|
|
28
|
-
throw new Error('Snapshot requested but snapshot creator not provided.');
|
|
29
|
-
}
|
|
30
|
-
const snapshotOutput = await this.snapshot({ isolateMemory: exports.MEMORY_LIMIT }, Buffer.from(bundle.bundleFileContent), bundle.bundleFilePath, bundle.bundleFileSourceMap ? Buffer.from(bundle.bundleFileSourceMap) : undefined);
|
|
31
|
-
await fs_1.promises.writeFile(bundle.bundleFilePath + '.snapshot', Buffer.from(snapshotOutput.buffer));
|
|
32
|
-
if (snapshotOutput.logs.length > 0) {
|
|
33
|
-
this.snapshotLogs.push(snapshotOutput.logs);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
await fs_1.promises.writeFile(bundle.bundleFilePath, bundle.bundleFileContent);
|
|
23
|
+
async generateSnapshot(filePath) {
|
|
24
|
+
if (!this.snapshot) {
|
|
25
|
+
throw new Error('Snapshot requested but snapshot creator not provided.');
|
|
38
26
|
}
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
const script = await (0, promises_1.readFile)(filePath);
|
|
28
|
+
const sourceMap = await (0, promises_1.readFile)(filePath + '.map').catch(() => undefined);
|
|
29
|
+
const snapshotOutput = await this.snapshot({ isolateMemory: exports.MEMORY_LIMIT }, script, filePath, sourceMap);
|
|
30
|
+
await (0, promises_1.writeFile)(filePath + '.snapshot', Buffer.from(snapshotOutput.buffer));
|
|
31
|
+
if (snapshotOutput.logs.length > 0) {
|
|
32
|
+
this.snapshotLogs.push(snapshotOutput.logs);
|
|
41
33
|
}
|
|
42
34
|
}
|
|
43
35
|
async startWatching(bundledCode, tunnelOptions = cli_shared_1.defaultNoDebugTunnelOptions) {
|
|
44
36
|
const isNodeJsRuntime = (await this.configFile.runtimeType()) === cli_shared_1.RuntimeType.nodejs;
|
|
45
|
-
|
|
46
|
-
if (isNodeJsRuntime && tunnelOptions.debug) {
|
|
47
|
-
directory = path_1.default.resolve(cli_shared_1.defaultDebugBundleOutputPath);
|
|
48
|
-
}
|
|
37
|
+
const pathTo = (relativePath) => path_1.default.resolve(bundledCode.outputDir, relativePath);
|
|
49
38
|
const isSnapshotEnabled = (await this.configFile.snapshotsEnabled()) && !isNodeJsRuntime;
|
|
50
39
|
if (isSnapshotEnabled) {
|
|
51
40
|
this.logger.info('');
|
|
52
41
|
this.logger.info(cli_shared_1.Text.tunnel.preBundleTask(cli_shared_1.Text.tunnel.snapshotting));
|
|
53
42
|
this.snapshotLogs = [];
|
|
43
|
+
const modules = new Set((await this.configFile.getAppHandlers()).map(({ module }) => module));
|
|
44
|
+
for (const module of modules) {
|
|
45
|
+
const handlerPath = pathTo(`${module}.js`);
|
|
46
|
+
await this.generateSnapshot(handlerPath);
|
|
47
|
+
}
|
|
54
48
|
}
|
|
55
|
-
const
|
|
56
|
-
const sourceMapPath = `${bundlePath}.map`;
|
|
57
|
-
return {
|
|
58
|
-
bundleFilePath: (0, path_1.resolve)(directory, bundlePath),
|
|
59
|
-
bundleFileContent: bundledCode.output[bundlePath],
|
|
60
|
-
bundleFileSourceMapPath: (0, path_1.resolve)(directory, sourceMapPath),
|
|
61
|
-
bundleFileSourceMap: bundledCode.sourceMap?.[sourceMapPath]
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
const manifestFilePath = (0, path_1.resolve)(directory, cli_shared_1.manifestFileName);
|
|
49
|
+
const manifestFilePath = pathTo(cli_shared_1.manifestFileName);
|
|
65
50
|
const manifestContents = JSON.stringify(await this.configFile.readConfig());
|
|
66
|
-
|
|
67
|
-
bundles.forEach((bundle) => allPromises.push(this.generateBundleFiles(bundle, isSnapshotEnabled)));
|
|
68
|
-
allPromises.push(fs_1.promises.writeFile(manifestFilePath, manifestContents));
|
|
69
|
-
await Promise.all(allPromises);
|
|
51
|
+
await (0, promises_1.writeFile)(manifestFilePath, manifestContents);
|
|
70
52
|
if (isSnapshotEnabled) {
|
|
71
53
|
if (this.snapshotLogs.length > 0) {
|
|
72
54
|
this.logger.info('');
|
|
@@ -82,7 +64,7 @@ class LocalFunctionHost {
|
|
|
82
64
|
this.logger.info('');
|
|
83
65
|
}
|
|
84
66
|
}
|
|
85
|
-
await this.initializeSandboxes(
|
|
67
|
+
await this.initializeSandboxes(bundledCode.outputDir, tunnelOptions);
|
|
86
68
|
runtime_1.StaticInvocationEventEmitter.addListener(runtime_1.EVENT_P3_LOG, this.onRuntimeLog);
|
|
87
69
|
}
|
|
88
70
|
async stopWatching() {
|
|
@@ -2,8 +2,10 @@ import { BundlerOutput, WatcherMonitor } from '@forge/bundler';
|
|
|
2
2
|
import { DevelopmentServer, WatchHooks } from '../../servers';
|
|
3
3
|
import { TunnelOptions } from '@forge/cli-shared';
|
|
4
4
|
export declare class MultiCompilerWatcher implements WatcherMonitor {
|
|
5
|
-
private readonly
|
|
6
|
-
|
|
5
|
+
private readonly faasServer;
|
|
6
|
+
private readonly uiServers;
|
|
7
|
+
constructor(faasServer: DevelopmentServer, uiServers: DevelopmentServer[]);
|
|
8
|
+
allServers(): DevelopmentServer[];
|
|
7
9
|
compileAndWatch({ onChange: { onBuildWillStart, onBuildFinished } }: {
|
|
8
10
|
onChange: WatchHooks;
|
|
9
11
|
}, tunnelOptions?: TunnelOptions): Promise<BundlerOutput>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-compiler-watcher.d.ts","sourceRoot":"","sources":["../../../src/command/interactors/multi-compiler-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAA+B,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE/E,qBAAa,oBAAqB,YAAW,cAAc;
|
|
1
|
+
{"version":3,"file":"multi-compiler-watcher.d.ts","sourceRoot":"","sources":["../../../src/command/interactors/multi-compiler-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAA+B,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE/E,qBAAa,oBAAqB,YAAW,cAAc;IAEvD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,iBAAiB,EAAE;IAG1C,UAAU,IAAI,iBAAiB,EAAE;IAI3B,eAAe,CAC1B,EACE,QAAQ,EAAE,EAAE,gBAAgB,EAAE,eAAe,EAAE,EAChD,EAAE;QACD,QAAQ,EAAE,UAAU,CAAC;KACtB,EACD,aAAa,GAAE,aAA2C,GACzD,OAAO,CAAC,aAAa,CAAC;IAgBZ,IAAI;CAGlB"}
|
|
@@ -3,36 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MultiCompilerWatcher = void 0;
|
|
4
4
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
5
5
|
class MultiCompilerWatcher {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
faasServer;
|
|
7
|
+
uiServers;
|
|
8
|
+
constructor(faasServer, uiServers) {
|
|
9
|
+
this.faasServer = faasServer;
|
|
10
|
+
this.uiServers = uiServers;
|
|
11
|
+
}
|
|
12
|
+
allServers() {
|
|
13
|
+
return [this.faasServer, ...this.uiServers];
|
|
9
14
|
}
|
|
10
15
|
async compileAndWatch({ onChange: { onBuildWillStart, onBuildFinished } }, tunnelOptions = cli_shared_1.defaultNoDebugTunnelOptions) {
|
|
11
|
-
const
|
|
16
|
+
const [faasResult] = await Promise.all(this.allServers().map((server) => server.compileAndWatch({
|
|
12
17
|
onBuildWillStart,
|
|
13
18
|
onBuildFinished
|
|
14
19
|
}, tunnelOptions)));
|
|
15
|
-
|
|
16
|
-
output: {}
|
|
17
|
-
};
|
|
18
|
-
for (const result of results) {
|
|
19
|
-
multiResult.output = {
|
|
20
|
-
...multiResult.output,
|
|
21
|
-
...result.output
|
|
22
|
-
};
|
|
23
|
-
multiResult.sourceMap = {
|
|
24
|
-
...multiResult.sourceMap,
|
|
25
|
-
...result.sourceMap
|
|
26
|
-
};
|
|
27
|
-
multiResult.metadata = {
|
|
28
|
-
...multiResult.metadata,
|
|
29
|
-
...result.metadata
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return multiResult;
|
|
20
|
+
return faasResult;
|
|
33
21
|
}
|
|
34
22
|
async stop() {
|
|
35
|
-
await Promise.all(this.
|
|
23
|
+
await Promise.all(this.allServers().map((server) => server.stop()));
|
|
36
24
|
}
|
|
37
25
|
}
|
|
38
26
|
exports.MultiCompilerWatcher = MultiCompilerWatcher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel-interactor.d.ts","sourceRoot":"","sources":["../../../src/command/interactors/tunnel-interactor.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAyC,MAAM,EAAQ,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE/C,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAEpC,mBAAmB,CACxB,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EACjC,aAAa,EAAE,cAAc,GAAG,SAAS,EACzC,mBAAmB,EAAE,SAAS,GAC7B,OAAO,CAAC,IAAI,CAAC;IAsCT,6BAA6B,CAAC,gBAAgB,EAAE,MAAM;IAUtD,QAAQ,sBACM,iBAAiB,kBACrB,aAAa,KAC3B,QAAQ,cAAc,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"tunnel-interactor.d.ts","sourceRoot":"","sources":["../../../src/command/interactors/tunnel-interactor.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAyC,MAAM,EAAQ,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE/C,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAEpC,mBAAmB,CACxB,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EACjC,aAAa,EAAE,cAAc,GAAG,SAAS,EACzC,mBAAmB,EAAE,SAAS,GAC7B,OAAO,CAAC,IAAI,CAAC;IAsCT,6BAA6B,CAAC,gBAAgB,EAAE,MAAM;IAUtD,QAAQ,sBACM,iBAAiB,kBACrB,aAAa,KAC3B,QAAQ,cAAc,GAAG,SAAS,CAAC,CA8DpC;CACH"}
|
|
@@ -55,7 +55,7 @@ class TunnelInteractor {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
watchApp = async (startTunnelResult, tunnelOptions = cli_shared_1.defaultNoDebugTunnelOptions) => {
|
|
58
|
-
const { localPort, inspectorAddress, reloadSandboxes,
|
|
58
|
+
const { localPort, inspectorAddress, reloadSandboxes, faasServer, uiServers } = startTunnelResult;
|
|
59
59
|
if (inspectorAddress) {
|
|
60
60
|
this.logger.info(cli_shared_1.Text.tunnel.startedInspector(inspectorAddress));
|
|
61
61
|
}
|
|
@@ -81,25 +81,23 @@ class TunnelInteractor {
|
|
|
81
81
|
this.logger.info('');
|
|
82
82
|
this.logger.info(cli_shared_1.Text.tunnel.startedServer(localPort, this.logger.debugEnabled) + '\n');
|
|
83
83
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
catch (_) {
|
|
100
|
-
}
|
|
101
|
-
return multiCompiler;
|
|
84
|
+
const multiCompiler = new multi_compiler_watcher_1.MultiCompilerWatcher(faasServer, uiServers);
|
|
85
|
+
await (0, bundler_1.runLinter)();
|
|
86
|
+
this.logger.info(cli_shared_1.Text.tunnel.preBundleTask(cli_shared_1.Text.tunnel.bundlingHeader));
|
|
87
|
+
try {
|
|
88
|
+
const output = await multiCompiler.compileAndWatch({
|
|
89
|
+
onChange: {
|
|
90
|
+
onBuildWillStart: onBundlingStart,
|
|
91
|
+
onBuildFinished: onBundlingFinish
|
|
92
|
+
}
|
|
93
|
+
}, tunnelOptions);
|
|
94
|
+
await reloadSandboxes(output, tunnelOptions);
|
|
95
|
+
this.logger.info('');
|
|
96
|
+
this.logger.info(cli_shared_1.Text.tunnel.startedServer(localPort, this.logger.debugEnabled) + '\n');
|
|
97
|
+
}
|
|
98
|
+
catch (_) {
|
|
102
99
|
}
|
|
100
|
+
return multiCompiler;
|
|
103
101
|
};
|
|
104
102
|
}
|
|
105
103
|
exports.TunnelInteractor = TunnelInteractor;
|
|
@@ -15,7 +15,8 @@ export interface StartTunnelResult {
|
|
|
15
15
|
localPort: number;
|
|
16
16
|
tunnelDefinitions: TunnelDefinitions;
|
|
17
17
|
inspectorAddress?: string;
|
|
18
|
-
|
|
18
|
+
faasServer: DevelopmentServer;
|
|
19
|
+
uiServers: DevelopmentServer[];
|
|
19
20
|
stopFunction(): Promise<void>;
|
|
20
21
|
reloadSandboxes(bundledCode: BundlerOutput, tunnelOptions: TunnelOptions): Promise<void>;
|
|
21
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-tunnel-command.d.ts","sourceRoot":"","sources":["../../src/command/start-tunnel-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAyB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChH,OAAO,EAAE,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AAI9D,OAAO,EACL,iBAAiB,EAKlB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAsC,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACzE,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,iBAAiB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"start-tunnel-command.d.ts","sourceRoot":"","sources":["../../src/command/start-tunnel-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,UAA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E;IACxF,OAAO,CAAC,iBAAiB,CAAgC;gBAGtC,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,iBAAiB,EAC5B,aAAa,EAAE,mBAAmB,EAClC,YAAY,EAAE,qBAAqB,EACnC,YAAY,EAAE,qBAAqB,EACnC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU;IAGzC,OAAO,CAAC,YAAY,CAUlB;IAEF,OAAO,CAAC,qBAAqB,CAuB3B;IAEF,OAAO,CAAC,gCAAgC,CAoCtC;IAEW,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAyD9E"}
|
|
@@ -122,7 +122,8 @@ class StartTunnelCommand {
|
|
|
122
122
|
inspectorAddress,
|
|
123
123
|
stopFunction,
|
|
124
124
|
reloadSandboxes,
|
|
125
|
-
|
|
125
|
+
faasServer: faasTunnelServer.devServer,
|
|
126
|
+
uiServers: customUITunnelsServers.map(({ devServer }) => devServer)
|
|
126
127
|
};
|
|
127
128
|
}
|
|
128
129
|
catch (e) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import
|
|
4
|
-
import * as http from 'http';
|
|
3
|
+
import http from 'http';
|
|
5
4
|
import { URL } from 'url';
|
|
5
|
+
import express from 'express';
|
|
6
6
|
import { ConfigFile, FileSystemReader, Logger, TunnelOptions } from '@forge/cli-shared';
|
|
7
7
|
import { ExternalRequestBody } from '@forge/runtime';
|
|
8
8
|
import { Permissions, Remotes } from '@forge/manifest';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/servers/dev-server.ts"],"names":[],"mappings":";;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/servers/dev-server.ts"],"names":[],"mapp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G,CAAC,CAAC;CACrE;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ/E;AAED,qBAAa,sBAAuB,YAAW,iBAAiB;IAO5D,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IATnC,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,EACtB,gBAAgB,EAAE,gBAAgB;IAQxC,KAAK,CAAC,IAAI,SAAI,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAe5F,IAAI;IAIJ,eAAe,CAC1B,EAAE,gBAAgB,EAAE,eAAe,EAAE,EAAE,UAAU,CAAC,aAAa,CAAC,EAChE,aAAa,GAAE,aAA2C,GACzD,OAAO,CAAC,aAAa,CAAC;IAuDlB,MAAM,IAAI,OAAO,CAAC,WAAW;IAI7B,gBAAgB,EAAE,OAAO,CAAC,OAAO,CA2CtC;CACH"}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LocalDevelopmentServer = exports.stopServer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
6
|
const express_1 = tslib_1.__importDefault(require("express"));
|
|
6
7
|
const bundler_1 = require("@forge/bundler");
|
|
7
8
|
const cli_shared_1 = require("@forge/cli-shared");
|
|
8
9
|
const runtime_1 = require("@forge/runtime");
|
|
9
|
-
const util_1 = require("../util");
|
|
10
10
|
const bundler_2 = require("@forge/bundler");
|
|
11
|
+
const util_1 = require("../util");
|
|
11
12
|
async function stopServer(server) {
|
|
12
13
|
if (!server) {
|
|
13
14
|
return;
|
|
@@ -51,18 +52,21 @@ class LocalDevelopmentServer {
|
|
|
51
52
|
await stopServer(this.httpServer);
|
|
52
53
|
}
|
|
53
54
|
async compileAndWatch({ onBuildWillStart, onBuildFinished }, tunnelOptions = cli_shared_1.defaultNoDebugTunnelOptions) {
|
|
55
|
+
const isNodeJsRuntime = (await this.configFile.runtimeType()) === cli_shared_1.RuntimeType.nodejs;
|
|
56
|
+
const outputDir = isNodeJsRuntime && tunnelOptions.debug ? path_1.default.resolve(cli_shared_1.TUNNEL_BUNDLE_DIRECTORY) : (0, cli_shared_1.tmpDir)('tunnel');
|
|
54
57
|
const handlers = await this.configFile.getAppHandlers();
|
|
55
58
|
const entryPoints = (0, bundler_1.getEntryPoints)(handlers);
|
|
56
59
|
if (!entryPoints.length) {
|
|
57
|
-
return {
|
|
60
|
+
return { outputDir };
|
|
58
61
|
}
|
|
59
|
-
const getConfig =
|
|
62
|
+
const getConfig = isNodeJsRuntime
|
|
60
63
|
? (0, bundler_2.getNodeRuntimeBuildConfig)((0, bundler_1.getWrapperProvider)({ fileSystemReader: this.fileSystemReader }))
|
|
61
64
|
: bundler_2.getSandboxedRuntimeBuildConfig;
|
|
62
65
|
const config = getConfig(entryPoints, {
|
|
63
66
|
isWatchMode: true,
|
|
64
67
|
isDebugMode: tunnelOptions.debug,
|
|
65
|
-
appDirectory: process.cwd()
|
|
68
|
+
appDirectory: process.cwd(),
|
|
69
|
+
outputDir
|
|
66
70
|
});
|
|
67
71
|
const compiler = (0, bundler_2.getCompiler)(config);
|
|
68
72
|
let isFirstRun = true;
|
|
@@ -77,12 +81,11 @@ class LocalDevelopmentServer {
|
|
|
77
81
|
try {
|
|
78
82
|
(0, bundler_2.handleWebpackCompilationResult)(this.logger, compilerError, stats);
|
|
79
83
|
this.logger.info(cli_shared_1.LogColor.trace(cli_shared_1.Text.tunnel.functionsBundlingSucceeded));
|
|
80
|
-
const bundle = (0, bundler_2.getInMemoryBundle)(config);
|
|
81
84
|
if (!isFirstRun) {
|
|
82
|
-
await onBuildFinished(null,
|
|
85
|
+
await onBuildFinished(null, { outputDir });
|
|
83
86
|
}
|
|
84
87
|
isFirstRun = false;
|
|
85
|
-
resolve(
|
|
88
|
+
resolve({ outputDir });
|
|
86
89
|
}
|
|
87
90
|
catch (err) {
|
|
88
91
|
await onBuildFinished(err);
|
|
@@ -5,6 +5,7 @@ import { DevelopmentServer, StartDevServerResult, WatchHooks } from './dev-serve
|
|
|
5
5
|
export declare class NativeUITunnelServer extends ResourceTunnelServer implements DevelopmentServer {
|
|
6
6
|
private readonly tunnelArgs;
|
|
7
7
|
readonly server: WebpackDevServer;
|
|
8
|
+
private readonly outputDir;
|
|
8
9
|
constructor(tunnelArgs: ResourceTunnelServerArgs);
|
|
9
10
|
start(): Promise<Required<StartDevServerResult>>;
|
|
10
11
|
compileAndWatch({ onBuildWillStart, onBuildFinished }: WatchHooks): Promise<BundlerOutput>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-ui-tunnel-server.d.ts","sourceRoot":"","sources":["../../src/servers/native-ui-tunnel-server.ts"],"names":[],"mappings":"AAAA,OAAO,gBAA+D,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAuE,MAAM,gBAAgB,CAAC;AACpH,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAG1F,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEnF,qBAAa,oBAAqB,SAAQ,oBAAqB,YAAW,iBAAiB;
|
|
1
|
+
{"version":3,"file":"native-ui-tunnel-server.d.ts","sourceRoot":"","sources":["../../src/servers/native-ui-tunnel-server.ts"],"names":[],"mappings":"AAAA,OAAO,gBAA+D,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAuE,MAAM,gBAAgB,CAAC;AACpH,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAG1F,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEnF,qBAAa,oBAAqB,SAAQ,oBAAqB,YAAW,iBAAiB;IAI7E,OAAO,CAAC,QAAQ,CAAC,UAAU;IAHvC,SAAgB,MAAM,EAAE,gBAAgB,CAAC;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEN,UAAU,EAAE,wBAAwB;IA4D3D,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAWzC,eAAe,CAAC,EAAE,gBAAgB,EAAE,eAAe,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IAsCjG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
|
|
@@ -10,12 +10,14 @@ const url_1 = require("url");
|
|
|
10
10
|
class NativeUITunnelServer extends resource_tunnel_server_1.ResourceTunnelServer {
|
|
11
11
|
tunnelArgs;
|
|
12
12
|
server;
|
|
13
|
+
outputDir;
|
|
13
14
|
constructor(tunnelArgs) {
|
|
14
15
|
super(tunnelArgs);
|
|
15
16
|
this.tunnelArgs = tunnelArgs;
|
|
16
17
|
const { key, path, port, permissions, remotes, i18nConfig } = tunnelArgs;
|
|
17
18
|
const entrypoint = { name: key, path, functions: [] };
|
|
18
19
|
const config = (0, bundler_1.getNativeUiBuildConfig)([entrypoint]);
|
|
20
|
+
this.outputDir = config.output.path;
|
|
19
21
|
const compiler = (0, bundler_1.getCompiler)({
|
|
20
22
|
...config,
|
|
21
23
|
infrastructureLogging: {
|
|
@@ -83,9 +85,7 @@ class NativeUITunnelServer extends resource_tunnel_server_1.ResourceTunnelServer
|
|
|
83
85
|
else {
|
|
84
86
|
isFirstCompilation = false;
|
|
85
87
|
}
|
|
86
|
-
resolve({
|
|
87
|
-
output: {}
|
|
88
|
-
});
|
|
88
|
+
resolve({ outputDir: this.outputDir });
|
|
89
89
|
}
|
|
90
90
|
catch (err) {
|
|
91
91
|
await onBuildFinished(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/tunnel",
|
|
3
|
-
"version": "5.5.0-next.
|
|
3
|
+
"version": "5.5.0-next.15",
|
|
4
4
|
"description": "Tunnel functionality for Forge CLI",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"compile": "tsc -b -v"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@forge/bundler": "4.19.0-next.
|
|
15
|
-
"@forge/cli-shared": "5.5.0-next.
|
|
14
|
+
"@forge/bundler": "4.19.0-next.15",
|
|
15
|
+
"@forge/cli-shared": "5.5.0-next.14",
|
|
16
16
|
"@forge/csp": "3.3.0",
|
|
17
17
|
"@forge/runtime": "5.10.1",
|
|
18
18
|
"chokidar": "^3.6.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@atlassian/xen-test-util": "^4.2.0",
|
|
32
|
-
"@forge/manifest": "7.7.0-next.
|
|
32
|
+
"@forge/manifest": "7.7.0-next.14",
|
|
33
33
|
"@types/express": "^4.17.21",
|
|
34
34
|
"@types/jest": "^29.5.12",
|
|
35
35
|
"@types/node": "14.18.63",
|