Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 6861d22

Browse files
committed
feat: snapshot in docker container when the local tools are not available
1 parent 561c597 commit 6861d22

10 files changed

+301
-82
lines changed

Diff for: plugins/NativeScriptSnapshotPlugin/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ exports.NativeScriptSnapshotPlugin = (function () {
113113
useLibs: options.useLibs,
114114
androidNdkPath: options.androidNdkPath,
115115
v8Version: options.v8Version,
116+
snapshotInDocker: options.snapshotInDocker
116117
}).then(() => {
117118
// Make the original files empty
118119
inputFiles.forEach(inputFile =>

Diff for: plugins/NativeScriptSnapshotPlugin/options.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"type": "string"
66
},
77
"angular": {
8-
"type": "boolean",
9-
"default": false
8+
"type": "boolean",
9+
"default": false
1010
},
1111
"chunk": {
1212
"type": "string"
@@ -39,6 +39,9 @@
3939
"type": "boolean",
4040
"default": false
4141
},
42+
"snapshotInDocker": {
43+
"type": "boolean"
44+
},
4245
"v8Version": {
4346
"type": "string"
4447
},
@@ -56,4 +59,4 @@
5659
"webpackConfig"
5760
],
5861
"additionalProperties": false
59-
}
62+
}

Diff for: snapshot/android/project-snapshot-generator-cli-ags-parser.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module.exports = function parseProjectSnapshotGeneratorArgs() {
99
result.useLibs = parseBool(result.useLibs);
1010
}
1111

12+
if (result.snapshotInDocker !== undefined) {
13+
result.snapshotInDocker = parseBool(result.snapshotInDocker);
14+
}
15+
1216
if (result.install !== undefined) {
1317
result.install = parseBool(result.install);
1418
}
@@ -22,7 +26,7 @@ function parseJsonFromProcessArgs() {
2226

2327
var currentKey = "";
2428
var currentValue = "";
25-
args.forEach(function(value, index, array) {
29+
args.forEach(function (value, index, array) {
2630
if (value.startsWith("--")) { // if is key
2731
addKeyAndValueToResult(currentKey, currentValue, result);
2832
currentKey = value.slice(2);

Diff for: snapshot/android/project-snapshot-generator.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ ProjectSnapshotGenerator.installSnapshotArtefacts = function (projectRoot) {
114114
shelljs.cp("-R", blobsSrcPath + "/", resolve(appPath, "../snapshots"));
115115

116116
/*
117-
Rename TNSSnapshot.blob files to snapshot.blob files. The xxd tool uses the file name for the name of the static array. This is why the *.blob files are initially named TNSSnapshot.blob. After the xxd step, they must be renamed to snapshot.blob, because this is the filename that the Android runtime is looking for.
117+
Rename TNSSnapshot.blob files to snapshot.blob files. The xxd tool uses the file name for the name of the static array.
118+
This is why the *.blob files are initially named TNSSnapshot.blob.
119+
After the xxd step, they must be renamed to snapshot.blob, because this is the filename that the Android runtime is looking for.
118120
*/
119121
shelljs.exec("find " + blobsDestinationPath + " -name '*.blob' -execdir mv {} snapshot.blob ';'");
120122

@@ -170,7 +172,7 @@ ProjectSnapshotGenerator.prototype.getV8Version = function (generationOptions) {
170172

171173
// try to get the V8 Version from the settings.json file in android runtime folder
172174
const runtimeV8Version = getAndroidV8Version(this.options.projectRoot);
173-
if(runtimeV8Version) {
175+
if (runtimeV8Version) {
174176
return resolve(runtimeV8Version);
175177
}
176178

@@ -184,7 +186,7 @@ ProjectSnapshotGenerator.prototype.getV8Version = function (generationOptions) {
184186
const version = findV8Version(runtimeVersion, latestVersionsMap)
185187
return resolve(version);
186188
})
187-
.catch(reject);
189+
.catch(reject);
188190
} else {
189191
return resolve(v8Version);
190192
}
@@ -254,7 +256,8 @@ ProjectSnapshotGenerator.prototype.generate = function (generationOptions) {
254256
useLibs: generationOptions.useLibs || false,
255257
inputFiles: generationOptions.inputFiles || [join(this.options.projectRoot, "__snapshot.js")],
256258
androidNdkPath,
257-
mksnapshotParams: mksnapshotParams
259+
mksnapshotParams: mksnapshotParams,
260+
snapshotInDocker: generationOptions.snapshotInDocker
258261
};
259262

260263
return generator.generate(options).then(() => {

0 commit comments

Comments
 (0)