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

feat: support snapshots in Docker #1048

Merged
merged 6 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/NativeScriptSnapshotPlugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ exports.NativeScriptSnapshotPlugin = (function () {
useLibs: options.useLibs,
androidNdkPath: options.androidNdkPath,
v8Version: options.v8Version,
snapshotInDocker: options.snapshotInDocker
}).then(() => {
// Make the original files empty
inputFiles.forEach(inputFile =>
Expand Down
9 changes: 6 additions & 3 deletions plugins/NativeScriptSnapshotPlugin/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"type": "string"
},
"angular": {
"type": "boolean",
"default": false
"type": "boolean",
"default": false
},
"chunk": {
"type": "string"
Expand Down Expand Up @@ -39,6 +39,9 @@
"type": "boolean",
"default": false
},
"snapshotInDocker": {
"type": "boolean"
},
"v8Version": {
"type": "string"
},
Expand All @@ -56,4 +59,4 @@
"webpackConfig"
],
"additionalProperties": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ module.exports = function parseProjectSnapshotGeneratorArgs() {
result.useLibs = parseBool(result.useLibs);
}

if (result.snapshotInDocker !== undefined) {
result.snapshotInDocker = parseBool(result.snapshotInDocker);
}

if (result.install !== undefined) {
result.install = parseBool(result.install);
}
Expand All @@ -22,7 +26,7 @@ function parseJsonFromProcessArgs() {

var currentKey = "";
var currentValue = "";
args.forEach(function(value, index, array) {
args.forEach(function (value, index, array) {
if (value.startsWith("--")) { // if is key
addKeyAndValueToResult(currentKey, currentValue, result);
currentKey = value.slice(2);
Expand Down
11 changes: 7 additions & 4 deletions snapshot/android/project-snapshot-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ ProjectSnapshotGenerator.installSnapshotArtefacts = function (projectRoot) {
shelljs.cp("-R", blobsSrcPath + "/", resolve(appPath, "../snapshots"));

/*
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.
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.
*/
shelljs.exec("find " + blobsDestinationPath + " -name '*.blob' -execdir mv {} snapshot.blob ';'");

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

// try to get the V8 Version from the settings.json file in android runtime folder
const runtimeV8Version = getAndroidV8Version(this.options.projectRoot);
if(runtimeV8Version) {
if (runtimeV8Version) {
return resolve(runtimeV8Version);
}

Expand All @@ -184,7 +186,7 @@ ProjectSnapshotGenerator.prototype.getV8Version = function (generationOptions) {
const version = findV8Version(runtimeVersion, latestVersionsMap)
return resolve(version);
})
.catch(reject);
.catch(reject);
} else {
return resolve(v8Version);
}
Expand Down Expand Up @@ -254,7 +256,8 @@ ProjectSnapshotGenerator.prototype.generate = function (generationOptions) {
useLibs: generationOptions.useLibs || false,
inputFiles: generationOptions.inputFiles || [join(this.options.projectRoot, "__snapshot.js")],
androidNdkPath,
mksnapshotParams: mksnapshotParams
mksnapshotParams: mksnapshotParams,
snapshotInDocker: generationOptions.snapshotInDocker
};

return generator.generate(options).then(() => {
Expand Down
Loading