@pisell/common 0.0.42 → 0.0.44
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/es/script/uploadCode/index.js +57 -56
- package/es/script/utils/index.js +40 -2
- package/lib/script/uploadCode/index.js +32 -31
- package/lib/script/utils/index.js +13 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env zx
|
|
2
2
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
5
5
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
6
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); } }
|
|
@@ -9,7 +9,7 @@ import inquirer from 'inquirer';
|
|
|
9
9
|
import 'zx/globals';
|
|
10
10
|
import { uploadStaticToOSS } from "../aws/index.js";
|
|
11
11
|
import Release from "../release/release.js";
|
|
12
|
-
import { getCurrentProjectName, getCurrentUserName, sendWebhook } from "../utils/index.js";
|
|
12
|
+
import { deleteGitTag, getCurrentProjectName, getCurrentUserName, sendWebhook } from "../utils/index.js";
|
|
13
13
|
import UploadCode from "./uploadCode.js";
|
|
14
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
15
|
/**
|
|
@@ -171,40 +171,36 @@ function _init() {
|
|
|
171
171
|
case 34:
|
|
172
172
|
console.log('使用本地/dist');
|
|
173
173
|
case 35:
|
|
174
|
-
if (!(res.env === 'prod')) {
|
|
175
|
-
_context.next =
|
|
174
|
+
if (!(res.env === 'prod' && res.project.fileName !== 'my_pisel_shop')) {
|
|
175
|
+
_context.next = 39;
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
|
-
_fileName = res.project.fileName;
|
|
179
|
-
|
|
180
|
-
_fileName = 'pre_' + _fileName;
|
|
181
|
-
}
|
|
182
|
-
// 上传oss
|
|
183
|
-
_context.next = 40;
|
|
178
|
+
_fileName = res.project.fileName; // 上传oss
|
|
179
|
+
_context.next = 39;
|
|
184
180
|
return uploadStaticToOSS(_fileName);
|
|
185
|
-
case
|
|
181
|
+
case 39:
|
|
186
182
|
console.log('开始压缩');
|
|
187
|
-
_context.next =
|
|
183
|
+
_context.next = 42;
|
|
188
184
|
return uploadCode.compress();
|
|
189
|
-
case
|
|
185
|
+
case 42:
|
|
190
186
|
console.log('✅ 压缩完成');
|
|
191
187
|
console.log('开始连接服务器');
|
|
192
|
-
_context.next =
|
|
188
|
+
_context.next = 46;
|
|
193
189
|
return uploadCode.connectServer();
|
|
194
|
-
case
|
|
190
|
+
case 46:
|
|
195
191
|
conn = _context.sent;
|
|
196
192
|
console.log('✅ 连接服务器完成');
|
|
197
193
|
console.log('开始上传');
|
|
198
|
-
_context.next =
|
|
194
|
+
_context.next = 51;
|
|
199
195
|
return uploadCode.serverUpload();
|
|
200
|
-
case
|
|
196
|
+
case 51:
|
|
201
197
|
console.log('✅ 上传完成');
|
|
202
198
|
console.log('开始解压');
|
|
203
|
-
_context.next =
|
|
199
|
+
_context.next = 55;
|
|
204
200
|
return uploadCode.serverUnpack();
|
|
205
|
-
case
|
|
201
|
+
case 55:
|
|
206
202
|
if (!res.is_release) {
|
|
207
|
-
_context.next =
|
|
203
|
+
_context.next = 60;
|
|
208
204
|
break;
|
|
209
205
|
}
|
|
210
206
|
releaseInstance = new Release({
|
|
@@ -214,34 +210,34 @@ function _init() {
|
|
|
214
210
|
conn: conn
|
|
215
211
|
});
|
|
216
212
|
console.log('开始发布');
|
|
217
|
-
_context.next =
|
|
213
|
+
_context.next = 60;
|
|
218
214
|
return releaseInstance.release();
|
|
219
|
-
case
|
|
220
|
-
_context.next =
|
|
215
|
+
case 60:
|
|
216
|
+
_context.next = 62;
|
|
221
217
|
return uploadCode.disconnectServer();
|
|
222
|
-
case
|
|
223
|
-
_context.next =
|
|
218
|
+
case 62:
|
|
219
|
+
_context.next = 64;
|
|
224
220
|
return $(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["git pull --no-edit"])));
|
|
225
|
-
case
|
|
226
|
-
_context.next =
|
|
221
|
+
case 64:
|
|
222
|
+
_context.next = 66;
|
|
227
223
|
return $(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["git push --follow-tags"])));
|
|
228
|
-
case
|
|
224
|
+
case 66:
|
|
229
225
|
console.log('✅ 成功后推送到git');
|
|
230
|
-
|
|
231
|
-
|
|
226
|
+
|
|
227
|
+
// 只有在shop端发布
|
|
228
|
+
if (!(res.project.fileName === 'my_pisel_shop')) {
|
|
229
|
+
_context.next = 70;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
_context.next = 70;
|
|
233
|
+
return updateVersion({
|
|
234
|
+
version: version,
|
|
235
|
+
changelog: res.changelog
|
|
236
|
+
}, res.env);
|
|
232
237
|
case 70:
|
|
233
|
-
_context.
|
|
234
|
-
_context.t0 = _context["catch"](26);
|
|
235
|
-
console.log(_context.t0, '执行出错 请排查重试');
|
|
236
|
-
_context.next = 75;
|
|
237
|
-
return $(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["git reset HEAD~1"])));
|
|
238
|
-
case 75:
|
|
239
|
-
_context.next = 77;
|
|
240
|
-
return $(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["git tag -d v", ""])), uploadCode.currentVersion);
|
|
241
|
-
case 77:
|
|
242
|
-
_context.next = 79;
|
|
238
|
+
_context.next = 72;
|
|
243
239
|
return sendWebhook({
|
|
244
|
-
title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883").concat(res.is_release ? '上传并发布' : '上传', "\
|
|
240
|
+
title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883").concat(res.is_release ? '上传并发布' : '上传', "\u6210\u529F"),
|
|
245
241
|
content: [{
|
|
246
242
|
key: '发布人',
|
|
247
243
|
value: currentUserName.replace('\n', '')
|
|
@@ -253,20 +249,22 @@ function _init() {
|
|
|
253
249
|
value: version || ''
|
|
254
250
|
}]
|
|
255
251
|
});
|
|
252
|
+
case 72:
|
|
253
|
+
_context.next = 83;
|
|
254
|
+
break;
|
|
255
|
+
case 74:
|
|
256
|
+
_context.prev = 74;
|
|
257
|
+
_context.t0 = _context["catch"](26);
|
|
258
|
+
console.log(_context.t0, '执行出错 请排查重试');
|
|
259
|
+
_context.next = 79;
|
|
260
|
+
return $(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["git reset HEAD~1"])));
|
|
256
261
|
case 79:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
_context.next = 82;
|
|
262
|
-
return updateVersion({
|
|
263
|
-
version: version,
|
|
264
|
-
changelog: res.changelog
|
|
265
|
-
}, res.env);
|
|
266
|
-
case 82:
|
|
267
|
-
_context.next = 84;
|
|
262
|
+
_context.next = 81;
|
|
263
|
+
return deleteGitTag("v".concat(uploadCode.currentVersion));
|
|
264
|
+
case 81:
|
|
265
|
+
_context.next = 83;
|
|
268
266
|
return sendWebhook({
|
|
269
|
-
title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883").concat(res.is_release ? '上传并发布' : '上传', "\
|
|
267
|
+
title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883").concat(res.is_release ? '上传并发布' : '上传', "\u5931\u8D25"),
|
|
270
268
|
content: [{
|
|
271
269
|
key: '发布人',
|
|
272
270
|
value: currentUserName.replace('\n', '')
|
|
@@ -276,15 +274,18 @@ function _init() {
|
|
|
276
274
|
}, {
|
|
277
275
|
key: '版本号',
|
|
278
276
|
value: version || ''
|
|
277
|
+
}, {
|
|
278
|
+
key: '错误信息',
|
|
279
|
+
value: "".concat(_context.t0) || ''
|
|
279
280
|
}]
|
|
280
281
|
});
|
|
281
|
-
case
|
|
282
|
+
case 83:
|
|
282
283
|
uploadCode.deleteLocalZip();
|
|
283
|
-
case
|
|
284
|
+
case 84:
|
|
284
285
|
case "end":
|
|
285
286
|
return _context.stop();
|
|
286
287
|
}
|
|
287
|
-
}, _callee, null, [[26,
|
|
288
|
+
}, _callee, null, [[26, 74]]);
|
|
288
289
|
}));
|
|
289
290
|
return _init.apply(this, arguments);
|
|
290
291
|
}
|
package/es/script/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -373,4 +373,42 @@ var checkPkgVersion = /*#__PURE__*/function () {
|
|
|
373
373
|
return _ref10.apply(this, arguments);
|
|
374
374
|
};
|
|
375
375
|
}();
|
|
376
|
-
|
|
376
|
+
function deleteGitTag(_x3) {
|
|
377
|
+
return _deleteGitTag.apply(this, arguments);
|
|
378
|
+
}
|
|
379
|
+
function _deleteGitTag() {
|
|
380
|
+
_deleteGitTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(tag) {
|
|
381
|
+
var tags;
|
|
382
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
383
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
384
|
+
case 0:
|
|
385
|
+
_context7.prev = 0;
|
|
386
|
+
_context7.next = 3;
|
|
387
|
+
return $(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["git show-ref --tags"])));
|
|
388
|
+
case 3:
|
|
389
|
+
tags = _context7.sent;
|
|
390
|
+
tags = tags.stdout.split('\n').map(function (line) {
|
|
391
|
+
return line.split(' ')[1];
|
|
392
|
+
});
|
|
393
|
+
if (!tags.includes("refs/tags/".concat(tag))) {
|
|
394
|
+
_context7.next = 8;
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
_context7.next = 8;
|
|
398
|
+
return $(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["git tag -d ", ""])), tag);
|
|
399
|
+
case 8:
|
|
400
|
+
_context7.next = 13;
|
|
401
|
+
break;
|
|
402
|
+
case 10:
|
|
403
|
+
_context7.prev = 10;
|
|
404
|
+
_context7.t0 = _context7["catch"](0);
|
|
405
|
+
console.error("An error occurred: ".concat(_context7.t0));
|
|
406
|
+
case 13:
|
|
407
|
+
case "end":
|
|
408
|
+
return _context7.stop();
|
|
409
|
+
}
|
|
410
|
+
}, _callee7, null, [[0, 10]]);
|
|
411
|
+
}));
|
|
412
|
+
return _deleteGitTag.apply(this, arguments);
|
|
413
|
+
}
|
|
414
|
+
export { isWorkingTreeClean, getServerConfig, connectServer, serverUpload, serverUnpack, versionSort, releaseProject, getGitCurrentBranch, getCurrentProjectName, loadJSON, getCurrentUserName, sendWebhook, checkPkgVersion, deleteGitTag };
|
|
@@ -145,11 +145,8 @@ async function init() {
|
|
|
145
145
|
} else {
|
|
146
146
|
console.log("使用本地/dist");
|
|
147
147
|
}
|
|
148
|
-
if (res.env === "prod") {
|
|
148
|
+
if (res.env === "prod" && res.project.fileName !== "my_pisel_shop") {
|
|
149
149
|
let _fileName = res.project.fileName;
|
|
150
|
-
if (res.env === "pre") {
|
|
151
|
-
_fileName = "pre_" + _fileName;
|
|
152
|
-
}
|
|
153
150
|
await (0, import_aws.uploadStaticToOSS)(_fileName);
|
|
154
151
|
}
|
|
155
152
|
console.log("开始压缩");
|
|
@@ -177,10 +174,36 @@ async function init() {
|
|
|
177
174
|
await $`git pull --no-edit`;
|
|
178
175
|
await $`git push --follow-tags`;
|
|
179
176
|
console.log("✅ 成功后推送到git");
|
|
177
|
+
if (res.project.fileName === "my_pisel_shop") {
|
|
178
|
+
await updateVersion(
|
|
179
|
+
{
|
|
180
|
+
version,
|
|
181
|
+
changelog: res.changelog
|
|
182
|
+
},
|
|
183
|
+
res.env
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
await (0, import_utils.sendWebhook)({
|
|
187
|
+
title: `${res.project.fileName} ${res.env}环境${res.is_release ? "上传并发布" : "上传"}成功`,
|
|
188
|
+
content: [
|
|
189
|
+
{
|
|
190
|
+
key: "发布人",
|
|
191
|
+
value: currentUserName.replace("\n", "")
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
key: "更新内容",
|
|
195
|
+
value: res.changelog
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
key: "版本号",
|
|
199
|
+
value: version || ""
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
});
|
|
180
203
|
} catch (error) {
|
|
181
204
|
console.log(error, "执行出错 请排查重试");
|
|
182
205
|
await $`git reset HEAD~1`;
|
|
183
|
-
await
|
|
206
|
+
await (0, import_utils.deleteGitTag)(`v${uploadCode.currentVersion}`);
|
|
184
207
|
await (0, import_utils.sendWebhook)({
|
|
185
208
|
title: `${res.project.fileName} ${res.env}环境${res.is_release ? "上传并发布" : "上传"}失败`,
|
|
186
209
|
content: [
|
|
@@ -195,36 +218,14 @@ async function init() {
|
|
|
195
218
|
{
|
|
196
219
|
key: "版本号",
|
|
197
220
|
value: version || ""
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
key: "错误信息",
|
|
224
|
+
value: `${error}` || ""
|
|
198
225
|
}
|
|
199
226
|
]
|
|
200
227
|
});
|
|
201
228
|
}
|
|
202
|
-
if (res.project.fileName === "my_pisel_shop") {
|
|
203
|
-
await updateVersion(
|
|
204
|
-
{
|
|
205
|
-
version,
|
|
206
|
-
changelog: res.changelog
|
|
207
|
-
},
|
|
208
|
-
res.env
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
await (0, import_utils.sendWebhook)({
|
|
212
|
-
title: `${res.project.fileName} ${res.env}环境${res.is_release ? "上传并发布" : "上传"}成功`,
|
|
213
|
-
content: [
|
|
214
|
-
{
|
|
215
|
-
key: "发布人",
|
|
216
|
-
value: currentUserName.replace("\n", "")
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
key: "更新内容",
|
|
220
|
-
value: res.changelog
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
key: "版本号",
|
|
224
|
-
value: version || ""
|
|
225
|
-
}
|
|
226
|
-
]
|
|
227
|
-
});
|
|
228
229
|
uploadCode.deleteLocalZip();
|
|
229
230
|
}
|
|
230
231
|
async function updateVersion(params, env) {
|
|
@@ -31,6 +31,7 @@ var utils_exports = {};
|
|
|
31
31
|
__export(utils_exports, {
|
|
32
32
|
checkPkgVersion: () => checkPkgVersion,
|
|
33
33
|
connectServer: () => connectServer,
|
|
34
|
+
deleteGitTag: () => deleteGitTag,
|
|
34
35
|
getCurrentProjectName: () => getCurrentProjectName,
|
|
35
36
|
getCurrentUserName: () => getCurrentUserName,
|
|
36
37
|
getGitCurrentBranch: () => getGitCurrentBranch,
|
|
@@ -268,10 +269,22 @@ var checkPkgVersion = async (checkPackages) => {
|
|
|
268
269
|
message: errorMessage
|
|
269
270
|
};
|
|
270
271
|
};
|
|
272
|
+
async function deleteGitTag(tag) {
|
|
273
|
+
try {
|
|
274
|
+
let tags = await $`git show-ref --tags`;
|
|
275
|
+
tags = tags.stdout.split("\n").map((line) => line.split(" ")[1]);
|
|
276
|
+
if (tags.includes(`refs/tags/${tag}`)) {
|
|
277
|
+
await $`git tag -d ${tag}`;
|
|
278
|
+
}
|
|
279
|
+
} catch (error) {
|
|
280
|
+
console.error(`An error occurred: ${error}`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
271
283
|
// Annotate the CommonJS export names for ESM import in node:
|
|
272
284
|
0 && (module.exports = {
|
|
273
285
|
checkPkgVersion,
|
|
274
286
|
connectServer,
|
|
287
|
+
deleteGitTag,
|
|
275
288
|
getCurrentProjectName,
|
|
276
289
|
getCurrentUserName,
|
|
277
290
|
getGitCurrentBranch,
|