You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/08/09 01:04:34 UTC
[09/14] git commit: Rewrite tooling/platform scripts from WSH to
NodeJS
Rewrite tooling/platform scripts from WSH to NodeJS
Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/5ce7b168
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/5ce7b168
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/5ce7b168
Branch: refs/heads/master
Commit: 5ce7b168087f96214f9c49cc148fc3f18de05f9e
Parents: 320ea2b
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Mon Jul 14 16:29:44 2014 +0400
Committer: sgrebnov <v-...@microsoft.com>
Committed: Fri Aug 8 19:33:59 2014 +0400
----------------------------------------------------------------------
windows/bin/check_reqs | 54 +-
windows/bin/check_reqs.bat | 8 +-
windows/bin/check_reqs.js | 96 -
windows/bin/create | 39 +
windows/bin/create.bat | 8 +-
windows/bin/create.js | 232 ---
windows/bin/lib/check_reqs.js | 41 +
windows/bin/lib/create.js | 82 +
windows/bin/lib/update.js | 72 +
windows/bin/update | 34 +
windows/bin/update.bat | 8 +-
windows/bin/update.js | 210 --
windows/cordova.js | 1598 +++++++++++++++
windows/node_modules/.bin/nopt | 15 +
windows/node_modules/.bin/nopt.cmd | 5 +
windows/node_modules/.bin/shjs | 15 +
windows/node_modules/.bin/shjs.cmd | 5 +
windows/node_modules/node-uuid/.npmignore | 2 +
windows/node_modules/node-uuid/LICENSE.md | 2 +
windows/node_modules/node-uuid/README.md | 207 ++
windows/node_modules/node-uuid/component.json | 18 +
windows/node_modules/node-uuid/package.json | 35 +
windows/node_modules/node-uuid/uuid.js | 245 +++
windows/node_modules/nopt/.npmignore | 1 +
windows/node_modules/nopt/LICENSE | 23 +
windows/node_modules/nopt/README.md | 209 ++
windows/node_modules/nopt/bin/nopt.js | 54 +
.../node_modules/nopt/examples/my-program.js | 30 +
windows/node_modules/nopt/lib/nopt.js | 414 ++++
.../nopt/node_modules/abbrev/CONTRIBUTING.md | 3 +
.../nopt/node_modules/abbrev/LICENSE | 23 +
.../nopt/node_modules/abbrev/README.md | 23 +
.../nopt/node_modules/abbrev/abbrev.js | 62 +
.../nopt/node_modules/abbrev/package.json | 29 +
.../nopt/node_modules/abbrev/test.js | 47 +
windows/node_modules/nopt/package.json | 41 +
windows/node_modules/nopt/test/basic.js | 251 +++
windows/node_modules/q/CONTRIBUTING.md | 40 +
windows/node_modules/q/LICENSE | 18 +
windows/node_modules/q/README.md | 820 ++++++++
.../q/benchmark/compare-with-callbacks.js | 71 +
windows/node_modules/q/benchmark/scenarios.js | 36 +
windows/node_modules/q/package.json | 93 +
windows/node_modules/q/q.js | 1904 ++++++++++++++++++
windows/node_modules/q/queue.js | 35 +
windows/node_modules/shelljs/.documentup.json | 6 +
windows/node_modules/shelljs/.jshintrc | 7 +
windows/node_modules/shelljs/.npmignore | 2 +
windows/node_modules/shelljs/.travis.yml | 5 +
windows/node_modules/shelljs/LICENSE | 26 +
windows/node_modules/shelljs/README.md | 569 ++++++
windows/node_modules/shelljs/bin/shjs | 51 +
windows/node_modules/shelljs/global.js | 3 +
windows/node_modules/shelljs/make.js | 47 +
windows/node_modules/shelljs/package.json | 47 +
.../shelljs/scripts/generate-docs.js | 21 +
.../node_modules/shelljs/scripts/run-tests.js | 50 +
windows/node_modules/shelljs/shell.js | 157 ++
windows/node_modules/shelljs/src/cat.js | 43 +
windows/node_modules/shelljs/src/cd.js | 19 +
windows/node_modules/shelljs/src/chmod.js | 208 ++
windows/node_modules/shelljs/src/common.js | 203 ++
windows/node_modules/shelljs/src/cp.js | 201 ++
windows/node_modules/shelljs/src/dirs.js | 191 ++
windows/node_modules/shelljs/src/echo.js | 20 +
windows/node_modules/shelljs/src/error.js | 10 +
windows/node_modules/shelljs/src/exec.js | 181 ++
windows/node_modules/shelljs/src/find.js | 51 +
windows/node_modules/shelljs/src/grep.js | 52 +
windows/node_modules/shelljs/src/ln.js | 53 +
windows/node_modules/shelljs/src/ls.js | 126 ++
windows/node_modules/shelljs/src/mkdir.js | 68 +
windows/node_modules/shelljs/src/mv.js | 80 +
windows/node_modules/shelljs/src/popd.js | 1 +
windows/node_modules/shelljs/src/pushd.js | 1 +
windows/node_modules/shelljs/src/pwd.js | 11 +
windows/node_modules/shelljs/src/rm.js | 145 ++
windows/node_modules/shelljs/src/sed.js | 43 +
windows/node_modules/shelljs/src/tempdir.js | 56 +
windows/node_modules/shelljs/src/test.js | 85 +
windows/node_modules/shelljs/src/to.js | 29 +
windows/node_modules/shelljs/src/toEnd.js | 29 +
windows/node_modules/shelljs/src/which.js | 83 +
windows/package.json | 6 +
windows/template/CordovaApp.Store80.jsproj | 2 +-
windows/template/cordova/build | 34 +
windows/template/cordova/build.bat | 8 +-
windows/template/cordova/clean | 32 +
windows/template/cordova/clean.bat | 8 +-
.../cordova/lib/ApplyPlatformConfig.ps1 | 4 +-
windows/template/cordova/lib/build.js | 305 +--
windows/template/cordova/lib/clean.js | 83 +-
windows/template/cordova/lib/deploy.js | 461 -----
windows/template/cordova/lib/exec.js | 38 +
windows/template/cordova/lib/list-devices.bat | 10 +-
windows/template/cordova/lib/log.js | 77 -
windows/template/cordova/lib/package.js | 183 ++
windows/template/cordova/lib/run.js | 93 +
windows/template/cordova/lib/spawn.js | 40 +
windows/template/cordova/lib/target-list.js | 233 ---
windows/template/cordova/lib/utils.js | 93 +
windows/template/cordova/node_modules/.bin/nopt | 15 +
.../template/cordova/node_modules/.bin/nopt.cmd | 5 +
.../cordova/node_modules/nopt/.npmignore | 1 +
.../template/cordova/node_modules/nopt/LICENSE | 23 +
.../cordova/node_modules/nopt/README.md | 209 ++
.../cordova/node_modules/nopt/bin/nopt.js | 54 +
.../node_modules/nopt/examples/my-program.js | 30 +
.../cordova/node_modules/nopt/lib/nopt.js | 414 ++++
.../nopt/node_modules/abbrev/CONTRIBUTING.md | 3 +
.../nopt/node_modules/abbrev/LICENSE | 23 +
.../nopt/node_modules/abbrev/README.md | 23 +
.../nopt/node_modules/abbrev/abbrev.js | 62 +
.../nopt/node_modules/abbrev/package.json | 29 +
.../nopt/node_modules/abbrev/test.js | 47 +
.../cordova/node_modules/nopt/package.json | 41 +
.../cordova/node_modules/nopt/test/basic.js | 251 +++
.../cordova/node_modules/q/CONTRIBUTING.md | 40 +
windows/template/cordova/node_modules/q/LICENSE | 18 +
.../template/cordova/node_modules/q/README.md | 820 ++++++++
.../q/benchmark/compare-with-callbacks.js | 71 +
.../node_modules/q/benchmark/scenarios.js | 36 +
.../cordova/node_modules/q/package.json | 93 +
windows/template/cordova/node_modules/q/q.js | 1904 ++++++++++++++++++
.../template/cordova/node_modules/q/queue.js | 35 +
windows/template/cordova/run | 34 +
windows/template/cordova/run.bat | 8 +-
127 files changed, 14567 insertions(+), 1670 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/check_reqs
----------------------------------------------------------------------
diff --git a/windows/bin/check_reqs b/windows/bin/check_reqs
index 9b73d88..19b5c80 100644
--- a/windows/bin/check_reqs
+++ b/windows/bin/check_reqs
@@ -1,24 +1,34 @@
-#! /bin/sh
+#!/usr/bin/env node
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
-echo "ERROR: Cordova tooling for Windows 8 requires Windows 8 Professional with the 'msbuild' command "
-echo " in the PATH environment variable as well as having .NET Framework 4.0 (from WP SDK's)"
-exit 1
\ No newline at end of file
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+var check_reqs = require('./lib/check_reqs');
+
+// check for help flag
+if (process.argv[2] == '--help' || process.argv[2] == '/?' || process.argv[2] == '-h' ||
+ process.argv[2] == 'help' || process.argv[2] == '-help' || process.argv[2] == '/help') {
+ check_reqs.help();
+} else {
+ check_reqs.run().done(function success(msbuild) {
+ console.log('Found msbuild ver.', msbuild.version, 'at', msbuild.path);
+ }, function (err) {
+ console.error('Failed to check requirements due to', err);
+ });
+}
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/check_reqs.bat
----------------------------------------------------------------------
diff --git a/windows/bin/check_reqs.bat b/windows/bin/check_reqs.bat
index 393e824..683914b 100644
--- a/windows/bin/check_reqs.bat
+++ b/windows/bin/check_reqs.bat
@@ -15,11 +15,11 @@
:: specific language governing permissions and limitations
:: under the License
@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%check_reqs.js (
- cscript "%full_path%check_reqs.js" %* //nologo
+SET script_path="%~dp0check_reqs"
+IF EXIST %script_path% (
+ node "%script_path%" %*
) ELSE (
ECHO.
- ECHO ERROR: Could not find 'check_reqs.js' in 'bin' folder, aborting...>&2
+ ECHO ERROR: Could not find 'check_reqs' script in 'bin' folder, aborting...>&2
EXIT /B 1
)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/check_reqs.js
----------------------------------------------------------------------
diff --git a/windows/bin/check_reqs.js b/windows/bin/check_reqs.js
deleted file mode 100644
index fd0fd8c..0000000
--- a/windows/bin/check_reqs.js
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-
-var args = WScript.Arguments;
-var wscript_shell = WScript.CreateObject("WScript.Shell");
-
-function Usage() {
- Log("Usage: [ check_reqs | cscript check_reqs.js ]");
- Log("examples:");
- Log(" cscript C:\\Users\\anonymous\\cordova-windows\\windows8\\bin\\check_reqs.js");
- Log(" CordovaWindowsPhone\\bin\\check_reqs");
-
-}
-
-// log to stdout or stderr
-function Log(msg, error) {
- if (error) {
- WScript.StdErr.WriteLine(msg);
- }
- else {
- WScript.StdOut.WriteLine(msg);
- }
-}
-
-// gets the output from a command, failing with the given error message
-function check_command(cmd, fail_msg) {
- Log("CMD:"+cmd);
- var out = wscript_shell.Exec(cmd);
- while (out.Status == 0) {
- WScript.Sleep(100);
- }
-
- //Check that command executed
- if (!out.StdErr.AtEndOfStream) {
- var line = out.StdErr.ReadLine();
- Log(fail_msg, true);
- Log('Output : ' + line, true);
- WScript.Quit(1);
- }
-
- if (!out.StdOut.AtEndOfStream) {
- var line = out.StdOut.ReadAll();
- return line;
- }
- else {
- Log('Unable to get output from command "' + cmd + '"', true);
- WScript.Quit(1);
- }
-}
-
-
-if (args.Count() > 0) {
- Usage();
- WScript.Quit(1);
-}
-else
-{
-/* The tooling for cordova windows phone requires these commands
- * in the environment PATH variable.
- * - msbuild (ex. C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319)
- */
- var version;
-
- try {
- version = wscript_shell.RegRead("HKLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\4.0\\MSBuildRuntimeVersion");
- if(version != null && version.indexOf("4.0") == 0) {
- // All good!
- Log(version);
- }
- else {
- throw(new Error("version not 4.0"));
- }
- }
- catch(err) {
- Log('Please install the .NET Framework v4.0 (part of the latest windows phone SDK\'s).', true);
- WScript.Quit(2);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/create
----------------------------------------------------------------------
diff --git a/windows/bin/create b/windows/bin/create
new file mode 100644
index 0000000..3869d8b
--- /dev/null
+++ b/windows/bin/create
@@ -0,0 +1,39 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+/*
+ * create a cordova/windows8 project
+ * USAGE
+ * ./create [path package activity]
+ * ./bin/create.bat C:\Users\Me\MyTestProj "test.proj" "TestProject"
+ */
+
+var create = require('./lib/create');
+
+// check for help flag
+if (process.argv[2] == '--help' || process.argv[2] == '/?' || process.argv[2] == '-h' ||
+ process.argv[2] == 'help' || process.argv[2] == '-help' || process.argv[2] == '/help') {
+ check_reqs.help();
+} else {
+ create.run(process.argv).done(null, function (err) {
+ console.error('Failed to check requirements due to', err);
+ });
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/create.bat
----------------------------------------------------------------------
diff --git a/windows/bin/create.bat b/windows/bin/create.bat
index 0f3ef7a..58690eb 100644
--- a/windows/bin/create.bat
+++ b/windows/bin/create.bat
@@ -15,11 +15,11 @@
:: specific language governing permissions and limitations
:: under the License
@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%create.js (
- cscript "%full_path%create.js" %* //nologo
+SET script_path="%~dp0create"
+IF EXIST %script_path% (
+ node %script_path% %*
) ELSE (
ECHO.
- ECHO ERROR: Could not find 'create.js' in 'bin' folder, aborting...>&2
+ ECHO ERROR: Could not find 'create' script in 'bin' folder, aborting...>&2
EXIT /B 1
)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/create.js
----------------------------------------------------------------------
diff --git a/windows/bin/create.js b/windows/bin/create.js
deleted file mode 100644
index 2cc5ed3..0000000
--- a/windows/bin/create.js
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-/*
- * create a cordova/windows8 project
- *
- * USAGE
- * ./create [path package activity]
-
- ./bin/create.bat C:\Users\Me\MyTestProj "test.proj" "TestProject"
- */
-
-
-var fso=WScript.CreateObject("Scripting.FileSystemObject");
-var wscript_shell = WScript.CreateObject("WScript.Shell");
-// working dir
-var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');
-
-var args = WScript.Arguments,
- TEMPLATES_PATH = '\\template',
- // default template to use when creating the project
- CREATE_TEMPLATE = TEMPLATES_PATH,
- PROJECT_PATH,
- PACKAGE,
- NAME,
- GUID;
-
-// File System Object constants
-var ForReading = 1, ForWriting = 2, ForAppending = 8;
-var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
-
-function Usage() {
- Log("Usage: create PathTONewProject [ PackageName AppName ]");
- Log(" PathTONewProject : The path to where you wish to create the project");
- Log(" PackageName : The namespace for the project (default is Cordova.Example)")
- Log(" AppName : The name of the application (default is CordovaAppProj)");
- Log("examples:");
- Log(" create C:\\Users\\anonymous\\Desktop\\MyProject");
- Log(" create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp");
-}
-
-// logs messaged to stdout and stderr
-function Log(msg, isError) {
- if (isError) {
- WScript.StdErr.WriteLine(msg);
- }
- else {
- WScript.StdOut.WriteLine(msg);
- }
-}
-
-function read(filename) {
- var f=fso.OpenTextFile(filename, 1,2);
- var s=f.ReadAll();
- f.Close();
- return s;
-}
-
-function write(filename, contents) {
- var f=fso.OpenTextFile(filename, ForWriting, TristateTrue);
- f.Write(contents);
- f.Close();
-}
-
-function replaceInFile(filename, regexp, replacement) {
- write(filename,read(filename).replace(regexp,replacement));
-}
-
-
-// executes a commmand in the shell
-function exec(command) {
- var oShell=wscript_shell.Exec(command);
- while (oShell.Status == 0) {
- WScript.sleep(100);
- }
-}
-
-// executes a commmand in the shell
-function exec_verbose(command) {
- //Log("Command: " + command);
- var oShell=wscript_shell.Exec(command);
- while (oShell.Status == 0) {
- //Wait a little bit so we're not super looping
- WScript.sleep(100);
- //Print any stdout output from the script
- if (!oShell.StdOut.AtEndOfStream) {
- var line = oShell.StdOut.ReadLine();
- Log(line);
- }
- }
- //Check to make sure our scripts did not encounter an error
- if (!oShell.StdErr.AtEndOfStream) {
- var line = oShell.StdErr.ReadAll();
- Log(line, true);
- WScript.Quit(1);
- }
-}
-
-//generate guid for the project
-function genGuid() {
- var TypeLib = WScript.CreateObject("Scriptlet.TypeLib");
- strGuid = TypeLib.Guid.split("}")[0]; // there is extra crap after the } that is causing file streams to break, probably an EOF ...
- strGuid = strGuid.replace(/[\{\}]/g,"");
- return strGuid;
-}
-
-// deletes the path element if it exists
-function delete_if_exists(path) {
- if (fso.FolderExists(path)) {
- fso.DeleteFolder(path);
- }
- else if (fso.FileExists(path)) {
- fso.DeleteFile(path);
- }
-}
-
-
-// creates new project in path, with the given package and app name
-function create(destPath, namespace, name, guid) {
- Log("Creating Cordova Windows Project:");
- Log("\tApp Name : " + name);
- Log("\tNamespace : " + namespace);
- Log("\tPath : " + destPath);
-
- var safeProjectName = name.replace(/(\.\s|\s\.|\s+|\.+)/g, '_');
-
- var srcPath = ROOT + CREATE_TEMPLATE;
-
- // Copy the template source files to the new destination
- fso.CopyFolder(srcPath,destPath);
- // Copy our unique VERSION file, so peeps can tell what version this project was created from.
- fso.CopyFile(ROOT +'\\VERSION',destPath + "\\" );
-
- var newProjGuid = guid || genGuid();
-
- // replace the guid in the AppManifest and deploy script
- replaceInFile(destPath + "\\package.store.appxmanifest",/\$guid1\$/g,newProjGuid);
- replaceInFile(destPath + "\\package.store80.appxmanifest",/\$guid1\$/g,newProjGuid);
- replaceInFile(destPath + "\\package.phone.appxmanifest",/\$guid1\$/g,newProjGuid);
-
- replaceInFile(destPath + "\\cordova\\lib\\deploy.js",/\$guid1\$/g,newProjGuid);
- replaceInFile(destPath + "\\cordova\\lib\\deploy.js",/\$namespace\$/g,namespace);
-
- // replace $safeprojectname$ and $projectname$ in AppManifest
- replaceInFile(destPath + "\\package.store.appxmanifest",/\$safeprojectname\$/g,safeProjectName);
- replaceInFile(destPath + "\\package.store80.appxmanifest",/\$safeprojectname\$/g,safeProjectName);
- replaceInFile(destPath + "\\package.phone.appxmanifest",/\$safeprojectname\$/g,safeProjectName);
- replaceInFile(destPath + "\\package.store.appxmanifest",/\$projectname\$/g,name);
- replaceInFile(destPath + "\\package.store80.appxmanifest",/\$projectname\$/g,name);
- replaceInFile(destPath + "\\package.phone.appxmanifest",/\$projectname\$/g,name);
-
- // cleanup
-
- // Delete bld forder and bin folder
-
- delete_if_exists(destPath + "\\bld");
- delete_if_exists(destPath + "\\bin");
- delete_if_exists(destPath + "\\*.user");
- delete_if_exists(destPath + "\\*.suo");
- delete_if_exists(destPath + "\\MyTemplate.vstemplate");
-
- // TODO: Name the project according to the arguments
- // update the solution to include the new project by name
- // version BS
- // index.html title set to project name ?
-
- Log("Project created");
-}
-
-if (args.Count() > 0) {
- // support help flags
- if (args(0) == "--help" || args(0) == "/?" ||
- args(0) == "help" || args(0) == "-help" || args(0) == "/help" || args(0) == "-h") {
- Usage();
- WScript.Quit(1);
- }
-
- PROJECT_PATH = args(0);
- if (fso.FolderExists(PROJECT_PATH)) {
- Log("Project directory already exists:", true);
- Log("\t" + PROJECT_PATH, true);
- Log("CREATE FAILED.", true);
- WScript.Quit(1);
- }
-
- if (args.Count() > 1) {
- PACKAGE = args(1);
- }
- else {
- PACKAGE = "Cordova.Example";
- }
-
- if (args.Count() > 2) {
- NAME = args(2);
- }
- else {
- NAME = "CordovaAppProj";
- }
-
- if (args.Count() > 3) {
- var guid_regex = /\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}/;
- if (args(3).substr(0,7) == "--guid=" && args(3).match(guid_regex)) {
- GUID = args(3).split
- } else {
- Log("Did not recognize argument '" + args(3) + "'. If your trying to add a GUID make sure it's in the proper format.");
- WScript.Quit(2);
- }
- }
-
- create(PROJECT_PATH, PACKAGE, NAME, GUID);
-}
-else {
- Usage();
- WScript.Quit(1);
-}
-
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/windows/bin/lib/check_reqs.js b/windows/bin/lib/check_reqs.js
new file mode 100644
index 0000000..1335b20
--- /dev/null
+++ b/windows/bin/lib/check_reqs.js
@@ -0,0 +1,41 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+var Q = require('Q'),
+ os = require('os'),
+ utils = require('../../template/cordova/lib/utils');
+
+module.exports.help = function () {
+ Log("Usage: [ check_reqs | node check_reqs ]");
+ Log("examples:");
+ Log(" cscript C:\\Users\\anonymous\\cordova-windows\\windows8\\bin\\check_reqs.bat");
+ Log(" CordovaWindowsPhone\\bin\\check_reqs");
+};
+
+module.exports.run = function () {
+ if (os.platform() != 'win32'){
+ // Build Universal windows apps available for windows platform only, so we reject on others platforms
+ return Q.reject(
+ "ERROR: Cordova tooling for Windows 8 requires Windows 8 Professional with the 'msbuild' command\n" +
+ "in the PATH environment variable as well as having .NET Framework 4.0 (from WP SDK's)"
+ );
+ }
+ // Check for MSBuild available
+ return utils.getMSBuild();
+};
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/windows/bin/lib/create.js b/windows/bin/lib/create.js
new file mode 100644
index 0000000..8e00eff
--- /dev/null
+++ b/windows/bin/lib/create.js
@@ -0,0 +1,82 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+var Q = require('Q'),
+ fs = require('fs'),
+ path = require('path'),
+ nopt = require('nopt'),
+ shell = require('shelljs'),
+ uuid = require('node-uuid');
+
+// Creates cordova-windows project at specified path with specified namespace, app name and GUID
+module.exports.run = function (argv) {
+
+ // Parse args
+ var args = nopt({"guid": String}, {}, argv);
+
+ // Set parameters/defaults for create
+ var projectPath = args.argv.remain[0];
+ if (fs.existsSync(projectPath)){
+ return Q.reject("Project directory already exists:\n\t" + projectPath);
+ }
+ var packageName = args.argv.remain[1] || "Cordova.Example",
+ appName = args.argv.remain[2] || "CordovaAppProj",
+ safeAppName = appName.replace(/(\.\s|\s\.|\s+|\.+)/g, '_'),
+ guid = args['guid'] || uuid.v1();
+
+ console.log("Creating Cordova Windows Project:");
+ console.log("\tApp Name : " + appName);
+ console.log("\tNamespace : " + packageName);
+ console.log("\tPath : " + projectPath);
+
+ // Copy the template source files to the new destination
+ console.log('Copying template to ' + projectPath);
+ shell.cp("-rf", path.join(__dirname, '..', '..', 'template', '*'), projectPath);
+
+ // replace specific values in manifests' templates
+ ["package.store.appxmanifest", "package.store80.appxmanifest", "package.phone.appxmanifest"].forEach(function (file) {
+ var fileToReplace = path.join(projectPath, file);
+ shell.sed('-i', /\$guid1\$/g, guid, fileToReplace);
+ shell.sed('-i', /\$safeprojectname\$/g, safeAppName, fileToReplace);
+ shell.sed('-i', /\$projectname\$/g, packageName, fileToReplace);
+ });
+
+ // Delete bld forder and bin folder
+ ["bld", "bin", "*.user", "*.suo", "MyTemplate.vstemplate"].forEach(function (file) {
+ shell.rm('-rf', path.join(projectPath, file));
+ });
+
+ // TODO: Name the project according to the arguments
+ // update the solution to include the new project by name
+ // version BS
+ // index.html title set to project name ?
+
+ return Q.resolve();
+};
+
+module.exports.help = function () {
+ console.log("Usage: create PathToProject [ PackageName [ AppName [--guid=<GUID string>] ] ]");
+ console.log(" PathToProject : The path to where you wish to create the project");
+ console.log(" PackageName : The namespace for the project (default is Cordova.Example)");
+ console.log(" AppName : The name of the application (default is CordovaAppProj)");
+ console.log(" --guid : The App's GUID (default is random generated)");
+ console.log("examples:");
+ console.log(" create C:\\Users\\anonymous\\Desktop\\MyProject");
+ console.log(" create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp");
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/lib/update.js
----------------------------------------------------------------------
diff --git a/windows/bin/lib/update.js b/windows/bin/lib/update.js
new file mode 100644
index 0000000..09ae004
--- /dev/null
+++ b/windows/bin/lib/update.js
@@ -0,0 +1,72 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+var Q = require('Q'),
+ fs = require('fs'),
+ create = require('./create');
+
+// returns package metadata from config.xml with fields 'namespace' and 'name'
+function extractMetadata(path) {
+ if (fs.existsSync(path.join(path, 'config.xml'))){
+ return Q.reject('config.xml does not exist');
+ }
+
+ var meta = { // default values
+ namespace: 'io.cordova.hellocordova',
+ name: 'HelloCordova'
+ };
+
+ // TODO: read real values from config.xml
+ //var config = read(path + '/config.xml').split('\n');
+ //for (line in config) {
+ // in case of cli all values will be updated by cli for you
+ // but the script could be used w/o cli so we should correctly populate meta
+ //}
+
+ return Q.resolve(meta);
+}
+
+module.exports.help = function () {
+ Log("WARNING : Make sure to back up your project before updating!");
+ Log("Usage: update Path-To-Project ");
+ Log(" Path-To-Old-Project : The path the project you would like to update.");
+ Log("examples:");
+ Log(" update C:\\Users\\anonymous\\Desktop\\MyProject");
+};
+
+// updates the cordova.js in project along with the cordova tooling.
+module.exports.run = function (argv) {
+ var projectpath = argv[2];
+ if (!fs.existsSync(projectpath)){
+ // if specified project path is not valid then reject promise
+ Q.reject("The given path to the project does not exist." +
+ " Please provide a path to the project you would like to update.");
+ }
+
+ return extractMetadata(projectpath).then(function (metadata) {
+ // this could be used to automatically produce correct folder name under cli
+ // var projectpath = path.replace(/platforms\\windows8$/, 'platforms\\windows')
+ shell.rm('-rf', projectpath);
+ // setup args for create.run which requires process.argv-like array
+ [metadata.namespace, metadata.name].forEach(function (arg) {
+ argv.push(arg);
+ });
+ return create.run(argv);
+ });
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/update
----------------------------------------------------------------------
diff --git a/windows/bin/update b/windows/bin/update
new file mode 100644
index 0000000..dc23c76
--- /dev/null
+++ b/windows/bin/update
@@ -0,0 +1,34 @@
+#!/usr/bin/env node
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+var update = require('./lib/update');
+
+// check for help flag
+if (process.argv[2] == '--help' || process.argv[2] == '/?' || process.argv[2] == '-h' ||
+ process.argv[2] == 'help' || process.argv[2] == '-help' || process.argv[2] == '/help') {
+ update.help();
+} else {
+ update.run(process.argv).done(function () {
+ console.log('Successfully updated windows project.');
+ }, function (err) {
+ console.error('Failed to check requirements due to', err);
+ });
+}
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/update.bat
----------------------------------------------------------------------
diff --git a/windows/bin/update.bat b/windows/bin/update.bat
index c309f61..33becfc 100644
--- a/windows/bin/update.bat
+++ b/windows/bin/update.bat
@@ -15,11 +15,11 @@
:: specific language governing permissions and limitations
:: under the License
@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%update.js (
- cscript "%full_path%update.js" %* //nologo
+SET script_path="%~dp0update"
+IF EXIST %script_path% (
+ node %script_path% %*
) ELSE (
ECHO.
- ECHO ERROR: Could not find 'update.js' in 'bin' folder, aborting...>&2
+ ECHO ERROR: Could not find 'update' script in 'bin' folder, aborting...>&2
EXIT /B 1
)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/5ce7b168/windows/bin/update.js
----------------------------------------------------------------------
diff --git a/windows/bin/update.js b/windows/bin/update.js
deleted file mode 100644
index b34dec9..0000000
--- a/windows/bin/update.js
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-
-var fso = WScript.CreateObject("Scripting.FileSystemObject");
-var wscript_shell = WScript.CreateObject("WScript.Shell");
-var shell = WScript.CreateObject("shell.application");
-var args = WScript.Arguments;
-// working dir
-var ROOT = WScript.ScriptFullName.split('\\bin\\update.js').join('');
-//Get version number
-var VERSION = read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
-var plugins_folder = "\\Plugins";
-var template_folder = "\\templates\\standalone";
-// anything thats missing to the project
-var overwrite = false;
-var replace = false;
-
-// usage function
-function Usage() {
- Log("WARNING : Make sure to back up your project before updating!")
- Log("Usage: update Path-To-Project ");//[ -f | -r ] ");
- Log(" Path-To-Old-Project : The path the project you would like to update.");
- //Log(" -f : Will forcefully overwrite and add all core components of the application.");
- //Log(" -r : Will create an updated project, only keeping the www assets. *NOTE: no native code will be preserved*");
- Log("examples:");
- Log(" update C:\\Users\\anonymous\\Desktop\\MyProject");
-}
-
-// logs messaged to stdout and stderr
-function Log(msg, error) {
- if (error) {
- WScript.StdErr.WriteLine(msg);
- }
- else {
- WScript.StdOut.WriteLine(msg);
- }
-}
-
-// executes a commmand in the shell
-function exec_verbose(command) {
- Log("Command: " + command);
- var oShell=wscript_shell.Exec(command);
- while (oShell.Status == 0) {
- //Wait a little bit so we're not super looping
- WScript.sleep(100);
- //Print any stdout output from the script
- if (!oShell.StdOut.AtEndOfStream) {
- var line = oShell.StdOut.ReadAll();
- Log(line);
- }
- }
- //Check to make sure our scripts did not encounter an error
- if (!oShell.StdErr.AtEndOfStream) {
- var line = oShell.StdErr.ReadAll();
- Log(line, true);
- WScript.Quit(2);
- }
-}
-
-var ForReading = 1, ForWriting = 2, ForAppending = 8;
-var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
-
-// returns the contents of a file
-function read(filename) {
- if (fso.FileExists(filename)) {
- var f=fso.OpenTextFile(filename, 1, 2);
- var s=f.ReadAll();
- f.Close();
- return s;
- }
- else {
- Log('Cannot read non-existant file : ' + filename, true);
- WScript.Quit(2);
- }
- return null;
-}
-
-
-// // returns the name of the application
-// function get_app_name(path) {
-// var WMAppManifest = read(path + '\\Properties\\WMAppManifest.xml').split('\n');
-// for (line in WMAppManifest) {
-// if (WMAppManifest[line].match(/Title\=\"/)) {
-// return WMAppManifest[line].split('Title="')[1].split('"')[0];
-// }
-// }
-// Log("Error : unable to find applicaiton name in the project.", true);
-// Log(" Path : " + path, true);
-// WScript.Quit(2);
-// }
-
-// // returns the name of the application package
-// function get_package_name(path) {
-// var WMAppManifest = read(path + '\\Properties\\WMAppManifest.xml').split('\n');
-// for (line in WMAppManifest) {
-// if (WMAppManifest[line].match(/Title\=\"/)) {
-// return WMAppManifest[line].split('Title="')[1].split('"')[0];
-// }
-// }
-// Log("Error : unable to find applicaiton name in the project.", true);
-// Log(" Path : " + path, true);
-// WScript.Quit(2);
-// }
-
-// // returns the GUID ame of the application
-// function get_app_GUID(path) {
-// var AppXAML = read(path + '\\App.xaml').split('\n');
-// for (line in AppXAML) {
-// if (AppXAML[line].match(/x\:Class\=\"/)) {
-// return AppXAML[line].split('Class="')[1].split('"')[0];
-// }
-// }
-// Log("Error : unable to find package name in the project.", true);
-// Log(" Path : " + path, true);
-// WScript.Quit(2);
-// }
-
-// deletes the path element if it exists
-function delete_if_exists(path) {
- if (fso.FolderExists(path)) {
- fso.DeleteFolder(path);
- }
- else if (fso.FileExists(path)) {
- fso.DeleteFile(path);
- }
-}
-
-function extractMetadata(path) {
- if (!fso.FileExists(path+'/config.xml')) {
- Log('config.xml does not exist');
- WScript.Quit(2);
- }
-
- var meta = { // default values
- namespace: 'io.cordova.hellocordova',
- name: 'HelloCordova'
- }
-
- var config = read(path + '/config.xml').split('\n');
- for (line in config) {
- // TODO read real values from config.xml
- // in case of cli all values will be updated by cli for you
- // but the script could be used w/o cli so we should correctly populate meta
- }
-
- return meta;
-}
-
-function quote(value) {
- return "\"" + value + "\"";
-}
-
-// updates the cordova.js in project along with the cordova tooling.
-function update_project(path) {
- var meta = extractMetadata(path);
-
- delete_if_exists(path);
-
- // this could be used to automatically produce correct folder name under cli
- // var targetPath = path.replace(/platforms\\windows8$/, 'platforms\\windows')
-
- exec_verbose(quote(ROOT + '\\bin\\create.bat')
- + ' ' + quote(path)
- + ' ' + quote(meta.namespace)
- + ' ' + quote(meta.name));
-}
-
-// no args
-if (args.Count() == 0) {
- Usage();
- WScript.Quit(1);
-}
-
-// to many args
-if(args.Count() > 2) {
- Log("Error : too many arguments provided.", true);
- WScript.Quit(1);
-}
-
-// help
-if (args(0).indexOf("--help") > -1 || args(0).indexOf("/?") > -1 ) {
- Usage();
- WScript.Quit(1);
-}
-
-// folder does not exist
-if (!fso.FolderExists(args(0))) {
- Log("The given path to the project does not exist.", true);
- Log(" Please provide a path to the project you would like to update.", true);
- Usage();
- WScript.Quit(2);
-}
-
-update_project(args(0));
\ No newline at end of file