@pisell/common 1.0.57 → 1.0.58
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/CHANGELOG.md +7 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +28 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +16 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +11 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +12 -0
- package/es/bin/pisell.js +5 -1
- package/es/index.d.ts +3 -1
- package/es/index.js +5 -1
- package/es/script/aws/index.js +127 -210
- package/es/script/constants/index.js +84 -69
- package/es/script/deploy.js +33 -44
- package/es/script/index.js +43 -37
- package/es/script/release/index.js +83 -150
- package/es/script/release/release.js +82 -167
- package/es/script/uploadCode/index.js +238 -308
- package/es/script/uploadCode/uploadCode.js +219 -432
- package/es/script/utils/index.js +255 -369
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +29 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +16 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +11 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +18 -0
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/bin/pisell.js +4 -24
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -23
- package/lib/script/aws/index.js +139 -124
- package/lib/script/constants/index.js +85 -104
- package/lib/script/deploy.js +34 -55
- package/lib/script/index.js +41 -56
- package/lib/script/release/index.js +90 -108
- package/lib/script/release/release.js +82 -85
- package/lib/script/uploadCode/index.js +244 -229
- package/lib/script/uploadCode/uploadCode.js +222 -224
- package/lib/script/utils/index.js +270 -264
- package/package.json +2 -2
- package/src/script/constants/index.js +6 -0
- package/src/script/uploadCode/index.js +1 -0
- package/src/script/uploadCode/uploadCode.js +1 -0
- package/src/script/utils/index.js +3 -1
|
@@ -1,228 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_asyncToGenerator = require('../../_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js');
|
|
3
|
+
const require_script_utils_index = require('../utils/index.js');
|
|
4
|
+
const require_script_constants_index = require('../constants/index.js');
|
|
5
|
+
let path = require("path");
|
|
6
|
+
path = require_rolldown_runtime.__toESM(path);
|
|
7
|
+
let archiver = require("archiver");
|
|
8
|
+
archiver = require_rolldown_runtime.__toESM(archiver);
|
|
28
9
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var import_archiver = __toESM(require("archiver"));
|
|
36
|
-
var import_path = __toESM(require("path"));
|
|
37
|
-
var import_constants = require("../constants/index.js");
|
|
38
|
-
var import_utils = require("../utils/index.js");
|
|
10
|
+
//#region src/script/uploadCode/uploadCode.js
|
|
11
|
+
/**
|
|
12
|
+
* @Title: 上传代码至服务器类
|
|
13
|
+
* @Describe:
|
|
14
|
+
* @Author: Zsj
|
|
15
|
+
*/
|
|
39
16
|
var UploadCode = class {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
17
|
+
constructor(props) {
|
|
18
|
+
const { project, env, version, changelog, is_release } = props;
|
|
19
|
+
this.projectName = project.fileName;
|
|
20
|
+
this.projectRelativePath = project.path;
|
|
21
|
+
this.env = env;
|
|
22
|
+
this.version = version;
|
|
23
|
+
this.changelog = changelog;
|
|
24
|
+
this.is_release = is_release;
|
|
25
|
+
this.currentVersion = "";
|
|
26
|
+
this.projectAbsolutePath = "";
|
|
27
|
+
this.conn = null;
|
|
28
|
+
this.serverConfig = null;
|
|
29
|
+
this.isSSR = require_script_constants_index.isSsrMap[this.projectName];
|
|
30
|
+
this.outPath = require_script_constants_index.outPathMap[this.projectName][this.env];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @Title: 设置服务器连接配置
|
|
34
|
+
* @Describe:
|
|
35
|
+
* @Author: Zsj
|
|
36
|
+
*/
|
|
37
|
+
setConfig(serverConfig) {
|
|
38
|
+
this.serverConfig = serverConfig;
|
|
39
|
+
return this.serverConfig;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @Title: 发布前检查环境和参数是否正确
|
|
43
|
+
* @Describe:
|
|
44
|
+
* @Author: Zsj
|
|
45
|
+
*/
|
|
46
|
+
check() {
|
|
47
|
+
var _this = this;
|
|
48
|
+
return require_asyncToGenerator._asyncToGenerator(function* () {
|
|
49
|
+
const serverConfigMap = yield require_script_utils_index.getServerConfig(_this.projectName);
|
|
50
|
+
if (!serverConfigMap) {
|
|
51
|
+
console.log("未找到发布脚本!");
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
cd(_this.projectRelativePath);
|
|
55
|
+
_this.projectAbsolutePath = process.cwd();
|
|
56
|
+
if (!(yield require_script_utils_index.isWorkingTreeClean())) {
|
|
57
|
+
console.log("工作区不干净, 请先提交代码");
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const { success, message } = yield require_script_utils_index.checkPkgVersion(require_script_constants_index.checkPackages);
|
|
61
|
+
if (!success) {
|
|
62
|
+
console.log(message);
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
let serverConfig = _this.setConfig(serverConfigMap[_this.env]);
|
|
66
|
+
if (_this.env === "release") serverConfig = _this.setConfig(serverConfigMap.cn[_this.env]);
|
|
67
|
+
if (_this.env === "prod") serverConfig = _this.setConfig(serverConfigMap["prod3"]);
|
|
68
|
+
if (_this.env === "prod" && [
|
|
69
|
+
"xzero",
|
|
70
|
+
"saas_admin",
|
|
71
|
+
"saas_shop",
|
|
72
|
+
"saas_shop_pos",
|
|
73
|
+
"saas_kds",
|
|
74
|
+
"saas_ads",
|
|
75
|
+
"saas_home"
|
|
76
|
+
].includes(_this.projectName)) {
|
|
77
|
+
serverConfig = serverConfigMap.aws.service[_this.env];
|
|
78
|
+
serverConfig.privateKey = fs.readFileSync(serverConfig.privateKey);
|
|
79
|
+
}
|
|
80
|
+
if (_this.env === "prod" && ["admin", "docs"].includes(_this.projectName)) {
|
|
81
|
+
serverConfig = serverConfigMap.aws.service[_this.env];
|
|
82
|
+
serverConfig.privateKey = fs.readFileSync("../../../pem/pisell-pro.pem");
|
|
83
|
+
}
|
|
84
|
+
console.log(serverConfig, "serverConfig");
|
|
85
|
+
_this.setConfig(serverConfig);
|
|
86
|
+
if (!serverConfig) {
|
|
87
|
+
console.log("您当前没有权限!");
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
console.log("当前主项目分支", yield require_script_utils_index.getGitCurrentBranch());
|
|
91
|
+
return true;
|
|
92
|
+
})();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @Title: 更新项目中version 并加入changelog
|
|
96
|
+
* @Describe:
|
|
97
|
+
* @Author: Zsj
|
|
98
|
+
*/
|
|
99
|
+
updateVersion() {
|
|
100
|
+
var _this2 = this;
|
|
101
|
+
return require_asyncToGenerator._asyncToGenerator(function* () {
|
|
102
|
+
if (_this2.env === "prod") {
|
|
103
|
+
yield $`npm version ${_this2.version} -m "%s ${_this2.changelog}"`;
|
|
104
|
+
let { version } = yield fs.readJson("./package.json");
|
|
105
|
+
_this2.currentVersion = version;
|
|
106
|
+
}
|
|
107
|
+
if (_this2.env !== "prod") {
|
|
108
|
+
yield $`npm version ${_this2.version} --no-git-tag-version`;
|
|
109
|
+
yield $`git add package.json`;
|
|
110
|
+
let { version } = yield fs.readJson("./package.json");
|
|
111
|
+
_this2.currentVersion = version;
|
|
112
|
+
yield $`git commit -m "chore: ${_this2.currentVersion} ${_this2.changelog}"`;
|
|
113
|
+
}
|
|
114
|
+
return _this2.currentVersion;
|
|
115
|
+
})();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @Title: 根据env执行打包
|
|
119
|
+
* @Describe:
|
|
120
|
+
* @Author: Zsj
|
|
121
|
+
*/
|
|
122
|
+
build() {
|
|
123
|
+
var _this3 = this;
|
|
124
|
+
return require_asyncToGenerator._asyncToGenerator(function* () {
|
|
125
|
+
yield $`npm run build:${_this3.env}`;
|
|
126
|
+
})();
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @Title: 压缩dist文件为zip
|
|
130
|
+
* @Describe:
|
|
131
|
+
* @Author: Zsj
|
|
132
|
+
*/
|
|
133
|
+
compress() {
|
|
134
|
+
var _this4 = this;
|
|
135
|
+
return require_asyncToGenerator._asyncToGenerator(function* () {
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
137
|
+
const __dirname = process.cwd();
|
|
138
|
+
const zipFile = path.default.resolve(__dirname, `${_this4.currentVersion}.zip`);
|
|
139
|
+
const originFilePath = path.default.resolve(__dirname, "dist");
|
|
140
|
+
const output = fs.createWriteStream(zipFile);
|
|
141
|
+
const archive = (0, archiver.default)("zip", { zlib: { level: 9 } });
|
|
142
|
+
archive.on("error", function(err) {
|
|
143
|
+
reject(err);
|
|
144
|
+
});
|
|
145
|
+
output.on("close", function() {
|
|
146
|
+
resolve(true);
|
|
147
|
+
});
|
|
148
|
+
archive.pipe(output);
|
|
149
|
+
archive.directory(originFilePath, "/dist");
|
|
150
|
+
archive.finalize();
|
|
151
|
+
});
|
|
152
|
+
})();
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* @Title: 连接服务器
|
|
156
|
+
* @Describe:
|
|
157
|
+
* @Author: Zsj
|
|
158
|
+
*/
|
|
159
|
+
connectServer() {
|
|
160
|
+
var _this5 = this;
|
|
161
|
+
return require_asyncToGenerator._asyncToGenerator(function* () {
|
|
162
|
+
if (!_this5.serverConfig) {
|
|
163
|
+
console.log("未找到发布配置!");
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
_this5.conn = yield require_script_utils_index.connectServer(_this5.serverConfig);
|
|
167
|
+
return _this5.conn;
|
|
168
|
+
})();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* @Title: 本地zip文件上传到服务器
|
|
172
|
+
* @Describe:
|
|
173
|
+
* @Author: Zsj
|
|
174
|
+
*/
|
|
175
|
+
serverUpload() {
|
|
176
|
+
var _this6 = this;
|
|
177
|
+
return require_asyncToGenerator._asyncToGenerator(function* () {
|
|
178
|
+
const localPath = path.default.resolve(_this6.projectAbsolutePath, `${_this6.currentVersion}.zip`);
|
|
179
|
+
const remotePath = `/tmp/${_this6.projectName}-${_this6.currentVersion}.zip`;
|
|
180
|
+
return yield require_script_utils_index.serverUpload(_this6.conn, {
|
|
181
|
+
localPath,
|
|
182
|
+
remotePath
|
|
183
|
+
});
|
|
184
|
+
})();
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* @Title: 服务器中解压文件
|
|
188
|
+
* @Describe:
|
|
189
|
+
* @Author: Zsj
|
|
190
|
+
*/
|
|
191
|
+
serverUnpack() {
|
|
192
|
+
var _this7 = this;
|
|
193
|
+
return require_asyncToGenerator._asyncToGenerator(function* () {
|
|
194
|
+
return yield require_script_utils_index.serverUnpack(_this7.conn, {
|
|
195
|
+
path: _this7.outPath,
|
|
196
|
+
fileName: `${_this7.currentVersion}`,
|
|
197
|
+
fullFileName: `${_this7.projectName}-${_this7.currentVersion}.zip`,
|
|
198
|
+
changelog: _this7.changelog,
|
|
199
|
+
env: _this7.env
|
|
200
|
+
});
|
|
201
|
+
})();
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* @Title: 删除本地zip文件
|
|
205
|
+
* @Describe:
|
|
206
|
+
* @Author: Zsj
|
|
207
|
+
*/
|
|
208
|
+
deleteLocalZip() {
|
|
209
|
+
return $`rm -rf ${this.currentVersion}.zip`;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* @Title: 断开服务连接
|
|
213
|
+
* @Describe:
|
|
214
|
+
* @Author: Zsj
|
|
215
|
+
*/
|
|
216
|
+
disconnectServer() {
|
|
217
|
+
var _this8 = this;
|
|
218
|
+
return require_asyncToGenerator._asyncToGenerator(function* () {
|
|
219
|
+
return yield _this8.conn.end();
|
|
220
|
+
})();
|
|
221
|
+
}
|
|
227
222
|
};
|
|
228
223
|
var uploadCode_default = UploadCode;
|
|
224
|
+
|
|
225
|
+
//#endregion
|
|
226
|
+
module.exports = uploadCode_default;
|