@seayoo-web/finder 2.0.14 → 2.1.0
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.js +32 -10
- package/package.json +1 -1
- package/types/src/core.d.ts +11 -3
package/dist/index.js
CHANGED
|
@@ -41,13 +41,21 @@ function getAllFiles(dir, ignores = []) {
|
|
|
41
41
|
function isIgnoreFile(filePath, ignores) {
|
|
42
42
|
const filename = basename(filePath);
|
|
43
43
|
const dirs = normalize(filePath).split(sep);
|
|
44
|
-
return ignores.some((
|
|
45
|
-
if (
|
|
46
|
-
return dirs.includes(
|
|
44
|
+
return ignores.some((pattern) => {
|
|
45
|
+
if (pattern.endsWith("/")) {
|
|
46
|
+
return pattern.includes("*") ? dirs.some((dir) => getRegexp(pattern.slice(0, -1)).test(dir)) : dirs.includes(pattern.slice(0, -1));
|
|
47
47
|
}
|
|
48
|
-
return filename ===
|
|
48
|
+
return pattern.includes("*") ? getRegexp(pattern).test(filename) : filename === pattern;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
const pathRegCache = {};
|
|
52
|
+
const getRegexp = function(path2) {
|
|
53
|
+
if (path2 && pathRegCache[path2]) {
|
|
54
|
+
return pathRegCache[path2];
|
|
55
|
+
}
|
|
56
|
+
const fixRegStr = path2.replace(/([\\(){}\[\]\^\$\+\-\?\.|])/g, "\\$1").replace(/\*{1,}/g, ".*");
|
|
57
|
+
return pathRegCache[path2] = new RegExp("^" + fixRegStr + "$");
|
|
58
|
+
};
|
|
51
59
|
function pure(url) {
|
|
52
60
|
return url.replace(/(?:^https?:\/\/|\/*$)/gi, "");
|
|
53
61
|
}
|
|
@@ -286,16 +294,30 @@ async function finderDeploy(option) {
|
|
|
286
294
|
})
|
|
287
295
|
);
|
|
288
296
|
const lastDeployResult = results[results.length - 1];
|
|
289
|
-
if (
|
|
290
|
-
|
|
297
|
+
if (lastDeployResult && lastDeployResult.previewUrl) {
|
|
298
|
+
doPreview(lastDeployResult.previewUrl, preview);
|
|
291
299
|
}
|
|
292
|
-
return
|
|
300
|
+
return deployTo.join(",");
|
|
293
301
|
}
|
|
294
302
|
const deployResult = await deploy({ debug, target: deployTo, buffer, user, key, payload });
|
|
295
|
-
if (
|
|
296
|
-
|
|
303
|
+
if (deployResult && deployResult.previewUrl) {
|
|
304
|
+
doPreview(deployResult.previewUrl, preview);
|
|
305
|
+
}
|
|
306
|
+
return deployTo;
|
|
307
|
+
}
|
|
308
|
+
function doPreview(defaultPreviewUrl, option) {
|
|
309
|
+
if (!option) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (option === true) {
|
|
313
|
+
open(defaultPreviewUrl);
|
|
314
|
+
return;
|
|
297
315
|
}
|
|
298
|
-
|
|
316
|
+
const base = defaultPreviewUrl.replace(/index\.html.*$/i, "");
|
|
317
|
+
const files = Array.isArray(option) ? option : [option];
|
|
318
|
+
files.forEach((file) => {
|
|
319
|
+
open(base + file);
|
|
320
|
+
});
|
|
299
321
|
}
|
|
300
322
|
async function finderUpload(option) {
|
|
301
323
|
const { filePath, deployTo, user, key, preview, debug } = option;
|
package/package.json
CHANGED
package/types/src/core.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ import "colors";
|
|
|
3
3
|
export declare function finderDeploy(option: {
|
|
4
4
|
/** 需要推送的代码目录 */
|
|
5
5
|
dist: string;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* 忽略部署的文件,如果是目录则需要以 / 结尾,支持 * 占位符模糊匹配。
|
|
8
|
+
*
|
|
9
|
+
* 匹配时仅针对单一目录和文件名进行检查,不跨目录检查
|
|
10
|
+
*/
|
|
7
11
|
ignoreFiles?: string[];
|
|
8
12
|
/** 部署的目标地址 */
|
|
9
13
|
deployTo: string | string[];
|
|
@@ -13,8 +17,12 @@ export declare function finderDeploy(option: {
|
|
|
13
17
|
key: string;
|
|
14
18
|
/** 是否输出更多调试信息 */
|
|
15
19
|
debug?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
|
|
20
|
+
/**
|
|
21
|
+
* 是否部署完毕后打开目标文件(index.html)
|
|
22
|
+
*
|
|
23
|
+
* 也可以指定不同的目标文件
|
|
24
|
+
*/
|
|
25
|
+
preview?: boolean | string | string[];
|
|
18
26
|
/** 代码的 commit log 信息,换行用 \n */
|
|
19
27
|
commitLogs?: string;
|
|
20
28
|
}): Promise<string>;
|