jd-minigame-ci 0.0.8

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/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # 京东小游戏 CI 工具
2
+
3
+ ## 概述
4
+
5
+ jd-minigame-ci 是为京东小游戏开发者提供的工具包。开发者无需打开开发者工具,使用工具包即可完成小程序代码的上传、预览等操作。
6
+
7
+ ## 上传秘钥
8
+
9
+ 使用工具包之前,请访问“[京东小程序控制台](https://mp-console.jd.com/)—设置—开发设置—小游戏代码上传秘钥”获取上传秘钥。
10
+
11
+ ![alt 京东小程序秘钥生成](https://storage.360buyimg.com/ide-update/images/upload_key.png
12
+ )
13
+
14
+ ## 功能
15
+
16
+ 1. 上传代码,对应小程序开发者工具的上传功能
17
+ 2. 预览代码,对应小程序开发者工具的预览功能
18
+ 3. 支持“node 脚本”和“命令行”调用方式
19
+ 4. 跨平台,支持 Windows/Mac/Linux,可用于产品集成流水线部署
20
+
21
+ ## 安装
22
+
23
+ ```Shell
24
+ npm install -g jd-minigame-ci
25
+ ```
26
+
27
+ ## 命令行调用
28
+
29
+ ### 创建小游戏配置文件
30
+ 在游戏项目父目录或者其他目录(注意不要在当前待打包游戏的子目录)执行以下命令:
31
+ ```Shell
32
+ jgc config
33
+ ```
34
+ 配置成功后会在当前目录生成配置文件 jgc.config.js,配置示例如下:
35
+
36
+ ```js
37
+ module.exports = {
38
+ "type": "game", // 包类型, 有三种类型可选:game(小游戏), plugin(插件)
39
+ "appId": "133D26A41FB623****", // 游戏的appId
40
+ "requestToken": "1c0f081c18a248adbff9f****", // 游戏上传秘钥
41
+ "entry": "./build/source", // 需要被打包的小游戏的路径
42
+ "version": "1.0.0", // 选填,版本号
43
+ "description": "自测" // 选填,自定义备注
44
+ }
45
+ ```
46
+
47
+ ### 预览功能
48
+ 预览功能主要用于开发过程中,对小游戏进行真机预览及调试。
49
+
50
+ 在生成 jgc.config.js 的同级目录执行以下命令:
51
+
52
+ ```Shell
53
+ jgc preview
54
+ ```
55
+ 执行完上述命令后,如果一切正常,会在Termina出现二维码,
56
+
57
+ ![alt 预览二维码](https://storage.360buyimg.com/ide-update/images/WX20240227-184741.png
58
+ )
59
+
60
+ ### 上传功能
61
+
62
+ 上传功能用于开发者通过命令行快速将本地代码包上传至开发版本,并自动设置为体验版,返回体验版二维码。
63
+
64
+ 在生成 jgc.config.js 的同级目录执行以下命令
65
+
66
+ ```Shell
67
+ jgc upload
68
+ ```
69
+ ![alt 体验版二维码](https://storage.360buyimg.com/ide-update/images/upload.png
70
+ )
71
+
72
+
73
+ ## 脚本调用
74
+
75
+ ### 上传功能
76
+
77
+ ```JavaScript
78
+ const jgcCli = require('jd-minigame-ci')
79
+ jgcCli.upload({
80
+ type: 'game', // 类型
81
+ appId: '***', // 小游戏的appId
82
+ requestToken: '', // 小游戏的上传秘钥
83
+ entry: '', // 需要被打包的小游戏(或者游戏插件)的路径
84
+ version: '1.0.0', // 小游戏版本号
85
+ description: 'fix:小游戏bug', // 小游戏版本描述
86
+ }).then(data => {
87
+ console.log('data',data);
88
+ });
89
+ ```
90
+
91
+ #### 输入参数
92
+
93
+ | 参数名 | 类型 | 必填 | 说明 |
94
+ |------------|-------|----|--------------|
95
+ | appId | string | 是 | 小游戏的appId |
96
+ | requestToken | string | 是 | 秘钥信息 |
97
+ | entry | string | 是 | 项目路径 |
98
+ | version | string | 否 | 自定义版本号 |
99
+ | description | string | 否 | 自定义备注 |
100
+
101
+
102
+ #### 返回值
103
+ | 属性 | 类型 | 说明 |
104
+ |------------|-------|--------------|
105
+ | url | string | openapp 协议二维码地址 |
106
+ | expiredTime | string | 过期时间 |
107
+
108
+ ### 预览功能
109
+
110
+ ```JavaScript
111
+ const jgcCli = require('jd-minigame-ci')
112
+ jgcCli.preview({
113
+ type: 'game', // 类型
114
+ appId: '***', // 小游戏的appId
115
+ requestToken: '', // 小游戏的上传秘钥
116
+ entry: '', // 需要被打包的小游戏(或者游戏插件)的路径
117
+ }).then(data => {
118
+ console.log('data',data);
119
+ });
120
+ ```
121
+
122
+ #### 输入参数
123
+
124
+ | 参数名 | 类型 | 必填 | 说明 |
125
+ |------------|-------|----|--------------|
126
+ | appId | string | 是 | 小游戏的appId |
127
+ | requestToken | string | 是 | 秘钥信息 |
128
+ | entry | string | 是 | 项目路径 |
129
+
130
+ #### 返回值
131
+ | 属性 | 类型 | 说明 |
132
+ |------------|-------|--------------|
133
+ | url | string | openapp 协议二维码地址 |
134
+ | expiredTime | string | 过期时间 |
135
+
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ !function(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var e=r();for(var n in e)("object"==typeof exports?exports:t)[n]=e[n]}}(global,(()=>{return t={538:(t,r,e)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */o=function(){return r};var t,r={},e=Object.prototype,i=e.hasOwnProperty,a=Object.defineProperty||function(t,r,e){t[r]=e.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",s=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(t){l=function(t,r,e){return t[r]=e}}function p(t,r,e,n){var o=r&&r.prototype instanceof w?r:w,i=Object.create(o.prototype),c=new N(n||[]);return a(i,"_invoke",{value:_(t,e,c)}),i}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=p;var y="suspendedStart",v="suspendedYield",d="executing",g="completed",m={};function w(){}function b(){}function x(){}var E={};l(E,u,(function(){return this}));var L=Object.getPrototypeOf,k=L&&L(L(q([])));k&&k!==e&&i.call(k,u)&&(E=k);var O=x.prototype=w.prototype=Object.create(E);function j(t){["next","throw","return"].forEach((function(r){l(t,r,(function(t){return this._invoke(r,t)}))}))}function S(t,r){function e(o,a,c,u){var s=h(t[o],t,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==n(l)&&i.call(l,"__await")?r.resolve(l.__await).then((function(t){e("next",t,c,u)}),(function(t){e("throw",t,c,u)})):r.resolve(l).then((function(t){f.value=t,c(f)}),(function(t){return e("throw",t,c,u)}))}u(s.arg)}var o;a(this,"_invoke",{value:function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}})}function _(r,e,n){var o=y;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=h(r,e,n);if("normal"===s.type){if(o=n.done?g:v,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=g,n.method="throw",n.arg=s.arg)}}}function P(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,P(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function T(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function I(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function q(r){if(r||""===r){var e=r[u];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(n(r)+" is not iterable")}return b.prototype=x,a(O,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:b,configurable:!0}),b.displayName=l(x,f,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,l(t,f,"GeneratorFunction")),t.prototype=Object.create(O),t},r.awrap=function(t){return{__await:t}},j(S.prototype),l(S.prototype,s,(function(){return this})),r.AsyncIterator=S,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new S(p(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(O),l(O,f,"Generator"),l(O,u,(function(){return this})),l(O,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=q,N.prototype={constructor:N,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!r)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),I(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;I(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:q(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function i(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}var a=e(652),c=e(928),u=e(172),s=e(410).globSync;function f(t){try{if(a.pathExistsSync(t))return!0;if(f(c.dirname(t)))return a.mkdirsSync(t),!0}catch(t){console.log("make dir error,",t)}}r.writeFile=function(){var t,r=(t=o().mark((function t(r,e){var n,i=arguments;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=i.length>2&&void 0!==i[2]?i[2]:"utf8",f(c.posix.parse(r).dir)&&a.writeFileSync(r,e,n);case 4:case"end":return t.stop()}}),t)})),function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function c(t){i(a,n,o,c,u,"next",t)}function u(t){i(a,n,o,c,u,"throw",t)}c(void 0)}))});return function(t,e){return r.apply(this,arguments)}}(),r.hasGameJsonFile=function(t){return a.pathExistsSync(t)?s("game.json",{cwd:t,ignore:"node_modules/**"}).length>0:console.log("当前入口文件目录不存在!")},r.hasJgcConfigFile=function(t){try{return a.accessSync(t,a.constants.F_OK),!0}catch(t){return console.log("文件不存在"),!1}},r.compressDirectory=function(t,r){return new Promise((function(e,n){var o=a.createWriteStream(r),i=u("zip",{zlib:{level:9}});o.on("close",(function(){return e(i.pointer())})),i.on("warning",(function(t){return"ENOENT"!==t.code&&n(t)})),i.on("error",n),i.pipe(o),i.glob("**/*",{cwd:t}),i.finalize()}))},r.deleteFile=function(t){a.existsSync(t)&&a.unlink(t,(function(t){t&&console.log("删除zip文件失败: ",t)}))}},954:(t,r,e)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */o=function(){return r};var t,r={},e=Object.prototype,i=e.hasOwnProperty,a=Object.defineProperty||function(t,r,e){t[r]=e.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",s=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(t){l=function(t,r,e){return t[r]=e}}function p(t,r,e,n){var o=r&&r.prototype instanceof w?r:w,i=Object.create(o.prototype),c=new N(n||[]);return a(i,"_invoke",{value:_(t,e,c)}),i}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=p;var y="suspendedStart",v="suspendedYield",d="executing",g="completed",m={};function w(){}function b(){}function x(){}var E={};l(E,u,(function(){return this}));var L=Object.getPrototypeOf,k=L&&L(L(q([])));k&&k!==e&&i.call(k,u)&&(E=k);var O=x.prototype=w.prototype=Object.create(E);function j(t){["next","throw","return"].forEach((function(r){l(t,r,(function(t){return this._invoke(r,t)}))}))}function S(t,r){function e(o,a,c,u){var s=h(t[o],t,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==n(l)&&i.call(l,"__await")?r.resolve(l.__await).then((function(t){e("next",t,c,u)}),(function(t){e("throw",t,c,u)})):r.resolve(l).then((function(t){f.value=t,c(f)}),(function(t){return e("throw",t,c,u)}))}u(s.arg)}var o;a(this,"_invoke",{value:function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}})}function _(r,e,n){var o=y;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=h(r,e,n);if("normal"===s.type){if(o=n.done?g:v,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=g,n.method="throw",n.arg=s.arg)}}}function P(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,P(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function T(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function I(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function q(r){if(r||""===r){var e=r[u];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(n(r)+" is not iterable")}return b.prototype=x,a(O,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:b,configurable:!0}),b.displayName=l(x,f,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,l(t,f,"GeneratorFunction")),t.prototype=Object.create(O),t},r.awrap=function(t){return{__await:t}},j(S.prototype),l(S.prototype,s,(function(){return this})),r.AsyncIterator=S,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new S(p(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(O),l(O,f,"Generator"),l(O,u,(function(){return this})),l(O,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=q,N.prototype={constructor:N,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!r)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),I(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;I(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:q(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function i(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}var a=e(928),c=e(857),u=e(538),s=e(60),f=e(425),l=-1;function p(t,r){return h.apply(this,arguments)}function h(){var t;return t=o().mark((function t(r,e){var n,i,p,h,y,v,d,g,m,w,b,x,E;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s.checkConfigOptions(r,e)){t.next=3;break}throw{code:l,errMsg:"配置参数验证失败"};case 3:if(n=r.appId,i=r.requestToken,p=r.entry,h=r.versionName||"1.0.0",y=r.description||" ",u.hasGameJsonFile(p)){t.next=9;break}throw{code:l,errMsg:"".concat(p,"目录不存在 game.json")};case 9:return v=a.join(c.tmpdir(),"jd_game_temp.zip"),t.prev=10,u.deleteFile(v),t.next=14,u.compressDirectory(p,v);case 14:t.next=19;break;case 16:throw t.prev=16,t.t0=t.catch(10),new Error("压缩失效:",t.t0);case 19:return t.next=21,f.uploadProject({sourceFile:v,appId:n,requestToken:i});case 21:if(d=t.sent,1!==e){t.next=31;break}return t.next=25,f.generateQrCode({packId:d,appId:n,requestToken:i});case 25:return g=t.sent,m=g.imgUrl,w=g.expiredTime,t.abrupt("return",{url:m,expiredTime:w});case 31:if(2!==e){t.next=38;break}return t.next=34,f.setDevPackage({appId:n,requestToken:i,versionName:h,entry:p,description:y},d);case 34:return b=t.sent,x=b.imgUrl,E=b.expiredTime,t.abrupt("return",{url:x,expiredTime:E});case 38:case"end":return t.stop()}}),t,null,[[10,16]])})),h=function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function c(t){i(a,n,o,c,u,"next",t)}function u(t){i(a,n,o,c,u,"throw",t)}c(void 0)}))},h.apply(this,arguments)}t.exports={preview:function(t){return p(t,1)},upload:function(t){return p(t,2)}}},425:(t,r,e)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function i(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?o(Object(e),!0).forEach((function(r){a(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):o(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function a(t,r,e){var o;return o=function(t,r){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,r||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(r,"string"),(r="symbol"==n(o)?o:o+"")in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function c(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */c=function(){return r};var t,r={},e=Object.prototype,o=e.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},u=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(t){l=function(t,r,e){return t[r]=e}}function p(t,r,e,n){var o=r&&r.prototype instanceof w?r:w,a=Object.create(o.prototype),c=new N(n||[]);return i(a,"_invoke",{value:_(t,e,c)}),a}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=p;var y="suspendedStart",v="suspendedYield",d="executing",g="completed",m={};function w(){}function b(){}function x(){}var E={};l(E,u,(function(){return this}));var L=Object.getPrototypeOf,k=L&&L(L(q([])));k&&k!==e&&o.call(k,u)&&(E=k);var O=x.prototype=w.prototype=Object.create(E);function j(t){["next","throw","return"].forEach((function(r){l(t,r,(function(t){return this._invoke(r,t)}))}))}function S(t,r){function e(i,a,c,u){var s=h(t[i],t,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==n(l)&&o.call(l,"__await")?r.resolve(l.__await).then((function(t){e("next",t,c,u)}),(function(t){e("throw",t,c,u)})):r.resolve(l).then((function(t){f.value=t,c(f)}),(function(t){return e("throw",t,c,u)}))}u(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function o(){return new r((function(r,o){e(t,n,r,o)}))}return a=a?a.then(o,o):o()}})}function _(r,e,n){var o=y;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=h(r,e,n);if("normal"===s.type){if(o=n.done?g:v,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=g,n.method="throw",n.arg=s.arg)}}}function P(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,P(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function T(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function I(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function q(r){if(r||""===r){var e=r[u];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var i=-1,a=function e(){for(;++i<r.length;)if(o.call(r,i))return e.value=r[i],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(n(r)+" is not iterable")}return b.prototype=x,i(O,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:b,configurable:!0}),b.displayName=l(x,f,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,l(t,f,"GeneratorFunction")),t.prototype=Object.create(O),t},r.awrap=function(t){return{__await:t}},j(S.prototype),l(S.prototype,s,(function(){return this})),r.AsyncIterator=S,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new S(p(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(O),l(O,f,"Generator"),l(O,u,(function(){return this})),l(O,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=q,N.prototype={constructor:N,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!r)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),I(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;I(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:q(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function u(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function s(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var i=t.apply(r,e);function a(t){u(i,n,o,a,c,"next",t)}function c(t){u(i,n,o,a,c,"throw",t)}a(void 0)}))}}var f=e(938),l=e(305),p=e(652),h="http://vapp-ide-pack.jd.com";function y(){return(y=s(c().mark((function t(r){var e,n,o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,g(r);case 3:if(0!==(e=t.sent).code){t.next=12;break}return n=e.result,t.next=8,w(r,n);case 8:return o=t.sent,t.abrupt("return",o);case 12:throw new Error("上传失败");case 13:t.next=18;break;case 15:throw t.prev=15,t.t0=t.catch(0),t.t0 instanceof Error?t.t0:new Error(t.t0||"上传失败");case 18:case"end":return t.stop()}}),t,null,[[0,15]])})))).apply(this,arguments)}function v(t,r){return d.apply(this,arguments)}function d(){return d=s(c().mark((function t(r,e){var n,o,a,u,s=arguments;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(a in n=s.length>2&&void 0!==s[2]?s[2]:"请求失败",o=new l,e)o.append(a,e[a]);return t.prev=3,t.next=6,f.post(r,o,{headers:i({},o.getHeaders())});case 6:if(0!==(u=t.sent).data.code){t.next=9;break}return t.abrupt("return",u.data);case 9:throw new Error("".concat(n,": ").concat(u.data.errorMessage));case 12:throw t.prev=12,t.t0=t.catch(3),new Error("".concat(n,": ").concat(t.t0));case 15:case"end":return t.stop()}}),t,null,[[3,12]])}))),d.apply(this,arguments)}function g(t){return m.apply(this,arguments)}function m(){return(m=s(c().mark((function t(r){var e,n,o,i,a;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.sourceFile,n=r.appId,o=r.requestToken,i="".concat(h,"/v1/devops/pack"),a={appId:n,requestToken:o,sourceFile:p.createReadStream(e)},t.abrupt("return",v(i,a,"文件上传报错"));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function w(t,r){return b.apply(this,arguments)}function b(){return(b=s(c().mark((function t(r,e){var n,o,i,a;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=Date.now(),o=5e5,i=3e3;case 3:if(!(Date.now()-n<o)){t.next=13;break}return t.next=6,new Promise((function(t){return setTimeout(t,i)}));case 6:return t.next=8,x(r,e);case 8:if(0!==(a=t.sent).code||!a.result){t.next=11;break}return t.abrupt("return",a.result);case 11:t.next=3;break;case 13:throw new Error("查询超时");case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function x(t,r){return E.apply(this,arguments)}function E(){return(E=s(c().mark((function t(r,e){var n,o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.appId,o=r.requestToken,i={appId:n,requestToken:o,uuid:e},t.abrupt("return",v("".concat(h,"/v1/ci/queryPackIdByUuid"),i,"获取构建包id失效"));case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function L(){return(L=s(c().mark((function t(r){var e,n,o,i,a,u;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.appId,n=r.requestToken,o=r.packId,i={appId:e,requestToken:n,packId:o},t.next=4,v("".concat(h,"/v1/ci/queryQrcodeByPackId"),i,"获取二维码失效");case 4:return a=t.sent,(u=new Date).setMinutes(u.getMinutes()+25),t.abrupt("return",{imgUrl:a.result,expiredTime:"".concat(k(u.getHours()),":").concat(k(u.getMinutes()))});case 8:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function k(t){return String(t).length<2?"0".concat(String(t)):String(t)}function O(){return(O=s(c().mark((function t(r,e){var n,o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,j(r,e);case 2:return n=t.sent,t.next=5,_(r,n);case 5:return t.next=7,T(r);case 7:return o=t.sent,t.abrupt("return",o);case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function j(t,r){return S.apply(this,arguments)}function S(){return(S=s(c().mark((function t(r,e){var n,o,i,a,u,s,f;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.appId,o=r.requestToken,i=r.versionName,a=r.description,u={packId:e,appId:n,requestToken:o,versionName:i,description:a},t.next=4,v("".concat(h,"/v1/ci/commitDevVersion"),u,"设置为开发版失效");case 4:return s=t.sent,f=s.result,t.abrupt("return",f);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function _(t,r){return P.apply(this,arguments)}function P(){return(P=s(c().mark((function t(r,e){var n,o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.appId,o=r.requestToken,i={appId:n,requestToken:o,devId:e},t.next=4,v("".concat(h,"/v1/ci/devExperience"),i,"设置为体验版失效");case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function T(t){return I.apply(this,arguments)}function I(){return(I=s(c().mark((function t(r){var e,n,o,i,a,u;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.appId,n=r.requestToken,o={appId:e,requestToken:n},console.log(),t.next=5,v("".concat(h,"/v1/ci/queryExperienceQrcode"),o,"获取体验二维码失效");case 5:return i=t.sent,a=i.result,(u=new Date).setMinutes(u.getMinutes()+25),t.abrupt("return",{imgUrl:a,expiredTime:"".concat(k(u.getHours()),":").concat(k(u.getMinutes()))});case 10:case"end":return t.stop()}}),t)})))).apply(this,arguments)}t.exports={uploadProject:function(t){return y.apply(this,arguments)},generateQrCode:function(t){return L.apply(this,arguments)},setDevPackage:function(t,r){return O.apply(this,arguments)},commitDevVersion:j,setDevExperience:_,queryExperienceQrcodeByPackId:T}},60:(t,r)=>{r.checkConfigOptions=function(t,r){var e=t||{},n=e.appId,o=e.requestToken;return entry=e.entry,[n,o,entry].every((function(t){return function(t){return"string"==typeof t&&!!t.trim()}(t)}))}},172:t=>{"use strict";t.exports=require("archiver")},938:t=>{"use strict";t.exports=require("axios")},305:t=>{"use strict";t.exports=require("form-data")},652:t=>{"use strict";t.exports=require("fs-extra")},410:t=>{"use strict";t.exports=require("glob")},857:t=>{"use strict";t.exports=require("os")},928:t=>{"use strict";t.exports=require("path")}},r={},function e(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return t[n](i,i.exports,e),i.exports}(954);var t,r}));
package/dist/jgc.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(global,(()=>(()=>{var t={538:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */o=function(){return e};var t,e={},r=Object.prototype,i=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",s=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function p(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{p({},"")}catch(t){p=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,i=Object.create(o.prototype),c=new I(n||[]);return a(i,"_invoke",{value:S(t,r,c)}),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var y="suspendedStart",v="suspendedYield",d="executing",m="completed",g={};function w(){}function b(){}function x(){}var k={};p(k,u,(function(){return this}));var E=Object.getPrototypeOf,L=E&&E(E(N([])));L&&L!==r&&i.call(L,u)&&(k=L);var j=x.prototype=w.prototype=Object.create(k);function O(t){["next","throw","return"].forEach((function(e){p(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(o,a,c,u){var s=h(t[o],t,a);if("throw"!==s.type){var f=s.arg,p=f.value;return p&&"object"==n(p)&&i.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,c,u)}),(function(t){r("throw",t,c,u)})):e.resolve(p).then((function(t){f.value=t,c(f)}),(function(t){return r("throw",t,c,u)}))}u(s.arg)}var o;a(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function S(e,r,n){var o=y;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=h(e,r,n);if("normal"===s.type){if(o=n.done?m:v,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function _(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,_(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(i.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(n(e)+" is not iterable")}return b.prototype=x,a(j,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:b,configurable:!0}),b.displayName=p(x,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,p(t,f,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},O(P.prototype),p(P.prototype,s,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new P(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),p(j,f,"Generator"),p(j,u,(function(){return this})),p(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=N,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(q),!e)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),q(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;q(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function i(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var a=r(652),c=r(928),u=r(172),s=r(410).globSync;function f(t){try{if(a.pathExistsSync(t))return!0;if(f(c.dirname(t)))return a.mkdirsSync(t),!0}catch(t){console.log("make dir error,",t)}}e.writeFile=function(){var t,e=(t=o().mark((function t(e,r){var n,i=arguments;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=i.length>2&&void 0!==i[2]?i[2]:"utf8",f(c.posix.parse(e).dir)&&a.writeFileSync(e,r,n);case 4:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(t){i(a,n,o,c,u,"next",t)}function u(t){i(a,n,o,c,u,"throw",t)}c(void 0)}))});return function(t,r){return e.apply(this,arguments)}}(),e.hasGameJsonFile=function(t){return a.pathExistsSync(t)?s("game.json",{cwd:t,ignore:"node_modules/**"}).length>0:console.log("当前入口文件目录不存在!")},e.hasJgcConfigFile=function(t){try{return a.accessSync(t,a.constants.F_OK),!0}catch(t){return console.log("文件不存在"),!1}},e.compressDirectory=function(t,e){return new Promise((function(r,n){var o=a.createWriteStream(e),i=u("zip",{zlib:{level:9}});o.on("close",(function(){return r(i.pointer())})),i.on("warning",(function(t){return"ENOENT"!==t.code&&n(t)})),i.on("error",n),i.pipe(o),i.glob("**/*",{cwd:t}),i.finalize()}))},e.deleteFile=function(t){a.existsSync(t)&&a.unlink(t,(function(t){t&&console.log("删除zip文件失败: ",t)}))}},522:t=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,n(o.key),o)}}function n(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}var o=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.configPrompts=[{name:"type",message:"请选择要发布的包类型:",type:"list",choices:[{name:"小游戏",value:"game"},{name:"插件",value:"plugin"}],default:"game"},{name:"appId",type:"input",message:"请输入appId:",validate:function(t){return!!t||"appId不能为空"}},{name:"requestToken",type:"input",message:"请输入代码上传秘钥:",validate:function(t){return!!t||"代码上传秘钥不能为空"}},{name:"entry",type:"input",message:"请输入需要被打包的游戏(或者插件)的路径:",default:"./"},{name:"versionName",type:"input",message:"请输入需要被打包的游戏(或者插件)的版本号:",default:"1.0.0"},{name:"description",type:"input",message:"请输入需要被打包的游戏(或者插件)的备注:",default:""}]},(e=[{key:"getPrompts",value:function(){return this.configPrompts}}])&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();t.exports=o},890:(t,e,r)=>{var n=r(420),o=r(241),i=r(268);e.showQrCode=function(t){return new Promise((function(e,r){n.read(t).then((function(t){var r=t.bitmap,n=r.width,a=r.height,c=r.data,u=new Uint8ClampedArray(c),s=i(u,n,a);o.generate(s.data,{small:!0}),e(!0)})).catch((function(t){throw new Error("获取二维码信息失败:",t)}))}))},e.getBase64=function(t){return n.read(t).then((function(t){return t.getBase64Async("image/png")})).catch((function(){throw new Error("获取二维码base64失败")}))}},425:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function a(t,e,r){var o;return o=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(e,"string"),(e="symbol"==n(o)?o:o+"")in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */c=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},u=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function p(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{p({},"")}catch(t){p=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,a=Object.create(o.prototype),c=new I(n||[]);return i(a,"_invoke",{value:S(t,r,c)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var y="suspendedStart",v="suspendedYield",d="executing",m="completed",g={};function w(){}function b(){}function x(){}var k={};p(k,u,(function(){return this}));var E=Object.getPrototypeOf,L=E&&E(E(N([])));L&&L!==r&&o.call(L,u)&&(k=L);var j=x.prototype=w.prototype=Object.create(k);function O(t){["next","throw","return"].forEach((function(e){p(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(i,a,c,u){var s=h(t[i],t,a);if("throw"!==s.type){var f=s.arg,p=f.value;return p&&"object"==n(p)&&o.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,c,u)}),(function(t){r("throw",t,c,u)})):e.resolve(p).then((function(t){f.value=t,c(f)}),(function(t){return r("throw",t,c,u)}))}u(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function S(e,r,n){var o=y;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=h(e,r,n);if("normal"===s.type){if(o=n.done?m:v,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function _(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,_(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(o.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(n(e)+" is not iterable")}return b.prototype=x,i(j,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:b,configurable:!0}),b.displayName=p(x,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,p(t,f,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},O(P.prototype),p(P.prototype,s,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new P(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),p(j,f,"Generator"),p(j,u,(function(){return this})),p(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=N,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(q),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),q(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;q(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function u(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){u(i,n,o,a,c,"next",t)}function c(t){u(i,n,o,a,c,"throw",t)}a(void 0)}))}}var f=r(938),p=r(305),l=r(652),h="http://vapp-ide-pack.jd.com";function y(){return(y=s(c().mark((function t(e){var r,n,o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,m(e);case 3:if(0!==(r=t.sent).code){t.next=12;break}return n=r.result,t.next=8,w(e,n);case 8:return o=t.sent,t.abrupt("return",o);case 12:throw new Error("上传失败");case 13:t.next=18;break;case 15:throw t.prev=15,t.t0=t.catch(0),t.t0 instanceof Error?t.t0:new Error(t.t0||"上传失败");case 18:case"end":return t.stop()}}),t,null,[[0,15]])})))).apply(this,arguments)}function v(t,e){return d.apply(this,arguments)}function d(){return d=s(c().mark((function t(e,r){var n,o,a,u,s=arguments;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(a in n=s.length>2&&void 0!==s[2]?s[2]:"请求失败",o=new p,r)o.append(a,r[a]);return t.prev=3,t.next=6,f.post(e,o,{headers:i({},o.getHeaders())});case 6:if(0!==(u=t.sent).data.code){t.next=9;break}return t.abrupt("return",u.data);case 9:throw new Error("".concat(n,": ").concat(u.data.errorMessage));case 12:throw t.prev=12,t.t0=t.catch(3),new Error("".concat(n,": ").concat(t.t0));case 15:case"end":return t.stop()}}),t,null,[[3,12]])}))),d.apply(this,arguments)}function m(t){return g.apply(this,arguments)}function g(){return(g=s(c().mark((function t(e){var r,n,o,i,a;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.sourceFile,n=e.appId,o=e.requestToken,i="".concat(h,"/v1/devops/pack"),"文件上传报错",a={appId:n,requestToken:o,sourceFile:l.createReadStream(r)},t.abrupt("return",v(i,a,"文件上传报错"));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function w(t,e){return b.apply(this,arguments)}function b(){return(b=s(c().mark((function t(e,r){var n,o,i,a;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=Date.now(),o=5e5,i=3e3;case 3:if(!(Date.now()-n<o)){t.next=13;break}return t.next=6,new Promise((function(t){return setTimeout(t,i)}));case 6:return t.next=8,x(e,r);case 8:if(0!==(a=t.sent).code||!a.result){t.next=11;break}return t.abrupt("return",a.result);case 11:t.next=3;break;case 13:throw new Error("查询超时");case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function x(t,e){return k.apply(this,arguments)}function k(){return(k=s(c().mark((function t(e,r){var n,o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.appId,o=e.requestToken,i={appId:n,requestToken:o,uuid:r},t.abrupt("return",v("".concat(h,"/v1/ci/queryPackIdByUuid"),i,"获取构建包id失效"));case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function E(){return(E=s(c().mark((function t(e){var r,n,o,i,a,u;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.appId,n=e.requestToken,o=e.packId,i={appId:r,requestToken:n,packId:o},t.next=4,v("".concat(h,"/v1/ci/queryQrcodeByPackId"),i,"获取二维码失效");case 4:return a=t.sent,(u=new Date).setMinutes(u.getMinutes()+25),t.abrupt("return",{imgUrl:a.result,expiredTime:"".concat(L(u.getHours()),":").concat(L(u.getMinutes()))});case 8:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function L(t){return String(t).length<2?"0".concat(String(t)):String(t)}function j(){return(j=s(c().mark((function t(e,r){var n,o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,O(e,r);case 2:return n=t.sent,t.next=5,S(e,n);case 5:return t.next=7,T(e);case 7:return o=t.sent,t.abrupt("return",o);case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function O(t,e){return P.apply(this,arguments)}function P(){return(P=s(c().mark((function t(e,r){var n,o,i,a,u,s,f;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.appId,o=e.requestToken,i=e.versionName,a=e.description,u={packId:r,appId:n,requestToken:o,versionName:i,description:a},t.next=4,v("".concat(h,"/v1/ci/commitDevVersion"),u,"设置为开发版失效");case 4:return s=t.sent,f=s.result,t.abrupt("return",f);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function S(t,e){return _.apply(this,arguments)}function _(){return(_=s(c().mark((function t(e,r){var n,o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.appId,o=e.requestToken,i={appId:n,requestToken:o,devId:r},t.next=4,v("".concat(h,"/v1/ci/devExperience"),i,"设置为体验版失效");case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function T(t){return q.apply(this,arguments)}function q(){return(q=s(c().mark((function t(e){var r,n,o,i,a,u;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.appId,n=e.requestToken,o={appId:r,requestToken:n},console.log(),t.next=5,v("".concat(h,"/v1/ci/queryExperienceQrcode"),o,"获取体验二维码失效");case 5:return i=t.sent,a=i.result,(u=new Date).setMinutes(u.getMinutes()+25),t.abrupt("return",{imgUrl:a,expiredTime:"".concat(L(u.getHours()),":").concat(L(u.getMinutes()))});case 10:case"end":return t.stop()}}),t)})))).apply(this,arguments)}t.exports={uploadProject:function(t){return y.apply(this,arguments)},generateQrCode:function(t){return E.apply(this,arguments)},setDevPackage:function(t,e){return j.apply(this,arguments)},commitDevVersion:O,setDevExperience:S,queryExperienceQrcodeByPackId:T}},60:(t,e)=>{e.checkConfigOptions=function(t,e){var r=t||{},n=r.appId,o=r.requestToken;return entry=r.entry,[n,o,entry].every((function(t){return function(t){return"string"==typeof t&&!!t.trim()}(t)}))}},589:t=>{function e(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e.keys=()=>[],e.resolve=e,e.id=589,t.exports=e},172:t=>{"use strict";t.exports=require("archiver")},938:t=>{"use strict";t.exports=require("axios")},858:t=>{"use strict";t.exports=require("commander")},305:t=>{"use strict";t.exports=require("form-data")},652:t=>{"use strict";t.exports=require("fs-extra")},410:t=>{"use strict";t.exports=require("glob")},937:t=>{"use strict";t.exports=require("inquirer")},420:t=>{"use strict";t.exports=require("jimp")},268:t=>{"use strict";t.exports=require("jsqr")},720:t=>{"use strict";t.exports=require("ora")},205:t=>{"use strict";t.exports=require("picocolors")},241:t=>{"use strict";t.exports=require("qrcode-terminal")},857:t=>{"use strict";t.exports=require("os")},928:t=>{"use strict";t.exports=require("path")}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);return(()=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e=function(){return n};var r,n={},o=Object.prototype,i=o.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",s=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function p(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{p({},"")}catch(r){p=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,i=Object.create(o.prototype),c=new I(n||[]);return a(i,"_invoke",{value:S(t,r,c)}),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=l;var y="suspendedStart",v="suspendedYield",d="executing",m="completed",g={};function w(){}function b(){}function x(){}var k={};p(k,u,(function(){return this}));var E=Object.getPrototypeOf,L=E&&E(E(N([])));L&&L!==o&&i.call(L,u)&&(k=L);var j=x.prototype=w.prototype=Object.create(k);function O(t){["next","throw","return"].forEach((function(e){p(t,e,(function(t){return this._invoke(e,t)}))}))}function P(e,r){function n(o,a,c,u){var s=h(e[o],e,a);if("throw"!==s.type){var f=s.arg,p=f.value;return p&&"object"==t(p)&&i.call(p,"__await")?r.resolve(p.__await).then((function(t){n("next",t,c,u)}),(function(t){n("throw",t,c,u)})):r.resolve(p).then((function(t){f.value=t,c(f)}),(function(t){return n("throw",t,c,u)}))}u(s.arg)}var o;a(this,"_invoke",{value:function(t,e){function i(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(i,i):i()}})}function S(t,e,n){var o=y;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:r,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=h(t,e,n);if("normal"===s.type){if(o=n.done?m:v,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function _(t,e){var n=e.method,o=t.iterator[n];if(o===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=r,_(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function N(e){if(e||""===e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function t(){for(;++o<e.length;)if(i.call(e,o))return t.value=e[o],t.done=!1,t;return t.value=r,t.done=!0,t};return a.next=a}}throw new TypeError(t(e)+" is not iterable")}return b.prototype=x,a(j,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:b,configurable:!0}),b.displayName=p(x,f,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,p(t,f,"GeneratorFunction")),t.prototype=Object.create(j),t},n.awrap=function(t){return{__await:t}},O(P.prototype),p(P.prototype,s,(function(){return this})),n.AsyncIterator=P,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new P(l(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),p(j,f,"Generator"),p(j,u,(function(){return this})),p(j,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},n.values=N,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(q),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,o){return c.type="throw",c.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),q(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;q(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:N(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),g}},n}function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}var i=r(928),a=r(857),c=r(720),u=r(205),s=new(0,r(858).Command),f=r(937),p=r(522),l=r(538),h=r(60),y=r(425),v=r(890);function d(t){return m.apply(this,arguments)}function m(){return(m=o(e().mark((function t(n){var o,s,f,p,d,m,g,w,b,x,k,E,L,j,O,P,S,_,T,q;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=1===n?"preview":"upload",s=i.posix.resolve("","./jgc.config.js"),l.hasJgcConfigFile(s)){t.next=5;break}return t.abrupt("return",console.log("".concat(u.red("请先创建配置文件!"))));case 5:if(f="function"==typeof require?require:r(589),p=f(s),h.checkConfigOptions(p)){t.next=10;break}return t.abrupt("return",console.log("配置参数校验失败!请检查"));case 10:if(d=p.appId,m=p.requestToken,g=p.versionName,w=p.entry,b=p.description,l.hasGameJsonFile(w)){t.next=14;break}return t.abrupt("return",console.log("请确定需要被打包的游戏(或者插件)的目录下存在game.json!"));case 14:return x=a.tmpdir()+i.sep+"jd_game_temp.zip",l.deleteFile(x),k=c("文件压缩").start(),t.prev=17,t.next=20,l.compressDirectory(w,x);case 20:E=t.sent,k.succeed("压缩完成,共"+E/1e3+"KB"),t.next=28;break;case 24:t.prev=24,t.t0=t.catch(17),k.fail("压缩失败:",t.t0),process.exit(1);case 28:return k.start(),k.text="上传中",t.next=32,y.uploadProject({sourceFile:x,appId:d,requestToken:m});case 32:if(L=t.sent,k.succeed("上传完成,packId:".concat(L)),"preview"!==o){t.next=46;break}return t.next=37,y.generateQrCode({packId:L,appId:d,requestToken:m});case 37:return j=t.sent,O=j.imgUrl,P=j.expiredTime,t.next=42,v.showQrCode(O);case 42:k.succeed("二维码生成完成,将于".concat(P,"过期")),k.info("二维码仅支持协作成员访问"),t.next=64;break;case 46:if("upload"!==o){t.next=64;break}return k.start(),t.next=50,y.commitDevVersion({appId:d,requestToken:m,versionName:g,description:b},L);case 50:return S=t.sent,k.succeed("开发版设置完成, devId:"+S),t.next=54,y.setDevExperience({appId:d,requestToken:m},S);case 54:return k.succeed("体验版设置完成"),t.next=57,y.queryExperienceQrcodeByPackId({appId:d,requestToken:m});case 57:return _=t.sent,T=_.imgUrl,q=_.expiredTime,t.next=62,v.showQrCode(T);case 62:k.info("二维码仅支持协作成员访问"),k.succeed("二维码生成完成,将于".concat(q,"过期"));case 64:case"end":return t.stop()}}),t,null,[[17,24]])})))).apply(this,arguments)}s.command("config").description("小游戏配置").action(o(e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(new p).getPrompts(),t.next=3,f.prompt(r);case 3:if(n=t.sent,l.hasGameJsonFile(n.entry)){t.next=7;break}return t.abrupt("return",console.log("".concat(u.red("请确定需要被打包的游戏(或者插件)的目录下存在game.json"))));case 7:try{"jgc.config.js",l.writeFile("./".concat("jgc.config.js"),"module.exports = ".concat(JSON.stringify(n,null,2)),"utf-8"),console.log("✨ ".concat(u.green("创建小游戏配置文件成功")))}catch(t){console.log("创建小游戏配置文件失败:",t)}case 8:case"end":return t.stop()}}),t)})))),s.command("preview").description("小游戏真机预览").action(o(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:d(1);case 1:case"end":return t.stop()}}),t)})))),s.command("upload").description("小游戏发布").action(o(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:d(2);case 1:case"end":return t.stop()}}),t)})))),s.parse(process.argv)})(),{}})()));
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "jd-minigame-ci",
3
+ "version": "0.0.8",
4
+ "description": "The jd-minigame-ci is a toolkit provided for developers of JD Mini Games. Developers can complete code upload and preview operations for JD Mini Games without the need to open the developer tools, simply by using this toolkit.",
5
+ "author": "chenlong328",
6
+ "license": "ISC",
7
+ "main": "dist/index.js",
8
+ "bin": {
9
+ "jgc": "./dist/jgc.js"
10
+ },
11
+ "scripts": {
12
+ "config": "NODE_ENV=development node ./dist/jgc.js config",
13
+ "preview": "NODE_ENV=development node ./dist/jgc.js preview",
14
+ "dev:preview": "NODE_ENV=development node ./src/jgc.js preview",
15
+ "dev:upload": "NODE_ENV=development node ./src/jgc.js upload",
16
+ "build": "webpack --mode production --progress --config webpack.config.js && chmod 777 ./dist/index.js && chmod 777 ./dist/jgc.js"
17
+ },
18
+ "dependencies": {
19
+ "@babel/cli": "^7.23.9",
20
+ "@babel/core": "^7.23.9",
21
+ "@babel/preset-env": "^7.23.9",
22
+ "archiver": "^6.0.1",
23
+ "axios": "^1.6.7",
24
+ "commander": "^11.1.0",
25
+ "fs-extra": "^11.2.0",
26
+ "glob": "^10.3.10",
27
+ "inquirer": "8.2.6",
28
+ "jimp": "^0.22.12",
29
+ "minimist": "^1.2.8",
30
+ "ora": "5.4.1",
31
+ "qrcode": "^1.5.3",
32
+ "qrcode-terminal": "^0.12.0",
33
+ "strip-ansi": "6.0.1",
34
+ "string-width": "4.2.3",
35
+ "jsqr": "1.4.0"
36
+ },
37
+ "devDependencies": {
38
+ "babel-loader": "^9.1.3",
39
+ "babel-minify-webpack-plugin": "^0.3.1",
40
+ "clean-webpack-plugin": "^4.0.0",
41
+ "terser-webpack-plugin": "^5.3.10",
42
+ "webpack": "^5.90.3",
43
+ "webpack-cli": "^5.1.4",
44
+ "webpack-node-externals": "^3.0.0"
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "package.json",
49
+ "README.md"
50
+ ]
51
+ }