@pisell/common 0.0.21-bata → 0.0.21

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.
@@ -8,6 +8,22 @@ var outPathMap = {
8
8
  prod: '../data/release/project/pisell_v2',
9
9
  release: '../data/release/project/pisell_v2',
10
10
  pre: '../data/release/project/pisell_v2'
11
+ },
12
+ my_pisel_pc_v2: {
13
+ prod: '../data/release/project/my_pisel_pc_v2',
14
+ release: '../data/release/project/my_pisel_pc_v2',
15
+ pre: '../data/release/project/my_pisel_pc_v2'
16
+ },
17
+ my_pisel_h5_v2: {
18
+ prod: '../data/release/project/my_pisel_h5_v2',
19
+ release: '../data/release/project/my_pisel_h5_v2',
20
+ pre: '../data/release/project/my_pisel_h5_v2'
11
21
  }
12
22
  };
13
- export { outPathMap };
23
+ var isSsrMap = {
24
+ my_pisel_shop: false,
25
+ admin: false,
26
+ my_pisel_pc_v2: true,
27
+ my_pisel_h5_v2: true
28
+ };
29
+ export { outPathMap, isSsrMap };
@@ -71,7 +71,7 @@ var getVersionList = /*#__PURE__*/function () {
71
71
  case 0:
72
72
  env = _ref.env, project = _ref.project;
73
73
  _context.next = 3;
74
- return getServerConfig(project.fileName);
74
+ return getServerConfig();
75
75
  case 3:
76
76
  config = _context.sent;
77
77
  host = config[env].host;
@@ -43,7 +43,7 @@ var Release = /*#__PURE__*/function () {
43
43
  while (1) switch (_context.prev = _context.next) {
44
44
  case 0:
45
45
  _context.next = 2;
46
- return getServerConfig(this.projectName);
46
+ return getServerConfig();
47
47
  case 2:
48
48
  serverConfigMap = _context.sent;
49
49
  serverConfig = serverConfigMap[this.env]; // 选择release默认用国内cn服务器
@@ -11,7 +11,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
11
11
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
12
  import archiver from 'archiver';
13
13
  import path from 'path';
14
- import { outPathMap } from "../constants/index.js";
14
+ import { isSsrMap, outPathMap } from "../constants/index.js";
15
15
  import { connectServer as _connectServer, getGitCurrentBranch, getServerConfig, isWorkingTreeClean, serverUnpack as _serverUnpack, serverUpload as _serverUpload } from "../utils/index.js";
16
16
 
17
17
  /**
@@ -37,6 +37,8 @@ var UploadCode = /*#__PURE__*/function () {
37
37
  this.projectAbsolutePath = '';
38
38
  this.conn = null;
39
39
  this.serverConfig = null;
40
+ // 是否是ssr项目
41
+ this.isSSR = isSsrMap[this.projectName];
40
42
  this.outPath = outPathMap[this.projectName][this.env];
41
43
  }
42
44
 
@@ -66,7 +68,7 @@ var UploadCode = /*#__PURE__*/function () {
66
68
  while (1) switch (_context.prev = _context.next) {
67
69
  case 0:
68
70
  _context.next = 2;
69
- return getServerConfig(this.projectName);
71
+ return getServerConfig();
70
72
  case 2:
71
73
  serverConfigMap = _context.sent;
72
74
  if (serverConfigMap) {
@@ -342,7 +344,8 @@ var UploadCode = /*#__PURE__*/function () {
342
344
  path: this.outPath,
343
345
  fileName: "".concat(this.currentVersion),
344
346
  fullFileName: "".concat(this.currentVersion, ".zip"),
345
- changelog: this.changelog
347
+ changelog: this.changelog,
348
+ isSSR: this.isSSR
346
349
  });
347
350
  case 2:
348
351
  return _context7.abrupt("return", _context7.sent);
@@ -62,42 +62,27 @@ var getGitCurrentBranch = /*#__PURE__*/function () {
62
62
  };
63
63
  }();
64
64
 
65
- /**
66
- * monorepo项目名称
67
- * @type {string[]}
68
- */
69
- var monorepoProjectNameArr = ['admin'];
70
-
71
65
  /**
72
66
  * @Title: 获取本地lm_config.json配置信息
73
- * @Describe
67
+ * @Describe:
74
68
  * @Author: Zsj
75
69
  */
76
70
  var getServerConfig = /*#__PURE__*/function () {
77
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(project) {
71
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
78
72
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
79
73
  while (1) switch (_context3.prev = _context3.next) {
80
74
  case 0:
81
- if (!monorepoProjectNameArr.includes(project)) {
82
- _context3.next = 4;
83
- break;
84
- }
85
- _context3.next = 3;
86
- return fs.readJson('../../lm_config.json');
87
- case 3:
88
- return _context3.abrupt("return", _context3.sent);
89
- case 4:
90
- _context3.next = 6;
75
+ _context3.next = 2;
91
76
  return fs.readJson('../lm_config.json');
92
- case 6:
77
+ case 2:
93
78
  return _context3.abrupt("return", _context3.sent);
94
- case 7:
79
+ case 3:
95
80
  case "end":
96
81
  return _context3.stop();
97
82
  }
98
83
  }, _callee3);
99
84
  }));
100
- return function getServerConfig(_x) {
85
+ return function getServerConfig() {
101
86
  return _ref3.apply(this, arguments);
102
87
  };
103
88
  }();
@@ -170,7 +155,8 @@ var serverUnpack = function serverUnpack(conn, _ref5) {
170
155
  var path = _ref5.path,
171
156
  fileName = _ref5.fileName,
172
157
  fullFileName = _ref5.fullFileName,
173
- changelog = _ref5.changelog;
158
+ changelog = _ref5.changelog,
159
+ isSSR = _ref5.isSSR;
174
160
  if (!conn) return Promise.reject('未连接服务器');
175
161
  // 文件全名
176
162
  return new Promise(function (resolve, reject) {
@@ -180,7 +166,7 @@ var serverUnpack = function serverUnpack(conn, _ref5) {
180
166
  reject(err);
181
167
  return;
182
168
  }
183
- stream.end("\n cd ".concat(path, "\n unzip ").concat(fullFileName, " -d ").concat(fileName, " && mv ").concat(fileName, "/dist/* ").concat(fileName, "/ && rmdir ").concat(fileName, "/dist\n rm -rf ").concat(fullFileName, "\n echo \"").concat(changelog, "\" > ./").concat(fileName, "/changelog.md\n sh deleteOldVersion.sh\n exit\n ") // 打开到path
169
+ stream.end("\n cd ".concat(path, "\n unzip ").concat(fullFileName, " -d ").concat(fileName, " && mv ").concat(fileName, "/dist/* ").concat(fileName, "/ && rmdir ").concat(fileName, "/dist\n rm -rf ").concat(fullFileName, "\n echo \"").concat(changelog, "\" > ./").concat(fileName, "/changelog.md\n sh deleteOldVersion.sh\n ").concat(isSSR ? 'pm2 restart server.js' : '', "\n exit\n ") // 打开到path
184
170
  // 解压 1.0.0.zip 文件到 1.0.0 移动dist中内容到 1.0.0内 删除dist
185
171
  // 删除1.0.0.zip
186
172
  // 写入changelog到changelog.md
@@ -329,7 +315,7 @@ var sendWebhook = /*#__PURE__*/function () {
329
315
  }
330
316
  }, _callee5);
331
317
  }));
332
- return function sendWebhook(_x2) {
318
+ return function sendWebhook(_x) {
333
319
  return _ref9.apply(this, arguments);
334
320
  };
335
321
  }();
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/script/constants/index.js
20
20
  var constants_exports = {};
21
21
  __export(constants_exports, {
22
+ isSsrMap: () => isSsrMap,
22
23
  outPathMap: () => outPathMap
23
24
  });
24
25
  module.exports = __toCommonJS(constants_exports);
@@ -32,9 +33,26 @@ var outPathMap = {
32
33
  prod: "../data/release/project/pisell_v2",
33
34
  release: "../data/release/project/pisell_v2",
34
35
  pre: "../data/release/project/pisell_v2"
36
+ },
37
+ my_pisel_pc_v2: {
38
+ prod: "../data/release/project/my_pisel_pc_v2",
39
+ release: "../data/release/project/my_pisel_pc_v2",
40
+ pre: "../data/release/project/my_pisel_pc_v2"
41
+ },
42
+ my_pisel_h5_v2: {
43
+ prod: "../data/release/project/my_pisel_h5_v2",
44
+ release: "../data/release/project/my_pisel_h5_v2",
45
+ pre: "../data/release/project/my_pisel_h5_v2"
35
46
  }
36
47
  };
48
+ var isSsrMap = {
49
+ my_pisel_shop: false,
50
+ admin: false,
51
+ my_pisel_pc_v2: true,
52
+ my_pisel_h5_v2: true
53
+ };
37
54
  // Annotate the CommonJS export names for ESM import in node:
38
55
  0 && (module.exports = {
56
+ isSsrMap,
39
57
  outPathMap
40
58
  });
@@ -79,7 +79,7 @@ var inquirerResult = (versionList) => {
79
79
  };
80
80
  var ignoreName = ["master", ".git", "pre-master"];
81
81
  var getVersionList = async ({ env, project }) => {
82
- const config = await (0, import_utils.getServerConfig)(project.fileName);
82
+ const config = await (0, import_utils.getServerConfig)();
83
83
  let host = config[env].host;
84
84
  if (env === "release") {
85
85
  host = config.cn[env].host;
@@ -39,7 +39,7 @@ var Release = class {
39
39
  * @Author: Zsj
40
40
  */
41
41
  async setConfig() {
42
- const serverConfigMap = await (0, import_utils.getServerConfig)(this.projectName);
42
+ const serverConfigMap = await (0, import_utils.getServerConfig)();
43
43
  let serverConfig = serverConfigMap[this.env];
44
44
  if (this.env === "release") {
45
45
  serverConfig = serverConfigMap.cn[this.env];
@@ -49,6 +49,7 @@ var UploadCode = class {
49
49
  this.projectAbsolutePath = "";
50
50
  this.conn = null;
51
51
  this.serverConfig = null;
52
+ this.isSSR = import_constants.isSsrMap[this.projectName];
52
53
  this.outPath = import_constants.outPathMap[this.projectName][this.env];
53
54
  }
54
55
  /**
@@ -66,7 +67,7 @@ var UploadCode = class {
66
67
  * @Author: Zsj
67
68
  */
68
69
  async check() {
69
- const serverConfigMap = await (0, import_utils.getServerConfig)(this.projectName);
70
+ const serverConfigMap = await (0, import_utils.getServerConfig)();
70
71
  if (!serverConfigMap) {
71
72
  console.log("未找到发布脚本!");
72
73
  return false;
@@ -183,7 +184,8 @@ var UploadCode = class {
183
184
  path: this.outPath,
184
185
  fileName: `${this.currentVersion}`,
185
186
  fullFileName: `${this.currentVersion}.zip`,
186
- changelog: this.changelog
187
+ changelog: this.changelog,
188
+ isSSR: this.isSSR
187
189
  });
188
190
  }
189
191
  /**
@@ -54,11 +54,7 @@ var getGitCurrentBranch = async () => {
54
54
  const v = await $`git symbolic-ref --short HEAD`;
55
55
  return v.stdout;
56
56
  };
57
- var monorepoProjectNameArr = ["admin"];
58
- var getServerConfig = async (project) => {
59
- if (monorepoProjectNameArr.includes(project)) {
60
- return await fs.readJson("../../lm_config.json");
61
- }
57
+ var getServerConfig = async () => {
62
58
  return await fs.readJson("../lm_config.json");
63
59
  };
64
60
  var connectServer = (config2) => {
@@ -116,7 +112,7 @@ var serverUpload = (conn, { localPath, remotePath }) => {
116
112
  });
117
113
  });
118
114
  };
119
- var serverUnpack = (conn, { path: path2, fileName, fullFileName, changelog }) => {
115
+ var serverUnpack = (conn, { path: path2, fileName, fullFileName, changelog, isSSR }) => {
120
116
  if (!conn)
121
117
  return Promise.reject("未连接服务器");
122
118
  return new Promise((resolve, reject) => {
@@ -133,6 +129,7 @@ var serverUnpack = (conn, { path: path2, fileName, fullFileName, changelog }) =>
133
129
  rm -rf ${fullFileName}
134
130
  echo "${changelog}" > ./${fileName}/changelog.md
135
131
  sh deleteOldVersion.sh
132
+ ${isSSR ? "pm2 restart server.js" : ""}
136
133
  exit
137
134
  `
138
135
  // 打开到path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/common",
3
- "version": "0.0.21-bata",
3
+ "version": "0.0.21",
4
4
  "description": "A collection of reusable UI components for web development",
5
5
  "license": "MIT",
6
6
  "sideEffects": [