private static bool PackageJsonInfoCheck(PackageJsonInfo packageJsonInfo, out int retCode) { // 1. package name check string pattern = "(^[a-zA-Z_]+\\.([a-zA-Z_]+\\.)+[a-zA-Z_]+$)"; var rst = RegexUtils.RegexMatch(packageJsonInfo.name, pattern); if (rst == false) { retCode = 1; return(false); } // 2. display name check pattern = "^[a-zA-Z_ ]+$"; rst = RegexUtils.RegexMatch(packageJsonInfo.displayName, pattern); if (rst == false) { retCode = 2; return(false); } // 3. version check pattern = "(^[0-9]+\\.[0-9]+\\.[0-9]+$)"; rst = RegexUtils.RegexMatch(packageJsonInfo.version, pattern); if (rst == false) { retCode = 3; return(false); } retCode = 0; return(true); }
/// <summary> /// 创建插件package.json时,默认添加"UPMTool"依赖到dependenciesUt /// "com.chino.upmtool": "https://gitee.com/Chino66/UPM-Tool-Develop.git#upm" /// </summary> /// <param name="packageJsonInfo"></param> public static void AddUPMToolDependency(PackageJsonInfo packageJsonInfo) { var dependency = new PackageDependency(); dependency.packageName = "com.chino.upmtool"; dependency.version = "https://gitee.com/Chino66/UPM-Tool-Develop.git#upm"; packageJsonInfo.dependenciesUt.Add(dependency); }
/// <summary> /// 创建插件包框架结构 /// </summary> /// <param name="packageJsonInfo"></param> public static void CreatePackageAction(PackageJsonInfo packageJsonInfo) { // 创建readme.md var path = PackageChecker.readmeMDPath; var content = $"# {packageJsonInfo.displayName}"; CreateTextFile(path, content); // 创建changelog.md path = PackageChecker.changelogMDPath; content = $"# {packageJsonInfo.displayName} changelog"; CreateTextFile(path, content); // 创建Resources目录 path = PackageChecker.resourcesPath; CreateDir(path); }
public static bool SavePackageJsonChange(PackageJsonInfo packageJsonInfo, string path, out string msg) { // check var rst = PackageJsonInfoCheck(packageJsonInfo, out var retCode); // tip msg = RetCodeToMsg(retCode); if (rst == false) { // 提示错误 Debug.LogError($"检测失败,{msg}"); return(false); } var json = PackageJson.ToJson(packageJsonInfo); CreateTextFile(path, json); return(true); }