miniprogram-ci 2.0.6 → 2.0.7
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 +2 -0
- package/dist/@types/config/config.d.ts +1 -1
- package/dist/@types/modules/corecompiler/baseCompiler.d.ts +1 -0
- package/dist/@types/modules/corecompiler/originalCompiler.d.ts +1 -0
- package/dist/@types/modules/corecompiler/summerCompiler.d.ts +1 -0
- package/dist/@types/types/devtools.d.ts +1 -0
- package/dist/config/config.js +1 -1
- package/dist/modules/corecompiler/summerCompiler.js +1 -1
- package/dist/schema/dist/app.js +4 -1
- package/dist/schema/dist/ext.js +4 -1
- package/dist/schema/dist/game.js +1 -1
- package/dist/schema/dist/page.js +1 -1
- package/dist/schema/dist/plugin.js +1 -1
- package/dist/schema/dist/pluginpage.js +1 -1
- package/dist/schema/dist/projectconfig.js +4 -1
- package/dist/schema/dist/projectprivateconfig.js +4 -1
- package/dist/schema/dist/sitemap.js +1 -1
- package/dist/schema/dist/theme.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -106,6 +106,7 @@ export declare abstract class BaseCoreCompiler {
|
|
|
106
106
|
}>;
|
|
107
107
|
abstract getPackageFiles(graphId: MiniProgramDevtools.GraphId, root: string): Promise<FileInfo[]>;
|
|
108
108
|
abstract getSubPkgSortedJSFiles(rootPath: string): Promise<{
|
|
109
|
+
entryJS: string;
|
|
109
110
|
allFiles: string[];
|
|
110
111
|
pageFiles: string[];
|
|
111
112
|
componentFiles: string[];
|
|
@@ -93,6 +93,7 @@ export declare class OriginalCompiler extends BaseCoreCompiler {
|
|
|
93
93
|
}>;
|
|
94
94
|
getPackageFiles(graphId: MiniProgramDevtools.GraphId, root: string): Promise<FileInfo[]>;
|
|
95
95
|
getSubPkgSortedJSFiles(_rootPath: string): Promise<{
|
|
96
|
+
entryJS: string;
|
|
96
97
|
allFiles: string[];
|
|
97
98
|
pageFiles: string[];
|
|
98
99
|
componentFiles: string[];
|
package/dist/config/config.js
CHANGED
|
@@ -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.
|
|
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.7",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.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),request_1=require("../../utils/request"),progressRecorder_1=require("../../utils/progressRecorder"),tools_1=require("../../utils/tools"),config_1=require("../../config/config"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),uglifyfilenames_1=require("./original/protect/uglifyfilenames"),index_1=require("./original/index"),baseCompiler_1=require("./baseCompiler"),miniProgram=config_1.COMPILE_TYPE.miniProgram,miniGame=config_1.COMPILE_TYPE.miniGame,miniProgramPlugin=config_1.COMPILE_TYPE.miniProgramPlugin,miniGamePlugin=config_1.COMPILE_TYPE.miniGamePlugin;function performanceMark(e,s){}class SummerCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e,s,t,i){super(e),this.project=e,this.cachePath=s,this.projectInfo=t,this.devtoolMessagehub=i,this.isSummer=!0,this.codeCache=new Map,this.promiseCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this.onFileChange=(e,s)=>{if("change"!==e||s.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);if("change"!==e)for(const e of this.promiseCache.keys())e.startsWith("getPackageFiles-")&&this.promiseCache.delete(e);this.invalidCodeCache(),this.subProcessManager.sendEvent("fileChange",{type:e,targetPath:s})},this.onPreCompileOptionsChange=async e=>{await this.clearCache(),this.subProcessManager.sendEvent("precompileOptionsChange",e)},this.onProgressUpdate=(e,s,t)=>{const i="doing"===s?"doing":"done"===s?"success":"error";this.messageHub.showBuildLog(""+e,i,t)},performanceMark("create summer compiler"),this.messageHub=new messageHub_1.MessageHub(i),this.ready()}get status(){return this._status}async init(){performanceMark("init summer compiler");const e=path_1.default.posix.join(__dirname,"./summerEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,e,{cachePath:this.cachePath},this.projectInfo,8891),this.addProjectListener(),this.loadStatus(),performanceMark("init summer compiler",!0)}async loadStatus(){this._status=await this.subProcessManager.runTask("loadStatus")}destroy(){var e;null===(e=this.subProcessManager)||void 0===e||e.destroy(),this.removeProjectListener(),this._checkReadyTask=void 0}async clearCache(){var e;await(null===(e=this.subProcessManager)||void 0===e?void 0:e.runTask("clearCache")),this.codeCache.clear(),this.promiseCache.clear()}updateOptions(e){var s;lodash_1.default.isEqual(e,this.projectInfo)||(this.projectInfo=e,this.promiseCache.clear(),this.codeCache.clear(),null===(s=this.subProcessManager)||void 0===s||s.sendEvent("updateOptions",e),this.loadStatus())}addProjectListener(){var e,s;this._eventAdded&&this.removeProjectListener(),null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),null===(s=this.project.event)||void 0===s||s.on("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!0}removeProjectListener(){var e,s;null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange),null===(s=this.project.event)||void 0===s||s.off("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!1}invalidCodeCache(){for(const e of this.codeCache.values())e.isValid=!1}async getConf(e){var s,t;const i="getConf-"+e;if(this.promiseCache.has(i))return(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.log(i,"hit cache"),this.promiseCache.get(i);(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(i,"do request"),performanceMark("request get conf");const r={graphId:e},o=this.subProcessManager.runTask("getConf",r,this.onProgressUpdate);return this.promiseCache.set(i,o),performanceMark("request get conf",!0),o}async getPackageFiles(e,s){var t,i;const r=`getPackageFiles-${e}-${s}`;if(this.promiseCache.has(r))return(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(r,"hit cache"),this.promiseCache.get(r);(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(r,"do request"),performanceMark("request get getPackageFiles");const o=this.subProcessManager.runTask("getPackageFiles",{graphId:e,root:s},this.onProgressUpdate);return this.promiseCache.set(r,o),performanceMark("request get getPackageFiles",!0),o}async getCode(e,s){var t,i,r;const o=`getCode-${e}${s?"-"+s.package:""}`;if(this.promiseCache.has(o))return(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(o,"hit promise cache"),this.promiseCache.get(o);const n=this.codeCache.get(o);if(null==n?void 0:n.isValid)return n.codeFiles;(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(o,"do request");const a={};if(n){const{codeFiles:e}=n;for(const s of Object.keys(e)){const t=e[s];"error"in t||(a[s]=t.md5)}}const c={graphId:e,cacheMd5:a,package:null==s?void 0:s.package};performanceMark("request get code");const l=Date.now();(null===(r=process.env)||void 0===r?void 0:r.isDevtools)&&(console.time("[summer-compiler] runTask "+o),console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] runTask ${o}`));const g=this.subProcessManager.runTask("getCode",c,this.onProgressUpdate).then(e=>{var s,t;(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.timeEnd("[summer-compiler] runTask "+o);const i=(null===(t=this.codeCache.get(o))||void 0===t?void 0:t.codeFiles)||{};for(const s of Object.keys(e)){const t=e[s];"error"in t||""!==t.md5?i[s]=t:delete i[s]}return this.codeCache.set(o,{isValid:!0,codeFiles:i}),i},e=>{throw e.code?console.error(e):console.error("Unexpected error when getCode",e),e});return g.finally(()=>{var e;performanceMark("request get code",!0),(null===(e=process.env)||void 0===e?void 0:e.isDevtools)&&console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] [cost ${Date.now()-l}ms] runTask ${o}`),this.promiseCache.delete(o)}),this.promiseCache.set(o,g),g}async getExtJSON(){return await(0,index_1.getExtJSON)(this.project)}async getAppJSON(){return(await this.getConf(miniProgram)).app}async getGameJSON(){return(await this.getConf(miniGame)).app}async getSiteMapJSON(){return(await this.getConf(miniProgram)).sitemap}async getPageJSON(e){const s=await this.getConf(miniProgram),t=s.pages[e]||s.comps[e];if(!t)throw new Error("summer-compiler 收集json配置有遗漏, "+e);return t}async getAllPageAndComponent(){const e=await this.getConf(miniProgram);return Object.keys(e.pages).concat(Object.keys(e.comps))}async getAllSortedJSFiles(){const e=await this.getConf(miniProgram),s=Object.keys(e.pages),t=Object.keys(e.comps),i=s.filter(e=>!t.includes(e)).map(e=>e+".js"),r=t.map(e=>e+".js"),o=await this.getCode(miniProgram,{package:config_1.FullPkg}),n=Object.keys(o).filter(e=>e.endsWith(".js")&&"app.js"!==e&&!i.includes(e)&&!r.includes(e));return{jsPagesFiles:i,components:r,otherJsFiles:n}}async getAllWxmlAndWxsFiles(){const e=await this.getCode(miniProgram,{package:config_1.FullPkg}),s=Object.keys(e).filter(e=>e.endsWith(".wxml")),t=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:s,wxsFiles:t,content:s.concat(t).reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async getPackageWxmlAndWxsFiles(e){let s=await this.getCode(miniProgram,{package:e});if(e!==config_1.MainPkg){const e=await this.getCode(miniProgram,{package:config_1.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxml")),i=Object.keys(s).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}async getPackageWxssFiles(e){let s=await this.getCode(miniProgram,{package:e});if(e!==config_1.MainPkg){const e=await this.getCode(miniProgram,{package:config_1.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxss"));return{wxssFiles:t,content:t.reduce((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}getWxssMap(e,s){s=(0,tools_1.normalizePath)(s);for(const[t,i]of this.codeCache.entries())if(t.startsWith("getCode-"+e)){const e=i.codeFiles[s];if(e&&!("error"in e))return e.map}}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniProgram),s=await this.getCode(miniProgram,{package:"__APP__"}),t=Object.keys(s).filter(e=>e.endsWith(".js")),i=[],r=[],o=[],n=[],a=[];let c=!1;const l={},g=s=>Object.keys(e.packages).find(e=>s.startsWith(e))||config_1.MainPkg;e.app.functionalPages&&t.forEach(e=>{if(e.startsWith("functional-pages/")){const s=e.replace(/\.js$/,"");if(l[s])return;l[s]=!0,a.push(encodeURI(s))}}),e.app.workers&&t.forEach(s=>{if(s.startsWith((0,tools_1.getWorkersPath)(e.app.workers))){const e=s.replace(/\.js$/,"");if(l[e])return;l[e]=!0,n.push(e)}});Object.keys(e.comps).filter(e=>g(e)===config_1.MainPkg).forEach(s=>{if((s.startsWith("miniprogram_npm/weui-miniprogram")||s.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(l[s])return;l[s]=!0;const t=encodeURI(s);o.push(""+t)});Object.keys(e.pages).filter(e=>g(e)===config_1.MainPkg).forEach(e=>{if(l[e])return;l[e]=!0;const s=encodeURI(e);i.push(""+s)}),t.forEach(e=>{const s=e.replace(/\.js$/,"");l[s]||(l[s]=!0,"app.js"!==e?r.push(""+encodeURI(s)):c=!0)});const h=[...r,...o,...i];return c&&h.push("app"),{hasAppJS:c,allFiles:h,pageFiles:i,componentFiles:o,workerFiles:n,functionalPageFiles:a,otherFiles:r}}async getSubPkgSortedJSFiles(e){const s=await this.getConf(miniProgram),t=await this.getCode(miniProgram,{package:e}),i=Object.keys(t).filter(e=>e.endsWith(".js")),r=[],o=[],n={},a=e=>Object.keys(s.packages).find(s=>e.startsWith(s))||config_1.MainPkg;Object.keys(s.comps).filter(s=>a(s)===e).forEach(e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&s.app.useExtendedLib&&s.app.useExtendedLib.weui)return;if(n[e])return;n[e]=!0;const t=encodeURI(e);o.push(""+t)});Object.keys(s.pages).filter(s=>a(s)===e).forEach(e=>{if(n[e])return;n[e]=!0;const s=encodeURI(e);r.push(""+s)});const c=i.map(e=>""+encodeURI(e.replace(/\.js$/,"")));return{allFiles:c,pageFiles:r,componentFiles:o,otherFiles:c.filter(e=>!r.includes(e)&&!o.includes(e))}}async compileJS(e){const s=this.project.type;let t;if(e.root===this.project.miniprogramRoot){const i=await this.getConf(this.isGameType(s)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram),r=Object.keys(i.packages).find(s=>e.filePath.startsWith(s))||config_1.MainPkg;t=(await this.getCode(this.isGameType(s)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram,{package:r,partialCompilePath:[]}))[e.filePath]}else{t=(await this.getCode(this.isGameType(s)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin))[e.filePath]}if(!t){const s=new Error(`summer-compiler miss ${e.root} js file, ${e.filePath}`);throw s.code="ENOENT",s}if("error"in t)throw t.error;return Object.assign({filePath:e.filePath,code:t.code,map:t.map},t.jsTag)}async compile(e){const s=await this.subProcessManager.runTask("compile",e,(s,t,i)=>{var r;null===(r=e.onProgressUpdate)||void 0===r||r.call(e,{id:s.toString(),status:t,message:i})});for(const e of Object.keys(s))"object"==typeof s[e]&&"Buffer"===s[e].type&&(s[e]=Buffer.from(s[e].data));return s}async getPluginJSON(e=""){return(await this.getConf(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin)).plugin}async getPluginPageJSON(e){const s=await this.getConf(miniProgramPlugin),t=s.pages[e]||s.comps[e];if(!t)throw new Error("summer-compiler 收集plugin json配置有遗漏, "+e);return t}async getPluginComponents(){const e=await this.getConf(miniProgramPlugin),s=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(s)}async getPluginJSFiles(){const e=await this.getCode(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin),s=Object.keys(e).filter(e=>e.endsWith(".js"));return{jsFiles:s,content:s.reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async getPluginWxssFiles(){const e=await this.getCode(miniProgramPlugin),s=Object.keys(e).filter(e=>e.endsWith(".wxss"));return{wxssFiles:s,content:s.reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async getPluginWxmlAndWxsFiles(){const e=await this.getCode(miniProgramPlugin),s=Object.keys(e).filter(e=>e.endsWith(".wxml")),t=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:s,wxsFiles:t,content:s.concat(t).reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async checkThemeJSON(e){return(await this.getConf(miniProgram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this._locale!==e&&(this._locale=e,this.subProcessManager.runTask("setLocale",e))}async uglifyFileNames(e,s,t){return await(0,uglifyfilenames_1.uglifyFileNames)(e,s,t)}async getMPFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgram)}async getPluginFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgramPlugin)}async getCompAndPagesOfConf(){const e=await this.getConf(miniProgram);return{pages:e.pages,comps:e.comps}}}exports.SummerCompiler=SummerCompiler;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),request_1=require("../../utils/request"),progressRecorder_1=require("../../utils/progressRecorder"),tools_1=require("../../utils/tools"),config_1=require("../../config/config"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),uglifyfilenames_1=require("./original/protect/uglifyfilenames"),index_1=require("./original/index"),baseCompiler_1=require("./baseCompiler"),miniProgram=config_1.COMPILE_TYPE.miniProgram,miniGame=config_1.COMPILE_TYPE.miniGame,miniProgramPlugin=config_1.COMPILE_TYPE.miniProgramPlugin,miniGamePlugin=config_1.COMPILE_TYPE.miniGamePlugin;function performanceMark(e,s){}class SummerCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e,s,t,i){super(e),this.project=e,this.cachePath=s,this.projectInfo=t,this.devtoolMessagehub=i,this.isSummer=!0,this.codeCache=new Map,this.promiseCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this.onFileChange=(e,s)=>{if("change"!==e||s.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);if("change"!==e)for(const e of this.promiseCache.keys())e.startsWith("getPackageFiles-")&&this.promiseCache.delete(e);this.invalidCodeCache(),this.subProcessManager.sendEvent("fileChange",{type:e,targetPath:s})},this.onPreCompileOptionsChange=async e=>{await this.clearCache(),this.subProcessManager.sendEvent("precompileOptionsChange",e)},this.onProgressUpdate=(e,s,t)=>{const i="doing"===s?"doing":"done"===s?"success":"error";this.messageHub.showBuildLog(""+e,i,t)},performanceMark("create summer compiler"),this.messageHub=new messageHub_1.MessageHub(i),this.ready()}get status(){return this._status}async init(){performanceMark("init summer compiler");const e=path_1.default.posix.join(__dirname,"./summerEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,e,{cachePath:this.cachePath},this.projectInfo,8891),this.addProjectListener(),this.loadStatus(),performanceMark("init summer compiler",!0)}async loadStatus(){this._status=await this.subProcessManager.runTask("loadStatus")}destroy(){var e;null===(e=this.subProcessManager)||void 0===e||e.destroy(),this.removeProjectListener(),this._checkReadyTask=void 0}async clearCache(){var e;await(null===(e=this.subProcessManager)||void 0===e?void 0:e.runTask("clearCache")),this.codeCache.clear(),this.promiseCache.clear()}updateOptions(e){var s;lodash_1.default.isEqual(e,this.projectInfo)||(this.projectInfo=e,this.promiseCache.clear(),this.codeCache.clear(),null===(s=this.subProcessManager)||void 0===s||s.sendEvent("updateOptions",e),this.loadStatus())}addProjectListener(){var e,s;this._eventAdded&&this.removeProjectListener(),null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),null===(s=this.project.event)||void 0===s||s.on("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!0}removeProjectListener(){var e,s;null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange),null===(s=this.project.event)||void 0===s||s.off("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!1}invalidCodeCache(){for(const e of this.codeCache.values())e.isValid=!1}async getConf(e){var s,t;const i="getConf-"+e;if(this.promiseCache.has(i))return(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.log(i,"hit cache"),this.promiseCache.get(i);(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(i,"do request"),performanceMark("request get conf");const r={graphId:e},o=this.subProcessManager.runTask("getConf",r,this.onProgressUpdate);return this.promiseCache.set(i,o),performanceMark("request get conf",!0),o}async getPackageFiles(e,s){var t,i;const r=`getPackageFiles-${e}-${s}`;if(this.promiseCache.has(r))return(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(r,"hit cache"),this.promiseCache.get(r);(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(r,"do request"),performanceMark("request get getPackageFiles");const o=this.subProcessManager.runTask("getPackageFiles",{graphId:e,root:s},this.onProgressUpdate);return this.promiseCache.set(r,o),performanceMark("request get getPackageFiles",!0),o}async getCode(e,s){var t,i,r;const o=`getCode-${e}${s?"-"+s.package:""}`;if(this.promiseCache.has(o))return(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(o,"hit promise cache"),this.promiseCache.get(o);const n=this.codeCache.get(o);if(null==n?void 0:n.isValid)return n.codeFiles;(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(o,"do request");const a={};if(n){const{codeFiles:e}=n;for(const s of Object.keys(e)){const t=e[s];"error"in t||(a[s]=t.md5)}}const c={graphId:e,cacheMd5:a,package:null==s?void 0:s.package};performanceMark("request get code");const l=Date.now();(null===(r=process.env)||void 0===r?void 0:r.isDevtools)&&(console.time("[summer-compiler] runTask "+o),console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] runTask ${o}`));const g=this.subProcessManager.runTask("getCode",c,this.onProgressUpdate).then(e=>{var s,t;(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.timeEnd("[summer-compiler] runTask "+o);const i=(null===(t=this.codeCache.get(o))||void 0===t?void 0:t.codeFiles)||{};for(const s of Object.keys(e)){const t=e[s];"error"in t||""!==t.md5?i[s]=t:delete i[s]}return this.codeCache.set(o,{isValid:!0,codeFiles:i}),i},e=>{throw e.code?console.error(e):console.error("Unexpected error when getCode",e),e});return g.finally(()=>{var e;performanceMark("request get code",!0),(null===(e=process.env)||void 0===e?void 0:e.isDevtools)&&console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] [cost ${Date.now()-l}ms] runTask ${o}`),this.promiseCache.delete(o)}),this.promiseCache.set(o,g),g}async getExtJSON(){return await(0,index_1.getExtJSON)(this.project)}async getAppJSON(){return(await this.getConf(miniProgram)).app}async getGameJSON(){return(await this.getConf(miniGame)).app}async getSiteMapJSON(){return(await this.getConf(miniProgram)).sitemap}async getPageJSON(e){const s=await this.getConf(miniProgram),t=s.pages[e]||s.comps[e];if(!t)throw new Error("summer-compiler 收集json配置有遗漏, "+e);return t}async getAllPageAndComponent(){const e=await this.getConf(miniProgram);return Object.keys(e.pages).concat(Object.keys(e.comps))}async getAllSortedJSFiles(){const e=await this.getConf(miniProgram),s=Object.keys(e.pages),t=Object.keys(e.comps),i=s.filter(e=>!t.includes(e)).map(e=>e+".js"),r=t.map(e=>e+".js"),o=await this.getCode(miniProgram,{package:config_1.FullPkg}),n=Object.keys(o).filter(e=>e.endsWith(".js")&&"app.js"!==e&&!i.includes(e)&&!r.includes(e));return{jsPagesFiles:i,components:r,otherJsFiles:n}}async getAllWxmlAndWxsFiles(){const e=await this.getCode(miniProgram,{package:config_1.FullPkg}),s=Object.keys(e).filter(e=>e.endsWith(".wxml")),t=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:s,wxsFiles:t,content:s.concat(t).reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async getPackageWxmlAndWxsFiles(e){let s=await this.getCode(miniProgram,{package:e});if(e!==config_1.MainPkg){const e=await this.getCode(miniProgram,{package:config_1.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxml")),i=Object.keys(s).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}async getPackageWxssFiles(e){let s=await this.getCode(miniProgram,{package:e});if(e!==config_1.MainPkg){const e=await this.getCode(miniProgram,{package:config_1.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxss"));return{wxssFiles:t,content:t.reduce((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}getWxssMap(e,s){s=(0,tools_1.normalizePath)(s);for(const[t,i]of this.codeCache.entries())if(t.startsWith("getCode-"+e)){const e=i.codeFiles[s];if(e&&!("error"in e))return e.map}}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniProgram),s=await this.getCode(miniProgram,{package:"__APP__"}),t=Object.keys(s).filter(e=>e.endsWith(".js")),i=[],r=[],o=[],n=[],a=[];let c=!1;const l={},g=s=>Object.keys(e.packages).find(e=>s.startsWith(e))||config_1.MainPkg;e.app.functionalPages&&t.forEach(e=>{if(e.startsWith("functional-pages/")){const s=e.replace(/\.js$/,"");if(l[s])return;l[s]=!0,a.push(encodeURI(s))}}),e.app.workers&&t.forEach(s=>{if(s.startsWith((0,tools_1.getWorkersPath)(e.app.workers))){const e=s.replace(/\.js$/,"");if(l[e])return;l[e]=!0,n.push(e)}});Object.keys(e.comps).filter(e=>g(e)===config_1.MainPkg).forEach(s=>{if((s.startsWith("miniprogram_npm/weui-miniprogram")||s.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(l[s])return;l[s]=!0;const t=encodeURI(s);o.push(""+t)});Object.keys(e.pages).filter(e=>g(e)===config_1.MainPkg).forEach(e=>{if(l[e])return;l[e]=!0;const s=encodeURI(e);i.push(""+s)}),t.forEach(e=>{const s=e.replace(/\.js$/,"");l[s]||(l[s]=!0,"app.js"!==e?r.push(""+encodeURI(s)):c=!0)});const h=[...r,...o,...i];return c&&h.push("app"),{hasAppJS:c,allFiles:h,pageFiles:i,componentFiles:o,workerFiles:n,functionalPageFiles:a,otherFiles:r}}async getSubPkgSortedJSFiles(e){const s=await this.getConf(miniProgram),t=await this.getCode(miniProgram,{package:e}),i=Object.keys(t).filter(e=>e.endsWith(".js")),r=[],o=[],n=[],a={},c=e=>Object.keys(s.packages).find(s=>e.startsWith(s))||config_1.MainPkg;Object.keys(s.comps).filter(s=>c(s)===e).forEach(e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&s.app.useExtendedLib&&s.app.useExtendedLib.weui)return;if(a[e])return;a[e]=!0;const t=encodeURI(e);n.push(""+t)});Object.keys(s.pages).filter(s=>c(s)===e).forEach(e=>{if(a[e])return;a[e]=!0;const s=encodeURI(e);r.push(""+s)});let l=s.packages[e].entry||"";l&&(l=path_1.default.join(e,l),l=l.replace(/\.js$/,"")),i.forEach(e=>{const s=e.replace(/\.js$/,"");a[s]||(a[s]=!0,s!==l&&o.push(""+encodeURI(s)))});const g=i.map(e=>""+encodeURI(e.replace(/\.js$/,"")));return{entryJS:l,allFiles:g,pageFiles:r,componentFiles:n,otherFiles:o}}async compileJS(e){const s=this.project.type;let t;if(e.root===this.project.miniprogramRoot){const i=await this.getConf(this.isGameType(s)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram),r=Object.keys(i.packages).find(s=>e.filePath.startsWith(s))||config_1.MainPkg;t=(await this.getCode(this.isGameType(s)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram,{package:r,partialCompilePath:[]}))[e.filePath]}else{t=(await this.getCode(this.isGameType(s)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin))[e.filePath]}if(!t){const s=new Error(`summer-compiler miss ${e.root} js file, ${e.filePath}`);throw s.code="ENOENT",s}if("error"in t)throw t.error;return Object.assign({filePath:e.filePath,code:t.code,map:t.map},t.jsTag)}async compile(e){const s=await this.subProcessManager.runTask("compile",e,(s,t,i)=>{var r;null===(r=e.onProgressUpdate)||void 0===r||r.call(e,{id:s.toString(),status:t,message:i})});for(const e of Object.keys(s))"object"==typeof s[e]&&"Buffer"===s[e].type&&(s[e]=Buffer.from(s[e].data));return s}async getPluginJSON(e=""){return(await this.getConf(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin)).plugin}async getPluginPageJSON(e){const s=await this.getConf(miniProgramPlugin),t=s.pages[e]||s.comps[e];if(!t)throw new Error("summer-compiler 收集plugin json配置有遗漏, "+e);return t}async getPluginComponents(){const e=await this.getConf(miniProgramPlugin),s=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(s)}async getPluginJSFiles(){const e=await this.getCode(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin),s=Object.keys(e).filter(e=>e.endsWith(".js"));return{jsFiles:s,content:s.reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async getPluginWxssFiles(){const e=await this.getCode(miniProgramPlugin),s=Object.keys(e).filter(e=>e.endsWith(".wxss"));return{wxssFiles:s,content:s.reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async getPluginWxmlAndWxsFiles(){const e=await this.getCode(miniProgramPlugin),s=Object.keys(e).filter(e=>e.endsWith(".wxml")),t=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:s,wxsFiles:t,content:s.concat(t).reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async checkThemeJSON(e){return(await this.getConf(miniProgram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this._locale!==e&&(this._locale=e,this.subProcessManager.runTask("setLocale",e))}async uglifyFileNames(e,s,t){return await(0,uglifyfilenames_1.uglifyFileNames)(e,s,t)}async getMPFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgram)}async getPluginFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgramPlugin)}async getCompAndPagesOfConf(){const e=await this.getConf(miniProgram);return{pages:e.pages,comps:e.comps}}}exports.SummerCompiler=SummerCompiler;
|
package/dist/schema/dist/app.js
CHANGED
|
@@ -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":
|
|
2223
|
+
"$version": 1718940707580
|
|
2221
2224
|
}
|
package/dist/schema/dist/ext.js
CHANGED
|
@@ -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":
|
|
1090
|
+
"$version": 1675931606631
|
|
1088
1091
|
}
|
package/dist/schema/dist/game.js
CHANGED
package/dist/schema/dist/page.js
CHANGED
|
@@ -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":
|
|
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":
|
|
373
|
+
"$version": 1718869873347
|
|
371
374
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miniprogram-ci",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
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",
|