@seayoo-web/finder 2.0.0 → 2.0.1
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/dist/index.cjs +10 -13
- package/dist/index.js +11 -14
- package/package.json +1 -1
- package/src/compress.ts +4 -10
- package/src/core.ts +4 -4
- package/src/service.ts +4 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ const open = require("open");
|
|
|
6
6
|
require("colors");
|
|
7
7
|
const compressing = require("compressing");
|
|
8
8
|
const os = require("os");
|
|
9
|
-
const presetIgnores = ["node_modules/", ".git/", ".vscode/", ".DS_Store"];
|
|
9
|
+
const presetIgnores = ["node_modules/", ".git/", ".vscode/", "__MACOSX/", ".DS_Store"];
|
|
10
10
|
function compressToBuffer(sourceDir, ignoreFiles, debug) {
|
|
11
11
|
const ignoreFileList = [...presetIgnores, ...ignoreFiles || []];
|
|
12
12
|
const filesToCompress = getAllFiles(sourceDir, ignoreFileList);
|
|
@@ -24,13 +24,7 @@ function compressToBuffer(sourceDir, ignoreFiles, debug) {
|
|
|
24
24
|
}
|
|
25
25
|
const chunks = [];
|
|
26
26
|
return new Promise(function(resolve, reject) {
|
|
27
|
-
zipStream.on("data", (chunk) => chunks.push(chunk)).on("end", () =>
|
|
28
|
-
const buffer = Buffer.concat(chunks);
|
|
29
|
-
if (debug) {
|
|
30
|
-
fs.writeFileSync(path.join(process.cwd(), "_finder_deploy_buffer.zip"), buffer);
|
|
31
|
-
}
|
|
32
|
-
resolve(buffer);
|
|
33
|
-
}).on("error", reject);
|
|
27
|
+
zipStream.on("data", (chunk) => chunks.push(chunk)).on("end", () => resolve(Buffer.concat(chunks))).on("error", reject);
|
|
34
28
|
});
|
|
35
29
|
}
|
|
36
30
|
function getAllFiles(dir, ignores = []) {
|
|
@@ -124,7 +118,8 @@ const FinderServers = {
|
|
|
124
118
|
"finder.seayoo.io": [],
|
|
125
119
|
"finder.seayoo.com": [],
|
|
126
120
|
"finder.seayoo.internal": [],
|
|
127
|
-
"finder.dev.seayoo.com": []
|
|
121
|
+
"finder.dev.seayoo.com": [],
|
|
122
|
+
"finder.dev.seayoo.io": []
|
|
128
123
|
};
|
|
129
124
|
const FinderApiPaths = {
|
|
130
125
|
deploy: "/service/deploy",
|
|
@@ -246,7 +241,9 @@ async function getServerSupportedProjects(serverDomain, ignoreCache = false, deb
|
|
|
246
241
|
headers: { UserAgent: `web finder agent v2` }
|
|
247
242
|
});
|
|
248
243
|
if (status !== 200) {
|
|
249
|
-
|
|
244
|
+
if (!serverDomain.includes(".internal")) {
|
|
245
|
+
console.error(`服务器 ${inspectURL} 检查接口错误`.bgRed, (message || "").red);
|
|
246
|
+
}
|
|
250
247
|
return [];
|
|
251
248
|
}
|
|
252
249
|
if (!Array.isArray(data) || !data.every((d) => typeof d === "string")) {
|
|
@@ -268,9 +265,6 @@ async function finderDeploy(option) {
|
|
|
268
265
|
if (!fs.existsSync(path.resolve(dist)) || !fs.lstatSync(path.resolve(dist)).isDirectory()) {
|
|
269
266
|
throw "部署参数错误,dist 需要是一个存在的文件目录".bgRed + " " + dist.red;
|
|
270
267
|
}
|
|
271
|
-
const buffer = await compressToBuffer(dist, ignoreFiles || [], debug).catch((e) => {
|
|
272
|
-
throw "部署预处理之压缩代码失败".bgRed + " " + (e instanceof Error ? e.message : String(e));
|
|
273
|
-
});
|
|
274
268
|
const payload = commitLogs ? { 更新内容: commitLogs } : void 0;
|
|
275
269
|
if (debug) {
|
|
276
270
|
console.log({
|
|
@@ -283,6 +277,9 @@ async function finderDeploy(option) {
|
|
|
283
277
|
preview
|
|
284
278
|
});
|
|
285
279
|
}
|
|
280
|
+
const buffer = await compressToBuffer(dist, ignoreFiles, debug).catch((e) => {
|
|
281
|
+
throw "部署预处理之压缩代码失败".bgRed + " " + (e instanceof Error ? e.message : String(e));
|
|
282
|
+
});
|
|
286
283
|
if (Array.isArray(deployTo)) {
|
|
287
284
|
const results = await Promise.all(
|
|
288
285
|
deployTo.map((target) => {
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import fs, {
|
|
1
|
+
import fs, { readdirSync, lstatSync, existsSync, readFileSync, writeFileSync } from "fs";
|
|
2
2
|
import path, { relative, join, basename, normalize, sep, dirname, resolve, extname } from "path";
|
|
3
3
|
import open from "open";
|
|
4
4
|
import "colors";
|
|
5
5
|
import { zip } from "compressing";
|
|
6
6
|
import os from "os";
|
|
7
|
-
const presetIgnores = ["node_modules/", ".git/", ".vscode/", ".DS_Store"];
|
|
7
|
+
const presetIgnores = ["node_modules/", ".git/", ".vscode/", "__MACOSX/", ".DS_Store"];
|
|
8
8
|
function compressToBuffer(sourceDir, ignoreFiles, debug) {
|
|
9
9
|
const ignoreFileList = [...presetIgnores, ...ignoreFiles || []];
|
|
10
10
|
const filesToCompress = getAllFiles(sourceDir, ignoreFileList);
|
|
@@ -22,13 +22,7 @@ function compressToBuffer(sourceDir, ignoreFiles, debug) {
|
|
|
22
22
|
}
|
|
23
23
|
const chunks = [];
|
|
24
24
|
return new Promise(function(resolve2, reject) {
|
|
25
|
-
zipStream.on("data", (chunk) => chunks.push(chunk)).on("end", () =>
|
|
26
|
-
const buffer = Buffer.concat(chunks);
|
|
27
|
-
if (debug) {
|
|
28
|
-
writeFileSync(join(process.cwd(), "_finder_deploy_buffer.zip"), buffer);
|
|
29
|
-
}
|
|
30
|
-
resolve2(buffer);
|
|
31
|
-
}).on("error", reject);
|
|
25
|
+
zipStream.on("data", (chunk) => chunks.push(chunk)).on("end", () => resolve2(Buffer.concat(chunks))).on("error", reject);
|
|
32
26
|
});
|
|
33
27
|
}
|
|
34
28
|
function getAllFiles(dir, ignores = []) {
|
|
@@ -122,7 +116,8 @@ const FinderServers = {
|
|
|
122
116
|
"finder.seayoo.io": [],
|
|
123
117
|
"finder.seayoo.com": [],
|
|
124
118
|
"finder.seayoo.internal": [],
|
|
125
|
-
"finder.dev.seayoo.com": []
|
|
119
|
+
"finder.dev.seayoo.com": [],
|
|
120
|
+
"finder.dev.seayoo.io": []
|
|
126
121
|
};
|
|
127
122
|
const FinderApiPaths = {
|
|
128
123
|
deploy: "/service/deploy",
|
|
@@ -244,7 +239,9 @@ async function getServerSupportedProjects(serverDomain, ignoreCache = false, deb
|
|
|
244
239
|
headers: { UserAgent: `web finder agent v2` }
|
|
245
240
|
});
|
|
246
241
|
if (status !== 200) {
|
|
247
|
-
|
|
242
|
+
if (!serverDomain.includes(".internal")) {
|
|
243
|
+
console.error(`服务器 ${inspectURL} 检查接口错误`.bgRed, (message || "").red);
|
|
244
|
+
}
|
|
248
245
|
return [];
|
|
249
246
|
}
|
|
250
247
|
if (!Array.isArray(data) || !data.every((d) => typeof d === "string")) {
|
|
@@ -266,9 +263,6 @@ async function finderDeploy(option) {
|
|
|
266
263
|
if (!existsSync(resolve(dist)) || !lstatSync(resolve(dist)).isDirectory()) {
|
|
267
264
|
throw "部署参数错误,dist 需要是一个存在的文件目录".bgRed + " " + dist.red;
|
|
268
265
|
}
|
|
269
|
-
const buffer = await compressToBuffer(dist, ignoreFiles || [], debug).catch((e) => {
|
|
270
|
-
throw "部署预处理之压缩代码失败".bgRed + " " + (e instanceof Error ? e.message : String(e));
|
|
271
|
-
});
|
|
272
266
|
const payload = commitLogs ? { 更新内容: commitLogs } : void 0;
|
|
273
267
|
if (debug) {
|
|
274
268
|
console.log({
|
|
@@ -281,6 +275,9 @@ async function finderDeploy(option) {
|
|
|
281
275
|
preview
|
|
282
276
|
});
|
|
283
277
|
}
|
|
278
|
+
const buffer = await compressToBuffer(dist, ignoreFiles, debug).catch((e) => {
|
|
279
|
+
throw "部署预处理之压缩代码失败".bgRed + " " + (e instanceof Error ? e.message : String(e));
|
|
280
|
+
});
|
|
284
281
|
if (Array.isArray(deployTo)) {
|
|
285
282
|
const results = await Promise.all(
|
|
286
283
|
deployTo.map((target) => {
|
package/package.json
CHANGED
package/src/compress.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { readdirSync, lstatSync
|
|
1
|
+
import { readdirSync, lstatSync } from "fs";
|
|
2
2
|
import { join, relative, normalize, basename, sep } from "path";
|
|
3
3
|
|
|
4
4
|
import { zip } from "compressing";
|
|
5
5
|
|
|
6
6
|
// 部署代码默认的忽略列表
|
|
7
|
-
const presetIgnores = ["node_modules/", ".git/", ".vscode/", ".DS_Store"];
|
|
7
|
+
const presetIgnores = ["node_modules/", ".git/", ".vscode/", "__MACOSX/", ".DS_Store"];
|
|
8
8
|
|
|
9
9
|
/** 代码压缩 */
|
|
10
10
|
export function compressToBuffer(sourceDir: string, ignoreFiles?: string[], debug?: boolean): Promise<Buffer> {
|
|
@@ -28,14 +28,8 @@ export function compressToBuffer(sourceDir: string, ignoreFiles?: string[], debu
|
|
|
28
28
|
return new Promise(function (resolve, reject) {
|
|
29
29
|
zipStream
|
|
30
30
|
.on("data", (chunk) => chunks.push(chunk as Buffer))
|
|
31
|
-
.on("end", () =>
|
|
32
|
-
|
|
33
|
-
if (debug) {
|
|
34
|
-
writeFileSync(join(process.cwd(), "_finder_deploy_buffer.zip"), buffer);
|
|
35
|
-
}
|
|
36
|
-
resolve(buffer);
|
|
37
|
-
})
|
|
38
|
-
.on("error", reject); // 处理错误
|
|
31
|
+
.on("end", () => resolve(Buffer.concat(chunks)))
|
|
32
|
+
.on("error", reject);
|
|
39
33
|
});
|
|
40
34
|
}
|
|
41
35
|
|
package/src/core.ts
CHANGED
|
@@ -34,10 +34,6 @@ export async function finderDeploy(option: {
|
|
|
34
34
|
if (!existsSync(resolve(dist)) || !lstatSync(resolve(dist)).isDirectory()) {
|
|
35
35
|
throw "部署参数错误,dist 需要是一个存在的文件目录".bgRed + " " + dist.red;
|
|
36
36
|
}
|
|
37
|
-
// 压缩代码准备上传
|
|
38
|
-
const buffer = await compressToBuffer(dist, ignoreFiles || [], debug).catch((e) => {
|
|
39
|
-
throw "部署预处理之压缩代码失败".bgRed + " " + (e instanceof Error ? e.message : String(e));
|
|
40
|
-
});
|
|
41
37
|
const payload = commitLogs ? { 更新内容: commitLogs } : undefined;
|
|
42
38
|
if (debug) {
|
|
43
39
|
console.log({
|
|
@@ -50,6 +46,10 @@ export async function finderDeploy(option: {
|
|
|
50
46
|
preview,
|
|
51
47
|
});
|
|
52
48
|
}
|
|
49
|
+
// 压缩代码准备上传
|
|
50
|
+
const buffer = await compressToBuffer(dist, ignoreFiles, debug).catch((e) => {
|
|
51
|
+
throw "部署预处理之压缩代码失败".bgRed + " " + (e instanceof Error ? e.message : String(e));
|
|
52
|
+
});
|
|
53
53
|
if (Array.isArray(deployTo)) {
|
|
54
54
|
// 多次部署
|
|
55
55
|
const results = await Promise.all(
|
package/src/service.ts
CHANGED
|
@@ -9,6 +9,7 @@ const FinderServers: Record<string, string[]> = {
|
|
|
9
9
|
"finder.seayoo.com": [],
|
|
10
10
|
"finder.seayoo.internal": [],
|
|
11
11
|
"finder.dev.seayoo.com": [],
|
|
12
|
+
"finder.dev.seayoo.io": [],
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
/** finder 的 api path */
|
|
@@ -164,7 +165,9 @@ async function getServerSupportedProjects(
|
|
|
164
165
|
headers: { UserAgent: `web finder agent v2` },
|
|
165
166
|
});
|
|
166
167
|
if (status !== 200) {
|
|
167
|
-
|
|
168
|
+
if (!serverDomain.includes(".internal")) {
|
|
169
|
+
console.error(`服务器 ${inspectURL} 检查接口错误`.bgRed, (message || "").red);
|
|
170
|
+
}
|
|
168
171
|
return [];
|
|
169
172
|
}
|
|
170
173
|
if (!Array.isArray(data) || !data.every((d) => typeof d === "string")) {
|