@jsii/kernel 1.68.0 → 1.70.0
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/lib/api.d.ts +1 -0
- package/lib/kernel.js +11 -14
- package/lib/recording.js +1 -1
- package/lib/tar-cache/index.d.ts +1 -5
- package/lib/tar-cache/index.js +29 -16
- package/package.json +7 -7
package/lib/api.d.ts
CHANGED
package/lib/kernel.js
CHANGED
|
@@ -4,14 +4,12 @@ exports.Kernel = exports.RuntimeError = exports.JsiiFault = void 0;
|
|
|
4
4
|
const spec = require("@jsii/spec");
|
|
5
5
|
const spec_1 = require("@jsii/spec");
|
|
6
6
|
const cp = require("child_process");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
7
|
const fs = require("fs-extra");
|
|
9
8
|
const module_1 = require("module");
|
|
10
9
|
const os = require("os");
|
|
11
10
|
const path = require("path");
|
|
12
11
|
const api = require("./api");
|
|
13
12
|
const api_1 = require("./api");
|
|
14
|
-
const link_1 = require("./link");
|
|
15
13
|
const objects_1 = require("./objects");
|
|
16
14
|
const onExit = require("./on-exit");
|
|
17
15
|
const wire = require("./serialization");
|
|
@@ -88,21 +86,13 @@ class Kernel {
|
|
|
88
86
|
const originalUmask = process.umask(0o022);
|
|
89
87
|
try {
|
|
90
88
|
// untar the archive to its final location
|
|
91
|
-
const {
|
|
89
|
+
const { cache } = this._debugTime(() => tar.extract(req.tarball, packageDir, {
|
|
92
90
|
strict: true,
|
|
93
91
|
strip: 1,
|
|
94
92
|
unlink: true,
|
|
95
93
|
}, req.name, req.version), `tar.extract(${req.tarball}) => ${packageDir}`);
|
|
96
|
-
// Create the install directory (there may be several path components for @scoped/packages)
|
|
97
|
-
fs.mkdirSync(path.dirname(packageDir), { recursive: true });
|
|
98
94
|
if (cache != null) {
|
|
99
95
|
this._debug(`Package cache enabled, extraction resulted in a cache ${cache}`);
|
|
100
|
-
// Link the package into place.
|
|
101
|
-
this._debugTime(() => (0, link_1.link)(extractedTo, packageDir), `link(${extractedTo}, ${packageDir})`);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
// This is not from cache, so we move it around instead of copying.
|
|
105
|
-
(0, fs_1.renameSync)(extractedTo, packageDir);
|
|
106
96
|
}
|
|
107
97
|
}
|
|
108
98
|
finally {
|
|
@@ -312,7 +302,12 @@ class Kernel {
|
|
|
312
302
|
}
|
|
313
303
|
catch (e) {
|
|
314
304
|
this._debug('promise error:', e);
|
|
315
|
-
|
|
305
|
+
if (e.name === "@jsii/kernel.Fault" /* JsiiErrorType.JSII_FAULT */) {
|
|
306
|
+
throw new JsiiFault(e.message);
|
|
307
|
+
}
|
|
308
|
+
// default to RuntimeError, since non-kernel errors may not
|
|
309
|
+
// have their `name` field defined
|
|
310
|
+
throw new RuntimeError(e);
|
|
316
311
|
}
|
|
317
312
|
return {
|
|
318
313
|
result: this._fromSandbox(result, (_a = method.returns) !== null && _a !== void 0 ? _a : 'void', `returned by async method ${method.name}`),
|
|
@@ -338,7 +333,7 @@ class Kernel {
|
|
|
338
333
|
}
|
|
339
334
|
complete(req) {
|
|
340
335
|
var _a;
|
|
341
|
-
const { cbid, err, result } = req;
|
|
336
|
+
const { cbid, err, result, name } = req;
|
|
342
337
|
this._debug('complete', cbid, err, result);
|
|
343
338
|
const cb = this.waiting.get(cbid);
|
|
344
339
|
if (!cb) {
|
|
@@ -346,7 +341,9 @@ class Kernel {
|
|
|
346
341
|
}
|
|
347
342
|
if (err) {
|
|
348
343
|
this._debug('completed with error:', err);
|
|
349
|
-
cb.fail(
|
|
344
|
+
cb.fail(name === "@jsii/kernel.Fault" /* JsiiErrorType.JSII_FAULT */
|
|
345
|
+
? new JsiiFault(err)
|
|
346
|
+
: new RuntimeError(err));
|
|
350
347
|
}
|
|
351
348
|
else {
|
|
352
349
|
const sandoxResult = this._toSandbox(result, (_a = cb.expectedReturnType) !== null && _a !== void 0 ? _a : 'void', `returned by callback ${cb.toString()}`);
|
package/lib/recording.js
CHANGED
|
@@ -57,7 +57,7 @@ function recordInteraction(kernel, inputOutputLogPath) {
|
|
|
57
57
|
}
|
|
58
58
|
catch (e) {
|
|
59
59
|
logOutput({ error: e.message, name: e.name });
|
|
60
|
-
if (e.
|
|
60
|
+
if (e.name === "@jsii/kernel.RuntimeError" /* JsiiErrorType.RUNTIME_ERROR */) {
|
|
61
61
|
throw new kernel_1.RuntimeError(e.message);
|
|
62
62
|
}
|
|
63
63
|
throw new kernel_1.JsiiFault(e.message);
|
package/lib/tar-cache/index.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as tar from 'tar';
|
|
2
2
|
export declare type ExtractOptions = Omit<tar.ExtractOptions & tar.FileOptions, 'file' | 'cwd'>;
|
|
3
3
|
export interface ExtractResult {
|
|
4
|
-
/**
|
|
5
|
-
* The path in which the extracted files are located
|
|
6
|
-
*/
|
|
7
|
-
readonly path: string;
|
|
8
4
|
/**
|
|
9
5
|
* When `'hit'`, the data was already present in cache and was returned from
|
|
10
6
|
* cache.
|
|
@@ -25,7 +21,7 @@ export interface ExtractResult {
|
|
|
25
21
|
*
|
|
26
22
|
* @returns the result of the extraction.
|
|
27
23
|
*/
|
|
28
|
-
export declare function extract(file: string, options: ExtractOptions, ...comments: readonly string[]): ExtractResult;
|
|
24
|
+
export declare function extract(file: string, outDir: string, options: ExtractOptions, ...comments: readonly string[]): ExtractResult;
|
|
29
25
|
/** @internal */
|
|
30
26
|
export declare function getPackageCacheEnabled(): boolean;
|
|
31
27
|
/** @internal */
|
package/lib/tar-cache/index.js
CHANGED
|
@@ -3,10 +3,9 @@ var _a;
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.setPackageCacheEnabled = exports.getPackageCacheEnabled = exports.extract = void 0;
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const os_1 = require("os");
|
|
7
|
-
const path_1 = require("path");
|
|
8
6
|
const tar = require("tar");
|
|
9
7
|
const disk_cache_1 = require("../disk-cache");
|
|
8
|
+
const link_1 = require("../link");
|
|
10
9
|
const default_cache_root_1 = require("./default-cache-root");
|
|
11
10
|
let packageCacheEnabled = ((_a = process.env.JSII_RUNTIME_PACKAGE_CACHE) === null || _a === void 0 ? void 0 : _a.toLocaleUpperCase()) === 'enabled';
|
|
12
11
|
/**
|
|
@@ -18,27 +17,36 @@ let packageCacheEnabled = ((_a = process.env.JSII_RUNTIME_PACKAGE_CACHE) === nul
|
|
|
18
17
|
*
|
|
19
18
|
* @returns the result of the extraction.
|
|
20
19
|
*/
|
|
21
|
-
function extract(file, options, ...comments) {
|
|
22
|
-
|
|
20
|
+
function extract(file, outDir, options, ...comments) {
|
|
21
|
+
(0, fs_1.mkdirSync)(outDir, { recursive: true });
|
|
22
|
+
try {
|
|
23
|
+
return (packageCacheEnabled ? extractViaCache : extractToOutDir)(file, outDir, options, ...comments);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
(0, fs_1.rmSync)(outDir, { force: true, recursive: true });
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
23
29
|
}
|
|
24
30
|
exports.extract = extract;
|
|
25
|
-
function
|
|
31
|
+
function extractViaCache(file, outDir, options = {}, ...comments) {
|
|
26
32
|
var _a;
|
|
27
33
|
const cacheRoot = (_a = process.env.JSII_RUNTIME_PACKAGE_CACHE_ROOT) !== null && _a !== void 0 ? _a : (0, default_cache_root_1.defaultCacheRoot)();
|
|
28
|
-
const
|
|
29
|
-
const entry =
|
|
30
|
-
|
|
34
|
+
const dirCache = disk_cache_1.DiskCache.inDirectory(cacheRoot);
|
|
35
|
+
const entry = dirCache.entryFor(file, ...comments);
|
|
36
|
+
const { path, cache } = entry.lock((lock) => {
|
|
31
37
|
let cache = 'hit';
|
|
32
38
|
if (!entry.pathExists) {
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
// !!!IMPORTANT!!!
|
|
40
|
+
// Extract directly into the final target directory, as certain antivirus
|
|
41
|
+
// software configurations on Windows will make a `renameSync` operation
|
|
42
|
+
// fail with EPERM until the files have been fully analyzed.
|
|
43
|
+
(0, fs_1.mkdirSync)(entry.path, { recursive: true });
|
|
35
44
|
try {
|
|
36
45
|
untarInto({
|
|
37
46
|
...options,
|
|
38
|
-
cwd:
|
|
47
|
+
cwd: entry.path,
|
|
39
48
|
file,
|
|
40
49
|
});
|
|
41
|
-
(0, fs_1.renameSync)(tmpPath, entry.path);
|
|
42
50
|
}
|
|
43
51
|
catch (error) {
|
|
44
52
|
(0, fs_1.rmSync)(entry.path, { force: true, recursive: true });
|
|
@@ -49,11 +57,16 @@ function extractToCache(file, options = {}, ...comments) {
|
|
|
49
57
|
lock.touch();
|
|
50
58
|
return { path: entry.path, cache };
|
|
51
59
|
});
|
|
60
|
+
(0, link_1.link)(path, outDir);
|
|
61
|
+
return { cache };
|
|
52
62
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
function extractToOutDir(file, cwd, options = {}) {
|
|
64
|
+
// !!!IMPORTANT!!!
|
|
65
|
+
// Extract directly into the final target directory, as certain antivirus
|
|
66
|
+
// software configurations on Windows will make a `renameSync` operation
|
|
67
|
+
// fail with EPERM until the files have been fully analyzed.
|
|
68
|
+
untarInto({ ...options, cwd, file });
|
|
69
|
+
return {};
|
|
57
70
|
}
|
|
58
71
|
function untarInto(options) {
|
|
59
72
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsii/kernel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.70.0",
|
|
4
4
|
"description": "kernel for jsii execution environment",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -31,19 +31,19 @@
|
|
|
31
31
|
"package": "package-js"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@jsii/spec": "^1.
|
|
34
|
+
"@jsii/spec": "^1.70.0",
|
|
35
35
|
"fs-extra": "^10.1.0",
|
|
36
36
|
"lockfile": "^1.0.4",
|
|
37
37
|
"tar": "^6.1.11"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@scope/jsii-calc-base": "^1.
|
|
41
|
-
"@scope/jsii-calc-lib": "^1.
|
|
40
|
+
"@scope/jsii-calc-base": "^1.70.0",
|
|
41
|
+
"@scope/jsii-calc-lib": "^1.70.0",
|
|
42
42
|
"@types/fs-extra": "^9.0.13",
|
|
43
43
|
"@types/lockfile": "^1.0.2",
|
|
44
|
-
"@types/tar": "^6.1.
|
|
45
|
-
"jest-expect-message": "^1.1.
|
|
46
|
-
"jsii-build-tools": "^1.
|
|
44
|
+
"@types/tar": "^6.1.3",
|
|
45
|
+
"jest-expect-message": "^1.1.3",
|
|
46
|
+
"jsii-build-tools": "^1.70.0",
|
|
47
47
|
"jsii-calc": "^3.20.120"
|
|
48
48
|
}
|
|
49
49
|
}
|