dingtalk-docs-cool-app
Version:
钉钉文档酷应用插件扩展 开发者初始化包
1 lines • 1.63 kB
JavaScript
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _inheritsLoose from"@babel/runtime/helpers/inheritsLoose";import _regeneratorRuntime from"@babel/runtime/regenerator";import{join}from"path";import{existsSync,writeFileSync,createWriteStream}from"fs";import archiver from"archiver";import{Command}from"@oclif/core";import{bundle}from"../../common/bundle";import{cleanFolder}from"../../common/clear";import{getManifestByFieldDecorator}from"../../module/fields";var PackField=function(e){function r(){return e.apply(this,arguments)||this}return _inheritsLoose(r,e),r.prototype.run=function(){var e=_asyncToGenerator(_regeneratorRuntime.mark((function e(){var r,t,o,n,i,a,s,c,m=this;return _regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=process.cwd(),t=join(r,"./src"),o=join(r,"./output/output"),n=join(o,"./build/index.js"),e.next=6,bundle(join(t,"./index.ts"),n);case 6:return this.log("✅ 编译成功"),existsSync(n)||(this.log("请检查src文件夹下是否有index.ts文件"),this.exit()),e.next=10,import(n);case 10:return i=e.sent.default,a=getManifestByFieldDecorator(i),writeFileSync(join(o,"./manifest.json"),JSON.stringify(a,null,2)),e.next=15,bundle(n,n);case 15:cleanFolder(join(o,"./build"),["index.js","manifest.json"]),s=createWriteStream(join(r,"./output/output.zip")),(c=archiver("zip",{zlib:{level:9}})).pipe(s),c.directory(o,!1),c.finalize(),s.on("close",(function(){m.log(c.pointer()+" total bytes")}));case 22:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r}(Command);export{PackField as default};