@xiping/vite-version 1.0.40 → 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.
Files changed (2) hide show
  1. package/lib/index.js +16 -8
  2. package/package.json +2 -4
package/lib/index.js CHANGED
@@ -1,11 +1,19 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import dayjs from "dayjs";
4
- import utc from "dayjs/plugin/utc";
5
- import timezone from "dayjs/plugin/timezone";
6
- // 扩展 dayjs 以支持时区
7
- dayjs.extend(utc);
8
- dayjs.extend(timezone);
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
+ }
9
17
  export function viteVersionPlugin(props) {
10
18
  const defaultOptions = {
11
19
  filename: "version.txt",
@@ -26,9 +34,9 @@ export function viteVersionPlugin(props) {
26
34
  // Get the output directory from Vite config
27
35
  const outDir = _outDir || "dist";
28
36
  // Create version.txt content with build time
29
- const now = dayjs();
37
+ const now = new Date();
30
38
  const timezoneName = Intl.DateTimeFormat().resolvedOptions().timeZone;
31
- const buildTime = `${now.format("YYYY-MM-DD HH:mm:ss")} (${timezoneName})`;
39
+ const buildTime = `${formatDateTime(now)} (${timezoneName})`;
32
40
  let versionContent = `Build Time: ${buildTime}`;
33
41
  if (options.infoText) {
34
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.40",
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": "e7557a98b36680d243416591410267142f2ad4e6",
28
+ "gitHead": "86d1f6807922c588006ad1bb0b8843080a32a207",
29
29
  "publishConfig": {
30
30
  "access": "public",
31
31
  "registry": "https://registry.npmjs.org/"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^24.10.1",
35
- "dayjs": "^1.11.19",
36
35
  "typescript": "^5.9.3",
37
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
  }