@forge/bundler 4.6.6 → 4.6.7-next.1
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 +15 -0
- package/out/stubs/console.d.ts +4 -3
- package/out/stubs/console.d.ts.map +1 -1
- package/out/stubs/console.js +22 -65
- package/out/stubs/log-events.d.ts +4 -26
- package/out/stubs/log-events.d.ts.map +1 -1
- package/out/stubs/log-events.js +11 -44
- package/out/stubs/wrapper.js +1 -1
- package/package.json +4 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @forge/bundler
|
|
2
2
|
|
|
3
|
+
## 4.6.7-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9610487: Simplify logs handling on Node runtime
|
|
8
|
+
- Updated dependencies [9610487]
|
|
9
|
+
- @forge/runtime@4.3.3-next.0
|
|
10
|
+
|
|
11
|
+
## 4.6.7-next.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @forge/cli-shared@3.11.1-next.0
|
|
16
|
+
- @forge/lint@3.3.1-next.0
|
|
17
|
+
|
|
3
18
|
## 4.6.6
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/out/stubs/console.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ConsoleMethod, LogHeader } from '@forge/runtime';
|
|
2
|
-
export declare
|
|
3
|
-
export declare function
|
|
1
|
+
import { ConsoleMethod, P3LogEvent, LogHeader, LogFooter, HeadedLogLine } from '@forge/runtime';
|
|
2
|
+
export declare function emitTunnelEvent(event: P3LogEvent): void;
|
|
3
|
+
export declare function emitLogEvent(event: LogHeader | HeadedLogLine | LogFooter): void;
|
|
4
|
+
export declare function forgeConsole(consoleMethod: ConsoleMethod, header: LogHeader): (...rawData: unknown[]) => void;
|
|
4
5
|
export declare function replaceConsole(header: LogHeader): void;
|
|
5
6
|
export declare function restoreConsole(): void;
|
|
6
7
|
//# sourceMappingURL=console.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/stubs/console.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/stubs/console.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,aAAa,EACb,UAAU,EAEV,SAAS,EACT,SAAS,EAET,aAAa,EAEd,MAAM,gBAAgB,CAAC;AAQxB,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAEvD;AAOD,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,IAAI,CAE/E;AA6BD,wBAAgB,YAAY,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,mCAY3E;AAMD,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,QAI/C;AAED,wBAAgB,cAAc,SAI7B"}
|
package/out/stubs/console.js
CHANGED
|
@@ -1,86 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.restoreConsole = exports.replaceConsole = exports.forgeConsole = exports.
|
|
4
|
-
const bunyan_1 = require("bunyan");
|
|
3
|
+
exports.restoreConsole = exports.replaceConsole = exports.forgeConsole = exports.emitLogEvent = exports.emitTunnelEvent = void 0;
|
|
5
4
|
const api_1 = require("@forge/api");
|
|
6
5
|
const runtime_1 = require("@forge/runtime");
|
|
7
6
|
const util_1 = require("util");
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
return arg;
|
|
11
|
-
}
|
|
12
|
-
else if (arg instanceof Error) {
|
|
13
|
-
return arg.toString();
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function transformSandBoxLogMessage(arg) {
|
|
20
|
-
let msg = null;
|
|
21
|
-
if (Array.isArray(arg) && arg.length > 0) {
|
|
22
|
-
msg = stringMessage(arg[0]);
|
|
23
|
-
if (msg !== null) {
|
|
24
|
-
arg = arg.slice(1);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (msg === null) {
|
|
28
|
-
msg = '';
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
msg,
|
|
32
|
-
'*': arg
|
|
33
|
-
};
|
|
7
|
+
function emitTunnelEvent(event) {
|
|
8
|
+
process.stdout.write(JSON.stringify(event) + '\n');
|
|
34
9
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const transformedMessage = transformSandBoxLogMessage(logEventData.logArguments);
|
|
39
|
-
return {
|
|
40
|
-
type: 'log',
|
|
41
|
-
id: requestId,
|
|
42
|
-
msg: transformedMessage.msg,
|
|
43
|
-
P: 3,
|
|
44
|
-
ts: Date.now(),
|
|
45
|
-
lvl: logEventData.logLevel,
|
|
46
|
-
'*': transformedMessage['*']
|
|
47
|
-
};
|
|
10
|
+
exports.emitTunnelEvent = emitTunnelEvent;
|
|
11
|
+
function emitLogEvent(event) {
|
|
12
|
+
process.stdout.write(JSON.stringify(event) + '\n');
|
|
48
13
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
level: bunyan_1.levelFromName.info,
|
|
52
|
-
serializers: { '*': exports.starSerializer }
|
|
53
|
-
});
|
|
54
|
-
function customConsole(logMethod, header) {
|
|
14
|
+
exports.emitLogEvent = emitLogEvent;
|
|
15
|
+
function customConsole(logLevel, header) {
|
|
55
16
|
return (...rawData) => {
|
|
56
17
|
var _a;
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
const logLine = formatLogMessage(awsRequestId, logEventData);
|
|
70
|
-
const headedLogLine = Object.assign(Object.assign({}, header), logLine);
|
|
71
|
-
logger.info(headedLogLine, logLine.msg);
|
|
72
|
-
}
|
|
18
|
+
const msg = (0, util_1.format)((_a = rawData[0]) !== null && _a !== void 0 ? _a : '');
|
|
19
|
+
const rest = rawData.slice(1).map((val) => (0, util_1.format)(val));
|
|
20
|
+
const invocationId = (0, api_1.getRuntime)().lambdaContext.awsRequestId;
|
|
21
|
+
if (global.__forge_tunnel__) {
|
|
22
|
+
const logEventData = { invocationId, logLevel, logArguments: [msg, ...rest] };
|
|
23
|
+
emitTunnelEvent(logEventData);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const logLine = Object.assign(Object.assign({}, header), { type: runtime_1.LogType.LOG, id: invocationId, P: 3, ts: Date.now(), lvl: logLevel, msg, '*': rest });
|
|
27
|
+
emitLogEvent(logLine);
|
|
73
28
|
}
|
|
74
29
|
};
|
|
75
30
|
}
|
|
76
31
|
function forgeConsole(consoleMethod, header) {
|
|
77
32
|
switch (consoleMethod) {
|
|
78
33
|
case 'debug':
|
|
34
|
+
return customConsole(runtime_1.LogLevel.DEBUG, header);
|
|
79
35
|
case 'warn':
|
|
36
|
+
return customConsole(runtime_1.LogLevel.WARN, header);
|
|
80
37
|
case 'error':
|
|
81
|
-
return customConsole(
|
|
38
|
+
return customConsole(runtime_1.LogLevel.ERROR, header);
|
|
82
39
|
default:
|
|
83
|
-
return customConsole(
|
|
40
|
+
return customConsole(runtime_1.LogLevel.INFO, header);
|
|
84
41
|
}
|
|
85
42
|
}
|
|
86
43
|
exports.forgeConsole = forgeConsole;
|
|
@@ -1,30 +1,8 @@
|
|
|
1
|
+
import { ExternalRequestBody, LogHeader } from '@forge/runtime';
|
|
1
2
|
export declare const AWS_EXECUTION_ENV_PREFIX = "AWS_Lambda_";
|
|
2
3
|
export declare const RUNTIME_NAME_FALLBACK = "node";
|
|
3
4
|
export declare function getRuntimeName(): string;
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
LOG = "log"
|
|
8
|
-
}
|
|
9
|
-
export declare function emitHeaderEvent(lambdaEvent: any): {
|
|
10
|
-
type: EventType;
|
|
11
|
-
id: string;
|
|
12
|
-
time: string;
|
|
13
|
-
};
|
|
14
|
-
export declare function emitSuccessfulFooterEvent(): {
|
|
15
|
-
type: EventType;
|
|
16
|
-
id: string;
|
|
17
|
-
time: string;
|
|
18
|
-
};
|
|
19
|
-
export declare function emitFailedFooterEvent(): {
|
|
20
|
-
type: EventType;
|
|
21
|
-
id: string;
|
|
22
|
-
time: string;
|
|
23
|
-
};
|
|
24
|
-
export declare function emitErrorEvent(caughtObject: any): {
|
|
25
|
-
type: EventType;
|
|
26
|
-
id: string;
|
|
27
|
-
time: string;
|
|
28
|
-
};
|
|
29
|
-
export {};
|
|
5
|
+
export declare function emitHeaderEvent(lambdaEvent: ExternalRequestBody): LogHeader;
|
|
6
|
+
export declare function emitSuccessfulFooterEvent(): void;
|
|
7
|
+
export declare function emitFailedFooterEvent(): void;
|
|
30
8
|
//# sourceMappingURL=log-events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-events.d.ts","sourceRoot":"","sources":["../../src/stubs/log-events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log-events.d.ts","sourceRoot":"","sources":["../../src/stubs/log-events.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAa,SAAS,EAAW,MAAM,gBAAgB,CAAC;AAIpF,eAAO,MAAM,wBAAwB,gBAAgB,CAAC;AACtD,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAE5C,wBAAgB,cAAc,IAAI,MAAM,CAavC;AAmDD,wBAAgB,eAAe,CAAC,WAAW,EAAE,mBAAmB,GAAG,SAAS,CAI3E;AAED,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
package/out/stubs/log-events.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.emitFailedFooterEvent = exports.emitSuccessfulFooterEvent = exports.emitHeaderEvent = exports.getRuntimeName = exports.RUNTIME_NAME_FALLBACK = exports.AWS_EXECUTION_ENV_PREFIX = void 0;
|
|
4
4
|
const api_1 = require("@forge/api");
|
|
5
|
-
const bunyan_1 = require("bunyan");
|
|
6
|
-
const console_1 = require("./console");
|
|
7
5
|
const runtime_1 = require("@forge/runtime");
|
|
6
|
+
const console_1 = require("./console");
|
|
8
7
|
exports.AWS_EXECUTION_ENV_PREFIX = 'AWS_Lambda_';
|
|
9
8
|
exports.RUNTIME_NAME_FALLBACK = 'node';
|
|
10
9
|
function getRuntimeName() {
|
|
@@ -22,6 +21,8 @@ function invocationHeaderLogs(lambdaEvent) {
|
|
|
22
21
|
const { featureFlags, contextAri, appContext, tracing } = lambdaEvent === null || lambdaEvent === void 0 ? void 0 : lambdaEvent._meta;
|
|
23
22
|
const { appId, environmentId, appVersion, functionKey, moduleKey, moduleType } = appContext !== null && appContext !== void 0 ? appContext : {};
|
|
24
23
|
return {
|
|
24
|
+
id: (0, api_1.getRuntime)().lambdaContext.awsRequestId,
|
|
25
|
+
type: runtime_1.LogType.HEADER,
|
|
25
26
|
appId,
|
|
26
27
|
environmentId,
|
|
27
28
|
appVersion,
|
|
@@ -36,6 +37,8 @@ function invocationHeaderLogs(lambdaEvent) {
|
|
|
36
37
|
}
|
|
37
38
|
function invocationFooterLogs(successfulInvocation) {
|
|
38
39
|
return {
|
|
40
|
+
id: (0, api_1.getRuntime)().lambdaContext.awsRequestId,
|
|
41
|
+
type: runtime_1.LogType.FOOTER,
|
|
39
42
|
success: successfulInvocation,
|
|
40
43
|
logMetadata: {
|
|
41
44
|
bytes: 0,
|
|
@@ -59,53 +62,17 @@ function invocationFooterLogs(successfulInvocation) {
|
|
|
59
62
|
}
|
|
60
63
|
};
|
|
61
64
|
}
|
|
62
|
-
var EventType;
|
|
63
|
-
(function (EventType) {
|
|
64
|
-
EventType["HEADER"] = "header";
|
|
65
|
-
EventType["FOOTER"] = "footer";
|
|
66
|
-
EventType["LOG"] = "log";
|
|
67
|
-
})(EventType || (EventType = {}));
|
|
68
|
-
function simpleBunyanLogEvent(eventType, eventLevel, data) {
|
|
69
|
-
function groupLogData(logData) {
|
|
70
|
-
if (eventType === 'footer' || eventType === 'header') {
|
|
71
|
-
return logData;
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
'*': (0, console_1.starSerializer)([logData]),
|
|
75
|
-
P: 3,
|
|
76
|
-
lvl: eventLevel,
|
|
77
|
-
ts: Date.now()
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const invocationId = (0, api_1.getRuntime)().lambdaContext.awsRequestId;
|
|
81
|
-
const logEvent = Object.assign({ type: eventType, id: invocationId, time: new Date().toISOString() }, groupLogData(data));
|
|
82
|
-
process.stdout.write(JSON.stringify(logEvent) + '\n');
|
|
83
|
-
return logEvent;
|
|
84
|
-
}
|
|
85
|
-
function logErrorToTunnelProcess(caughtObject) {
|
|
86
|
-
if (global.__forge_tunnel__) {
|
|
87
|
-
const logEventData = {
|
|
88
|
-
invocationId: (0, api_1.getRuntime)().lambdaContext.awsRequestId,
|
|
89
|
-
logLevel: runtime_1.LogLevel.ERROR,
|
|
90
|
-
logArguments: [caughtObject]
|
|
91
|
-
};
|
|
92
|
-
process.stdout.write(JSON.stringify(Object.assign(Object.assign({}, logEventData), { logArguments: (0, console_1.starSerializer)(logEventData.logArguments) })) + '\n');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
65
|
function emitHeaderEvent(lambdaEvent) {
|
|
96
|
-
|
|
66
|
+
const event = invocationHeaderLogs(lambdaEvent);
|
|
67
|
+
(0, console_1.emitLogEvent)(event);
|
|
68
|
+
return event;
|
|
97
69
|
}
|
|
98
70
|
exports.emitHeaderEvent = emitHeaderEvent;
|
|
99
71
|
function emitSuccessfulFooterEvent() {
|
|
100
|
-
|
|
72
|
+
(0, console_1.emitLogEvent)(invocationFooterLogs(true));
|
|
101
73
|
}
|
|
102
74
|
exports.emitSuccessfulFooterEvent = emitSuccessfulFooterEvent;
|
|
103
75
|
function emitFailedFooterEvent() {
|
|
104
|
-
|
|
76
|
+
(0, console_1.emitLogEvent)(invocationFooterLogs(false));
|
|
105
77
|
}
|
|
106
78
|
exports.emitFailedFooterEvent = emitFailedFooterEvent;
|
|
107
|
-
function emitErrorEvent(caughtObject) {
|
|
108
|
-
logErrorToTunnelProcess(caughtObject);
|
|
109
|
-
return simpleBunyanLogEvent(EventType.LOG, bunyan_1.levelFromName.error, caughtObject);
|
|
110
|
-
}
|
|
111
|
-
exports.emitErrorEvent = emitErrorEvent;
|
package/out/stubs/wrapper.js
CHANGED
|
@@ -55,7 +55,7 @@ const adapter = (name) => {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
catch (err) {
|
|
58
|
-
|
|
58
|
+
console.error(err);
|
|
59
59
|
(0, log_events_1.emitFailedFooterEvent)();
|
|
60
60
|
const errorName = (0, api_1.isForgePlatformError)(err) ? err.name : api_1.FUNCTION_ERR;
|
|
61
61
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bundler",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.7-next.1",
|
|
4
4
|
"description": "Default bundler for Forge apps",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Atlassian",
|
|
@@ -20,15 +20,14 @@
|
|
|
20
20
|
"@babel/preset-typescript": "^7.16.7",
|
|
21
21
|
"@forge/api": "2.15.2",
|
|
22
22
|
"@forge/babel-plugin-transform-ui": "1.1.2",
|
|
23
|
-
"@forge/cli-shared": "3.11.0",
|
|
24
|
-
"@forge/lint": "3.3.0",
|
|
25
|
-
"@forge/runtime": "4.3.
|
|
23
|
+
"@forge/cli-shared": "3.11.1-next.0",
|
|
24
|
+
"@forge/lint": "3.3.1-next.0",
|
|
25
|
+
"@forge/runtime": "4.3.3-next.0",
|
|
26
26
|
"@forge/util": "1.2.3",
|
|
27
27
|
"assert": "^1.1.1",
|
|
28
28
|
"babel-loader": "^8.2.3",
|
|
29
29
|
"browserify-zlib": "^0.2.0",
|
|
30
30
|
"buffer": "^4.3.0",
|
|
31
|
-
"bunyan": "^1.8.15",
|
|
32
31
|
"chalk": "^2.4.2",
|
|
33
32
|
"console-browserify": "^1.1.0",
|
|
34
33
|
"crypto-browserify": "^3.11.0",
|
|
@@ -56,7 +55,6 @@
|
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
57
|
"@atlassian/xen-test-util": "^1.1.1",
|
|
59
|
-
"@types/bunyan": "^1.8.8",
|
|
60
58
|
"@types/jest": "^29.1.2",
|
|
61
59
|
"@types/node": "14.18.42",
|
|
62
60
|
"@types/react": "^17.0.53",
|