diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000000..f7e554ce10
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,4 @@
+# Ensure that the shebang of our start script can be correctly interpreted
+
+bin/appbuilder.js eol=lf
+
diff --git a/.gitignore b/.gitignore
index da23d0d4ba..69dce8499d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,25 +1,37 @@
-# Logs
-logs
-*.log
-
-# Runtime data
-pids
-*.pid
-*.seed
+*.js
+!/*.js
+!bin/nativescript.js
+!vendor/*.js
+*.js.map
-# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+*.tgz
+*.tmp
+*.sublime-workspace
+tscommand*.tmp.txt
+.tscache/
+/lib/.d.ts
-# Coverage directory used by tools like istanbul
-coverage
-
-# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
-.grunt
+pids
+logs
+results
+scratch/
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/watcherTasks.xml
-# Compiled binary addons (http://nodejs.org/api/addons.html)
-build/Release
+test-reports.xml
-# Dependency directory
-# Deployed apps should consider commenting this line out:
-# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
+npm-debug.log
node_modules
+resources/App_Resources
+resources/Cordova
+resources/ItemTemplates
+resources/ProjectTemplates
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000000..386ca6c4fb
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "lib/common"]
+ path = lib/common
+ url = git@github.com:telerik/mobile-cli-lib.git
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000000..a3bf33e13a
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+nativescript-cli
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000000..e206d70d85
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000000..1162f43828
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000000..4b29c89c25
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/.idea/nativescript-cli.iml b/.idea/nativescript-cli.iml
new file mode 100644
index 0000000000..6b8184f8ef
--- /dev/null
+++ b/.idea/nativescript-cli.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/.idea/scopes/Nativescript_CLI_TypeScript.xml b/.idea/scopes/Nativescript_CLI_TypeScript.xml
new file mode 100644
index 0000000000..efb2748f34
--- /dev/null
+++ b/.idea/scopes/Nativescript_CLI_TypeScript.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
new file mode 100644
index 0000000000..922003b843
--- /dev/null
+++ b/.idea/scopes/scope_settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000000..c80f2198b5
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000000..da8a5d1de0
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,137 @@
+var util = require("util");
+
+var now = new Date().toISOString();
+
+function shallowCopy(obj) {
+ var result = {};
+ Object.keys(obj).forEach(function(key) {
+ result[key] = obj[key];
+ });
+ return result;
+}
+
+module.exports = function(grunt) {
+ grunt.initConfig({
+ copyPackageTo: "\\\\telerik.com\\Resources\\BlackDragon\\Builds\\nativescript-cli",
+
+ deploymentEnvironment: process.env["DeploymentEnvironment"] || "local",
+ jobName: process.env["JOB_NAME"] || "local",
+ buildNumber: process.env["BUILD_NUMBER"] || "non-ci",
+ dateString: now.substr(0, now.indexOf("T")),
+
+ pkg: grunt.file.readJSON("package.json"),
+
+ ts: {
+ options: {
+ target: 'es5',
+ module: 'commonjs',
+ sourceMap: true,
+ declaration: false,
+ removeComments: false
+ },
+
+ devlib: {
+ src: ["lib/**/*.ts"],
+ reference: "lib/.d.ts"
+ },
+
+ devall: {
+ src: ["lib/**/*.ts", "test/**/*.ts"],
+ reference: "lib/.d.ts"
+ },
+
+ release_build: {
+ src: ["lib/**/*.ts", "test/**/*.ts"],
+ reference: "lib/.d.ts",
+ options: {
+ sourceMap: false,
+ removeComments: true
+ }
+ }
+ },
+
+ watch: {
+ devall: {
+ files: ["lib/**/*.ts", 'test/**/*.ts'],
+ tasks: ['ts:devall'],
+ options: {
+ atBegin: true,
+ interrupt: true
+ }
+ }
+ },
+
+ shell: {
+ options: {
+ stdout: true,
+ stderr: true
+ },
+
+ build_package: {
+ command: "npm pack",
+ options: {
+ execOptions: {
+ env: (function() {
+ var env = shallowCopy(process.env);
+ env["NATIVESCRIPT_SKIP_POSTINSTALL_TASKS"] = "1";
+ return env;
+ })()
+ }
+ }
+ }
+ },
+
+ copy: {
+ package_to_drop_folder: {
+ src: "*.tgz",
+ dest: "<%= copyPackageTo %>/<%= jobName %>/<%= deploymentEnvironment %>/<%= dateString %> #<%= buildNumber %>/"
+ },
+ package_to_qa_drop_folder: {
+ src: "*.tgz",
+ dest: "<%= copyPackageTo %>/<%= jobName %>/<%= deploymentEnvironment %>/nativescript.tgz"
+ }
+ },
+
+ clean: {
+ src: ["test/**/*.js*", "lib/**/*.js*", "*.tgz"]
+ }
+ });
+
+ grunt.loadNpmTasks("grunt-contrib-clean");
+ grunt.loadNpmTasks("grunt-contrib-copy");
+ grunt.loadNpmTasks("grunt-contrib-watch");
+ grunt.loadNpmTasks("grunt-shell");
+ grunt.loadNpmTasks("grunt-ts");
+
+ grunt.registerTask("set_package_version", function(version) {
+ var fs = require("fs");
+ var buildVersion = version !== undefined ? version : process.env["BUILD_NUMBER"];
+ if (process.env["BUILD_CAUSE_GHPRBCAUSE"]) {
+ buildVersion = "PR" + buildVersion;
+ }
+
+ var packageJson = grunt.file.readJSON("package.json");
+ var versionParts = packageJson.version.split("-");
+ versionParts[1] = buildVersion;
+ packageJson.version = versionParts.join("-");
+ grunt.file.write("package.json", JSON.stringify(packageJson, null, " "));
+ });
+
+ grunt.registerTask("test", ["ts:devall", "shell:npm_test"]);
+ grunt.registerTask("pack", [
+ "clean",
+ "ts:release_build",
+ "shell:prepare_resources",
+
+ "shell:apply_deployment_environment",
+ "shell:ci_unit_tests",
+
+ "set_package_version",
+ "shell:build_package",
+
+ "copy:package_to_drop_folder",
+ "copy:package_to_qa_drop_folder"
+ ]);
+
+ grunt.registerTask("default", "ts:devlib");
+};
diff --git a/bin/nativescript b/bin/nativescript
new file mode 100644
index 0000000000..8876dd94d6
--- /dev/null
+++ b/bin/nativescript
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+AB_DIR="`dirname \"$0\"`"
+node "$AB_DIR/nativescript.js" $@
diff --git a/bin/nativescript.cmd b/bin/nativescript.cmd
new file mode 100644
index 0000000000..9074113019
--- /dev/null
+++ b/bin/nativescript.cmd
@@ -0,0 +1 @@
+@node %~dp0\nativescript.js %*
\ No newline at end of file
diff --git a/bin/nativescript.js b/bin/nativescript.js
new file mode 100644
index 0000000000..f44316be67
--- /dev/null
+++ b/bin/nativescript.js
@@ -0,0 +1,3 @@
+#!/usr/bin/env node
+
+require("../lib/nativescript-cli.js");
\ No newline at end of file
diff --git a/lib/bootstrap.ts b/lib/bootstrap.ts
new file mode 100644
index 0000000000..e7a290a099
--- /dev/null
+++ b/lib/bootstrap.ts
@@ -0,0 +1,4 @@
+global._ = require("underscore");
+global.$injector = require("./common/lib/yok").injector;
+
+$injector.require("nativescript-cli", "./nativescript-cli");
diff --git a/lib/common b/lib/common
new file mode 160000
index 0000000000..a4294787f9
--- /dev/null
+++ b/lib/common
@@ -0,0 +1 @@
+Subproject commit a4294787f9ce49b5de608ed02cfc08124594ab32
diff --git a/lib/nativescript-cli.ts b/lib/nativescript-cli.ts
new file mode 100644
index 0000000000..bbb1df0206
--- /dev/null
+++ b/lib/nativescript-cli.ts
@@ -0,0 +1,10 @@
+///
+
+import Fiber = require("fibers");
+
+require("./bootstrap");
+
+var fiber = Fiber(() => {
+});
+global.__main_fiber__ = fiber; // leak fiber to prevent it from being GC'd and thus corrupting V8
+fiber.run();
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000000..1d5163808d
--- /dev/null
+++ b/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "nativescript-cli",
+ "version": "0.1.0",
+ "author": "Telerik ",
+ "description": "Command-line interface for building NativeScript projects",
+ "bin": {
+ "nativescript": "./bin/nativescript.js"
+ },
+ "main": "./lib/nativescript-cli.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/NativeScript/nativescript-cli.git"
+ },
+ "keywords": [
+ "nativescript",
+ "appbuilder",
+ "telerik",
+ "mobile"
+ ],
+ "license": "Apache2.0",
+ "dependencies": {
+ "fibers": "https://github.com/icenium/node-fibers/tarball/master",
+ "log4js": "0.6.9",
+ "tabtab": "https://github.com/tailsu/node-tabtab/tarball/master",
+ "underscore": "1.5.2",
+ "unzip": "0.1.9",
+ "yargs": "1.2.2"
+ },
+ "analyze": true,
+ "devDependencies": {
+ "grunt": "0.4.2",
+ "grunt-ts": "1.11.2",
+ "grunt-contrib-clean": "0.5.0",
+ "grunt-contrib-watch": "0.5.3",
+ "grunt-shell": "0.6.4",
+ "grunt-contrib-copy": "0.5.0"
+ },
+ "license": "Apache-2.0",
+ "engines": {
+ "node": "~0.10.22"
+ }
+}