miniprogram-ci 2.0.6 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +4 -2
  2. package/README.md +4 -0
  3. package/dist/@types/config/config.d.ts +1 -1
  4. package/dist/@types/modules/corecompiler/baseCompiler.d.ts +1 -0
  5. package/dist/@types/modules/corecompiler/originalCompiler.d.ts +1 -0
  6. package/dist/@types/modules/corecompiler/processHandler.d.ts +23 -0
  7. package/dist/@types/modules/corecompiler/summer/graph/appgraph.d.ts +3 -0
  8. package/dist/@types/modules/corecompiler/summer/graph/basegraph.d.ts +3 -0
  9. package/dist/@types/modules/corecompiler/summer/graph/gamegraph.d.ts +3 -0
  10. package/dist/@types/modules/corecompiler/summer/graph/gameplugingraph.d.ts +3 -0
  11. package/dist/@types/modules/corecompiler/summer/graph/plugingraph.d.ts +3 -0
  12. package/dist/@types/modules/corecompiler/summer/summer.d.ts +1 -0
  13. package/dist/@types/modules/corecompiler/summerCompiler.d.ts +17 -1
  14. package/dist/@types/modules/index.d.ts +4 -2
  15. package/dist/@types/modules/nativecompiler/ios/buildCloud.d.ts +2 -2
  16. package/dist/@types/types/devtools.d.ts +7 -0
  17. package/dist/@types/utils/debug.d.ts +3 -0
  18. package/dist/@types/utils/miniappJson.d.ts +1 -0
  19. package/dist/@types/utils/tools.d.ts +1 -0
  20. package/dist/config/config.js +1 -1
  21. package/dist/modules/corecompiler/processHandler.js +1 -0
  22. package/dist/modules/corecompiler/summer/graph/appgraph.js +1 -1
  23. package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
  24. package/dist/modules/corecompiler/summer/graph/gamegraph.js +1 -1
  25. package/dist/modules/corecompiler/summer/graph/gameplugingraph.js +1 -1
  26. package/dist/modules/corecompiler/summer/graph/plugingraph.js +1 -1
  27. package/dist/modules/corecompiler/summer/pluginDriver.js +1 -1
  28. package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
  29. package/dist/modules/corecompiler/summer/summer.js +1 -1
  30. package/dist/modules/corecompiler/summerCompiler.js +1 -1
  31. package/dist/modules/corecompiler/summerEntryProcess.js +1 -1
  32. package/dist/modules/index.js +1 -1
  33. package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
  34. package/dist/modules/nativecompiler/ios/index.js +1 -1
  35. package/dist/project/baseProject.js +1 -1
  36. package/dist/schema/dist/app.js +4 -1
  37. package/dist/schema/dist/ext.js +4 -1
  38. package/dist/schema/dist/game.js +1 -1
  39. package/dist/schema/dist/page.js +1 -1
  40. package/dist/schema/dist/plugin.js +1 -1
  41. package/dist/schema/dist/pluginpage.js +1 -1
  42. package/dist/schema/dist/projectconfig.js +4 -1
  43. package/dist/schema/dist/projectprivateconfig.js +4 -1
  44. package/dist/schema/dist/sitemap.js +1 -1
  45. package/dist/schema/dist/theme.js +1 -1
  46. package/dist/utils/codesign.js +1 -1
  47. package/dist/utils/debug.js +1 -0
  48. package/dist/utils/miniapp-builder.js +1 -1
  49. package/dist/utils/miniappJson.js +1 -1
  50. package/dist/utils/subprocess/processManager.js +1 -1
  51. package/dist/utils/tools.js +1 -1
  52. package/package.json +101 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Builder=void 0;const index_1=require("./precompiler/index"),nativecompiler_1=require("./nativecompiler"),createSummer_1=require("./createSummer"),singletontask_1=require("../utils/singletontask");class Builder{constructor(e,t){this.originProject=e,this._options=t}async getCompiler(){return this.getSummerCompiler()}async getPreCompileProject(){if(!this._precompileProject){const{targetPlatform:e,targetPlatformDefines:t}=this._options,i=await this.getPreCompiler();this._precompileProject=await i.getPreCompileProject({targetPlatform:e,targetPlatformDefines:t,runEnv:"main process"}),await this._precompileProject.ready()}return this._precompileProject}async getPreCompiler(){if(!this._preCompiler){const{devtoolMessagehub:e}=this._options;this._preCompiler=new index_1.PreCompiler(this.originProject,e)}return this._preCompiler}async getSummerCompiler(){if(!this._summerCompiler){const{summerCompilerClass:e,projectInfo:t,cachePath:i="",devtoolMessagehub:r}=this._options,o=await this.getPreCompileProject();e?(this._summerCompiler=new e(o,i,t,r),await this._summerCompiler.ready()):this._summerCompiler=await(0,createSummer_1.getSummerCompiler)(o)}return this._summerCompiler}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this,this._options))),await this._checkReadyTask.getResult()}async init(){}async getNativeCompiler(){return this._nativeCompiler||await this.initNativeCompiler(this._options),this._nativeCompiler}async initNativeCompiler(e){if("multiPlatform"!==this.originProject.projectArchitecture)return;const{miniappDirPath:t,devtoolsVersion:i,devtoolMessagehub:r}=e;this._nativeCompiler=new nativecompiler_1.NativeCompiler({project:this._precompileProject,devtoolMessagehub:r,devtoolsVersion:i,miniappDirPath:t}),await this._nativeCompiler.ready()}getPreCompileOptions(){var e,t;return{targetPlatform:null===(e=this._precompileProject)||void 0===e?void 0:e.targetPlatform,targetPlatformDefines:null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatformDefines}}async changePreCompileOptions(e){var t;await this.getPreCompileProject(),(null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatform)!==e.targetPlatform&&(this._precompileProject.updateConditionCompileOptions(e),await new Promise(e=>setTimeout(e,500)))}async setLocale(e){(await this.getSummerCompiler()).setLocale(e)}destroy(){var e,t;(null===(e=this._summerCompiler)||void 0===e?void 0:e.isSummer)&&this._summerCompiler.destroy(),null===(t=this._nativeCompiler)||void 0===t||t.destroy()}}exports.Builder=Builder;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Builder=void 0;const index_1=require("./precompiler/index"),nativecompiler_1=require("./nativecompiler"),createSummer_1=require("./createSummer"),singletontask_1=require("../utils/singletontask");class Builder{constructor(e,t){this._getSummerCompiler=async()=>{if(!this._summerCompiler){const{summerCompilerClass:e,projectInfo:t,cachePath:i="",devtoolMessagehub:r}=this._options,o=await this.getPreCompileProject();e?(this._summerCompiler=new e(o,i,t,r),await this._summerCompiler.ready()):this._summerCompiler=await(0,createSummer_1.getSummerCompiler)(o)}return this._summerCompiler},this.originProject=e,this._options=t}async getCompiler(){return this.getSummerCompiler()}async getPreCompileProject(){if(!this._precompileProject){const{targetPlatform:e,targetPlatformDefines:t}=this._options,i=await this.getPreCompiler();this._precompileProject=await i.getPreCompileProject({targetPlatform:e,targetPlatformDefines:t,runEnv:"main process"}),await this._precompileProject.ready()}return this._precompileProject}async getPreCompiler(){if(!this._preCompiler){const{devtoolMessagehub:e}=this._options;this._preCompiler=new index_1.PreCompiler(this.originProject,e)}return this._preCompiler}async getSummerCompiler(){var e;return this._getSummerCompilerTask||(this._getSummerCompilerTask=new singletontask_1.SingletonTask(this._getSummerCompiler)),null===(e=this._getSummerCompilerTask)||void 0===e?void 0:e.getResult(!0)}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this,this._options))),await this._checkReadyTask.getResult()}async init(){}async getNativeCompiler(){return this._nativeCompiler||await this.initNativeCompiler(this._options),this._nativeCompiler}async initNativeCompiler(e){if("multiPlatform"!==this.originProject.projectArchitecture)return;const{miniappDirPath:t,devtoolsVersion:i,devtoolMessagehub:r}=e;this._nativeCompiler=new nativecompiler_1.NativeCompiler({project:this._precompileProject,devtoolMessagehub:r,devtoolsVersion:i,miniappDirPath:t}),await this._nativeCompiler.ready()}getPreCompileOptions(){var e,t;return{targetPlatform:null===(e=this._precompileProject)||void 0===e?void 0:e.targetPlatform,targetPlatformDefines:null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatformDefines}}async changePreCompileOptions(e){var t;await this.getPreCompileProject(),(null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatform)!==e.targetPlatform&&(this._precompileProject.updateConditionCompileOptions(e),await new Promise(e=>setTimeout(e,500)))}async setLocale(e){(await this.getSummerCompiler()).setLocale(e)}destroy(){var e,t;(null===(e=this._summerCompiler)||void 0===e?void 0:e.isSummer)&&this._summerCompiler.destroy(),null===(t=this._nativeCompiler)||void 0===t||t.destroy()}}exports.Builder=Builder;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.privateDescriptions=exports.remoteBuildProjectMaterialAbsoluteCacheDir=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),glob_1=tslib_1.__importDefault(require("glob")),env_1=require("../../../utils/env"),miniapp_builder_1=require("../../../utils/miniapp-builder"),codesign_1=require("../../../utils/codesign"),miniappJson_1=require("../../../utils/miniappJson"),lodash_1=require("lodash"),tools_1=require("../../../utils/tools"),uuidv4=require("uuid/v4"),sizeOf=require("image-size"),plist=require("simple-plist"),errorIOSSdkVersions=["1.0.19"],APPEX_PROFILES_MAPS_FILE="__appexProfilesCacheDir__/profilesMap.json",APPEX_PROFILES_MAPS_FOR_SHELL_FILE="__appexProfilesCacheDir__/profilesMapForShell.txt",defaultIconDirPath=path_1.default.join(__dirname,"../../../static/images/"),getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"];exports.remoteBuildProjectMaterialAbsoluteCacheDir="__absoluteFile";const iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}};exports.privateDescriptions=["NSPhotoLibraryUsageDescription","NSPhotoLibraryAddUsageDescription","NSCameraUsageDescription","NSMicrophoneUsageDescription","NSLocationWhenInUseUsageDescription","NSLocationAlwaysUsageDescription","NSLocationAlwaysAndWhenInUseUsageDescription","NSCalendarsUsageDescription","NSContactsUsageDescription","NSBluetoothPeripheralUsageDescription","NSBluetoothAlwaysUsageDescription","NSSpeechRecognitionUsageDescription","NSRemindersUsageDescription","NSMotionUsageDescription","NSHealthUpdateUsageDescription","NSHealthShareUsageDescription","NSAppleMusicUsageDescription","NFCReaderUsageDescription","NSHealthClinicalHealthRecordsShareUsageDescription","NSHomeKitUsageDescription","NSSiriUsageDescription","NSFaceIDUsageDescription","NSLocalNetworkUsageDescription","NSUserTrackingUsageDescription","NSLocationUsageDescription"];class buildCloudManager{generateTempDemoIpaPath(e){const i=path_1.default.join(e,"../.."),t=path_1.default.basename(i),n=path_1.default.dirname(i),a=path_1.default.join(n,t+"-operateDir");fs_extra_1.default.existsSync(a)&&fs_extra_1.default.removeSync(a),fs_extra_1.default.ensureDirSync(a);const s=path_1.default.join(a,"Payload/demo.app");return fs_extra_1.default.copySync(e,s),s}generateInfoPlistCFBundleURLTypesItem(e){const i={};return e.CFBundleURLName&&(i.CFBundleURLName=e.CFBundleURLName),e.CFBundleURLSchemes&&(i.CFBundleURLSchemes=[e.CFBundleURLSchemes]),e.CFBundleTypeRole&&(i.CFBundleTypeRole=e.CFBundleTypeRole),i}updatePrivacyBackgroundImage(e,i,t,n,a){t.message("doing","updatePrivacyBackgroundImage "+n);if(fs_extra_1.default.readdirSync(i).forEach(e=>{"privacy_"+n===path_1.default.basename(e,path_1.default.extname(e))&&fs_extra_1.default.removeSync(path_1.default.join(i,e))}),!a)return;path_1.default.isAbsolute(a)||(a=path_1.default.join(e,a)),a=this.getMaterialFilePath(e,a);const s=path_1.default.extname(a),o=path_1.default.join(i,`privacy_${n}${s}`);try{fs_extra_1.default.copyFileSync(a,o)}catch(e){throw t.message("fail",`copy privacy image failed: ${n}, ${a} to ${o}`),e}}async updateIOSInfoPlistInfo(e,i,t,n,a,s){var o,r,l,p,d,c,u,f;a.progress("update app base info...");const{mobileapp_info:_={}}=i,h=_.mobileapp_id,g=path_1.default.join(t,"Info.plist"),m={},y=(e,i)=>{var t,n;if(i.startsWith("%")&&i.endsWith("%")){const o=i.slice(1,-1);m[e]=o;const r=(null===(n=null===(t=null==s?void 0:s.base)||void 0===t?void 0:t.ios)||void 0===n?void 0:n[o])||"";return r||a.message("fail",`未在国际化配置 base.json 中找到字段 ${o},请检查`),r}return i},S=plist.readFileSync(g);if(S.CFBundleName=y("CFBundleName",n.name),S.CFBundleDisplayName=y("CFBundleDisplayName",n.name),S.CFBundleShortVersionString=n.version,"number"==typeof n.versionCode?S.CFBundleVersion=parseInt(n.versionCode.toString(),10).toString():S.CFBundleVersion=(parseInt(S.CFBundleVersion,10)+1).toString(),S.CFBundleIdentifier=this.getBundleIdentifier(_),Array.isArray(S.CFBundleURLTypes)||(S.CFBundleURLTypes=[]),(null===(r=null===(o=S.CFBundleURLTypes)||void 0===o?void 0:o[0])||void 0===r?void 0:r.CFBundleURLSchemes)&&(S.CFBundleURLTypes[0].CFBundleURLSchemes=[h]),S.CFBundleURLTypes[0]&&(S.CFBundleURLTypes=[S.CFBundleURLTypes[0]]),exports.privateDescriptions.forEach(e=>{var i,t;(null===(i=null==n?void 0:n.privateDescriptions)||void 0===i?void 0:i[e])?S[e]=y(e,null===(t=n.privateDescriptions)||void 0===t?void 0:t[e]):delete S[e]}),!0===(null===(l=null==n?void 0:n.infoPlist)||void 0===l?void 0:l.DisableAppUsesNonExemptEncryption)?S.ITSAppUsesNonExemptEncryption=!1:delete S.ITSAppUsesNonExemptEncryption,S.UIBackgroundModes=[],!0===(null===(p=null==n?void 0:n.infoPlist)||void 0===p?void 0:p.AudioInBackgroundMode)&&S.UIBackgroundModes.push("audio"),!0===(null===(d=null==n?void 0:n.infoPlist)||void 0===d?void 0:d.LocationInBackgroundMode)&&S.UIBackgroundModes.push("location"),!0===(null===(c=null==n?void 0:n.infoPlist)||void 0===c?void 0:c.requiresFullScreen)?S.UIRequiresFullScreen=!0:delete S.UIRequiresFullScreen,"object"==typeof(null===(u=null==n?void 0:n.infoPlist)||void 0===u?void 0:u.CFBundleURLTypes)){const e=this.generateInfoPlistCFBundleURLTypesItem(n.infoPlist.CFBundleURLTypes);S.CFBundleURLTypes.push(e);const{additionalCFBundleURLTypes:i}=n.infoPlist.CFBundleURLTypes;Array.isArray(i)&&i.forEach(e=>{if("object"==typeof e){const i=this.generateInfoPlistCFBundleURLTypesItem(e);S.CFBundleURLTypes.push(i)}})}if(!0===n.enableIpad&&((0,miniappJson_1.iOSAppJsonIsUsingIPadResizable)(e)?(S["UISupportedInterfaceOrientations~ipad"]=["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortraitUpsideDown","UIInterfaceOrientationLandscapeLeft","UIInterfaceOrientationLandscapeRight"],a.progress("ipad is support Landscape")):(S["UISupportedInterfaceOrientations~ipad"]=["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortraitUpsideDown"],a.progress("ipad is not support Landscape"))),null===(f=n.infoPlist)||void 0===f?void 0:f.LSApplicationQueriesSchemes){const e=n.infoPlist.LSApplicationQueriesSchemes.split(",");e.length&&S.LSApplicationQueriesSchemes.push(...e.filter(e=>e))}return plist.writeFileSync(g,S),await this.writeI18NInfoFile(t,s,m),S.CFBundleVersion}getBundleIdentifier(e){return e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id}useGDT(e){return(0,miniappJson_1.iOSMiniAppJsonIsUsingGDT)(e)}async updateIOSAppConfigPlistInfo(e,i,t,n,a,s,o,r="Dark",l){var p,d,c,u;o.progress("update app module info...");const{module_info:f={},cpa_info:_={},cpa_package_info:h={enable_remove_watermark:!1}}=i;if(!_.sdk_key||!_.sdk_key_secret)throw new Error("sdkKey and sdkSecret not found");const g=path_1.default.join(t,"MiniApp.bundle"),m=path_1.default.join(g,"AppConfig.plist"),y=plist.readFileSync(m);h.enable_remove_watermark?y.enableRemoveWatermark=!0:y.splashscreenTheme=r,y.miniModuleId=f.module_id,y.sdkKey=_.sdk_key,y.sdkSecret=_.sdk_key_secret;const{privacy:S={}}=n;y.privacy||(y.privacy={}),y.privacy.enable=!!S.enable;const I=path_1.default.posix.join(g,"configs/privacy.json"),{contentViewImage:x,cancelButtonImage:b,confirmButtonImage:v,template:P}=S;if(S.enable){let i=P||"";if(fs_extra_1.default.ensureDirSync(path_1.default.posix.join(g,"configs")),i.startsWith("%")&&i.endsWith("%")){const t=P.slice(1,-1);i=(null===(d=null===(p=null==l?void 0:l.base)||void 0===p?void 0:p.ios)||void 0===d?void 0:d[t])||"",i||o.message("fail",`未在国际化配置 base.json 中找到字段 ${t},请检查`),Object.keys(l).forEach(i=>{var n,a;if("base"===i)return;let s=null===(a=null===(n=l[i])||void 0===n?void 0:n.ios)||void 0===a?void 0:a[t];if(s){s=this.getMaterialFilePath(e,s);const t=`configs/privacy-${i}.json`,n=path_1.default.posix.join(g,t);fs_extra_1.default.existsSync(s)?fs_extra_1.default.copyFileSync(s,n):o.message("fail",`未找到隐私协议在国际化配置 ${i}.json 中配置的文件 ${s},请检查`)}})}i?(i=this.getMaterialFilePath(e,i),fs_extra_1.default.existsSync(i)?(fs_extra_1.default.copyFileSync(i,I),y.privacy.template="configs/privacy.json"):(o.message("fail",`未找到隐私协议中配置的文件 ${i},请检查`),y.privacy.template="configs/defaultPrivacy.json")):y.privacy.template="configs/defaultPrivacy.json",!0===S.enableNativePlugin&&"string"==typeof S.nativePluginId&&S.nativePluginId.length>2&&(y.privacy.plugin={pluginId:S.nativePluginId,enable:!0})}else y.privacy.template="",fs_extra_1.default.removeSync(I);this.updatePrivacyBackgroundImage(e,t,o,"contentViewImage",x),this.updatePrivacyBackgroundImage(e,t,o,"confirmButtonImage",v),this.updatePrivacyBackgroundImage(e,t,o,"cancelButtonImage",b);const{appMenuEnable:F=!0}=n;y.appMenuEnable=F;const{enableVConsole:B="undefined"}=n;y.enableVConsole=B;const{tpush:j}=n;let D=!1;if("object"==typeof j){const e=path_1.default.posix.join(t,"PlugIns/TPNSService.appex"),i=path_1.default.posix.join(e,"AppConfig.plist");if(this.useTpush(n)){y.TPNSAccessID=j.accessID,y.TPNSAccessKey=j.accessKey,j.clusterDomainName?y.clusterDomainName=j.clusterDomainName:delete y.clusterDomainName;const t=s?"x86_64":"arm64",n=path_1.default.join(a,`appex/${t}/TPNSService.appex`);if(!fs_extra_1.default.existsSync(n))throw new Error("can not found extendsdk: "+n);try{fs_extra_1.default.copySync(n,e),plist.writeFileSync(i,y),D=!0}catch(e){throw new Error("copy TPNSService.appex to app failed: "+e)}}}if(!D)try{const e=path_1.default.posix.join(t,"PlugIns");fs_extra_1.default.existsSync(e)?(fs_extra_1.default.removeSync(e),o.progress("removed PlugIns folder...")):o.progress("no PlugIns folder...")}catch(e){throw new Error("remove TPNSService.appex from app failed: "+e)}if(null===(c=n.useExtendedSdk)||void 0===c?void 0:c.WeAppLBS){if(!n.qmapAPIKey)throw new Error("You need to provide the Tencent Location Service API Key when using LBS SDK.");y.qmapAPIKey=n.qmapAPIKey}const{gdt:C}=n,w=this.useGDT(n);if(y.GDTAd=w?{appid:C.appid,enable:!0,SplashAd:{placementId:C.splashAd_placementId,fetchDelay:C.splashAd_fetchDelay||3,defaultEnable:null===(u=C.splashAd_defaultEnable)||void 0===u||u}}:{appid:"",enable:!1,SplashAd:{placementId:"",fetchDelay:3}},n["mini-plugin"]&&Array.isArray(n["mini-plugin"].ios)){const e=n["mini-plugin"].ios.filter(e=>!!(e.open&&e.pluginId&&e.loadWhenStart)).map(e=>e.pluginId);y.plugins={loadWhenStart:e}}const{enableDebugLog:U=!1}=n;y.enableDebugLog=U;const{debugLogSizeLimit:A=10}=n;isNaN(Number(A))?o.message("fail",`ios debugLogSizeLimit ${A} is NaN`):y.debugLogSizeLimit=Number(A);const{enableOpenUrlNavigate:E=!1}=n;y.enableOpenUrlNavigate=E,plist.writeFileSync(m,y)}async updateIOSAppexInfoPlistInfo(e,i,t,n,a){if(this.useTpush(t)){a.progress("update appex for notification base info...");const{mobileapp_info:s={}}=e,o=path_1.default.join(i,"PlugIns/TPNSService.appex"),r=path_1.default.join(o,"Info.plist"),l=plist.readFileSync(r);l.CFBundleShortVersionString=t.version,a.progress("update appex for CFBundleVersion: "+n),l.CFBundleVersion=n;const p=s.ios_flag&&s.bundle_id||s.debug_ios_bundle_id;l.CFBundleIdentifier=t.tpush.serviceBundleId||p+".service",a.progress("update appex bundle identifier for infoPlist : "+l.CFBundleIdentifier),plist.writeFileSync(r,l)}else a.progress("not using tpush...")}updateBundleIcons(e,i,t,n,a){const s=[],o=[],r=[];for(const l in t){if(!t[l])continue;const p=this.getMaterialFilePath(e,t[l]);if(!p)return void a.message("fail","getMatrialFailed: "+t[l]);const d=iconInfoMap[l];try{const e=sizeOf(p),i=d.size[0]*d.scale,n=d.size[1]*d.scale;if(e.width!==i||e.height!==n){a.progress(`check ${l} size failed, require [${i}, ${n}] but [${e.width}, ${e.height}] ingore ${t[l]} `);continue}}catch(e){a.progress(`get ${l} info failed, ingore ${t[l]}(e: ${e.message})`);continue}const c=path_1.default.extname(p),u=1===d.scale?"":`@${d.scale}x`,f=`${d.size[0]}x${d.size[1]}`,_=l.startsWith("ipad"),h="appStore1024"===l,g=n,m=path_1.default.join(i,`${g}${f}${u}${_?"~ipad":""}${c}`),y={from:p,to:m,filename:path_1.default.basename(m),size:f,scale:d.scale+"x",idiom:d.idiom,key:l};s.push(y),h||(_?r.includes(`${g}${f}`)||r.push(`${g}${f}${u}`):o.includes(`${g}${f}`)||o.push(`${g}${f}${u}`))}return{iphoneBundleIconFiles:o,ipadBundleIconFiles:r,addFiles:s}}async updateIOSIcons(e,i,t,n,a,s){s.progress("update app icons...");const{icons:o={}}=n,r=a&&!env_1.isWin&&!!t;s.progress("genAssetCar: "+r);const l=glob_1.default.sync("AppIcon*.+(png|jpg|jpeg|webp)",{nodir:!0,cwd:i}).map(e=>path_1.default.join(i,e)),p="AppIcon-"+uuidv4().slice(0,8),d=this.updateBundleIcons(e,i,o,p,s);if(!d)throw new Error("updateBundleIcons failed");const{iphoneBundleIconFiles:c=[],ipadBundleIconFiles:u=[],addFiles:f=[]}=d,_={};for(const e in iconInfoMap){if(!iconInfoMap[e].required||o[e])continue;const i=iconInfoMap[e].size[0]*iconInfoMap[e].scale,t=iconInfoMap[e].size[1]*iconInfoMap[e].scale;if(_[e]=path_1.default.join(defaultIconDirPath,`donut-icon${i}x${t}.png`),s.progress(`using default app icons when ${e} is not config...`),!fs_extra_1.default.existsSync(_[e]))throw new Error(`required ${e} but not default or set`)}const h=this.updateBundleIcons(e,i,_,p,s);if(!h)throw new Error("updateBundleIcons WithDefaultIcon failed");const{iphoneBundleIconFiles:g,ipadBundleIconFiles:m,addFiles:y}=h;if(c.push(...g),u.push(...m),f.push(...y),!c.length&&!u.length)return;l.forEach(e=>{fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e)});const S=path_1.default.join(t,"__assetCarOperateDir/assetsCar/"),I=path_1.default.join(S,`Assets.xcassets/${p}.appiconset/`);r&&(fs_extra_1.default.ensureDirSync(I),fs_extra_1.default.emptyDirSync(I));const x=[];if(f.forEach(e=>{fs_extra_1.default.existsSync(e.to)&&fs_extra_1.default.removeSync(e.to),fs_extra_1.default.copyFileSync(e.from,e.to),r&&(fs_extra_1.default.copySync(e.from,path_1.default.join(I,e.filename)),x.push({filename:e.filename,size:e.size,scale:e.scale,idiom:e.idiom}))}),r&&fs_extra_1.default.writeJsonSync(path_1.default.join(I,"Contents.json"),{images:x,info:{author:"xcode",version:1}},{spaces:"\t"}),r){const e=path_1.default.join(__dirname,"../../../static/scripts/assetsCar/"),t=path_1.default.join(S,"createAssetsCar");fs_extra_1.default.copySync(e,S);try{await(0,codesign_1.checkXcodeEnv)(s),child_process.execSync(`"${t}" ${p}`,{env:(0,env_1.getProcessEnv)()})}catch(e){s.progress("createAssetsCar failed "+(e.message||""))}const n=path_1.default.join(S,"build/Assets.car"),a=path_1.default.join(i,"Assets.car");fs_extra_1.default.copyFileSync(n,a)}else{const e=path_1.default.join(i,"Assets.car");fs_extra_1.default.removeSync(e)}const b=path_1.default.join(i,"Info.plist"),v=plist.readFileSync(b);v.CFBundleIcons||(v.CFBundleIcons={CFBundlePrimaryIcon:{}}),v.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconName=p,v.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles=c,v["CFBundleIcons~ipad"]||(v["CFBundleIcons~ipad"]={CFBundlePrimaryIcon:{}}),v["CFBundleIcons~ipad"].CFBundlePrimaryIcon.CFBundleIconName=p,v["CFBundleIcons~ipad"].CFBundlePrimaryIcon.CFBundleIconFiles=u,v.NSAppTransportSecurity={NSAllowsArbitraryLoads:!0},plist.writeFileSync(b,v)}async updateSplashScreen(e,i,t,n,a="Dark"){n.progress("update splashscreen image...");const{splashscreen:s={}}=t;let o;if(allowTheme.includes(a)&&(o=path_1.default.join(i,`/Base.lproj/LaunchScreen${a}.storyboardc`)),o&&fs_extra_1.default.existsSync(o)&&fs_extra_1.default.copySync(o,path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc")),allowTheme.forEach(e=>{const t=path_1.default.join(i,`/Base.lproj/LaunchScreen${e}.storyboardc`);fs_extra_1.default.existsSync(t)&&fs_extra_1.default.removeSync(t)}),s.customImage){const t=path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib");let a=fs_extra_1.default.readFileSync(t).toString("hex");if(!s.customImage.endsWith(".png"))return void n.message("fail","IOS 启动页图片配置格式错误,必须为 PNG 格式");let o=s.customImage;o=this.getMaterialFilePath(e,s.customImage);const r=path_1.default.join(i,"Info.plist"),l=plist.readFileSync(r),p=l.UISplashScreenImageName+".png";glob_1.default.sync("LaunchScreen-*.+(png|jpg|jpeg|webp)",{nodir:!0,cwd:i}).forEach(e=>{const t=path_1.default.join(i,e);fs_extra_1.default.removeSync(t)});const d="LaunchScreen-"+uuidv4().slice(0,12),c=d+".png",u=path_1.default.join(i,c);fs_extra_1.default.copyFileSync(o,u),l.UISplashScreenImageName=d,plist.writeFileSync(r,l);const f=Buffer.from(p,"utf-8").toString("hex"),_=Buffer.from(c,"utf-8").toString("hex");-1!==a.indexOf(f)?(a=a.replace(f,_),console.log("replace storyboard customImage success")):console.log("replace storyboard customImage fail"),fs_extra_1.default.writeFileSync(t,Buffer.from(a,"hex"))}return!1}genUseExtendedSdk(e){const i=Object.assign({},e.useExtendedSdk||{});for(const t in e)if("object"==typeof e[t])for(const n in e[t])if(n.startsWith("useExtendedLib_WeApp")&&!0===e[t][n]){i[n.slice("useExtendedLib_".length)]=!0}return!i.WeAppLBS||i.WeAppOpenFuns||i.WeAppOpenFuns_HasPay||(i.WeAppOpenFuns=!0),i}async updateExtendedSdk(e,i,t,n,a,s){const o=path_1.default.join(i,"Frameworks");fs_extra_1.default.ensureDirSync(o),s.progress("update extendsdk...");const r=path_1.default.join(t,"WeAppSDK.podspec"),l=fs_extra_1.default.readFileSync(r,"utf-8"),p=this.genUseExtendedSdk(a);s.progress("useExtendedSdks: "+JSON.stringify(p));const{mobileapp_info:d={}}=e,c=this.getBundleIdentifier(d);if(p.WeAppOpenFuns&&p.WeAppOpenFuns_HasPay)throw new Error("OpenFuncs SDK 只可勾选使用一个,请按需勾选使用");const u={};for(const e in p){if(!p[e])continue;const i=getDepReg(e),a=l.match(i);if(!(null==a?void 0:a[1]))throw new Error(`拓展模块 ${e} 不存在或已被移除,请检查 project.miniapp.json -> 对应平台 -> useExtendedSdk 删除配置 ${e},版本配置差异请参考更新日志或 https://dev.weixin.qq.com/docs/framework/dev/sdk/difflog.html`);const s=[];if(a[1].split("\n").forEach(e=>{const i=e.match(/.*'(.*?)',/);if(null==i?void 0:i[1]){const e=i[1].split("/").pop(),a=path_1.default.join(t,"Libs",n,e);if(!fs_extra_1.default.existsSync(a))throw new Error(`拓展模块 ${e} 不存在或已被移除,请检查 project.miniapp.json -> 对应平台 -> useExtendedSdk 删除配置 ${e},版本配置差异请参考更新日志或 https://dev.weixin.qq.com/docs/framework/dev/sdk/difflog.html`);const r=path_1.default.join(o,e);fs_extra_1.default.copySync(a,r),s.push(path_1.default.basename(e));const l=path_1.default.join(r,"info.plist");if(!fs_extra_1.default.existsSync(l))throw new Error("can not found extendsdk info.plist: "+e);this.changeExtendSDKInfoplistBundleId(l,c,e)}}),s.length){u[s.shift()]=s}}const f=path_1.default.join(i,"DyFrameworks.plist");fs_extra_1.default.existsSync(f)&&fs_extra_1.default.removeSync(f),plist.writeFileSync(f,u)}async updatePrivacyInfo(e,i,t){var n;const a=null===(n=null==i?void 0:i.privacy)||void 0===n?void 0:n.privacyInfo;a&&(a.endsWith("PrivacyInfo.xcprivacy")?fs_extra_1.default.existsSync(a)?(fs_extra_1.default.copySync(a,path_1.default.join(e,"/PrivacyInfo.xcprivacy")),t.progress("隐私清单文件替换成功")):t.message("fail","隐私清单文件替换失败,文件不存在,将使用默认文件"):t.message("fail","隐私清单文件替换失败,文件名必须为 PrivacyInfo.xcprivacy,将使用默认文件"))}async updatePlugin(e,i,t,n,a,s,o,r){if(!i.length)return;const l=path_1.default.join(e,"Frameworks"),p=path_1.default.join(e,"PlugIns");fs_extra_1.default.ensureDirSync(l),r.progress("update plugin...");const d=this.prepareAppexProfileConfig(i,n,t,a,s,o,n.version,r);if(!d)throw new Error("依赖的多端插件需要配置对应的profile");const c={};if(n["mini-plugin"]&&Array.isArray(n["mini-plugin"].ios)){n["mini-plugin"].ios.forEach(e=>{e.open&&e.pluginId&&"string"==typeof e.resourcePath&&e.resourcePath.length>0&&(c[e.pluginId]=e.resourcePath)})}i.forEach(i=>{const{pluginId:n}=i,a=i.dir,s=n+".framework",o=path_1.default.join(l,s);if(-1!==a.indexOf("local-miniapp-plugin")){const e=fs_extra_1.default.statSync(a),{mtime:i}=e;r.progress(`${n}.framework 正在使用本地版本,修改时间为 ${i}`)}fs_extra_1.default.existsSync(o)&&fs_extra_1.default.removeSync(o);const u=path_1.default.join(a,s);if(fs_extra_1.default.existsSync(u)){fs_extra_1.default.copySync(u,o),this.copyResourcesToMainBundle(u,e),this.copyUserResourcePathIntoPlugins(n,t,c[n],path_1.default.join(o,"MiniPlugin.bundle"),r);fs_extra_1.default.readdirSync(a).forEach(i=>{if(i.endsWith(".appex")){const s=path_1.default.parse(i).name,o=d[s],l=path_1.default.join(p,i);if(!o||!0!==o.enable)return;r.progress(`${n} 插件使用 appex 中 : ${i}`),fs_extra_1.default.existsSync(l)&&fs_extra_1.default.removeSync(l),fs_extra_1.default.ensureDirSync(l);const u=path_1.default.join(a,i);fs_extra_1.default.copySync(u,l),(null==o?void 0:o.profilePath)&&fs_extra_1.default.copySync(o.profilePath,path_1.default.join(l,"embedded.mobileprovision")),this.copyResourcesToMainBundle(u,e),this.copyUserResourcePathIntoPlugins(n,t,c[n],path_1.default.join(l,"MiniPlugin.bundle"),r)}})}else fs_extra_1.default.copySync(a,o),this.copyResourcesToMainBundle(a,e),this.copyUserResourcePathIntoPlugins(n,t,c[n],path_1.default.join(o,"MiniPlugin.bundle"),r)})}copyUserResourcePathIntoPlugins(e,i,t,n,a){const s=n;if(t){const n=path_1.default.basename(t),o=this.getMaterialFilePath(i,t);if(o){a.progress(`${e}.framework 正在拷贝配置的资源:${t}`);const i=fs_extra_1.default.lstatSync(o);fs_extra_1.default.ensureDirSync(s),i.isDirectory()?fs_extra_1.default.copySync(o,s):i.isFile()&&fs_extra_1.default.copyFileSync(o,path_1.default.join(s,n))}}}copyResourcesToMainBundle(e,i){const t=path_1.default.join(e,"MiniPlugin.bundle"),n=path_1.default.join(t,"PluginConfig.plist");if(fs_extra_1.default.existsSync(n)){const e=plist.readFileSync(n).CopyResourcesToMainBundle;(null==e?void 0:e.length)&&e.forEach(e=>{const n=path_1.default.join(t,e);fs_extra_1.default.existsSync(n)&&fs_extra_1.default.copySync(n,path_1.default.join(i,e))})}}prepareAppexProfileConfig(e,i,t,n,a,s,o,r){if(!n)return void r.message("doing","miniappCacheDirPath is missing");let l=!1;const p={};if(i["mini-plugin"]&&Array.isArray(i["mini-plugin"].ios)){i["mini-plugin"].ios.forEach(e=>{if(e.open&&e.pluginId&&"object"==typeof e.appexProfiles)for(const i in e.appexProfiles){r.message("doing",`检查插件 ${e.pluginId} ${i} appex 配置中 ...`);const n=e.appexProfiles[i];if(!0===n.enable){const s=`${e.pluginId}_${i}`;p[s]={enable:!0};let o=n.profilePath;if(a&&(o=n.distributeProfilePath),n.bundleID&&o){const a=path_1.default.join(t,o);fs_extra_1.default.existsSync(a)?(p[s].bundleID=n.bundleID,p[s].profilePath=path_1.default.join(t,o)):(l=!0,r.message("fail",`${e.pluginId} 中 ${i} 的 profilePath 无法找到对应的文件:${a}(需要在小程序项目路径下,填入相对于项目根目录的路径)`))}else l=!0,r.message("fail",`${e.pluginId}中${i} 是 无效的appexProfiles配置。需要配置 bundleID,profilePath,distributeProfilePath。profile 文件需要放置在小程序项目内,然后配置相对于小程序项目根目录的相对路径。分发证书构建的情况下, 一定需要配置distributeProfilePath。查看文档了解详情。`)}}})}if(e.forEach(e=>{fs_extra_1.default.readdirSync(e.dir).forEach(i=>{if(i.endsWith(".appex")){const t=path_1.default.parse(i).name,n=p[t];if(n&&!0===n.enable)if(n.bundleID&&n.profilePath){if(n.bundleID&&n.profilePath){const t=path_1.default.join(e.dir,i,"info.plist"),a=n.bundleID;this.changeInfoplistBundleId(t,a),this.changeInfoplistBundleVersion(t,s,o),r.message("doing",`${e.pluginId} ${i} ${a} ${t} 处理 appex bundle ID 中`)}}else l=!0,r.message("fail",`${e.pluginId} 的 多端插件包含了${t.slice(e.pluginId.length+1)} 的 appex。开发者需要在project.miniapp.json 中 mini-plugin 配置下对应合理的 profile 文件。查看文档了解详情。`)}})}),l)return!1;if(!(0,lodash_1.isEmpty)(p)){const e=path_1.default.join(n,APPEX_PROFILES_MAPS_FILE);fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e),fs_extra_1.default.ensureFileSync(e);const i={};for(const e in p)i[e]={bundleID:p[e].bundleID,profilePath:p[e].profilePath};fs_extra_1.default.writeFileSync(e,JSON.stringify(i));const t=path_1.default.join(n,APPEX_PROFILES_MAPS_FOR_SHELL_FILE);fs_extra_1.default.existsSync(t)&&fs_extra_1.default.removeSync(t),fs_extra_1.default.ensureFileSync(t);const a=Object.keys(p).map(e=>{const i=p[e];return`pluginAppexName:${e};_;_;bundleID:${i.bundleID};_;_;profile:${i.profilePath}\n\n`}).join("");fs_extra_1.default.writeFileSync(t,a)}return p}changeExtendSDKInfoplistBundleId(e,i,t){const n=`${i}.${path_1.default.parse(t).name.replace(/_/g,"")}`;return this.changeInfoplistBundleId(e,n)}changeInfoplistBundleId(e,i){const t=plist.readFileSync(e);return t.CFBundleIdentifier=i,plist.writeFileSync(e,t),t.CFBundleIdentifier}changeInfoplistBundleVersion(e,i,t){const n=plist.readFileSync(e);return n.CFBundleVersion=i,n.CFBundleShortVersionString=t,plist.writeFileSync(e,n),n.CFBundleIdentifier}async getEntitlements(e,i,t,n){const{mobileapp_info:a={}}=e;let s=a.ios_universal_link||a.debug_ios_universal_link;return(s.startsWith("https://")||s.startsWith("http://"))&&(s=s.replace(/^http(s)?:\/\//g,"applinks:")),{"com.apple.developer.associated-domains":s}}useTpush(e){return(0,miniappJson_1.iOSMiniAppJsonIsUsingTpush)(e)}async buildCloud(e,i){const{projectPath:t,demoIpaPath:n,sdkPath:a,arch:s="arm64",bindingInfo:o,certificateInfo:r,output:l,miniappCacheDirPath:p,pluginDirList:d,inLandun:c,theme:u,i18nInfo:f}=e,_=this.generateTempDemoIpaPath(n),{selfCertificate:h={}}=r,g=(null==h?void 0:h.isPublish)||!1,m=(0,miniappJson_1.tryGetIOSMiniappJson)(t),y=this.useTpush(m);if((0,lodash_1.isEmpty)(m))throw new Error("获取project.miniapp.json失败");if(errorIOSSdkVersions.includes(m.sdkVersion))throw new Error("当前 mini-ios.sdkVersion 存在缺陷,请参考更新日志进行修改");let S=o;if(r.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=S;S=Object.assign(Object.assign({},S),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const I=await this.updateIOSInfoPlistInfo(t,S,_,m,i,f);await this.updateIOSAppConfigPlistInfo(t,S,_,m,a,!1,i,u,f),await this.updateIOSAppexInfoPlistInfo(S,_,m,I,i),await this.updateIOSIcons(t,_,p,m,g,i),await this.updateSplashScreen(t,_,m,i,u),await this.updateExtendedSdk(S,_,a,s,m,i),await this.updatePlugin(_,d,t,m,p,g,I,i),await this.updatePrivacyInfo(_,m,i);const x=await this.getEntitlements(S,_,m,i),{mobileapp_info:b={}}=S;let v;v=r.signType===miniapp_builder_1.miniappSinTypes.appleId.type?miniapp_builder_1.DEFAULT_BUNDLE_ID:b.ios_flag&&b.bundle_id||b.debug_ios_bundle_id;const P={bundleId:v,output:l,entitlements:x};if(m.buildCloud&&(m.buildCloud.certificate&&"string"==typeof m.buildCloud.certificate&&(P.certificate=m.buildCloud.certificate),m.buildCloud.profile&&"string"==typeof m.buildCloud.profile&&(P.profile=path_1.default.join(t,m.buildCloud.profile)),y&&m.buildCloud.tpnsProfile&&"string"==typeof m.buildCloud.tpnsProfile&&(P.tpnsProfile=path_1.default.join(t,m.buildCloud.tpnsProfile))),h.isPublish){const e=await(0,codesign_1.codesignAndExport)(t,_,p||"",P,i,y,!0===c);if(!0!==e.success)throw new Error("Build ipa failed:"+(e.errMsg||"codesignAndExport failed"))}return{projectPath:t,demoIpaPath:_,opts:P,iosMiniappJson:m,isPublish:g}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach(n=>{if("base"===n)return;let a="";Object.keys(t).forEach(e=>{var s,o,r,l;(null===(o=null===(s=i[n])||void 0===s?void 0:s.ios)||void 0===o?void 0:o[t[e]])&&(a+=`${e} = "${null===(l=null===(r=i[n])||void 0===r?void 0:r.ios)||void 0===l?void 0:l[t[e]]}";\n`)}),a&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,n+".lproj")),fs_extra_1.default.writeFileSync(path_1.default.join(e,n+".lproj/InfoPlist.strings"),a))})}getMaterialFilePath(e,i){if(!i)return"";let t=i;if(path_1.default.isAbsolute(i)||(t=path_1.default.join(e,i)),fs_extra_1.default.existsSync(t))return t;const n=(0,tools_1.generateMD5)(i),a=path_1.default.basename(i),s=path_1.default.join(e,exports.remoteBuildProjectMaterialAbsoluteCacheDir,`${n}_${a}`);return fs_extra_1.default.existsSync(s)?s:""}}exports.default=new buildCloudManager;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.remoteBuildProjectMaterialAbsoluteCacheDir=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),glob_1=tslib_1.__importDefault(require("glob")),env_1=require("../../../utils/env"),miniapp_builder_1=require("../../../utils/miniapp-builder"),codesign_1=require("../../../utils/codesign"),miniappJson_1=require("../../../utils/miniappJson"),lodash_1=require("lodash"),tools_1=require("../../../utils/tools"),uuidv4=require("uuid/v4"),sizeOf=require("image-size"),plist=require("simple-plist"),errorIOSSdkVersions=["1.0.19"],APPEX_PROFILES_MAPS_FILE="__appexProfilesCacheDir__/profilesMap.json",APPEX_PROFILES_MAPS_FOR_SHELL_FILE="__appexProfilesCacheDir__/profilesMapForShell.txt",defaultIconDirPath=path_1.default.join(__dirname,"../../../static/images/"),getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"];exports.remoteBuildProjectMaterialAbsoluteCacheDir="__absoluteFile";const iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},appStore1024Other:{size:[1024,1024],scale:1,idiom:"ios-marketing-other"},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}};class buildCloudManager{generateTempDemoIpaPath(e){const i=path_1.default.join(e,"../.."),t=path_1.default.basename(i),n=path_1.default.dirname(i),a=path_1.default.join(n,t+"-operateDir");fs_extra_1.default.existsSync(a)&&fs_extra_1.default.removeSync(a),fs_extra_1.default.ensureDirSync(a);const s=path_1.default.join(a,"Payload/demo.app");return fs_extra_1.default.copySync(e,s),s}generateInfoPlistCFBundleURLTypesItem(e){const i={};return e.CFBundleURLName&&(i.CFBundleURLName=e.CFBundleURLName),e.CFBundleURLSchemes&&(i.CFBundleURLSchemes=[e.CFBundleURLSchemes]),e.CFBundleTypeRole&&(i.CFBundleTypeRole=e.CFBundleTypeRole),i}updatePrivacyBackgroundImage(e,i,t,n,a){t.message("doing","updatePrivacyBackgroundImage "+n);if(fs_extra_1.default.readdirSync(i).forEach(e=>{"privacy_"+n===path_1.default.basename(e,path_1.default.extname(e))&&fs_extra_1.default.removeSync(path_1.default.join(i,e))}),!a)return;path_1.default.isAbsolute(a)||(a=path_1.default.join(e,a)),a=this.getMaterialFilePath(e,a);const s=path_1.default.extname(a),o=path_1.default.join(i,`privacy_${n}${s}`);try{fs_extra_1.default.copyFileSync(a,o)}catch(e){throw t.message("fail",`copy privacy image failed: ${n}, ${a} to ${o}`),e}}async updateIOSInfoPlistInfo(e,i,t,n,a,s){var o,l,r,d,p,u,c,f,_,h;a.progress("update app base info...");const{mobileapp_info:g={}}=i,m=g.mobileapp_id,y=path_1.default.join(t,"Info.plist"),I={},S=(e,i)=>{var t,n;if((null==i?void 0:i.startsWith("%"))&&(null==i?void 0:i.endsWith("%"))){const o=i.slice(1,-1);I[e]=o;const l=(null===(n=null===(t=null==s?void 0:s.base)||void 0===t?void 0:t.ios)||void 0===n?void 0:n[o])||"";return l||a.message("fail",`未在国际化配置 base.json 中找到字段 ${o},请检查`),l}return i};S("UISplashScreenImageName",null===(o=null==n?void 0:n.splashscreen)||void 0===o?void 0:o.customImage),S("UILaunchStoryboardName",null===(l=null==n?void 0:n.splashscreen)||void 0===l?void 0:l.customImage);const x=plist.readFileSync(y);if(x.CFBundleName=S("CFBundleName",n.name),x.CFBundleDisplayName=S("CFBundleDisplayName",n.name),x.CFBundleShortVersionString=n.version,"number"==typeof n.versionCode?x.CFBundleVersion=parseInt(n.versionCode.toString(),10).toString():x.CFBundleVersion=(parseInt(x.CFBundleVersion,10)+1).toString(),x.CFBundleIdentifier=this.getBundleIdentifier(g),Array.isArray(x.CFBundleURLTypes)||(x.CFBundleURLTypes=[]),(null===(d=null===(r=x.CFBundleURLTypes)||void 0===r?void 0:r[0])||void 0===d?void 0:d.CFBundleURLSchemes)&&(x.CFBundleURLTypes[0].CFBundleURLSchemes=[m]),x.CFBundleURLTypes[0]&&(x.CFBundleURLTypes=[x.CFBundleURLTypes[0]]),Object.keys(miniappJson_1.iosPrivacyDescObj).forEach(e=>{var i,t;(null===(i=null==n?void 0:n.privateDescriptions)||void 0===i?void 0:i[e])?x[e]=S(e,null===(t=n.privateDescriptions)||void 0===t?void 0:t[e]):delete x[e]}),!0===(null===(p=null==n?void 0:n.infoPlist)||void 0===p?void 0:p.DisableAppUsesNonExemptEncryption)?x.ITSAppUsesNonExemptEncryption=!1:delete x.ITSAppUsesNonExemptEncryption,x.UIBackgroundModes=[],!0===(null===(u=null==n?void 0:n.infoPlist)||void 0===u?void 0:u.AudioInBackgroundMode)&&x.UIBackgroundModes.push("audio"),!0===(null===(c=null==n?void 0:n.infoPlist)||void 0===c?void 0:c.LocationInBackgroundMode)&&x.UIBackgroundModes.push("location"),!0===(null===(f=null==n?void 0:n.infoPlist)||void 0===f?void 0:f.requiresFullScreen)?x.UIRequiresFullScreen=!0:delete x.UIRequiresFullScreen,"object"==typeof(null===(_=null==n?void 0:n.infoPlist)||void 0===_?void 0:_.CFBundleURLTypes)){const e=this.generateInfoPlistCFBundleURLTypesItem(n.infoPlist.CFBundleURLTypes);x.CFBundleURLTypes.push(e);const{additionalCFBundleURLTypes:i}=n.infoPlist.CFBundleURLTypes;Array.isArray(i)&&i.forEach(e=>{if("object"==typeof e){const i=this.generateInfoPlistCFBundleURLTypesItem(e);x.CFBundleURLTypes.push(i)}})}if(!0===n.enableIpad&&((0,miniappJson_1.iOSAppJsonIsUsingIPadResizable)(e)?(x["UISupportedInterfaceOrientations~ipad"]=["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortraitUpsideDown","UIInterfaceOrientationLandscapeLeft","UIInterfaceOrientationLandscapeRight"],a.progress("ipad is support Landscape")):(x["UISupportedInterfaceOrientations~ipad"]=["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortraitUpsideDown"],a.progress("ipad is not support Landscape"))),null===(h=n.infoPlist)||void 0===h?void 0:h.LSApplicationQueriesSchemes){const e=n.infoPlist.LSApplicationQueriesSchemes.split(",");e.length&&x.LSApplicationQueriesSchemes.push(...e.filter(e=>e))}return plist.writeFileSync(y,x),await this.writeI18NInfoFile(t,s,I),x.CFBundleVersion}getBundleIdentifier(e){return e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id}useGDT(e){return(0,miniappJson_1.iOSMiniAppJsonIsUsingGDT)(e)}async updateIOSAppConfigPlistInfo(e,i,t,n,a,s,o,l="Dark",r){var d,p,u,c;o.progress("update app module info...");const{module_info:f={},cpa_info:_={},cpa_package_info:h={enable_remove_watermark:!1}}=i;if(!_.sdk_key||!_.sdk_key_secret)throw new Error("sdkKey and sdkSecret not found");const g=path_1.default.join(t,"MiniApp.bundle"),m=path_1.default.join(g,"AppConfig.plist"),y=plist.readFileSync(m);h.enable_remove_watermark?y.enableRemoveWatermark=!0:y.splashscreenTheme=l,y.miniModuleId=f.module_id,y.sdkKey=_.sdk_key,y.sdkSecret=_.sdk_key_secret;const{privacy:I={}}=n;y.privacy||(y.privacy={}),y.privacy.enable=!!I.enable;const S=path_1.default.posix.join(g,"configs/privacy.json"),{contentViewImage:x,cancelButtonImage:v,confirmButtonImage:b,template:P}=I;if(I.enable){let i=P||"";if(fs_extra_1.default.ensureDirSync(path_1.default.posix.join(g,"configs")),i.startsWith("%")&&i.endsWith("%")){const t=P.slice(1,-1);i=(null===(p=null===(d=null==r?void 0:r.base)||void 0===d?void 0:d.ios)||void 0===p?void 0:p[t])||"",i||o.message("fail",`未在国际化配置 base.json 中找到字段 ${t},请检查`),Object.keys(r).forEach(i=>{var n,a;if("base"===i)return;let s=null===(a=null===(n=r[i])||void 0===n?void 0:n.ios)||void 0===a?void 0:a[t];if(s){s=this.getMaterialFilePath(e,s);const t=`configs/privacy-${i}.json`,n=path_1.default.posix.join(g,t);fs_extra_1.default.existsSync(s)?fs_extra_1.default.copyFileSync(s,n):o.message("fail",`未找到隐私协议在国际化配置 ${i}.json 中配置的文件 ${s},请检查`)}})}i?(i=this.getMaterialFilePath(e,i),fs_extra_1.default.existsSync(i)?(fs_extra_1.default.copyFileSync(i,S),y.privacy.template="configs/privacy.json"):(o.message("fail",`未找到隐私协议中配置的文件 ${i},请检查`),y.privacy.template="configs/defaultPrivacy.json")):y.privacy.template="configs/defaultPrivacy.json",!0===I.enableNativePlugin&&"string"==typeof I.nativePluginId&&I.nativePluginId.length>2&&(y.privacy.plugin={pluginId:I.nativePluginId,enable:!0})}else y.privacy.template="",fs_extra_1.default.removeSync(S);this.updatePrivacyBackgroundImage(e,t,o,"contentViewImage",x),this.updatePrivacyBackgroundImage(e,t,o,"confirmButtonImage",b),this.updatePrivacyBackgroundImage(e,t,o,"cancelButtonImage",v);const{appMenuEnable:F=!0}=n;y.appMenuEnable=F;const{enableVConsole:j="undefined"}=n;y.enableVConsole=j;const{tpush:B}=n;let C=!1;if("object"==typeof B){const e=path_1.default.posix.join(t,"PlugIns/TPNSService.appex"),i=path_1.default.posix.join(e,"AppConfig.plist");if(this.useTpush(n)){y.TPNSAccessID=B.accessID,y.TPNSAccessKey=B.accessKey,B.clusterDomainName?y.clusterDomainName=B.clusterDomainName:delete y.clusterDomainName;const t=s?"x86_64":"arm64",n=path_1.default.join(a,`appex/${t}/TPNSService.appex`);if(!fs_extra_1.default.existsSync(n))throw new Error("can not found extendsdk: "+n);try{fs_extra_1.default.copySync(n,e),plist.writeFileSync(i,y),C=!0}catch(e){throw new Error("copy TPNSService.appex to app failed: "+e)}}}if(!C)try{const e=path_1.default.posix.join(t,"PlugIns");fs_extra_1.default.existsSync(e)?(fs_extra_1.default.removeSync(e),o.progress("removed PlugIns folder...")):o.progress("no PlugIns folder...")}catch(e){throw new Error("remove TPNSService.appex from app failed: "+e)}if(null===(u=n.useExtendedSdk)||void 0===u?void 0:u.WeAppLBS){if(!n.qmapAPIKey)throw new Error("You need to provide the Tencent Location Service API Key when using LBS SDK.");y.qmapAPIKey=n.qmapAPIKey}const{gdt:w}=n,L=this.useGDT(n);if(y.GDTAd=L?{appid:w.appid,enable:!0,SplashAd:{placementId:w.splashAd_placementId,fetchDelay:w.splashAd_fetchDelay||3,defaultEnable:null===(c=w.splashAd_defaultEnable)||void 0===c||c}}:{appid:"",enable:!1,SplashAd:{placementId:"",fetchDelay:3}},n["mini-plugin"]&&Array.isArray(n["mini-plugin"].ios)){const e=n["mini-plugin"].ios.filter(e=>!!(e.open&&e.pluginId&&e.loadWhenStart)).map(e=>e.pluginId);y.plugins={loadWhenStart:e}}const{enableDebugLog:$=!1}=n;y.enableDebugLog=$;const{debugLogSizeLimit:D=10}=n;isNaN(Number(D))?o.message("fail",`ios debugLogSizeLimit ${D} is NaN`):y.debugLogSizeLimit=Number(D);const{enableOpenUrlNavigate:E=!1}=n;y.enableOpenUrlNavigate=E,plist.writeFileSync(m,y)}async updateIOSAppexInfoPlistInfo(e,i,t,n,a){if(this.useTpush(t)){a.progress("update appex for notification base info...");const{mobileapp_info:s={}}=e,o=path_1.default.join(i,"PlugIns/TPNSService.appex"),l=path_1.default.join(o,"Info.plist"),r=plist.readFileSync(l);r.CFBundleShortVersionString=t.version,a.progress("update appex for CFBundleVersion: "+n),r.CFBundleVersion=n;const d=s.ios_flag&&s.bundle_id||s.debug_ios_bundle_id;r.CFBundleIdentifier=t.tpush.serviceBundleId||d+".service",a.progress("update appex bundle identifier for infoPlist : "+r.CFBundleIdentifier),plist.writeFileSync(l,r)}else a.progress("not using tpush...")}updateBundleIcons(e,i,t,n,a){const s=[],o=[],l=[];for(const r in t){if(!t[r])continue;const d=this.getMaterialFilePath(e,t[r]);if(!d)return void a.message("fail","getMatrialFailed: "+t[r]);const p=iconInfoMap[r];try{const e=sizeOf(d),i=p.size[0]*p.scale,n=p.size[1]*p.scale;if(e.width!==i||e.height!==n){a.progress(`check ${r} size failed, require [${i}, ${n}] but [${e.width}, ${e.height}] ingore ${t[r]} `);continue}}catch(e){a.progress(`get ${r} info failed, ingore ${t[r]}(e: ${e.message})`);continue}const u=path_1.default.extname(d),c=1===p.scale?"":`@${p.scale}x`,f=`${p.size[0]}x${p.size[1]}`,_=r.startsWith("ipad"),h="appStore1024"===r||"appStore1024Other"===r,g="appStore1024Other"===r?n+"Other":n,m=path_1.default.join(i,`${g}${f}${c}${_?"~ipad":""}${u}`),y={from:d,to:m,filename:path_1.default.basename(m),size:f,scale:p.scale+"x",idiom:p.idiom,key:r};s.push(y),h||(_?l.includes(`${g}${f}`)||l.push(`${g}${f}${c}`):o.includes(`${g}${f}`)||o.push(`${g}${f}${c}`))}return{iphoneBundleIconFiles:o,ipadBundleIconFiles:l,addFiles:s}}async updateIOSIcons(e,i,t,n,a,s){s.progress("update app icons...");const{icons:o={}}=n,l=a&&!env_1.isWin&&!!t;s.progress("genAssetCar: "+l);const r=glob_1.default.sync("AppIcon*.+(png|jpg|jpeg|webp)",{nodir:!0,cwd:i}).map(e=>path_1.default.join(i,e)),d="AppIcon-"+uuidv4().slice(0,8),p=this.updateBundleIcons(e,i,o,d,s);if(!p)throw new Error("updateBundleIcons failed");const{iphoneBundleIconFiles:u=[],ipadBundleIconFiles:c=[],addFiles:f=[]}=p,_={};for(const e in iconInfoMap){if(!iconInfoMap[e].required||o[e])continue;const i=iconInfoMap[e].size[0]*iconInfoMap[e].scale,t=iconInfoMap[e].size[1]*iconInfoMap[e].scale;if(_[e]=path_1.default.join(defaultIconDirPath,`donut-icon${i}x${t}.png`),s.progress(`using default app icons when ${e} is not config...`),!fs_extra_1.default.existsSync(_[e]))throw new Error(`required ${e} but not default or set`)}const h=this.updateBundleIcons(e,i,_,d,s);if(!h)throw new Error("updateBundleIcons WithDefaultIcon failed");const{iphoneBundleIconFiles:g,ipadBundleIconFiles:m,addFiles:y}=h;if(u.push(...g),c.push(...m),f.push(...y),!u.length&&!c.length)return;r.forEach(e=>{fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e)});const I=path_1.default.join(t,"__assetCarOperateDir/assetsCar/"),S=path_1.default.join(I,`Assets.xcassets/${d}.appiconset/`);l&&(fs_extra_1.default.ensureDirSync(S),fs_extra_1.default.emptyDirSync(S));const x=[];let v=!1;if(f.forEach(e=>{fs_extra_1.default.existsSync(e.to)&&fs_extra_1.default.removeSync(e.to),fs_extra_1.default.copyFileSync(e.from,e.to),l&&(fs_extra_1.default.copySync(e.from,path_1.default.join(S,e.filename)),console.log("看看啊",path_1.default.join(S,e.filename)),"ios-marketing-other"===e.idiom&&(v=!0),x.push({filename:e.filename,size:e.size,scale:e.scale,idiom:e.idiom}))}),l&&fs_extra_1.default.writeJsonSync(path_1.default.join(S,"Contents.json"),{images:x,info:{author:"xcode",version:1}},{spaces:"\t"}),l){const e=path_1.default.join(__dirname,"../../../static/scripts/assetsCar/"),t=path_1.default.join(I,"createAssetsCar");fs_extra_1.default.copySync(e,I);try{await(0,codesign_1.checkXcodeEnv)(s),child_process.execSync(`"${t}" ${d}`,{env:(0,env_1.getProcessEnv)()})}catch(e){s.progress("createAssetsCar failed "+(e.message||""))}const n=path_1.default.join(I,"build/Assets.car"),a=path_1.default.join(i,"Assets.car");fs_extra_1.default.copyFileSync(n,a)}else{const e=path_1.default.join(i,"Assets.car");fs_extra_1.default.removeSync(e)}const b=path_1.default.join(i,"Info.plist"),P=plist.readFileSync(b);if(!P.CFBundleIcons){const e={CFBundlePrimaryIcon:{}};P.CFBundleIcons=e}v&&(P.CFBundleIcons.CFBundleAlternateIcons={OtherAppStoreIcon:{CFBundleIconFiles:[d+"Other"],CFBundleIconName:"OtherAppStoreIcon"}}),P.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconName=d,P.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles=u,P["CFBundleIcons~ipad"]||(P["CFBundleIcons~ipad"]={CFBundlePrimaryIcon:{}}),P["CFBundleIcons~ipad"].CFBundlePrimaryIcon.CFBundleIconName=d,P["CFBundleIcons~ipad"].CFBundlePrimaryIcon.CFBundleIconFiles=c,P.NSAppTransportSecurity={NSAllowsArbitraryLoads:!0},plist.writeFileSync(b,P)}replaceLaunchScreenImage(e,i,t,n,a,s){const o=path_1.default.join(e,"01J-lp-oVM-view-Ze5-6b-2t3.nib");let l=fs_extra_1.default.readFileSync(o).toString("hex");if(!i.endsWith(".png"))return void n.message("fail","IOS 启动页图片配置格式错误,必须为 PNG 格式, 错误配置:"+i);const r=this.getMaterialFilePath(a,i),d=t+".png",p="LaunchScreen-"+uuidv4().slice(0,12),u=p+".png",c=path_1.default.join(s,u);fs_extra_1.default.copyFileSync(r,c);const f=Buffer.from(d,"utf-8").toString("hex"),_=Buffer.from(u,"utf-8").toString("hex");return-1!==l.indexOf(f)?(l=l.replace(f,_),console.log("replace storyboard customImage success")):console.log("replace storyboard customImage fail"),fs_extra_1.default.writeFileSync(o,Buffer.from(l,"hex")),p}async updateSplashScreen(e,i,t,n,a="Dark",s){var o,l,r;let d;n.progress("update splashscreen image..."),allowTheme.includes(a)&&(d=path_1.default.join(i,`/Base.lproj/LaunchScreen${a}.storyboardc`)),d&&fs_extra_1.default.existsSync(d)&&fs_extra_1.default.copySync(d,path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc")),allowTheme.forEach(e=>{const t=path_1.default.join(i,`/Base.lproj/LaunchScreen${e}.storyboardc`);fs_extra_1.default.existsSync(t)&&fs_extra_1.default.removeSync(t)});let p=null===(o=null==t?void 0:t.splashscreen)||void 0===o?void 0:o.customImage;if(!p)return;const u=path_1.default.join(i,"Info.plist"),c=plist.readFileSync(u),f=c.UISplashScreenImageName;if(glob_1.default.sync("LaunchScreen-*.+(png|jpg|jpeg|webp)",{nodir:!0,cwd:i}).forEach(e=>{const t=path_1.default.join(i,e);fs_extra_1.default.removeSync(t)}),p.startsWith("%")&&(null==p?void 0:p.endsWith("%"))){const t=p.slice(1,-1),a=(null===(r=null===(l=null==s?void 0:s.base)||void 0===l?void 0:l.ios)||void 0===r?void 0:r[t])||"";if(!a)return void n.message("fail",`未在国际化配置 base.json 中找到字段 ${t},请检查,启动页国际化配置失败`);p=a,Object.keys(s).forEach(a=>{var o,l;if("base"===a)return;const r=null===(l=null===(o=s[a])||void 0===o?void 0:o.ios)||void 0===l?void 0:l[t];if(r){const t=path_1.default.join(i,`/${a}.lproj/LaunchScreen_${a}.storyboardc`);fs_extra_1.default.ensureDirSync(path_1.default.join(t,"..")),fs_extra_1.default.copySync(path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc"),t);const s=this.replaceLaunchScreenImage(t,this.getMaterialFilePath(e,r),f,n,e,i);n.progress(`update ${a} splashscreen image...`);const o=fs_extra_1.default.readFileSync(path_1.default.join(i,a+".lproj/InfoPlist.strings"),"utf8");let l="";l=s?o.replace("__UISplashScreenImageName__",`UISplashScreenImageName = "${s}";\n`).replace("__UILaunchStoryboardName__",`UILaunchStoryboardName = "LaunchScreen_${a}";\n`):o.replace("__UISplashScreenImageName__","").replace("__UILaunchStoryboardName__",""),fs_extra_1.default.writeFileSync(path_1.default.join(i,a+".lproj/InfoPlist.strings"),l),n.progress(`update ${a} splashscreen image success`)}})}n.progress("update base splashscreen image...");const _=this.replaceLaunchScreenImage(path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc"),this.getMaterialFilePath(e,p),f,n,e,i);n.progress("update base splashscreen image success"),_&&(c.UISplashScreenImageName=_,c.UILaunchStoryboardName="LaunchScreen",plist.writeFileSync(u,c))}genUseExtendedSdk(e){const i=Object.assign({},e.useExtendedSdk||{});for(const t in e)if("object"==typeof e[t])for(const n in e[t])if(n.startsWith("useExtendedLib_WeApp")&&!0===e[t][n]){i[n.slice("useExtendedLib_".length)]=!0}return!i.WeAppLBS||i.WeAppOpenFuns||i.WeAppOpenFuns_HasPay||(i.WeAppOpenFuns=!0),i}async updateExtendedSdk(e,i,t,n,a,s){const o=path_1.default.join(i,"Frameworks");fs_extra_1.default.ensureDirSync(o),s.progress("update extendsdk...");const l=path_1.default.join(t,"WeAppSDK.podspec"),r=fs_extra_1.default.readFileSync(l,"utf-8"),d=this.genUseExtendedSdk(a);s.progress("useExtendedSdks: "+JSON.stringify(d));const{mobileapp_info:p={}}=e,u=this.getBundleIdentifier(p);if(d.WeAppOpenFuns&&d.WeAppOpenFuns_HasPay)throw new Error("OpenFuncs SDK 只可勾选使用一个,请按需勾选使用");const c={};for(const e in d){if(!d[e])continue;const i=getDepReg(e),a=r.match(i);if(!(null==a?void 0:a[1]))throw new Error(`拓展模块 ${e} 不存在或已被移除,请检查 project.miniapp.json -> 对应平台 -> useExtendedSdk 删除配置 ${e},版本配置差异请参考更新日志或 https://dev.weixin.qq.com/docs/framework/dev/sdk/difflog.html`);const s=[];if(a[1].split("\n").forEach(e=>{const i=e.match(/.*'(.*?)',/);if(null==i?void 0:i[1]){const e=i[1].split("/").pop(),a=path_1.default.join(t,"Libs",n,e);if(!fs_extra_1.default.existsSync(a))throw new Error(`拓展模块 ${e} 不存在或已被移除,请检查 project.miniapp.json -> 对应平台 -> useExtendedSdk 删除配置 ${e},版本配置差异请参考更新日志或 https://dev.weixin.qq.com/docs/framework/dev/sdk/difflog.html`);const l=path_1.default.join(o,e);fs_extra_1.default.copySync(a,l),s.push(path_1.default.basename(e));const r=path_1.default.join(l,"info.plist");if(!fs_extra_1.default.existsSync(r))throw new Error("can not found extendsdk info.plist: "+e);this.changeExtendSDKInfoplistBundleId(r,u,e)}}),s.length){c[s.shift()]=s}}const f=path_1.default.join(i,"DyFrameworks.plist");fs_extra_1.default.existsSync(f)&&fs_extra_1.default.removeSync(f),plist.writeFileSync(f,c)}async updatePrivacyInfo(e,i,t){var n;const a=null===(n=null==i?void 0:i.privacy)||void 0===n?void 0:n.privacyInfo;a&&(a.endsWith("PrivacyInfo.xcprivacy")?fs_extra_1.default.existsSync(a)?(fs_extra_1.default.copySync(a,path_1.default.join(e,"/PrivacyInfo.xcprivacy")),t.progress("隐私清单文件替换成功")):t.message("fail","隐私清单文件替换失败,文件不存在,将使用默认文件"):t.message("fail","隐私清单文件替换失败,文件名必须为 PrivacyInfo.xcprivacy,将使用默认文件"))}async updatePlugin(e,i,t,n,a,s,o,l){if(!i.length)return;const r=path_1.default.join(e,"Frameworks"),d=path_1.default.join(e,"PlugIns");fs_extra_1.default.ensureDirSync(r),l.progress("update plugin...");const p=this.prepareAppexProfileConfig(i,n,t,a,s,o,n.version,l);if(!p)throw new Error("依赖的多端插件需要配置对应的profile");const u={};if(n["mini-plugin"]&&Array.isArray(n["mini-plugin"].ios)){n["mini-plugin"].ios.forEach(e=>{e.open&&e.pluginId&&"string"==typeof e.resourcePath&&e.resourcePath.length>0&&(u[e.pluginId]=e.resourcePath)})}i.forEach(i=>{const{pluginId:n}=i,a=i.dir,s=n+".framework",o=path_1.default.join(r,s);if(-1!==a.indexOf("local-miniapp-plugin")){const e=fs_extra_1.default.statSync(a),{mtime:i}=e;l.progress(`${n}.framework 正在使用本地版本,修改时间为 ${i}`)}fs_extra_1.default.existsSync(o)&&fs_extra_1.default.removeSync(o);const c=path_1.default.join(a,s);if(fs_extra_1.default.existsSync(c)){fs_extra_1.default.copySync(c,o),this.copyResourcesToMainBundle(c,e),this.copyUserResourcePathIntoPlugins(n,t,u[n],path_1.default.join(o,"MiniPlugin.bundle"),l);fs_extra_1.default.readdirSync(a).forEach(i=>{if(i.endsWith(".appex")){const s=path_1.default.parse(i).name,o=p[s],r=path_1.default.join(d,i);if(!o||!0!==o.enable)return;l.progress(`${n} 插件使用 appex 中 : ${i}`),fs_extra_1.default.existsSync(r)&&fs_extra_1.default.removeSync(r),fs_extra_1.default.ensureDirSync(r);const c=path_1.default.join(a,i);fs_extra_1.default.copySync(c,r),(null==o?void 0:o.profilePath)&&fs_extra_1.default.copySync(o.profilePath,path_1.default.join(r,"embedded.mobileprovision")),this.copyResourcesToMainBundle(c,e),this.copyUserResourcePathIntoPlugins(n,t,u[n],path_1.default.join(r,"MiniPlugin.bundle"),l)}})}else fs_extra_1.default.copySync(a,o),this.copyResourcesToMainBundle(a,e),this.copyUserResourcePathIntoPlugins(n,t,u[n],path_1.default.join(o,"MiniPlugin.bundle"),l)})}copyUserResourcePathIntoPlugins(e,i,t,n,a){const s=n;if(t){const n=path_1.default.basename(t),o=this.getMaterialFilePath(i,t);if(o){a.progress(`${e}.framework 正在拷贝配置的资源:${t}`);const i=fs_extra_1.default.lstatSync(o);fs_extra_1.default.ensureDirSync(s),i.isDirectory()?fs_extra_1.default.copySync(o,s):i.isFile()&&fs_extra_1.default.copyFileSync(o,path_1.default.join(s,n))}}}copyResourcesToMainBundle(e,i){const t=path_1.default.join(e,"MiniPlugin.bundle"),n=path_1.default.join(t,"PluginConfig.plist");if(fs_extra_1.default.existsSync(n)){const e=plist.readFileSync(n).CopyResourcesToMainBundle;(null==e?void 0:e.length)&&e.forEach(e=>{const n=path_1.default.join(t,e);fs_extra_1.default.existsSync(n)&&fs_extra_1.default.copySync(n,path_1.default.join(i,e))})}}prepareAppexProfileConfig(e,i,t,n,a,s,o,l){if(!n)return void l.message("doing","miniappCacheDirPath is missing");let r=!1;const d={};if(i["mini-plugin"]&&Array.isArray(i["mini-plugin"].ios)){i["mini-plugin"].ios.forEach(e=>{if(e.open&&e.pluginId&&"object"==typeof e.appexProfiles)for(const i in e.appexProfiles){l.message("doing",`检查插件 ${e.pluginId} ${i} appex 配置中 ...`);const n=e.appexProfiles[i];if(!0===n.enable){const s=`${e.pluginId}_${i}`;d[s]={enable:!0};let o=n.profilePath;if(a&&(o=n.distributeProfilePath),n.bundleID&&o){const a=path_1.default.join(t,o);fs_extra_1.default.existsSync(a)?(d[s].bundleID=n.bundleID,d[s].profilePath=path_1.default.join(t,o)):(r=!0,l.message("fail",`${e.pluginId} 中 ${i} 的 profilePath 无法找到对应的文件:${a}(需要在小程序项目路径下,填入相对于项目根目录的路径)`))}else r=!0,l.message("fail",`${e.pluginId}中${i} 是 无效的appexProfiles配置。需要配置 bundleID,profilePath,distributeProfilePath。profile 文件需要放置在小程序项目内,然后配置相对于小程序项目根目录的相对路径。分发证书构建的情况下, 一定需要配置distributeProfilePath。查看文档了解详情。`)}}})}if(e.forEach(e=>{fs_extra_1.default.readdirSync(e.dir).forEach(i=>{if(i.endsWith(".appex")){const t=path_1.default.parse(i).name,n=d[t];if(n&&!0===n.enable)if(n.bundleID&&n.profilePath){if(n.bundleID&&n.profilePath){const t=path_1.default.join(e.dir,i,"info.plist"),a=n.bundleID;this.changeInfoplistBundleId(t,a),this.changeInfoplistBundleVersion(t,s,o),l.message("doing",`${e.pluginId} ${i} ${a} ${t} 处理 appex bundle ID 中`)}}else r=!0,l.message("fail",`${e.pluginId} 的 多端插件包含了${t.slice(e.pluginId.length+1)} 的 appex。开发者需要在project.miniapp.json 中 mini-plugin 配置下对应合理的 profile 文件。查看文档了解详情。`)}})}),r)return!1;if(!(0,lodash_1.isEmpty)(d)){const e=path_1.default.join(n,APPEX_PROFILES_MAPS_FILE);fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e),fs_extra_1.default.ensureFileSync(e);const i={};for(const e in d)i[e]={bundleID:d[e].bundleID,profilePath:d[e].profilePath};fs_extra_1.default.writeFileSync(e,JSON.stringify(i));const t=path_1.default.join(n,APPEX_PROFILES_MAPS_FOR_SHELL_FILE);fs_extra_1.default.existsSync(t)&&fs_extra_1.default.removeSync(t),fs_extra_1.default.ensureFileSync(t);const a=Object.keys(d).map(e=>{const i=d[e];return`pluginAppexName:${e};_;_;bundleID:${i.bundleID};_;_;profile:${i.profilePath}\n\n`}).join("");fs_extra_1.default.writeFileSync(t,a)}return d}changeExtendSDKInfoplistBundleId(e,i,t){const n=`${i}.${path_1.default.parse(t).name.replace(/_/g,"")}`;return this.changeInfoplistBundleId(e,n)}changeInfoplistBundleId(e,i){const t=plist.readFileSync(e);return t.CFBundleIdentifier=i,plist.writeFileSync(e,t),t.CFBundleIdentifier}changeInfoplistBundleVersion(e,i,t){const n=plist.readFileSync(e);return n.CFBundleVersion=i,n.CFBundleShortVersionString=t,plist.writeFileSync(e,n),n.CFBundleIdentifier}async getEntitlements(e,i,t,n){const{mobileapp_info:a={}}=e;let s=a.ios_universal_link||a.debug_ios_universal_link;return(s.startsWith("https://")||s.startsWith("http://"))&&(s=s.replace(/^http(s)?:\/\//g,"applinks:")),{"com.apple.developer.associated-domains":s}}useTpush(e){return(0,miniappJson_1.iOSMiniAppJsonIsUsingTpush)(e)}async buildCloud(e,i){const{projectPath:t,demoIpaPath:n,sdkPath:a,arch:s="arm64",bindingInfo:o,certificateInfo:l,output:r,miniappCacheDirPath:d,pluginDirList:p,inLandun:u,theme:c,i18nInfo:f}=e,_=this.generateTempDemoIpaPath(n),{selfCertificate:h={}}=l,g=(null==h?void 0:h.isPublish)||!1,m=(0,miniappJson_1.tryGetIOSMiniappJson)(t),y=this.useTpush(m);if((0,lodash_1.isEmpty)(m))throw new Error("获取project.miniapp.json失败");if(errorIOSSdkVersions.includes(m.sdkVersion))throw new Error("当前 mini-ios.sdkVersion 存在缺陷,请参考更新日志进行修改");let I=o;if(l.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=I;I=Object.assign(Object.assign({},I),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const S=await this.updateIOSInfoPlistInfo(t,I,_,m,i,f);await this.updateIOSAppConfigPlistInfo(t,I,_,m,a,!1,i,c,f),await this.updateIOSAppexInfoPlistInfo(I,_,m,S,i),await this.updateIOSIcons(t,_,d,m,g,i),await this.updateSplashScreen(t,_,m,i,c,f),await this.updateExtendedSdk(I,_,a,s,m,i),await this.updatePlugin(_,p,t,m,d,g,S,i),await this.updatePrivacyInfo(_,m,i);const x=await this.getEntitlements(I,_,m,i),{mobileapp_info:v={}}=I;let b;b=l.signType===miniapp_builder_1.miniappSinTypes.appleId.type?miniapp_builder_1.DEFAULT_BUNDLE_ID:v.ios_flag&&v.bundle_id||v.debug_ios_bundle_id;const P={bundleId:b,output:r,entitlements:x};if(m.buildCloud&&(m.buildCloud.certificate&&"string"==typeof m.buildCloud.certificate&&(P.certificate=m.buildCloud.certificate),m.buildCloud.profile&&"string"==typeof m.buildCloud.profile&&(P.profile=path_1.default.join(t,m.buildCloud.profile)),y&&m.buildCloud.tpnsProfile&&"string"==typeof m.buildCloud.tpnsProfile&&(P.tpnsProfile=path_1.default.join(t,m.buildCloud.tpnsProfile))),h.isPublish){const e=await(0,codesign_1.codesignAndExport)(t,_,d||"",P,i,y,!0===u);if(!0!==e.success)throw new Error("Build ipa failed:"+(e.errMsg||"codesignAndExport failed"))}return{projectPath:t,demoIpaPath:_,opts:P,iosMiniappJson:m,isPublish:g}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach(n=>{if("base"===n)return;let a="";Object.keys(t).forEach(e=>{var s,o,l,r;"UISplashScreenImageName"!==e?"UILaunchStoryboardName"!==e?(null===(o=null===(s=i[n])||void 0===s?void 0:s.ios)||void 0===o?void 0:o[t[e]])&&(a+=`${e} = "${null===(r=null===(l=i[n])||void 0===l?void 0:l.ios)||void 0===r?void 0:r[t[e]]}";\n`):a+="__UILaunchStoryboardName__\n":a+="__UISplashScreenImageName__\n"}),a&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,n+".lproj")),fs_extra_1.default.writeFileSync(path_1.default.join(e,n+".lproj/InfoPlist.strings"),a))})}getMaterialFilePath(e,i){if(!i)return"";let t=i;if(path_1.default.isAbsolute(i)||(t=path_1.default.join(e,i)),fs_extra_1.default.existsSync(t))return t;const n=(0,tools_1.generateMD5)(i),a=path_1.default.basename(i),s=path_1.default.join(e,exports.remoteBuildProjectMaterialAbsoluteCacheDir,`${n}_${a}`);return fs_extra_1.default.existsSync(s)?s:""}}exports.default=new buildCloudManager;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IOSUtils=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),env_1=require("../../../utils/env"),deviceUtils=tslib_1.__importStar(require("./device")),projectConfigUtils=tslib_1.__importStar(require("./projectconfig")),cp_1=require("../../../utils/cp"),miniapp_builder_1=require("../../../utils/miniapp-builder"),miniappJson_1=require("../../../utils/miniappJson"),singletontask_1=require("../../../utils/singletontask"),buildCloud_1=tslib_1.__importStar(require("./buildCloud")),tools_1=require("../../../utils/tools"),codesign_1=require("../../../utils/codesign"),ProjectMiniappJsonSplashScreenThemeKey="__splashscreenTheme",_iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}},_allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"],_getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),buildIOSPluginTask={};class IOSUtils{constructor(e,i={},t,n){this.root=e,this.userConfig=i,this.miniappDirPath=t,this.devtoolsVersion=n}getProjectConfig(){const e=projectConfigUtils.getProjectConfig(this.root,this.userConfig);if(!e)throw new Error("iOS project folder not found. Are you sure this is a miniapp project?");return e}getBundleId(e){return child_process.execFileSync("/usr/libexec/PlistBuddy",["-c","Print:CFBundleIdentifier",path_1.default.join(e,"Info.plist")],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim()}tryInstallPod(e,i){const t=this.getProjectConfig(),{sourceDir:n}=t,o={cwd:n,env:(0,env_1.getProcessEnv)()};i.progress("export LANG=en_US.UTF-8 && pod install"),child_process.execSync("export LANG=en_US.UTF-8 && pod install",o)}async runLocal(e,i){const t=this.getProjectConfig(),{sourceDir:n}=t;process.chdir(n),this.tryInstallPod(e,i);const o=path_1.default.basename(t.name,path_1.default.extname(t.name)),s=e.scheme||o;if(i.progress(`Found Xcode ${t.isWorkspace?"workspace":"project"} "${t.name}"`),e.device||e.udid){if(e.udid||e.device){const n=await deviceUtils.getDevices({recorder:i}),o=n.find(i=>i.udid===e.udid||i.name===e.device);if(!o)throw new Error(`Could not find a device with udid(${e.udid}) or device(${e.device}). ${deviceUtils.printFoundDevices(n)}`);if("simulator"===o.type)return void await this.runOnSimulatorLocal(t,s,e,i);await this.runOnDeviceLocal(t,s,o,i)}}else await this.runOnSimulatorLocal(t,s,e,i)}async runCloud(e,i){try{const{deviceType:t,udid:n,projectPath:o,demoIpaPath:s,sdkPath:a,bindingInfo:r,certificateInfo:c,arch:l="arm64",pluginDirList:d,miniappCacheDirPath:p,theme:u,i18nInfo:h}=e,f=buildCloud_1.default.generateTempDemoIpaPath(s),_="simulator"===t,m=(0,miniappJson_1.tryGetIOSMiniappJson)(o);let g=r;if(c.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=g;g=Object.assign(Object.assign({},g),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const b=await buildCloud_1.default.updateIOSInfoPlistInfo(o,g,f,m,i,h);await buildCloud_1.default.updateIOSAppConfigPlistInfo(o,g,f,m,a,_,i,u,h),await buildCloud_1.default.updateIOSAppexInfoPlistInfo(g,f,m,b,i),await buildCloud_1.default.updateIOSIcons(o,f,"",m,!1,i),await buildCloud_1.default.updateSplashScreen(o,f,m,i,u),await buildCloud_1.default.updateExtendedSdk(g,f,a,l,m,i),await buildCloud_1.default.updatePlugin(f,d,o,m,p,!1,b,i);const v=await buildCloud_1.default.getEntitlements(g,f,m,i);if("device"===t){const{mobileapp_info:e={}}=g,t=e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id;await(0,miniapp_builder_1.signAndInstallOrExport)(o,f,p,c,{bundleId:t,install:!0,deviceId:n,entitlements:v},{recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion})}else await this.runOnSimulatorCloud(f,{udid:n},i)}catch(e){throw new Error("Run the app failed:"+e.message)}}async buildLocal(e,i){const t=this.getProjectConfig();process.chdir(t.sourceDir);const n=path_1.default.basename(t.name,path_1.default.extname(t.name)),o=e.scheme||n;this.tryInstallPod(e,i),i.progress("start build ipa...");const s=await this.buildProjectArchive(t,{output:e.output,scheme:o},i),a=await this.exportArchive(t,s,e,i);return console.log("Successfully build ipa: "+a),a}async buildCloud(e,i){try{const{projectPath:t,certificateInfo:n,miniappCacheDirPath:o}=e,s=await buildCloud_1.default.buildCloud(e,i),{demoIpaPath:a,opts:r}=s,c={recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion};s.isPublish||await(0,miniapp_builder_1.signAndInstallOrExport)(t,a,o,n,r,c)}catch(e){throw new Error("Build ipa failed:"+e.message)}}async genProjectMaterialMap(e,i,t,n){var o,s;const a=buildCloud_1.remoteBuildProjectMaterialAbsoluteCacheDir,r=path_1.default.join(i,a),c=(0,miniappJson_1.tryGetIOSMiniappJson)(e);function l(e,i){fs_extra_1.default.ensureDirSync(path_1.default.dirname(i)),fs_extra_1.default.copyFileSync(e,i)}function d(t,n,o=!0){if(!n){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}if(path_1.default.isAbsolute(n)){const e=path_1.default.basename(n);if(!fs_extra_1.default.existsSync(n)){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}const i=(0,tools_1.generateMD5)(n);return l(n,path_1.default.join(r,`${i}_${e}`)),path_1.default.join(a,e)}const s=path_1.default.join(e,n),c=path_1.default.join(i,n);if(!fs_extra_1.default.existsSync(s)){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}return l(s,c),n}fs_extra_1.default.ensureDirSync(r);const{privacy:p={},icons:u={},splashscreen:h={},buildCloud:f={}}=c,_=d("project.miniapp.json","project.miniapp.json",!1),m=d("project.config.json","project.config.json",!1),g=(0,miniappJson_1.getMiniprogramRoot)(e),b=d("app.json",path_1.default.join(g,"app.json"),!1),{template:v,contentViewImage:y,cancelButtonImage:S,confirmButtonImage:w}=p,P=d("privacy template",v),I=d("privacy contentViewImage",y),x=d("privacy cancelButtonImage",S),j=d("privacy confirmButtonImage",w),E=[];for(const e in u)if(u[e]){const i=d("icons."+e,u[e],!1);i&&E.push(i)}const O=d("splashscreen.customImage",h.customImage),{p12:D,profile:C,tpnsProfile:A}=f,$=d("p12 Path",D,!1),T=d("profile Path",C,!1);let k=void 0;!0===(null===(o=null==c?void 0:c.tpush)||void 0===o?void 0:o.useExtendedLib_WeAppTPNS)&&(k=d("tpns profile Path",A,!0!==(null===(s=null==c?void 0:c.tpush)||void 0===s?void 0:s.useExtendedLib_WeAppTPNS)));const B="miniapp/ios/i18nInfo.json",U=path_1.default.join(e,B),F=d("i18n",B,!0);if(fs_extra_1.default.existsSync(U)){const i=function(e,i){function t(i,t,n){if(t[n]&&"object"==typeof t[n][i])for(const o in t[n][i])if("object"==typeof t[n][i]){const s=t[n][i][o];if("string"==typeof s&&s.length>0){fs_extra_1.default.existsSync(path_1.default.isAbsolute(s)?s:path_1.default.join(e,s))&&d(`i18nFiles.${n}.${o}`,s,!0)}}}try{const n=fs_extra_1.default.readJSONSync(path_1.default.join(e,i));for(const e in n)t("ios",n,e),t("android",n,e)}catch(e){return e.message}}(e,B);if(i)throw n.message("fail",i),new Error("copyi18NFiles error "+i)}const L=path_1.default.join(i,"project.miniapp.json");try{const e=fs_extra_1.default.readJsonSync(L);let{theme:i}=t;t.theme||(i="Dark"),e.__splashscreenTheme=i,fs_extra_1.default.writeJSONSync(L,e)}catch(e){throw new Error(`ReadWriteJsonFailed projectMiniappJsonCacheFilePath: ${L},error ${e.message}`)}const M=c["mini-plugin"];return M&&Array.isArray(M.ios)&&M.ios.forEach(e=>{!0===e.open&&e.resourcePath&&d(`mini-plugin ios ${e.pluginId}:${e.resourcePath}`,e.resourcePath)}),{projectMiniappJson:_,projectConfigJson:m,appJson:b,privacyJson:P,privacyContentViewImage:I,privacyCancelButtonImage:x,privacyConfirmButtonImage:j,icons:E,splashScreen:O,p12:$,profile:T,tpnsProfile:k,i18nJson:F}}async codesignIOSApp(e,i){const{projectPath:t,demoIpaPath:n,opts:o}=e,s=await(0,codesign_1.codesignAndExport)(t,n,e.miniappCacheDir||"",o,i,e.isUsingTpush,!1,!0);if(!0!==s.success)throw new Error("Build ipa failed:"+(s.errMsg||"codesignAndExport failed"))}async packIOSCloudBuildMaterial(e,i){i.progress("start uploadProjectAllMaterial");const{projectPath:t,matrialDistPath:n,theme:o}=e;await this.genProjectMaterialMap(t,n,e,i);i.progress("packIOSCloudBuildMaterial done")}launchSimulator(e,i){let t;try{t=JSON.parse(child_process.execFileSync("xcrun",["simctl","list","--json","devices"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}))}catch(e){throw new Error("Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues."+e.message)}const n=["iPhone 13","iPhone 12","iPhone 11"].reduce((e,i)=>e||deviceUtils.findMatchingSimulator(t,{device:i}),deviceUtils.findMatchingSimulator(t,e));if(!n)throw new Error("No simulator available with "+(e.device?`name "${e.device}"`:`udid "${e.udid}"`));const o=child_process.execFileSync("xcode-select",["-p"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim();if(child_process.execFileSync("open",[o+"/Applications/Simulator.app","--args","-CurrentDeviceUDID",n.udid],{env:(0,env_1.getProcessEnv)()}),!n.booted){const e=deviceUtils.formattedDeviceName(n);i.progress("Launching "+e),child_process.spawnSync("xcrun",["simctl","boot",n.udid],{env:(0,env_1.getProcessEnv)()})}return n}async runOnSimulatorCloud(e,i,t){const{udid:n}=i,o=this.launchSimulator({udid:n},t);await this.installAppOnSimulator(o,e,t),await this.launchAppOnSimulator(o,e,t)}async runOnSimulatorLocal(e,i,t,n){const o=this.launchSimulator(t,n),{appPath:s}=await this.buildProjectApp(e,{udid:o.udid,scheme:i},n);await this.installAppOnSimulator(o,s,n),await this.launchAppOnSimulator(o,s,n)}async runOnDeviceLocal(e,i,t,n){const{appPath:o}=await this.buildProjectApp(e,{udid:t.udid,scheme:i},n);if("catalyst"===t.type){child_process.spawn(`${o}/${i}`,[],{detached:!0,stdio:"ignore",env:(0,env_1.getProcessEnv)()}).unref()}else{const e=["--bundle",o,"--id",t.udid,"--justlaunch"];n.progress("Installing and launching your app on "+t.name);const i=path_1.default.join(__dirname,"../../../vendor/ios-deploy/ios-deploy");await(0,cp_1.spawnSync)(i,e,{},n)}return n.progress("Install successfully the app to the device.")}buildProjectApp(e,i,t){return new Promise((n,o)=>{const{scheme:s,udid:a}=i,r=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",s];let c;a&&r.push("-destination","id="+a),t.progress(`Building (using "xcodebuild ${r.join(" ")}")`),this.xcbeautifyAvailable()?c=child_process.spawn("xcbeautify",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}):this.xcprettyAvailable()&&(c=child_process.spawn("xcpretty",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}));const l=child_process.spawn("xcodebuild",r,{env:(0,env_1.getProcessEnv)()});let d="",p="";l.stdout.on("data",e=>{const i=e.toString();t.progress(i),d+=i,c&&c.stdin.write(e)}),l.stderr.on("data",e=>{const i=e.toString();p+=i,t.progress(i)}),l.on("close",i=>{if(c&&c.stdin.end(),0!==i)return void o(new Error(` Failed to build iOS project.\n We ran "xcodebuild" command but it exited with error code ${i}. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n ${c?void 0:`${d}\n${p}`}\n `));let a;try{a=this.getBuildInfo(e,d,s)}catch(e){o(e)}t.progress("Successfully built the app"),n(a)})})}async installAppOnSimulator(e,i,t){const n=["simctl","install",e.udid,i];await(0,cp_1.spawnSync)("xcrun",n,{},t)}async launchAppOnSimulator(e,i,t){const n=this.getBundleId(i),o=["simctl","launch",e.udid,n];await(0,cp_1.spawnSync)("xcrun",o,{},t),t.progress("Successfully launched the app on the simulator")}async buildProjectArchive(e,i,t){const{output:n,scheme:o,udid:s}=i,a=path_1.default.join(n,"./app"),{sourceDir:r}=e;fs_extra_1.default.ensureDirSync(path_1.default.dirname(a));const c=["archive",e.isWorkspace?"-workspace":"-project",e.name,"-scheme",o,"-archivePath",a];s&&c.push("-destination","id="+s);try{if(await(0,cp_1.spawnSync)("xcodebuild",c,{cwd:r},t),!fs_extra_1.default.existsSync(a+".xcarchive"))throw new Error(`Failed to build iOS project.\n ${a+".xcarchive"} does not found\n `);return t.progress(`Successfully archive the app: ${a}.xcarchive`),a+".xcarchive"}catch(i){throw new Error(`Failed to build iOS project. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}}async exportArchive(e,i,t,n){const o=path_1.default.join(t.output,"ipa");fs_extra_1.default.ensureDirSync(o),fs_extra_1.default.emptyDirSync(o);const{exportOptionPlistPath:s}=t;if(!s)throw new Error("build ios ipa require exportOptionPlistPath in project.miniapp.json");let a="";a=path_1.default.isAbsolute(s)?s:path_1.default.join(t.projectPath,s);const r=["-exportArchive","-archivePath",i,"-exportOptionsPlist",a,"-exportPath",o];try{await(0,cp_1.spawnSync)("xcodebuild",r,{cwd:e.sourceDir},n)}catch(i){throw new Error(`To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}return fs_extra_1.default.removeSync(i),o}getTargetPaths(e){const i=JSON.parse(e);for(const e in i){if("app"===i[e].buildSettings.WRAPPER_EXTENSION)return{targetBuildDir:i[e].buildSettings.TARGET_BUILD_DIR,executableFolderPath:i[e].buildSettings.EXECUTABLE_FOLDER_PATH}}return{}}getBuildInfo(e,i,t){const n=this.getPlatformName(i),o=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",t,"-sdk",n,"-showBuildSettings","-json"].join(" "),s=child_process.execSync("xcodebuild "+o,{encoding:"utf8",cwd:e.sourceDir,env:(0,env_1.getProcessEnv)()}),a=this.getBuildProductDir(i),{executableFolderPath:r}=this.getTargetPaths(s);if(!r)throw new Error("Failed to get the app name.");return{sdk:n,appPath:`${a}/${r}`}}getPlatformName(e){const i=/export PLATFORM_NAME\\?="?(\w+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find PLATFORM_NAME in xcodebuild output.");return i[1]}getBuildProductDir(e){const i=/export BUILT_PRODUCTS_DIR\\?="?(.+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find BUILT_PRODUCTS_DIR in xcodebuild output.");return i[1]}xcbeautifyAvailable(){try{child_process.execSync("xcbeautify --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}xcprettyAvailable(){try{child_process.execSync("xcpretty --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}async buildPlugin(e,i){const{pluginId:t,projectPath:n,buildShellPath:o}=e;i.progress("start build native plugin...");try{const e=[n,t];fs_extra_1.default.chmodSync(o,"777"),buildIOSPluginTask[t]?(i.message("fail","存在未结束的插件构建任务,需等待构建结束..."),await buildIOSPluginTask[t].getResult(!0)):(buildIOSPluginTask[t]=new singletontask_1.SingletonTask(cp_1.spawnSyncExecShell.bind(null,o,e,{},i)),await buildIOSPluginTask[t].getResult(!0),buildIOSPluginTask[t]=void 0)}catch(e){throw buildIOSPluginTask[t]=void 0,new Error("build plugin failed: "+e)}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach(n=>{if("base"===n)return;let o="";Object.keys(t).forEach(e=>{var s,a,r,c;(null===(a=null===(s=i[n])||void 0===s?void 0:s.ios)||void 0===a?void 0:a[t[e]])&&(o+=`${e} = "${null===(c=null===(r=i[n])||void 0===r?void 0:r.ios)||void 0===c?void 0:c[t[e]]}";\n`)}),o&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,n+".lproj")),fs_extra_1.default.writeFileSync(path_1.default.join(e,n+".lproj/InfoPlist.strings"),o))})}}exports.IOSUtils=IOSUtils;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IOSUtils=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),env_1=require("../../../utils/env"),deviceUtils=tslib_1.__importStar(require("./device")),projectConfigUtils=tslib_1.__importStar(require("./projectconfig")),cp_1=require("../../../utils/cp"),miniapp_builder_1=require("../../../utils/miniapp-builder"),miniappJson_1=require("../../../utils/miniappJson"),singletontask_1=require("../../../utils/singletontask"),buildCloud_1=tslib_1.__importStar(require("./buildCloud")),tools_1=require("../../../utils/tools"),codesign_1=require("../../../utils/codesign"),ProjectMiniappJsonSplashScreenThemeKey="__splashscreenTheme",_iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}},_allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"],_getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),buildIOSPluginTask={};class IOSUtils{constructor(e,i={},t,n){this.root=e,this.userConfig=i,this.miniappDirPath=t,this.devtoolsVersion=n}getProjectConfig(){const e=projectConfigUtils.getProjectConfig(this.root,this.userConfig);if(!e)throw new Error("iOS project folder not found. Are you sure this is a miniapp project?");return e}getBundleId(e){return child_process.execFileSync("/usr/libexec/PlistBuddy",["-c","Print:CFBundleIdentifier",path_1.default.join(e,"Info.plist")],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim()}tryInstallPod(e,i){const t=this.getProjectConfig(),{sourceDir:n}=t,o={cwd:n,env:(0,env_1.getProcessEnv)()};i.progress("export LANG=en_US.UTF-8 && pod install"),child_process.execSync("export LANG=en_US.UTF-8 && pod install",o)}async runLocal(e,i){const t=this.getProjectConfig(),{sourceDir:n}=t;process.chdir(n),this.tryInstallPod(e,i);const o=path_1.default.basename(t.name,path_1.default.extname(t.name)),s=e.scheme||o;if(i.progress(`Found Xcode ${t.isWorkspace?"workspace":"project"} "${t.name}"`),e.device||e.udid){if(e.udid||e.device){const n=await deviceUtils.getDevices({recorder:i}),o=n.find(i=>i.udid===e.udid||i.name===e.device);if(!o)throw new Error(`Could not find a device with udid(${e.udid}) or device(${e.device}). ${deviceUtils.printFoundDevices(n)}`);if("simulator"===o.type)return void await this.runOnSimulatorLocal(t,s,e,i);await this.runOnDeviceLocal(t,s,o,i)}}else await this.runOnSimulatorLocal(t,s,e,i)}async runCloud(e,i){try{const{deviceType:t,udid:n,projectPath:o,demoIpaPath:s,sdkPath:a,bindingInfo:r,certificateInfo:c,arch:l="arm64",pluginDirList:d,miniappCacheDirPath:p,theme:u,i18nInfo:h}=e,f=buildCloud_1.default.generateTempDemoIpaPath(s),_="simulator"===t,m=(0,miniappJson_1.tryGetIOSMiniappJson)(o);let g=r;if(c.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=g;g=Object.assign(Object.assign({},g),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const b=await buildCloud_1.default.updateIOSInfoPlistInfo(o,g,f,m,i,h);await buildCloud_1.default.updateIOSAppConfigPlistInfo(o,g,f,m,a,_,i,u,h),await buildCloud_1.default.updateIOSAppexInfoPlistInfo(g,f,m,b,i),await buildCloud_1.default.updateIOSIcons(o,f,"",m,!1,i),await buildCloud_1.default.updateSplashScreen(o,f,m,i,u,h),await buildCloud_1.default.updateExtendedSdk(g,f,a,l,m,i),await buildCloud_1.default.updatePlugin(f,d,o,m,p,!1,b,i);const v=await buildCloud_1.default.getEntitlements(g,f,m,i);if("device"===t){const{mobileapp_info:e={}}=g,t=e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id;await(0,miniapp_builder_1.signAndInstallOrExport)(o,f,p,c,{bundleId:t,install:!0,deviceId:n,entitlements:v},{recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion})}else await this.runOnSimulatorCloud(f,{udid:n},i)}catch(e){throw new Error("Run the app failed:"+e.message)}}async buildLocal(e,i){const t=this.getProjectConfig();process.chdir(t.sourceDir);const n=path_1.default.basename(t.name,path_1.default.extname(t.name)),o=e.scheme||n;this.tryInstallPod(e,i),i.progress("start build ipa...");const s=await this.buildProjectArchive(t,{output:e.output,scheme:o},i),a=await this.exportArchive(t,s,e,i);return console.log("Successfully build ipa: "+a),a}async buildCloud(e,i){try{const{projectPath:t,certificateInfo:n,miniappCacheDirPath:o}=e,s=await buildCloud_1.default.buildCloud(e,i),{demoIpaPath:a,opts:r}=s,c={recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion};s.isPublish||await(0,miniapp_builder_1.signAndInstallOrExport)(t,a,o,n,r,c)}catch(e){throw new Error("Build ipa failed:"+e.message)}}async genProjectMaterialMap(e,i,t,n){var o,s;const a=buildCloud_1.remoteBuildProjectMaterialAbsoluteCacheDir,r=path_1.default.join(i,a),c=(0,miniappJson_1.tryGetIOSMiniappJson)(e);function l(e,i){fs_extra_1.default.ensureDirSync(path_1.default.dirname(i)),fs_extra_1.default.copyFileSync(e,i)}function d(t,n,o=!0){if(!n){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}if(path_1.default.isAbsolute(n)){const e=path_1.default.basename(n);if(!fs_extra_1.default.existsSync(n)){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}const i=(0,tools_1.generateMD5)(n);return l(n,path_1.default.join(r,`${i}_${e}`)),path_1.default.join(a,e)}const s=path_1.default.join(e,n),c=path_1.default.join(i,n);if(!fs_extra_1.default.existsSync(s)){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}return l(s,c),n}fs_extra_1.default.ensureDirSync(r);const{privacy:p={},icons:u={},splashscreen:h={},buildCloud:f={}}=c,_=d("project.miniapp.json","project.miniapp.json",!1),m=d("project.config.json","project.config.json",!1),g=(0,miniappJson_1.getMiniprogramRoot)(e),b=d("app.json",path_1.default.join(g,"app.json"),!1),{template:v,contentViewImage:y,cancelButtonImage:S,confirmButtonImage:w}=p,P=d("privacy template",v),I=d("privacy contentViewImage",y),x=d("privacy cancelButtonImage",S),j=d("privacy confirmButtonImage",w),E=[];for(const e in u)if(u[e]){const i=d("icons."+e,u[e],!1);i&&E.push(i)}const O=d("splashscreen.customImage",h.customImage),{p12:D,profile:C,tpnsProfile:A}=f,$=d("p12 Path",D,!1),T=d("profile Path",C,!1);let k=void 0;!0===(null===(o=null==c?void 0:c.tpush)||void 0===o?void 0:o.useExtendedLib_WeAppTPNS)&&(k=d("tpns profile Path",A,!0!==(null===(s=null==c?void 0:c.tpush)||void 0===s?void 0:s.useExtendedLib_WeAppTPNS)));const B="miniapp/ios/i18nInfo.json",U=path_1.default.join(e,B),F=d("i18n",B,!0);if(fs_extra_1.default.existsSync(U)){const i=function(e,i){function t(i,t,n){if(t[n]&&"object"==typeof t[n][i])for(const o in t[n][i])if("object"==typeof t[n][i]){const s=t[n][i][o];if("string"==typeof s&&s.length>0){fs_extra_1.default.existsSync(path_1.default.isAbsolute(s)?s:path_1.default.join(e,s))&&d(`i18nFiles.${n}.${o}`,s,!0)}}}try{const n=fs_extra_1.default.readJSONSync(path_1.default.join(e,i));for(const e in n)t("ios",n,e),t("android",n,e)}catch(e){return e.message}}(e,B);if(i)throw n.message("fail",i),new Error("copyi18NFiles error "+i)}const L=path_1.default.join(i,"project.miniapp.json");try{const e=fs_extra_1.default.readJsonSync(L);let{theme:i}=t;t.theme||(i="Dark"),e.__splashscreenTheme=i,fs_extra_1.default.writeJSONSync(L,e)}catch(e){throw new Error(`ReadWriteJsonFailed projectMiniappJsonCacheFilePath: ${L},error ${e.message}`)}const M=c["mini-plugin"];return M&&Array.isArray(M.ios)&&M.ios.forEach(e=>{!0===e.open&&e.resourcePath&&d(`mini-plugin ios ${e.pluginId}:${e.resourcePath}`,e.resourcePath)}),{projectMiniappJson:_,projectConfigJson:m,appJson:b,privacyJson:P,privacyContentViewImage:I,privacyCancelButtonImage:x,privacyConfirmButtonImage:j,icons:E,splashScreen:O,p12:$,profile:T,tpnsProfile:k,i18nJson:F}}async codesignIOSApp(e,i){const{projectPath:t,demoIpaPath:n,opts:o}=e,s=await(0,codesign_1.codesignAndExport)(t,n,e.miniappCacheDir||"",o,i,e.isUsingTpush,!1,!0);if(!0!==s.success)throw new Error("Build ipa failed:"+(s.errMsg||"codesignAndExport failed"))}async packIOSCloudBuildMaterial(e,i){i.progress("start uploadProjectAllMaterial");const{projectPath:t,matrialDistPath:n,theme:o}=e;await this.genProjectMaterialMap(t,n,e,i);i.progress("packIOSCloudBuildMaterial done")}launchSimulator(e,i){let t;try{t=JSON.parse(child_process.execFileSync("xcrun",["simctl","list","--json","devices"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}))}catch(e){throw new Error("Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues."+e.message)}const n=["iPhone 13","iPhone 12","iPhone 11"].reduce((e,i)=>e||deviceUtils.findMatchingSimulator(t,{device:i}),deviceUtils.findMatchingSimulator(t,e));if(!n)throw new Error("No simulator available with "+(e.device?`name "${e.device}"`:`udid "${e.udid}"`));const o=child_process.execFileSync("xcode-select",["-p"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim();if(child_process.execFileSync("open",[o+"/Applications/Simulator.app","--args","-CurrentDeviceUDID",n.udid],{env:(0,env_1.getProcessEnv)()}),!n.booted){const e=deviceUtils.formattedDeviceName(n);i.progress("Launching "+e),child_process.spawnSync("xcrun",["simctl","boot",n.udid],{env:(0,env_1.getProcessEnv)()})}return n}async runOnSimulatorCloud(e,i,t){const{udid:n}=i,o=this.launchSimulator({udid:n},t);await this.installAppOnSimulator(o,e,t),await this.launchAppOnSimulator(o,e,t)}async runOnSimulatorLocal(e,i,t,n){const o=this.launchSimulator(t,n),{appPath:s}=await this.buildProjectApp(e,{udid:o.udid,scheme:i},n);await this.installAppOnSimulator(o,s,n),await this.launchAppOnSimulator(o,s,n)}async runOnDeviceLocal(e,i,t,n){const{appPath:o}=await this.buildProjectApp(e,{udid:t.udid,scheme:i},n);if("catalyst"===t.type){child_process.spawn(`${o}/${i}`,[],{detached:!0,stdio:"ignore",env:(0,env_1.getProcessEnv)()}).unref()}else{const e=["--bundle",o,"--id",t.udid,"--justlaunch"];n.progress("Installing and launching your app on "+t.name);const i=path_1.default.join(__dirname,"../../../vendor/ios-deploy/ios-deploy");await(0,cp_1.spawnSync)(i,e,{},n)}return n.progress("Install successfully the app to the device.")}buildProjectApp(e,i,t){return new Promise((n,o)=>{const{scheme:s,udid:a}=i,r=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",s];let c;a&&r.push("-destination","id="+a),t.progress(`Building (using "xcodebuild ${r.join(" ")}")`),this.xcbeautifyAvailable()?c=child_process.spawn("xcbeautify",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}):this.xcprettyAvailable()&&(c=child_process.spawn("xcpretty",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}));const l=child_process.spawn("xcodebuild",r,{env:(0,env_1.getProcessEnv)()});let d="",p="";l.stdout.on("data",e=>{const i=e.toString();t.progress(i),d+=i,c&&c.stdin.write(e)}),l.stderr.on("data",e=>{const i=e.toString();p+=i,t.progress(i)}),l.on("close",i=>{if(c&&c.stdin.end(),0!==i)return void o(new Error(` Failed to build iOS project.\n We ran "xcodebuild" command but it exited with error code ${i}. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n ${c?void 0:`${d}\n${p}`}\n `));let a;try{a=this.getBuildInfo(e,d,s)}catch(e){o(e)}t.progress("Successfully built the app"),n(a)})})}async installAppOnSimulator(e,i,t){const n=["simctl","install",e.udid,i];await(0,cp_1.spawnSync)("xcrun",n,{},t)}async launchAppOnSimulator(e,i,t){const n=this.getBundleId(i),o=["simctl","launch",e.udid,n];await(0,cp_1.spawnSync)("xcrun",o,{},t),t.progress("Successfully launched the app on the simulator")}async buildProjectArchive(e,i,t){const{output:n,scheme:o,udid:s}=i,a=path_1.default.join(n,"./app"),{sourceDir:r}=e;fs_extra_1.default.ensureDirSync(path_1.default.dirname(a));const c=["archive",e.isWorkspace?"-workspace":"-project",e.name,"-scheme",o,"-archivePath",a];s&&c.push("-destination","id="+s);try{if(await(0,cp_1.spawnSync)("xcodebuild",c,{cwd:r},t),!fs_extra_1.default.existsSync(a+".xcarchive"))throw new Error(`Failed to build iOS project.\n ${a+".xcarchive"} does not found\n `);return t.progress(`Successfully archive the app: ${a}.xcarchive`),a+".xcarchive"}catch(i){throw new Error(`Failed to build iOS project. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}}async exportArchive(e,i,t,n){const o=path_1.default.join(t.output,"ipa");fs_extra_1.default.ensureDirSync(o),fs_extra_1.default.emptyDirSync(o);const{exportOptionPlistPath:s}=t;if(!s)throw new Error("build ios ipa require exportOptionPlistPath in project.miniapp.json");let a="";a=path_1.default.isAbsolute(s)?s:path_1.default.join(t.projectPath,s);const r=["-exportArchive","-archivePath",i,"-exportOptionsPlist",a,"-exportPath",o];try{await(0,cp_1.spawnSync)("xcodebuild",r,{cwd:e.sourceDir},n)}catch(i){throw new Error(`To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}return fs_extra_1.default.removeSync(i),o}getTargetPaths(e){const i=JSON.parse(e);for(const e in i){if("app"===i[e].buildSettings.WRAPPER_EXTENSION)return{targetBuildDir:i[e].buildSettings.TARGET_BUILD_DIR,executableFolderPath:i[e].buildSettings.EXECUTABLE_FOLDER_PATH}}return{}}getBuildInfo(e,i,t){const n=this.getPlatformName(i),o=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",t,"-sdk",n,"-showBuildSettings","-json"].join(" "),s=child_process.execSync("xcodebuild "+o,{encoding:"utf8",cwd:e.sourceDir,env:(0,env_1.getProcessEnv)()}),a=this.getBuildProductDir(i),{executableFolderPath:r}=this.getTargetPaths(s);if(!r)throw new Error("Failed to get the app name.");return{sdk:n,appPath:`${a}/${r}`}}getPlatformName(e){const i=/export PLATFORM_NAME\\?="?(\w+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find PLATFORM_NAME in xcodebuild output.");return i[1]}getBuildProductDir(e){const i=/export BUILT_PRODUCTS_DIR\\?="?(.+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find BUILT_PRODUCTS_DIR in xcodebuild output.");return i[1]}xcbeautifyAvailable(){try{child_process.execSync("xcbeautify --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}xcprettyAvailable(){try{child_process.execSync("xcpretty --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}async buildPlugin(e,i){const{pluginId:t,projectPath:n,buildShellPath:o}=e;i.progress("start build native plugin...");try{const e=[n,t];fs_extra_1.default.chmodSync(o,"777"),buildIOSPluginTask[t]?(i.message("fail","存在未结束的插件构建任务,需等待构建结束..."),await buildIOSPluginTask[t].getResult(!0)):(buildIOSPluginTask[t]=new singletontask_1.SingletonTask(cp_1.spawnSyncExecShell.bind(null,o,e,{},i)),await buildIOSPluginTask[t].getResult(!0),buildIOSPluginTask[t]=void 0)}catch(e){throw buildIOSPluginTask[t]=void 0,new Error("build plugin failed: "+e)}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach(n=>{if("base"===n)return;let o="";Object.keys(t).forEach(e=>{var s,a,r,c;(null===(a=null===(s=i[n])||void 0===s?void 0:s.ios)||void 0===a?void 0:a[t[e]])&&(o+=`${e} = "${null===(c=null===(r=i[n])||void 0===r?void 0:r.ios)||void 0===c?void 0:c[t[e]]}";\n`)}),o&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,n+".lproj")),fs_extra_1.default.writeFileSync(path_1.default.join(e,n+".lproj/InfoPlist.strings"),o))})}}exports.IOSUtils=IOSUtils;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),stream_1=require("stream"),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../utils/tools"),waitable_1=tslib_1.__importDefault(require("../utils/waitable"));class BaseProject extends waitable_1.default{constructor(){super(...arguments),this._projectPath="",this._projectArchitecture="miniProgram",this._type="miniProgram",this._privateKey="",this.ignores=[],this.setting={},this._dirSet=new Set,this._fileSet=new Set,this.event=new stream_1.EventEmitter}get projectPath(){return this._projectPath}get projectArchitecture(){return this._projectArchitecture}get srcPath(){let t="";return"miniProgramPlugin"!==this._type&&"miniGamePlugin"!==this._type||(t=(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.pluginRoot||""))),t=(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.miniprogramRoot||"")),(this._projectPath.startsWith("//")||this._projectPath.startsWith("\\\\"))&&(t.startsWith("//")||(t="/"+t)),t}get pluginSrcPath(){return(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.pluginRoot||""))}get type(){return this._type}set type(t){this._type=t}get appid(){return this._appid}set appid(t){this._appid=t}get privateKey(){return this._privateKey}set privateKey(t){this._privateKey=t}get miniprogramRoot(){return this._miniprogramRoot||""}set miniprogramRoot(t){this._miniprogramRoot=t}get pluginRoot(){return this._pluginRoot}set pluginRoot(t){this._pluginRoot=t}get nameMappingFromDevtools(){return this._nameMappingFromDevtools}set nameMappingFromDevtools(t){this._nameMappingFromDevtools=t}async attr(){return this._attr}async ready(){await this.wait()}getProjectType(t,e){let i="";return i=(null==t?void 0:t.gameApp)?"miniGamePlugin"===e?"miniGamePlugin":"miniGame":e,i}getProjectConfig(){let t={};const e=path_1.default.join(this.projectPath,"project.config.json");if(fs_extra_1.default.existsSync(e))try{t=fs_extra_1.default.readJsonSync(e)}catch(t){throw new Error("project.config.json not exist")}return t}async serialize(){const{files:t,dirs:e}=this.getFilesAndDirs();return{projectPath:this.projectPath,appid:this.appid,attr:await this.attr(),type:this.type,projectArchitecture:this.projectArchitecture,miniprogramRoot:this.miniprogramRoot,pluginRoot:this.pluginRoot,files:t,dirs:e,setting:this.setting}}updateFiles(){this.updateFileAndDirs(...arguments)}updateOptions(t){this._appid=t.appid,this._attr=t.attr,this._type=this.getProjectType(t.attr,t.compileType),this._miniprogramRoot=t.miniprogramRoot,this._pluginRoot=t.pluginRoot,this._projectArchitecture=t.projectArchitecture,this.event.emit("optionsChange",t)}cacheDirName(t,e){t.has(e)||(t.add(e),this.cacheDirName(t,path_1.default.posix.dirname(e)))}deleteDirOrFileOfSet(t,e,i){if(t.has(i)){t.delete(i);const r=i+"/",s=Array.from(t);for(const e of s)e.startsWith(r)&&t.delete(e);const a=Array.from(e);for(const t of a)t.startsWith(r)&&e.delete(t)}e.has(i)&&e.delete(i)}getTargetPath(t="",e=""){return(0,tools_1.normalizePath)(path_1.default.posix.join(t,e)).replace(/\/$/,"").replace(/^\//,"")}getFilesAndDirs(){return{files:Array.from(this._fileSet),dirs:Array.from(this._dirSet)}}exists(t="",e=""){const i=this.getTargetPath(t,e);if(this._fileSet.has(i)||this._dirSet.has(i))return!0;const r=(0,tools_1.normalizePath)(path_1.default.posix.join(this.projectPath,i));return fs_extra_1.default.existsSync(r)}stat(t="",e=""){const i=this.getTargetPath(t,e),r=path_1.default.join(this.projectPath,i);let s={};if(this._fileSet.has(i)){return{isFile:!0,isDirectory:!1,size:this.getFileSize(t,e),mtimeMs:s.mtimeMs||""}}if(this._dirSet.has(i))return{isFile:!1,isDirectory:!0,size:0,mtimeMs:s.mtimeMs};fs_extra_1.default.existsSync(r)&&(s=fs_extra_1.default.statSync(r))}getAllFileInfo(t=""){const e=this.getFileList(t),i={};return e.forEach(t=>{i[t]=this.stat("",t)||{}}),i}getFileList(t="",e=""){return Array.from(this._fileSet).filter(i=>(!e||path_1.default.posix.extname(i)===e)&&!(t&&!i.startsWith(t)))}getSrcFile(t,e){t=t||"";const i=this.getTargetPath(t,e),r=(0,tools_1.normalizePath)(path_1.default.posix.join(this.projectPath,i));return fs_extra_1.default.readFileSync(r,null)}getFile(t,e){return this.getSrcFile(t,e)}getJson(t="",e=""){const i=this.getFile(t,e).toString("utf-8");try{return JSON.parse(i)}catch(i){throw new Error("JSON parse failed: "+this.getTargetPath(t,e))}}getFileSize(t="",e=""){const i=this.getFile(t,e);return i?i.byteLength:0}getExtAppid(){throw new Error("Method not implemented.")}async onFileChange(t,e){e=(0,tools_1.normalizePath)(e).replace(/\/$/,"").replace(/^\//,""),"add"===t&&(this.cacheDirName(this._dirSet,path_1.default.posix.dirname(e)),this._fileSet.add(e)),"addDir"===t&&this.cacheDirName(this._dirSet,e),"unlink"===t&&this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),"unlinkDir"===t&&this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),"change"===t&&this._fileSet.has(e),this.event.emit("fileChange",t,e)}clearCache(){}}exports.BaseProject=BaseProject;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),stream_1=require("stream"),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../utils/tools"),waitable_1=tslib_1.__importDefault(require("../utils/waitable"));class BaseProject extends waitable_1.default{constructor(){super(...arguments),this._projectPath="",this._projectArchitecture="miniProgram",this._type="miniProgram",this._privateKey="",this.ignores=[],this.setting={},this._dirSet=new Set,this._fileSet=new Set,this.event=new stream_1.EventEmitter}get projectPath(){return this._projectPath}get projectArchitecture(){return this._projectArchitecture}get srcPath(){let t="";return"miniProgramPlugin"!==this._type&&"miniGamePlugin"!==this._type||(t=(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.pluginRoot||""))),t=(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.miniprogramRoot||"")),(this._projectPath.startsWith("//")||this._projectPath.startsWith("\\\\"))&&(t.startsWith("//")||(t="/"+t)),t}get pluginSrcPath(){return(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.pluginRoot||""))}get type(){return this._type}set type(t){this._type=t}get appid(){return this._appid}set appid(t){this._appid=t}get privateKey(){return this._privateKey}set privateKey(t){this._privateKey=t}get miniprogramRoot(){return this._miniprogramRoot||""}set miniprogramRoot(t){this._miniprogramRoot=t}get pluginRoot(){return this._pluginRoot}set pluginRoot(t){this._pluginRoot=t}get nameMappingFromDevtools(){return this._nameMappingFromDevtools}set nameMappingFromDevtools(t){this._nameMappingFromDevtools=t}async attr(){return this._attr}async ready(){await this.wait()}getProjectType(t,e){let i="";return i=(null==t?void 0:t.gameApp)?"miniGamePlugin"===e?"miniGamePlugin":"miniGame":e,i}getProjectConfig(){let t={};const e=path_1.default.join(this.projectPath,"project.config.json");if(fs_extra_1.default.existsSync(e))try{t=fs_extra_1.default.readJsonSync(e)}catch(t){throw new Error("project.config.json not exist")}return t}async serialize(){const{files:t,dirs:e}=this.getFilesAndDirs();return{projectPath:this.projectPath,appid:this.appid,attr:await this.attr(),type:this.type,projectArchitecture:this.projectArchitecture,miniprogramRoot:this.miniprogramRoot,pluginRoot:this.pluginRoot,files:t,dirs:e,setting:this.setting}}updateFiles(){this.updateFileAndDirs(...arguments)}updateOptions(t){this._appid=t.appid,this._attr=t.attr,this._type=this.getProjectType(t.attr,t.compileType),this._miniprogramRoot=t.miniprogramRoot,this._pluginRoot=t.pluginRoot,this._projectArchitecture=t.projectArchitecture,this.event.emit("optionsChange",t)}cacheDirName(t,e){t.has(e)||(t.add(e),this.cacheDirName(t,path_1.default.posix.dirname(e)))}deleteDirOrFileOfSet(t,e,i){if(t.has(i)){t.delete(i);const r=i+"/",s=Array.from(t);for(const e of s)e.startsWith(r)&&t.delete(e);const a=Array.from(e);for(const t of a)t.startsWith(r)&&e.delete(t)}e.has(i)&&e.delete(i)}getTargetPath(t="",e=""){return(0,tools_1.normalizePath)(path_1.default.posix.join(t,e)).replace(/\/$/,"").replace(/^\//,"")}getFilesAndDirs(){return{files:Array.from(this._fileSet),dirs:Array.from(this._dirSet)}}exists(t="",e=""){const i=this.getTargetPath(t,e);if(this._fileSet.has(i)||this._dirSet.has(i))return!0;const r=(0,tools_1.normalizePath)(path_1.default.posix.join(this.projectPath,i));return fs_extra_1.default.existsSync(r)}stat(t="",e=""){const i=this.getTargetPath(t,e),r=path_1.default.join(this.projectPath,i);let s={};if(fs_extra_1.default.existsSync(r)&&(s=fs_extra_1.default.statSync(r)),this._fileSet.has(i)){return{isFile:!0,isDirectory:!1,size:this.getFileSize(t,e),mtimeMs:s.mtimeMs||""}}if(this._dirSet.has(i))return{isFile:!1,isDirectory:!0,size:0,mtimeMs:s.mtimeMs}}getAllFileInfo(t=""){const e=this.getFileList(t),i={};return e.forEach(t=>{i[t]=this.stat("",t)||{}}),i}getFileList(t="",e=""){return Array.from(this._fileSet).filter(i=>(!e||path_1.default.posix.extname(i)===e)&&!(t&&!i.startsWith(t)))}getSrcFile(t,e){t=t||"";const i=this.getTargetPath(t,e),r=(0,tools_1.normalizePath)(path_1.default.posix.join(this.projectPath,i));return fs_extra_1.default.readFileSync(r,null)}getFile(t,e){return this.getSrcFile(t,e)}getJson(t="",e=""){const i=this.getFile(t,e).toString("utf-8");try{return JSON.parse(i)}catch(i){throw new Error("JSON parse failed: "+this.getTargetPath(t,e))}}getFileSize(t="",e=""){const i=this.getFile(t,e);return i?i.byteLength:0}getExtAppid(){throw new Error("Method not implemented.")}async onFileChange(t,e){e=(0,tools_1.normalizePath)(e).replace(/\/$/,"").replace(/^\//,""),"add"===t&&(this.cacheDirName(this._dirSet,path_1.default.posix.dirname(e)),this._fileSet.add(e)),"addDir"===t&&this.cacheDirName(this._dirSet,e),"unlink"===t&&this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),"unlinkDir"===t&&this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),"change"===t&&this._fileSet.has(e),this.event.emit("fileChange",t,e)}clearCache(){}}exports.BaseProject=BaseProject;
@@ -2076,6 +2076,9 @@ module.exports = {
2076
2076
  "name": {
2077
2077
  "type": "string"
2078
2078
  },
2079
+ "entry": {
2080
+ "type": "string"
2081
+ },
2079
2082
  "root": {
2080
2083
  "type": "string"
2081
2084
  },
@@ -2217,5 +2220,5 @@ module.exports = {
2217
2220
  }
2218
2221
  },
2219
2222
  "$schema": "http://json-schema.org/draft-07/schema#",
2220
- "$version": 1715672764344
2223
+ "$version": 1718940707580
2221
2224
  }
@@ -952,6 +952,9 @@ module.exports = {
952
952
  "name": {
953
953
  "type": "string"
954
954
  },
955
+ "entry": {
956
+ "type": "string"
957
+ },
955
958
  "root": {
956
959
  "type": "string"
957
960
  },
@@ -1084,5 +1087,5 @@ module.exports = {
1084
1087
  }
1085
1088
  },
1086
1089
  "$schema": "http://json-schema.org/draft-07/schema#",
1087
- "$version": 1710507688689
1090
+ "$version": 1675931606631
1088
1091
  }
@@ -207,5 +207,5 @@ module.exports = {
207
207
  }
208
208
  },
209
209
  "$schema": "http://json-schema.org/draft-07/schema#",
210
- "$version": 1710507688689
210
+ "$version": 1701660938211
211
211
  }
@@ -512,5 +512,5 @@ module.exports = {
512
512
  }
513
513
  },
514
514
  "$schema": "http://json-schema.org/draft-07/schema#",
515
- "$version": 1715672877117
515
+ "$version": 1718869682828
516
516
  }
@@ -49,5 +49,5 @@ module.exports = {
49
49
  },
50
50
  "additionalProperties": false,
51
51
  "$schema": "http://json-schema.org/draft-07/schema#",
52
- "$version": 1710507688689
52
+ "$version": 1701660938211
53
53
  }
@@ -10,5 +10,5 @@ module.exports = {
10
10
  },
11
11
  "additionalProperties": false,
12
12
  "$schema": "http://json-schema.org/draft-07/schema#",
13
- "$version": 1710507688689
13
+ "$version": 1701660938211
14
14
  }
@@ -168,6 +168,9 @@ module.exports = {
168
168
  "ignoreUploadUnusedFiles": {
169
169
  "type": "boolean"
170
170
  },
171
+ "ignoreCodeQuality": {
172
+ "type": "boolean"
173
+ },
171
174
  "autoAudits": {
172
175
  "type": "boolean"
173
176
  },
@@ -651,5 +654,5 @@ module.exports = {
651
654
  }
652
655
  },
653
656
  "$schema": "http://json-schema.org/draft-07/schema#",
654
- "$version": 1710507688689
657
+ "$version": 1718869292222
655
658
  }
@@ -166,6 +166,9 @@ module.exports = {
166
166
  "ignoreDevUnusedFiles": {
167
167
  "type": "boolean"
168
168
  },
169
+ "ignoreCodeQuality": {
170
+ "type": "boolean"
171
+ },
169
172
  "checkInvalidKey": {
170
173
  "type": "boolean"
171
174
  },
@@ -367,5 +370,5 @@ module.exports = {
367
370
  }
368
371
  },
369
372
  "$schema": "http://json-schema.org/draft-07/schema#",
370
- "$version": 1710507688689
373
+ "$version": 1718869873347
371
374
  }
@@ -49,5 +49,5 @@ module.exports = {
49
49
  "rules"
50
50
  ],
51
51
  "$schema": "http://json-schema.org/draft-07/schema#",
52
- "$version": 1710507688689
52
+ "$version": 1701660938211
53
53
  }
@@ -16,5 +16,5 @@ module.exports = {
16
16
  },
17
17
  "additionalProperties": false,
18
18
  "$schema": "http://json-schema.org/draft-07/schema#",
19
- "$version": 1710507688689
19
+ "$version": 1701660938211
20
20
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkXcodeEnv=exports.codesignAndExport=void 0;const generateIpa_1=require("./generateIpa"),singletontask_1=require("./singletontask"),cp_1=require("./cp"),path=require("path"),signAndInstallTask={};async function codesignAndExport(e,n,t,s,i,a,c,o){var r;const{output:p}=s,d=path.join(__dirname,"../static/scripts/resignIpa"),l=await(0,generateIpa_1.generateIpa)(n,i),g=(null===(r=s.entitlements)||void 0===r?void 0:r["com.apple.developer.associated-domains"])||"";try{await checkXcodeEnv(i);const e=[l,p,s.outputAppWithName?s.outputAppWithName:"false",a?"true":"",g,t];let n=!1;if(s.certificate?(e.push(s.certificate),s.profile?(e.push(s.profile),n=!0,s.tpnsProfile?(e.push(s.tpnsProfile),i.message("doing","certificate: find tpns profile")):i.message("doing","certificate: cant find tpns profile")):i.message("fail","certificate: cant find profile")):!0===o?n=!0:i.message("fail","certificate: cant find certificate"),!n)throw i.message("fail","codesignAndExport missing needed info"),new Error("Failed! codesignAndExport missing needed info");return signAndInstallTask[l]||(signAndInstallTask[l]=new singletontask_1.SingletonTask(cp_1.spawnSyncExecShell.bind(null,d,e,{},i))),await signAndInstallTask[l].getResult(!0),{success:!0}}catch(e){return{success:!1,errMsg:e.message}}finally{delete signAndInstallTask[l]}}async function checkXcodeEnv(e){const n=path.join(__dirname,"../static/scripts/checkXcodeEnv");await(0,cp_1.spawnSyncExecShell)(n,[],{},e)}exports.codesignAndExport=codesignAndExport,exports.checkXcodeEnv=checkXcodeEnv;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkXcodeEnv=exports.codesignAndExport=void 0;const generateIpa_1=require("./generateIpa"),singletontask_1=require("./singletontask"),cp_1=require("./cp"),env_1=require("./env"),path=require("path"),signAndInstallTask={};async function codesignAndExport(e,n,t,i,s,a,c,r){var o;const{output:p}=i,d=path.join(__dirname,"../static/scripts/resignIpa"),l=await(0,generateIpa_1.generateIpa)(n,s),g=(null===(o=i.entitlements)||void 0===o?void 0:o["com.apple.developer.associated-domains"])||"";try{await checkXcodeEnv(s);const e=[l,p,i.outputAppWithName?i.outputAppWithName:"false",a?"true":"",g,t];let n=!1;if(i.certificate?(e.push(i.certificate),i.profile?(e.push(i.profile),n=!0,i.tpnsProfile?(e.push(i.tpnsProfile),s.message("doing","certificate: find tpns profile")):s.message("doing","certificate: cant find tpns profile")):s.message("fail","certificate: cant find profile")):!0===r?n=!0:s.message("fail","certificate: cant find certificate"),!n)throw s.message("fail","codesignAndExport missing needed info"),new Error("Failed! codesignAndExport missing needed info");return signAndInstallTask[l]||(signAndInstallTask[l]=new singletontask_1.SingletonTask(cp_1.spawnSyncExecShell.bind(null,d,e,{},s))),await signAndInstallTask[l].getResult(!0),{success:!0}}catch(e){return{success:!1,errMsg:e.message}}finally{delete signAndInstallTask[l]}}async function checkXcodeEnv(e){if(env_1.isWin)throw new Error("windows下不能使用分发证书签名。需要启用远程构建");const n=path.join(__dirname,"../static/scripts/checkXcodeEnv");await(0,cp_1.spawnSyncExecShell)(n,[],{},e)}exports.codesignAndExport=codesignAndExport,exports.checkXcodeEnv=checkXcodeEnv;
@@ -0,0 +1 @@
1
+ "use strict";function shouldInspectCompiler(){var o;return!!(null===(o=global.localStorage)||void 0===o?void 0:o.getItem("inspectCompiler"))}function shouldRunInMainProcess(){var o;return!!(null===(o=global.localStorage)||void 0===o?void 0:o.getItem("compilerInMainProcess"))}function shouldNotRunInWorker(){var o;return!!(null===(o=global.localStorage)||void 0===o?void 0:o.getItem("compilerNotInWorker"))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.shouldNotRunInWorker=exports.shouldRunInMainProcess=exports.shouldInspectCompiler=void 0,exports.shouldInspectCompiler=shouldInspectCompiler,exports.shouldRunInMainProcess=shouldRunInMainProcess,exports.shouldNotRunInWorker=shouldNotRunInWorker;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.signAndInstallOrExport=exports.doCertificateSignAndInstallOrExport=exports.doAppleIdSignAndInstallOrExport=exports.clearCache=exports.getIOSDevices=exports.miniappSinTypes=exports.DEFAULT_BUNDLE_ID=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),singletontask_1=require("./singletontask"),zip_1=require("./zip"),cp_1=require("./cp"),tools_1=require("./tools"),progressRecorder_1=require("./progressRecorder"),download_1=require("./download"),glob_1=tslib_1.__importDefault(require("glob")),miniappJson_1=require("./miniappJson"),generateIpa_1=require("./generateIpa"),path=require("path"),os=require("os"),fse=require("fs-extra"),querystring=require("querystring");exports.DEFAULT_BUNDLE_ID="com.tencent.devtoolssaaademo.db";const isMac="darwin"===process.platform,remoteUrlRoot="http://dldir1.qq.com/WechatWebDev/donut/miniapp-builder/";exports.miniappSinTypes={appleId:{type:"appleId"},certificate:{type:"certificate"}};const majorVersion="0",signAndInstallTask={};async function getMiniAppBuilderVersion(e="cli"){try{"dev"!==e&&"cli"!==e&&(e="release-0");const i=`${remoteUrlRoot}versionMap/${e}.json`,n=path.join(os.tmpdir(),"miniapp-builder-version.json");fse.existsSync(n)&&fse.removeSync(n),await(0,download_1.downloadLargeFile)(i,n);const t=fse.readJSONSync(n);return isMac?t.mac:t.win}catch(e){throw new Error("getMiniAppBuilderVersion fail: "+e.message)}}async function downloadMiniAppBuilder(e,i,n){const t=`${remoteUrlRoot}${isMac?"mac":"win"}/miniapp-builder-${e}.zip`,s=path.join(os.tmpdir(),"miniapp-builder.zip");fse.existsSync(s)&&fse.removeSync(s),null==n||n.progress("Downloading the miniapp-builder..."),await(0,download_1.downloadLargeFile)(t,s),await(0,zip_1.unzip)(s,i)}async function getMiniAppBuilder(e){const{miniappDirPath:i=path.join(__dirname,"../vendor"),devtoolsVersion:n="cli",recorder:t}=e,s=await getMiniAppBuilderVersion(n);let r="";const a=path.join(i,"miniapp-builder");if(r="win32"===process.platform?(0,tools_1.unifyPath)(path.join(a,s,"MiniappBuilder.exe")):(0,tools_1.unifyPath)(path.join(a,s,"MiniAppBuilder")),!fse.existsSync(r)){fse.ensureDirSync(a),fse.emptyDirSync(a);const e=path.dirname(r);fse.ensureDirSync(e),await downloadMiniAppBuilder(s,e,t);glob_1.default.sync("*",{nodir:!0,cwd:e}).forEach(i=>{fse.chmodSync(path.join(e,i),"777")})}return{builderPath:r,exe:path.basename(r),cwd:path.dirname(r)}}async function getIOSDevices(e){const{builderPath:i}=await getMiniAppBuilder(e),n=child_process.execSync(`"${i}" --action getDevices`,{}).toString().split("\n"),t=[];return n.forEach(e=>{if(e.trim()){const i=e.split("|");t.push({type:"device",name:(i[1]||"").trim(),version:(i[2]||"").trim(),udid:(i[3]||"").trim()})}}),t}async function clearCache(e){const{builderPath:i}=await getMiniAppBuilder(e),n=(0,miniappJson_1.getTargetMiniprogramArg)(e.projectPath,"appid");child_process.execSync(`"${i}" --appid ${n} --action clear --type ${e.type}`,{})}async function doAppleIdSignAndInstallOrExport(e,i){const{recorder:n}=i,t=genInterceptRecorder(n),{exe:s,cwd:r,builderPath:a}=await getMiniAppBuilder(i),p=(0,tools_1.unifyPath)(e.ipaPath),o=["--appid",(0,miniappJson_1.getTargetMiniprogramArg)(e.projectPath,"appid"),"--action","sign","--ipa",p,"--type","appleId"];if(e.appleId&&o.push("-ai",e.appleId),e.password&&o.push("-p",e.password),e.entitlements&&o.push("--entitlements",querystring.stringify(e.entitlements)),e.install&&(isMac?o.push("--install"):o.push("--install","true")),e.deviceId&&o.push("--deviceId",e.deviceId),e.output&&o.push("--output",e.output),e.bundleId){const i=e.bundleId===exports.DEFAULT_BUNDLE_ID?"auto":e.bundleId;o.push("--bundleId",i)}try{return signAndInstallTask[p]||(signAndInstallTask[p]=isMac?new singletontask_1.SingletonTask(cp_1.spawnSync.bind(null,a,o,{},t)):new singletontask_1.SingletonTask(cp_1.spawnSync.bind(null,s,o,{cwd:r},t))),await signAndInstallTask[p].getResult(!0),{success:!0}}catch(e){return{success:!1,errMsg:e.message}}finally{delete signAndInstallTask[p]}}async function doCertificateSignAndInstallOrExport(e,i){const{recorder:n}=i,{exe:t,cwd:s,builderPath:r}=await getMiniAppBuilder(i),a=(0,miniappJson_1.tryGetIOSMiniappJson)(e.projectPath),p=(0,miniappJson_1.iOSMiniAppJsonIsUsingTpush)(a),o=e.miniappCacheDirPath||"",l=(0,tools_1.unifyPath)(e.ipaPath),c=["--appid",(0,miniappJson_1.getTargetMiniprogramArg)(e.projectPath,"appid"),"--action","sign","--miniappCacheDir",o,"--ipa",l,"--type","certificate"];e.entitlements&&c.push("--entitlements",querystring.stringify(e.entitlements)),e.install&&(isMac?c.push("--install"):c.push("--install","true")),p&&(isMac?c.push("--extensionProfilePath"):c.push("--extension","true")),e.deviceId&&c.push("--deviceId",e.deviceId),e.output&&c.push("--output",e.output);try{return signAndInstallTask[l]||(signAndInstallTask[l]=isMac?new singletontask_1.SingletonTask(cp_1.spawnSync.bind(null,r,c,{},n)):new singletontask_1.SingletonTask(cp_1.spawnSync.bind(null,t,c,{cwd:s},n))),await signAndInstallTask[l].getResult(!0),{success:!0}}catch(e){return{success:!1,errMsg:e.message}}finally{delete signAndInstallTask[l]}}async function signAndInstallOrExport(e,i,n,t,s,r){const{recorder:a}=r,{install:p,deviceId:o,output:l,entitlements:c,bundleId:d}=s,u=await(0,generateIpa_1.generateIpa)(i,a);try{null==a||a.progress("signing the app...");const{signType:i}=t;let s=null;if(s=i===exports.miniappSinTypes.appleId.type?await doAppleIdSignAndInstallOrExport({bundleId:d,projectPath:e,ipaPath:u,entitlements:c,install:p,output:l,deviceId:o},r):await doCertificateSignAndInstallOrExport({projectPath:e,ipaPath:u,miniappCacheDirPath:n,entitlements:c,install:p,output:l,deviceId:o},r),!s.success)throw new Error("Sign the app fail:"+s.errMsg)}finally{fse.existsSync(u)&&fse.removeSync(u)}}function genInterceptRecorder(e){if(e){const i=new progressRecorder_1.Recorder((i,n,t)=>{(t.indexOf('["MiniAppBuilder could not find this device."]')>-1||t.indexOf("no connected device")>-1)&&e.message("fail","无法找到手机设备,请检查手机是否正确链接电脑(can not find device)"),e.message(n,t)});return i.run("!inner",()=>{}),i}}exports.getIOSDevices=getIOSDevices,exports.clearCache=clearCache,exports.doAppleIdSignAndInstallOrExport=doAppleIdSignAndInstallOrExport,exports.doCertificateSignAndInstallOrExport=doCertificateSignAndInstallOrExport,exports.signAndInstallOrExport=signAndInstallOrExport;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.signAndInstallOrExport=exports.doCertificateSignAndInstallOrExport=exports.doAppleIdSignAndInstallOrExport=exports.clearCache=exports.getIOSDevices=exports.miniappSinTypes=exports.DEFAULT_BUNDLE_ID=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),singletontask_1=require("./singletontask"),zip_1=require("./zip"),cp_1=require("./cp"),tools_1=require("./tools"),progressRecorder_1=require("./progressRecorder"),download_1=require("./download"),glob_1=tslib_1.__importDefault(require("glob")),miniappJson_1=require("./miniappJson"),generateIpa_1=require("./generateIpa"),path=require("path"),os=require("os"),fse=require("fs-extra"),querystring=require("querystring");exports.DEFAULT_BUNDLE_ID="com.tencent.devtoolssaaademo.db";const isMac="darwin"===process.platform,remoteUrlRoot="http://dldir1.qq.com/WechatWebDev/donut/miniapp-builder/";exports.miniappSinTypes={appleId:{type:"appleId"},certificate:{type:"certificate"}};const majorVersion="1",signAndInstallTask={};async function getMiniAppBuilderVersion(e="cli"){try{"dev"!==e&&"cli"!==e&&(e="release-1");const i=`${remoteUrlRoot}versionMap/${e}.json`,n=path.join(os.tmpdir(),"miniapp-builder-version.json");fse.existsSync(n)&&fse.removeSync(n),await(0,download_1.downloadLargeFile)(i,n);const t=fse.readJSONSync(n);return isMac?t.mac:t.win}catch(e){throw new Error("getMiniAppBuilderVersion fail: "+e.message)}}async function downloadMiniAppBuilder(e,i,n){const t=`${remoteUrlRoot}${isMac?"mac":"win"}/miniapp-builder-${e}.zip`,s=path.join(os.tmpdir(),"miniapp-builder.zip");fse.existsSync(s)&&fse.removeSync(s),null==n||n.progress("Downloading the miniapp-builder..."),await(0,download_1.downloadLargeFile)(t,s),await(0,zip_1.unzip)(s,i)}async function getMiniAppBuilder(e){const{miniappDirPath:i=path.join(__dirname,"../vendor"),devtoolsVersion:n="cli",recorder:t}=e,s=await getMiniAppBuilderVersion(n);let r="";const a=path.join(i,"miniapp-builder");if(r="win32"===process.platform?(0,tools_1.unifyPath)(path.join(a,s,"MiniappBuilder.exe")):(0,tools_1.unifyPath)(path.join(a,s,"MiniAppBuilder")),!fse.existsSync(r)){fse.ensureDirSync(a),fse.emptyDirSync(a);const e=path.dirname(r);fse.ensureDirSync(e),await downloadMiniAppBuilder(s,e,t);glob_1.default.sync("*",{nodir:!0,cwd:e}).forEach(i=>{fse.chmodSync(path.join(e,i),"777")})}return{builderPath:r,exe:path.basename(r),cwd:path.dirname(r)}}async function getIOSDevices(e){const{builderPath:i}=await getMiniAppBuilder(e),n=child_process.execSync(`"${i}" --action getDevices`,{}).toString().split("\n"),t=[];return n.forEach(e=>{if(e.trim()){const i=e.split("|");t.push({type:"device",name:(i[1]||"").trim(),version:(i[2]||"").trim(),udid:(i[3]||"").trim()})}}),t}async function clearCache(e){const{builderPath:i}=await getMiniAppBuilder(e),n=(0,miniappJson_1.getTargetMiniprogramArg)(e.projectPath,"appid");child_process.execSync(`"${i}" --appid ${n} --action clear --type ${e.type}`,{})}async function doAppleIdSignAndInstallOrExport(e,i){const{recorder:n}=i,t=genInterceptRecorder(n),{exe:s,cwd:r,builderPath:a}=await getMiniAppBuilder(i),p=(0,tools_1.unifyPath)(e.ipaPath),o=["--appid",(0,miniappJson_1.getTargetMiniprogramArg)(e.projectPath,"appid"),"--action","sign","--ipa",p,"--type","appleId"];if(e.appleId&&o.push("-ai",e.appleId),e.password&&o.push("-p",e.password),e.entitlements&&o.push("--entitlements",querystring.stringify(e.entitlements)),e.install&&(isMac?o.push("--install"):o.push("--install","true")),e.deviceId&&o.push("--deviceId",e.deviceId),e.output&&o.push("--output",e.output),e.bundleId){const i=e.bundleId===exports.DEFAULT_BUNDLE_ID?"auto":e.bundleId;o.push("--bundleId",i)}try{return signAndInstallTask[p]||(signAndInstallTask[p]=isMac?new singletontask_1.SingletonTask(cp_1.spawnSync.bind(null,a,o,{},t)):new singletontask_1.SingletonTask(cp_1.spawnSync.bind(null,s,o,{cwd:r},t))),await signAndInstallTask[p].getResult(!0),{success:!0}}catch(e){return{success:!1,errMsg:e.message}}finally{delete signAndInstallTask[p]}}async function doCertificateSignAndInstallOrExport(e,i){const{recorder:n}=i,{exe:t,cwd:s,builderPath:r}=await getMiniAppBuilder(i),a=(0,miniappJson_1.tryGetIOSMiniappJson)(e.projectPath),p=(0,miniappJson_1.iOSMiniAppJsonIsUsingTpush)(a),o=e.miniappCacheDirPath||"",l=(0,tools_1.unifyPath)(e.ipaPath),c=["--appid",(0,miniappJson_1.getTargetMiniprogramArg)(e.projectPath,"appid"),"--action","sign","--miniappCacheDir",o,"--ipa",l,"--type","certificate"];e.entitlements&&c.push("--entitlements",querystring.stringify(e.entitlements)),e.install&&(isMac?c.push("--install"):c.push("--install","true")),p&&(isMac?c.push("--extensionProfilePath"):c.push("--extension","true")),e.deviceId&&c.push("--deviceId",e.deviceId),e.output&&c.push("--output",e.output);try{return signAndInstallTask[l]||(signAndInstallTask[l]=isMac?new singletontask_1.SingletonTask(cp_1.spawnSync.bind(null,r,c,{},n)):new singletontask_1.SingletonTask(cp_1.spawnSync.bind(null,t,c,{cwd:s},n))),await signAndInstallTask[l].getResult(!0),{success:!0}}catch(e){return{success:!1,errMsg:e.message}}finally{delete signAndInstallTask[l]}}async function signAndInstallOrExport(e,i,n,t,s,r){const{recorder:a}=r,{install:p,deviceId:o,output:l,entitlements:c,bundleId:d}=s,u=await(0,generateIpa_1.generateIpa)(i,a);try{null==a||a.progress("signing the app...");const{signType:i}=t;let s=null;if(s=i===exports.miniappSinTypes.appleId.type?await doAppleIdSignAndInstallOrExport({bundleId:d,projectPath:e,ipaPath:u,entitlements:c,install:p,output:l,deviceId:o},r):await doCertificateSignAndInstallOrExport({projectPath:e,ipaPath:u,miniappCacheDirPath:n,entitlements:c,install:p,output:l,deviceId:o},r),!s.success)throw new Error("Sign the app fail:"+s.errMsg)}finally{fse.existsSync(u)&&fse.removeSync(u)}}function genInterceptRecorder(e){if(e){const i=new progressRecorder_1.Recorder((i,n,t)=>{(t.indexOf('["MiniAppBuilder could not find this device."]')>-1||t.indexOf("no connected device")>-1)&&e.message("fail","无法找到手机设备,请检查手机是否正确链接电脑(can not find device)"),e.message(n,t)});return i.run("!inner",()=>{}),i}}exports.getIOSDevices=getIOSDevices,exports.clearCache=clearCache,exports.doAppleIdSignAndInstallOrExport=doAppleIdSignAndInstallOrExport,exports.doCertificateSignAndInstallOrExport=doCertificateSignAndInstallOrExport,exports.signAndInstallOrExport=signAndInstallOrExport;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getTargetMiniprogramArg=exports.getMiniprogramRoot=exports.getRawAppJSON=exports.iOSAppJsonIsUsingIPadResizable=exports.iOSMiniAppJsonIsUsingGDT=exports.iOSMiniAppJsonIsUsingTpush=exports.writeMiniAppJson=exports.isNewMiniAppProject=exports.isMiniAppProject=exports.tryGetPluginMiniappJson=exports.tryGetIOSMiniappJson=exports.tryGetAndroidMiniappJson=exports.getMiniappJson=exports.getRawMiniappJson=exports.identityServiceConfigToMiniAppJSON=exports.PLATFORM=exports.miniAppPlatformMap=void 0;const tools_1=require("./tools"),each=require("licia/each"),safeSet=require("licia/safeSet"),path=require("path"),fse=require("fs-extra"),_=require("lodash");var PLATFORM;function identityServiceConfigToMiniAppJSON(i,n={}){return n.identityServiceConfig={authorizeMiniprogramType:1,miniprogramLoginPath:i},n}function getRawMiniappJson(i){var n,o,t,e,p,r;i=(0,tools_1.unifyPath)(i);const s=path.posix.join(i,"project.miniapp.json");if(!fse.existsSync(s))return{};let a={};try{a=fse.readJsonSync(s)}catch(i){console.error(i)}return a.miniVersion&&"v1"!==a.miniVersion||((null===(n=a["mini-android"])||void 0===n?void 0:n.projectPath)&&!path.isAbsolute(null===(o=a["mini-android"])||void 0===o?void 0:o.projectPath)&&(a["mini-android"].projectPath=path.posix.join(i,null===(t=a["mini-android"])||void 0===t?void 0:t.projectPath)),(null===(e=a["mini-ios"])||void 0===e?void 0:e.projectPath)&&!path.isAbsolute(null===(p=a["mini-ios"])||void 0===p?void 0:p.projectPath)&&(a["mini-ios"].projectPath=path.posix.join(i,null===(r=a["mini-ios"])||void 0===r?void 0:r.projectPath))),a}function getMiniappJson(i,n="mini-weixin"){const o=Object.values(exports.miniAppPlatformMap),t=getRawMiniappJson(i),e=_.omit(t,o);return _.merge(e,t[n]||("mini-weixin"===n?t["mini-wechat"]:{}))}function tryGetAndroidMiniappJson(i){let n={};try{n=getMiniappJson(i,PLATFORM.ANDROID)}catch(i){}return n}function tryGetIOSMiniappJson(i){return getMiniappJson(i,PLATFORM.IOS)||{}}function tryGetPluginMiniappJson(i){let n={};try{n=getMiniappJson(i,PLATFORM.PLUGIN)}catch(i){}return n}function isMiniAppProject(i){const n=path.posix.join(i,"project.miniapp.json");return"multiPlatform"===fse.readJsonSync(n).projectArchitecture}function isNewMiniAppProject(i){const n=getRawMiniappJson(i);return isMiniAppProject(i)&&"v2"===n.miniVersion}function writeMiniAppJson(i,n){const o=path.posix.join(i,"project.miniapp.json");let t={};try{t=fse.readJsonSync(o)}catch(i){return}each(n,(i,n)=>{safeSet(t,n,i)}),fse.writeJSONSync(o,t,{spaces:2})}function iOSMiniAppJsonIsUsingTpush(i){const n=i.tpush&&!0===i.tpush.useExtendedLib_WeAppTPNS&&"number"==typeof i.tpush.accessID&&"string"==typeof i.tpush.accessKey&&"string"==typeof i.tpush.serviceBundleId;if(n&&(0,tools_1.compareVersion)(i.sdkVersion,"1.0.7")<=0)throw new Error(`can not use TPNS(消息推送) extendsdk in sdk version ${i.sdkVersion}, TPNS is supported in 1.0.8.`);return n}function iOSMiniAppJsonIsUsingGDT(i){const n=i.gdt&&!0===i.gdt.useExtendedLib_WeAppGDT&&"string"==typeof i.gdt.appid&&"string"==typeof i.gdt.splashAd_placementId;if(n&&(0,tools_1.compareVersion)(i.sdkVersion,"1.0.19")<=0)throw new Error(`can not use GDT(广告) extendsdk in sdk version ${i.sdkVersion}, GDT is supported in 1.0.20.`);return n}function iOSAppJsonIsUsingIPadResizable(i){return!0===getRawAppJSON(i).resizable}function getRawAppJSON(i){let n,o;const t=getMiniprogramRoot(i);n=t?path.posix.join(i,t,"app.json"):path.posix.join(i,"app.json");try{o=fse.readJsonSync(n)}catch(i){throw console.error(i),i}return o}function getMiniprogramRoot(i){const n=(0,tools_1.normalizePath)(path.posix.join(i,"project.config.json"));let o;try{o=fse.readJsonSync(n)}catch(i){throw console.error(i),i}return o.miniprogramRoot?o.miniprogramRoot:""}function getTargetMiniprogramArg(i,n){const o=(0,tools_1.normalizePath)(path.posix.join(i,"project.config.json"));let t;try{t=fse.readJsonSync(o)}catch(i){throw console.error(i),i}return t[n]||""}exports.miniAppPlatformMap={"mini-android":"mini-android","mini-ios":"mini-ios","mini-weixin":"mini-weixin"},function(i){i.ANDROID="mini-android",i.IOS="mini-ios",i.PLUGIN="mini-plugin"}(PLATFORM=exports.PLATFORM||(exports.PLATFORM={})),exports.identityServiceConfigToMiniAppJSON=identityServiceConfigToMiniAppJSON,exports.getRawMiniappJson=getRawMiniappJson,exports.getMiniappJson=getMiniappJson,exports.tryGetAndroidMiniappJson=tryGetAndroidMiniappJson,exports.tryGetIOSMiniappJson=tryGetIOSMiniappJson,exports.tryGetPluginMiniappJson=tryGetPluginMiniappJson,exports.isMiniAppProject=isMiniAppProject,exports.isNewMiniAppProject=isNewMiniAppProject,exports.writeMiniAppJson=writeMiniAppJson,exports.iOSMiniAppJsonIsUsingTpush=iOSMiniAppJsonIsUsingTpush,exports.iOSMiniAppJsonIsUsingGDT=iOSMiniAppJsonIsUsingGDT,exports.iOSAppJsonIsUsingIPadResizable=iOSAppJsonIsUsingIPadResizable,exports.getRawAppJSON=getRawAppJSON,exports.getMiniprogramRoot=getMiniprogramRoot,exports.getTargetMiniprogramArg=getTargetMiniprogramArg;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.iosPrivacyDescObj=exports.getTargetMiniprogramArg=exports.getMiniprogramRoot=exports.getRawAppJSON=exports.iOSAppJsonIsUsingIPadResizable=exports.iOSMiniAppJsonIsUsingGDT=exports.iOSMiniAppJsonIsUsingTpush=exports.writeMiniAppJson=exports.isNewMiniAppProject=exports.isMiniAppProject=exports.tryGetPluginMiniappJson=exports.tryGetIOSMiniappJson=exports.tryGetAndroidMiniappJson=exports.getMiniappJson=exports.getRawMiniappJson=exports.identityServiceConfigToMiniAppJSON=exports.PLATFORM=exports.miniAppPlatformMap=void 0;const tools_1=require("./tools"),each=require("licia/each"),safeSet=require("licia/safeSet"),path=require("path"),fse=require("fs-extra"),_=require("lodash");var PLATFORM;function identityServiceConfigToMiniAppJSON(i,n={}){return n.identityServiceConfig={authorizeMiniprogramType:1,miniprogramLoginPath:i},n}function getRawMiniappJson(i){var n,o,e,t,p,s;i=(0,tools_1.unifyPath)(i);const r=path.posix.join(i,"project.miniapp.json");if(!fse.existsSync(r))return{};let a={};try{a=fse.readJsonSync(r)}catch(i){console.error(i)}return a.miniVersion&&"v1"!==a.miniVersion||((null===(n=a["mini-android"])||void 0===n?void 0:n.projectPath)&&!path.isAbsolute(null===(o=a["mini-android"])||void 0===o?void 0:o.projectPath)&&(a["mini-android"].projectPath=path.posix.join(i,null===(e=a["mini-android"])||void 0===e?void 0:e.projectPath)),(null===(t=a["mini-ios"])||void 0===t?void 0:t.projectPath)&&!path.isAbsolute(null===(p=a["mini-ios"])||void 0===p?void 0:p.projectPath)&&(a["mini-ios"].projectPath=path.posix.join(i,null===(s=a["mini-ios"])||void 0===s?void 0:s.projectPath))),a}function getMiniappJson(i,n="mini-weixin"){const o=Object.values(exports.miniAppPlatformMap),e=getRawMiniappJson(i),t=_.omit(e,o);return _.merge(t,e[n]||("mini-weixin"===n?e["mini-wechat"]:{}))}function tryGetAndroidMiniappJson(i){let n={};try{n=getMiniappJson(i,PLATFORM.ANDROID)}catch(i){}return n}function tryGetIOSMiniappJson(i){let n={};try{n=getMiniappJson(i,PLATFORM.IOS)}catch(i){}return n}function tryGetPluginMiniappJson(i){let n={};try{n=getMiniappJson(i,PLATFORM.PLUGIN)}catch(i){}return n}function isMiniAppProject(i){const n=path.posix.join(i,"project.miniapp.json");return"multiPlatform"===fse.readJsonSync(n).projectArchitecture}function isNewMiniAppProject(i){const n=getRawMiniappJson(i);return isMiniAppProject(i)&&"v2"===n.miniVersion}function writeMiniAppJson(i,n){const o=path.posix.join(i,"project.miniapp.json");let e={};try{e=fse.readJsonSync(o)}catch(i){return}each(n,(i,n)=>{safeSet(e,n,i)}),fse.writeJSONSync(o,e,{spaces:2})}function iOSMiniAppJsonIsUsingTpush(i){const n=i.tpush&&!0===i.tpush.useExtendedLib_WeAppTPNS&&"number"==typeof i.tpush.accessID&&"string"==typeof i.tpush.accessKey&&"string"==typeof i.tpush.serviceBundleId;if(n&&(0,tools_1.compareVersion)(i.sdkVersion,"1.0.7")<=0)throw new Error(`can not use TPNS(消息推送) extendsdk in sdk version ${i.sdkVersion}, TPNS is supported in 1.0.8.`);return n}function iOSMiniAppJsonIsUsingGDT(i){const n=i.gdt&&!0===i.gdt.useExtendedLib_WeAppGDT&&"string"==typeof i.gdt.appid&&"string"==typeof i.gdt.splashAd_placementId;if(n&&(0,tools_1.compareVersion)(i.sdkVersion,"1.0.19")<=0)throw new Error(`can not use GDT(广告) extendsdk in sdk version ${i.sdkVersion}, GDT is supported in 1.0.20.`);return n}function iOSAppJsonIsUsingIPadResizable(i){return!0===getRawAppJSON(i).resizable}function getRawAppJSON(i){let n,o;const e=getMiniprogramRoot(i);n=e?path.posix.join(i,e,"app.json"):path.posix.join(i,"app.json");try{o=fse.readJsonSync(n)}catch(i){throw console.error(i),i}return o}function getMiniprogramRoot(i){const n=(0,tools_1.normalizePath)(path.posix.join(i,"project.config.json"));let o;try{o=fse.readJsonSync(n)}catch(i){throw console.error(i),i}return o.miniprogramRoot?o.miniprogramRoot:""}function getTargetMiniprogramArg(i,n){const o=(0,tools_1.normalizePath)(path.posix.join(i,"project.config.json"));let e;try{e=fse.readJsonSync(o)}catch(i){throw console.error(i),i}return e[n]||""}exports.miniAppPlatformMap={"mini-android":"mini-android","mini-ios":"mini-ios","mini-weixin":"mini-weixin"},function(i){i.ANDROID="mini-android",i.IOS="mini-ios",i.PLUGIN="mini-plugin"}(PLATFORM=exports.PLATFORM||(exports.PLATFORM={})),exports.identityServiceConfigToMiniAppJSON=identityServiceConfigToMiniAppJSON,exports.getRawMiniappJson=getRawMiniappJson,exports.getMiniappJson=getMiniappJson,exports.tryGetAndroidMiniappJson=tryGetAndroidMiniappJson,exports.tryGetIOSMiniappJson=tryGetIOSMiniappJson,exports.tryGetPluginMiniappJson=tryGetPluginMiniappJson,exports.isMiniAppProject=isMiniAppProject,exports.isNewMiniAppProject=isNewMiniAppProject,exports.writeMiniAppJson=writeMiniAppJson,exports.iOSMiniAppJsonIsUsingTpush=iOSMiniAppJsonIsUsingTpush,exports.iOSMiniAppJsonIsUsingGDT=iOSMiniAppJsonIsUsingGDT,exports.iOSAppJsonIsUsingIPadResizable=iOSAppJsonIsUsingIPadResizable,exports.getRawAppJSON=getRawAppJSON,exports.getMiniprogramRoot=getMiniprogramRoot,exports.getTargetMiniprogramArg=getTargetMiniprogramArg,exports.iosPrivacyDescObj={NSPhotoLibraryUsageDescription:"当前应用程序需要访问用户的相册,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSCameraUsageDescription:"当前应用程序需要访问用户的相机,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSMicrophoneUsageDescription:"当前应用程序需要访问用户的麦克风,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSLocationWhenInUseUsageDescription:"当前应用程序需要在使用时访问用户的位置,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSLocationAlwaysUsageDescription:"当前应用程序需要始终访问用户的位置,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSLocationAlwaysAndWhenInUseUsageDescription:"当前应用程序需要始终和在使用时访问用户的位置,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSContactsUsageDescription:"当前应用程序需要访问用户的联系人,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSCalendarsUsageDescription:"当前应用程序需要访问用户的日历,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSRemindersUsageDescription:"当前应用程序需要访问用户的提醒事项,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSHealthShareUsageDescription:"当前应用程序需要共享用户的健康数据,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSHealthUpdateUsageDescription:"当前应用程序需要更新用户的健康数据,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSBluetoothPeripheralUsageDescription:"当前应用程序需要访问用户的蓝牙,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSBluetoothAlwaysUsageDescription:"当前应用程序需要始终访问用户的蓝牙,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSMotionUsageDescription:"",NSHomeKitUsageDescription:"",NSSiriUsageDescription:"",NSSpeechRecognitionUsageDescription:"当前应用程序需要使用语音识别,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSVideoSubscriberAccountUsageDescription:"",NSAppleMusicUsageDescription:"",NSFaceIDUsageDescription:"",NSNFCReaderUsageDescription:"",NSUserTrackingUsageDescription:"",NSLocalNetworkUsageDescription:"当前应用程序需要访问本地网络,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NSSystemAdministrationUsageDescription:"当前应用程序需要进行系统管理操作,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可」",NFCReaderUsageDescription:"",NSHealthClinicalHealthRecordsShareUsageDescription:"",NSPhotoLibraryAddUsageDescription:"应用程序在请求访问照片库,如需修改描述请前往「project.miniapp.json - 隐私信息访问许可描述」修改,并且关闭「自动使用默认描述补全默认隐私信息访问许可"};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SubProcessProxy=void 0;const tslib_1=require("tslib"),child_process_1=require("child_process"),path_1=tslib_1.__importDefault(require("path")),customError_1=require("../customError"),singletontask_1=require("../singletontask");function performanceMark(s,e){}function shouldInspectCompiler(){var s;return!!(null===(s=global.localStorage)||void 0===s?void 0:s.getItem("inspectCompiler"))}const PROCESS_READY_TIMEOUT=2e4;class SubProcessProxy{constructor(s,e,t,r,o=8891){this.project=s,this.entryPath=e,this.passData=t,this.initOptions=r,this.inspectPort=o,this.taskMap=new Map,this.taskId=0,this.init=async()=>{performanceMark("process init"),this.process=await this.forkProcess(),performanceMark("process init",!0)}}async ready(){var s;return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init)),await(null===(s=this._checkReadyTask)||void 0===s?void 0:s.getResult(!0))}async sendProcessMessage(s){await this.ready(),this.process.send(s)}destroy(){var s;null===(s=this.process)||void 0===s||s.kill("SIGTERM"),this.process=void 0,this._checkReadyTask=void 0}async forkProcess(){const s=this.entryPath,e={stdio:["pipe","pipe","pipe","ipc"],cwd:this.project.projectPath,env:Object.assign(Object.assign({},process.env),{cpprocessEnv:"childprocess",nativeProcess:"1",timeout:global.TEST_COMPILER_PROCESS_TIMEOUT})};shouldInspectCompiler()&&(e.execArgv=["--inspect-brk="+this.inspectPort]);const t=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname;if(e.env.isDevtools=t,t){let s=path_1.default.join(path_1.default.dirname(process.execPath),"node");"darwin"!==process.platform&&(s+=".exe"),e.execPath=s}performanceMark("fork process");const r=await this.project.serialize();return new Promise((o,i)=>{const a=(0,child_process_1.fork)(s,["--expose-gc"],e),n=setTimeout(()=>{this.destroy(),i(new Error("fork process timeout"))},2e4);a.stdout.setEncoding("utf8"),a.stdout.on("data",s=>{console.log("child process stdout: "+s)}),a.stderr.on("data",s=>{console.error("child process stderr: "+s)}),a.on("exit",(s,e)=>{this.process=void 0,this._checkReadyTask=void 0,t&&console.error(`child process exit: code(${s}), signal(${e})`),0!==s&&i(new Error(`native child process exit: code(${s}), signal(${e})`))}),a.on("message",s=>{if("ready"===s.type&&(clearTimeout(n),performanceMark("process ready"),o(a)),"noReady"===s.type&&(performanceMark("process not ready"),i(new Error(s.error.message))),"progress"===s.type){const e=this.taskMap.get(s.taskId);(null==e?void 0:e.progressUpdate)&&e.progressUpdate(s.id,s.status,s.message)}if("response"===s.type){const{id:e,data:t,error:r}=s;r?this.onResponse(e,void 0,r):this.onResponse(e,t,void 0)}}),a.unref(),this.taskId+=1;const c={type:"init",data:{passData:this.passData,projectInfo:r,options:this.initOptions}};return a.send(c),a})}onResponse(s,e,t){const r=this.taskMap.get(s);this.taskMap.delete(s),r?t?(t=new customError_1.CustomError(t),r.reject(t)):r.resolve(e):console.error(`child process task: ${s} not found`)}async sendEvent(s,e){this.sendProcessMessage({type:"event",name:s,data:e})}async runTask(s,e,t){return new Promise((r,o)=>{const i={name:s,data:e,resolve:r,reject:o,progressUpdate:t};this.taskId+=1,this.taskMap.set(this.taskId,i),this.sendProcessMessage({type:"request",id:this.taskId,name:s,data:e})})}}exports.SubProcessProxy=SubProcessProxy;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SubProcessProxy=void 0;const tslib_1=require("tslib"),child_process_1=require("child_process"),path_1=tslib_1.__importDefault(require("path")),customError_1=require("../customError"),singletontask_1=require("../singletontask"),debug_1=require("../debug");function performanceMark(s,e){}const PROCESS_READY_TIMEOUT=2e4;class SubProcessProxy{constructor(s,e,t,r,o=8891){this.project=s,this.entryPath=e,this.passData=t,this.initOptions=r,this.inspectPort=o,this.taskMap=new Map,this.taskId=0,this.init=async()=>{performanceMark("process init"),this.process=await this.forkProcess(),performanceMark("process init",!0)}}async ready(){var s;return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init)),await(null===(s=this._checkReadyTask)||void 0===s?void 0:s.getResult(!0))}async sendProcessMessage(s){await this.ready(),this.process.send(s)}destroy(){var s;null===(s=this.process)||void 0===s||s.kill("SIGTERM"),this.process=void 0,this._checkReadyTask=void 0}async forkProcess(){const s=await this.project.serialize(),e={type:"init",data:{passData:this.passData,projectInfo:s,options:this.initOptions}};if((0,debug_1.shouldRunInMainProcess)()){const s=require("../../modules/corecompiler/processHandler");return await s.initHandler(e),{send:async e=>{if((0,debug_1.shouldRunInMainProcess)()){const t=await s.messageHandler(e),{id:r,data:o,error:i}=t;this.onResponse(r,o,i)}else;}}}const t=this.entryPath,r={stdio:["pipe","pipe","pipe","ipc"],cwd:this.project.projectPath,env:Object.assign(Object.assign({},process.env),{cpprocessEnv:"childprocess",nativeProcess:"1",timeout:global.TEST_COMPILER_PROCESS_TIMEOUT})};(0,debug_1.shouldInspectCompiler)()&&(r.execArgv=["--inspect-brk="+this.inspectPort]);const o=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname;if(r.env.isDevtools=o,o){let s=path_1.default.join(path_1.default.dirname(process.execPath),"node");"darwin"!==process.platform&&(s+=".exe"),r.execPath=s}return performanceMark("fork process"),new Promise((s,i)=>{const a=(0,child_process_1.fork)(t,["--expose-gc"],r),n=setTimeout(()=>{this.destroy(),i(new Error("fork process timeout"))},2e4);return a.stdout.setEncoding("utf8"),a.stdout.on("data",s=>{console.log("child process stdout: "+s)}),a.stderr.on("data",s=>{console.error("child process stderr: "+s)}),a.on("exit",(s,e)=>{this.process=void 0,this._checkReadyTask=void 0,o&&console.error(`child process exit: code(${s}), signal(${e})`),0!==s&&i(new Error(`native child process exit: code(${s}), signal(${e})`))}),a.on("message",e=>{if("ready"===e.type&&(clearTimeout(n),performanceMark("process ready"),s(a)),"noReady"===e.type&&(performanceMark("process not ready"),i(new Error(e.error.message))),"progress"===e.type){const s=this.taskMap.get(e.taskId);(null==s?void 0:s.progressUpdate)&&s.progressUpdate(e.id,e.status,e.message)}if("response"===e.type){const{id:s,data:t,error:r}=e;r?this.onResponse(s,void 0,r):this.onResponse(s,t,void 0)}}),a.unref(),this.taskId+=1,a.send(e),a})}onResponse(s,e,t){const r=this.taskMap.get(s);this.taskMap.delete(s),r?t?(t=new customError_1.CustomError(t),r.reject(t)):r.resolve(e):console.error(`child process task: ${s} not found`)}async sendEvent(s,e){this.sendProcessMessage({type:"event",name:s,data:e})}async runTask(s,e,t){return new Promise((r,o)=>{const i={name:s,data:e,resolve:r,reject:o,progressUpdate:t};this.taskId+=1,this.taskMap.set(this.taskId,i),this.sendProcessMessage({type:"request",id:this.taskId,name:s,data:e})})}}exports.SubProcessProxy=SubProcessProxy;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkIsUseCompilerPlugins=exports.isGameApp=exports.isLeftSubPathOfRight=exports.pathRelative=exports.compareVersion=exports.unifyPath=exports.getWorkersPath=exports.getPluginJson=exports.getAppJson=exports.getTerm=exports.checkIsIndependentSubpackage=exports.checkIsInSubPackage=exports.devtoolsError=exports.devtoolsLog=exports.devtoolsInfo=exports.formatTime=exports.formatNumber=exports.generateMD5=exports.formatSourceMap=exports.isFileIncluded=exports.isFileIgnored=exports.leading=exports.trailing=exports.escapeQuot=exports.mkdirSync=exports.rmSync=exports.isHexColor=exports.formatJSONParseErr=exports.bufferToUtf8String=exports.getType=exports.wrapCodeByEval=exports.escapeScript=exports.normalizePath=void 0;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),crypto_1=tslib_1.__importDefault(require("crypto")),babel_code_frame_1=tslib_1.__importDefault(require("babel-code-frame")),minimatch_1=tslib_1.__importDefault(require("minimatch")),startWith_1=tslib_1.__importDefault(require("licia/startWith")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),lodash_1=tslib_1.__importDefault(require("lodash")),define_1=require("../config/define"),types_1=require("../types"),jsonlint=require("./jsonlint");function normalizePath(e=""){const t=path_1.default.posix.normalize(e.replace(/\\/g,"/"));return!e.startsWith("//")&&!e.startsWith("\\\\")||t.startsWith("//")?t:"/"+t}function escapeScript(e){return e?e.replace(/<script/g,"&lt;script").replace(/<\/script/g,"&lt;/script"):e}function wrapCodeByEval(e){return`;(window.eval || __global.__hackEval)('${e}')`}function getType(e){return Object.prototype.toString.call(e).toLowerCase().split(" ")[1].replace("]","")}exports.normalizePath=normalizePath,exports.escapeScript=escapeScript,exports.wrapCodeByEval=wrapCodeByEval,exports.getType=getType;const bufferToUtf8String=e=>{const t=e.toString();if(0===Buffer.compare(Buffer.from(t,"utf8"),e))return t};function getErrLine(e,t,r,o){r=r>0?r:1;return`${o}\n${(0,babel_code_frame_1.default)(e,t,r)}`}exports.bufferToUtf8String=bufferToUtf8String;const formatJSONParseErr=e=>{const t=e.data||"";try{jsonlint.parser.parse(t)}catch(r){try{const o=`Expecting ${r.expected}, got ${r.token}`,n=getErrLine(t,r.line,r.loc.first_column,o);return`${e.filePath}\n${n}`}catch(e){}}return`${e.filePath}\n${e.error}`};exports.formatJSONParseErr=formatJSONParseErr;const isHexColor=e=>/^#[a-f\d]{3}$/i.test(e)||/^#[a-f\d]{4}$/i.test(e)||/^#[a-f\d]{6}$/i.test(e)||/^#[a-f\d]{8}$/i.test(e);function rmSync(e){try{if(e=path_1.default.resolve(e),!fs_1.default.existsSync(e))return;if(fs_1.default.lstatSync(e).isDirectory()){const t=fs_1.default.readdirSync(e);if(t.length>0)for(let r=0,o=t.length;r<o;r++)rmSync(path_1.default.posix.join(e,t[r]));fs_1.default.rmdirSync(e)}else fs_1.default.unlinkSync(e)}catch(e){}}function mkdirSync(e){if(e=path_1.default.resolve(e),fs_1.default.existsSync(e)){if(fs_1.default.lstatSync(e).isDirectory())return;fs_1.default.unlinkSync(e)}mkdirSync(path_1.default.dirname(e)),fs_1.default.mkdirSync(e)}function escapeQuot(e,t="`"){return e?"`"===t?e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$"):'"'===t?e.replace(/\\/g,"\\\\").replace(/\r\n/g,"\n").replace(/\n/g,"\\n").replace(/"/g,'\\"'):"'"===t?e.replace(/\\/g,"\\\\").replace(/\r\n/g,"\n").replace(/\n/g,"\\n").replace(/'/g,"\\'"):e:e}function trailing(e,t,r=!1){return r?e.endsWith(t)?e.slice(0,e.length-1):e:e.endsWith(t)?e:e+t}function leading(e,t,r=!1){return r?e.startsWith(t)?e.slice(1):e:e.startsWith(t)?e:t+e}exports.isHexColor=isHexColor,exports.rmSync=rmSync,exports.mkdirSync=mkdirSync,exports.escapeQuot=escapeQuot,exports.trailing=trailing,exports.leading=leading;const FFSPRGRulesFactory=function(e){let t=null,r=Object.create(null);return function(e,o){if(o.length<1)return!1;if(t===o){if(void 0!==r[e])return r[e]}else t=o,r=Object.create(null);const n=e.replace(/\\/g,"/").toLowerCase();if(!n)return!1;const i=n.slice(n.lastIndexOf("/")+1);let s=!1;for(const e of o){if(!e)continue;const t=e.value.toLowerCase();if("prefix"===e.type)s=i.startsWith(t);else if("suffix"===e.type)s=i.endsWith(t);else if("folder"===e.type)s=leading(n,"/").startsWith(trailing(leading(t,"/"),"/"));else if("file"===e.type)s=leading(n,"/")===leading(t,"/");else if("glob"===e.type)try{s=(0,minimatch_1.default)(n,t)||(0,minimatch_1.default)(leading(n,"/"),t)}catch(e){s=!1}else if("regexp"===e.type)try{s=new RegExp(t,"igm").test(n)||new RegExp(t,"igm").test(leading(n,"/"))}catch(e){s=!1}if(s)break}return r[e]=s,s}};function formatSourceMap(e){if(e){if("string"===getType(e))return e;try{return JSON.stringify(e)}catch(e){}}}function generateMD5(e){const t=crypto_1.default.createHash("md5");return t.update(e),t.digest("hex")}exports.isFileIgnored=FFSPRGRulesFactory(),exports.isFileIncluded=FFSPRGRulesFactory(),exports.formatSourceMap=formatSourceMap,exports.generateMD5=generateMD5;const formatNumber=e=>e>9?""+e:"0"+e;exports.formatNumber=formatNumber;const formatTime=e=>{const t=e.getFullYear(),r=e.getMonth()+1,o=e.getDate(),n=e.getHours(),i=e.getMinutes(),s=e.getSeconds();return`${[t,r,o].map(exports.formatNumber).join("/")} ${[n,i,s].map(exports.formatNumber).join(":")}`};exports.formatTime=formatTime;const isDevtools=process.__nwjs&&window.nw&&"wechatwebdevtools"===nw.App.manifest.appname;function devtoolsInfo(...e){isDevtools&&console.info(...e)}function devtoolsLog(...e){isDevtools&&console.log(...e)}function devtoolsError(...e){isDevtools&&console.error(...e)}function getPluginByAliasOrProvider(e,t){if(e){const r=e[t];if(r)return{alias:t,provider:r.provider,version:r.version};for(const r in e){const o=e[r];if(o.provider===t)return{alias:r,provider:o.provider,version:o.version}}}}function checkPluginByAliasOrProvider(e,t){let r;if(e.subPackages)for(const o of e.subPackages)if(r=getPluginByAliasOrProvider(o.plugins,t),r)return Object.assign(Object.assign({},r),{config:o});if(r=getPluginByAliasOrProvider(e.plugins,t),r)return r}function checkIsInSubPackage(e,t=""){let r;if((0,startWith_1.default)(t,"plugin://")){const r=t.match(/^plugin:\/\/([^/]*)\/(.*)/),o=null==r?void 0:r[1];if(!o)return;const n=checkPluginByAliasOrProvider(e,o);return null==n?void 0:n.config}if(e.subPackages)for(let o=0,n=e.subPackages.length;o<n;o++){const n=e.subPackages[o];if(t.startsWith(n.root)){r=n;break}}return r}function checkIsIndependentSubpackage(e,t){const r=checkIsInSubPackage(e,t);if(r&&!0===r.independent)return r}function getTerm(){if(!!!(null===window||void 0===window?void 0:window.nw))return require("terminal-kit").terminal}function getTargetPlatformJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=Object.values(define_1.PLATFORM),o=fs_extra_1.default.readJsonSync(e),n=lodash_1.default.omit(o,r);return lodash_1.default.merge(n,o[t]||("mini-weixin"===t?o["mini-wechat"]:{}))}function getAppJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=path_1.default.join(e.projectPath,e.miniprogramRoot||"","app.json");if(!fs_extra_1.default.existsSync(r))throw Error("no found app.json");return getTargetPlatformJson(r,t)}function getPluginJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=path_1.default.join(e.projectPath,e.pluginRoot||"","plugin.json");if(!fs_extra_1.default.existsSync(r))throw Error("no found plugin.json");return getTargetPlatformJson(r,t)}exports.devtoolsInfo=devtoolsInfo,exports.devtoolsLog=devtoolsLog,exports.devtoolsError=devtoolsError,exports.checkIsInSubPackage=checkIsInSubPackage,exports.checkIsIndependentSubpackage=checkIsIndependentSubpackage,exports.getTerm=getTerm,exports.getAppJson=getAppJson,exports.getPluginJson=getPluginJson;const getWorkersPath=e=>"string"==typeof e?e:e.path;exports.getWorkersPath=getWorkersPath;const unifyPath=e=>e.replace(/\\/g,"/");exports.unifyPath=unifyPath;const compareVersion=(e,t)=>{e=e.split("."),t=t.split(".");const r=Math.max(e.length,t.length);for(;e.length<r;)e.push("0");for(;t.length<r;)t.push("0");for(let o=0;o<r;o++){const r=parseInt(e[o],10),n=parseInt(t[o],10);if(r>n)return 1;if(r<n)return-1}return 0};exports.compareVersion=compareVersion;const pathRelative=(e,t)=>(e=path_1.default.posix.normalize(e.replace(/\\/g,"/")),t=path_1.default.posix.normalize(t.replace(/\\/g,"/")),path_1.default.posix.relative(e,t));function _isLeftSubPathOfRight(e,t){if(!t)return!0;if(t=normalizePath(t),e=normalizePath(e),!t.endsWith("/")){if(e===t)return!0;t+="/"}return!!e.startsWith(t)}function isLeftSubPathOfRight(e,t){void 0===e&&(console.error(new Error("The child string is undefined here, please check!!")),e="");const r=e.startsWith(t),o=_isLeftSubPathOfRight(e,t);return r!==o&&console.error(new Error(`${e} ${t} difference check sub path here! new result: ${o}`)),o}function isGameApp(e){return e.type===types_1.EProjectType.miniGame||e.type===types_1.EProjectType.miniGamePlugin}exports.pathRelative=pathRelative,exports.isLeftSubPathOfRight=isLeftSubPathOfRight,exports.isGameApp=isGameApp;const checkIsUseCompilerPlugins=()=>!0;exports.checkIsUseCompilerPlugins=checkIsUseCompilerPlugins;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.sourcePathToTargetPath=exports.checkIsUseCompilerPlugins=exports.isGameApp=exports.isLeftSubPathOfRight=exports.pathRelative=exports.compareVersion=exports.unifyPath=exports.getWorkersPath=exports.getPluginJson=exports.getAppJson=exports.getTerm=exports.checkIsIndependentSubpackage=exports.checkIsInSubPackage=exports.devtoolsError=exports.devtoolsLog=exports.devtoolsInfo=exports.formatTime=exports.formatNumber=exports.generateMD5=exports.formatSourceMap=exports.isFileIncluded=exports.isFileIgnored=exports.leading=exports.trailing=exports.escapeQuot=exports.mkdirSync=exports.rmSync=exports.isHexColor=exports.formatJSONParseErr=exports.bufferToUtf8String=exports.getType=exports.wrapCodeByEval=exports.escapeScript=exports.normalizePath=void 0;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),crypto_1=tslib_1.__importDefault(require("crypto")),babel_code_frame_1=tslib_1.__importDefault(require("babel-code-frame")),minimatch_1=tslib_1.__importDefault(require("minimatch")),startWith_1=tslib_1.__importDefault(require("licia/startWith")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),lodash_1=tslib_1.__importDefault(require("lodash")),define_1=require("../config/define"),types_1=require("../types"),jsonlint=require("./jsonlint");function normalizePath(e=""){const t=path_1.default.posix.normalize(e.replace(/\\/g,"/"));return!e.startsWith("//")&&!e.startsWith("\\\\")||t.startsWith("//")?t:"/"+t}function escapeScript(e){return e?e.replace(/<script/g,"&lt;script").replace(/<\/script/g,"&lt;/script"):e}function wrapCodeByEval(e){return`;(window.eval || __global.__hackEval)('${e}')`}function getType(e){return Object.prototype.toString.call(e).toLowerCase().split(" ")[1].replace("]","")}exports.normalizePath=normalizePath,exports.escapeScript=escapeScript,exports.wrapCodeByEval=wrapCodeByEval,exports.getType=getType;const bufferToUtf8String=e=>{const t=e.toString();if(0===Buffer.compare(Buffer.from(t,"utf8"),e))return t};function getErrLine(e,t,r,o){r=r>0?r:1;return`${o}\n${(0,babel_code_frame_1.default)(e,t,r)}`}exports.bufferToUtf8String=bufferToUtf8String;const formatJSONParseErr=e=>{const t=e.data||"";try{jsonlint.parser.parse(t)}catch(r){try{const o=`Expecting ${r.expected}, got ${r.token}`,s=getErrLine(t,r.line,r.loc.first_column,o);return`${e.filePath}\n${s}`}catch(e){}}return`${e.filePath}\n${e.error}`};exports.formatJSONParseErr=formatJSONParseErr;const isHexColor=e=>/^#[a-f\d]{3}$/i.test(e)||/^#[a-f\d]{4}$/i.test(e)||/^#[a-f\d]{6}$/i.test(e)||/^#[a-f\d]{8}$/i.test(e);function rmSync(e){try{if(e=path_1.default.resolve(e),!fs_1.default.existsSync(e))return;if(fs_1.default.lstatSync(e).isDirectory()){const t=fs_1.default.readdirSync(e);if(t.length>0)for(let r=0,o=t.length;r<o;r++)rmSync(path_1.default.posix.join(e,t[r]));fs_1.default.rmdirSync(e)}else fs_1.default.unlinkSync(e)}catch(e){}}function mkdirSync(e){if(e=path_1.default.resolve(e),fs_1.default.existsSync(e)){if(fs_1.default.lstatSync(e).isDirectory())return;fs_1.default.unlinkSync(e)}mkdirSync(path_1.default.dirname(e)),fs_1.default.mkdirSync(e)}function escapeQuot(e,t="`"){return e?"`"===t?e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$"):'"'===t?e.replace(/\\/g,"\\\\").replace(/\r\n/g,"\n").replace(/\n/g,"\\n").replace(/"/g,'\\"'):"'"===t?e.replace(/\\/g,"\\\\").replace(/\r\n/g,"\n").replace(/\n/g,"\\n").replace(/'/g,"\\'"):e:e}function trailing(e,t,r=!1){return r?e.endsWith(t)?e.slice(0,e.length-1):e:e.endsWith(t)?e:e+t}function leading(e,t,r=!1){return r?e.startsWith(t)?e.slice(1):e:e.startsWith(t)?e:t+e}exports.isHexColor=isHexColor,exports.rmSync=rmSync,exports.mkdirSync=mkdirSync,exports.escapeQuot=escapeQuot,exports.trailing=trailing,exports.leading=leading;const FFSPRGRulesFactory=function(e){let t=null,r=Object.create(null);return function(e,o){if(o.length<1)return!1;if(t===o){if(void 0!==r[e])return r[e]}else t=o,r=Object.create(null);const s=e.replace(/\\/g,"/").toLowerCase();if(!s)return!1;const n=s.slice(s.lastIndexOf("/")+1);let i=!1;for(const e of o){if(!e)continue;const t=e.value.toLowerCase();if("prefix"===e.type)i=n.startsWith(t);else if("suffix"===e.type)i=n.endsWith(t);else if("folder"===e.type)i=leading(s,"/").startsWith(trailing(leading(t,"/"),"/"));else if("file"===e.type)i=leading(s,"/")===leading(t,"/");else if("glob"===e.type)try{i=(0,minimatch_1.default)(s,t)||(0,minimatch_1.default)(leading(s,"/"),t)}catch(e){i=!1}else if("regexp"===e.type)try{i=new RegExp(t,"igm").test(s)||new RegExp(t,"igm").test(leading(s,"/"))}catch(e){i=!1}if(i)break}return r[e]=i,i}};function formatSourceMap(e){if(e){if("string"===getType(e))return e;try{return JSON.stringify(e)}catch(e){}}}function generateMD5(e){const t=crypto_1.default.createHash("md5");return t.update(e),t.digest("hex")}exports.isFileIgnored=FFSPRGRulesFactory(),exports.isFileIncluded=FFSPRGRulesFactory(),exports.formatSourceMap=formatSourceMap,exports.generateMD5=generateMD5;const formatNumber=e=>e>9?""+e:"0"+e;exports.formatNumber=formatNumber;const formatTime=e=>{const t=e.getFullYear(),r=e.getMonth()+1,o=e.getDate(),s=e.getHours(),n=e.getMinutes(),i=e.getSeconds();return`${[t,r,o].map(exports.formatNumber).join("/")} ${[s,n,i].map(exports.formatNumber).join(":")}`};exports.formatTime=formatTime;const isDevtools=process.__nwjs&&window.nw&&"wechatwebdevtools"===nw.App.manifest.appname;function devtoolsInfo(...e){isDevtools&&console.info(...e)}function devtoolsLog(...e){isDevtools&&console.log(...e)}function devtoolsError(...e){isDevtools&&console.error(...e)}function getPluginByAliasOrProvider(e,t){if(e){const r=e[t];if(r)return{alias:t,provider:r.provider,version:r.version};for(const r in e){const o=e[r];if(o.provider===t)return{alias:r,provider:o.provider,version:o.version}}}}function checkPluginByAliasOrProvider(e,t){let r;if(e.subPackages)for(const o of e.subPackages)if(r=getPluginByAliasOrProvider(o.plugins,t),r)return Object.assign(Object.assign({},r),{config:o});if(r=getPluginByAliasOrProvider(e.plugins,t),r)return r}function checkIsInSubPackage(e,t=""){let r;if((0,startWith_1.default)(t,"plugin://")){const r=t.match(/^plugin:\/\/([^/]*)\/(.*)/),o=null==r?void 0:r[1];if(!o)return;const s=checkPluginByAliasOrProvider(e,o);return null==s?void 0:s.config}if(e.subPackages)for(let o=0,s=e.subPackages.length;o<s;o++){const s=e.subPackages[o];if(t.startsWith(s.root)){r=s;break}}return r}function checkIsIndependentSubpackage(e,t){const r=checkIsInSubPackage(e,t);if(r&&!0===r.independent)return r}function getTerm(){if(!!!(null===window||void 0===window?void 0:window.nw))return require("terminal-kit").terminal}function getTargetPlatformJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=Object.values(define_1.PLATFORM),o=fs_extra_1.default.readJsonSync(e),s=lodash_1.default.omit(o,r);return lodash_1.default.merge(s,o[t]||("mini-weixin"===t?o["mini-wechat"]:{}))}function getAppJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=path_1.default.join(e.projectPath,e.miniprogramRoot||"","app.json");if(!fs_extra_1.default.existsSync(r))throw Error("no found app.json");return getTargetPlatformJson(r,t)}function getPluginJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=path_1.default.join(e.projectPath,e.pluginRoot||"","plugin.json");if(!fs_extra_1.default.existsSync(r))throw Error("no found plugin.json");return getTargetPlatformJson(r,t)}exports.devtoolsInfo=devtoolsInfo,exports.devtoolsLog=devtoolsLog,exports.devtoolsError=devtoolsError,exports.checkIsInSubPackage=checkIsInSubPackage,exports.checkIsIndependentSubpackage=checkIsIndependentSubpackage,exports.getTerm=getTerm,exports.getAppJson=getAppJson,exports.getPluginJson=getPluginJson;const getWorkersPath=e=>"string"==typeof e?e:e.path;exports.getWorkersPath=getWorkersPath;const unifyPath=e=>e.replace(/\\/g,"/");exports.unifyPath=unifyPath;const compareVersion=(e,t)=>{e=e.split("."),t=t.split(".");const r=Math.max(e.length,t.length);for(;e.length<r;)e.push("0");for(;t.length<r;)t.push("0");for(let o=0;o<r;o++){const r=parseInt(e[o],10),s=parseInt(t[o],10);if(r>s)return 1;if(r<s)return-1}return 0};exports.compareVersion=compareVersion;const pathRelative=(e,t)=>(e=path_1.default.posix.normalize(e.replace(/\\/g,"/")),t=path_1.default.posix.normalize(t.replace(/\\/g,"/")),path_1.default.posix.relative(e,t));function _isLeftSubPathOfRight(e,t){if(!t)return!0;if(t=normalizePath(t),e=normalizePath(e),!t.endsWith("/")){if(e===t)return!0;t+="/"}return!!e.startsWith(t)}function isLeftSubPathOfRight(e,t){void 0===e&&(console.error(new Error("The child string is undefined here, please check!!")),e="");const r=e.startsWith(t),o=_isLeftSubPathOfRight(e,t);return r!==o&&console.error(new Error(`${e} ${t} difference check sub path here! new result: ${o}`)),o}function isGameApp(e){return e.type===types_1.EProjectType.miniGame||e.type===types_1.EProjectType.miniGamePlugin}exports.pathRelative=pathRelative,exports.isLeftSubPathOfRight=isLeftSubPathOfRight,exports.isGameApp=isGameApp;const checkIsUseCompilerPlugins=()=>!0;exports.checkIsUseCompilerPlugins=checkIsUseCompilerPlugins;const sourceExt2TargetExtConf={".ts":".js",".less":".wxss",".sass":".wxss",".scss":".wxss"},sourcePathToTargetPath=e=>{const t=path_1.default.extname(e);return sourceExt2TargetExtConf[t]?e.substr(0,e.length-t.length)+sourceExt2TargetExtConf[t]:e};exports.sourcePathToTargetPath=sourcePathToTargetPath;