miniprogram-ci 2.0.5 → 2.0.6

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ #### 2.0.6
2
+ - `fix` 修复 未设置 onProgressUpdate 输出日志为[object Object]的问题
1
3
  #### 2.0.5
2
4
  - `fix` 修复 命令行执行完不退出的问题
3
5
  - `fix` 修复 输出日志为[object Object]的问题
package/README.md CHANGED
@@ -8,6 +8,8 @@ miniprogram-ci 从 1.0.28 开始支持第三方平台开发的上传和预览,
8
8
 
9
9
  ## 最近变更
10
10
 
11
+ #### 2.0.6
12
+ - `fix` 修复 未设置 onProgressUpdate 输出日志为[object Object]的问题
11
13
  #### 2.0.5
12
14
  - `fix` 修复 命令行执行完不退出的问题
13
15
  - `fix` 修复 输出日志为[object Object]的问题
@@ -1,5 +1,5 @@
1
1
  import { IProject } from '../types';
2
- export declare const CI_VERSION = "2.0.5";
2
+ export declare const CI_VERSION = "2.0.6";
3
3
  export declare const PARAM_ERROR = 10000;
4
4
  export declare const WXML_NOT_FOUND = 10007;
5
5
  export declare const JS_NOT_FOUND = 10008;
package/dist/ci/upload.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.innerUpload=exports.upload=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),log=tslib_1.__importStar(require("../utils/log")),request_1=require("../utils/request"),pack_1=require("./utils/pack"),zlib_1=tslib_1.__importDefault(require("zlib")),sign_1=require("../utils/sign"),tools_1=require("../utils/tools"),config_1=require("../config/config"),taskstatus_1=require("../utils/taskstatus"),error_1=require("../utils/error"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),querystring_1=tslib_1.__importDefault(require("querystring")),url_config_1=require("../config/url.config"),jsonParse_1=require("../utils/jsonParse"),cache_1=require("../utils/cache"),cos_upload_1=require("./cos-upload"),filterUnusedFile_1=require("./utils/filterUnusedFile"),getcompiler_1=require("./getcompiler"),tools_2=require("./utils/tools");exports.SIGNATURE_FILE_NAME="ci.signature";const MIN_COS_UPLOAD_SIZE=5242880;async function upload(e){var o;const t=await innerUpload(e);return(null===(o=t.respBody)||void 0===o?void 0:o.dev_plugin_id)&&(log.log("Development Version Plugin ID: "+t.respBody.dev_plugin_id),t.devPluginId=t.respBody.dev_plugin_id),{subPackageInfo:t.subPackageInfo,pluginInfo:t.pluginInfo,devPluginId:t.devPluginId}}async function innerUpload(e){const{project:o,setting:t={useProjectConfig:!1},desc:r=`robot ${e.robot||"1"} use miniprogram-ci to upload at ${(0,tools_1.formatTime)(new Date)}`,version:i="",robot:s="1",onProgressUpdate:n=function(e){console.log(""+e)},test:a,pagePath:l,searchQuery:u,threads:p=0,bigPackageSizeSupport:c,allowIgnoreUnusedFiles:d=!0}=e;let{useCOS:_}=e;if(process.env.COMPILE_THREADS=p.toString(),!i)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("upload","version"),config_1.PARAM_ERROR);if(!o)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("upload","project"),config_1.PARAM_ERROR);cache_1.cacheManager.clean();const g=await(0,getcompiler_1.getCompiler)(o,t),f=(0,tools_2.formatCISetting)(o,t);let b=await g.compile({setting:f,onProgressUpdate:n,resultType:"prod"});!1!==d&&(b=await(0,filterUnusedFile_1.filterUnusedFile)(!!a,o,b));const y=config_1.CI_VERSION,S={codeprotect:t.codeProtect?1:0,type:o.type,appid:o.appid,version:i,desc:r,robot:s},q={scene:e.scene||1011};let P;l&&(q.path=l,S.path=l),u&&(q.query=querystring_1.default.parse(u)),S.debugLaunchInfo=JSON.stringify(q),l&&u&&(S.path+="?"+u),a&&c&&(S.bigPackageSizeSupport=1);let R={};try{P=await o.getFile(o.miniprogramRoot,"ext.json"),R=JSON.parse(P.toString("utf-8"))}catch(e){}if(R&&(R.extEnable&&(S.extAppId=R.extAppid),R.directCommit)){let e="";e=R.extEnable?"The code will be uploaded into the waiting list of extAppid.":"The code will be uploaded into the draft box of the third-party platform.",log.warn(e)}try{const e=new taskstatus_1.TaskStatus(locales_1.default.config.UPLOAD.toString());n(e);const t=`${a?url_config_1.TEST_SOURCE_URL:url_config_1.UPLOAD_URL}?${querystring_1.default.stringify(S)}`;let r,i=!1,l=0;const u=(0,pack_1.pack)(b),p=zlib_1.default.gzipSync(u.buffer);if(log.info("useCOS parameter: ",_),log.info("upload zip buffer size: ",p.length),void 0===_&&(_=p.length>5242880),_){log.info("upload by COS: ",_);const e=await(0,cos_upload_1.uploadByCos)(p,t,o,s);e.fallback?(i=e.fallback,log.info("upload by COS failed, fallback to http way")):(r={body:e.body},l=e.uploadCOSCostTime)}if(!_||i){const e=await(0,sign_1.getSignature)(o.privateKey,o.appid);b[exports.SIGNATURE_FILE_NAME]=JSON.stringify({signature:e,version:y});const i=(0,pack_1.pack)(b),s=zlib_1.default.gzipSync(i.buffer);log.info("request url:",t);const n=(await(0,request_1.request)({url:t,method:"post",body:s})).body.toString();if(r=(0,jsonParse_1.jsonRespParse)(n,t),0!==r.errCode)throw new Error(n)}e.done(),n(e);const c={respBody:r.body};if(Array.isArray(r.body.subpackage_info)){const e=r.body.subpackage_info;c.subPackageInfo=e}if(Array.isArray(r.body.ext_plugin_info)){const e=r.body.ext_plugin_info;c.pluginInfo=e.map(e=>({pluginProviderAppid:e.provider,version:e.version,size:e.size}))}return c}catch(e){throw new error_1.CodeError(e.toString(),config_1.UPLOAD_CGI_ERR)}}exports.upload=upload,exports.innerUpload=innerUpload;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.innerUpload=exports.upload=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),log=tslib_1.__importStar(require("../utils/log")),request_1=require("../utils/request"),pack_1=require("./utils/pack"),zlib_1=tslib_1.__importDefault(require("zlib")),sign_1=require("../utils/sign"),tools_1=require("../utils/tools"),config_1=require("../config/config"),taskstatus_1=require("../utils/taskstatus"),error_1=require("../utils/error"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),querystring_1=tslib_1.__importDefault(require("querystring")),url_config_1=require("../config/url.config"),jsonParse_1=require("../utils/jsonParse"),cache_1=require("../utils/cache"),cos_upload_1=require("./cos-upload"),filterUnusedFile_1=require("./utils/filterUnusedFile"),getcompiler_1=require("./getcompiler"),tools_2=require("./utils/tools");exports.SIGNATURE_FILE_NAME="ci.signature";const MIN_COS_UPLOAD_SIZE=5242880;async function upload(e){var o;const t=await innerUpload(e);return(null===(o=t.respBody)||void 0===o?void 0:o.dev_plugin_id)&&(log.log("Development Version Plugin ID: "+t.respBody.dev_plugin_id),t.devPluginId=t.respBody.dev_plugin_id),{subPackageInfo:t.subPackageInfo,pluginInfo:t.pluginInfo,devPluginId:t.devPluginId}}async function innerUpload(e){const{project:o,setting:t={useProjectConfig:!1},desc:r=`robot ${e.robot||"1"} use miniprogram-ci to upload at ${(0,tools_1.formatTime)(new Date)}`,version:i="",robot:s="1",onProgressUpdate:n=function(e){if("object"==typeof e)try{const o=JSON.stringify(e);return void console.log(o)}catch(e){}console.log(""+e)},test:l,pagePath:a,searchQuery:u,threads:p=0,bigPackageSizeSupport:c,allowIgnoreUnusedFiles:d=!0}=e;let{useCOS:_}=e;if(process.env.COMPILE_THREADS=p.toString(),!i)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("upload","version"),config_1.PARAM_ERROR);if(!o)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("upload","project"),config_1.PARAM_ERROR);cache_1.cacheManager.clean();const g=await(0,getcompiler_1.getCompiler)(o,t),f=(0,tools_2.formatCISetting)(o,t);let b=await g.compile({setting:f,onProgressUpdate:n,resultType:"prod"});!1!==d&&(b=await(0,filterUnusedFile_1.filterUnusedFile)(!!l,o,b));const y=config_1.CI_VERSION,S={codeprotect:t.codeProtect?1:0,type:o.type,appid:o.appid,version:i,desc:r,robot:s},q={scene:e.scene||1011};let P;a&&(q.path=a,S.path=a),u&&(q.query=querystring_1.default.parse(u)),S.debugLaunchInfo=JSON.stringify(q),a&&u&&(S.path+="?"+u),l&&c&&(S.bigPackageSizeSupport=1);let h={};try{P=await o.getFile(o.miniprogramRoot,"ext.json"),h=JSON.parse(P.toString("utf-8"))}catch(e){}if(h&&(h.extEnable&&(S.extAppId=h.extAppid),h.directCommit)){let e="";e=h.extEnable?"The code will be uploaded into the waiting list of extAppid.":"The code will be uploaded into the draft box of the third-party platform.",log.warn(e)}try{const e=new taskstatus_1.TaskStatus(locales_1.default.config.UPLOAD.toString());n(e);const t=`${l?url_config_1.TEST_SOURCE_URL:url_config_1.UPLOAD_URL}?${querystring_1.default.stringify(S)}`;let r,i=!1,a=0;const u=(0,pack_1.pack)(b),p=zlib_1.default.gzipSync(u.buffer);if(log.info("useCOS parameter: ",_),log.info("upload zip buffer size: ",p.length),void 0===_&&(_=p.length>5242880),_){log.info("upload by COS: ",_);const e=await(0,cos_upload_1.uploadByCos)(p,t,o,s);e.fallback?(i=e.fallback,log.info("upload by COS failed, fallback to http way")):(r={body:e.body},a=e.uploadCOSCostTime)}if(!_||i){const e=await(0,sign_1.getSignature)(o.privateKey,o.appid);b[exports.SIGNATURE_FILE_NAME]=JSON.stringify({signature:e,version:y});const i=(0,pack_1.pack)(b),s=zlib_1.default.gzipSync(i.buffer);log.info("request url:",t);const n=(await(0,request_1.request)({url:t,method:"post",body:s})).body.toString();if(r=(0,jsonParse_1.jsonRespParse)(n,t),0!==r.errCode)throw new Error(n)}e.done(),n(e);const c={respBody:r.body};if(Array.isArray(r.body.subpackage_info)){const e=r.body.subpackage_info;c.subPackageInfo=e}if(Array.isArray(r.body.ext_plugin_info)){const e=r.body.ext_plugin_info;c.pluginInfo=e.map(e=>({pluginProviderAppid:e.provider,version:e.version,size:e.size}))}return c}catch(e){throw new error_1.CodeError(e.toString(),config_1.UPLOAD_CGI_ERR)}}exports.upload=upload,exports.innerUpload=innerUpload;
@@ -1 +1 @@
1
- "use strict";var COMPILE_TYPE,AstType;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.0.5",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.MINI_GAME_WORKERS_PACKAGE_ROOT="workers.js",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(e){e.miniProgram="miniProgram",e.miniProgramPlugin="miniProgramPlugin",e.miniGame="miniGame",e.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE=exports.COMPILE_TYPE||(exports.COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxCustomTabbarCount:10,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}},exports.multiPlatformRoot="miniapp",exports.MainPkg="__APP__",exports.FullPkg="__FULL__",exports.getDefaultIgnores=getDefaultIgnores,exports.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType=exports.AstType||(exports.AstType={}));
1
+ "use strict";var COMPILE_TYPE,AstType;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.0.6",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.MINI_GAME_WORKERS_PACKAGE_ROOT="workers.js",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(e){e.miniProgram="miniProgram",e.miniProgramPlugin="miniProgramPlugin",e.miniGame="miniGame",e.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE=exports.COMPILE_TYPE||(exports.COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxCustomTabbarCount:10,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}},exports.multiPlatformRoot="miniapp",exports.MainPkg="__APP__",exports.FullPkg="__FULL__",exports.getDefaultIgnores=getDefaultIgnores,exports.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType=exports.AstType||(exports.AstType={}));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.printFoundDevices=exports.formattedDeviceName=exports.matchingDevice=exports.findMatchingSimulator=exports.getDevices=exports.parseXctraceIOSDevicesList=void 0;const tslib_1=require("tslib"),execa=tslib_1.__importStar(require("execa")),env_1=require("../../../utils/env"),miniappBuilder=tslib_1.__importStar(require("../../../utils/miniapp-builder"));function parseIOSDevicesList(e){const i=[];return e.split("\n").forEach(e=>{const t=e.match(/(.*?) (\(([0-9.]+)\) )?\[([0-9A-F-]+)\]( \(Simulator\))?/i);if(t){const[,e,,r,n,s]=t,c={name:e,udid:n};r?(c.version=r,c.type=s?"simulator":"device"):c.type="catalyst",i.push(c)}}),i}function parseXctraceIOSDevicesList(e){const i=[];let t=!1;return-1===e.indexOf("== Simulators ==")?[]:(e.split("\n").forEach(e=>{"== Simulators =="===e&&(t=!0);const r=e.match(/(.*?) (\(([0-9.]+)\) )?\(([0-9A-F-]+)\)/i);if(r){const[,e,,n,s]=r,c={name:e,udid:s};n?(c.version=n,c.type=t?"simulator":"device"):c.type="catalyst",i.push(c)}}),i)}async function getDevices(e){let i=[];const{recorder:t}=e||{};try{const e=await execa.default("xcrun",["xctrace","list","devices"],{env:(0,env_1.getProcessEnv)()});i=parseXctraceIOSDevicesList(""===e.stderr?e.stdout:e.stderr)}catch(e){try{i=parseIOSDevicesList(execa.sync("xcrun",["instruments","-s"],{env:(0,env_1.getProcessEnv)()}).stdout)}catch(e){}}let r=i.filter(e=>"device"===e.type);if(!r.length)try{r=await miniappBuilder.getIOSDevices(e||{}),r.forEach(e=>{i.find(i=>i.udid===e.udid)||i.push(e)})}catch(e){t?t.progress("get Devices error:"+e.message):console.error("get Devices error:",e)}return i.filter(e=>!!e.version)}function findMatchingSimulator(e,i){if(!e.devices)return null;const{devices:t}=e;let r,n,s=null;if(null==i?void 0:i.device){const e=i.device.match(/(.*)? (?:\((\d+\.\d+)?\))$/);void 0!==(null==e?void 0:e[2])?(r=e[2],s=e[1]):s=i.device}for(const e in t){const c=t[e];let o=e;if(o.startsWith("com.apple.CoreSimulator.SimRuntime.")&&(o=o.replace(/^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g,"$1 $2.$3")),(o.includes("iOS")||o.includes("tvOS"))&&(!r||o.endsWith(r)))for(const e of c){if("(available)"!==e.availability&&"YES"!==e.isAvailable&&!0!==e.isAvailable)continue;const t="Booted"===e.state,r={udid:e.udid,name:e.name,booted:t,version:o};if(null==i?void 0:i.udid){if(e.udid===i.udid)return r}else{if(t&&null===s)return r;e.name!==s||n||(n=r)}}}return n}function matchingDevice(e,i,t){if(!0===i){const i=e.find(e=>"device"===e.type);return i?(t.progress(`Using first available device named "${i.name}" due to lack of name supplied.`),i):void t.progress("No iOS devices connected.")}const r=e.find(e=>e.name===i||formattedDeviceName(e)===i);if(!r)throw new Error(`Could not find a device named: "${String(i)} ${printFoundDevices(e)}}".`);return r}function formattedDeviceName(e){return e.version?`${e.name} (${e.version})`:e.name}function printFoundDevices(e){return["Available devices:",...e.map(e=>` - ${e.name} (${e.udid})`)].join("\n")}exports.parseXctraceIOSDevicesList=parseXctraceIOSDevicesList,exports.getDevices=getDevices,exports.findMatchingSimulator=findMatchingSimulator,exports.matchingDevice=matchingDevice,exports.formattedDeviceName=formattedDeviceName,exports.printFoundDevices=printFoundDevices;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.printFoundDevices=exports.formattedDeviceName=exports.matchingDevice=exports.findMatchingSimulator=exports.getDevices=exports.parseXctraceIOSDevicesList=void 0;const tslib_1=require("tslib"),execa=tslib_1.__importStar(require("execa")),env_1=require("../../../utils/env"),miniappBuilder=tslib_1.__importStar(require("../../../utils/miniapp-builder"));function parseIOSDevicesList(e){const i=[];return e.split("\n").forEach(e=>{const t=e.match(/(.*?) (\(([0-9.]+)\) )?\[([0-9A-F-]+)\]( \(Simulator\))?/i);if(t){const[,e,,r,n,s]=t,c={name:e,udid:n};r?(c.version=r,c.type=s?"simulator":"device"):c.type="catalyst",i.push(c)}}),i}function parseXctraceIOSDevicesList(e){const i=[];let t=!1;return e.split("\n").forEach(e=>{"== Simulators =="===e&&(t=!0);const r=e.match(/^(.*?) (\(([0-9.]{3,})\) )?\(([0-9A-F-]{5,})\)$/i);if(r){const[,e,,n,s]=r,c={name:e,udid:s};n?(c.version=n,c.type=t?"simulator":"device"):c.type="catalyst",i.push(c)}}),i}async function getDevices(e){let i=[];const{recorder:t}=e||{};try{const e=await execa.default("xcrun",["xctrace","list","devices"],{env:(0,env_1.getProcessEnv)()});i=parseXctraceIOSDevicesList(""===e.stderr?e.stdout:e.stderr)}catch(e){try{i=parseIOSDevicesList(execa.sync("xcrun",["instruments","-s"],{env:(0,env_1.getProcessEnv)()}).stdout)}catch(e){}}let r=i.filter(e=>"device"===e.type);if(!r.length)try{r=await miniappBuilder.getIOSDevices(e||{}),r.forEach(e=>{i.find(i=>i.udid===e.udid)||i.push(e)})}catch(e){t?t.progress("get Devices error:"+e.message):console.error("get Devices error:",e)}return i.filter(e=>!!e.version)}function findMatchingSimulator(e,i){if(!e.devices)return null;const{devices:t}=e;let r,n,s=null;if(null==i?void 0:i.device){const e=i.device.match(/(.*)? (?:\((\d+\.\d+)?\))$/);void 0!==(null==e?void 0:e[2])?(r=e[2],s=e[1]):s=i.device}for(const e in t){const c=t[e];let o=e;if(o.startsWith("com.apple.CoreSimulator.SimRuntime.")&&(o=o.replace(/^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g,"$1 $2.$3")),(o.includes("iOS")||o.includes("tvOS"))&&(!r||o.endsWith(r)))for(const e of c){if("(available)"!==e.availability&&"YES"!==e.isAvailable&&!0!==e.isAvailable)continue;const t="Booted"===e.state,r={udid:e.udid,name:e.name,booted:t,version:o};if(null==i?void 0:i.udid){if(e.udid===i.udid)return r}else{if(t&&null===s)return r;e.name!==s||n||(n=r)}}}return n}function matchingDevice(e,i,t){if(!0===i){const i=e.find(e=>"device"===e.type);return i?(t.progress(`Using first available device named "${i.name}" due to lack of name supplied.`),i):void t.progress("No iOS devices connected.")}const r=e.find(e=>e.name===i||formattedDeviceName(e)===i);if(!r)throw new Error(`Could not find a device named: "${String(i)} ${printFoundDevices(e)}}".`);return r}function formattedDeviceName(e){return e.version?`${e.name} (${e.version})`:e.name}function printFoundDevices(e){return["Available devices:",...e.map(e=>` - ${e.name} (${e.udid})`)].join("\n")}exports.parseXctraceIOSDevicesList=parseXctraceIOSDevicesList,exports.getDevices=getDevices,exports.findMatchingSimulator=findMatchingSimulator,exports.matchingDevice=matchingDevice,exports.formattedDeviceName=formattedDeviceName,exports.printFoundDevices=printFoundDevices;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miniprogram-ci",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Module that build miniprogram project for web or app extracted from WeChatDevtools.",
5
5
  "homepage": "https://developers.weixin.qq.com/community/homepage",
6
6
  "main": "dist/index.js",