From 89c1f7cac28b705a6f4baa98252017c7b6490201 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Thu, 23 Nov 2017 14:33:14 +0100 Subject: [PATCH 01/14] Add GithubRepository object --- ...pes_Upbring_Upfile_UpfileOverride_Upset.cs | 503 +++++++++--------- .../Schemas/Repositories/GithubRepository.cs | 53 ++ .../Repositories/GithubRepository.cs.meta | 12 + .../Editor/Uplift/Schemas/RepositoryTypes.xsd | 8 + 4 files changed, 325 insertions(+), 251 deletions(-) create mode 100644 Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs create mode 100644 Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs.meta diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs index 28bf94b4..c8dac7f7 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs @@ -1,45 +1,22 @@ -// --- BEGIN LICENSE BLOCK --- -/* - * Copyright (c) 2017-present WeWantToKnow AS - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -// --- END LICENSE BLOCK --- +//------------------------------------------------------------------------------ +// +// Ce code a été généré par un outil. +// Version du runtime :2.0.50727.8825 +// +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. +// +//------------------------------------------------------------------------------ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - +// This source code was auto-generated by xsd, Version=2.0.50727.3038. // -//This source code was auto-generated by MonoXSD -// namespace Uplift.Schemas { + using System.Xml.Serialization; /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -61,7 +38,7 @@ public InstalledPackage[] InstalledPackage { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -110,7 +87,7 @@ public string Version { /// [System.Xml.Serialization.XmlIncludeAttribute(typeof(InstallSpecGUID))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(InstallSpecPath))] - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -170,7 +147,7 @@ public string Value { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] public enum InstallSpecType { @@ -200,7 +177,7 @@ public enum InstallSpecType { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] public enum PlatformType { @@ -215,235 +192,215 @@ public enum PlatformType { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class OverrideDestinationSpec { - - private InstallSpecType typeField; - - private string locationField; + public partial class InstallSpecGUID : InstallSpec { - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public InstallSpecType Type { - get { - return this.typeField; - } - set { - this.typeField = value; - } - } + private string guidField; /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string Location { + public string Guid { get { - return this.locationField; + return this.guidField; } set { - this.locationField = value; + this.guidField = value; } } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class SkipInstallSpec { + public partial class InstallSpecPath : InstallSpec { - private InstallSpecType typeField; + private string pathField; /// [System.Xml.Serialization.XmlAttributeAttribute()] - public InstallSpecType Type { + public string Path { get { - return this.typeField; + return this.pathField; } set { - this.typeField = value; + this.pathField = value; } } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class DependencyDefinition { - - private SkipInstallSpec[] skipInstallField; - - private OverrideDestinationSpec[] overrideDestinationField; + [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] + public partial class Upfile { - private string nameField; + private string unityVersionField; - private string versionField; + private Configuration configurationField; - private string repositoryField; + private Repository[] repositoriesField; - /// - [System.Xml.Serialization.XmlArrayItemAttribute("Skip", IsNullable=false)] - public SkipInstallSpec[] SkipInstall { - get { - return this.skipInstallField; - } - set { - this.skipInstallField = value; - } - } + private DependencyDefinition[] dependenciesField; /// - [System.Xml.Serialization.XmlArrayItemAttribute("Override", IsNullable=false)] - public OverrideDestinationSpec[] OverrideDestination { + public string UnityVersion { get { - return this.overrideDestinationField; + return this.unityVersionField; } set { - this.overrideDestinationField = value; + this.unityVersionField = value; } } /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Name { + public Configuration Configuration { get { - return this.nameField; + return this.configurationField; } set { - this.nameField = value; + this.configurationField = value; } } /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Version { + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(FileRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GitRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GithubRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(WebRepository), IsNullable=false)] + public Repository[] Repositories { get { - return this.versionField; + return this.repositoriesField; } set { - this.versionField = value; + this.repositoriesField = value; } } /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Repository { + [System.Xml.Serialization.XmlArrayItemAttribute("Package", IsNullable=false)] + public DependencyDefinition[] Dependencies { get { - return this.repositoryField; + return this.dependenciesField; } set { - this.repositoryField = value; + this.dependenciesField = value; } } } /// - [System.Xml.Serialization.XmlIncludeAttribute(typeof(FileRepository))] - [System.Xml.Serialization.XmlIncludeAttribute(typeof(GitRepository))] - [System.Xml.Serialization.XmlIncludeAttribute(typeof(WebRepository))] - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class Repository { + public partial class Configuration { - private string extractPathField; + private PathConfiguration repositoryPathField; - private string valueField; + private PathConfiguration docsPathField; + + private PathConfiguration examplesPathField; + + private PathConfiguration baseInstallPathField; + + private PathConfiguration mediaPathField; + + private PathConfiguration gizmoPathField; + + private PathConfiguration pluginPathField; + + private PathConfiguration editorPluginPathField; /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string ExtractPath { + public PathConfiguration RepositoryPath { get { - return this.extractPathField; + return this.repositoryPathField; } set { - this.extractPathField = value; + this.repositoryPathField = value; } } /// - [System.Xml.Serialization.XmlTextAttribute()] - public string Value { + public PathConfiguration DocsPath { get { - return this.valueField; + return this.docsPathField; } set { - this.valueField = value; + this.docsPathField = value; } } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class FileRepository : Repository { - private string pathField; + /// + public PathConfiguration ExamplesPath { + get { + return this.examplesPathField; + } + set { + this.examplesPathField = value; + } + } /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Path { + public PathConfiguration BaseInstallPath { get { - return this.pathField; + return this.baseInstallPathField; } set { - this.pathField = value; + this.baseInstallPathField = value; } } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GitRepository : Repository { - private string urlField; + /// + public PathConfiguration MediaPath { + get { + return this.mediaPathField; + } + set { + this.mediaPathField = value; + } + } /// - [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] - public string Url { + public PathConfiguration GizmoPath { get { - return this.urlField; + return this.gizmoPathField; } set { - this.urlField = value; + this.gizmoPathField = value; } } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class WebRepository : Repository { - private string urlField; + /// + public PathConfiguration PluginPath { + get { + return this.pluginPathField; + } + set { + this.pluginPathField = value; + } + } /// - [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] - public string Url { + public PathConfiguration EditorPluginPath { get { - return this.urlField; + return this.editorPluginPathField; } set { - this.urlField = value; + this.editorPluginPathField = value; } } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -503,214 +460,257 @@ public string Value { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class Configuration { - - private PathConfiguration repositoryPathField; - - private PathConfiguration docsPathField; - - private PathConfiguration examplesPathField; - - private PathConfiguration baseInstallPathField; + public partial class FileRepository : Repository { - private PathConfiguration mediaPathField; + private string pathField; - private PathConfiguration gizmoPathField; + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Path { + get { + return this.pathField; + } + set { + this.pathField = value; + } + } + } + + /// + [System.Xml.Serialization.XmlIncludeAttribute(typeof(FileRepository))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(GitRepository))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(GithubRepository))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(WebRepository))] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class Repository { - private PathConfiguration pluginPathField; + private string extractPathField; - private PathConfiguration editorPluginPathField; + private string valueField; /// - public PathConfiguration RepositoryPath { + [System.Xml.Serialization.XmlAttributeAttribute()] + public string ExtractPath { get { - return this.repositoryPathField; + return this.extractPathField; } set { - this.repositoryPathField = value; + this.extractPathField = value; } } /// - public PathConfiguration DocsPath { + [System.Xml.Serialization.XmlTextAttribute()] + public string Value { get { - return this.docsPathField; + return this.valueField; } set { - this.docsPathField = value; + this.valueField = value; } } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GitRepository : Repository { + + private string urlField; /// - public PathConfiguration ExamplesPath { + [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] + public string Url { get { - return this.examplesPathField; + return this.urlField; } set { - this.examplesPathField = value; + this.urlField = value; } } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GithubRepository : Repository { + + private string urlField; /// - public PathConfiguration BaseInstallPath { + [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] + public string Url { get { - return this.baseInstallPathField; + return this.urlField; } set { - this.baseInstallPathField = value; + this.urlField = value; } } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class WebRepository : Repository { + + private string urlField; /// - public PathConfiguration MediaPath { + [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] + public string Url { get { - return this.mediaPathField; + return this.urlField; } set { - this.mediaPathField = value; + this.urlField = value; } } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class DependencyDefinition { + + private SkipInstallSpec[] skipInstallField; + + private OverrideDestinationSpec[] overrideDestinationField; + + private string nameField; + + private string versionField; + + private string repositoryField; /// - public PathConfiguration GizmoPath { + [System.Xml.Serialization.XmlArrayItemAttribute("Skip", IsNullable=false)] + public SkipInstallSpec[] SkipInstall { get { - return this.gizmoPathField; + return this.skipInstallField; } set { - this.gizmoPathField = value; + this.skipInstallField = value; } } /// - public PathConfiguration PluginPath { + [System.Xml.Serialization.XmlArrayItemAttribute("Override", IsNullable=false)] + public OverrideDestinationSpec[] OverrideDestination { get { - return this.pluginPathField; + return this.overrideDestinationField; } set { - this.pluginPathField = value; + this.overrideDestinationField = value; } } /// - public PathConfiguration EditorPluginPath { + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Name { get { - return this.editorPluginPathField; + return this.nameField; } set { - this.editorPluginPathField = value; + this.nameField = value; } } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class InstallSpecGUID : InstallSpec { - private string guidField; + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Version { + get { + return this.versionField; + } + set { + this.versionField = value; + } + } /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string Guid { + public string Repository { get { - return this.guidField; + return this.repositoryField; } set { - this.guidField = value; + this.repositoryField = value; } } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class InstallSpecPath : InstallSpec { + public partial class SkipInstallSpec { - private string pathField; + private InstallSpecType typeField; /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string Path { + public InstallSpecType Type { get { - return this.pathField; + return this.typeField; } set { - this.pathField = value; + this.typeField = value; } } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] - public partial class Upfile { - - private string unityVersionField; - - private Configuration configurationField; - - private Repository[] repositoriesField; - - private DependencyDefinition[] dependenciesField; + public partial class OverrideDestinationSpec { - /// - public string UnityVersion { - get { - return this.unityVersionField; - } - set { - this.unityVersionField = value; - } - } + private InstallSpecType typeField; - /// - public Configuration Configuration { - get { - return this.configurationField; - } - set { - this.configurationField = value; - } - } + private string locationField; /// - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(FileRepository), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GitRepository), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(WebRepository), IsNullable=false)] - public Repository[] Repositories { + [System.Xml.Serialization.XmlAttributeAttribute()] + public InstallSpecType Type { get { - return this.repositoriesField; + return this.typeField; } set { - this.repositoriesField = value; + this.typeField = value; } } /// - [System.Xml.Serialization.XmlArrayItemAttribute("Package", IsNullable=false)] - public DependencyDefinition[] Dependencies { + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Location { get { - return this.dependenciesField; + return this.locationField; } set { - this.dependenciesField = value; + this.locationField = value; } } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -722,6 +722,7 @@ public partial class UpfileOverride { /// [System.Xml.Serialization.XmlArrayItemAttribute(typeof(FileRepository), IsNullable=false)] [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GitRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GithubRepository), IsNullable=false)] [System.Xml.Serialization.XmlArrayItemAttribute(typeof(WebRepository), IsNullable=false)] public Repository[] Repositories { get { @@ -734,7 +735,7 @@ public Repository[] Repositories { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "0.0.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs new file mode 100644 index 00000000..83954ed2 --- /dev/null +++ b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs @@ -0,0 +1,53 @@ +// --- BEGIN LICENSE BLOCK --- +/* + * Copyright (c) 2017-present WeWantToKnow AS + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// --- END LICENSE BLOCK --- + +using System; +using Uplift.Common; + +namespace Uplift.Schemas +{ + public partial class GithubRepository : Repository + { + public override TemporaryDirectory DownloadPackage(Upset package) + { + throw new NotImplementedException(); + } + + public override Upset[] ListPackages() + { + // FIXME: + /* Github API: + * - Retrieve release tagged "packages" + * - foreach asset in the release, if asset is Upset, parse Upset and add it to LIST + * - return LIST + */ + throw new NotImplementedException(); + } + + private object GetPackagesRelease() + { + + } + } +} diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs.meta b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs.meta new file mode 100644 index 00000000..8e751e1e --- /dev/null +++ b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 84b62f3c29189fd4db839fac78188758 +timeCreated: 1511443550 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor/Uplift/Schemas/RepositoryTypes.xsd b/Assets/Plugins/Editor/Uplift/Schemas/RepositoryTypes.xsd index 63501332..7829c4b8 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/RepositoryTypes.xsd +++ b/Assets/Plugins/Editor/Uplift/Schemas/RepositoryTypes.xsd @@ -12,6 +12,13 @@ + + + + + + + @@ -38,6 +45,7 @@ + From c09b9dd4498710c828c6ee95f2d7aa8338b80a14 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Fri, 24 Nov 2017 12:28:54 +0100 Subject: [PATCH 02/14] Refactor UpfileOverride to more generic DotUplift --- ...t_RepositoryTypes_Upbring_Upfile_Upset.cs} | 399 +++++++++++------- ...ositoryTypes_Upbring_Upfile_Upset.cs.meta} | 4 +- .../Editor/Uplift/Schemas/DotUplift.xsd | 47 +++ ...leOverride.xsd.meta => DotUplift.xsd.meta} | 4 +- .../Uplift/Schemas/Extensions/DotUpfile.cs | 58 +++ .../Schemas/Extensions/DotUpfile.cs.meta | 12 + .../Uplift/Schemas/Extensions/Upfile.cs | 84 +--- .../Editor/Uplift/Schemas/UpfileOverride.xsd | 16 - .../Uplift/Testing/UnitTesting/UpfileTest.cs | 46 +- TestData/UpfileTest/UpfileOverride.xml | 4 +- 10 files changed, 420 insertions(+), 254 deletions(-) rename Assets/Plugins/Editor/Uplift/Schemas/{Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs => Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs} (87%) rename Assets/Plugins/Editor/Uplift/Schemas/{Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs.meta => Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs.meta} (76%) create mode 100644 Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd rename Assets/Plugins/Editor/Uplift/Schemas/{UpfileOverride.xsd.meta => DotUplift.xsd.meta} (64%) create mode 100644 Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs create mode 100644 Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs.meta delete mode 100644 Assets/Plugins/Editor/Uplift/Schemas/UpfileOverride.xsd diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs b/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs similarity index 87% rename from Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs rename to Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs index c8dac7f7..27e9d233 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs @@ -15,6 +15,258 @@ namespace Uplift.Schemas { using System.Xml.Serialization; + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] + public partial class DotUplift { + + private Repository[] repositoriesField; + + private RepositoryAuthentication[] authenticationMethodsField; + + /// + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(FileRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GitRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GithubRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(WebRepository), IsNullable=false)] + public Repository[] Repositories { + get { + return this.repositoriesField; + } + set { + this.repositoriesField = value; + } + } + + /// + [System.Xml.Serialization.XmlArrayItemAttribute("GitRepository", typeof(RepositoryToken), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute("GithubRepository", typeof(RepositoryCredentials), IsNullable=false)] + public RepositoryAuthentication[] AuthenticationMethods { + get { + return this.authenticationMethodsField; + } + set { + this.authenticationMethodsField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class FileRepository : Repository { + + private string pathField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Path { + get { + return this.pathField; + } + set { + this.pathField = value; + } + } + } + + /// + [System.Xml.Serialization.XmlIncludeAttribute(typeof(FileRepository))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(GitRepository))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(GithubRepository))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(WebRepository))] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class Repository { + + private string extractPathField; + + private string valueField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string ExtractPath { + get { + return this.extractPathField; + } + set { + this.extractPathField = value; + } + } + + /// + [System.Xml.Serialization.XmlTextAttribute()] + public string Value { + get { + return this.valueField; + } + set { + this.valueField = value; + } + } + } + + /// + [System.Xml.Serialization.XmlIncludeAttribute(typeof(RepositoryCredentials))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(RepositoryToken))] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public abstract partial class RepositoryAuthentication { + + private string repositoryField; + + private string valueField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Repository { + get { + return this.repositoryField; + } + set { + this.repositoryField = value; + } + } + + /// + [System.Xml.Serialization.XmlTextAttribute()] + public string Value { + get { + return this.valueField; + } + set { + this.valueField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class RepositoryCredentials : RepositoryAuthentication { + + private string loginField; + + private string passwordField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Login { + get { + return this.loginField; + } + set { + this.loginField = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Password { + get { + return this.passwordField; + } + set { + this.passwordField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class RepositoryToken : RepositoryAuthentication { + + private string tokenField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Token { + get { + return this.tokenField; + } + set { + this.tokenField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GitRepository : Repository { + + private string urlField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] + public string Url { + get { + return this.urlField; + } + set { + this.urlField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GithubRepository : Repository { + + private string urlField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] + public string Url { + get { + return this.urlField; + } + set { + this.urlField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class WebRepository : Repository { + + private string urlField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] + public string Url { + get { + return this.urlField; + } + set { + this.urlField = value; + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] @@ -459,128 +711,6 @@ public string Value { } } - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class FileRepository : Repository { - - private string pathField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Path { - get { - return this.pathField; - } - set { - this.pathField = value; - } - } - } - - /// - [System.Xml.Serialization.XmlIncludeAttribute(typeof(FileRepository))] - [System.Xml.Serialization.XmlIncludeAttribute(typeof(GitRepository))] - [System.Xml.Serialization.XmlIncludeAttribute(typeof(GithubRepository))] - [System.Xml.Serialization.XmlIncludeAttribute(typeof(WebRepository))] - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class Repository { - - private string extractPathField; - - private string valueField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string ExtractPath { - get { - return this.extractPathField; - } - set { - this.extractPathField = value; - } - } - - /// - [System.Xml.Serialization.XmlTextAttribute()] - public string Value { - get { - return this.valueField; - } - set { - this.valueField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GitRepository : Repository { - - private string urlField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] - public string Url { - get { - return this.urlField; - } - set { - this.urlField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GithubRepository : Repository { - - private string urlField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] - public string Url { - get { - return this.urlField; - } - set { - this.urlField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class WebRepository : Repository { - - private string urlField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] - public string Url { - get { - return this.urlField; - } - set { - this.urlField = value; - } - } - } - /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] @@ -709,31 +839,6 @@ public string Location { } } - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] - public partial class UpfileOverride { - - private Repository[] repositoriesField; - - /// - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(FileRepository), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GitRepository), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GithubRepository), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(WebRepository), IsNullable=false)] - public Repository[] Repositories { - get { - return this.repositoriesField; - } - set { - this.repositoriesField = value; - } - } - } - /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs.meta b/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs.meta similarity index 76% rename from Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs.meta rename to Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs.meta index 0f765427..c0f8f884 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpfileOverride_Upset.cs.meta +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: f31c05a22425a4105acbdb8ac0e7787e -timeCreated: 1502376553 +guid: 13d1af682f47cb743a8dd02d2a992cce +timeCreated: 1511519038 licenseType: Free MonoImporter: serializedVersion: 2 diff --git a/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd b/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd new file mode 100644 index 00000000..5e626178 --- /dev/null +++ b/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Assets/Plugins/Editor/Uplift/Schemas/UpfileOverride.xsd.meta b/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd.meta similarity index 64% rename from Assets/Plugins/Editor/Uplift/Schemas/UpfileOverride.xsd.meta rename to Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd.meta index 9539f770..0f74ea37 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/UpfileOverride.xsd.meta +++ b/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 51d2d558af69e4d6f922b65714d5981b -timeCreated: 1502376553 +guid: 9b89badf13164df41b9dce4c1eb8e0e2 +timeCreated: 1511519038 licenseType: Free DefaultImporter: userData: diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs new file mode 100644 index 00000000..4b9d9760 --- /dev/null +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs @@ -0,0 +1,58 @@ +using System; +using System.IO; +using System.Xml.Serialization; +using UnityEngine; +using Uplift.Common; + +namespace Uplift.Schemas +{ + public partial class DotUplift + { + public static readonly string defaultName = ".Uplift.xml"; + + internal DotUplift() {} + + public static DotUplift FromDefaultFile() + { + return FromFile(defaultName); + } + + public static DotUplift FromFile(string name) + { + string source = System.IO.Path.Combine(GetHomePath(), name); + + StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); + + DotUplift result = new DotUplift { Repositories = new Repository[0], AuthenticationMethods = new RepositoryAuthentication[0] }; + using (FileStream fs = new FileStream(source, FileMode.Open)) + { + try + { + result = deserializer.Deserialize(fs); + + foreach (Repository repo in result.Repositories) + { + if (repo is FileRepository) + (repo as FileRepository).Path = Uplift.Common.FileSystemUtil.MakePathOSFriendly((repo as FileRepository).Path); + } + } + catch (InvalidOperationException) + { + Debug.LogError(string.Format("Global Override file at {0} is not well formed", source)); + } + + return result; + } + } + + public static string GetHomePath() + { + return (Environment.OSVersion.Platform == PlatformID.Unix || + Environment.OSVersion.Platform == PlatformID.MacOSX) + ? Environment.GetEnvironmentVariable("HOME") + : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%"); + } + + + } +} \ No newline at end of file diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs.meta b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs.meta new file mode 100644 index 00000000..a66c2a70 --- /dev/null +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b657dcbb299a45b41a18f14ee97ba9ed +timeCreated: 1511521202 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/Upfile.cs b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/Upfile.cs index bf5e59d2..fde25c53 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/Upfile.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/Upfile.cs @@ -73,7 +73,7 @@ internal static void InitializeInstance() // --- CLASS DECLARATION --- public static readonly string upfilePath = "Upfile.xml"; - public static readonly string globalOverridePath = ".Upfile.xml"; + public string overridePath; public static bool CheckForUpfile() { @@ -128,7 +128,7 @@ public void SaveFile() // Set Repositories foreach(Repository repo in Repositories) - if(!GetOverrides(GetOverrideFilePath()).Any(extraRepo => + if(!GetRepositoryOverrides().Any(extraRepo => extraRepo is FileRepository && Uplift.Common.FileSystemUtil.MakePathOSFriendly((extraRepo as FileRepository).Path) == Uplift.Common.FileSystemUtil.MakePathOSFriendly((repo as FileRepository).Path) )) @@ -242,77 +242,37 @@ private void AddOrReplaceDependency(XmlDocument document, DependencyDefinition d public virtual void LoadOverrides() { - string overrideFilePath = GetOverrideFilePath(); - try { - LoadOverrides(overrideFilePath); - } - catch (Exception e) - { - throw new ApplicationException("Uplift: Could not load Upfile overrides from "+overrideFilePath, e); - } - } - - internal virtual string GetOverrideFilePath() - { - string homePath = (Environment.OSVersion.Platform == PlatformID.Unix || - Environment.OSVersion.Platform == PlatformID.MacOSX) - ? Environment.GetEnvironmentVariable("HOME") - : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%"); + Repository[] overrides = GetRepositoryOverrides(); + if (Repositories == null) + { + Repositories = overrides; + } + else if(overrides != null) + { + int repositoriesSize = Repositories.Length + overrides.Length; - return Path.Combine(homePath, globalOverridePath); - } + Repository[] newRepositoryArray = new Repository[repositoriesSize]; + Array.Copy(Repositories, newRepositoryArray, Repositories.Length); + Array.Copy(overrides, 0, newRepositoryArray, Repositories.Length, overrides.Length); - internal virtual void LoadOverrides(string path) - { - Repository[] overrides = GetOverrides(path); - - if (Repositories == null) - { - Repositories = overrides; + Repositories = newRepositoryArray; + } } - else if(overrides != null) + catch (Exception e) { - int repositoriesSize = Repositories.Length + overrides.Length; - - Repository[] newRepositoryArray = new Repository[repositoriesSize]; - Array.Copy(Repositories, newRepositoryArray, Repositories.Length); - Array.Copy(overrides, 0, newRepositoryArray, Repositories.Length, overrides.Length); - - Repositories = newRepositoryArray; + Debug.LogError("Could not load repositories overrides from .Uplift file\n" + e); } } - internal virtual Repository[] GetOverrides(string path) - { - // If we don't have override file, ignore - if (!File.Exists(path)) return null; - - StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); - - using (FileStream fs = new FileStream(path, FileMode.Open)) - { - try - { - UpfileOverride upOverride = deserializer.Deserialize(fs); - - foreach (Repository repo in upOverride.Repositories) - { - if (repo is FileRepository) - (repo as FileRepository).Path = Uplift.Common.FileSystemUtil.MakePathOSFriendly((repo as FileRepository).Path); - } - return upOverride.Repositories; - } - catch (InvalidOperationException) - { - Debug.LogError(string.Format("Global Override file at {0} is not well formed", path)); - return null; - } - } + internal Repository[] GetRepositoryOverrides() + { + return string.IsNullOrEmpty(overridePath) ? + DotUplift.FromDefaultFile().Repositories : + DotUplift.FromFile(overridePath).Repositories; } - public string GetPackagesRootPath() { return Configuration.RepositoryPath.Location; diff --git a/Assets/Plugins/Editor/Uplift/Schemas/UpfileOverride.xsd b/Assets/Plugins/Editor/Uplift/Schemas/UpfileOverride.xsd deleted file mode 100644 index 2e8a2c01..00000000 --- a/Assets/Plugins/Editor/Uplift/Schemas/UpfileOverride.xsd +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs b/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs index e079ab5a..ddaa136d 100644 --- a/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs +++ b/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs @@ -124,29 +124,29 @@ public void LoadXmlAbsent() Assert.IsTrue(caught); } - [Test] - public void LoadPresentOverrideTest() - { - string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); - string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "UpfileOverride.xml"); - Upfile upfile = Upfile.LoadXml(upfilePath); - upfile.LoadOverrides(upfileOverridePath); - - Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Some","Repository"))), "Original repository not found"); - Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Another","Repository"))), "Override repository not found"); - } - - [Test] - public void LoadAbsentOverrideTest() - { - string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); - string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "NoUpfileInIt", "UpfileOverride.xml"); - Upfile upfile = Upfile.LoadXml(upfilePath); - upfile.LoadOverrides(upfileOverridePath); - - Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Some","Repository"))), "Original repository not found"); - Assert.IsFalse(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Another","Repository"))), "Loaded absent file"); - } + // [Test] + // public void LoadPresentOverrideTest() + // { + // string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); + // string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "DotUplift.xml"); + // Upfile upfile = Upfile.LoadXml(upfilePath); + // upfile.LoadOverrides(upfileOverridePath); + + // Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Some","Repository"))), "Original repository not found"); + // Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Another","Repository"))), "Override repository not found"); + // } + + // [Test] + // public void LoadAbsentOverrideTest() + // { + // string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); + // string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "NoUpfileInIt", "DotUplift.xml"); + // Upfile upfile = Upfile.LoadXml(upfilePath); + // upfile.LoadOverrides(upfileOverridePath); + + // Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Some","Repository"))), "Original repository not found"); + // Assert.IsFalse(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Another","Repository"))), "Loaded absent file"); + // } [Test] public void GetDestinationForBase() diff --git a/TestData/UpfileTest/UpfileOverride.xml b/TestData/UpfileTest/UpfileOverride.xml index f5e309f0..2aee39cf 100644 --- a/TestData/UpfileTest/UpfileOverride.xml +++ b/TestData/UpfileTest/UpfileOverride.xml @@ -1,5 +1,5 @@ - + - + From e9b33d8734c7d5d2bd1aa642ed8f984f8d88601c Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Fri, 24 Nov 2017 17:53:29 +0100 Subject: [PATCH 03/14] Implement GithubRepository Implement a working GithubRepository. This include a lot of changes in different places. --- .../Uplift/Common/StrictXmlSerializer.cs | 9 +- .../Uplift/Common/UnityPackageOpener.cs | 264 +++++++-------- ...ft_RepositoryTypes_Upbring_Upfile_Upset.cs | 4 +- .../Editor/Uplift/Schemas/DotUplift.xsd | 4 +- .../Schemas/Repositories/GithubRepository.cs | 84 ++++- .../Editor/Uplift/UpdateTool/Updater.cs | 183 +---------- Assets/Plugins/Editor/Uplift/Utils/GitHub.cs | 300 +++++++++++++++++- 7 files changed, 516 insertions(+), 332 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/Common/StrictXmlSerializer.cs b/Assets/Plugins/Editor/Uplift/Common/StrictXmlSerializer.cs index d0d282ac..e09dea4f 100644 --- a/Assets/Plugins/Editor/Uplift/Common/StrictXmlSerializer.cs +++ b/Assets/Plugins/Editor/Uplift/Common/StrictXmlSerializer.cs @@ -42,12 +42,17 @@ public StrictXmlDeserializer() { this.serializer = new XmlSerializer(typeof(T)); } - public T Deserialize(FileStream fileStream) { + public T Deserialize(Stream stream) { return StrictDeserialize( - () => { return serializer.Deserialize(fileStream); } + () => { return serializer.Deserialize(stream); } ); } + public T Deserialize(string xmlString) + { + return Deserialize(new MemoryStream (Convert.FromBase64String(xmlString))); + } + private T StrictDeserialize(Func block) { errors = new List (); diff --git a/Assets/Plugins/Editor/Uplift/Common/UnityPackageOpener.cs b/Assets/Plugins/Editor/Uplift/Common/UnityPackageOpener.cs index 60d6a1b8..02e264f4 100644 --- a/Assets/Plugins/Editor/Uplift/Common/UnityPackageOpener.cs +++ b/Assets/Plugins/Editor/Uplift/Common/UnityPackageOpener.cs @@ -48,9 +48,7 @@ public void Extract(string archivePath) Path.GetDirectoryName(archivePath) ); } - - // From https://github.com/Unity-Technologies/dotpackage-assistant/blob/master/DotPackageAssistant.cs - + /// /// Extracts a package from archivePath, and unpacks it at destinationPath /// @@ -58,167 +56,177 @@ public void Extract(string archivePath, string destinationPath) { using (FileStream compressedFileStream = File.OpenRead(archivePath)) { - GZipStream gzipFileStream = new GZipStream(compressedFileStream, CompressionMode.Decompress); - BinaryReader reader = new BinaryReader(gzipFileStream); - int readBufferSize = 1024 * 1024 * 10; - int tarBlockSize = 512; - byte[] readBuffer = new byte[readBufferSize]; - Regex hashPattern = new Regex(@"^([a-f\d]{20,})\/"); + Extract(compressedFileStream, destinationPath); + } + } + + // From https://github.com/Unity-Technologies/dotpackage-assistant/blob/master/DotPackageAssistant.cs - byte[] rawAsset = null; - byte[] rawMeta = null; - string path = null; + /// + /// Extracts a package from the input stream, and unpacks it at destinationPath + /// + public void Extract(Stream stream, string destinationPath) + { + GZipStream gzipFileStream = new GZipStream(stream, CompressionMode.Decompress); + BinaryReader reader = new BinaryReader(gzipFileStream); + int readBufferSize = 1024 * 1024 * 10; + int tarBlockSize = 512; + byte[] readBuffer = new byte[readBufferSize]; + Regex hashPattern = new Regex(@"^([a-f\d]{20,})\/"); - while (true) + byte[] rawAsset = null; + byte[] rawMeta = null; + string path = null; + + while (true) + { + byte[] headerBuffer = reader.ReadBytes(tarBlockSize); //We want the header, but the header is padded to a blocksize + if (headerBuffer.All(x => x == 0)) { - byte[] headerBuffer = reader.ReadBytes(tarBlockSize); //We want the header, but the header is padded to a blocksize - if (headerBuffer.All(x => x == 0)) - { - //Reached end of stream - break; - } - GCHandle handle = GCHandle.Alloc(headerBuffer, GCHandleType.Pinned); - TarHeader header; - header = (TarHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(TarHeader)); - handle.Free(); + //Reached end of stream + break; + } + GCHandle handle = GCHandle.Alloc(headerBuffer, GCHandleType.Pinned); + TarHeader header; + header = (TarHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(TarHeader)); + handle.Free(); - string filename; + string filename; + unsafe + { + filename = Marshal.PtrToStringAnsi((IntPtr)header.filename, 100); + } + filename = filename.Trim(); + filename = filename.TrimEnd(new char[] { (char)0 }); + + string ustar; + unsafe + { + ustar = Marshal.PtrToStringAnsi((IntPtr)header.ustar, 6); + } + string prefix = string.Empty; + if (ustar.Equals("ustar")) + { unsafe { - filename = Marshal.PtrToStringAnsi((IntPtr)header.filename, 100); + prefix = Marshal.PtrToStringAnsi((IntPtr)header.prefix, 155); } - filename = filename.Trim(); - filename = filename.TrimEnd(new char[] { (char)0 }); + } + prefix = prefix.Trim(); + prefix = prefix.TrimEnd(new char[] { (char)0 }); - string ustar; - unsafe + string fullname = prefix + filename; + Match hashMatch = hashPattern.Match(fullname); + + bool extractPathName = false; + bool extractRawMeta = false; + bool extractRawAsset = false; + + if (hashMatch.Success) + { + if (fullname.EndsWith("/asset.meta")) { - ustar = Marshal.PtrToStringAnsi((IntPtr)header.ustar, 6); + extractRawMeta = true; } - string prefix = string.Empty; - if (ustar.Equals("ustar")) + if (fullname.EndsWith("/asset")) { - unsafe - { - prefix = Marshal.PtrToStringAnsi((IntPtr)header.prefix, 155); - } + extractRawAsset = true; } - prefix = prefix.Trim(); - prefix = prefix.TrimEnd(new char[] { (char)0 }); - - string fullname = prefix + filename; - Match hashMatch = hashPattern.Match(fullname); + if (fullname.EndsWith("/pathname")) + { + extractPathName = true; + } + } - bool extractPathName = false; - bool extractRawMeta = false; - bool extractRawAsset = false; + string rawFilesize; + unsafe + { + rawFilesize = Marshal.PtrToStringAnsi((IntPtr)header.filesize, 12); + } + string filesize = rawFilesize.Trim(); + filesize = filesize.TrimEnd(new char[] { (char)0 }); - if (hashMatch.Success) + //Convert the octal string to a decimal number + try + { + int filesizeInt = Convert.ToInt32(filesize, 8); + int toRead = filesizeInt; + int toWrite = filesizeInt; + int modulus = filesizeInt % tarBlockSize; + if (modulus > 0) + toRead += (tarBlockSize - modulus); //Read the file and assume it's also 512 byte padded + while (toRead > 0) { - if (fullname.EndsWith("/asset.meta")) + int readThisTime = Math.Min(readBufferSize, toRead); + int writeThisTime = Math.Min(readBufferSize, toWrite); + readBuffer = reader.ReadBytes(readThisTime); + if (extractPathName) { - extractRawMeta = true; + if (toRead > readThisTime) + throw new Exception("Assumed a pathname would fit in a single read!"); + string pathnameFileContents = Encoding.UTF8.GetString(readBuffer, 0, filesizeInt); + path = FormatPath(pathnameFileContents.Split(new char[] { '\n' })[0]); + Debug.Log(path); } - if (fullname.EndsWith("/asset")) + else if(extractRawMeta) { - extractRawAsset = true; + if(rawMeta == null) rawMeta = new byte[0]; + int rawLength = rawMeta.Length; + Array.Resize(ref rawMeta, rawLength + writeThisTime); + Array.Copy(readBuffer, 0, rawMeta, rawLength, writeThisTime); } - if (fullname.EndsWith("/pathname")) + else if(extractRawAsset) { - extractPathName = true; + if(rawAsset == null) rawAsset = new byte[0]; + int rawLength = rawAsset.Length; + Array.Resize(ref rawAsset, rawLength + writeThisTime); + Array.Copy(readBuffer, 0, rawAsset, rawLength, writeThisTime); } + toRead -= readThisTime; + toWrite -= writeThisTime; } - - string rawFilesize; - unsafe + } + catch (Exception ex) + { + Debug.Log(String.Format("Caught Exception converting octal string to int: {0}", ex.Message)); + foreach (byte fsChar in filesize) { - rawFilesize = Marshal.PtrToStringAnsi((IntPtr)header.filesize, 12); + Debug.Log(fsChar); } - string filesize = rawFilesize.Trim(); - filesize = filesize.TrimEnd(new char[] { (char)0 }); + throw; + } + + // Path has been read, write to file system + if(path != null) + { + string target = Path.Combine(destinationPath, path); + Uplift.Common.FileSystemUtil.EnsureParentExists(target); - //Convert the octal string to a decimal number - try + // Asset or not? (ie directory) + if(rawAsset == null) { - int filesizeInt = Convert.ToInt32(filesize, 8); - int toRead = filesizeInt; - int toWrite = filesizeInt; - int modulus = filesizeInt % tarBlockSize; - if (modulus > 0) - toRead += (tarBlockSize - modulus); //Read the file and assume it's also 512 byte padded - while (toRead > 0) - { - int readThisTime = Math.Min(readBufferSize, toRead); - int writeThisTime = Math.Min(readBufferSize, toWrite); - readBuffer = reader.ReadBytes(readThisTime); - if (extractPathName) - { - if (toRead > readThisTime) - throw new Exception("Assumed a pathname would fit in a single read!"); - string pathnameFileContents = Encoding.UTF8.GetString(readBuffer, 0, filesizeInt); - path = FormatPath(pathnameFileContents.Split(new char[] { '\n' })[0]); - Debug.Log(path); - } - else if(extractRawMeta) - { - if(rawMeta == null) rawMeta = new byte[0]; - int rawLength = rawMeta.Length; - Array.Resize(ref rawMeta, rawLength + writeThisTime); - Array.Copy(readBuffer, 0, rawMeta, rawLength, writeThisTime); - } - else if(extractRawAsset) - { - if(rawAsset == null) rawAsset = new byte[0]; - int rawLength = rawAsset.Length; - Array.Resize(ref rawAsset, rawLength + writeThisTime); - Array.Copy(readBuffer, 0, rawAsset, rawLength, writeThisTime); - } - toRead -= readThisTime; - toWrite -= writeThisTime; - } + Directory.CreateDirectory(target); } - catch (Exception ex) + else { - Debug.Log(String.Format("Caught Exception converting octal string to int: {0}", ex.Message)); - foreach (byte fsChar in filesize) + using(var tw = new StreamWriter(target, false, new UTF8Encoding(false))) { - Debug.Log(fsChar); + tw.BaseStream.Write(rawAsset, 0, rawAsset.Length); } - throw; + rawAsset = null; } - // Path has been read, write to file system - if(path != null) + // Create meta + if(rawMeta != null) { - string target = Path.Combine(destinationPath, path); - Uplift.Common.FileSystemUtil.EnsureParentExists(target); - - // Asset or not? (ie directory) - if(rawAsset == null) + using(var tw = new StreamWriter(target + ".meta", false, new UTF8Encoding(false))) { - Directory.CreateDirectory(target); + tw.BaseStream.Write(rawMeta, 0, rawMeta.Length); } - else - { - using(var tw = new StreamWriter(target, false, new UTF8Encoding(false))) - { - tw.BaseStream.Write(rawAsset, 0, rawAsset.Length); - } - rawAsset = null; - } - - // Create meta - if(rawMeta != null) - { - using(var tw = new StreamWriter(target + ".meta", false, new UTF8Encoding(false))) - { - tw.BaseStream.Write(rawMeta, 0, rawMeta.Length); - } - rawMeta = null; - } - - path = null; + rawMeta = null; } + + path = null; } } } diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs b/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs index 27e9d233..a749c1aa 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs @@ -42,8 +42,8 @@ public Repository[] Repositories { } /// - [System.Xml.Serialization.XmlArrayItemAttribute("GitRepository", typeof(RepositoryToken), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute("GithubRepository", typeof(RepositoryCredentials), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(RepositoryCredentials), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(RepositoryToken), IsNullable=false)] public RepositoryAuthentication[] AuthenticationMethods { get { return this.authenticationMethodsField; diff --git a/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd b/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd index 5e626178..beb242b5 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd +++ b/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd @@ -17,8 +17,8 @@ - - + + diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs index 83954ed2..7c59ae45 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs @@ -23,31 +23,95 @@ // --- END LICENSE BLOCK --- using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Linq; +using System.IO; +using System.Text.RegularExpressions; +using UnityEngine; using Uplift.Common; +using Uplift.GitHubModule; +using System.Net; +using System.Security.Cryptography.X509Certificates; namespace Uplift.Schemas { public partial class GithubRepository : Repository { + private GitHubRelease release; + public override TemporaryDirectory DownloadPackage(Upset package) { - throw new NotImplementedException(); + string sourceName = Regex.Replace(package.MetaInformation.dirName, ".Upset.xml$", ".unitypackage", RegexOptions.IgnoreCase); + + release = GetPackagesRelease(); + if(!release.assets.Any(asset => asset.name.Contains(sourceName))) + throw new ArgumentException(string.Format("Package {0} is not present in this repository", package.PackageName)); + + GitHubAsset packageAsset = release.assets.First(asset => asset.name.Contains(sourceName)); + TemporaryDirectory td = new TemporaryDirectory(); + StreamReader sr = new StreamReader(GitHub.GetAssetStream(packageAsset, GetToken())); + UnityPackage unityPackage = new UnityPackage(); + unityPackage.Extract(sr.BaseStream, td.Path); + return td; } public override Upset[] ListPackages() { - // FIXME: - /* Github API: - * - Retrieve release tagged "packages" - * - foreach asset in the release, if asset is Upset, parse Upset and add it to LIST - * - return LIST - */ - throw new NotImplementedException(); + release = GetPackagesRelease(); + + GitHubAsset[] upsetAssets = release.assets.Where(asset => asset.name.EndsWith("Upset.xml")).ToArray(); + + List upsetList = new List(); + foreach(GitHubAsset asset in upsetAssets) + { + StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); + + StreamReader sr = new StreamReader(GitHub.GetAssetStream(asset, GetToken())); + UnityPackage unityPackage = new UnityPackage(); + Upset upset = deserializer.Deserialize(sr.BaseStream); + upset.MetaInformation.dirName = asset.name; + upsetList.Add(upset); + } + + return upsetList.ToArray(); } - private object GetPackagesRelease() + private GitHubRelease GetPackagesRelease() { - + if(release == null) + { + IEnumerator e = GitHub.LoadReleases(urlField, GetToken()); + do { Thread.Sleep(1000); } while (e.MoveNext()); + + GitHubRelease[] releases = (GitHubRelease[]) e.Current; + if (releases == null) + throw new ApplicationException("This github repository does not have releases"); + + if (!releases.Any(rel => rel.tag == "packages")) + throw new ApplicationException("This repository does not have a release untitled 'packages'"); + + release = releases.First(rel => rel.tag == "packages"); + } + + return release; + } + + private string GetToken() + { + DotUplift dotUplift = DotUplift.FromDefaultFile(); + if(dotUplift.AuthenticationMethods != null) + foreach(RepositoryAuthentication auth in dotUplift.AuthenticationMethods) + { + if(!(auth is RepositoryToken)) continue; + if(!(auth.Repository == urlField)) continue; + + return (auth as RepositoryToken).Token; + } + + Debug.LogWarning("Could not find authentication method for repository at " + urlField); + return null; } } } diff --git a/Assets/Plugins/Editor/Uplift/UpdateTool/Updater.cs b/Assets/Plugins/Editor/Uplift/UpdateTool/Updater.cs index 0405cbb1..619f67dd 100644 --- a/Assets/Plugins/Editor/Uplift/UpdateTool/Updater.cs +++ b/Assets/Plugins/Editor/Uplift/UpdateTool/Updater.cs @@ -46,151 +46,14 @@ public class Updater : MonoBehaviour private static readonly CultureInfo provider = CultureInfo.InvariantCulture; private static readonly string lastUpdateCheckKey = "UpliftLastUpdateCheck"; private static IEnumerator updateCoroutine; - private static readonly string[] githubCertificatesString = new string[] - { -// github.com -@"-----BEGIN CERTIFICATE----- -MIIHeTCCBmGgAwIBAgIQC/20CQrXteZAwwsWyVKaJzANBgkqhkiG9w0BAQsFADB1 -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMTQwMgYDVQQDEytEaWdpQ2VydCBTSEEyIEV4dGVuZGVk -IFZhbGlkYXRpb24gU2VydmVyIENBMB4XDTE2MDMxMDAwMDAwMFoXDTE4MDUxNzEy -MDAwMFowgf0xHTAbBgNVBA8MFFByaXZhdGUgT3JnYW5pemF0aW9uMRMwEQYLKwYB -BAGCNzwCAQMTAlVTMRkwFwYLKwYBBAGCNzwCAQITCERlbGF3YXJlMRAwDgYDVQQF -Ewc1MTU3NTUwMSQwIgYDVQQJExs4OCBDb2xpbiBQIEtlbGx5LCBKciBTdHJlZXQx -DjAMBgNVBBETBTk0MTA3MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5p -YTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEVMBMGA1UEChMMR2l0SHViLCBJbmMu -MRMwEQYDVQQDEwpnaXRodWIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEA54hc8pZclxgcupjiA/F/OZGRwm/ZlucoQGTNTKmBEgNsrn/mxhngWmPw -bAvUaLP//T79Jc+1WXMpxMiz9PK6yZRRFuIo0d2bx423NA6hOL2RTtbn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OtjSyuVnSn4QIgJ6RqvYbSX1vKLeX7vpnOfCAfS2Y8lB5R -NMwk6us2QiAAdgBo9pj4H2SCvjqM7rkoHUz8cVFdZ5PURNEKZ6y7T0/7xAAAAVNh -iennAAAEAwBHMEUCIQDZpd5S+3to8k7lcDeWBhiJASiYTk2rNAT26lVaM3xhWwIg -NUqrkIODZpRg+khhp8ag65B8mu0p4JUAmkRDbiYnRvYAdwBWFAaaL9fC7NP14b1E -sj7HRna5vJkRXMDvlJhV1onQ3QAAAVNhieqZAAAEAwBIMEYCIQDnm3WStlvE99GC -izSx+UGtGmQk2WTokoPgo1hfiv8zIAIhAPrYeXrBgseA9jUWWoB4IvmcZtshjXso -nT8MIG1u1zF8MA0GCSqGSIb3DQEBCwUAA4IBAQCLbNtkxuspqycq8h1EpbmAX0wM -5DoW7hM/FVdz4LJ3Kmftyk1yd8j/PSxRrAQN2Mr/frKeK8NE1cMji32mJbBqpWtK -/+wC+avPplBUbNpzP53cuTMF/QssxItPGNP5/OT9Aj1BxA/NofWZKh4ufV7cz3pY -RDS4BF+EEFQ4l5GY+yp4WJA/xSvYsTHWeWxRD1/nl62/Rd9FN2NkacRVozCxRVle -FrBHTFxqIP6kDnxiLElBrZngtY07ietaYZVLQN/ETyqLQftsf8TecwTklbjvm8NT -JqbaIVifYwqwNN+4lRxS3F5lNlA/il12IOgbRioLI62o8G0DaEUQgHNf8vSG ------END CERTIFICATE----- -", -// DigiCert High Assurance EV Root CA -@"-----BEGIN CERTIFICATE----- -MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j -ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL -MAkG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PqA8hjpodHRwOi8vY3JsNC5kaWdpY2Vy -dC5jb20vRGlnaUNlcnRIaWdoQXNzdXJhbmNlRVZSb290Q0EuY3JsMD0GA1UdIAQ2 -MDQwMgYEVR0gADAqMCgGCCsGAQUFBwIBFhxodHRwczovL3d3dy5kaWdpY2VydC5j -b20vQ1BTMB0GA1UdDgQWBBQ901Cl1qCt7vNKYApl0yHU+PjWDzAfBgNVHSMEGDAW -gBSxPsNpA/i/RwHUmCYaCALvY2QrwzANBgkqhkiG9w0BAQsFAAOCAQEAnbbQkIbh -hgLtxaDwNBx0wY12zIYKqPBKikLWP8ipTa18CK3mtlC4ohpNiAexKSHc59rGPCHg -4xFJcKx6HQGkyhE6V6t9VypAdP3THYUYUN9XR3WhfVUgLkc3UHKMf4Ib0mKPLQNa -2sPIoc4sUqIAY+tzunHISScjl2SFnjgOrWNoPLpSgVh5oywM395t6zHyuqB8bPEs -1OG9d4Q3A84ytciagRpKkk47RpqF/oOi+Z6Mo8wNXrM9zwR4jxQUezKcxwCmXMS1 -oVWNWlZopCJwqjyBcdmdqEU79OX2olHdx3ti6G8MdOu42vi/hw15UJGQmxg7kVkn -8TUoE6smftX3eg== ------END CERTIFICATE----- -", -// Amazon S3 (provider for the release download) *.s3.amazonaws.com -@"-----BEGIN CERTIFICATE----- -MIIFWjCCBEKgAwIBAgIQBVG1kvpTzyBSuLcPJ1zBWTANBgkqhkiG9w0BAQsFADBk -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSMwIQYDVQQDExpEaWdpQ2VydCBCYWx0aW1vcmUgQ0Et -MiBHMjAeFw0xNzA5MjIwMDAwMDBaFw0xOTAxMDMxMjAwMDBaMGsxCzAJBgNVBAYT -AlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdTZWF0dGxlMRgwFgYD -VQQKEw9BbWF6b24uY29tIEluYy4xGzAZBgNV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L0RpZ2lDZXJ0QmFsdGltb3JlQ0EtMkcyLmNydDAMBgNVHRMBAf8EAjAAMA0GCSqG -SIb3DQEBCwUAA4IBAQBydwnbmrwTTwhtCckZ9lDGoE+tdDFchjFG59dyzX1I4bHV -thVUwjEoc3VxngvmKb3cqLcHzXHNdoEdffRtw0IiEerPRsk7Nxh2p1HWR3cu/Hyp -kqGlObJADiw1DX4UDob735hevqcGN9M0rn9P/AbPK0HCn5uokLDmbeqe6u1YgdJL -m4skA/WsUsMCfsZY27RiZ+B162+laDD0oRiovOx5zKrzG/3yAFVutz2Bfud3QenU -3zt14ttnzFCcMlglW9oqffHMwQ1Smx/30ccDonoa1E02hnNmxeLyBwomPqd/ZYy6 -zSJW0aSi1DadkZsifpr65AwgSuN5uGEhQas0glsN ------END CERTIFICATE----- -" - }; - private static bool trustUnknown; public static void UpdateUplift(string url) { - trustUnknown = UpliftPreferences.TrustUnknownCertificates(); string unitypackageName = url.Split('/').Last(); DirectoryInfo assetsPath = new DirectoryInfo(Application.dataPath); string destination = Path.Combine(assetsPath.Parent.FullName, unitypackageName); - ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallback; + ServicePointManager.ServerCertificateValidationCallback = GitHub.CertificateValidationCallback; using (var client = new WebClient()) { client.DownloadFile(url, destination); @@ -255,49 +118,5 @@ private static IEnumerator CheckForUpdateRoutine() { DateTime.UtcNow.ToString(dateFormat, provider) ); } - - private static bool CertificateValidationCallback( - System.Object sender, - X509Certificate certificate, - X509Chain chain, - SslPolicyErrors sslPolicyErrors - ) - { - bool correct = true; - if(sslPolicyErrors == SslPolicyErrors.None) return true; - - X509Certificate[] githubCertificates = new X509Certificate[githubCertificatesString.Length]; - for(int i = 0; i < githubCertificatesString.Length; i++) - { - githubCertificates[i] = new X509Certificate(); - githubCertificates[i].Import(Encoding.ASCII.GetBytes(githubCertificatesString[i])); - } - - if(!(githubCertificates.Any(cert => cert.GetCertHashString() == certificate.GetCertHashString()) || trustUnknown)) - { - Debug.LogErrorFormat("The received certificate ({0}) is not known by Uplift. We cannot download the update package. You could update Uplift manually, or go to Preferences and set 'Trust unknown certificates' to true.", certificate.GetCertHashString()); - Debug.Log("Known certificates are:"); - foreach(X509Certificate cert in githubCertificates) - Debug.Log(" -- " + cert.GetCertHashString()); - return false; - } - - for (int i=0; i < chain.ChainStatus.Length; i++) { - if (chain.ChainStatus[i].Status == X509ChainStatusFlags.RevocationStatusUnknown) { - continue; - } - chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain; - chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; - chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan (0, 1, 0); - chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags; - bool chainIsValid = chain.Build ((X509Certificate2)certificate); - if (!chainIsValid) { - correct = false; - break; - } - } - - return correct; - } } } diff --git a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs index db799bd7..7890deda 100644 --- a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs +++ b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs @@ -25,7 +25,12 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Net; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; +using System.Text; using UnityEngine; using Uplift.Common; using Uplift.MiniJSON; @@ -34,16 +39,206 @@ namespace Uplift.GitHubModule { public class GitHub { - public static IEnumerator LoadReleases(string url) + private static readonly string[] githubCertificatesString = new string[] { - WWW www = new WWW (url); +// github.com +@"-----BEGIN CERTIFICATE----- +MIIHeTCCBmGgAwIBAgIQC/20CQrXteZAwwsWyVKaJzANBgkqhkiG9w0BAQsFADB1 +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMTQwMgYDVQQDEytEaWdpQ2VydCBTSEEyIEV4dGVuZGVk +IFZhbGlkY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ix+/UAyW4 +Sy1+SfIxV//PVuMumFcAdQDuS723dc5guuFCaR+r4Z5mow9+X7By2IMAxHuJeqj9 +ywAAAVmynEAuAAAEAwBGMEQCIHKrzA5IbzNEGMr2NmbmcJncuUTZHsHRJqU0eCZc +ian5AiBGGIX5adWUbjuFWiBb1ZnEkYsH81/ozbYGm5xY36IkxwB2ALvZ37wfinG1 +k5Qjl6qSe0c4V5UKq1LoGpCWZDaOHtGFAAABWbKcPl0AAAQDAEcwRQIhAJJMvQld +/c79AthFEj02qVdazf/Smjkb+ggN/DjrSB28AiAGEjSwxCj4r+PnUgzFtURbLofk +3iAvECLj9NZO2SZbdTANBgkqhkiG9w0BAQsFAAOCAQEAfIMvSUq9Z4EUniI976aO +kXTSPwa8GT+KFzlLpcyPmcU/x8ATptUsARnS96Yzx7BWtchprXsDWKdFLgmQ/YTT +dgUfy/Qyy7baJvCyLwBf4cJpsBdYaKxcige2dnAJjgVIvl8jEO4k+lD5BWgqQgRE +lDXj0SVVQQ1wd0MZTKWlDVbxmKsXzu5I0kWCG6/mfBcJc+6H+ABWc1YIK+pLP1jD +YcC8wj9fRkTCpZW/3lZ/Nt+snM1ujTRZ7RTBlRG2uJLpIX15JihSprEr3u39RHUp +HOODLNzVAw63zfJqCJvPtaCr+/KXKrqfjk9Z+e7Nmg+IxOf4M/Mxbox4KJvLlX8p +wQ== +-----END CERTIFICATE----- +", +// DigiCert High Assurance EV Root CA +@"-----BEGIN CERTIFICATE----- +MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j +ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL +MAkGA1UEBhMCVVMxFTATB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Y3JsNC5kaWdpY2Vy +dC5jb20vRGlnaUNlcnRIaWdoQXNzdXJhbmNlRVZSb290Q0EuY3JsMD0GA1UdIAQ2 +MDQwMgYEVR0gADAqMCgGCCsGAQUFBwIBFhxodHRwczovL3d3dy5kaWdpY2VydC5j +b20vQ1BTMB0GA1UdDgQWBBQ901Cl1qCt7vNKYApl0yHU+PjWDzAfBgNVHSMEGDAW +gBSxPsNpA/i/RwHUmCYaCALvY2QrwzANBgkqhkiG9w0BAQsFAAOCAQEAnbbQkIbh +hgLtxaDwNBx0wY12zIYKqPBKikLWP8ipTa18CK3mtlC4ohpNiAexKSHc59rGPCHg +4xFJcKx6HQGkyhE6V6t9VypAdP3THYUYUN9XR3WhfVUgLkc3UHKMf4Ib0mKPLQNa +2sPIoc4sUqIAY+tzunHISScjl2SFnjgOrWNoPLpSgVh5oywM395t6zHyuqB8bPEs +1OG9d4Q3A84ytciagRpKkk47RpqF/oOi+Z6Mo8wNXrM9zwR4jxQUezKcxwCmXMS1 +oVWNWlZopCJwqjyBcdmdqEU79OX2olHdx3ti6G8MdOu42vi/hw15UJGQmxg7kVkn +8TUoE6smftX3eg== +-----END CERTIFICATE----- +", +// Amazon S3 (provider for the release download) *.s3.amazonaws.com +@"-----BEGIN CERTIFICATE----- +MIIFWjCCBEKgAwIBAgIQBVG1kvpTzyBSuLcPJ1zBWTANBgkqhkiG9w0BAQsFADBk +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSMwIQYDVQQDExpEaWdpQ2VydCBCYWx0aW1vcmUgQ0Et +MiBHMjAeFw0xNzA5MjIwMDAwMDBaFw0xOTAxMDMxMjAwMDBaMGsxCzAJBgNVBAYT +AlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdTZWF0dGxlMRgwFgYD +VQQKEw9BbWF6b24uY29tIEluYy4xGzAZBgNVBAMMEiouczMuYW1h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QmFsdGltb3JlQ0EtMkcyLmNydDAMBgNVHRMBAf8EAjAAMA0GCSqG +SIb3DQEBCwUAA4IBAQBydwnbmrwTTwhtCckZ9lDGoE+tdDFchjFG59dyzX1I4bHV +thVUwjEoc3VxngvmKb3cqLcHzXHNdoEdffRtw0IiEerPRsk7Nxh2p1HWR3cu/Hyp +kqGlObJADiw1DX4UDob735hevqcGN9M0rn9P/AbPK0HCn5uokLDmbeqe6u1YgdJL +m4skA/WsUsMCfsZY27RiZ+B162+laDD0oRiovOx5zKrzG/3yAFVutz2Bfud3QenU +3zt14ttnzFCcMlglW9oqffHMwQ1Smx/30ccDonoa1E02hnNmxeLyBwomPqd/ZYy6 +zSJW0aSi1DadkZsifpr65AwgSuN5uGEhQas0glsN +-----END CERTIFICATE----- +" + }; + + + public static IEnumerator LoadReleases(string url, string authToken = null) + { + WWW www = string.IsNullOrEmpty(authToken) ? + new WWW (url) : + new WWW ( + url, + null, + new Dictionary + { + { "Authorization", "token " + authToken } + }); while (www.isDone == false) yield return null; yield return www; if(!string.IsNullOrEmpty(www.error)) { - Debug.Log(www.error); + Debug.LogError(www.error); + Debug.LogWarning(www.text); } else { @@ -86,17 +281,108 @@ private static GitHubAsset[] ExtractAssets(Dictionary release) foreach (Dictionary asset in assets) { assetList.Add(new GitHubAsset { + apiURL = (string)asset["url"], htmlURL = (string)asset["browser_download_url"], - name = (string)asset["name"] + name = (string)asset["name"], + contentType = (string)asset["content_type"] }); } return assetList.ToArray(); } + + public static X509Certificate[] GetCertificates() + { + X509Certificate[] githubCertificates = new X509Certificate[githubCertificatesString.Length]; + for(int i = 0; i < githubCertificatesString.Length; i++) + { + githubCertificates[i] = new X509Certificate(); + githubCertificates[i].Import(Encoding.ASCII.GetBytes(githubCertificatesString[i])); + } + + return githubCertificates; + } + + public static bool CertificateValidationCallback( + System.Object sender, + X509Certificate certificate, + X509Chain chain, + SslPolicyErrors sslPolicyErrors + ) + { + bool correct = true; + if(sslPolicyErrors == SslPolicyErrors.None) return true; + + X509Certificate[] githubCertificates = GetCertificates(); + + if(!(githubCertificates.Any(cert => cert.GetCertHashString() == certificate.GetCertHashString()) || UpliftPreferences.TrustUnknownCertificates())) + { + Debug.LogErrorFormat("The received certificate ({0}) is not known by Uplift. We cannot download the update package. You could update Uplift manually, or go to Preferences and set 'Trust unknown certificates' to true.", certificate.GetCertHashString()); + Debug.Log("Known certificates are:"); + foreach(X509Certificate cert in githubCertificates) + Debug.Log(" -- " + cert.GetCertHashString()); + return false; + } + + for (int i=0; i < chain.ChainStatus.Length; i++) { + if (chain.ChainStatus[i].Status == X509ChainStatusFlags.RevocationStatusUnknown) { + continue; + } + chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain; + chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; + chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan (0, 1, 0); + chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags; + bool chainIsValid = chain.Build ((X509Certificate2)certificate); + if (!chainIsValid) { + correct = false; + break; + } + } + + return correct; + } + + public static Stream GetAssetStream(GitHubAsset asset) + { + return GetAssetStream(asset, ""); + } + public static Stream GetAssetStream(GitHubAsset asset, string token) + { + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(asset.apiURL); + request.Method = "GET"; + if(!string.IsNullOrEmpty(token)) + request.Headers["Authorization"] = "token " + token; + request.Accept = "application/octet-stream"; + request.UserAgent = "curl/7.47.0"; + request.AllowAutoRedirect = false; + + ServicePointManager.ServerCertificateValidationCallback = GitHub.CertificateValidationCallback; + Uri address; + HttpStatusCode responseStatus; + using(HttpWebResponse response = (HttpWebResponse)request.GetResponse()) + { + responseStatus = response.StatusCode; + if((int)response.StatusCode < 300 || (int)response.StatusCode > 399) + throw new ApplicationException("Request should be redirected"); + address = new Uri(response.GetResponseHeader("Location")); + } + + request = (HttpWebRequest)WebRequest.Create(address); + request.Method = "GET"; + request.UserAgent = "curl/7.47.0"; + HttpWebResponse finalResponse = (HttpWebResponse)request.GetResponse(); + responseStatus = finalResponse.StatusCode; + if((int)finalResponse.StatusCode >= 200 && (int)finalResponse.StatusCode <= 299) + { + return finalResponse.GetResponseStream(); + } + + throw new ApplicationException("Could not get asset at " + asset.apiURL); + } } // Based on https://developer.github.com/v3/repos/releases/ - public struct GitHubRelease + public class GitHubRelease { public string tag; public string body; @@ -104,9 +390,11 @@ public struct GitHubRelease public GitHubAsset[] assets; } - public struct GitHubAsset + public class GitHubAsset { public string htmlURL; + public string apiURL; public string name; + public string contentType; } } From 4dc83e25459afc2132dc0b451b8491bf82c2cc13 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Fri, 24 Nov 2017 18:36:36 +0100 Subject: [PATCH 04/14] Add license blocks --- ...ft_RepositoryTypes_Upbring_Upfile_Upset.cs | 26 ++++++++++++++++++- .../Uplift/Schemas/Extensions/DotUpfile.cs | 24 +++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs b/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs index a749c1aa..e04ed999 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs @@ -1,4 +1,28 @@ -//------------------------------------------------------------------------------ +// --- BEGIN LICENSE BLOCK --- +/* + * Copyright (c) 2017-present WeWantToKnow AS + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// --- END LICENSE BLOCK --- + +//------------------------------------------------------------------------------ // // Ce code a été généré par un outil. // Version du runtime :2.0.50727.8825 diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs index 4b9d9760..c40dcc7b 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs @@ -1,3 +1,27 @@ +// --- BEGIN LICENSE BLOCK --- +/* + * Copyright (c) 2017-present WeWantToKnow AS + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// --- END LICENSE BLOCK --- + using System; using System.IO; using System.Xml.Serialization; From f7b42808456cdf3d510fd694aeb407a031668454 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Fri, 24 Nov 2017 18:58:28 +0100 Subject: [PATCH 05/14] Add progress bar to Upset Parsing --- .../Uplift/Schemas/Repositories/GithubRepository.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs index 7c59ae45..4ab0f150 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs @@ -29,6 +29,7 @@ using System.Linq; using System.IO; using System.Text.RegularExpressions; +using UnityEditor; using UnityEngine; using Uplift.Common; using Uplift.GitHubModule; @@ -63,7 +64,11 @@ public override Upset[] ListPackages() GitHubAsset[] upsetAssets = release.assets.Where(asset => asset.name.EndsWith("Upset.xml")).ToArray(); + string progressBarTitle = "Parsing Upsets from GitHub repository"; + int index = 0; + List upsetList = new List(); + EditorUtility.DisplayProgressBar(progressBarTitle, "Please wait a little bit while Uplift parses the Upset in the GitHub repository at " + urlField, (100f * (float)index) / upsetAssets.Length); foreach(GitHubAsset asset in upsetAssets) { StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); @@ -73,8 +78,14 @@ public override Upset[] ListPackages() Upset upset = deserializer.Deserialize(sr.BaseStream); upset.MetaInformation.dirName = asset.name; upsetList.Add(upset); + EditorUtility.DisplayProgressBar( + progressBarTitle, + "Parsing " + asset.name, + (100f * (float)(++index)) / upsetAssets.Length + ); } + EditorUtility.ClearProgressBar(); return upsetList.ToArray(); } From f21defff5e079a0fb9d55babd076ffec77e8f43d Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Mon, 27 Nov 2017 10:13:47 +0100 Subject: [PATCH 06/14] Various syntax and naming modifications --- ...es_Upbring_Upfile_UpliftSettings_Upset.cs} | 494 ++++++++---------- ...bring_Upfile_UpliftSettings_Upset.cs.meta} | 4 +- .../Uplift/Schemas/Extensions/Upfile.cs | 43 +- .../{DotUpfile.cs => UpliftSettings.cs} | 12 +- .../UpliftSettings.cs.meta} | 4 +- .../Schemas/Repositories/GithubRepository.cs | 31 +- .../{DotUplift.xsd => UpliftSettings.xsd} | 10 +- ...plift.xsd.meta => UpliftSettings.xsd.meta} | 4 +- .../Uplift/Testing/UnitTesting/UpfileTest.cs | 4 +- Assets/Plugins/Editor/Uplift/Utils/GitHub.cs | 4 +- ...{UpfileOverride.xml => UpliftSettings.xml} | 4 +- 11 files changed, 283 insertions(+), 331 deletions(-) rename Assets/Plugins/Editor/Uplift/Schemas/{Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs => Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs} (90%) rename Assets/Plugins/Editor/Uplift/Schemas/{Extensions/DotUpfile.cs.meta => Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs.meta} (76%) rename Assets/Plugins/Editor/Uplift/Schemas/Extensions/{DotUpfile.cs => UpliftSettings.cs} (85%) rename Assets/Plugins/Editor/Uplift/Schemas/{Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs.meta => Extensions/UpliftSettings.cs.meta} (76%) rename Assets/Plugins/Editor/Uplift/Schemas/{DotUplift.xsd => UpliftSettings.xsd} (86%) rename Assets/Plugins/Editor/Uplift/Schemas/{DotUplift.xsd.meta => UpliftSettings.xsd.meta} (64%) rename TestData/UpfileTest/{UpfileOverride.xml => UpliftSettings.xml} (72%) diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs similarity index 90% rename from Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs rename to Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs index e04ed999..a06dde9b 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs @@ -1,28 +1,4 @@ -// --- BEGIN LICENSE BLOCK --- -/* - * Copyright (c) 2017-present WeWantToKnow AS - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -// --- END LICENSE BLOCK --- - -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // Ce code a été généré par un outil. // Version du runtime :2.0.50727.8825 @@ -39,258 +15,6 @@ namespace Uplift.Schemas { using System.Xml.Serialization; - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] - public partial class DotUplift { - - private Repository[] repositoriesField; - - private RepositoryAuthentication[] authenticationMethodsField; - - /// - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(FileRepository), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GitRepository), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GithubRepository), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(WebRepository), IsNullable=false)] - public Repository[] Repositories { - get { - return this.repositoriesField; - } - set { - this.repositoriesField = value; - } - } - - /// - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(RepositoryCredentials), IsNullable=false)] - [System.Xml.Serialization.XmlArrayItemAttribute(typeof(RepositoryToken), IsNullable=false)] - public RepositoryAuthentication[] AuthenticationMethods { - get { - return this.authenticationMethodsField; - } - set { - this.authenticationMethodsField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class FileRepository : Repository { - - private string pathField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Path { - get { - return this.pathField; - } - set { - this.pathField = value; - } - } - } - - /// - [System.Xml.Serialization.XmlIncludeAttribute(typeof(FileRepository))] - [System.Xml.Serialization.XmlIncludeAttribute(typeof(GitRepository))] - [System.Xml.Serialization.XmlIncludeAttribute(typeof(GithubRepository))] - [System.Xml.Serialization.XmlIncludeAttribute(typeof(WebRepository))] - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class Repository { - - private string extractPathField; - - private string valueField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string ExtractPath { - get { - return this.extractPathField; - } - set { - this.extractPathField = value; - } - } - - /// - [System.Xml.Serialization.XmlTextAttribute()] - public string Value { - get { - return this.valueField; - } - set { - this.valueField = value; - } - } - } - - /// - [System.Xml.Serialization.XmlIncludeAttribute(typeof(RepositoryCredentials))] - [System.Xml.Serialization.XmlIncludeAttribute(typeof(RepositoryToken))] - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public abstract partial class RepositoryAuthentication { - - private string repositoryField; - - private string valueField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Repository { - get { - return this.repositoryField; - } - set { - this.repositoryField = value; - } - } - - /// - [System.Xml.Serialization.XmlTextAttribute()] - public string Value { - get { - return this.valueField; - } - set { - this.valueField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class RepositoryCredentials : RepositoryAuthentication { - - private string loginField; - - private string passwordField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Login { - get { - return this.loginField; - } - set { - this.loginField = value; - } - } - - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Password { - get { - return this.passwordField; - } - set { - this.passwordField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class RepositoryToken : RepositoryAuthentication { - - private string tokenField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public string Token { - get { - return this.tokenField; - } - set { - this.tokenField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GitRepository : Repository { - - private string urlField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] - public string Url { - get { - return this.urlField; - } - set { - this.urlField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GithubRepository : Repository { - - private string urlField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] - public string Url { - get { - return this.urlField; - } - set { - this.urlField = value; - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class WebRepository : Repository { - - private string urlField; - - /// - [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] - public string Url { - get { - return this.urlField; - } - set { - this.urlField = value; - } - } - } - /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] @@ -735,6 +459,128 @@ public string Value { } } + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class FileRepository : Repository { + + private string pathField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Path { + get { + return this.pathField; + } + set { + this.pathField = value; + } + } + } + + /// + [System.Xml.Serialization.XmlIncludeAttribute(typeof(FileRepository))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(GitRepository))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(GithubRepository))] + [System.Xml.Serialization.XmlIncludeAttribute(typeof(WebRepository))] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class Repository { + + private string extractPathField; + + private string valueField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string ExtractPath { + get { + return this.extractPathField; + } + set { + this.extractPathField = value; + } + } + + /// + [System.Xml.Serialization.XmlTextAttribute()] + public string Value { + get { + return this.valueField; + } + set { + this.valueField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GitRepository : Repository { + + private string urlField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] + public string Url { + get { + return this.urlField; + } + set { + this.urlField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GithubRepository : Repository { + + private string urlField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] + public string Url { + get { + return this.urlField; + } + set { + this.urlField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class WebRepository : Repository { + + private string urlField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] + public string Url { + get { + return this.urlField; + } + set { + this.urlField = value; + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] @@ -863,6 +709,100 @@ public string Location { } } + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] + public partial class UpliftSettings { + + private Repository[] repositoriesField; + + private RepositoryToken[] authenticationMethodsField; + + /// + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(FileRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GitRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(GithubRepository), IsNullable=false)] + [System.Xml.Serialization.XmlArrayItemAttribute(typeof(WebRepository), IsNullable=false)] + public Repository[] Repositories { + get { + return this.repositoriesField; + } + set { + this.repositoriesField = value; + } + } + + /// + [System.Xml.Serialization.XmlArrayItemAttribute(IsNullable=false)] + public RepositoryToken[] AuthenticationMethods { + get { + return this.authenticationMethodsField; + } + set { + this.authenticationMethodsField = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class RepositoryToken : RepositoryAuthentication { + + private string tokenField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Token { + get { + return this.tokenField; + } + set { + this.tokenField = value; + } + } + } + + /// + [System.Xml.Serialization.XmlIncludeAttribute(typeof(RepositoryToken))] + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public abstract partial class RepositoryAuthentication { + + private string repositoryField; + + private string valueField; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public string Repository { + get { + return this.repositoryField; + } + set { + this.repositoryField = value; + } + } + + /// + [System.Xml.Serialization.XmlTextAttribute()] + public string Value { + get { + return this.valueField; + } + set { + this.valueField = value; + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs.meta b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs.meta similarity index 76% rename from Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs.meta rename to Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs.meta index a66c2a70..8d697798 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs.meta +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: b657dcbb299a45b41a18f14ee97ba9ed -timeCreated: 1511521202 +guid: 5339aac872f92114eae5f79f9e64ef45 +timeCreated: 1511774104 licenseType: Free MonoImporter: serializedVersion: 2 diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/Upfile.cs b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/Upfile.cs index fde25c53..9b2b71ab 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/Upfile.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/Upfile.cs @@ -242,35 +242,38 @@ private void AddOrReplaceDependency(XmlDocument document, DependencyDefinition d public virtual void LoadOverrides() { - try + Repository[] overrides = GetRepositoryOverrides(); + if (Repositories == null) { - Repository[] overrides = GetRepositoryOverrides(); - if (Repositories == null) - { - Repositories = overrides; - } - else if(overrides != null) - { - int repositoriesSize = Repositories.Length + overrides.Length; + Repositories = overrides; + } + else if(overrides != null) + { + int repositoriesSize = Repositories.Length + overrides.Length; - Repository[] newRepositoryArray = new Repository[repositoriesSize]; - Array.Copy(Repositories, newRepositoryArray, Repositories.Length); - Array.Copy(overrides, 0, newRepositoryArray, Repositories.Length, overrides.Length); + Repository[] newRepositoryArray = new Repository[repositoriesSize]; + Array.Copy(Repositories, newRepositoryArray, Repositories.Length); + Array.Copy(overrides, 0, newRepositoryArray, Repositories.Length, overrides.Length); - Repositories = newRepositoryArray; - } + Repositories = newRepositoryArray; + } + } + + internal Repository[] GetRepositoryOverrides() + { + Repository[] result = new Repository[0]; + try + { + result = string.IsNullOrEmpty(overridePath) ? + UpliftSettings.FromDefaultFile().Repositories : + UpliftSettings.FromFile(overridePath).Repositories; } catch (Exception e) { Debug.LogError("Could not load repositories overrides from .Uplift file\n" + e); } - } - internal Repository[] GetRepositoryOverrides() - { - return string.IsNullOrEmpty(overridePath) ? - DotUplift.FromDefaultFile().Repositories : - DotUplift.FromFile(overridePath).Repositories; + return result; } public string GetPackagesRootPath() diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs similarity index 85% rename from Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs rename to Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs index c40dcc7b..6551c1a1 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/DotUpfile.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs @@ -30,24 +30,24 @@ namespace Uplift.Schemas { - public partial class DotUplift + public partial class UpliftSettings { public static readonly string defaultName = ".Uplift.xml"; - internal DotUplift() {} + internal UpliftSettings() {} - public static DotUplift FromDefaultFile() + public static UpliftSettings FromDefaultFile() { return FromFile(defaultName); } - public static DotUplift FromFile(string name) + public static UpliftSettings FromFile(string name) { string source = System.IO.Path.Combine(GetHomePath(), name); - StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); + StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); - DotUplift result = new DotUplift { Repositories = new Repository[0], AuthenticationMethods = new RepositoryAuthentication[0] }; + UpliftSettings result = new UpliftSettings { Repositories = new Repository[0], AuthenticationMethods = new RepositoryToken[0] }; using (FileStream fs = new FileStream(source, FileMode.Open)) { try diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs.meta b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs.meta similarity index 76% rename from Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs.meta rename to Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs.meta index c0f8f884..05d0be09 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_DotUplift_RepositoryTypes_Upbring_Upfile_Upset.cs.meta +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 13d1af682f47cb743a8dd02d2a992cce -timeCreated: 1511519038 +guid: 9a9abfd729e23ce4dbb509e04d6ed67c +timeCreated: 1511774105 licenseType: Free MonoImporter: serializedVersion: 2 diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs index 4ab0f150..c6400f60 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs @@ -52,9 +52,11 @@ public override TemporaryDirectory DownloadPackage(Upset package) GitHubAsset packageAsset = release.assets.First(asset => asset.name.Contains(sourceName)); TemporaryDirectory td = new TemporaryDirectory(); - StreamReader sr = new StreamReader(GitHub.GetAssetStream(packageAsset, GetToken())); - UnityPackage unityPackage = new UnityPackage(); - unityPackage.Extract(sr.BaseStream, td.Path); + using(StreamReader sr = new StreamReader(GitHub.GetAssetStream(packageAsset, GetToken()))) + { + UnityPackage unityPackage = new UnityPackage(); + unityPackage.Extract(sr.BaseStream, td.Path); + } return td; } @@ -68,16 +70,18 @@ public override Upset[] ListPackages() int index = 0; List upsetList = new List(); - EditorUtility.DisplayProgressBar(progressBarTitle, "Please wait a little bit while Uplift parses the Upset in the GitHub repository at " + urlField, (100f * (float)index) / upsetAssets.Length); + EditorUtility.DisplayProgressBar(progressBarTitle, "Please wait a little bit while Uplift parses the Upset in the GitHub repository at " + urlField, 0f); foreach(GitHubAsset asset in upsetAssets) { StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); - StreamReader sr = new StreamReader(GitHub.GetAssetStream(asset, GetToken())); - UnityPackage unityPackage = new UnityPackage(); - Upset upset = deserializer.Deserialize(sr.BaseStream); - upset.MetaInformation.dirName = asset.name; - upsetList.Add(upset); + using(StreamReader sr = new StreamReader(GitHub.GetAssetStream(asset, GetToken()))) + { + Upset upset = deserializer.Deserialize(sr.BaseStream); + upset.MetaInformation.dirName = asset.name; + upsetList.Add(upset); + } + EditorUtility.DisplayProgressBar( progressBarTitle, "Parsing " + asset.name, @@ -100,10 +104,11 @@ private GitHubRelease GetPackagesRelease() if (releases == null) throw new ApplicationException("This github repository does not have releases"); - if (!releases.Any(rel => rel.tag == "packages")) - throw new ApplicationException("This repository does not have a release untitled 'packages'"); + release = releases.FirstOrDefault(rel => rel.tag == "packages"); + + if (release == null) + throw new ApplicationException("This repository does not have a release tagged as 'packages'"); - release = releases.First(rel => rel.tag == "packages"); } return release; @@ -111,7 +116,7 @@ private GitHubRelease GetPackagesRelease() private string GetToken() { - DotUplift dotUplift = DotUplift.FromDefaultFile(); + UpliftSettings dotUplift = UpliftSettings.FromDefaultFile(); if(dotUplift.AuthenticationMethods != null) foreach(RepositoryAuthentication auth in dotUplift.AuthenticationMethods) { diff --git a/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd b/Assets/Plugins/Editor/Uplift/Schemas/UpliftSettings.xsd similarity index 86% rename from Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd rename to Assets/Plugins/Editor/Uplift/Schemas/UpliftSettings.xsd index beb242b5..7def32e7 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd +++ b/Assets/Plugins/Editor/Uplift/Schemas/UpliftSettings.xsd @@ -6,9 +6,9 @@ - + - + @@ -18,7 +18,7 @@ - + @@ -36,6 +36,8 @@ + + + diff --git a/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd.meta b/Assets/Plugins/Editor/Uplift/Schemas/UpliftSettings.xsd.meta similarity index 64% rename from Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd.meta rename to Assets/Plugins/Editor/Uplift/Schemas/UpliftSettings.xsd.meta index 0f74ea37..5e5d9c27 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/DotUplift.xsd.meta +++ b/Assets/Plugins/Editor/Uplift/Schemas/UpliftSettings.xsd.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 9b89badf13164df41b9dce4c1eb8e0e2 -timeCreated: 1511519038 +guid: e5bbfb085045cdc46bd5d2486d202994 +timeCreated: 1511774104 licenseType: Free DefaultImporter: userData: diff --git a/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs b/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs index ddaa136d..43654cd1 100644 --- a/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs +++ b/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs @@ -128,7 +128,7 @@ public void LoadXmlAbsent() // public void LoadPresentOverrideTest() // { // string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); - // string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "DotUplift.xml"); + // string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "UpliftSettings.xml"); // Upfile upfile = Upfile.LoadXml(upfilePath); // upfile.LoadOverrides(upfileOverridePath); @@ -140,7 +140,7 @@ public void LoadXmlAbsent() // public void LoadAbsentOverrideTest() // { // string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); - // string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "NoUpfileInIt", "DotUplift.xml"); + // string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "NoUpfileInIt", "UpliftSettings.xml"); // Upfile upfile = Upfile.LoadXml(upfilePath); // upfile.LoadOverrides(upfileOverridePath); diff --git a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs index 7890deda..10e13e64 100644 --- a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs +++ b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs @@ -353,7 +353,7 @@ public static Stream GetAssetStream(GitHubAsset asset, string token) if(!string.IsNullOrEmpty(token)) request.Headers["Authorization"] = "token " + token; request.Accept = "application/octet-stream"; - request.UserAgent = "curl/7.47.0"; + request.UserAgent = "Uplift GithubRepository/1.0 - https://github.com/DragonBox/uplift"; request.AllowAutoRedirect = false; ServicePointManager.ServerCertificateValidationCallback = GitHub.CertificateValidationCallback; @@ -369,7 +369,7 @@ public static Stream GetAssetStream(GitHubAsset asset, string token) request = (HttpWebRequest)WebRequest.Create(address); request.Method = "GET"; - request.UserAgent = "curl/7.47.0"; + request.UserAgent = "Uplift GithubRepository/1.0 - https://github.com/DragonBox/uplift"; HttpWebResponse finalResponse = (HttpWebResponse)request.GetResponse(); responseStatus = finalResponse.StatusCode; if((int)finalResponse.StatusCode >= 200 && (int)finalResponse.StatusCode <= 299) diff --git a/TestData/UpfileTest/UpfileOverride.xml b/TestData/UpfileTest/UpliftSettings.xml similarity index 72% rename from TestData/UpfileTest/UpfileOverride.xml rename to TestData/UpfileTest/UpliftSettings.xml index 2aee39cf..e274ed07 100644 --- a/TestData/UpfileTest/UpfileOverride.xml +++ b/TestData/UpfileTest/UpliftSettings.xml @@ -1,5 +1,5 @@ - + - + From a33bc18dc3ea1f11a94ed067366a20780fe6b84c Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Mon, 27 Nov 2017 10:53:03 +0100 Subject: [PATCH 07/14] Move .Uplift.xml to .uplift/settings.xml --- .../Schemas/Extensions/UpliftSettings.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs index 6551c1a1..2123003c 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs @@ -27,27 +27,37 @@ using System.Xml.Serialization; using UnityEngine; using Uplift.Common; +using FileSystemUtil = Uplift.Common.FileSystemUtil; namespace Uplift.Schemas { public partial class UpliftSettings { - public static readonly string defaultName = ".Uplift.xml"; + public static readonly string folderName = ".uplift"; + public static readonly string defaultFileName = "settings.xml"; internal UpliftSettings() {} public static UpliftSettings FromDefaultFile() { - return FromFile(defaultName); + return FromFile(defaultFileName); } public static UpliftSettings FromFile(string name) { - string source = System.IO.Path.Combine(GetHomePath(), name); + UpliftSettings result = new UpliftSettings { Repositories = new Repository[0], AuthenticationMethods = new RepositoryToken[0] }; + + string sourceDir = System.IO.Path.Combine(GetHomePath(), folderName); + string source = System.IO.Path.Combine(sourceDir, name); + + if(!Directory.Exists(sourceDir) || !File.Exists(source)) + { + Debug.Log("No local settings file detected."); + return result; + } StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); - UpliftSettings result = new UpliftSettings { Repositories = new Repository[0], AuthenticationMethods = new RepositoryToken[0] }; using (FileStream fs = new FileStream(source, FileMode.Open)) { try @@ -57,7 +67,7 @@ public static UpliftSettings FromFile(string name) foreach (Repository repo in result.Repositories) { if (repo is FileRepository) - (repo as FileRepository).Path = Uplift.Common.FileSystemUtil.MakePathOSFriendly((repo as FileRepository).Path); + (repo as FileRepository).Path = FileSystemUtil.MakePathOSFriendly((repo as FileRepository).Path); } } catch (InvalidOperationException) From c8ec0114f4a293d86329d33c75222d22e8ce9955 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Mon, 27 Nov 2017 10:54:26 +0100 Subject: [PATCH 08/14] Make package loading non-blocking on failure --- .../Editor/Uplift/Packages/PackageList.cs | 30 ++++++++++++++----- .../Schemas/Repositories/GithubRepository.cs | 5 ++++ Assets/Plugins/Editor/Uplift/Utils/GitHub.cs | 2 ++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/Packages/PackageList.cs b/Assets/Plugins/Editor/Uplift/Packages/PackageList.cs index 1ad447b3..33f3ed99 100644 --- a/Assets/Plugins/Editor/Uplift/Packages/PackageList.cs +++ b/Assets/Plugins/Editor/Uplift/Packages/PackageList.cs @@ -80,16 +80,30 @@ public void RefreshPackages() public void LoadPackages(Repository repository) { - PackageRepo pr; - foreach (Upset package in repository.ListPackages()) + using(LogAggregator la = LogAggregator.InUnity( + "Packages successfully loaded from {0}", + "Packages successfully loaded from {0}, but warning were raised", + "Error(s) occured while loading packages from {0}", + repository.ToString() + )) { - pr = new PackageRepo + PackageRepo pr; + try { - Package = package, - Repository = repository - }; - Packages.Add(pr); - + foreach (Upset package in repository.ListPackages()) + { + pr = new PackageRepo + { + Package = package, + Repository = repository + }; + Packages.Add(pr); + } + } + catch(Exception e) + { + Debug.LogException(e); + } } } diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs index c6400f60..03320477 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs @@ -129,5 +129,10 @@ private string GetToken() Debug.LogWarning("Could not find authentication method for repository at " + urlField); return null; } + + public override string ToString() + { + return "GithubRepository: " + urlField; + } } } diff --git a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs index 10e13e64..5d632573 100644 --- a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs +++ b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs @@ -239,6 +239,8 @@ public static IEnumerator LoadReleases(string url, string authToken = null) { Debug.LogError(www.error); Debug.LogWarning(www.text); + + yield return null; } else { From 6ac3d95c9ae11f883f3c1e57558a5d6271fe4acc Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Mon, 27 Nov 2017 11:07:38 +0100 Subject: [PATCH 09/14] Fix tests --- .../Schemas/Extensions/UpliftSettings.cs | 12 +++-- .../Uplift/Testing/Helpers/UpfileExposer.cs | 5 -- .../Uplift/Testing/UnitTesting/UpfileTest.cs | 48 ++++++++++--------- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs index 2123003c..abf605ba 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs @@ -40,19 +40,21 @@ internal UpliftSettings() {} public static UpliftSettings FromDefaultFile() { - return FromFile(defaultFileName); + string sourceDir = System.IO.Path.Combine(GetHomePath(), folderName); + string source = System.IO.Path.Combine(sourceDir, defaultFileName); + + return FromFile(source); } - public static UpliftSettings FromFile(string name) + public static UpliftSettings FromFile(string source) { UpliftSettings result = new UpliftSettings { Repositories = new Repository[0], AuthenticationMethods = new RepositoryToken[0] }; string sourceDir = System.IO.Path.Combine(GetHomePath(), folderName); - string source = System.IO.Path.Combine(sourceDir, name); - if(!Directory.Exists(sourceDir) || !File.Exists(source)) + if(!File.Exists(source)) { - Debug.Log("No local settings file detected."); + Debug.Log("No local settings file detected at " + source); return result; } diff --git a/Assets/Plugins/Editor/Uplift/Testing/Helpers/UpfileExposer.cs b/Assets/Plugins/Editor/Uplift/Testing/Helpers/UpfileExposer.cs index 0c7bde4a..285c4196 100644 --- a/Assets/Plugins/Editor/Uplift/Testing/Helpers/UpfileExposer.cs +++ b/Assets/Plugins/Editor/Uplift/Testing/Helpers/UpfileExposer.cs @@ -82,11 +82,6 @@ internal static Upfile LoadTestXml(string path) return upfile; } } - - public override void LoadOverrides() - { - return; - } } } #endif diff --git a/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs b/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs index 43654cd1..8fc7c8d0 100644 --- a/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs +++ b/Assets/Plugins/Editor/Uplift/Testing/UnitTesting/UpfileTest.cs @@ -124,29 +124,31 @@ public void LoadXmlAbsent() Assert.IsTrue(caught); } - // [Test] - // public void LoadPresentOverrideTest() - // { - // string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); - // string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "UpliftSettings.xml"); - // Upfile upfile = Upfile.LoadXml(upfilePath); - // upfile.LoadOverrides(upfileOverridePath); - - // Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Some","Repository"))), "Original repository not found"); - // Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Another","Repository"))), "Override repository not found"); - // } - - // [Test] - // public void LoadAbsentOverrideTest() - // { - // string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); - // string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "NoUpfileInIt", "UpliftSettings.xml"); - // Upfile upfile = Upfile.LoadXml(upfilePath); - // upfile.LoadOverrides(upfileOverridePath); - - // Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Some","Repository"))), "Original repository not found"); - // Assert.IsFalse(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Another","Repository"))), "Loaded absent file"); - // } + [Test] + public void LoadPresentOverrideTest() + { + string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); + string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "UpliftSettings.xml"); + Upfile upfile = Upfile.LoadXml(upfilePath); + upfile.overridePath = upfileOverridePath; + upfile.LoadOverrides(); + + Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Some","Repository"))), "Original repository not found"); + Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Another","Repository"))), "Override repository not found"); + } + + [Test] + public void LoadAbsentOverrideTest() + { + string upfilePath = Helper.PathCombine ("TestData", "UpfileTest", "Upfile.xml"); + string upfileOverridePath = Helper.PathCombine ("TestData", "UpfileTest", "NoUpfileInIt", "UpliftSettings.xml"); + Upfile upfile = Upfile.LoadXml(upfilePath); + upfile.overridePath = upfileOverridePath; + upfile.LoadOverrides(); + + Assert.IsTrue(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Some","Repository"))), "Original repository not found"); + Assert.IsFalse(upfile.Repositories.Any(repo => repo is FileRepository && string.Equals((repo as FileRepository).Path, Helper.PathCombine("Path","To","Another","Repository"))), "Loaded absent file"); + } [Test] public void GetDestinationForBase() From c0649eacd88e662c00b1eb0542c3347059cd7883 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Mon, 27 Nov 2017 11:16:12 +0100 Subject: [PATCH 10/14] Put back license block in generated file --- ...pes_Upbring_Upfile_UpliftSettings_Upset.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs index a06dde9b..e593d5f7 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs @@ -1,4 +1,28 @@ -//------------------------------------------------------------------------------ +// --- BEGIN LICENSE BLOCK --- +/* + * Copyright (c) 2017-present WeWantToKnow AS + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// --- END LICENSE BLOCK --- + +//------------------------------------------------------------------------------ // // Ce code a été généré par un outil. // Version du runtime :2.0.50727.8825 From 2c1b0c80d2d4e5146d5bdeb6d9398af6cfda585c Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Mon, 27 Nov 2017 11:31:22 +0100 Subject: [PATCH 11/14] Fix warning --- .../Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs index abf605ba..4f0b6f9a 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs @@ -50,8 +50,6 @@ public static UpliftSettings FromFile(string source) { UpliftSettings result = new UpliftSettings { Repositories = new Repository[0], AuthenticationMethods = new RepositoryToken[0] }; - string sourceDir = System.IO.Path.Combine(GetHomePath(), folderName); - if(!File.Exists(source)) { Debug.Log("No local settings file detected at " + source); From 6c15c6a70ec84d4b6bc44b9099077c8757fb23f4 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Mon, 27 Nov 2017 11:52:30 +0100 Subject: [PATCH 12/14] Support multiple releases in same GitHubRepository --- ...pes_Upbring_Upfile_UpliftSettings_Upset.cs | 26 +++++------ .../Schemas/Repositories/GithubRepository.cs | 43 +++++++++++++------ .../Editor/Uplift/Schemas/RepositoryTypes.xsd | 30 ++++++++----- 3 files changed, 63 insertions(+), 36 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs index e593d5f7..e35b594e 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs @@ -517,8 +517,6 @@ public partial class Repository { private string extractPathField; - private string valueField; - /// [System.Xml.Serialization.XmlAttributeAttribute()] public string ExtractPath { @@ -529,18 +527,7 @@ public string ExtractPath { this.extractPathField = value; } } - - /// - [System.Xml.Serialization.XmlTextAttribute()] - public string Value { - get { - return this.valueField; - } - set { - this.valueField = value; } - } - } /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] @@ -570,8 +557,21 @@ public string Url { [System.ComponentModel.DesignerCategoryAttribute("code")] public partial class GithubRepository : Repository { + private string[] tagListField; + private string urlField; + /// + [System.Xml.Serialization.XmlArrayItemAttribute("Tag", IsNullable=false)] + public string[] TagList { + get { + return this.tagListField; + } + set { + this.tagListField = value; + } + } + /// [System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")] public string Url { diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs index 03320477..03ddc8d0 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs @@ -40,14 +40,16 @@ namespace Uplift.Schemas { public partial class GithubRepository : Repository { - private GitHubRelease release; + private GitHubRelease[] releases; public override TemporaryDirectory DownloadPackage(Upset package) { string sourceName = Regex.Replace(package.MetaInformation.dirName, ".Upset.xml$", ".unitypackage", RegexOptions.IgnoreCase); - release = GetPackagesRelease(); - if(!release.assets.Any(asset => asset.name.Contains(sourceName))) + releases = GetPackagesReleases(); + GitHubRelease release = releases.FirstOrDefault(rel => rel.assets.Any(asset => asset.name.Contains(sourceName))); + + if(release == null) throw new ArgumentException(string.Format("Package {0} is not present in this repository", package.PackageName)); GitHubAsset packageAsset = release.assets.First(asset => asset.name.Contains(sourceName)); @@ -62,9 +64,11 @@ public override TemporaryDirectory DownloadPackage(Upset package) public override Upset[] ListPackages() { - release = GetPackagesRelease(); + releases = GetPackagesReleases(); - GitHubAsset[] upsetAssets = release.assets.Where(asset => asset.name.EndsWith("Upset.xml")).ToArray(); + GitHubAsset[] upsetAssets = releases + .SelectMany(rel => rel.assets.Where(asset => asset.name.EndsWith("Upset.xml"))) + .ToArray(); string progressBarTitle = "Parsing Upsets from GitHub repository"; int index = 0; @@ -93,25 +97,38 @@ public override Upset[] ListPackages() return upsetList.ToArray(); } - private GitHubRelease GetPackagesRelease() + private GitHubRelease[] GetPackagesReleases() { - if(release == null) + if(releases == null) { IEnumerator e = GitHub.LoadReleases(urlField, GetToken()); do { Thread.Sleep(1000); } while (e.MoveNext()); - GitHubRelease[] releases = (GitHubRelease[]) e.Current; - if (releases == null) + GitHubRelease[] fetchedReleases = (GitHubRelease[]) e.Current; + + if (fetchedReleases == null) throw new ApplicationException("This github repository does not have releases"); - release = releases.FirstOrDefault(rel => rel.tag == "packages"); + string[] tagArray; + if(tagListField == null || tagListField.Length == 0) + { + tagArray = new string[] { "packages" }; + } + else + { + tagArray = tagListField; + Array.Resize(ref tagArray, tagListField.Length + 1); + tagArray[tagListField.Length] = "packages"; + } - if (release == null) - throw new ApplicationException("This repository does not have a release tagged as 'packages'"); + releases = fetchedReleases.Where(rel => tagArray.Contains(rel.tag)).ToArray(); + + if (releases == null) + throw new ApplicationException("This repository does not have a release correctly tagged"); } - return release; + return releases; } private string GetToken() diff --git a/Assets/Plugins/Editor/Uplift/Schemas/RepositoryTypes.xsd b/Assets/Plugins/Editor/Uplift/Schemas/RepositoryTypes.xsd index 7829c4b8..f6c2d9b3 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/RepositoryTypes.xsd +++ b/Assets/Plugins/Editor/Uplift/Schemas/RepositoryTypes.xsd @@ -6,39 +6,42 @@ - + - + - + + + + - + - + - + - + - + - + - + @@ -48,4 +51,11 @@ + + + + + + + From 226d0e4852790195e79997117835e1fd9cad6da4 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Mon, 27 Nov 2017 12:06:34 +0100 Subject: [PATCH 13/14] Fix progress bar --- .../Schemas/Repositories/GithubRepository.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs index 03ddc8d0..7a66b03b 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs @@ -79,18 +79,18 @@ public override Upset[] ListPackages() { StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); + EditorUtility.DisplayProgressBar( + progressBarTitle, + "Parsing " + asset.name, + (float)(index++) / upsetAssets.Length + ); + using(StreamReader sr = new StreamReader(GitHub.GetAssetStream(asset, GetToken()))) { Upset upset = deserializer.Deserialize(sr.BaseStream); upset.MetaInformation.dirName = asset.name; upsetList.Add(upset); } - - EditorUtility.DisplayProgressBar( - progressBarTitle, - "Parsing " + asset.name, - (100f * (float)(++index)) / upsetAssets.Length - ); } EditorUtility.ClearProgressBar(); @@ -120,7 +120,7 @@ private GitHubRelease[] GetPackagesReleases() Array.Resize(ref tagArray, tagListField.Length + 1); tagArray[tagListField.Length] = "packages"; } - + releases = fetchedReleases.Where(rel => tagArray.Contains(rel.tag)).ToArray(); if (releases == null) From 528d11d43396d333e8f4171e7e15d37b1b77ccc3 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Mon, 27 Nov 2017 18:14:42 +0100 Subject: [PATCH 14/14] Various minor changes --- .../Editor/Uplift/Packages/PackageList.cs | 24 ++++++++++------- .../Schemas/Extensions/UpliftSettings.cs | 13 ++++----- .../Schemas/Repositories/GithubRepository.cs | 27 ++++++++++--------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/Packages/PackageList.cs b/Assets/Plugins/Editor/Uplift/Packages/PackageList.cs index 33f3ed99..5c91e11a 100644 --- a/Assets/Plugins/Editor/Uplift/Packages/PackageList.cs +++ b/Assets/Plugins/Editor/Uplift/Packages/PackageList.cs @@ -87,22 +87,26 @@ public void LoadPackages(Repository repository) repository.ToString() )) { - PackageRepo pr; + Upset[] packages; try { - foreach (Upset package in repository.ListPackages()) - { - pr = new PackageRepo - { - Package = package, - Repository = repository - }; - Packages.Add(pr); - } + packages = repository.ListPackages(); } catch(Exception e) { Debug.LogException(e); + return; + } + + PackageRepo pr; + foreach (Upset package in packages) + { + pr = new PackageRepo + { + Package = package, + Repository = repository + }; + Packages.Add(pr); } } } diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs index 4f0b6f9a..8e402f1b 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Extensions/UpliftSettings.cs @@ -63,18 +63,19 @@ public static UpliftSettings FromFile(string source) try { result = deserializer.Deserialize(fs); - - foreach (Repository repo in result.Repositories) - { - if (repo is FileRepository) - (repo as FileRepository).Path = FileSystemUtil.MakePathOSFriendly((repo as FileRepository).Path); - } } catch (InvalidOperationException) { Debug.LogError(string.Format("Global Override file at {0} is not well formed", source)); + return result; } + foreach (Repository repo in result.Repositories) + { + if (repo is FileRepository) + (repo as FileRepository).Path = FileSystemUtil.MakePathOSFriendly((repo as FileRepository).Path); + } + return result; } } diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs index 7a66b03b..74a24115 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Repositories/GithubRepository.cs @@ -109,23 +109,26 @@ private GitHubRelease[] GetPackagesReleases() if (fetchedReleases == null) throw new ApplicationException("This github repository does not have releases"); - string[] tagArray; - if(tagListField == null || tagListField.Length == 0) - { - tagArray = new string[] { "packages" }; - } - else - { - tagArray = tagListField; - Array.Resize(ref tagArray, tagListField.Length + 1); - tagArray[tagListField.Length] = "packages"; - } + string[] tagArray = (tagListField == null || tagListField.Length == 0) ? + new string[] { "packages" } : + tagListField; releases = fetchedReleases.Where(rel => tagArray.Contains(rel.tag)).ToArray(); - if (releases == null) + // Fail hard if no release could be found + if (releases.Length == 0) throw new ApplicationException("This repository does not have a release correctly tagged"); + // Logs missing tags if only some of them were found + if (releases.Length < tagArray.Length) + { + string missingTags = string.Join( + ", ", + tagArray.Where(tag => !releases.Any(rel => rel.tag == tag)).ToArray() + ); + + Debug.LogWarningFormat("Could not find a matching release for all of your tags (missing {0})", missingTags); + } } return releases;