vite-plugin-deploy-oss 3.0.0 → 3.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.js +27 -3
- package/package.json +2 -4
package/dist/index.js
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import oss from "ali-oss";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
-
import deleteEmpty from "delete-empty";
|
|
5
4
|
import { globSync } from "glob";
|
|
6
|
-
import { stat, unlink } from "fs/promises";
|
|
5
|
+
import { readdir, rm, stat, unlink } from "fs/promises";
|
|
7
6
|
import { resolve } from "path";
|
|
8
7
|
import ora from "ora";
|
|
9
8
|
import { normalizePath } from "vite";
|
|
9
|
+
var GARBAGE_FILE_REGEX = /(?:Thumbs\.db|\.DS_Store)$/i;
|
|
10
|
+
var removeEmptyDirectories = async (rootDir) => {
|
|
11
|
+
const deletedDirectories = [];
|
|
12
|
+
const visit = async (dirPath) => {
|
|
13
|
+
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
14
|
+
let hasNonEmptyContent = false;
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
const entryPath = resolve(dirPath, entry.name);
|
|
17
|
+
if (entry.isDirectory()) {
|
|
18
|
+
const removed = await visit(entryPath);
|
|
19
|
+
if (!removed) hasNonEmptyContent = true;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (!GARBAGE_FILE_REGEX.test(entry.name)) {
|
|
23
|
+
hasNonEmptyContent = true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (hasNonEmptyContent) return false;
|
|
27
|
+
await rm(dirPath, { recursive: true, force: true });
|
|
28
|
+
deletedDirectories.push(dirPath);
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
31
|
+
await visit(resolve(rootDir));
|
|
32
|
+
return deletedDirectories;
|
|
33
|
+
};
|
|
10
34
|
var normalizeObjectKey = (targetDir, relativeFilePath) => normalizePath(`${targetDir}/${relativeFilePath}`).replace(/\/{2,}/g, "/").replace(/^\/+/, "");
|
|
11
35
|
var formatBytes = (bytes) => {
|
|
12
36
|
if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";
|
|
@@ -359,7 +383,7 @@ ${chalk.gray("\u7EDF\u8BA1:")}`);
|
|
|
359
383
|
console.log("");
|
|
360
384
|
}
|
|
361
385
|
try {
|
|
362
|
-
await
|
|
386
|
+
await removeEmptyDirectories(outDir);
|
|
363
387
|
} catch (error) {
|
|
364
388
|
console.warn(`${chalk.yellow("\u26A0 \u6E05\u7406\u7A7A\u76EE\u5F55\u5931\u8D25:")} ${error}`);
|
|
365
389
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-deploy-oss",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
"description": "将dist目录下的文件上传到阿里云oss",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/ali-oss": "^6.23.3",
|
|
35
|
-
"@types/
|
|
36
|
-
"@types/node": "^22.19.11",
|
|
35
|
+
"@types/node": "^22.19.13",
|
|
37
36
|
"tsup": "^8.5.1",
|
|
38
37
|
"typescript": "^5.9.3"
|
|
39
38
|
},
|
|
@@ -43,7 +42,6 @@
|
|
|
43
42
|
"dependencies": {
|
|
44
43
|
"ali-oss": "^6.23.0",
|
|
45
44
|
"chalk": "^5.6.2",
|
|
46
|
-
"delete-empty": "^3.0.0",
|
|
47
45
|
"glob": "^13.0.6",
|
|
48
46
|
"ora": "^9.3.0"
|
|
49
47
|
},
|