cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject git commit: tool->tools
Date Thu, 01 Nov 2012 17:41:53 GMT
Updated Branches:
  refs/heads/master 91b9039ea -> 4af31414a
Updated Tags:  refs/tags/2.2.0 [created] 4af31414a


tool->tools


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/commit/4af31414
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/tree/4af31414
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/diff/4af31414

Branch: refs/heads/master
Commit: 4af31414a035beb5f476ebf3b377cb8165f97da2
Parents: 91b9039
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Thu Nov 1 04:23:47 2012 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Thu Nov 1 04:23:47 2012 -0700

----------------------------------------------------------------------
 windows8/tool/CordovaBuilder/CordovaBuilder.sln    |   20 -
 .../CordovaBuilder/CordovaBuilder.cs               |  307 ---------------
 .../CordovaBuilder/CordovaBuilder.csproj           |   56 ---
 .../CordovaBuilder/Properties/AssemblyInfo.cs      |   33 --
 .../CordovaBuilder/lib/Ionic.Zip.dll               |  Bin 462336 -> 0 bytes
 windows8/tool/scripts/create.bat                   |   25 --
 windows8/tools/CordovaBuilder/CordovaBuilder.sln   |   20 +
 .../CordovaBuilder/CordovaBuilder.cs               |  307 +++++++++++++++
 .../CordovaBuilder/CordovaBuilder.csproj           |   56 +++
 .../CordovaBuilder/Properties/AssemblyInfo.cs      |   33 ++
 .../CordovaBuilder/lib/Ionic.Zip.dll               |  Bin 0 -> 462336 bytes
 windows8/tools/scripts/create.bat                  |   25 ++
 12 files changed, 441 insertions(+), 441 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tool/CordovaBuilder/CordovaBuilder.sln
----------------------------------------------------------------------
diff --git a/windows8/tool/CordovaBuilder/CordovaBuilder.sln b/windows8/tool/CordovaBuilder/CordovaBuilder.sln
deleted file mode 100644
index 198d228..0000000
--- a/windows8/tool/CordovaBuilder/CordovaBuilder.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CordovaBuilder", "CordovaBuilder\CordovaBuilder.csproj",
"{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Any CPU = Debug|Any CPU
-		Release|Any CPU = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}.Release|Any CPU.Build.0 = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tool/CordovaBuilder/CordovaBuilder/CordovaBuilder.cs
----------------------------------------------------------------------
diff --git a/windows8/tool/CordovaBuilder/CordovaBuilder/CordovaBuilder.cs b/windows8/tool/CordovaBuilder/CordovaBuilder/CordovaBuilder.cs
deleted file mode 100644
index 3524f9f..0000000
--- a/windows8/tool/CordovaBuilder/CordovaBuilder/CordovaBuilder.cs
+++ /dev/null
@@ -1,307 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.IO;
-
-using Ionic.Zip;
-using System.Text.RegularExpressions;
-
-namespace tooling
-{
-
-    class CordovaBuilder
-    {
-        
-        static void Usage()
-        {
-            Log("Usage: CordovaBuilder [ BuildOutputPath -c:Type ]");
-            Log("    BuildOutputPath : path to save the built application");
-            Log("    -c : which type of project you want to create, 0 for Metro App developers,
1 for Cordova API developers, default is 0");
-            Log("examples:");
-            Log("  CordovaBuilder bin\\Debug");
-            Log("  CordovaBuilder bin\\Release -c:1");
-
-        }
-
-        static void Log(string msg)
-        {
-            Console.WriteLine(msg);
-        }
-
-        static void ReadWait()
-        {
-            Console.WriteLine("\nPress ENTER to continue...");
-            Console.Read();
-        }
-
-        static private void DeleteFolder(string folder)
-        {
-            if (Directory.Exists(folder))
-            {
-                foreach (string file in Directory.GetFileSystemEntries(folder))
-                {
-                    if (File.Exists(file))
-                    {
-                        File.Delete(file);
-                    }
-                    else
-                    {
-                        DeleteFolder(file);
-                    }
-                }
-                Directory.Delete(folder);
-            }
-        }
-
-        static private void ModifyFile(string name, int userChosenType, string root, int
length, string source, string result) 
-        {
-            if (userChosenType == 0)
-            {
-                byte[] byteData = new byte[length];
-                char[] charData = new char[length];
-                FileStream readFile;
-
-                try
-                {
-                    readFile = new FileStream(root + name, FileMode.Open);
-                    readFile.Read(byteData, 0, length);
-                    Decoder dec = Encoding.UTF8.GetDecoder();
-                    dec.GetChars(byteData, 0, byteData.Length, charData, 0);
-
-                    string preMergeString = new string(charData);
-                    
-                    Regex reg = new Regex(source);
-                    string ss = reg.Replace(preMergeString, result);
-                    readFile.Close();
-                    
-                    byte[] finalData = new UTF8Encoding().GetBytes(ss);
-                    FileStream writeFile = new FileStream(root + name, FileMode.Open);
-                    writeFile.Write(finalData, 0, finalData.Length);
-                    writeFile.Flush();
-                    writeFile.Close();
-                }
-                catch (IOException e)
-                {
-                    Console.WriteLine("An IO exception has been thrown!");
-                    Console.WriteLine(e.ToString());
-                    Console.ReadLine();
-                }
-            }
-        }
-
-        static private string addToEnvironment()
-        {
-            // add to System Path environment.
-            string path = Environment.GetEnvironmentVariable("Path");
-
-            string[] tempArr = path.Split(';');
-            string[] results = new string[tempArr.Length + 1];
-            string appPath = System.Environment.CurrentDirectory + "\\";
-
-            bool appPathExist = false;
-
-            for (int i = 0; i < tempArr.Length; i++)
-            {
-                if (tempArr[i].Equals(appPath))
-                {
-                    appPathExist = true;
-                }
-                if (!tempArr[i].Contains("CordovaBuilder")) {
-                    results[i] = tempArr[i];
-                }
-            }
-
-            string[] appPaths = appPath.Split('\\');
-            if (appPaths.Length > 5)
-            {
-                if (!appPathExist && appPaths[appPaths.Length - 4].Equals("CordovaBuilder"))
-                {
-                    results[results.Length - 1] = appPath;
-                    
-                    List<string> final = new List<string>();
-                    for (int i = 0; i < results.Length; i++) 
-                    {
-                        if (!"".Equals(results[i]) && results[i] != null) 
-                        {
-                            final.Add(results[i]);
-                        }
-                        
-                    }
-                    string result = String.Join(";", final);
-
-                    Environment.SetEnvironmentVariable("Path", result, EnvironmentVariableTarget.Machine);
-                }
-            }
-            return path;
-        }
-
-        static private void createZip(int userChosenType, string[] currentResults, string
outPutPath)
-        {
-            string basePath = "";
-            string baseName = "";
-
-            if (userChosenType == 0)
-            {
-                basePath = String.Join("\\", currentResults) + "\\framework\\Cordova-Metro";
-                baseName = "\\Cordova-Metro.zip";
-            }
-            else if (userChosenType == 1)
-            {
-                basePath = String.Join("\\", currentResults) + "\\src";
-                baseName = "\\CordovaStarter.zip";
-            }
-
-            try
-            {
-                using (ZipFile zip = new ZipFile())
-                {
-                    zip.StatusMessageTextWriter = System.Console.Out;
-
-                    zip.AddDirectory(basePath); // recurses subdirectories
-
-                    zip.Save(outPutPath + baseName);
-                }
-            }
-            catch (System.Exception ex1)
-            {
-                System.Console.Error.WriteLine("exception: " + ex1);
-            }
-        
-        }
-
-        static private string[] mergeJsFiles(string path, int userChosenType)
-        {
-            string currentPath = Environment.GetEnvironmentVariable("Path");
-
-            string[] currentPaths = path.Split(';');
-            string[] currentTmparr = currentPaths[currentPaths.Length - 1].Split('\\');
-
-            for (int i = 0; i < currentPaths.Length; i++)
-            {
-                if (currentPaths[i].EndsWith("tool\\CordovaBuilder\\CordovaBuilder\\bin\\Debug\\")
|| currentPaths[i].EndsWith("tool\\CordovaBuilder\\CordovaBuilder\\bin\\Release\\"))
-                {
-                    currentTmparr = currentPaths[i].Split('\\');
-                }
-            }
-
-            string[] currentResults = new string[currentTmparr.Length - 6];
-
-            for (int i = 0; i < currentResults.Length; i++)
-            {
-                currentResults[i] = currentTmparr[i];
-            }
-            string currentResult = String.Join("\\", currentResults) + "\\src\\cordova-win8\\js";
-            string[] fileNames = Directory.GetFiles(currentResult, "*.js");
-            string root = String.Join("\\", currentResults) + "\\framework\\Cordova-Metro";
-
-            if (userChosenType == 0)
-            {
-                FileStream fileStream = new FileStream(root + "\\js\\cordova.js", FileMode.Create);
-                BinaryWriter binaryWriter = new BinaryWriter(fileStream);
-                
-                FileStream stream;
-                for (int i = 0; i < fileNames.Length; i++)
-                {
-                    stream = new FileStream(fileNames[i], FileMode.Open);
-                    BinaryReader reader = new BinaryReader(stream);
-                    int length = (int)stream.Length;
-                    byte[] threeBytes = reader.ReadBytes(3);
-                    //int ch = reader.PeekChar();
-                    if (threeBytes[0] == 0xef && threeBytes[1] == 0xbb &&
threeBytes[2] == 0xbf)
-                    {
-                        length -= 3;
-                    }
-                    else
-                    {
-                        binaryWriter.Write(threeBytes);
-                    }
-
-                    binaryWriter.Write(reader.ReadBytes(length));
-                    //binaryWriter.Write("\n");
-                    reader.Close();
-                    stream.Close();
-                }
-                binaryWriter.Close();
-                fileStream.Close();
-            }
-            return currentResults;
-        }
-
-        static private void cleanProject(int userChosenType, string[] currentResults, string
root)
-        {
-            if (userChosenType == 0)
-            {
-                /*string deleteFile = root + "\\js\\default.js";
-                if (File.Exists(deleteFile))
-                {
-                    File.Delete(deleteFile);
-                }*/
-            }
-            else if (userChosenType == 1)
-            {
-                DeleteFolder(String.Join("\\", currentResults) + "\\src\\cordova-win8\\bin");
-                DeleteFolder(String.Join("\\", currentResults) + "\\src\\cordova-win8\\bld");
-            }
-        
-        }
-
-
-        static void Main(string[] args) 
-        {
-            string path = addToEnvironment();
-
-            int userChosenType = 0;
-            string outPutPath = "";
-
-            if (args.Length < 1) 
-            {
-                Usage();
-                ReadWait();
-                return;
-            }
-
-            if (args.Length == 2) 
-            {
-                if (args[1].StartsWith("-c:")) 
-                {
-                    userChosenType = int.Parse(args[1].Substring(3));
-                    if (userChosenType != 1 && userChosenType != 0)
-                    {
-                        Usage();
-                        ReadWait();
-                        return;
-                    }
-                }
-            }
-
-            if (Directory.Exists(args[0]))
-            {
-                DirectoryInfo info = new DirectoryInfo(args[0]);
-                outPutPath = info.FullName;
-            }
-            else 
-            {
-                Log(string.Format("Error: could not find folder of path {0}", args[0]));
-                ReadWait();
-                return;
-            }
-
-            // Merge the JS files.
-            string[] currentResults = mergeJsFiles(path, userChosenType);
-
-            string root = String.Join("\\", currentResults) + "\\framework\\Cordova-Metro";
-            
-            // Modify the default.html.
-            ModifyFile("\\default.html", userChosenType, root, 1000, "js/default.js", "js/cordova.js");
-            
-			// Clean the project.
-            cleanProject(userChosenType, currentResults, root);
-
-            // Create zip.
-            createZip(userChosenType, currentResults, outPutPath);
-         }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tool/CordovaBuilder/CordovaBuilder/CordovaBuilder.csproj
----------------------------------------------------------------------
diff --git a/windows8/tool/CordovaBuilder/CordovaBuilder/CordovaBuilder.csproj b/windows8/tool/CordovaBuilder/CordovaBuilder/CordovaBuilder.csproj
deleted file mode 100644
index 1643c8b..0000000
--- a/windows8/tool/CordovaBuilder/CordovaBuilder/CordovaBuilder.csproj
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}</ProjectGuid>
-    <OutputType>Exe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>CordovaBuilder</RootNamespace>
-    <AssemblyName>CordovaBuilder</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Compile Include="CordovaBuilder.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="lib\Ionic.Zip.dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c,
processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>lib\Ionic.Zip.dll</HintPath>
-    </Reference>
-    <Reference Include="System" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and
uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tool/CordovaBuilder/CordovaBuilder/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/windows8/tool/CordovaBuilder/CordovaBuilder/Properties/AssemblyInfo.cs b/windows8/tool/CordovaBuilder/CordovaBuilder/Properties/AssemblyInfo.cs
deleted file mode 100644
index 7410239..0000000
--- a/windows8/tool/CordovaBuilder/CordovaBuilder/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("CordovaBuilder")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("CordovaBuilder")]
-[assembly: AssemblyCopyright("Copyright  ©  2012")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("aa0f18b9-5f12-41cd-8012-4f6587c0b23b")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tool/CordovaBuilder/CordovaBuilder/lib/Ionic.Zip.dll
----------------------------------------------------------------------
diff --git a/windows8/tool/CordovaBuilder/CordovaBuilder/lib/Ionic.Zip.dll b/windows8/tool/CordovaBuilder/CordovaBuilder/lib/Ionic.Zip.dll
deleted file mode 100644
index 95fa928..0000000
Binary files a/windows8/tool/CordovaBuilder/CordovaBuilder/lib/Ionic.Zip.dll and /dev/null
differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tool/scripts/create.bat
----------------------------------------------------------------------
diff --git a/windows8/tool/scripts/create.bat b/windows8/tool/scripts/create.bat
deleted file mode 100644
index 25dccbe..0000000
--- a/windows8/tool/scripts/create.bat
+++ /dev/null
@@ -1,25 +0,0 @@
-
-@echo off
-goto start
-
-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.
-
-
-:start
-csc /out:..\CordovaBuilder\CordovaBuilder\bin\Debug\CordovaBuilder.exe ..\CordovaBuilder\CordovaBuilder\CordovaBuilder.cs
-csc /out:..\CordovaBuilder\CordovaBuilder\bin\Release\CordovaBuilder.exe ..\CordovaBuilder\CordovaBuilder\CordovaBuilder.cs
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tools/CordovaBuilder/CordovaBuilder.sln
----------------------------------------------------------------------
diff --git a/windows8/tools/CordovaBuilder/CordovaBuilder.sln b/windows8/tools/CordovaBuilder/CordovaBuilder.sln
new file mode 100644
index 0000000..198d228
--- /dev/null
+++ b/windows8/tools/CordovaBuilder/CordovaBuilder.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CordovaBuilder", "CordovaBuilder\CordovaBuilder.csproj",
"{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tools/CordovaBuilder/CordovaBuilder/CordovaBuilder.cs
----------------------------------------------------------------------
diff --git a/windows8/tools/CordovaBuilder/CordovaBuilder/CordovaBuilder.cs b/windows8/tools/CordovaBuilder/CordovaBuilder/CordovaBuilder.cs
new file mode 100644
index 0000000..3524f9f
--- /dev/null
+++ b/windows8/tools/CordovaBuilder/CordovaBuilder/CordovaBuilder.cs
@@ -0,0 +1,307 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+
+using Ionic.Zip;
+using System.Text.RegularExpressions;
+
+namespace tooling
+{
+
+    class CordovaBuilder
+    {
+        
+        static void Usage()
+        {
+            Log("Usage: CordovaBuilder [ BuildOutputPath -c:Type ]");
+            Log("    BuildOutputPath : path to save the built application");
+            Log("    -c : which type of project you want to create, 0 for Metro App developers,
1 for Cordova API developers, default is 0");
+            Log("examples:");
+            Log("  CordovaBuilder bin\\Debug");
+            Log("  CordovaBuilder bin\\Release -c:1");
+
+        }
+
+        static void Log(string msg)
+        {
+            Console.WriteLine(msg);
+        }
+
+        static void ReadWait()
+        {
+            Console.WriteLine("\nPress ENTER to continue...");
+            Console.Read();
+        }
+
+        static private void DeleteFolder(string folder)
+        {
+            if (Directory.Exists(folder))
+            {
+                foreach (string file in Directory.GetFileSystemEntries(folder))
+                {
+                    if (File.Exists(file))
+                    {
+                        File.Delete(file);
+                    }
+                    else
+                    {
+                        DeleteFolder(file);
+                    }
+                }
+                Directory.Delete(folder);
+            }
+        }
+
+        static private void ModifyFile(string name, int userChosenType, string root, int
length, string source, string result) 
+        {
+            if (userChosenType == 0)
+            {
+                byte[] byteData = new byte[length];
+                char[] charData = new char[length];
+                FileStream readFile;
+
+                try
+                {
+                    readFile = new FileStream(root + name, FileMode.Open);
+                    readFile.Read(byteData, 0, length);
+                    Decoder dec = Encoding.UTF8.GetDecoder();
+                    dec.GetChars(byteData, 0, byteData.Length, charData, 0);
+
+                    string preMergeString = new string(charData);
+                    
+                    Regex reg = new Regex(source);
+                    string ss = reg.Replace(preMergeString, result);
+                    readFile.Close();
+                    
+                    byte[] finalData = new UTF8Encoding().GetBytes(ss);
+                    FileStream writeFile = new FileStream(root + name, FileMode.Open);
+                    writeFile.Write(finalData, 0, finalData.Length);
+                    writeFile.Flush();
+                    writeFile.Close();
+                }
+                catch (IOException e)
+                {
+                    Console.WriteLine("An IO exception has been thrown!");
+                    Console.WriteLine(e.ToString());
+                    Console.ReadLine();
+                }
+            }
+        }
+
+        static private string addToEnvironment()
+        {
+            // add to System Path environment.
+            string path = Environment.GetEnvironmentVariable("Path");
+
+            string[] tempArr = path.Split(';');
+            string[] results = new string[tempArr.Length + 1];
+            string appPath = System.Environment.CurrentDirectory + "\\";
+
+            bool appPathExist = false;
+
+            for (int i = 0; i < tempArr.Length; i++)
+            {
+                if (tempArr[i].Equals(appPath))
+                {
+                    appPathExist = true;
+                }
+                if (!tempArr[i].Contains("CordovaBuilder")) {
+                    results[i] = tempArr[i];
+                }
+            }
+
+            string[] appPaths = appPath.Split('\\');
+            if (appPaths.Length > 5)
+            {
+                if (!appPathExist && appPaths[appPaths.Length - 4].Equals("CordovaBuilder"))
+                {
+                    results[results.Length - 1] = appPath;
+                    
+                    List<string> final = new List<string>();
+                    for (int i = 0; i < results.Length; i++) 
+                    {
+                        if (!"".Equals(results[i]) && results[i] != null) 
+                        {
+                            final.Add(results[i]);
+                        }
+                        
+                    }
+                    string result = String.Join(";", final);
+
+                    Environment.SetEnvironmentVariable("Path", result, EnvironmentVariableTarget.Machine);
+                }
+            }
+            return path;
+        }
+
+        static private void createZip(int userChosenType, string[] currentResults, string
outPutPath)
+        {
+            string basePath = "";
+            string baseName = "";
+
+            if (userChosenType == 0)
+            {
+                basePath = String.Join("\\", currentResults) + "\\framework\\Cordova-Metro";
+                baseName = "\\Cordova-Metro.zip";
+            }
+            else if (userChosenType == 1)
+            {
+                basePath = String.Join("\\", currentResults) + "\\src";
+                baseName = "\\CordovaStarter.zip";
+            }
+
+            try
+            {
+                using (ZipFile zip = new ZipFile())
+                {
+                    zip.StatusMessageTextWriter = System.Console.Out;
+
+                    zip.AddDirectory(basePath); // recurses subdirectories
+
+                    zip.Save(outPutPath + baseName);
+                }
+            }
+            catch (System.Exception ex1)
+            {
+                System.Console.Error.WriteLine("exception: " + ex1);
+            }
+        
+        }
+
+        static private string[] mergeJsFiles(string path, int userChosenType)
+        {
+            string currentPath = Environment.GetEnvironmentVariable("Path");
+
+            string[] currentPaths = path.Split(';');
+            string[] currentTmparr = currentPaths[currentPaths.Length - 1].Split('\\');
+
+            for (int i = 0; i < currentPaths.Length; i++)
+            {
+                if (currentPaths[i].EndsWith("tool\\CordovaBuilder\\CordovaBuilder\\bin\\Debug\\")
|| currentPaths[i].EndsWith("tool\\CordovaBuilder\\CordovaBuilder\\bin\\Release\\"))
+                {
+                    currentTmparr = currentPaths[i].Split('\\');
+                }
+            }
+
+            string[] currentResults = new string[currentTmparr.Length - 6];
+
+            for (int i = 0; i < currentResults.Length; i++)
+            {
+                currentResults[i] = currentTmparr[i];
+            }
+            string currentResult = String.Join("\\", currentResults) + "\\src\\cordova-win8\\js";
+            string[] fileNames = Directory.GetFiles(currentResult, "*.js");
+            string root = String.Join("\\", currentResults) + "\\framework\\Cordova-Metro";
+
+            if (userChosenType == 0)
+            {
+                FileStream fileStream = new FileStream(root + "\\js\\cordova.js", FileMode.Create);
+                BinaryWriter binaryWriter = new BinaryWriter(fileStream);
+                
+                FileStream stream;
+                for (int i = 0; i < fileNames.Length; i++)
+                {
+                    stream = new FileStream(fileNames[i], FileMode.Open);
+                    BinaryReader reader = new BinaryReader(stream);
+                    int length = (int)stream.Length;
+                    byte[] threeBytes = reader.ReadBytes(3);
+                    //int ch = reader.PeekChar();
+                    if (threeBytes[0] == 0xef && threeBytes[1] == 0xbb &&
threeBytes[2] == 0xbf)
+                    {
+                        length -= 3;
+                    }
+                    else
+                    {
+                        binaryWriter.Write(threeBytes);
+                    }
+
+                    binaryWriter.Write(reader.ReadBytes(length));
+                    //binaryWriter.Write("\n");
+                    reader.Close();
+                    stream.Close();
+                }
+                binaryWriter.Close();
+                fileStream.Close();
+            }
+            return currentResults;
+        }
+
+        static private void cleanProject(int userChosenType, string[] currentResults, string
root)
+        {
+            if (userChosenType == 0)
+            {
+                /*string deleteFile = root + "\\js\\default.js";
+                if (File.Exists(deleteFile))
+                {
+                    File.Delete(deleteFile);
+                }*/
+            }
+            else if (userChosenType == 1)
+            {
+                DeleteFolder(String.Join("\\", currentResults) + "\\src\\cordova-win8\\bin");
+                DeleteFolder(String.Join("\\", currentResults) + "\\src\\cordova-win8\\bld");
+            }
+        
+        }
+
+
+        static void Main(string[] args) 
+        {
+            string path = addToEnvironment();
+
+            int userChosenType = 0;
+            string outPutPath = "";
+
+            if (args.Length < 1) 
+            {
+                Usage();
+                ReadWait();
+                return;
+            }
+
+            if (args.Length == 2) 
+            {
+                if (args[1].StartsWith("-c:")) 
+                {
+                    userChosenType = int.Parse(args[1].Substring(3));
+                    if (userChosenType != 1 && userChosenType != 0)
+                    {
+                        Usage();
+                        ReadWait();
+                        return;
+                    }
+                }
+            }
+
+            if (Directory.Exists(args[0]))
+            {
+                DirectoryInfo info = new DirectoryInfo(args[0]);
+                outPutPath = info.FullName;
+            }
+            else 
+            {
+                Log(string.Format("Error: could not find folder of path {0}", args[0]));
+                ReadWait();
+                return;
+            }
+
+            // Merge the JS files.
+            string[] currentResults = mergeJsFiles(path, userChosenType);
+
+            string root = String.Join("\\", currentResults) + "\\framework\\Cordova-Metro";
+            
+            // Modify the default.html.
+            ModifyFile("\\default.html", userChosenType, root, 1000, "js/default.js", "js/cordova.js");
+            
+			// Clean the project.
+            cleanProject(userChosenType, currentResults, root);
+
+            // Create zip.
+            createZip(userChosenType, currentResults, outPutPath);
+         }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tools/CordovaBuilder/CordovaBuilder/CordovaBuilder.csproj
----------------------------------------------------------------------
diff --git a/windows8/tools/CordovaBuilder/CordovaBuilder/CordovaBuilder.csproj b/windows8/tools/CordovaBuilder/CordovaBuilder/CordovaBuilder.csproj
new file mode 100644
index 0000000..1643c8b
--- /dev/null
+++ b/windows8/tools/CordovaBuilder/CordovaBuilder/CordovaBuilder.csproj
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{7D6262C4-A2B4-4FE6-87A7-650866FEE54B}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>CordovaBuilder</RootNamespace>
+    <AssemblyName>CordovaBuilder</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="CordovaBuilder.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="lib\Ionic.Zip.dll" />
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c,
processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>lib\Ionic.Zip.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and
uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tools/CordovaBuilder/CordovaBuilder/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/windows8/tools/CordovaBuilder/CordovaBuilder/Properties/AssemblyInfo.cs b/windows8/tools/CordovaBuilder/CordovaBuilder/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..7410239
--- /dev/null
+++ b/windows8/tools/CordovaBuilder/CordovaBuilder/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CordovaBuilder")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CordovaBuilder")]
+[assembly: AssemblyCopyright("Copyright  ©  2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("aa0f18b9-5f12-41cd-8012-4f6587c0b23b")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tools/CordovaBuilder/CordovaBuilder/lib/Ionic.Zip.dll
----------------------------------------------------------------------
diff --git a/windows8/tools/CordovaBuilder/CordovaBuilder/lib/Ionic.Zip.dll b/windows8/tools/CordovaBuilder/CordovaBuilder/lib/Ionic.Zip.dll
new file mode 100644
index 0000000..95fa928
Binary files /dev/null and b/windows8/tools/CordovaBuilder/CordovaBuilder/lib/Ionic.Zip.dll
differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/4af31414/windows8/tools/scripts/create.bat
----------------------------------------------------------------------
diff --git a/windows8/tools/scripts/create.bat b/windows8/tools/scripts/create.bat
new file mode 100644
index 0000000..25dccbe
--- /dev/null
+++ b/windows8/tools/scripts/create.bat
@@ -0,0 +1,25 @@
+
+@echo off
+goto start
+
+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.
+
+
+:start
+csc /out:..\CordovaBuilder\CordovaBuilder\bin\Debug\CordovaBuilder.exe ..\CordovaBuilder\CordovaBuilder\CordovaBuilder.cs
+csc /out:..\CordovaBuilder\CordovaBuilder\bin\Release\CordovaBuilder.exe ..\CordovaBuilder\CordovaBuilder\CordovaBuilder.cs
\ No newline at end of file


Mime
View raw message