UNPKG

dingtalk-docs-cool-app

Version:

钉钉文档酷应用插件扩展 开发者初始化包

1 lines 1.64 kB
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{build}from"../../common/babel";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,i,n,a,s,m,c=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"),build(t,join(o,"./build")),this.log("✅ 编译成功"),i=join(o,"./build/index.js"),existsSync(i)||(this.log("请检查src文件夹下是否有index.ts文件"),this.exit()),e.next=9,import(i);case 9:return n=e.sent.default,a=getManifestByFieldDecorator(n),writeFileSync(join(o,"./manifest.json"),JSON.stringify(a,null,2)),e.next=14,bundle(i,i);case 14:cleanFolder(join(o,"./build"),["index.js","manifest.json"]),s=createWriteStream(join(r,"./output/output.zip")),(m=archiver("zip",{zlib:{level:9}})).pipe(s),m.directory(o,!1),m.finalize(),s.on("close",(function(){c.log(m.pointer()+" total bytes")}));case 21:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r}(Command);export{PackField as default};