def BuildProject(self, isHD, channel): name = self.GetProjectName(channel) dirproject = mainResource.GetRootCocosBuildOutput() + "/" + name appid = mainAppInfo.GetAppId(isHD, channel) if name == Source.ProjectNameMiniGameWeixin or name == Source.ProjectNameMiniGameByte: filepath = mainResource.GetProjectConfigDefault( ) + "/" + name + "/game.json" strfile = FileUtil.GetFileString(filepath) strfile = strfile.replace("_Orientation_", "portrait") filepath = dirproject + "/game.json" FileUtil.RemoveFile(filepath) FileUtil.SaveString2File(strfile, filepath) filepath = mainResource.GetProjectConfigDefault( ) + "/" + name + "/project.config.json" strfile = FileUtil.GetFileString(filepath) print("BuildWeixin appid=" + appid) # wx3e44af039aee1b96 strfile = strfile.replace("_APPID_", appid) # print("BuildWeixin strfile="+strfile) filepath = dirproject + "/project.config.json" FileUtil.RemoveFile(filepath) FileUtil.SaveString2File(strfile, filepath) # python 里无法直接执行cd目录,要用chdir改变当前的工作目录 if os.path.exists(dirproject): os.chdir(dirproject) print("dirproject:" + dirproject) if name == Source.ProjectNameMiniGameVivo: os.system("npm install") os.system("npm run build")
def Run(self, isHd): print("UpdateAppstore Run") gameName = mainResource.getGameName() gameType = mainResource.getGameType() print(gameName) print(gameType) if len(sys.argv) > 2: if sys.argv[2] == "delete_screenshot": # delete_screenshots() sys.exit(0) #先从default 拷贝 文件模版 dir_default = mainResource.GetProjectConfigDefault() dir_to = mainResource.GetProjectConfigApp() dir1 = dir_default + "/appstore" dir2 = dir_to + "/appstore" flag = os.path.exists(dir2) print("UpdateAppstore dir1=" + dir1 + "dir2=" + dir2) if flag: shutil.rmtree(dir2) shutil.copytree(dir1, dir2) # self.copy_screenshots() self.updateAppstore(isHd) # self.updateAppstore(True) print("UpdateAppstore sucess")
def UploadIAPInfo(self, isHd, stros): package = mainAppInfo.GetAppPackage(stros, isHd) rootJson = self.LoadJsonIAP(isHd, stros) rootConfig = mainResource.GetProjectConfigDefault() striap = FileUtil.GetFileString(rootConfig + "/appstore/KEY_IAP.xml") listIAP = [] for item in rootJson["items"]: if item["isSkip"]: continue name = item["key"] striap = striap.replace("_NAME_", name) product_id = package + "." + item["id"] striap = striap.replace("_ID_", product_id) # consumable non-consumable isConsume = item["isConsume"] product_type = "non-consumable" if isConsume: product_type = "consumable" striap = striap.replace("_TYPE_", product_type) title_cn = item["title"]["cn"] striap = striap.replace("_TITLE_CN_", title_cn) title_en = item["title"]["en"] striap = striap.replace("_TITLE_EN_", title_en) title_cn = item["detail"]["cn"] striap = striap.replace("_DETAIL_CN_", title_cn) title_en = item["detail"]["en"] striap = striap.replace("_DETAIL_EN_", title_en) price = item["price_tier"] striap = striap.replace("_PRICE_", price) listIAP.append(striap) str_metadata_xml = FileUtil.GetFileString(rootConfig + "/appstore/IAP_metadata.xml") str_metadata_xml = str_metadata_xml.replace( "_VENDOR_ID_", mainAppInfo.GetAppSKU(isHd)) strkeyiap = "" for strtmp in listIAP: strkeyiap += strtmp str_metadata_xml = str_metadata_xml.replace("_KEY_IAP_", strkeyiap) rootConfig = mainResource.GetProjectConfigApp() file_metadata_ios = rootConfig + "/appstore/ios/app.itmsp/metadata.xml" if isHd: file_metadata_ios = rootConfig + "/appstore/ios/app_pad.itmsp/metadata.xml" FileUtil.SaveString2File(str_metadata_xml, file_metadata_ios) mainAppstoreUploadiOS.Run(isHd)
def copyResFiles(self,str): dir_default = mainResource.GetProjectConfigDefault() # "../../../default" dir_to = mainResource.GetProjectConfigApp() dir1 = dir_default+"/"+str dir2 = dir_to + "/"+str print(dir2) flag = os.path.exists(dir2) if flag: shutil.rmtree(dir2) shutil.copytree(dir1,dir2)
def DeleteAllScreenshots(self, isHd): verison = mainAppInfo.GetAppVersion(Source.IOS, isHd) rootConfig = mainResource.GetProjectConfigDefault() str_metadata_xml = FileUtil.GetFileString( rootConfig + "/appstore/metadata_clear_screenshots.xml") str_metadata_xml = str_metadata_xml.replace( "_VENDOR_ID_", mainAppInfo.GetAppSKU(isHd)) str_metadata_xml = str_metadata_xml.replace("_VERSION_", verison) rootConfig = mainResource.GetProjectConfigApp() file_metadata_ios = rootConfig + "/appstore/ios/app.itmsp/metadata.xml" if isHd: file_metadata_ios = rootConfig + "/appstore/ios/app_pad.itmsp/metadata.xml" FileUtil.SaveString2File(str_metadata_xml, file_metadata_ios) mainAppstoreUploadiOS.Run(isHd)
def ScanDir(self, sourceDir, dir2): for file in os.listdir(sourceDir): sourceFile = os.path.join(sourceDir, file) if os.path.isdir(sourceFile): if Platform.isWindowsSystem(): key = "/cmd_win" else: key = "/cmd_mac" dirsrc = mainResource.GetProjectConfigDefault() + key dir = sourceFile + key flag = os.path.exists(dir) if flag: shutil.rmtree(dir) shutil.copytree(dirsrc, dir) if Platform.isMacSystem(): self.UpdateMacFile(dir)
def updateName(self,isHd,isAuto): name = mainAppInfo.GetAppStoreAcount(isHd,Source.HUAWEI) mainHuaweiAppGalleryApi.ClientId = mainAppStoreAcount.GetClientId(Source.HUAWEI,name) mainHuaweiAppGalleryApi.ClientSecret = mainAppStoreAcount.GetClientSecret(Source.HUAWEI,name) appinfoOld = AppInfoOld(isHd) if appinfoOld.IsOldVersion(): # 转换 self.ConvertOld2New(isHd,appinfoOld) rootConfig = mainResource.GetProjectConfigApp() strHD = "HD" project_ios = rootConfig + "/ios/project" project_android = rootConfig + "/android/project" if isHd: project_ios = rootConfig + "/ios/project_hd" project_android = rootConfig + "/android/project_hd" # android file_name_cn_android = project_android + "/res/values/strings.xml" file_name_en_android = project_android + "/res/values-en/strings.xml" file_AndroidManifest = project_android + "/xml/AndroidManifest.xml" file_AndroidManifest_GP = project_android + "/xml_gp/AndroidManifest.xml" file_google_service_android = project_android + "/config/google-services.json" # ios file_name_cn_ios = project_ios + "/appname/zh-Hans.lproj/InfoPlist.strings" file_name_en_ios = project_ios + "/appname/en.lproj/InfoPlist.strings" file_info_plist_ios = project_ios + "/Info.plist" # loadJson data = self.loadJson(isHd) appname = data["appname"] APP_NAME_CN_ANDROID = appname[Source.ANDROID]["cn"] APP_NAME_EN_ANDROID = appname[Source.ANDROID]["en"] APP_NAME_CN_IOS = appname[Source.IOS]["cn"] APP_NAME_EN_IOS = appname[Source.IOS]["en"] PACKAGE_ANDROID = data["apppackage"][Source.ANDROID]["default"] PACKAGE_IOS = data["apppackage"][Source.IOS]["default"] self.versionCode = data["appversion"][Source.ANDROID]["code"] APPVERSION_IOS = data["appversion"][Source.IOS]["value"] #appid appid_ios = self.GetJsonAppId(data,Source.APPSTORE) appid_taptap = self.GetJsonAppId(data,Source.TAPTAP) appid_huawei = self.GetJsonAppId(data,Source.HUAWEI) self.SetConfigDataAppId(Source.IOS,Source.APPSTORE,appid_ios,isHd) self.SetConfigDataAppId(Source.ANDROID,Source.TAPTAP,appid_taptap,isHd) self.SetConfigDataAppId(Source.ANDROID,Source.HUAWEI,appid_huawei,isHd) csvfile = mainResource.GetConfigDataDir()+"/language/language.csv" self.UpdateLanguageName(csvfile,APP_NAME_CN_ANDROID,APP_NAME_EN_ANDROID,isHd) csvfile = mainResource.GetRootUnityAssetsResource()+"/ConfigData/language/language.csv" self.UpdateLanguageName(csvfile,APP_NAME_CN_ANDROID,APP_NAME_EN_ANDROID,isHd) # if data.has_key("PACKAGE_HD_ANDROID"): # PACKAGE_HD_ANDROID = data["PACKAGE_HD_ANDROID"] if isAuto==True: self.autoPlusVersion(isHd,data) # 重新加载 data = self.loadJson(isHd) APPVERSION_IOS = data["appversion"][Source.IOS]["value"] self.versionCode = data["appversion"][Source.ANDROID]["code"] APPVERSION_ANDROID = self.versionCodeToVersion(self.versionCode) APPVERSION_CODE_ANDROID = self.versionCode # appversion.json if isAuto==False: src = mainResource.GetProjectConfigDefault()+"/appinfo/appversion.json" dst = mainResource.GetProjectConfigApp()+"/appinfo/appversion.json" flag = os.path.exists(dst) # if not isHd: shutil.copyfile(src,dst) strfile = FileUtil.GetFileString(dst) key = "_VERSION_ANDROID_" if isHd: key = "_VERSION_HD_ANDROID_" # 保存版本 # android print("appid_huawei=",appid_huawei+" ishd=",isHd) # if len(appid_huawei)>1: version_web = mainHuaweiAppGalleryApi.GetVersion(appid_huawei) strfile = strfile.replace(key,version_web) FileUtil.SaveString2File(strfile,dst) self.SetAppVersion(isHd,Source.ANDROID,version_web) strcode = version_web.replace(".","") self.SetAppVersionCode(isHd,Source.ANDROID,strcode) # ios appid_apple = self.GetJsonAppId(data,Source.APPSTORE) version_web = mainAppVersionApple.ParseVersion(appid_apple) print("AppVersionApple=",version_web+" appid_apple=",appid_apple) self.SetAppVersion(isHd,Source.IOS,version_web) strcode = version_web.replace(".","") self.SetAppVersionCode(isHd,Source.IOS,strcode) filepath = mainResource.GetProjectConfigAppType()+"/appversion.json" flag = os.path.exists(filepath) strFileJson = "{}" if flag: strFileJson = FileUtil.GetFileString(filepath) dataRoot = json.loads(strFileJson) dataRoot[mainResource.getGameName()]= json.loads(strfile) JsonUtil.SaveJson(filepath,dataRoot) # 重新加载 data = self.loadJson(isHd) APPVERSION_IOS = data["appversion"][Source.IOS]["value"] self.versionCode = data["appversion"][Source.ANDROID]["code"] APPVERSION_ANDROID = self.versionCodeToVersion(self.versionCode) APPVERSION_CODE_ANDROID = self.versionCode print (APP_NAME_CN_ANDROID) print (APP_NAME_EN_ANDROID) print (APP_NAME_CN_IOS) print (APP_NAME_EN_IOS) print (PACKAGE_ANDROID) print("android version:"+APPVERSION_ANDROID) print("ios version:"+APPVERSION_IOS) # android # name strStart = "app_name\">" strEnd = "<" # cn strOut = self.replaceStringOfFile( file_name_cn_android, strStart, strEnd, APP_NAME_CN_ANDROID) self.saveString2File(strOut, file_name_cn_android) # en strOut = self.replaceStringOfFile( file_name_en_android, strStart, strEnd, APP_NAME_EN_ANDROID) self.saveString2File(strOut, file_name_en_android) self.updateAndroidManifest(file_AndroidManifest,PACKAGE_ANDROID,APPVERSION_ANDROID,APPVERSION_CODE_ANDROID,isHd) self.updateAndroidManifest(file_AndroidManifest_GP,PACKAGE_ANDROID,APPVERSION_ANDROID,APPVERSION_CODE_ANDROID,isHd) # admob self.replaceGoogleServiceFile(file_google_service_android, PACKAGE_ANDROID) # ios #appname self.replaceFile(file_info_plist_ios,"_APP_NAME_",APP_NAME_CN_IOS) file_name_cn_ios = project_ios + "/appname/zh-Hans.lproj/InfoPlist.strings" file_name_en_ios = project_ios + "/appname/en.lproj/InfoPlist.strings" # cn self.replaceFile(file_name_cn_ios,"_APP_NAME_",APP_NAME_CN_IOS) # en self.replaceFile(file_name_en_ios,"_APP_NAME_",APP_NAME_EN_IOS) # package self.replaceFile(file_info_plist_ios,"_APP_PACKAGE_",PACKAGE_IOS) # version self.replaceFile(file_info_plist_ios,"_APP_VERSION_",APPVERSION_IOS) #admob appid appid = mainAdConfig.GetCommonAppId(Source.ADMOB,Source.IOS,isHd) self.replaceFile(file_info_plist_ios,"_APP_ID_ADMOB_",appid) # CFBundleURLSchemes src = Source.WEIBO appid = mainConfig.GetShareAppId(src,Source.IOS,isHd) self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,0) src = Source.WEIXIN appid = mainConfig.GetShareAppId(src,Source.IOS,isHd) self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,0) src = Source.QQ appid = mainConfig.GetShareAppId(src,Source.IOS,isHd) self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,0) self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,1) # xiaomi aso keyword self.updateXiaoASOkeyword(data,isHd) # win self.updateNameWin(isHd,isAuto)