@pisell/common 1.0.58 → 1.0.59

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.
Files changed (56) hide show
  1. package/.fatherrc.ts +7 -7
  2. package/CHANGELOG.md +9 -1
  3. package/README.md +2 -2
  4. package/es/bin/pisell.js +1 -5
  5. package/es/index.d.ts +2 -4
  6. package/es/index.js +1 -5
  7. package/es/script/aws/index.js +212 -129
  8. package/es/script/constants/index.js +75 -84
  9. package/es/script/deploy.js +44 -33
  10. package/es/script/index.js +37 -43
  11. package/es/script/package.json +4 -4
  12. package/es/script/release/index.js +152 -85
  13. package/es/script/release/release.js +168 -83
  14. package/es/script/uploadCode/index.js +309 -239
  15. package/es/script/uploadCode/uploadCode.js +433 -220
  16. package/es/script/utils/index.js +381 -265
  17. package/lib/bin/pisell.js +24 -4
  18. package/lib/index.d.ts +2 -3
  19. package/lib/index.js +23 -4
  20. package/lib/script/aws/index.js +124 -139
  21. package/lib/script/constants/index.js +110 -85
  22. package/lib/script/deploy.js +55 -34
  23. package/lib/script/index.js +56 -41
  24. package/lib/script/package.json +4 -4
  25. package/lib/script/release/index.js +108 -90
  26. package/lib/script/release/release.js +85 -82
  27. package/lib/script/uploadCode/index.js +230 -244
  28. package/lib/script/uploadCode/uploadCode.js +225 -222
  29. package/lib/script/utils/index.js +264 -270
  30. package/package.json +2 -2
  31. package/src/bin/pisell.js +3 -3
  32. package/src/script/aws/index.js +138 -138
  33. package/src/script/constants/index.js +86 -86
  34. package/src/script/deploy.js +29 -29
  35. package/src/script/index.js +45 -45
  36. package/src/script/package.json +4 -4
  37. package/src/script/release/index.js +119 -119
  38. package/src/script/release/release.js +87 -87
  39. package/src/script/uploadCode/index.js +284 -284
  40. package/src/script/uploadCode/uploadCode.js +255 -255
  41. package/src/script/utils/index.js +331 -331
  42. package/tsconfig.json +14 -14
  43. package/tsdown.config.ts +93 -93
  44. package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +0 -28
  45. package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +0 -14
  46. package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +0 -27
  47. package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +0 -16
  48. package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +0 -11
  49. package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +0 -12
  50. package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +0 -29
  51. package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +0 -14
  52. package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +0 -27
  53. package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +0 -16
  54. package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +0 -11
  55. package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +0 -18
  56. package/lib/_virtual/rolldown_runtime.js +0 -29
@@ -1,247 +1,317 @@
1
1
  #!/usr/bin/env zx
2
- import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js";
3
- import { getCurrentProjectName, getCurrentUserName, sendWebhook } from "../utils/index.js";
4
- import release_default from "../release/release.js";
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
4
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { 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 = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(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, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; 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, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(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 resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "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 next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(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(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; 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, y) : this.complete(a); }, complete: function complete(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), y; }, finish: function finish(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), resetTryEntry(r), y; } }, catch: function _catch(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; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
5
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
6
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
7
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
8
+ import inquirer from 'inquirer';
9
+ import 'zx/globals';
5
10
  import { uploadStaticToOSS } from "../aws/index.js";
6
- import uploadCode_default$1 from "./uploadCode.js";
7
- import inquirer from "inquirer";
8
- import "zx/globals";
9
-
10
- //#region src/script/uploadCode/index.js
11
- /**
12
- * @Title: 选择器函数
13
- * @Describe:
14
- * @Author: Wzw
15
- */
16
- const inquirerResult = () => {
17
- return inquirer.prompt([
18
- {
19
- type: "list",
20
- message: "请选择发布环境",
21
- name: "env",
22
- choices: [
23
- "release",
24
- "pre",
25
- "prod"
26
- ]
27
- },
28
- {
29
- type: "rawlist",
30
- message: "请选择当前更新版本号",
31
- name: "version",
32
- default: false,
33
- choices: [
34
- "patch",
35
- "minor",
36
- "major"
37
- ]
38
- },
39
- {
40
- type: "input",
41
- message: "请输入更新内容",
42
- name: "changelog",
43
- default: "update"
44
- },
45
- {
46
- type: "list",
47
- message: "上传之后是否执行发布",
48
- name: "is_release",
49
- choices: [{
50
- value: true,
51
- name: "上传并发布"
52
- }, {
53
- value: false,
54
- name: "只上传"
55
- }]
56
- },
57
- {
58
- type: "list",
59
- message: "是否执行build打包",
60
- name: "whether_build",
61
- choices: [{
62
- value: true,
63
- name: "执行打包"
64
- }, {
65
- value: false,
66
- name: "不执行打包,使用项目根目录/dist文件夹"
67
- }]
68
- },
69
- {
70
- type: "confirm",
71
- message: "确认信息无误",
72
- name: "is_confirm",
73
- default: true
74
- }
75
- ]);
11
+ import Release from "../release/release.js";
12
+ import { getCurrentProjectName, getCurrentUserName, sendWebhook } from "../utils/index.js";
13
+ import UploadCode from "./uploadCode.js";
14
+ // {\"post\":{\"zh_cn\":{\"title\":\"my_pisell_shop release环境开始上传并发布\",\"content\":[[{\"text\":\"发布人:\",\"style\":[\"bold\"]},{\"text\":\"左胜杰\",\"style\":[\"bold\"]}],[{\"text\":\"版本号:\",\"style\":[\"bold\"]},{\"text\":\"1.0.71\",\"style\":[\"bold\"]}]]}}}
15
+ /**
16
+ * @Title: 选择器函数
17
+ * @Describe:
18
+ * @Author: Wzw
19
+ */
20
+ var inquirerResult = function inquirerResult() {
21
+ return inquirer.prompt([
22
+ // {
23
+ // type: "list",
24
+ // message: "请选择项目",
25
+ // name: "project",
26
+ // choices: [
27
+ // {
28
+ // value: {
29
+ // path: "./",
30
+ // fileName: "my_pisel_shop"
31
+ // },
32
+ // name: "my_pisel_shop"
33
+ // },
34
+ // ],
35
+ // },
36
+ {
37
+ type: 'list',
38
+ message: '请选择发布环境',
39
+ name: 'env',
40
+ choices: ['release', 'pre', 'prod']
41
+ }, {
42
+ type: 'rawlist',
43
+ message: '请选择当前更新版本号',
44
+ name: 'version',
45
+ default: false,
46
+ choices: ['patch', 'minor', 'major']
47
+ }, {
48
+ type: 'input',
49
+ message: '请输入更新内容',
50
+ name: 'changelog',
51
+ default: 'update'
52
+ }, {
53
+ type: 'list',
54
+ message: '上传之后是否执行发布',
55
+ name: 'is_release',
56
+ choices: [{
57
+ value: true,
58
+ name: '上传并发布'
59
+ }, {
60
+ value: false,
61
+ name: '只上传'
62
+ }]
63
+ }, {
64
+ type: 'list',
65
+ message: '是否执行build打包',
66
+ name: 'whether_build',
67
+ choices: [{
68
+ value: true,
69
+ name: '执行打包'
70
+ }, {
71
+ value: false,
72
+ name: '不执行打包,使用项目根目录/dist文件夹'
73
+ }]
74
+ }, {
75
+ type: 'confirm',
76
+ message: '确认信息无误',
77
+ name: 'is_confirm',
78
+ default: true
79
+ }]);
76
80
  };
77
81
  function init() {
78
- return _init.apply(this, arguments);
82
+ return _init.apply(this, arguments);
79
83
  }
80
84
  function _init() {
81
- _init = _asyncToGenerator(function* () {
82
- let res = yield inquirerResult();
83
- if (!res.is_confirm) {
84
- console.log("取消发布");
85
- return;
86
- }
87
- /** 之前选择项目模式改为获取当前主项目 */
88
- res.project = {
89
- path: "./",
90
- fileName: getCurrentProjectName()
91
- };
92
- yield $`git fetch --prune-tags`;
93
- const uploadCode = new uploadCode_default$1(res);
94
- if (!(yield uploadCode.check())) return;
95
- console.log("开始更新版本号");
96
- const version = yield uploadCode.updateVersion();
97
- console.log("✅ 版本更新完成");
98
- const currentUserName = yield getCurrentUserName();
99
- const result = yield sendWebhook({
100
- title: `${res.project.fileName} ${res.env}环境开始${res.is_release ? "上传并发布" : "上传"}`,
101
- content: [
102
- {
103
- key: "发布人",
104
- value: currentUserName.replace("\n", "")
105
- },
106
- {
107
- key: "更新内容",
108
- value: res.changelog
109
- },
110
- {
111
- key: "版本号",
112
- value: version || ""
113
- }
114
- ]
115
- });
116
- console.log(result, "result");
117
- try {
118
- if (res.whether_build) {
119
- console.log("开始打包");
120
- yield uploadCode.build();
121
- console.log("✅ 打包完成");
122
- } else console.log("使用本地/dist");
123
- if (res.env === "prod") {
124
- let _fileName = res.project.fileName;
125
- if (res.env === "pre") _fileName = "pre_" + _fileName;
126
- if (_fileName === "admin") _fileName = "my_pisell_v2";
127
- if (![
128
- "xzero",
129
- "docs",
130
- "saas_admin",
131
- "saas_shop",
132
- "saas_shop_pos",
133
- "saas_kds",
134
- "saas_ads",
135
- "saas_home"
136
- ].includes(_fileName)) yield uploadStaticToOSS(_fileName);
137
- }
138
- console.log("开始压缩");
139
- yield uploadCode.compress();
140
- console.log("✅ 压缩完成");
141
- console.log("开始连接服务器");
142
- const conn = yield uploadCode.connectServer();
143
- console.log("✅ 连接服务器完成");
144
- console.log("开始上传");
145
- yield uploadCode.serverUpload();
146
- console.log("✅ 上传完成");
147
- console.log("开始解压");
148
- yield uploadCode.serverUnpack();
149
- if (res.is_release) {
150
- const releaseInstance = new release_default({
151
- project: res.project,
152
- env: res.env,
153
- version,
154
- conn
155
- });
156
- console.log("开始发布");
157
- yield releaseInstance.release();
158
- }
159
- yield uploadCode.disconnectServer();
160
- yield $`git pull --no-edit`;
161
- yield $`git push --follow-tags`;
162
- console.log("✅ 成功后推送到git");
163
- } catch (error) {
164
- console.log(error, "执行出错 请排查重试");
165
- yield $`git reset HEAD~1`;
166
- yield $`git tag -d v${uploadCode.currentVersion}`;
167
- yield sendWebhook({
168
- title: `${res.project.fileName} ${res.env}环境${res.is_release ? "上传并发布" : "上传"}失败`,
169
- content: [
170
- {
171
- key: "发布人",
172
- value: currentUserName.replace("\n", "")
173
- },
174
- {
175
- key: "更新内容",
176
- value: res.changelog
177
- },
178
- {
179
- key: "版本号",
180
- value: version || ""
181
- }
182
- ]
183
- });
184
- }
185
- yield sendWebhook({
186
- title: `${res.project.fileName} ${res.env}环境${res.is_release ? "上传并发布" : "上传"}成功`,
187
- content: [
188
- {
189
- key: "发布人",
190
- value: currentUserName.replace("\n", "")
191
- },
192
- {
193
- key: "更新内容",
194
- value: res.changelog
195
- },
196
- {
197
- key: "版本号",
198
- value: version || ""
199
- }
200
- ]
201
- });
202
- uploadCode.deleteLocalZip();
203
- });
204
- return _init.apply(this, arguments);
85
+ _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
86
+ var res, uploadCode, version, currentUserName, result, _fileName, conn, releaseInstance;
87
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
88
+ while (1) switch (_context.prev = _context.next) {
89
+ case 0:
90
+ _context.next = 2;
91
+ return inquirerResult();
92
+ case 2:
93
+ res = _context.sent;
94
+ if (res.is_confirm) {
95
+ _context.next = 6;
96
+ break;
97
+ }
98
+ console.log('取消发布');
99
+ return _context.abrupt("return");
100
+ case 6:
101
+ /** 之前选择项目模式改为获取当前主项目 */
102
+ res.project = {
103
+ path: './',
104
+ fileName: getCurrentProjectName()
105
+ };
106
+
107
+ // const data = await $`curl -X POST -H "Content-Type: application/json" -d '{"msg_type":"post","content":""}' https://open.feishu.cn/open-apis/bot/v2/hook/08349b0d-016c-4133-9442-9e95d4adc1e8`
108
+
109
+ // 删除本地在远程不存在的tag
110
+ _context.next = 9;
111
+ return $(_templateObject || (_templateObject = _taggedTemplateLiteral(["git fetch --prune-tags"])));
112
+ case 9:
113
+ uploadCode = new UploadCode(res);
114
+ _context.next = 12;
115
+ return uploadCode.check();
116
+ case 12:
117
+ if (_context.sent) {
118
+ _context.next = 14;
119
+ break;
120
+ }
121
+ return _context.abrupt("return");
122
+ case 14:
123
+ console.log('开始更新版本号');
124
+ _context.next = 17;
125
+ return uploadCode.updateVersion();
126
+ case 17:
127
+ version = _context.sent;
128
+ console.log('✅ 版本更新完成');
129
+ _context.next = 21;
130
+ return getCurrentUserName();
131
+ case 21:
132
+ currentUserName = _context.sent;
133
+ _context.next = 24;
134
+ return sendWebhook({
135
+ title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883\u5F00\u59CB").concat(res.is_release ? '上传并发布' : '上传'),
136
+ content: [{
137
+ key: '发布人',
138
+ value: currentUserName.replace('\n', '')
139
+ }, {
140
+ key: '更新内容',
141
+ value: res.changelog
142
+ }, {
143
+ key: '版本号',
144
+ value: version || ''
145
+ }]
146
+ });
147
+ case 24:
148
+ result = _context.sent;
149
+ console.log(result, 'result');
150
+ _context.prev = 26;
151
+ if (!res.whether_build) {
152
+ _context.next = 34;
153
+ break;
154
+ }
155
+ console.log('开始打包');
156
+ _context.next = 31;
157
+ return uploadCode.build();
158
+ case 31:
159
+ console.log('✅ 打包完成');
160
+ _context.next = 35;
161
+ break;
162
+ case 34:
163
+ console.log('使用本地/dist');
164
+ case 35:
165
+ if (!(res.env === 'prod')) {
166
+ _context.next = 42;
167
+ break;
168
+ }
169
+ _fileName = res.project.fileName;
170
+ if (res.env === 'pre') {
171
+ _fileName = 'pre_' + _fileName;
172
+ }
173
+ if (_fileName === 'admin') {
174
+ _fileName = 'my_pisell_v2';
175
+ }
176
+ if (['xzero', 'docs', 'saas_admin', 'saas_shop', 'saas_shop_pos', 'saas_kds', 'saas_ads', 'saas_home'].includes(_fileName)) {
177
+ _context.next = 42;
178
+ break;
179
+ }
180
+ _context.next = 42;
181
+ return uploadStaticToOSS(_fileName);
182
+ case 42:
183
+ console.log('开始压缩');
184
+ _context.next = 45;
185
+ return uploadCode.compress();
186
+ case 45:
187
+ console.log('✅ 压缩完成');
188
+ console.log('开始连接服务器');
189
+ _context.next = 49;
190
+ return uploadCode.connectServer();
191
+ case 49:
192
+ conn = _context.sent;
193
+ console.log('✅ 连接服务器完成');
194
+ console.log('开始上传');
195
+ _context.next = 54;
196
+ return uploadCode.serverUpload();
197
+ case 54:
198
+ console.log('✅ 上传完成');
199
+ console.log('开始解压');
200
+ _context.next = 58;
201
+ return uploadCode.serverUnpack();
202
+ case 58:
203
+ if (!res.is_release) {
204
+ _context.next = 63;
205
+ break;
206
+ }
207
+ releaseInstance = new Release({
208
+ project: res.project,
209
+ env: res.env,
210
+ version: version,
211
+ conn: conn
212
+ });
213
+ console.log('开始发布');
214
+ _context.next = 63;
215
+ return releaseInstance.release();
216
+ case 63:
217
+ _context.next = 65;
218
+ return uploadCode.disconnectServer();
219
+ case 65:
220
+ _context.next = 67;
221
+ return $(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["git pull --no-edit"])));
222
+ case 67:
223
+ _context.next = 69;
224
+ return $(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["git push --follow-tags"])));
225
+ case 69:
226
+ console.log('✅ 成功后推送到git');
227
+ _context.next = 81;
228
+ break;
229
+ case 72:
230
+ _context.prev = 72;
231
+ _context.t0 = _context["catch"](26);
232
+ console.log(_context.t0, '执行出错 请排查重试');
233
+ _context.next = 77;
234
+ return $(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["git reset HEAD~1"])));
235
+ case 77:
236
+ _context.next = 79;
237
+ return $(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["git tag -d v", ""])), uploadCode.currentVersion);
238
+ case 79:
239
+ _context.next = 81;
240
+ return sendWebhook({
241
+ title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883").concat(res.is_release ? '上传并发布' : '上传', "\u5931\u8D25"),
242
+ content: [{
243
+ key: '发布人',
244
+ value: currentUserName.replace('\n', '')
245
+ }, {
246
+ key: '更新内容',
247
+ value: res.changelog
248
+ }, {
249
+ key: '版本号',
250
+ value: version || ''
251
+ }]
252
+ });
253
+ case 81:
254
+ _context.next = 83;
255
+ return sendWebhook({
256
+ title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883").concat(res.is_release ? '上传并发布' : '上传', "\u6210\u529F"),
257
+ content: [{
258
+ key: '发布人',
259
+ value: currentUserName.replace('\n', '')
260
+ }, {
261
+ key: '更新内容',
262
+ value: res.changelog
263
+ }, {
264
+ key: '版本号',
265
+ value: version || ''
266
+ }]
267
+ });
268
+ case 83:
269
+ uploadCode.deleteLocalZip();
270
+ case 84:
271
+ case "end":
272
+ return _context.stop();
273
+ }
274
+ }, _callee, null, [[26, 72]]);
275
+ }));
276
+ return _init.apply(this, arguments);
205
277
  }
206
- var uploadCode_default = init;
207
- /**
208
- *
209
- * 上传
210
- * 1. 选择项目 环境等.
211
- * 2. 打包
212
- * 3. 打包完成后生成dist文件压缩包
213
- * 4. 重命名为当前版本号
214
- * 5. 上传到服务器,并解压. 上传完成
215
- *
216
- *
217
- *
218
- * 服务器目录结构:
219
- *
220
- * project: 所有前端项目
221
- *
222
- * my_pisel_h5: 某个项目文件夹
223
- *
224
- * master: 当前线上环境指向的代码包
225
- *
226
- * v1.0.0: 某个版本
227
- *
228
- *
229
- * 部署, 此部分可界面化.
230
- * 1. 将master备份, 把对应版本的代码合并到master内.
231
- * 2. 重启当前服务
232
- *
233
- *
234
- * 回滚指定版本
235
- *
236
- * 1. 将master内文件清空并将某个版本的包解压到master内
237
- * 2. 重启服务
238
- *
239
- * node端需要提供以下接口
240
- *
241
- * 1. 获取每个项目的所有版本包名称.
242
- * 2. 通过 项目 + 版本包名称 将对应的包更新至maser 实现发布
243
- * 3. 将操作记录写成日志存储.
244
- */
278
+ export default init;
245
279
 
246
- //#endregion
247
- export { uploadCode_default as default };
280
+ /**
281
+ *
282
+ * 上传
283
+ * 1. 选择项目 环境等.
284
+ * 2. 打包
285
+ * 3. 打包完成后生成dist文件压缩包
286
+ * 4. 重命名为当前版本号
287
+ * 5. 上传到服务器,并解压. 上传完成
288
+ *
289
+ *
290
+ *
291
+ * 服务器目录结构:
292
+ *
293
+ * project: 所有前端项目
294
+ *
295
+ * my_pisel_h5: 某个项目文件夹
296
+ *
297
+ * master: 当前线上环境指向的代码包
298
+ *
299
+ * v1.0.0: 某个版本
300
+ *
301
+ *
302
+ * 部署, 此部分可界面化.
303
+ * 1. 将master备份, 把对应版本的代码合并到master内.
304
+ * 2. 重启当前服务
305
+ *
306
+ *
307
+ * 回滚指定版本
308
+ *
309
+ * 1. 将master内文件清空并将某个版本的包解压到master内
310
+ * 2. 重启服务
311
+ *
312
+ * node端需要提供以下接口
313
+ *
314
+ * 1. 获取每个项目的所有版本包名称.
315
+ * 2. 通过 项目 + 版本包名称 将对应的包更新至maser 实现发布
316
+ * 3. 将操作记录写成日志存储.
317
+ */