@forge/tunnel 5.11.1-next.5 → 5.11.1-next.7
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 +16 -0
- package/out/command/interactors/function-change-watcher.d.ts +2 -5
- package/out/command/interactors/function-change-watcher.d.ts.map +1 -1
- package/out/command/interactors/function-change-watcher.js +1 -43
- package/out/servers/dev-server.d.ts.map +1 -1
- package/out/servers/dev-server.js +2 -5
- package/out/services/local-invocation-service.d.ts +2 -3
- package/out/services/local-invocation-service.d.ts.map +1 -1
- package/out/services/local-invocation-service.js +1 -13
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @forge/tunnel
|
|
2
2
|
|
|
3
|
+
## 5.11.1-next.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @forge/bundler@5.0.1-next.7
|
|
8
|
+
- @forge/cli-shared@7.1.0-next.7
|
|
9
|
+
|
|
10
|
+
## 5.11.1-next.6
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 9f050ff: Removed support for Sandbox Runtime and Sanpshots
|
|
15
|
+
- Updated dependencies [9f050ff]
|
|
16
|
+
- @forge/cli-shared@7.1.0-next.6
|
|
17
|
+
- @forge/bundler@5.0.1-next.6
|
|
18
|
+
|
|
3
19
|
## 5.11.1-next.5
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigFile, Logger, TunnelOptions } from '@forge/cli-shared';
|
|
2
2
|
import { BundlerOutput } from '@forge/bundler';
|
|
3
|
-
import { Sandbox, SandboxConfig
|
|
3
|
+
import { Sandbox, SandboxConfig } from '@forge/runtime';
|
|
4
4
|
export interface FunctionChangeWatcher {
|
|
5
5
|
startWatching(bundledCode: BundlerOutput, tunnelOptions: TunnelOptions): Promise<void>;
|
|
6
6
|
stopWatching(): Promise<void>;
|
|
@@ -9,11 +9,8 @@ export declare const MEMORY_LIMIT = 256;
|
|
|
9
9
|
export declare class LocalFunctionHost implements FunctionChangeWatcher {
|
|
10
10
|
private readonly configFile;
|
|
11
11
|
private readonly logger;
|
|
12
|
-
private readonly snapshot;
|
|
13
12
|
private readonly createSandbox;
|
|
14
|
-
|
|
15
|
-
constructor(configFile: ConfigFile, logger: Logger, snapshot: SnapshotCreator | null, createSandbox: (cfg: SandboxConfig) => Promise<Sandbox>);
|
|
16
|
-
private generateSnapshot;
|
|
13
|
+
constructor(configFile: ConfigFile, logger: Logger, createSandbox: (cfg: SandboxConfig) => Promise<Sandbox>);
|
|
17
14
|
startWatching(bundledCode: BundlerOutput, tunnelOptions?: TunnelOptions): Promise<void>;
|
|
18
15
|
stopWatching(): Promise<void>;
|
|
19
16
|
private onRuntimeLog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-change-watcher.d.ts","sourceRoot":"","sources":["../../../src/command/interactors/function-change-watcher.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"function-change-watcher.d.ts","sourceRoot":"","sources":["../../../src/command/interactors/function-change-watcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAoB,MAAM,EAAE,aAAa,EAA+B,MAAM,mBAAmB,CAAC;AACrH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAIL,OAAO,EACP,aAAa,EACd,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;IAE3D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAFb,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC;IAG7D,aAAa,CACxB,WAAW,EAAE,aAAa,EAC1B,aAAa,GAAE,aAA2C,GACzD,OAAO,CAAC,IAAI,CAAC;IAYH,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"}
|
|
@@ -11,59 +11,17 @@ exports.MEMORY_LIMIT = 256;
|
|
|
11
11
|
class LocalFunctionHost {
|
|
12
12
|
configFile;
|
|
13
13
|
logger;
|
|
14
|
-
snapshot;
|
|
15
14
|
createSandbox;
|
|
16
|
-
|
|
17
|
-
constructor(configFile, logger, snapshot, createSandbox) {
|
|
15
|
+
constructor(configFile, logger, createSandbox) {
|
|
18
16
|
this.configFile = configFile;
|
|
19
17
|
this.logger = logger;
|
|
20
|
-
this.snapshot = snapshot;
|
|
21
18
|
this.createSandbox = createSandbox;
|
|
22
19
|
}
|
|
23
|
-
async generateSnapshot(filePath) {
|
|
24
|
-
if (!this.snapshot) {
|
|
25
|
-
throw new Error('Snapshot requested but snapshot creator not provided.');
|
|
26
|
-
}
|
|
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);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
20
|
async startWatching(bundledCode, tunnelOptions = cli_shared_1.defaultNoDebugTunnelOptions) {
|
|
36
|
-
const isNodeJsRuntime = (await this.configFile.runtimeType()) === cli_shared_1.RuntimeType.nodejs;
|
|
37
21
|
const pathTo = (relativePath) => path_1.default.resolve(bundledCode.outputDir, relativePath);
|
|
38
|
-
const isSnapshotEnabled = (await this.configFile.snapshotsEnabled()) && !isNodeJsRuntime;
|
|
39
|
-
if (isSnapshotEnabled) {
|
|
40
|
-
this.logger.info('');
|
|
41
|
-
this.logger.info(cli_shared_1.Text.tunnel.preBundleTask(cli_shared_1.Text.tunnel.snapshotting));
|
|
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
|
-
}
|
|
48
|
-
}
|
|
49
22
|
const manifestFilePath = pathTo(cli_shared_1.manifestFileName);
|
|
50
23
|
const manifestContents = JSON.stringify(await this.configFile.readConfig());
|
|
51
24
|
await (0, promises_1.writeFile)(manifestFilePath, manifestContents);
|
|
52
|
-
if (isSnapshotEnabled) {
|
|
53
|
-
if (this.snapshotLogs.length > 0) {
|
|
54
|
-
this.logger.info('');
|
|
55
|
-
this.snapshotLogs.forEach((snapshotLog) => {
|
|
56
|
-
snapshotLog.forEach((log) => {
|
|
57
|
-
this.logger.snapshotLog(log.message, (0, util_1.mapLogLevel)(log.level));
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
this.logger.info('');
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
this.logger.info(cli_shared_1.LogColor.trace(cli_shared_1.Text.tunnel.snapshottingNoLogs));
|
|
64
|
-
this.logger.info('');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
25
|
await this.initializeSandboxes(bundledCode.outputDir, tunnelOptions);
|
|
68
26
|
runtime_1.StaticInvocationEventEmitter.addListener(runtime_1.EVENT_P3_LOG, this.onRuntimeLog);
|
|
69
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/servers/dev-server.ts"],"names":[],"mappings":";;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAKL,YAAY,EACZ,aAAa,
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/servers/dev-server.ts"],"names":[],"mappings":";;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAKL,YAAY,EACZ,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,UAAU,EAEV,gBAAgB,EAChB,2BAA2B,EAC3B,MAAM,EACN,cAAc,EAEd,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAe,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAKvD,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,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,CA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,EACnB,aAAa,GAAE,aAA2C,GACzD,OAAO,CAAC,aAAa,CAAC;IA8BlB,MAAM,IAAI,OAAO,CAAC,WAAW;IAI7B,gBAAgB,EAAE,OAAO,CAAC,OAAO,CA4CtC;CACH"}
|
|
@@ -79,16 +79,13 @@ class LocalDevelopmentServer {
|
|
|
79
79
|
await stopServer(this.httpServer);
|
|
80
80
|
}
|
|
81
81
|
async compileAndWatch(watch, tunnelOptions = cli_shared_1.defaultNoDebugTunnelOptions) {
|
|
82
|
-
const isNodeJsRuntime = (await this.configFile.runtimeType()) === cli_shared_1.RuntimeType.nodejs;
|
|
83
82
|
const watchMode = tunnelOptions.debug ? 'debug' : 'watch';
|
|
84
83
|
const handlers = await this.configFile.getAppHandlers();
|
|
85
84
|
const entryPoints = (0, bundler_1.getEntryPoints)(handlers);
|
|
86
85
|
if (!entryPoints.length) {
|
|
87
86
|
return { outputDir: (0, bundler_1.getOutputDir)({ watchMode }) };
|
|
88
87
|
}
|
|
89
|
-
const bundler =
|
|
90
|
-
? (0, bundler_1.getNodeBundler)(this.logger, (0, bundler_1.getWrapperProvider)({ fileSystemReader: this.fileSystemReader, statsigService: this.statsigService }), this.configFile)
|
|
91
|
-
: new bundler_1.SandboxBundler(this.logger);
|
|
88
|
+
const bundler = (0, bundler_1.getNodeBundler)(this.logger, (0, bundler_1.getWrapperProvider)({ fileSystemReader: this.fileSystemReader, statsigService: this.statsigService }), this.configFile);
|
|
92
89
|
const { translations, modules } = await this.configFile.readConfig();
|
|
93
90
|
const i18nResourceBundle = await this.i18nResourceBundlingService.bundle(modules, translations);
|
|
94
91
|
const { result } = await bundler.watch({
|
|
@@ -127,7 +124,7 @@ class LocalDevelopmentServer {
|
|
|
127
124
|
};
|
|
128
125
|
try {
|
|
129
126
|
const invokeResults = await this.invocationService.invoke(request.handler, request);
|
|
130
|
-
if (
|
|
127
|
+
if (!invokeResults.success) {
|
|
131
128
|
return res.status(500).send(invokeResults.error);
|
|
132
129
|
}
|
|
133
130
|
res.json(invokeResults);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { InvocationService } from '../servers';
|
|
2
2
|
import { ExternalRequestBody, Inspector } from '@forge/runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { Logger } from '@forge/cli-shared';
|
|
4
4
|
export declare class LocalInvocationService implements InvocationService {
|
|
5
|
-
private readonly configFile;
|
|
6
5
|
private readonly logger;
|
|
7
6
|
private readonly inspector;
|
|
8
|
-
constructor(
|
|
7
|
+
constructor(logger: Logger, inspector: Inspector);
|
|
9
8
|
invoke(handler: string, request: ExternalRequestBody): Promise<any>;
|
|
10
9
|
static INTERNAL_METRICS: string[];
|
|
11
10
|
static printMetrics: (shouldReportMetrics: boolean, metrics: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-invocation-service.d.ts","sourceRoot":"","sources":["../../src/services/local-invocation-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI/C,OAAO,EACL,mBAAmB,EACnB,SAAS,EAKV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"local-invocation-service.d.ts","sourceRoot":"","sources":["../../src/services/local-invocation-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI/C,OAAO,EACL,mBAAmB,EACnB,SAAS,EAKV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAyB,MAAM,mBAAmB,CAAC;AAKlE,qBAAa,sBAAuB,YAAW,iBAAiB;IAE5D,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS;IAG1B,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC;IAgDhF,MAAM,CAAC,gBAAgB,WAA6D;IAEpF,MAAM,CAAC,YAAY,wBACI,OAAO;;wCAET,MAAM,GAAG,SAAS,UAC7B,MAAM,KACb,IAAI,CAcL;CACH"}
|
|
@@ -10,11 +10,9 @@ const cli_shared_1 = require("@forge/cli-shared");
|
|
|
10
10
|
const zlib = tslib_1.__importStar(require("node:zlib"));
|
|
11
11
|
const DEFAULT_INVOCATION_TIMEOUT = 25;
|
|
12
12
|
class LocalInvocationService {
|
|
13
|
-
configFile;
|
|
14
13
|
logger;
|
|
15
14
|
inspector;
|
|
16
|
-
constructor(
|
|
17
|
-
this.configFile = configFile;
|
|
15
|
+
constructor(logger, inspector) {
|
|
18
16
|
this.logger = logger;
|
|
19
17
|
this.inspector = inspector;
|
|
20
18
|
}
|
|
@@ -31,16 +29,6 @@ class LocalInvocationService {
|
|
|
31
29
|
this.logger.info(cli_shared_1.Text.tunnel.startedInspector(inspectorUrl));
|
|
32
30
|
}
|
|
33
31
|
const variables = request.variables || [];
|
|
34
|
-
const isSnapshotEnabled = await this.configFile.snapshotsEnabled();
|
|
35
|
-
const isSnapshotValueFoundAndUpdated = (variables || []).some((variable) => {
|
|
36
|
-
if (variable.key !== 'FUNCTION_IS_SNAPSHOTTED')
|
|
37
|
-
return false;
|
|
38
|
-
variable.value = isSnapshotEnabled.toString();
|
|
39
|
-
return true;
|
|
40
|
-
});
|
|
41
|
-
if (!isSnapshotValueFoundAndUpdated) {
|
|
42
|
-
variables.push({ key: 'FUNCTION_IS_SNAPSHOTTED', value: isSnapshotEnabled.toString(), secure: false });
|
|
43
|
-
}
|
|
44
32
|
const requestId = (0, util_1.getRequestId)(request, (0, uuid_1.v4)());
|
|
45
33
|
const timeout = request._meta.timeout ?? DEFAULT_INVOCATION_TIMEOUT;
|
|
46
34
|
const xenInvocationRequest = (0, runtime_1.xenInvocationRequestFactory)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/tunnel",
|
|
3
|
-
"version": "5.11.1-next.
|
|
3
|
+
"version": "5.11.1-next.7",
|
|
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": "5.0.1-next.
|
|
15
|
-
"@forge/cli-shared": "7.1.0-next.
|
|
14
|
+
"@forge/bundler": "5.0.1-next.7",
|
|
15
|
+
"@forge/cli-shared": "7.1.0-next.7",
|
|
16
16
|
"@forge/csp": "3.9.0",
|
|
17
17
|
"@forge/runtime": "5.10.8",
|
|
18
18
|
"cloudflared": "^0.7.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@atlassian/xen-test-util": "^4.2.0",
|
|
33
|
-
"@forge/manifest": "9.5.0-next.
|
|
33
|
+
"@forge/manifest": "9.5.0-next.6",
|
|
34
34
|
"@types/express": "^4.17.21",
|
|
35
35
|
"@types/jest": "^29.5.12",
|
|
36
36
|
"@types/node": "14.18.63",
|