@infly/libs 2.4.0 → 2.4.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/README.md +3 -3
- package/build/vite/index.d.ts +1 -1
- package/build/vite/index.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -187,13 +187,13 @@ export default defineConfig({
|
|
|
187
187
|
});
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
插件只在 `vite build` 时生效,默认向 `<head>`
|
|
190
|
+
插件只在 `vite build` 时生效,默认向 `<head>` 注入带 `+08:00` 的北京时间 ISO 8601 时间,不依赖构建机器或 Docker 的系统时区:
|
|
191
191
|
|
|
192
192
|
```html
|
|
193
|
-
<meta name="build-timestamp" content="2026-09-
|
|
193
|
+
<meta name="build-timestamp" content="2026-09-30T11:25:38.000+08:00">
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
-
可通过 `timestamp` 固定时间以支持可复现测试,通过 `metaName`
|
|
196
|
+
可通过 `timestamp` 固定时间以支持可复现测试,通过 `metaName` 调整字段名。该字段记录创建构建插件时的时间,不是 Jenkins 部署完成时间;新格式与原 UTC 格式表示同一实际时刻,可继续用 `Date.parse()` 读取。未显式引入该插件的既有项目行为不变。独立消费者须更新公共包锁文件并重新构建,已发布镜像中的 HTML 不会自动变化。
|
|
197
197
|
|
|
198
198
|
通用 workspace 与 Git 原语通过稳定子路径使用:
|
|
199
199
|
|
package/build/vite/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const BUILD_TIMESTAMP_META_NAME: "build-timestamp";
|
|
2
2
|
|
|
3
3
|
export interface BuildTimestampPluginOptions {
|
|
4
|
-
/**
|
|
4
|
+
/** 固定构建时间;默认使用创建插件时的当前时间,输出带 +08:00 的北京时间 ISO 8601。 */
|
|
5
5
|
timestamp?: string | Date;
|
|
6
6
|
/** 注入的 meta name;默认是 build-timestamp。 */
|
|
7
7
|
metaName?: string;
|
package/build/vite/index.js
CHANGED
|
@@ -5,7 +5,10 @@ function normalizeBuildTimestamp(value) {
|
|
|
5
5
|
if (Number.isNaN(date.getTime())) {
|
|
6
6
|
throw new TypeError("build timestamp must be a valid Date or date string");
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
// 固定以北京时间展示,不受开发电脑或 Docker 的系统时区影响。
|
|
9
|
+
// 输出必须携带 +08:00,让机器读取后仍得到原来的实际时刻。
|
|
10
|
+
const beijingDate = new Date(date.getTime() + 8 * 60 * 60 * 1000);
|
|
11
|
+
return beijingDate.toISOString().replace(/Z$/, "+08:00");
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
function normalizeMetaName(value) {
|
|
@@ -17,7 +20,7 @@ function normalizeMetaName(value) {
|
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
|
-
* 创建一个只在 Vite build
|
|
23
|
+
* 创建一个只在 Vite build 时生效的插件,把北京时间(UTC+8)写入最终 index.html。
|
|
21
24
|
*
|
|
22
25
|
* @param {{ timestamp?: string | Date, metaName?: string }} [options]
|
|
23
26
|
* @returns {object}
|