@xiping/vite-version 1.0.39 → 1.0.42
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/lib/index.js +17 -2
- package/package.json +4 -6
package/lib/index.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 格式化日期为 YYYY-MM-DD HH:mm:ss 格式
|
|
5
|
+
* @param date 日期对象
|
|
6
|
+
* @returns 格式化后的日期字符串
|
|
7
|
+
*/
|
|
8
|
+
function formatDateTime(date) {
|
|
9
|
+
const year = date.getFullYear();
|
|
10
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
11
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
12
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
13
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
14
|
+
const seconds = String(date.getSeconds()).padStart(2, "0");
|
|
15
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
16
|
+
}
|
|
4
17
|
export function viteVersionPlugin(props) {
|
|
5
18
|
const defaultOptions = {
|
|
6
19
|
filename: "version.txt",
|
|
@@ -21,7 +34,9 @@ export function viteVersionPlugin(props) {
|
|
|
21
34
|
// Get the output directory from Vite config
|
|
22
35
|
const outDir = _outDir || "dist";
|
|
23
36
|
// Create version.txt content with build time
|
|
24
|
-
const
|
|
37
|
+
const now = new Date();
|
|
38
|
+
const timezoneName = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
39
|
+
const buildTime = `${formatDateTime(now)} (${timezoneName})`;
|
|
25
40
|
let versionContent = `Build Time: ${buildTime}`;
|
|
26
41
|
if (options.infoText) {
|
|
27
42
|
versionContent += `\n${options.infoText}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiping/vite-version",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "vite-version",
|
|
6
6
|
"author": "The-End-Hero <527409987@qq.com>",
|
|
@@ -25,19 +25,17 @@
|
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/The-End-Hero/wang-ping/issues"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "86d1f6807922c588006ad1bb0b8843080a32a207",
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public",
|
|
31
31
|
"registry": "https://registry.npmjs.org/"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "^24.
|
|
35
|
-
"dayjs": "^1.11.18",
|
|
34
|
+
"@types/node": "^24.10.1",
|
|
36
35
|
"typescript": "^5.9.3",
|
|
37
|
-
"vite": "^7.
|
|
36
|
+
"vite": "^7.2.4"
|
|
38
37
|
},
|
|
39
38
|
"peerDependencies": {
|
|
40
|
-
"dayjs": "^1.0.0 || ^2.0.0",
|
|
41
39
|
"vite": ">=3.0.0"
|
|
42
40
|
}
|
|
43
41
|
}
|