Beispiel #1
0
        /// <summary>
        /// 剔除掉服务端同步的插件,再进行合并
        /// TODO: 只剔除一个就可以
        /// </summary>
        /// <returns></returns>
        public static PackageListConfig MergeGitClonedPackageList(PackageConfig toUploadPackageConfig)
        {
            string clonedConfigFilePath = Application.dataPath.CombinePath(toUploadPackageConfig.PackageServerGitUrl.GetLastWord()).CombinePath("PackageList.json");

            Log.I(clonedConfigFilePath);

            PackageListConfig clonedConfig = SerializeHelper.LoadJson <PackageListConfig>(clonedConfigFilePath);

            clonedConfig.InstalledPackageList.RemoveAll(config => config.Name.Equals(toUploadPackageConfig.Name));

            clonedConfig.InstalledPackageList.Add(toUploadPackageConfig);

            return(clonedConfig);
        }
Beispiel #2
0
        static void MakePackage()
        {
            string packagePath       = MouseSelector.GetSelectedPathOrFallback();
            string packageConfigPath = Path.Combine(packagePath, "Package.assets");

            PackageConfig packageConfig = null;

            if (File.Exists(packageConfigPath))
            {
                packageConfig             = PackageConfig.LoadFromPath(packageConfigPath);
                packageConfig.PackagePath = packagePath;
            }
            else
            {
                packageConfig = new PackageConfig(packagePath);
            }
            packageConfig.SaveLocal();
        }
Beispiel #3
0
        public static void DownloadZip(PackageConfig config)
        {
            ObservableWWW
            .GetAndGetBytes(config.DownloadURL).Subscribe(
                bytes =>
            {
                string tempZipFile = Application.persistentDataPath + "/temp.zip";
                File.WriteAllBytes(tempZipFile, bytes);
                string err = string.Empty;
                IOUtils.DeleteDirIfExists(config.PackagePath);
                ZipUtil.UnZipFile(tempZipFile, config.PackagePath);
                File.Delete(tempZipFile);

                AssetDatabase.Refresh();
                config.SaveLocal();
                Log.I("succeed");
            });
        }
Beispiel #4
0
        static void UploadPackage()
        {
            string packagePath       = MouseSelector.GetSelectedPathOrFallback();
            string packageConfigPath = packagePath.EndsWith(".asset") ? packagePath : packagePath.Append(".asset").ToString();

            if (File.Exists(packageConfigPath))
            {
                string err = string.Empty;

                PackageConfig config             = PackageConfig.LoadFromPath(packageConfigPath);
                string        serverUploaderPath = Application.dataPath.CombinePath(config.PackageServerGitUrl.GetLastWord());

                if (!Directory.Exists(serverUploaderPath))
                {
                    RunCommand(string.Empty, "git clone ".Append(config.PackageServerGitUrl).ToString());
                }

                ZipUtil.ZipDirectory(config.PackagePath,
                                     IOUtils.CreateDirIfNotExists(serverUploaderPath.CombinePath(config.Name)).CombinePath(config.Name + ".zip"));

                PackageListConfig
                .MergeGitClonedPackageList(config)
                .SaveExport(config.PackageServerGitUrl);

                RunCommand(config.PackageServerGitUrl.GetLastWord(), string.Format(
                               "git add . && git commit -m \"{0}\" && git push",
                               config.ReleaseNote.IsNullOrEmpty()
                                                ? "no release note"
                                                : config.Name.Append(" ").Append(config.Version).AppendFormat(" {0}", config.ReleaseNote).ToString()));

                RunCommand(string.Empty, "rm -rf " + config.PackageServerGitUrl.GetLastWord());

                AssetDatabase.Refresh();

                Application.OpenURL(config.PackageServerGitUrl);
            }
            else
            {
                Log.W("no package.json file in folder:{0}", packagePath);
            }
        }