@pisell/common 0.0.61 → 0.0.62

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.
@@ -6,9 +6,7 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
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); } }
7
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
8
  import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
9
- import { NodeHttpHandler } from '@smithy/node-http-handler';
10
9
  import fs from 'fs';
11
- import { Agent } from 'https';
12
10
  import mime from 'mime-types';
13
11
  import path from 'path';
14
12
  import { getServerConfig } from "../utils/index.js";
@@ -49,17 +47,7 @@ var init = /*#__PURE__*/function () {
49
47
  credentials: {
50
48
  accessKeyId: awsConfig.accessKeyId,
51
49
  secretAccessKey: awsConfig.secretAccessKey
52
- },
53
- requestHandler: new NodeHttpHandler({
54
- httpsAgent: new Agent({
55
- maxSockets: 500,
56
- // keepAlive is a default from AWS SDK. We want to preserve this for
57
- // performance reasons.
58
- keepAlive: true,
59
- keepAliveMsecs: 1000
60
- }),
61
- socketTimeout: 5000
62
- })
50
+ }
63
51
  });
64
52
  console.log('aws 初始化成功');
65
53
  return _context.abrupt("return", serverConfig.aws);
@@ -79,6 +79,16 @@ var inquirerResult = function inquirerResult() {
79
79
  default: true
80
80
  }]);
81
81
  };
82
+
83
+ // 手动上传oss
84
+ var isManuallyUploadOss = function isManuallyUploadOss() {
85
+ return inquirer.prompt([{
86
+ type: 'confirm',
87
+ message: '是否手动上传oss',
88
+ name: 'is_manually_upload_OSS',
89
+ default: false
90
+ }]);
91
+ };
82
92
  var inquirerOss = function inquirerOss() {
83
93
  return inquirer.prompt([{
84
94
  type: 'confirm',
@@ -101,7 +111,7 @@ function init() {
101
111
  */
102
112
  function _init() {
103
113
  _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
104
- var res, uploadCode, version, currentUserName, result, _fileName, ossRes, conn, releaseInstance, branch, grayBranch;
114
+ var res, isManuallyOss, isManuallyOssRes, uploadCode, version, currentUserName, result, _fileName, ossRes, conn, releaseInstance, branch, grayBranch;
105
115
  return _regeneratorRuntime().wrap(function _callee$(_context) {
106
116
  while (1) switch (_context.prev = _context.next) {
107
117
  case 0:
@@ -109,13 +119,24 @@ function _init() {
109
119
  return inquirerResult();
110
120
  case 2:
111
121
  res = _context.sent;
122
+ isManuallyOss = false;
112
123
  if (res.is_confirm) {
113
- _context.next = 6;
124
+ _context.next = 7;
114
125
  break;
115
126
  }
116
127
  console.log('取消发布');
117
128
  return _context.abrupt("return");
118
- case 6:
129
+ case 7:
130
+ if (!(res.env === 'prod')) {
131
+ _context.next = 12;
132
+ break;
133
+ }
134
+ _context.next = 10;
135
+ return isManuallyUploadOss();
136
+ case 10:
137
+ isManuallyOssRes = _context.sent;
138
+ isManuallyOss = isManuallyOssRes.is_manually_upload_OSS;
139
+ case 12:
119
140
  /** 之前选择项目模式改为获取当前主项目 */
120
141
  res.project = {
121
142
  path: './',
@@ -125,30 +146,30 @@ function _init() {
125
146
  // 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`
126
147
 
127
148
  // 删除本地在远程不存在的tag
128
- _context.next = 9;
149
+ _context.next = 15;
129
150
  return $(_templateObject || (_templateObject = _taggedTemplateLiteral(["git fetch --prune-tags"])));
130
- case 9:
151
+ case 15:
131
152
  uploadCode = new UploadCode(res);
132
- _context.next = 12;
153
+ _context.next = 18;
133
154
  return uploadCode.check();
134
- case 12:
155
+ case 18:
135
156
  if (_context.sent) {
136
- _context.next = 14;
157
+ _context.next = 20;
137
158
  break;
138
159
  }
139
160
  return _context.abrupt("return");
140
- case 14:
161
+ case 20:
141
162
  console.log('开始更新版本号');
142
- _context.next = 17;
163
+ _context.next = 23;
143
164
  return uploadCode.updateVersion();
144
- case 17:
165
+ case 23:
145
166
  version = _context.sent;
146
167
  console.log('✅ 版本更新完成');
147
- _context.next = 21;
168
+ _context.next = 27;
148
169
  return getCurrentUserName();
149
- case 21:
170
+ case 27:
150
171
  currentUserName = _context.sent;
151
- _context.next = 24;
172
+ _context.next = 30;
152
173
  return sendWebhook({
153
174
  title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883\u5F00\u59CB").concat(res.is_release ? '上传并发布' : '上传'),
154
175
  content: [{
@@ -162,64 +183,68 @@ function _init() {
162
183
  value: version || ''
163
184
  }]
164
185
  });
165
- case 24:
186
+ case 30:
166
187
  result = _context.sent;
167
188
  console.log(result, 'result');
168
- _context.prev = 26;
189
+ _context.prev = 32;
169
190
  if (!res.whether_build) {
170
- _context.next = 34;
191
+ _context.next = 40;
171
192
  break;
172
193
  }
173
194
  console.log('开始打包');
174
- _context.next = 31;
195
+ _context.next = 37;
175
196
  return uploadCode.build();
176
- case 31:
197
+ case 37:
177
198
  console.log('✅ 打包完成');
178
- _context.next = 35;
199
+ _context.next = 41;
179
200
  break;
180
- case 34:
201
+ case 40:
181
202
  console.log('使用本地/dist');
182
- case 35:
203
+ case 41:
183
204
  if (!(res.env === 'prod')) {
184
- _context.next = 44;
205
+ _context.next = 51;
206
+ break;
207
+ }
208
+ if (isManuallyOss) {
209
+ _context.next = 51;
185
210
  break;
186
211
  }
187
212
  _fileName = res.project.fileName; // 上传oss
188
- _context.next = 39;
213
+ _context.next = 46;
189
214
  return uploadStaticToOSS(_fileName);
190
- case 39:
191
- _context.next = 41;
215
+ case 46:
216
+ _context.next = 48;
192
217
  return inquirerOss();
193
- case 41:
218
+ case 48:
194
219
  ossRes = _context.sent;
195
220
  if (ossRes.is_upload_completed_OSS) {
196
- _context.next = 44;
221
+ _context.next = 51;
197
222
  break;
198
223
  }
199
224
  return _context.abrupt("return");
200
- case 44:
225
+ case 51:
201
226
  console.log('开始压缩');
202
- _context.next = 47;
227
+ _context.next = 54;
203
228
  return uploadCode.compress();
204
- case 47:
229
+ case 54:
205
230
  console.log('✅ 压缩完成');
206
231
  console.log('开始连接服务器');
207
- _context.next = 51;
232
+ _context.next = 58;
208
233
  return uploadCode.connectServer();
209
- case 51:
234
+ case 58:
210
235
  conn = _context.sent;
211
236
  console.log('✅ 连接服务器完成');
212
237
  console.log('开始上传');
213
- _context.next = 56;
238
+ _context.next = 63;
214
239
  return uploadCode.serverUpload();
215
- case 56:
240
+ case 63:
216
241
  console.log('✅ 上传完成');
217
242
  console.log('开始解压');
218
- _context.next = 60;
243
+ _context.next = 67;
219
244
  return uploadCode.serverUnpack();
220
- case 60:
245
+ case 67:
221
246
  if (!res.is_release) {
222
- _context.next = 70;
247
+ _context.next = 77;
223
248
  break;
224
249
  }
225
250
  releaseInstance = new Release({
@@ -229,40 +254,40 @@ function _init() {
229
254
  conn: conn
230
255
  });
231
256
  console.log('开始发布');
232
- _context.next = 65;
257
+ _context.next = 72;
233
258
  return getGitCurrentBranch();
234
- case 65:
259
+ case 72:
235
260
  branch = _context.sent;
236
261
  grayBranch = 'master';
237
262
  if (!originBranch.includes(branch.trim())) {
238
263
  grayBranch = branch;
239
264
  }
240
- _context.next = 70;
265
+ _context.next = 77;
241
266
  return releaseInstance.release(grayBranch);
242
- case 70:
243
- _context.next = 72;
267
+ case 77:
268
+ _context.next = 79;
244
269
  return uploadCode.disconnectServer();
245
- case 72:
246
- _context.next = 74;
270
+ case 79:
271
+ _context.next = 81;
247
272
  return $(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["git pull --no-edit"])));
248
- case 74:
249
- _context.next = 76;
273
+ case 81:
274
+ _context.next = 83;
250
275
  return $(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["git push --follow-tags"])));
251
- case 76:
276
+ case 83:
252
277
  console.log('✅ 成功后推送到git');
253
278
 
254
279
  // 只有在shop端发布
255
280
  if (!(res.project.fileName === 'my_pisel_shop')) {
256
- _context.next = 80;
281
+ _context.next = 87;
257
282
  break;
258
283
  }
259
- _context.next = 80;
284
+ _context.next = 87;
260
285
  return updateVersion({
261
286
  version: version,
262
287
  changelog: res.changelog
263
288
  }, res.env);
264
- case 80:
265
- _context.next = 82;
289
+ case 87:
290
+ _context.next = 89;
266
291
  return sendWebhook({
267
292
  title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883").concat(res.is_release ? '上传并发布' : '上传', "\u6210\u529F"),
268
293
  content: [{
@@ -276,20 +301,20 @@ function _init() {
276
301
  value: version || ''
277
302
  }]
278
303
  });
279
- case 82:
280
- _context.next = 93;
304
+ case 89:
305
+ _context.next = 100;
281
306
  break;
282
- case 84:
283
- _context.prev = 84;
284
- _context.t0 = _context["catch"](26);
307
+ case 91:
308
+ _context.prev = 91;
309
+ _context.t0 = _context["catch"](32);
285
310
  console.log(_context.t0, '执行出错 请排查重试');
286
- _context.next = 89;
311
+ _context.next = 96;
287
312
  return $(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["git reset HEAD~1"])));
288
- case 89:
289
- _context.next = 91;
313
+ case 96:
314
+ _context.next = 98;
290
315
  return deleteGitTag("v".concat(uploadCode.currentVersion));
291
- case 91:
292
- _context.next = 93;
316
+ case 98:
317
+ _context.next = 100;
293
318
  return sendWebhook({
294
319
  title: "".concat(res.project.fileName, " ").concat(res.env, "\u73AF\u5883").concat(res.is_release ? '上传并发布' : '上传', "\u5931\u8D25"),
295
320
  content: [{
@@ -306,13 +331,13 @@ function _init() {
306
331
  value: "".concat(_context.t0) || ''
307
332
  }]
308
333
  });
309
- case 93:
334
+ case 100:
310
335
  uploadCode.deleteLocalZip();
311
- case 94:
336
+ case 101:
312
337
  case "end":
313
338
  return _context.stop();
314
339
  }
315
- }, _callee, null, [[26, 84]]);
340
+ }, _callee, null, [[32, 91]]);
316
341
  }));
317
342
  return _init.apply(this, arguments);
318
343
  }
@@ -34,9 +34,7 @@ __export(aws_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(aws_exports);
36
36
  var import_client_s3 = require("@aws-sdk/client-s3");
37
- var import_node_http_handler = require("@smithy/node-http-handler");
38
37
  var import_fs = __toESM(require("fs"));
39
- var import_https = require("https");
40
38
  var import_mime_types = __toESM(require("mime-types"));
41
39
  var import_path = __toESM(require("path"));
42
40
  var import_utils = require("../utils/index.js");
@@ -55,17 +53,7 @@ var init = async () => {
55
53
  credentials: {
56
54
  accessKeyId: awsConfig.accessKeyId,
57
55
  secretAccessKey: awsConfig.secretAccessKey
58
- },
59
- requestHandler: new import_node_http_handler.NodeHttpHandler({
60
- httpsAgent: new import_https.Agent({
61
- maxSockets: 500,
62
- // keepAlive is a default from AWS SDK. We want to preserve this for
63
- // performance reasons.
64
- keepAlive: true,
65
- keepAliveMsecs: 1e3
66
- }),
67
- socketTimeout: 5e3
68
- })
56
+ }
69
57
  });
70
58
  console.log("aws 初始化成功");
71
59
  return serverConfig.aws;
@@ -101,6 +101,16 @@ var inquirerResult = () => {
101
101
  }
102
102
  ]);
103
103
  };
104
+ var isManuallyUploadOss = () => {
105
+ return import_inquirer.default.prompt([
106
+ {
107
+ type: "confirm",
108
+ message: "是否手动上传oss",
109
+ name: "is_manually_upload_OSS",
110
+ default: false
111
+ }
112
+ ]);
113
+ };
104
114
  var inquirerOss = () => {
105
115
  return import_inquirer.default.prompt([
106
116
  {
@@ -113,10 +123,15 @@ var inquirerOss = () => {
113
123
  };
114
124
  async function init() {
115
125
  let res = await inquirerResult();
126
+ let isManuallyOss = false;
116
127
  if (!res.is_confirm) {
117
128
  console.log("取消发布");
118
129
  return;
119
130
  }
131
+ if (res.env === "prod") {
132
+ const isManuallyOssRes = await isManuallyUploadOss();
133
+ isManuallyOss = isManuallyOssRes.is_manually_upload_OSS;
134
+ }
120
135
  res.project = {
121
136
  path: "./",
122
137
  fileName: (0, import_utils.getCurrentProjectName)()
@@ -157,11 +172,13 @@ async function init() {
157
172
  console.log("使用本地/dist");
158
173
  }
159
174
  if (res.env === "prod") {
160
- let _fileName = res.project.fileName;
161
- await (0, import_aws.uploadStaticToOSS)(_fileName);
162
- const ossRes = await inquirerOss();
163
- if (!ossRes.is_upload_completed_OSS) {
164
- return;
175
+ if (!isManuallyOss) {
176
+ let _fileName = res.project.fileName;
177
+ await (0, import_aws.uploadStaticToOSS)(_fileName);
178
+ const ossRes = await inquirerOss();
179
+ if (!ossRes.is_upload_completed_OSS) {
180
+ return;
181
+ }
165
182
  }
166
183
  }
167
184
  console.log("开始压缩");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/common",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "description": "A collection of reusable UI components for web development",
5
5
  "license": "MIT",
6
6
  "sideEffects": [
@@ -59,7 +59,6 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@aws-sdk/client-s3": "^3.456.0",
62
- "@smithy/node-http-handler": "^2.1.10",
63
62
  "antd5": "npm:antd@^5.5.0",
64
63
  "archiver": "^5.3.1",
65
64
  "array-move": "^3.0.1",