Skip to content

Commit

Permalink
LiveEdit 2.3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanaelA committed Sep 20, 2016
1 parent 3f57fff commit 40fc852
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 23 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# NativeScript Real Time LiveEdit Ability

A NativeScript module providing real time development for Android. This version is for v2.2.x of the Android Runtimes.
A NativeScript module providing real time development for Android. This version is for v2.3.x of the Android Runtimes.
Please note this project USED to be called NativeScript-LiveSync, but to eliminate the confusion between the Telerik LiveSync and my LiveSync, I decided to rename my project.

## License
Expand All @@ -26,6 +26,7 @@ The good news is they are catching up, they have fixed several major issues in e
* No extra code added to your application!
* Works on iOS Devices & iOS Simulator
* Support Angular2 projects
* Supports syncing multiple devices in sequence

#### Cons of Telerik's LiveSync:
* Not really Live. It syncs the files; but then has to restart the application from scratch when changing anything but a CSS or XML file.
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "nativescript-liveedit",
"version": "2.2.0",
"description": "A LiveEdit/LiveSync NativeScript module for Android v2.2.0 Runtimes",
"version": "2.3.0",
"description": "A LiveEdit/LiveSync NativeScript module for Android v2.3.0 Runtimes",
"main": "liveedit.js",
"nativescript": {
"platforms": {
"android": "2.2.0"
"android": "2.3.0"
}
},
"repository": {
Expand Down
Binary file modified platforms/android/nativescript.aar
Binary file not shown.
6 changes: 4 additions & 2 deletions support/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ var aarFileHashes = {
// These are the Original NativeScript Versions
"3f241535c547b017c8b187bc56ff81f7021626df": {version: "2.1.0", liveSync: false, upgrade: true},
"b2b2a6c9e0b535aa7bd00a042c2ac4af810282fa": {version: "2.1.1", liveSync: false, upgrade: true},
"3c1f676fa42dda8f09a1f92602dd58acce2ca58b": {version: "2.2.0", liveSync: false, convert: true},
"3c1f676fa42dda8f09a1f92602dd58acce2ca58b": {version: "2.2.0", liveSync: false, upgrade: true},
"67bbcc79d0dcbf42860ee1d81ab5ce4314e996c0": {version: "2.3.0", liveSync: false, convert: true},

// These are my Compiled versions
// I never made a 2.1.0 version
"6bf96a0e5856e26d91606934ed989cee66e5348a": {version: "2.1.1", liveSync: true, upgrade: true},
"3ca1e9080a41dd9f9fa7b66c5c0ae56071e8e05d": {version: "2.2.0", liveSync: true}
"3ca1e9080a41dd9f9fa7b66c5c0ae56071e8e05d": {version: "2.2.0", liveSync: true, upgrade: true},
"9b2cbc06ade5d0bbd5a8b03e7275b9d39181c135": {version: "2.3.0", liveSync: true}

};

Expand Down
116 changes: 99 additions & 17 deletions support/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
* I do contract work in most languages, so let me solve your problems!
*
* Any questions please feel free to email me or put a issue up on the github repo
* Version 0.1.7 Nathan@master-technology.com
* Version 0.2.1 Nathan@master-technology.com
*********************************************************************************/
"use strict";

/* global escape */
var TranspileTypeScript = true;

// Used for Demo's
var autoFocus = false;


// What is the current Test Mode allowed
var TM_AUTO = 0; // Automatically switch between Test most and normal mode depending on file saved
Expand All @@ -30,18 +33,32 @@ var APPMODE_NORMAL = "app.js";
var APPMODE_TEST = "./tns_modules/nativescript-unit-test-runner/app.js";
var appProjectData = null;

// DefaultActivity
var defaultActivity = "com.tns.NativeScriptActivity";

// Load our Requires
var fs = require('fs');
var cp = require('child_process');
var os = require('os');
var crypto = require('crypto');

// -------------------------------------------------------
// Handle Keystrokes

var readline = require('readline');
readline.emitKeypressEvents(process.stdin);
if (process.stdin.isTTY) {
process.stdin.setRawMode(true);
}
process.stdin.on('keypress', handleKeyStrokes);


// Configuration ----------------------------------------------
var watching = [".css", ".js", ".xml", ".ttf", ".otf", ".png", ".jpg"];
// ------------------------------------------------------------

console.log("\n------------------------------------------------------------");
console.log("NativeScript LiveEdit Watcher v0.17");
console.log("NativeScript LiveEdit Watcher v0.21");
console.log("(c)2015, 2016, Master Technology. www.master-technology.com");
console.log("------------------------------------------------------------");

Expand Down Expand Up @@ -87,7 +104,9 @@ if (!projectData.devDependencies || !projectData.devDependencies["nativescript-d
TranspileTypeScript = false;
}

// Set the Global wide
getPackageActivity();

// Set the Global wide error handler
setupErrorCatching();

console.log("Watching your project:", projectData.nativescript.id);
Expand Down Expand Up @@ -437,6 +456,7 @@ function futureAppLaunch() {
}

function restartApplication() {
focusApp();
var cmd = "adb shell am force-stop "+projectData.nativescript.id;
cp.exec(cmd, function(err, stdout) {
doLaunch();
Expand Down Expand Up @@ -481,8 +501,9 @@ function doLaunch() {
clearTimeout(isLaunchScheduled);
isLaunchScheduled = false;
}
focusApp();
console.log("Starting application...");
var child = cp.spawn('adb',['shell','am', 'start', '-S', projectData.nativescript.id + "/com.tns.NativeScriptActivity"], {stdio: "ignore", detached: true});
var child = cp.spawn('adb',['shell','am', 'start', '-S', projectData.nativescript.id + "/"+defaultActivity], {stdio: "ignore", detached: true});
child.unref();
}

Expand Down Expand Up @@ -836,18 +857,79 @@ function setupErrorCatching() {
});
}

/*
// TODO: see if we can get access before retry
process.stdin.on('readable', function() {
var chunk = process.stdin.read();
if (chunk !== null) {
process.stdout.write('data: ' + chunk);
}
});
function getPackageActivity() {
var data = fs.readFileSync('app/App_Resources/Android/AndroidManifest.xml').toString();

process.stdin.on('end', function() {
process.stdout.write('end');
});
process.stdin.resume();
// We aren't going to send this through a full xml parse; just do some simple string slicing to grab a single value out
// TODO: Maybe send it through an XML parser to be more accurate
var start = 0, offset, found = false, endOffset;
do {
offset = data.indexOf('<activity', start);
if (offset > -1) {
endOffset = data.indexOf('>', offset);
if (data[endOffset-1] !== '/') {
endOffset = data.indexOf("</activity>", offset);
}
var stringData = data.substring(offset, endOffset);
if (stringData.indexOf('android.intent.action.MAIN')) {
found = true;
offset = stringData.indexOf("android:name=") + 14;
endOffset = stringData.indexOf('"', offset+1);
var name = stringData.substring(offset, endOffset);
if (name.length && defaultActivity !== name) {
defaultActivity = name;
console.log("Using custom activity:", name);
}
}

*/
start = offset+1;
}
} while (offset > -1 && !found);
}

function handleKeyStrokes(str, key) {
if (str === "r") {
restartApplication();
} else if (str === "m") {
if (commandLine.testMode === TM_ALWAYS) {
console.log("Setting to be Test mode: Auto");
commandLine.testMode = TM_AUTO;
} else if (commandLine.testMode === TM_AUTO) {
console.log("Setting to be Test mode: Never");
commandLine.testMode = TM_NEVER;
} else if (commandLine.testMode === TM_NEVER) {
console.log("Setting to be Test mode: Always");
commandLine.testMode = TM_ALWAYS;
}
} else if (str === "t") {
setAppMode(CM_TESTMODE, true);
restartApplication();
} else if (str === "n") {
setAppMode(CM_NORMAL, true);
restartApplication();
} else if (str === "a") {
startAppium();
} else if (str === "d") {
// Start Debugger
} else if (str === "q") {
process.exit();
} else if (key.ctrl === true && key.name === 'c') {
process.exit();
}

}

function focusApp() {
if (!autoFocus) { return; }
// Focus.js = (new ActiveXObject("WScript.Shell")).AppActivate("Genymotion");
cp.execSync("cscript //nologo //E:jscript focus.js");
}

function startAppium() {
if (fs.existsSync("node_modules\\nativescript-dev-appium")) {
setAppMode(CM_NORMAL, true);
console.log("Starting NativeScript-Appium");
cp.spawn("node", ["node_modules\\nativescript-dev-appium\\test-runner.js"], {stdio: 'inherit'});
focusApp();
}
}

0 comments on commit 40fc852

Please sign in to comment.