示例#1
0
tagList.forEach(function(tag) {
    let thisTagDir = path.join(tagDir, tag),
        firstArticle,
        theseTags = articlesByDate
            .map(key => markdownFiles[filesByDate[key]])
            .filter(function(article) {
                if (article.tagNames.indexOf(tag) >= 0) {
                    firstArticle = firstArticle || article;
                    return true;
                }
                return false;
            });
    mkdir(thisTagDir);
    let tagPageContent = templateTools.processTagPage(
        tag,
        {
            href: navTools.getLinkForTag(tag),
            articles: theseTags
        }
    );
    fs.writeFileSync(
        path.join(thisTagDir, "index.html"),
        tagPageContent
    );
    if (firstArticle) {
        generator.addLocation(navTools.getLinkForTag(tag), timeTools.getDate(firstArticle), 0.4);
    }
});
`),l.push(h)}),k.forEach((a)=>{let h=a;if(!m[h]){let i=b.readFileSync(c.join(f,a),'utf8'),j=c.join(g,a),k=c.dirname(j);d.sync(k),b.writeFileSync(j,`module.exports = function(define, require, App, Page, getApp, wx) {
${o}
define('${a}', function(require, module, exports) {
${i}
})}
${e(a,i,3)}
  `),o='',l.unshift(h)}}),l}}(require('lazyload'),require);
示例#3
0
function launchTSCCheck() {
    if (!fs.existsSync('_dev')) {
        console.log('_dev not present, creating links...');
        mkdirp('_dev/ag-grid-community/dist');

        if (WINDOWS) {
            console.log('creating window links...');
            run('create-windows-links.bat').exec();
        } else {
            const linkType = 'symbolic';
            lnk('../ag-grid-community/src/main.ts', '_dev/ag-grid-community/', {
                force: true,
                type: linkType,
                rename: 'main.ts'
            });
            lnk('../ag-grid-community/src/ts', '_dev/ag-grid-community/dist', {
                force: true,
                type: linkType,
                rename: 'lib'
            });
            lnk('../ag-grid-enterprise/', '_dev', {force: true, type: linkType});
            lnk('../ag-grid-react/', '_dev', {force: true, type: linkType});
            lnk('../ag-grid-angular/exports.ts', '_dev/ag-grid-angular/', {
                force: true,
                type: linkType,
                rename: 'main.ts'
            });
            lnk('../ag-grid-angular/', '_dev', {force: true, type: linkType});
            lnk('../ag-grid-vue/', '_dev', {force: true, type: linkType});
        }
    }

    const tscPath = WINDOWS ? 'node_modules\\.bin\\tsc.cmd' : 'node_modules/.bin/tsc';

    const tsChecker = cp.spawn(tscPath, ['--watch', '--noEmit']);

    tsChecker.stdout.on('data', data => {
        data
            .toString()
            .trim()
            .split('\n')
            .filter(line => line.indexOf('Watching for') === -1 && line.indexOf('File change') === -1)
            .forEach(line => console.log(line.replace('_dev', '..').replace('/dist/lib/', '/src/ts/').red));
    });
}
示例#4
0
 return Promise.resolve().then(function() {
     let htmlContent = typeset(marked(articleData.contents.trim())),
         pageContent = templateTools.processArticlePage(
             Object.assign(
                 articleData,
                 {
                     content: htmlContent
                 }
             ),
             newestArticles
         );
     mkdir(articleOutputDir);
     fs.writeFileSync(
         path.join(articleOutputDir, "index.html"),
         pageContent
     );
     generator.addLocation(navTools.getLinkForArticle(articleData), timeTools.getDate(), 0.6);
 })
示例#5
0
module.exports = function(ext) {

	let middlewares = ext.middlewares
	,oneYear = 1000 * 60 * 60 * 24 * 365
	,serve = require('koa-static')
	,setting = ext.setting
	,path = require('path')
	,pluginStaticPath = setting.pluginStaticPath || path.resolve(cwd, '_static')

	,filesServ

	console.log(pluginStaticPath)
	//mkdir
	try {

		let staticRes = fs.accessSync(pluginStaticPath)

	} catch(e) {

		console.warn(pluginStaticPath, 'not exist')
		mkdir.sync(pluginStaticPath)

	}

	filesServ = serve( pluginStaticPath, {
		maxAge: oneYear
	})

	middlewares.splice(6, 0, filesServ)

	let extend = {
		middlewares: middlewares
	}

	return extend

////end
}
'use strict';!function(require,directRequire){function a(a){let b=h.createHash('md5');return b.update(a).digest('hex')}async function b(a,b=()=>{}){return new Promise(async(c,d)=>{try{const d=Date.now(),e=[...a];b('compilejs','\u6B63\u5728\u5904\u7406 '+a[0].file);const f=await Promise.all(a.map((a)=>{return l({taskName:'processJS',config:{file:a.file,es6:a.es6?'yes':'no',minified:a.minified?'yes':'no',sourceMaps:'map'},dataStr:a.code,maxTimeout:180000,useBackup:!0,downgrade:!1,onAfterRun:()=>{const c=e.findIndex((b)=>b===a);0<=c&&e.splice(c,1),e[0]&&b('compilejs','\u6B63\u5728\u5904\u7406 '+e[0].file)}})}));console.log(`compilejs all files cost time: ${Date.now()-d}`),c(f)}catch(a){a instanceof Error?d(a):d(new Error(a))}})}const c=require('fs'),d=require('path'),e=require('mkdir-p'),f=require('babel-core'),g=require('uglify-js'),h=require('crypto'),i=require('./162bf2ee28b76d3b3d95b685cede4146.js'),j=require('babel-code-frame'),k=require('./common/locales/index.js'),l=require('./9beb6be9c4f08fd7406b0e6f964234ea.js'),{bufToUTF8:m}=require('./efc820e1b92d6e4063535296d4a24213.js'),{FILE_NOT_UTF8:n,BABEL_TRANS_JS_ERR:o,UGLIFY_JS_ERR:p,BABILI_JS_ERR:q}=require('./949d8235c744ced2a80121e4dba34c28.js');var r={};module.exports=function(f,g={}){r[f.hash]||(r[f.hash]={});const h=g.onProgressUpdate||function(){},j=g.onFilesIgnored||function(){};let l=r[f.hash];return new Promise(async(o,p)=>{let{es6:q,minified:r,newFeature:s}=f.setting,{distPath:t}=g,u=await i(f),v=u.getAllJSFiles();const w=[],x=[];for(let b=0,e=v.length;b<e;b++){let e=v[b],f=u.getFile(e,null),g=m(f),h='';if(void 0===g){let a=new Error(k.config.FILE_NOT_UTF8.format(e));return a.code=n,p(a)}let i=Date.now(),j=a(g),o=`${e}_${q}_${r}_${s}`;if(l[o]&&l[o].md5===j)g=l[o].jsCode,h=l[o].map,console.log('compile js',e,'in cache, skip.');else{if((q||r)&&g.length<512000)w.push({file:e,code:g,es6:q,minified:r,md5:j});else try{const a=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/.exec(g);if(a&&a[1])if(/\.js\.map$/.test(a[1])){let b=d.dirname(d.join(u.srcPath,e));h=c.readFileSync(d.join(b,a[1])),h=JSON.stringify(JSON.parse(h))}else{const b=a[1].split('base64,')[1];h=Buffer.from(b,'base64').toString(),h=JSON.stringify(JSON.parse(h))}}catch(a){h=''}l[o]={md5:j,jsCode:g,map:h,ignored:(q||r)&&g.length>=512000}}}if(0<w.length){let a=[];try{a=await b(w,h)}catch(a){return p(a)}for(let b=0,c=w.length;b<c;b++){if(a[b].error){const c=a[b].error,d=new Error(c.message);return d.code=c.code,p(d)}const{file:c,md5:d}=w[b];l[`${c}_${q}_${r}_${s}`]={md5:d,jsCode:a[b].code,map:a[b].map}}}for(let a=0,b=v.length;a<b;a++){const b=v[a];let f=d.join(t,b),g=d.dirname(f);e.sync(g);const h=l[`${b}_${q}_${r}_${s}`];if(h&&h.jsCode){const a=h.jsCode;c.writeFileSync(f,a),h.ignored&&x.push(b),h.map&&c.writeFileSync(d.join(t,`${b}.map`),h.map)}}j(x),o()})}}(require('lazyload'),require);
'use strict';var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a};!function(require,directRequire){const a=require('fs'),b=require('path'),c=require('mkdir-p'),d=require('./5321b622f9bab971490e99e09b2389a9.js'),f=require('./0634ee2ebd3e560d9d4804ecc960160f.js'),e=require('./1fcc6bd55b687d154a4247e57fe3011d.js'),g=require('./3e74bc0c6a5fa450386148788cc0cf44.js'),h=require('./db2217eb4cff896bdcbc50abe005058f.js'),i=require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),j=require('./874074ba4ecebc4e49310ccc42243ff5.js'),k=require('./3bfffbe88b3d923921f851c0697974fe.js'),l=require('./3892cb9d0783075a973c350c41401370.js'),m=(d,e)=>{for(let f,g=0,h=e.length;g<h;g++)f=b.join(d,e[g].FunctionName),a.existsSync(f)||c.sync(f)},n=async(a)=>{const b=k.getCurrentTcbInfo();let c=b.currentEnv&&b.currentEnv.namespace;if(c)return c;let d,e=(await o()(a))||[];if(0>=e.length)(d=h.get(i.WINDOW_REGISTRY.CLOUD_CONSOLE))?d.focus():a({type:f.WINDOW_SET_CLOUD,data:{console:{show:!0}}});else{if(1==e.length)return a(p(0)),c=e[0].namespace,c;(d=h.get(i.WINDOW_REGISTRY.CLOUD_SCF_ACTION))?d.focus():a({type:f.WINDOW_SET_CLOUD,data:{fnaction:{show:!0},cloudfunctionRoot:{show:!0}}})}},o=()=>{return async(a)=>{try{let b=await g.getEnvList();return a({type:f.TCB_SET_ENV_LIST,data:b.env_list}),b.env_list}catch(b){a({type:f.INFO_SHOW_ERROR,data:{message:b.toString()}})}}},p=(a)=>{return{type:f.TCB_SELECT_ENV,data:a}},q=(a)=>{return async(c,e)=>{try{let h=await n(c,e);if(!h)return;const i=e(),j=i.project.current||{},k=b.join(j.projectpath,j.cloudfunctionRoot);a.showTips&&c(w({show:!0,title:'\u6B63\u5728\u540C\u6B65\u4E91\u51FD\u6570\u5217\u8868',content:'',showCancel:!1,showLoading:!0}));let l=`${Date.now()}${Math.random()}`,o=await g.getTcbFuncList({namespace:h,pageIndex:0,pageSize:d.FUNC_LIST_PAGE_SIZE}),p=[].concat(o.Functions);if(a.writeFile&&m(k,o.Functions),c({type:f.TCB_SET_SCF_LIST,data:{list:o.Functions,pageIndex:0,total:o.total,namespace:h,updateKey:l}}),o.total>d.FUNC_LIST_PAGE_SIZE){let b=parseInt((o.total-1)/d.FUNC_LIST_PAGE_SIZE);for(let e,j=1;j<b;j++)e=await g.getTcbFuncList({namespace:h,pageIndex:j,pageSize:d.FUNC_LIST_PAGE_SIZE}),p=p.concat(e.Functions),a.writeFile&&m(k,e.Functions),c({type:f.TCB_SET_SCF_LIST,data:{list:e.Functions,pageIndex:j,total:o.total,namespace:h,updateKey:l}})}return c({type:f.TCB_CLEAN_SCF_LIST,data:{namespace:h,updateKey:l}}),a.showTips&&c(w({show:!0,title:'\u540C\u6B65\u4E91\u51FD\u6570\u5217\u8868\u6210\u529F',content:'',showCancel:!1,showLoading:!1})),p}catch(b){a.showTips&&c(w({show:!0,title:'\u540C\u6B65\u4E91\u51FD\u6570\u5217\u8868\u5931\u8D25',content:b.toString(),showCancel:!1,showLoading:!1}))}}},r=(a)=>{return{type:f.TCB_CONSOLE_COMMAND,data:a}},s=(a)=>{return 1024>a?`${a} B`:1048576>a?`${(a/1024).toFixed(1)} KB`:`${(a/1024/1024).toFixed(1)} MB`},t=(a)=>{let b=[];return a.hasOwnProperty('packSize')&&b.push(`上传包大小:${s(a.packSize)}`),a.hasOwnProperty('filesCount')&&b.push(`文件数量:${a.filesCount}`),b.join('\uFF0C')},u=(a)=>{return async(c,d)=>{const f=await n(c,d);if(!f)return;const{dirPath:h,showTips:i,runtime:j,syncFunctions:k,createFunction:m}=a,o=b.basename(h);i&&c(w({show:!0,title:`正在${m?'\u521B\u5EFA':'\u4E0A\u4F20'} ${o}`,content:'',showCancel:!1,showLoading:!0}));try{const a=await g.uploadTcbFunc({functionName:o,dirPath:h,runtime:j,namespace:f});i&&(m?(c(w({show:!1})),c(e.setConfirmInfo({show:!0,content:`创建 ${o} 成功\n是否立即本地安装依赖 wx-server-sdk ?\n需保证 node & npm 已安装,且网络正常`,callback:(a)=>{if(a){const a='npm install --production';l(h,`echo ${a} && ${a}`)}}}))):c(w({show:!0,title:`上传 ${o} 成功`,content:t(a),showCancel:!1,showLoading:!1}))),k&&q({showTips:!1,writeFile:!1})(c,d)}catch(a){i&&c(w({show:!0,title:`${m?'\u521B\u5EFA':'\u4E0A\u4F20'} ${o} 失败`,content:a.toString(),showCancel:!1,showLoading:!1}))}}},v=(d)=>{return async(g,e)=>{const h=d.namespace||(await n(g,e));if(h)try{d.showTips&&g(w({show:!0,title:`正在下载 ${d.functionName}`,content:'',showCancel:!1,showLoading:!0}));let e=await j.getFunctionData({functionName:d.functionName,forceUpdate:!0,namespace:h});if(d.writeFile)for(var i in e){let f=b.join(d.dirPath,i),g=b.dirname(f);c.sync(g),a.writeFileSync(f,e[i])}g({type:f.TCB_SET_FILE,data:{functionName:d.functionName,fileList:Object.keys(e),namespace:h}}),d.showTips&&g(w({show:!0,title:'\u4E0B\u8F7D\u6210\u529F',content:'',showCancel:!1,showLoading:!1}))}catch(a){d.showTips&&g(w({show:!0,title:'\u4E0B\u8F7D\u5931\u8D25',content:a.toString(),showCancel:!1,showLoading:!1}))}}},w=(a)=>{return{type:f.TCB_SET_LOADING,data:a}};module.exports={getEnvList:o,selectEnv:p,getTcbFuncList:q,uploadTcbFunc:u,consoleCommand:r,showActionMsg:(a)=>{return{type:f.TCB_SCF_INFO,data:{show:!0,message:a}}},setConfirmInfo:(a)=>{return{type:f.TCB_SCF_INFO,data:a}},showConsoleAddSCF:()=>{return async(a,b)=>{const c=k.getCurrentTcbInfo(),d=await n(a,b);if(!d)return;let e;(e=h.get(i.WINDOW_REGISTRY.CLOUD_CONSOLE))?e.focus():a({type:f.WINDOW_SET_CLOUD,data:{console:{show:!0}}}),a(r({command:'SHOW_CREATE_SCF',data:{namespace:d,envId:c.currentEnv&&c.currentEnv.id}}))}},downloadTcbFunc:v,downloadAllTcbFunc:(d)=>{return async(g,e)=>{const h=e(),i=h.project.current.cloudfunctionRoot,k=await n(g,e);if(k){d.showTips&&g(w({show:!0,title:'\u6B63\u5728\u4E0B\u8F7D\u8BF7\u7A0D\u7B49',content:'',showCancel:!1,showLoading:!0}));try{const h=(await q(d)(g,e))||[];let m=[];for(let e,n=0,o=h.length;n<o;n++){e=h[n],d.showTips&&g(w({show:!0,title:`正在下载 ${e.FunctionName}`,content:'',showCancel:!1,showLoading:!0}));try{let h=await j.getFunctionData({functionName:e.FunctionName,forceUpdate:d.forceUpdate,namespace:k});if(d.writeFile){let d=b.join(i,e.FunctionName);for(var l in h){let e=b.join(d,l),f=b.dirname(e);c.sync(f),a.writeFileSync(e,h[l])}}g({type:f.TCB_SET_FILE,data:{functionName:e.FunctionName,fileList:Object.keys(h),namespace:k}})}catch(a){m.push(a.toString()),d.showTips&&g(w({show:!0,title:'\u90E8\u5206\u4E0B\u8F7D\u5931\u8D25',content:m.join('\n'),showCancel:!1,showLoading:!0}))}}d.showTips&&g(w({show:!0,title:'\u4E0B\u8F7D\u6210\u529F',content:'',showCancel:!1,showLoading:!1}))}catch(a){d.showTips&&g(w({show:!0,title:'\u4E0B\u8F7D\u5931\u8D25',content:a.toString(),showCancel:!1,showLoading:!1}))}}}},setLoading:w,uploadTcbFunctions:(a)=>{return async(b,c)=>{const d=a.dirPaths;for(let e,f=0;f<d.length;f++)e=d[f],await u({showTips:a.showTips,syncFunctions:!1,dirPath:e})(b,c);q({showTips:!1,writeFile:!1})(b,c)}},downloadTcbFunctions:(a)=>{return async(c,d)=>{for(let e,f=0;f<a.functionNames.length;f++)e=a.functionNames[f],await v(_extends({},a,{dirPath:b.join(a.dirPath,e),functionName:e}))(c,d)}},setCurrentEnv:(a)=>{return async(b)=>{const c=k.getCurrentTcbInfo();let d=c.envList;if(0>=d.length){let a=await g.getEnvList();b({type:f.TCB_SET_SCF_LIST,data:a.env_list}),d=a.env_list}const e=d.findIndex((b)=>{return b.namespace==a});-1!=e&&b(p(e))}}}}(require('lazyload'),require);
示例#8
0
gulp.task('make-plugin', function () {
  mkdir.sync(dist);
  return make_plugin.exec();
});
"use strict";!function(require,directRequire){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const a=require('./46d7303eb986fa402d60bf5e929aa077.js'),b=require('./a148d3a11fd5268109e21fb40c9d527b.js'),c=require("fs"),d=require("path"),e=require("mkdir-p"),f=20,g=()=>{};class h{constructor(a){this.counters={log:0,warn:0,error:0,assertion:0},this.timers={},this.caches={},this.warnCounter=0,this.errorCounter=0,this.assertionCounter=0,this.logFolder=a.logFolder,this.logFileForWarnings=a.logFileForWarnings,this.logFileForErrors=a.logFileForErrors,this.logFileForAssertions=a.logFileForAssertions,e.sync(this.logFolder),this.limitLogFiles.call(this)}limitLogFiles(){const a=this.getProperty("logFolder"),b=c.readdirSync(a),e={log:[],warn:[],error:[],assertion:[]};for(const g of b){const b=d.join(a,g),f=c.statSync(b);g.startsWith("log.")?e.log.push({filePath:b,createTime:parseInt(f.birthtime.getTime()/1e3+"")}):g.startsWith("warn.")?e.warn.push({filePath:b,createTime:parseInt(f.birthtime.getTime()/1e3+"")}):g.startsWith("error.")?e.error.push({filePath:b,createTime:parseInt(f.birthtime.getTime()/1e3+"")}):g.startsWith("assertion.")&&e.assertion.push({filePath:b,createTime:parseInt(f.birthtime.getTime()/1e3+"")})}const g=this.getProperty("counters");for(const a in e){if(!e.hasOwnProperty(a))continue;const b=e[a];if(b.sort((c,a)=>{return c.createTime<a.createTime?1:-1}),b.length>=f){for(let a=f;a<b.length;a++){const d=b[a];try{c.unlinkSync(d.filePath)}catch(a){}}g[a]=f}else g[a]=b.length}}get i(){return a.isDev?console.log.bind(console,a.timeStamp(),this.identifier):g}get w(){return this.logFileForWarnings?(...b)=>{this.logWarn.call(this,...b),console.warn.bind(a.timeStamp(),this.identifier,...b)}:console.warn.bind(console,a.timeStamp(),this.identifier)}get e(){return this.logFileForWarnings?(...b)=>{this.logError.call(this,...b),console.error.bind(a.timeStamp(),this.identifier,...b)}:console.error.bind(console,a.timeStamp(),this.identifier)}get assert(){return this.logFileForWarnings?(...b)=>{this.logAssertion.call(this,...b),console.error.bind(a.timeStamp(),this.identifier,...b)}:console.error.bind(console,a.timeStamp(),this.identifier,"[ASSERTION]")}get f(){return this.logLog.bind(this)}logLog(...b){this.logToFile.call(this,"log",`${this.identifier} ${a.timeStamp()} :: ${b.join(" ")}`)}logWarn(...b){this.logToFile.call(this,"warn",`${this.identifier} ${a.timeStamp()} :: ${b.join(" ")}`)}logError(...b){this.logToFile.call(this,"error",`${this.identifier} ${a.timeStamp()} :: ${b.join(" ")}`)}logAssertion(...b){this.logToFile.call(this,"assertion",`${this.identifier} ${a.timeStamp()} :: ${b.join(" ")}`)}logToFile(a,b){const e=this.getProperty("caches");e[a]=(e[a]||"")+"\n"+b;const f=this.getProperty("timers");f[a]||(f[a]=setTimeout(()=>{f[a]=void 0;const b=this.getProperty("counters"),g=this.getProperty("logFolder"),h=d.join(g,`${a}.${b[a]||0}.txt`);let i="";try{i=c.readFileSync(h,"utf-8")}catch(a){i=""}i+=e[a],e[a]="";try{c.writeFileSync(h,i,"utf-8"),i.length>512000&&(b[a]=Math.min(b[a]+1,1e3))}catch(a){}},5e3))}setProperty(a,b){this[a]=b}getProperty(a){return this[a]}}const i=new h({identifier:"[not provided]",logFolder:b.RemoteLogDir,logFileForWarnings:!0,logFileForErrors:!0,logFileForAssertions:!0}),j=i.getProperty.bind(i),k=i.setProperty.bind(i);exports.default=function(a){const b={identifier:a,setProperty:k,getProperty:j};return Object.setPrototypeOf(b,i),b}}(require("lazyload"),require);
'use strict';!function(require,directRequire){function a(a){return a.slice(g,h).readInt32BE()}function b(a){return a.slice(i,j).readInt32BE()}function c(c){let d=a(c),e=b(c),f=c.slice(k,k+d),g=[],h=k;for(let a=0;a<e;a++){let a={},b=c.slice(h,h+4).readInt32BE();h+=4,a.fileName=c.slice(h,h+b).toString(),h+=b,a.offset=c.slice(h,h+4).readInt32BE(),h+=4,a.length=c.slice(h,h+4).readInt32BE(),h+=4,g.push(a)}return g}const d=require('fs'),e=require('mkdir-p'),f=require('path'),g=5,h=9,i=14,j=18,k=18;module.exports=function(a,b){let g=c(a);for(var h={},j=0;j<g.length;j++){let b=g[j],c=b.fileName,d=b.offset,e=b.length,f=a.slice(d,d+e);h[c]=f}if(b)for(var i in h){const a=f.join(b,i);e.sync(f.dirname(a)),d.writeFileSync(a,h[i])}return h}}(require('lazyload'),require);
`),l.push('app.js');let o='var global={};var __wxAppData = {};var __wxRoute;var __wxRouteBegin;';return j.forEach((a)=>{let h=`${a}.js`;m[h]=!0;let i=b.readFileSync(c.join(f,`${a}.js`),'utf8'),j=c.join(g,`${a}.js`),k=c.dirname(j);d.sync(k),b.writeFileSync(j,`module.exports = function(define, require, App, Page, getApp, wx) {
__wxRoute = '${a}';__wxRouteBegin = true;
define('${a}.js', function(require, module, exports) {
${i}
})
require('${a}.js')}
${e(a+'.js',i,3)}
`),l.push(h)}),k.forEach((a)=>{let h=a;if(!m[h]){let i=b.readFileSync(c.join(f,a),'utf8'),j=c.join(g,a),k=c.dirname(j);d.sync(k),b.writeFileSync(j,`module.exports = function(define, require, App, Page, getApp, wx) {
'use strict';!function(require,directRequire){const a=require('glob'),b=require('fs'),c=require('path'),d=require('mkdir-p'),e=require('./eef4ce0c7ba11eb89c58f566edadbd28.js');module.exports=(f,g)=>{d.sync(g);const h=c.join(f,'app.json'),i=JSON.parse(b.readFileSync(h,'utf8'));let j=i.pages,k=a.sync(`**/*.js`,{cwd:f}),l=[],m={"app.js":!0},n=b.readFileSync(c.join(f,'app.js'),'utf8');b.writeFileSync(c.join(g,'app.js'),`module.exports = function(define, require, App, Page, getApp, wx) {
define('app.js', function(require, module, exports) {
${n}
})
require('app.js')}
${e('app.js',n,2)}
`),l.push('app.js');let o='var global={};var __wxAppData = {};var __wxRoute;var __wxRouteBegin;';return j.forEach((a)=>{let h=`${a}.js`;m[h]=!0;let i=b.readFileSync(c.join(f,`${a}.js`),'utf8'),j=c.join(g,`${a}.js`),k=c.dirname(j);d.sync(k),b.writeFileSync(j,`module.exports = function(define, require, App, Page, getApp, wx) {
__wxRoute = '${a}';__wxRouteBegin = true;
define('${a}.js', function(require, module, exports) {
${i}
})
require('${a}.js')}
${e(a+'.js',i,3)}
`),l.push(h)}),k.forEach((a)=>{let h=a;if(!m[h]){let i=b.readFileSync(c.join(f,a),'utf8'),j=c.join(g,a),k=c.dirname(j);d.sync(k),b.writeFileSync(j,`module.exports = function(define, require, App, Page, getApp, wx) {
${o}
define('${a}', function(require, module, exports) {
${i}
})}
${e(a,i,3)}
  `),o='',l.unshift(h)}}),l}}(require('lazyload'),require);
'use strict';!function(require,directRequire){const a=require('fs'),b=require('path'),c=require('mkdir-p'),d=require('./162bf2ee28b76d3b3d95b685cede4146.js'),e=require('./9fdd4ac31a05c27355910f0d74accd4c.js'),{bufToUTF8:f}=require('./efc820e1b92d6e4063535296d4a24213.js'),{FILE_NOT_UTF8:g}=require('./949d8235c744ced2a80121e4dba34c28.js'),h={".json":!0},{whiteFileExtName:i,gameWhiteFileExtName:j}=require('./6242f55dbdfe53c2f07b7a51568311f2.js'),k={".js":!0};module.exports=function(e,i={}){return new Promise(async(l,m)=>{const{distPath:n,gameJSON:o}=i,p=await d(e),q=p.getAllFile(),r=o.appConfig.configFrom;for(let d=0,e=q.length;d<e;d++){const e=q[d];if('game.json'===r&&'app-config.json'===e)continue;const i=b.extname(e);if(!k[i]&&j[i]){const d=p.getFile(e,null);if(h[i]){const a=f(d);if(void 0===a){const a=new Error(e);return a.code=g,m(a)}}const j=b.join(n,e),k=b.dirname(j);c.sync(k),a.writeFileSync(j,d)}}l()})}}(require('lazyload'),require);
'use strict';var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a};!function(require,directRequire){const a=require('fs'),b=require('glob'),c=require('path'),d=require('url'),e=require('react'),f=require('redux'),{connect:g}=require('react-redux'),h=require('lodash'),i=require('trash'),j=require('rmdir'),k=require('image-size'),l=require('./ff946754202ecf377034d29daac7c8d9.js'),m=require('./83822ab95828f61bf6a61c04d53246a8.js'),n=require('./72653d4b93cdd7443296229431a7aa9a.js'),o=require('./d62fc37d7aa6416d5dcc240ba94175cd.js'),p=require('./46f5e82e7b3fd4ec2c8023c3dcf88cc3.js'),q=require('./8c8af9e360a75571110bae2bcbfbba78.js'),r=require('./1fcc6bd55b687d154a4247e57fe3011d.js'),s=require('./a8c87029da0fa06e986298d447ab0fe2.js'),t=require('./ba23d8b47b1f4ea08b9fd49939b9443f.js'),u=require('./56c390e04c10e91a4aa2a2c19d9a885d.js'),v=require('./c1e9d0afe2f9700ca354dbeced1f34d5.js'),w=require('mkdir-p'),x=require('./da7c31daaf542cf1796023d8e344b98a.js'),y=require('./4e88c741ca9fb65fab96c500b6d7f2fb.js'),z=require('./9beb6be9c4f08fd7406b0e6f964234ea.js'),A=require('./514f85d2b0873069acdeb636da5dc337.js'),{whiteFileExtName:B}=require('./6242f55dbdfe53c2f07b7a51568311f2.js'),C={page:{".js":q.pageJS,".json":q.pageJSON,".wxml":q.pageWXML,".wxss":q.pageWXSS},component:{".js":q.componentJS,".json":q.componentJSON,".wxml":q.componentWXML,".wxss":q.componentWXSS}};let D;const E={".jpg":!0,".png":!0,".jpeg":!0,".icon":!0,".gif":!0,".svg":!0,".cer":!0};class F extends e.Component{constructor(a){super(a)}componentDidMount(){console.log('editor container mount',new Date),this.init()}componentWillUnmount(){this.cleanup()}componentWillReceiveProps(a){a.editorOpenFileInfo!=this.props.editorOpenFileInfo&&setTimeout(()=>{this.openFile()})}componentDidUpdate(a){a.project!==this.props.project&&a.project&&this.props.project&&a.project.projectid!==this.props.project.projectid&&(this.cleanup(),this.init()),a.focus!==this.props.focus&&(a.focus!==u.WINDOW_FOCUS.EDITOR&&this.props.focus===u.WINDOW_FOCUS.EDITOR?m.remoteEmit('REMOTE_FOCUS'):a.focus===u.WINDOW_FOCUS.EDITOR&&this.props.focus!==u.WINDOW_FOCUS.EDITOR&&m.remoteEmit('REMOTE_BLUR')),a.settings.edit.gitIgnoreWindowsReturn!==this.props.settings.edit.gitIgnoreWindowsReturn&&this.notifyGitStatus()}openFile(){m.remoteEmit('OPEN_FILE',this.props.editorOpenFileInfo),m.remoteEmit('REMOTE_FOCUS')}init(){this.setupMessageCenter(),this.setupFileUtils(),this.initEditorExtension(),this.mtimes=new Map,this.files=new Map}cleanup(){try{this.cleanupMessageCenter(),this.cleanupFileUtils()}catch(a){}}get container(){return this._container}set container(a){this._container=a}get editorWebview(){return this._editorWebview}set editorWebview(a){this._editorWebview=a}async setupFileUtils(){await this.getFileUtils(),this._onFileChange=this.onFileChange.bind(this),this.fileUtils.on('all',this._onFileChange)}async getFileUtils(){return this.fileUtils||(this.fileUtils=await o(this.props.project.projectpath)),this.fileUtils}getClientPath(){try{let a=this.props.project.miniprogramRoot;if(a&&!c.isAbsolute(a)){let b=this.normalizePath(a.substr(1));return b.endsWith('/')?b.slice(0,-1):b}}catch(a){}return''}cleanupFileUtils(){this.fileUtils.removeListener('all',this._onFileChange)}setupMessageCenter(){window.ms=l,this._onEditorMessage=this.onEditorMessage.bind(this),l.on('EDITOR',this._onEditorMessage)}cleanupMessageCenter(){l.off('EDITOR',this._onEditorMessage)}initEditorExtension(){this.loadEditorWebview()}loadEditorWebview(){return this.editorWebview?void this.editorWebview.reload():void this.setupWebview()}setupWebview(){this.editorWebview&&this.container.removeChild(this.editorWebview);const a=document.createElement('webview');a.setAttribute('partition','persist:editor'),a.setAttribute('tabIndex','-1'),a.style.width='100%',a.style.height='100%',a.setUserAgentOverride(`${a.getUserAgent()} devtoolsedit port/${global.messageCenterPort} proxy/${global.proxyPort}`),this.container.appendChild(a),a.addEventListener('dialog',(a)=>{let b=a.messageType||'',c=a.messageText,d=a.dialog;if('alert'===b);else if('confirm'===b){a.preventDefault();try{const a=JSON.parse(c);this.props.confirm(a,(a)=>{a?d.ok():d.cancel()})}catch(a){d&&d.cancel()}}else if('prompt'===b){let a=prompt(c);null===a?d.cancel():d.ok(a)}}),a.addEventListener('newwindow',(a)=>{nw.Shell.openExternal(a.targetUrl)}),a.addEventListener('exit',(a)=>{('abnormal'===a.reason||'crashed'===a.reason||'killed'===a.reason)&&this.setupWebview()}),a.src='html/editor.html',this.editorWebview=a}async onEditorMessage(a){let b={};try{b=JSON.parse(a)}catch(b){return void n.error(`onEditorMessage parse ${a} error ${b}`)}switch(b.type){case'FOCUS':{this.onReqFocus(b);break}case'GET_GIT_STATUS':{this.onReqGetGitStatus(b);break}case'REVIEW_FILE':{this.onReqReviewFile(b);break}case'RELOAD':{this.setupWebview();break}case'CLICK':{this.onWebviewClick();break}case'SHOW_EDITOR_IF_NEEDED':{this.props.show||this.props.toggleEditorWindow();break}case'TREE_SHOW':{this.setFileTreeShow();break}case'TREE_HIDE':{this.setFileTreeHide();break}case'GET_FILE':{this.onReqGetFile(b);break}case'GET_COMMIT_FILE':{this.onReqGetCommitFile(b);break}case'SAVE_FILE':{this.onReqSaveFile(b);break}case'FORMAT_CODE':{this.onReqFormatCode(b);break}case'FIND_IN_FILES':{this.onReqFindInFiles(b);break}case'SYNC_FILES':{this.onReqSyncFiles(b);break}case'INIT_PROJECT':{this.onReqInitProject(b);break}case'GET_API':{this.onReqGetAPI(b);break}case'OPEN_IN_DISK':{this.onReqOpenInDisk(b);break}case'RENAME':{this.rename(b);break}case'ADD_FILE':this.addFile(b);case'ADD_DIR':{this.addDir(b);break}case'ADD_PAGE':{this.addPage(b);break}case'ADD_COMPONENT':{this.addComponent(b);break}case'DELETE_FILE':{this.deleteFile(b);break}case'DELETE_DIR':{this.deleteDir(b);break}case'BUILD':{this.onReqBuild(b);break}}}async notifyGitStatus(){let a={enabled:!1,head:null};if(await this.isGitEnabled())try{const b=await z({taskName:'getgithead',config:{dir:this.props.project.projectpath},maxTimeout:60000,useBackup:!1,downgrade:!0});if(b.error)throw b.error;a={enabled:!!b.enabled,head:b.enabled?b.head+'':null}}catch(b){console.warn('getgithead error',b),a={enabled:!1,head:null}}const b={type:'EMIT',eventType:'REMOTE_GIT_STATUS_CHANGE',payload:{gitEnabled:a}};l.sendMessage('EDITOR',JSON.stringify(b))}async isGitEnabled(){if(this._gitEnabled===void 0){let a=!1;try{const b=await z({taskName:'getgitenabled',config:{dir:this.props.project.projectpath},maxTimeout:60000,useBackup:!1,downgrade:!0});if(b.error)throw b.error;a=b.enabled}catch(b){console.warn('getgitenabled failed',b),a=!1}this._gitEnabled=a}return this._gitEnabled}unsetGitEnabled(){void 0===this._gitEnabled||(this._prevGitEnabled=this._gitEnabled,this._gitEnabled=void 0)}async onFileChange(a,b,d){const e=this.props.project,f=c.relative(e.projectpath,b);/^\.git(\\|\/)/i.test(f)&&this.unsetGitEnabled(),clearTimeout(this._updateGitStatusTimeout),this._updateGitStatusTimeout=setTimeout(async()=>{this._updateGitStatusTimeout=void 0;const a=await this.isGitEnabled();(a||!!this._prevGitEnabled!==!!a)&&(this._prevGitEnabled=a,this.notifyGitStatus())},600);let g=d?+d.mtime:0,h=d?this.getSerializableStat(d):{},i={};if(b=this.getEditorPathFormat(f),('addDir'===a||'unlinkDir'===a)&&(b+='/'),this.triggerBuild(b),'add'===a||'addDir'===a)this.files.set(b,!0),i={payload:{eventType:a,path:b,stat:h}};else if('unlink'===a||'unlinkDir'===a)this.files.delete(b),i={payload:{eventType:a,path:b,stat:h}};else if('change'===a){if(+this.files.get(b)==g)return;this.files.set(b,g),i={payload:{eventType:a,path:b,stat:h}}}else return void n.info(`edit.js watch ${a}`);i.eventType='REMOTE_EXTERNAL_FILE_CHANGE',i.type='EMIT',l.sendMessage('EDITOR',JSON.stringify(i))}triggerBuild(a){let b=c.extname(a);if(B[b]){if('/project.config.json'!==a){a=this.normalizePath(a);let b=c.dirname(a),d=this.getClientPath();if(d&&0!==`${b}/`.indexOf(`${d}/`))return}const{autoSave:b,autoRefresh:d}=this.props.settings.edit;clearTimeout(this._rebuildCooldownTimeout),d&&(b?this._rebuildCooldownTimeout=setTimeout(()=>{this.props.rebuildImmediate(u.COMPILE_ORIGIN.SAVE_FILE)},u.REBUILD_INTERVAL.AUTO_REFRESH_AUTO_SAVE):this._rebuildCooldownTimeout=setTimeout(()=>{this.props.rebuildImmediate(u.COMPILE_ORIGIN.SAVE_FILE)},u.REBUILD_INTERVAL.AUTO_REFRESH))}}async getFiles(){function b(b){return new Promise((c,d)=>{a.lstat(b,(a,b)=>{a?d(a):c(b)})})}return new Promise(async(a)=>{const d=await this.getFileUtils(),e=d.getAllFileWithDir().map((a)=>'/'+a),f={},g=this.props.project.projectpath;for(const d of e)try{const a=await b(c.join(g,d));f[d]=_extends({},a,{isDir:a.isDirectory(),isFile:!a.isDirectory()})}catch(a){f[d]={}}a({files:e,info:f})})}getFiles2(c,{ignore:d=['.git','**/.git/**','node_modules','**/node_moduels/**']}={}){function e(b){return new Promise((c,d)=>{a.lstat(b,(a,b)=>{a?d(a):c(b)})})}return console.log('begin get file',new Date),new Promise((a,f)=>{b('**',{absolute:!0,ignore:d,cwd:c,nosort:!0,silent:!0,mark:!0,nodir:!1,dot:!0},async(b,d)=>{if(b)return void f(b);let g={};for(let a of d){const b=await e(a);g[a]=_extends({},b,{isDir:b.isDirectory(),isFile:!b.isDirectory()})}d=d.map((a)=>a.slice(c.length)),g=h.mapKeys(g,(a,b)=>b.slice(c.length)),console.log('end get file',new Date),a({files:d,info:g})})})}lstatRecursive(b,{absolute:d=!1,ignore:e=['.git']}={}){function f(b){return new Promise((c,d)=>{a.readdir(b,(a,b)=>{a?d(a):c(b)})})}function g(b){return new Promise((c,d)=>{a.lstat(b,(a,b)=>{a?d(a):c(b)})})}return new Promise(async(a,i)=>{try{const e=await g(b);if(!e.isDirectory())return void i('project path is a file');const j=await f(b),k=j.map((a)=>c.join(b,a));let l=[],m={};for(;0<k.length;){let a=k.pop();const b=await g(a);if(b.isDirectory()){const b=await f(a);Array.prototype.push.apply(k,b.map((b)=>c.join(a,b))),a+='/'}l.push(a),m[a]=_extends({},b,{isDir:b.isDirectory(),isFile:!b.isDirectory()})}if(l=l.map((a)=>a.replace('\\','/')),m=h.mapKeys(m,(a,b)=>b.replace('\\','/')),!d){const a=b.length;l=l.map((b)=>b.slice(a)),m=h.mapKeys(m,(b,c)=>c.slice(a))}a({files:l,info:m})}catch(a){i(a)}})}onReqFocus(){this.editorWebview&&(this.editorWebview.click&&this.editorWebview.click(),this.editorWebview.focus&&this.editorWebview.focus(),this.onWebviewClick())}onWebviewClick(){if(this.editorWebview){const a=new UIEvent('click',{bubbles:!0});this.editorWebview.dispatchEvent(a)}}setFileTreeShow(){this.props.setFileTreeShow(!0)}setFileTreeHide(){this.props.setFileTreeShow(!1)}onReqSaveFile(b){let d;try{const e=this.normalizePath(b.path),f=c.join(this.props.project.projectpath,e);let g=this.getClientPath();if(f===c.join(this.props.project.projectpath,g,'app.json')){let a=0;this.props.settings.edit.autoSave&&!this.props.settings.edit.autoRefresh&&(a=5e3),clearTimeout(D);let d,e,f,i;try{d=JSON.parse(this.fileUtils.getFile(c.join(g,'app.json'))),e=d.pages||[],f=JSON.parse(b.data),i=f.pages||[]}catch(a){}let j=h.difference(i,e);D=setTimeout(()=>{try{j.forEach((a)=>{this.autoAddPage(a)})}catch(a){}},a)}this.fileUtils.writeFileSync(e,b.data,'utf8');const i=a.lstatSync(f);d={errMsg:'',type:'CALLBACK',callback:b.callback,payload:{stat:this.getSerializableStat(i)}},this.mtimes.set(f,+i.mtime),this.files.set(b.path,i.mtime)}catch(a){n.error(`editor.container.js: onReqSaveFile error: ${a}`),d={errMsg:a.toString(),type:'CALLBACK',callback:b.callback}}l.sendMessage('EDITOR',JSON.stringify(d)),x('weapp_editor_savefile',this.props.project.appid)}async onReqGetGitStatus(a){console.log('editor.container.js, onReqGetGitStatus',a);const b={type:'CALLBACK',callback:a.callback,payload:{}};if(await this.isGitEnabled()){let a={};try{const b=await z({taskName:'getgitstatus',config:{dir:this.props.project.projectpath},maxTimeout:60000,useBackup:!1,downgrade:!0});if(b.error)throw b.error;a=b.status||{}}catch(b){console.warn('getGitStatus failed',b),a={}}const c={},d={};for(const b in a){if(!a.hasOwnProperty(b))continue;const e=a[b];d[this.getEditorPathFormat(b)]=c[e]=c[e]||{ignored:A.isStatusIgnored(e),new:A.isStatusNew(e),modified:A.isStatusModified(e),deleted:A.isStatusDeleted(e),staged:A.isStatusStaged(e),conflict:A.isStatusConflict(e)}}b.payload=d}l.sendMessage('EDITOR',JSON.stringify(b))}async onReqReviewFile(a){const b={type:'CALLBACK',callback:a.callback,payload:{gitLineDiffs:[]}},c=this.props.project.projectpath;if(await this.isGitEnabled()){const c=this.normalizePath(a.path);let d=[];try{let b=a.data||'';this.props.settings.edit.gitIgnoreWindowsReturn&&(b=b.replace(/\r\n/g,'\n'));const e=await z({taskName:'getgitlinediffs',config:{dir:this.props.project.projectpath,path:c},dataStr:b,maxTimeout:60000,useBackup:!1,downgrade:!0});if(e.error)throw e.error;d=e.gitLineDiffs||[]}catch(a){d=[]}b.payload.gitLineDiffs=d}l.sendMessage('EDITOR',JSON.stringify(b))}async onReqFormatCode(a){let b;try{b=this.props.settings.edit.tabSize}catch(a){b=2}let c=v(a.data,b),d={type:'CALLBACK',callback:a.callback,payload:c};l.sendMessage('EDITOR',JSON.stringify(d))}async onReqInitProject(a){const{files:b,info:c}=await this.getFiles(),d={},e=this.props.settings;for(const b in e.appearance)d[b]=e.appearance[b];for(const b in e.edit)d[b]=e.edit[b];let f;try{const a=await z({taskName:'getgithead',config:{dir:this.props.project.projectpath},maxTimeout:60000,useBackup:!1,downgrade:!0});if(a.error)throw a.error;f={enabled:!!a.enabled,head:a.enabled?a.head+'':null}}catch(a){console.warn('getgithead error',a),f={enabled:!1,head:null}}let g={errMsg:'',type:'CALLBACK',callback:a.callback,payload:{project:{name:this.props.project.projectname,path:this.props.project.projectpath,createTime:this.props.project.createTime},files:b,info:c,config:d,gitEnabled:f}};b.forEach((a)=>{this.files.set(a,!0)}),l.sendMessage('EDITOR',JSON.stringify(g))}async onReqGetAPI(a){let b;try{b=!!this.props.project.attr.gameApp}catch(a){b=!1}const c=await y.getFallbackAPI(b);let d={errMsg:'',type:'CALLBACK',callback:a.callback,payload:{files:c}};l.sendMessage('EDITOR',JSON.stringify(d))}async onReqSyncFiles(a){const{files:b,info:c}=await this.getFiles();let d={errMsg:'',type:'CALLBACK',callback:a.callback,payload:{files:b,info:c}};b.forEach((a)=>{this.files.set(a,!0)}),l.sendMessage('EDITOR',JSON.stringify(d))}async onReqGetCommitFile(a){const b={type:'CALLBACK',callback:a.callback,payload:{content:null,stats:null}};if(await this.isGitEnabled()){let c,d;const e=this.normalizePath(a.path);try{const a=await z({taskName:'getgitcommitfile',config:{dir:this.props.project.projectpath,path:e},maxTimeout:60000,useBackup:!1,downgrade:!0});if(a.error)throw a.error;c=a.content||null,d=a.stats||null}catch(a){console.warn('getGitCommitFile failed',a),c=null,d=null}b.payload.content='string'==typeof c?c:null,b.payload.stats=d||null}l.sendMessage('EDITOR',JSON.stringify(b))}async onReqGetFile(b){if(E[c.extname(b.path).toLowerCase()]){let e=d.resolve(`http://127.0.0.1:${global.proxyPort}/editor/files/`,this.normalizePath(b.path));try{e=decodeURI(e)}catch(a){}let f,g=c.join(this.props.project.projectpath,this.normalizePath(b.path));try{f=k(g)}catch(a){f={width:-1,height:-1}}const h=a.statSync(g),i={errMsg:'',type:'CALLBACK',callback:b.callback,payload:{url:e,dimension:f,stat:this.getSerializableStat(h)}};l.sendMessage('EDITOR',JSON.stringify(i))}else{const d=this.fileUtils.getFile(this.normalizePath(b.path)),e=a.statSync(c.join(this.props.project.projectpath,this.normalizePath(b.path))),f={errMsg:'',type:'CALLBACK',callback:b.callback,payload:{data:d,stat:this.getSerializableStat(e)}};l.sendMessage('EDITOR',JSON.stringify(f))}}async onReqFindInFiles(a){let{options:b,string:d}=a,{cwd:e,i:f,wholeword:g}=b;e=c.join(this.props.project.projectpath,e?e:''),p({str:d,cwd:e,i:f,wholeword:g,project:{projectpath:this.props.project.projectpath}},(b,c)=>{let d={type:'CALLBACK',callback:a.callback};b?d.errMsg=JSON.stringify(b):(d.errMsg='',d.payload=c),l.sendMessage('EDITOR',JSON.stringify(d))})}onReqOpenInDisk(a){const{path:b}=a;nw.Shell.showItemInFolder(c.join(this.props.project.projectpath,b)),l.sendMessage('EDITOR',JSON.stringify({errMsg:'',payload:{},type:'CALLBACK',callback:a.callback}))}rename(b){const{oldPath:d,newPath:e}=b;try{const f=c.join(this.props.project.projectpath,d),g=c.join(this.props.project.projectpath,e);a.renameSync(f,g);const h=a.lstatSync(g);this.files.delete(this.getEditorPathFormat(d)),this.files.set(e,!0),l.sendMessage('EDITOR',JSON.stringify({type:'CALLBACK',errMsg:'',payload:{stat:this.getSerializableStat(h)},callback:b.callback}))}catch(a){l.sendMessage('EDITOR',JSON.stringify({errMsg:a.toString(),type:'CALLBACK',callback:b.callback}))}}addFile(b){try{const d=c.join(this.props.project.projectpath,this.normalizePath(b.path));a.writeFileSync(d,'','utf8');const e=a.lstatSync(d);this.mtimes.set(d,+e.mtime);const f={errMsg:'',type:'CALLBACK',callback:b.callback,payload:{stat:this.getSerializableStat(e)}};this.files.set(b.path,!0),l.sendMessage('EDITOR',JSON.stringify(f))}catch(a){l.sendMessage('EDITOR',JSON.stringify({errMsg:a,type:'CALLBACK',callback:b.callback}))}}addDir(b){try{const d=c.join(this.props.project.projectpath,this.removeTrailingSlash(this.normalizePath(b.path)));w.sync(d);const e=a.lstatSync(d);this.mtimes.set(d,+e.mtime);const f={errMsg:'',type:'CALLBACK',callback:b.callback,payload:{stat:this.getSerializableStat(e)}};this.files.set(b.path,!0),l.sendMessage('EDITOR',JSON.stringify(f))}catch(a){l.sendMessage('EDITOR',JSON.stringify({errMsg:a.toString(),type:'CALLBACK',callback:b.callback}))}}autoAddPage(b){try{const d=this.normalizePath(b);let e=c.join(this.props.project.projectpath,this.getClientPath(),d),f=c.dirname(e);for(const b in w.sync(f),C.page)try{a.existsSync(`${e}${b}`)||a.writeFileSync(`${e}${b}`,C.page[b].replace(/\{\{page\}\}/g,d))}catch(a){}}catch(a){}}addPage(b){try{let d=this.getClientPath();const e=c.join(this.props.project.projectpath,d,'app.json');let f=JSON.parse(this.fileUtils.getFile(c.join(d,'app.json')));const g=f.pages||[];let h=new RegExp(`^${d}/`),i=this.removeTrailingSlash(this.normalizePath(b.path));i=i.replace(h,''),-1===g.indexOf(i)&&g.push(i),f.pages=g;let j;try{j=this.props.settings.edit.tabSize}catch(a){j=2}a.writeFileSync(e,JSON.stringify(f,null,j),'utf8');const k=c.join(this.props.project.projectpath,b.path);for(const b in C.page)try{a.existsSync(`${k}${b}`)||a.writeFileSync(`${k}${b}`,C.page[b].replace(/\{\{page\}\}/g,i))}catch(a){}const m=a.lstatSync(e),n={errMsg:'',type:'CALLBACK',callback:b.callback,payload:{stat:this.getSerializableStat(m)}};l.sendMessage('EDITOR',JSON.stringify(n))}catch(a){l.sendMessage('EDITOR',JSON.stringify({errMsg:a.toString(),type:'CALLBACK',callback:b.callback}))}}addComponent(b){try{let d=this.getClientPath(),e=new RegExp(`^${d}/`),f=this.removeTrailingSlash(this.normalizePath(b.path));f=f.replace(e,'');const g=c.join(this.props.project.projectpath,b.path);for(const b in C.component)try{a.existsSync(`${g}${b}`)||a.writeFileSync(`${g}${b}`,C.component[b].replace(/\{\{component\}\}/g,f))}catch(a){}const h={errMsg:'',type:'CALLBACK',callback:b.callback,payload:{}};l.sendMessage('EDITOR',JSON.stringify(h))}catch(a){l.sendMessage('EDITOR',JSON.stringify({errMsg:a.toString(),type:'CALLBACK',callback:b.callback}))}}async deleteFile(a){try{await i(c.join(this.props.project.projectpath,a.path)),this.files.delete(a.path),l.sendMessage('EDITOR',JSON.stringify({errMsg:'',type:'CALLBACK',callback:a.callback,payload:{}}))}catch(b){l.sendMessage('EDITOR',JSON.stringify({errMsg:b,type:'CALLBACK',callback:a.callback}))}}async deleteDir(a){try{await i(c.join(this.props.project.projectpath,a.path)),this.files.forEach((b,c)=>{c.startsWith(this.getEditorPathFormat(a.path,!0))&&this.files.delete(c)}),l.sendMessage('EDITOR',JSON.stringify({errMsg:'',type:'CALLBACK',callback:a.callback,payload:{}}))}catch(b){l.sendMessage('EDITOR',JSON.stringify({errMsg:b.toString(),type:'CALLBACK',callback:a.callback,payload:{}}))}}async onReqBuild(a){clearTimeout(this._rebuildCooldownTimeout),this._rebuildCooldownTimeout=setTimeout(()=>{this.props.rebuildImmediate(a&&a.data)},u.REBUILD_INTERVAL.AUTO_REFRESH)}getSerializableStat(a){return _extends({},a,{isDir:a.isDirectory(),isFile:!a.isDirectory()})}normalizePath(a){return a=a.replace(/\\/g,'/'),'/'===a[0]?a.substr(1):a}getEditorPathFormat(a,b=!1){return a=a.replace(/\\/g,'/'),b&&!a.endsWith('/')&&(a+='/'),'/'===a[0]?a:'/'+a}removeTrailingSlash(a){return a.endsWith('/')?a.slice(0,-1):a}render(){let a=this.props;if(!a.project)return null;let b='monaco';return a.show||(b+=' ui-invisible'),e.createElement('div',{className:b,style:{minHeight:'97px'},tabIndex:-1,ref:(a)=>this.container=a})}}module.exports=g((a)=>({editorOpenFileInfo:a.info.editorOpenFileInfo,show:a.window.editor&&a.window.editor.show,project:a.project.current,settings:a.settings,focus:a.window.focus}),(a)=>({confirm(b,c){a(r.setConfirmInfo(_extends({show:!0,showCancel:!0,callback:c,confirmText:'\u786E\u5B9A',cancelText:'\u53D6\u6D88'},b)))},setFileTreeShow(b){a(s.setEditor({fileTreeShow:b}))},toggleEditorWindow(){a(s.toggleEditorWindow())},rebuildImmediate(b){a(t.compileImmediate({origin:b}))}}))(F)}(require('lazyload'),require);
示例#15
0
文件: router.js 项目: Coselding/hera
'use strict'
const fs = require('fs')
const path = require('path')
const send = require('koa-send')
const mkdir = require('mkdir-p')
const crypto = require('crypto')
const loadConfig = require('./config')
const util = require('./util')
const cache = require('./cache')
const parser = require('./parser')
const router = require('koa-router')()
const hash_dir = crypto.createHash('md5').update(process.cwd()).digest("hex")
const formidable = require('koa-formidable')
const osTmp = require('os').tmpdir()
const tmpDir = path.join(osTmp, hash_dir)
mkdir.sync(tmpDir)
const root = (require('os').platform == "win32") ? process.cwd().split(path.sep)[0] : "/"
const version = require('../package.json').version
const builder = require('./builder')
const api = require('./api')

function escape(x) { return x}

function noext(str) {
  return str.replace(/\.\w+$/, '')
}

function loadFile(p, throwErr = true) {
  if (/\.wxss$/.test(p)) throwErr = false
  return new Promise((resolve, reject) => {
    fs.stat(`./${p}`, (err, stats) => {
'use strict';!function(require,directRequire){function a(a){return a.slice(g,h).readInt32BE()}function b(a){return a.slice(i,j).readInt32BE()}function c(c){const d=a(c),e=b(c),f=c.slice(k,k+d),g=[];let h=k;for(let a=0;a<e;a++){const a={},b=c.slice(h,h+4).readInt32BE();h+=4,a.fileName=c.slice(h,h+b).toString(),h+=b,a.offset=c.slice(h,h+4).readInt32BE(),h+=4,a.length=c.slice(h,h+4).readInt32BE(),h+=4,g.push(a)}return g}const d=require('fs'),e=require('mkdir-p'),f=require('path'),g=5,h=9,i=14,j=18,k=18;module.exports=function(a,b=void 0){const g=c(a);let h;return b||(h=new Map),g.forEach((c)=>{const g=c.fileName,i=c.offset,j=c.length,k=a.slice(i,i+j);if(b){const a=f.join(b,g),c=f.dirname(g);e.sync(f.join(b,c)),d.writeFileSync(a,k)}else h.set(g,k)}),b?void 0:h}}(require('lazyload'),require);
;!function(require, directRequire){;"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const path=require("path"),fs=require("fs"),zlib=require("zlib"),log=require('./72653d4b93cdd7443296229431a7aa9a.js'),request=require('./15ba1827c7f6564a45df6bd44da3a977.js'),baseRequest=require('./233d77ecf0781f44985f684f70e316d0.js'),urlConfig=require('./f171257bbcaef547a3cf27266ccb0db2.js'),dirConfig=require('./92320c1386e6db6a6f2556736a9bc280.js'),idepluginManager=require('./f5a748840b272d2bf0223c95f6c8dbe3.js'),tools=require('./84b183688a46c9e2626d3e6f83365e13.js'),unpack=require('./514d358c669501bba65151a1ad61ae2f.js'),mkdir=require("mkdir-p"),signature_1=require('./c3cff51847d72be47e57256891296359.js'),CHECK_INTERVAL=600000;let loopTimer=null,downloadLock=!1;const downloaded={};async function getOnlinePluginList(){const a={url:urlConfig.getPluginList,needToken:1},{body:b}=await request(a),c=b.baseresponse||{},d=c.errcode;return b.plugin_list}async function doCheckUpdate(){const a=await getOnlinePluginList();handleRequestResult(a)}function gunzipPack(a){return new Promise((b,c)=>{zlib.gunzip(a,(a,d)=>{a?c(a):b(d)})})}async function installPlugin(a,b){const c=path.join(dirConfig.WeappPlugin,a.plugin_id);try{const d=fs.readFileSync(b),e=await gunzipPack(d),f=unpack(e),g=JSON.parse(f["/manifest.json"]);if(g.version===a.version){for(const a in f){const b=path.join(c,a);mkdir.sync(path.dirname(b)),fs.writeFileSync(b,f[a])}idepluginManager.cleanFileCache(a.plugin_id)}}catch(b){log.error(`installPlugin ${a.plugin_id} ${a.version} catch error ${b}`);try{fs.unlinkSync(path.join(c,"./manifest.json"))}catch(a){}}fs.unlinkSync(b)}function downloadPlugin(a){const b=`${a.plugin_id}_${a.version}.wxpkg`,c=path.join(dirConfig.WeappApplication,b);return fs.existsSync(c)&&signature_1.checkFileMd5Signature(c,a.checksum)?void installPlugin(a,c):void(downloadLock||(downloadLock=!0,baseRequest({url:a.download_url,encoding:null},(b)=>{return downloaded[a.plugin_id]||(downloaded[a.plugin_id]={}),downloaded[a.plugin_id][a.version]=!0,downloadLock=!1,b?void log.error(`downloadPlugin ${a.plugin_id} ${a.version} fail ${b}`):void process.nextTick(()=>{signature_1.checkFileMd5Signature(c,a.checksum)&&installPlugin(a,c)})}).pipe(fs.createWriteStream(c))))}function handleRequestResult(a){const b=idepluginManager.getInstalledPluginManifest();for(const c of a){if(c.deleted)continue;if(-1===tools.compareSemVer(global.appVersion,c.min_devtool_version))continue;const a=b[c.plugin_id];a&&1!==tools.compareSemVer(c.version,a.version)||downloaded[c.plugin_id]&&downloaded[c.plugin_id][c.version]||downloadPlugin(c)}}function clearLoopTimer(){loopTimer&&(clearInterval(loopTimer),loopTimer=null)}exports.clearLoopTimer=clearLoopTimer;async function loop(){clearLoopTimer(),loopTimer=setInterval(()=>{try{doCheckUpdate()}catch(a){}},CHECK_INTERVAL)}exports.loop=loop;
示例#18
0
    pedantic: false,
    sanitize: false,
    smartLists: true,
    smartypants: false,
    highlight: function(code) {
        return highlightJS.highlightAuto(code).value;
    }
});
let tagList = new Set();

// Authors
const authors = require(path.join(root, "data", "authors.json"));

// Cleanup
rimraf(buildDir);
mkdir(buildDir);

// Process markdown headers
let markdownFiles = {},
    filesByDate = {};
fs.readdirSync(articlesDir)
    .filter(filename => /\.md$/.test(filename))
    .forEach(function(markdownFilename) {
        console.log(`Parsing: ${markdownFilename}`);
        let contents = fs.readFileSync(path.join(articlesDir, markdownFilename), "utf8"),
            data = markdownTools.processContents(contents),
            dateInfo = markdownTools.processDate(data.properties.date),
            urlArticleName = markdownFilename.split(".")[0],
            tags = (data.properties.tags || "").split(",").map(tag => tag.trim());
        let articleData = {
            contents: data.contents,