@pisell/common 0.0.56 → 0.0.57

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.
@@ -14,6 +14,9 @@ var filterFiles = ['index.html', 'umi.server.js', 'umi.server.d.ts'];
14
14
  var __dirname = process.cwd();
15
15
  var s3Client = null;
16
16
  var bucketName = '';
17
+ export var isAWSEnv = function isAWSEnv(env) {
18
+ return env === 'prod' || env === 'pre';
19
+ };
17
20
 
18
21
  /*******
19
22
  * @title: 初始化
@@ -7,6 +7,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
7
7
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
8
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
9
  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); }
10
+ import { isAWSEnv } from "../aws";
10
11
  import { isSsrMap, outPathMap } from "../constants/index.js";
11
12
  import { connectServer as _connectServer, getServerConfig, releaseProject } from "../utils/index.js";
12
13
 
@@ -52,7 +53,7 @@ var Release = /*#__PURE__*/function () {
52
53
  if (this.env === 'release') {
53
54
  serverConfig = serverConfigMap.cn[this.env];
54
55
  }
55
- if (this.env === 'prod') {
56
+ if (isAWSEnv(this.env)) {
56
57
  serverConfig = serverConfigMap.aws.service[this.env];
57
58
  serverConfig.privateKey = fs.readFileSync(serverConfig.privateKey);
58
59
  }
@@ -11,6 +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 { isAWSEnv } from "../aws";
14
15
  import { checkPackages, isSsrMap, outPathMap } from "../constants/index.js";
15
16
  import { checkPkgVersion, connectServer as _connectServer, getGitCurrentBranch, getServerConfig, isWorkingTreeClean, serverUnpack as _serverUnpack, serverUpload as _serverUpload } from "../utils/index.js";
16
17
 
@@ -110,7 +111,7 @@ var UploadCode = /*#__PURE__*/function () {
110
111
  return _context.abrupt("return", false);
111
112
  case 21:
112
113
  serverConfig = this.setConfig(serverConfigMap[this.env]);
113
- if (this.env === 'prod') {
114
+ if (isAWSEnv(this.env)) {
114
115
  serverConfig = serverConfigMap.aws.service[this.env];
115
116
  serverConfig.privateKey = fs.readFileSync(serverConfig.privateKey);
116
117
  this.setConfig(serverConfig);
@@ -13,6 +13,7 @@ import * as dotenv from 'dotenv';
13
13
  import npmCheck from 'npm-check';
14
14
  import path from 'path';
15
15
  import ssh2 from 'ssh2';
16
+ import { isAWSEnv } from "../aws";
16
17
 
17
18
  /**
18
19
  * @Title: 项目工作区是否干净
@@ -172,7 +173,7 @@ var serverUnpack = function serverUnpack(conn, _ref5) {
172
173
  reject(err);
173
174
  return;
174
175
  }
175
- stream.end(" ".concat(env === 'prod' ? 'sudo -i' : '', "\n cd /tmp\n mv ").concat(fullFileName, " ").concat(path, "\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 ").concat(env === 'prod' ? 'exit' : '', "\n ") // 打开到path
176
+ stream.end(" ".concat(isAWSEnv(env) ? 'sudo -i' : '', "\n cd /tmp\n mv ").concat(fullFileName, " ").concat(path, "\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 ").concat(isAWSEnv(env) ? 'exit' : '', "\n ") // 打开到path
176
177
  // 解压 1.0.0.zip 文件到 1.0.0 移动dist中内容到 1.0.0内 删除dist
177
178
  // 删除1.0.0.zip
178
179
  // 写入changelog到changelog.md
@@ -204,7 +205,7 @@ var releaseProject = function releaseProject(conn, _ref6) {
204
205
  reject(err);
205
206
  return;
206
207
  }
207
- stream.end(" ".concat(env === 'prod' ? 'sudo -i' : '', "\n cd ").concat(path, "\n cp -R -f pre-master next-master\n rm -rf pre-master\n \\cp -R -f ").concat(fileName, "/* next-master\n cp -R -f ").concat(fileName, " pre-master\n rm -rf master\n cp -R next-master master\n rm -rf next-master\n ").concat(isSSR ? 'pm2 restart server.js' : '', "\n exit\n ").concat(env === 'prod' ? 'exit' : '', "\n ") // 打开到path
208
+ stream.end(" ".concat(isAWSEnv(env) ? 'sudo -i' : '', "\n cd ").concat(path, "\n cp -R -f pre-master next-master\n rm -rf pre-master\n \\cp -R -f ").concat(fileName, "/* next-master\n cp -R -f ").concat(fileName, " pre-master\n rm -rf master\n cp -R next-master master\n rm -rf next-master\n ").concat(isSSR ? 'pm2 restart server.js' : '', "\n exit\n ").concat(isAWSEnv(env) ? 'exit' : '', "\n ") // 打开到path
208
209
  // 复制pre-master到next-master
209
210
  // 删除pre-master
210
211
  // 复制1.0.0到next-master
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/script/aws/index.js
30
30
  var aws_exports = {};
31
31
  __export(aws_exports, {
32
+ isAWSEnv: () => isAWSEnv,
32
33
  uploadFolderContents: () => uploadFolderContents,
33
34
  uploadStaticToOSS: () => uploadStaticToOSS
34
35
  });
@@ -42,6 +43,9 @@ var filterFiles = ["index.html", "umi.server.js", "umi.server.d.ts"];
42
43
  var __dirname = process.cwd();
43
44
  var s3Client = null;
44
45
  var bucketName = "";
46
+ var isAWSEnv = (env) => {
47
+ return env === "prod" || env === "pre";
48
+ };
45
49
  var init = async () => {
46
50
  try {
47
51
  const serverConfig = await (0, import_utils.getServerConfig)();
@@ -120,6 +124,7 @@ var uploadStaticToOSS = async (directory, folderPath = import_path.default.resol
120
124
  };
121
125
  // Annotate the CommonJS export names for ESM import in node:
122
126
  0 && (module.exports = {
127
+ isAWSEnv,
123
128
  uploadFolderContents,
124
129
  uploadStaticToOSS
125
130
  });
@@ -22,6 +22,7 @@ __export(release_exports, {
22
22
  default: () => release_default
23
23
  });
24
24
  module.exports = __toCommonJS(release_exports);
25
+ var import_aws = require("../aws");
25
26
  var import_constants = require("../constants/index.js");
26
27
  var import_utils = require("../utils/index.js");
27
28
  var Release = class {
@@ -45,7 +46,7 @@ var Release = class {
45
46
  if (this.env === "release") {
46
47
  serverConfig = serverConfigMap.cn[this.env];
47
48
  }
48
- if (this.env === "prod") {
49
+ if ((0, import_aws.isAWSEnv)(this.env)) {
49
50
  serverConfig = serverConfigMap.aws.service[this.env];
50
51
  serverConfig.privateKey = fs.readFileSync(serverConfig.privateKey);
51
52
  }
@@ -34,6 +34,7 @@ __export(uploadCode_exports, {
34
34
  module.exports = __toCommonJS(uploadCode_exports);
35
35
  var import_archiver = __toESM(require("archiver"));
36
36
  var import_path = __toESM(require("path"));
37
+ var import_aws = require("../aws");
37
38
  var import_constants = require("../constants/index.js");
38
39
  var import_utils = require("../utils/index.js");
39
40
  var UploadCode = class {
@@ -84,7 +85,7 @@ var UploadCode = class {
84
85
  return false;
85
86
  }
86
87
  let serverConfig = this.setConfig(serverConfigMap[this.env]);
87
- if (this.env === "prod") {
88
+ if ((0, import_aws.isAWSEnv)(this.env)) {
88
89
  serverConfig = serverConfigMap.aws.service[this.env];
89
90
  serverConfig.privateKey = fs.readFileSync(serverConfig.privateKey);
90
91
  this.setConfig(serverConfig);
@@ -49,6 +49,7 @@ var dotenv = __toESM(require("dotenv"));
49
49
  var import_npm_check = __toESM(require("npm-check"));
50
50
  var import_path = __toESM(require("path"));
51
51
  var import_ssh2 = __toESM(require("ssh2"));
52
+ var import_aws = require("../aws");
52
53
  var isWorkingTreeClean = async () => {
53
54
  const v = await $`git status --porcelain`;
54
55
  return v.stdout === "";
@@ -126,7 +127,7 @@ var serverUnpack = (conn, { path: path2, fileName, fullFileName, changelog, env
126
127
  return;
127
128
  }
128
129
  stream.end(
129
- ` ${env === "prod" ? "sudo -i" : ""}
130
+ ` ${(0, import_aws.isAWSEnv)(env) ? "sudo -i" : ""}
130
131
  cd /tmp
131
132
  mv ${fullFileName} ${path2}
132
133
  cd ${path2}
@@ -135,7 +136,7 @@ var serverUnpack = (conn, { path: path2, fileName, fullFileName, changelog, env
135
136
  echo "${changelog}" > ./${fileName}/changelog.md
136
137
  sh deleteOldVersion.sh
137
138
  exit
138
- ${env === "prod" ? "exit" : ""}
139
+ ${(0, import_aws.isAWSEnv)(env) ? "exit" : ""}
139
140
  `
140
141
  // 打开到path
141
142
  // 解压 1.0.0.zip 文件到 1.0.0 移动dist中内容到 1.0.0内 删除dist
@@ -160,7 +161,7 @@ var releaseProject = (conn, { path: path2, fileName, isSSR, env }) => {
160
161
  return;
161
162
  }
162
163
  stream.end(
163
- ` ${env === "prod" ? "sudo -i" : ""}
164
+ ` ${(0, import_aws.isAWSEnv)(env) ? "sudo -i" : ""}
164
165
  cd ${path2}
165
166
  cp -R -f pre-master next-master
166
167
  rm -rf pre-master
@@ -171,7 +172,7 @@ var releaseProject = (conn, { path: path2, fileName, isSSR, env }) => {
171
172
  rm -rf next-master
172
173
  ${isSSR ? "pm2 restart server.js" : ""}
173
174
  exit
174
- ${env === "prod" ? "exit" : ""}
175
+ ${(0, import_aws.isAWSEnv)(env) ? "exit" : ""}
175
176
  `
176
177
  // 打开到path
177
178
  // 复制pre-master到next-master
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/common",
3
- "version": "0.0.56",
3
+ "version": "0.0.57",
4
4
  "description": "A collection of reusable UI components for web development",
5
5
  "license": "MIT",
6
6
  "sideEffects": [