@taole/deploy-helper 1.1.1 → 1.1.3
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/index.mjs +1 -1
- package/lib/lightDeploy.mjs +12 -5
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -289,7 +289,7 @@ async function main() {
|
|
|
289
289
|
|
|
290
290
|
const needHandleLight = config.type === "ddfe:cdn";
|
|
291
291
|
if(needHandleLight){
|
|
292
|
-
await lightDeploy(config, mode
|
|
292
|
+
await lightDeploy(config, mode);
|
|
293
293
|
}
|
|
294
294
|
const needHandleAssets = config.assets && config.assets.dest;
|
|
295
295
|
|
package/lib/lightDeploy.mjs
CHANGED
|
@@ -18,11 +18,17 @@ function getErrorMessage(resJson, fallback) {
|
|
|
18
18
|
return fallback;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
async function apiCdnUpload({ distZipPath, prefix, mode, includeHtml, entryHtmlMap }, userCache) {
|
|
21
|
+
async function apiCdnUpload({ distZipPath, prefix, mode, includeHtml, entryHtmlMap, type, version }, userCache) {
|
|
22
22
|
const formData = new FormData();
|
|
23
23
|
formData.append("prefix", prefix);
|
|
24
24
|
formData.append("mode", mode);
|
|
25
25
|
formData.append("includeHtml", includeHtml ? "true" : "false");
|
|
26
|
+
if (type) {
|
|
27
|
+
formData.append("type", type);
|
|
28
|
+
}
|
|
29
|
+
if (version) {
|
|
30
|
+
formData.append("version", version);
|
|
31
|
+
}
|
|
26
32
|
if (entryHtmlMap) {
|
|
27
33
|
const entryHtmlMapStr =
|
|
28
34
|
typeof entryHtmlMap === "string" ? entryHtmlMap : JSON.stringify(entryHtmlMap);
|
|
@@ -52,10 +58,11 @@ async function apiCdnUpload({ distZipPath, prefix, mode, includeHtml, entryHtmlM
|
|
|
52
58
|
* light模式部署
|
|
53
59
|
* @param {*} config 配置
|
|
54
60
|
* @param {*} mode 部署环境
|
|
55
|
-
* @param {*} version 版本号
|
|
56
61
|
*/
|
|
57
|
-
export async function lightDeploy(config, mode
|
|
58
|
-
|
|
62
|
+
export async function lightDeploy(config, mode) {
|
|
63
|
+
const projectJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), "package.json"), "utf-8"));
|
|
64
|
+
const version = projectJson.version;
|
|
65
|
+
log(`light模式, 开始部署`, { mode, prefix: config.prefix, includeHtml: config.includeHtml, type: config.cdnType, version });
|
|
59
66
|
|
|
60
67
|
if (!mode || (mode !== "test" && mode !== "prod")) {
|
|
61
68
|
throw new Error("部署环境无效,仅支持 test 或 prod");
|
|
@@ -88,7 +95,7 @@ export async function lightDeploy(config, mode, version) {
|
|
|
88
95
|
log(`打包完成: ${distZipPath}`);
|
|
89
96
|
|
|
90
97
|
const includeHtml = config.includeHtml === true;
|
|
91
|
-
log(`开始上传至 CDN,mode=${mode}, prefix=${prefix}, includeHtml=${includeHtml}`);
|
|
98
|
+
log(`开始上传至 CDN,mode=${mode}, prefix=${prefix}, type=${config.cdnType || "project"}, version=${version}, includeHtml=${includeHtml}`);
|
|
92
99
|
const result = await apiCdnUpload(
|
|
93
100
|
{
|
|
94
101
|
distZipPath,
|