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

Commit

Permalink
feat: snapshot in docker container when the local tools are not avail…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
DimitarTachev committed Sep 18, 2019
1 parent 561c597 commit 6861d22
Show file tree
Hide file tree
Showing 10 changed files with 301 additions and 82 deletions.
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

0 comments on commit 6861d22

Please sign in to comment.