unplugin-version-injector 1.1.1-alpha.0 → 1.1.1-alpha.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/core.js +19 -9
- package/dist/core.mjs +19 -9
- package/dist/webpack.js +19 -9
- package/dist/webpack.mjs +19 -9
- package/package.json +1 -1
package/dist/core.js
CHANGED
@@ -37,18 +37,28 @@ module.exports = __toCommonJS(core_exports);
|
|
37
37
|
var import_unplugin = require("unplugin");
|
38
38
|
|
39
39
|
// src/utils.ts
|
40
|
-
var
|
41
|
-
var
|
40
|
+
var import_node_path = __toESM(require("path"));
|
41
|
+
var import_node_fs = __toESM(require("fs"));
|
42
|
+
function getCallerDir() {
|
43
|
+
const _stack = new Error().stack;
|
44
|
+
if (!_stack) return process.cwd();
|
45
|
+
const stackLines = _stack.split("\n");
|
46
|
+
const callerLine = stackLines.find((l) => l.includes(".js") || l.includes(".ts")) || "";
|
47
|
+
const match = callerLine.match(/\((.*):\d+:\d+\)$/) || callerLine.match(/at (.*):\d+:\d+/);
|
48
|
+
if (match) return import_node_path.default.dirname(match[1]);
|
49
|
+
return process.cwd();
|
50
|
+
}
|
42
51
|
function getPackageVersion() {
|
43
52
|
try {
|
44
|
-
const
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
53
|
+
const baseDir = getCallerDir();
|
54
|
+
const pkgPath = import_node_path.default.resolve(baseDir, "package.json");
|
55
|
+
const content = import_node_fs.default.readFileSync(pkgPath, "utf-8");
|
56
|
+
const pkg = JSON.parse(content);
|
57
|
+
return pkg.version || "0.0.0";
|
58
|
+
} catch (e) {
|
59
|
+
console.warn("[VersionInjector] Failed to read package.json:", e);
|
60
|
+
return "0.0.0";
|
50
61
|
}
|
51
|
-
return "0.0.0";
|
52
62
|
}
|
53
63
|
function defaultFormatDate(date) {
|
54
64
|
return date.toISOString();
|
package/dist/core.mjs
CHANGED
@@ -9,18 +9,28 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
9
9
|
import { createUnplugin } from "unplugin";
|
10
10
|
|
11
11
|
// src/utils.ts
|
12
|
-
import
|
13
|
-
import
|
12
|
+
import path from "node:path";
|
13
|
+
import fs from "node:fs";
|
14
|
+
function getCallerDir() {
|
15
|
+
const _stack = new Error().stack;
|
16
|
+
if (!_stack) return process.cwd();
|
17
|
+
const stackLines = _stack.split("\n");
|
18
|
+
const callerLine = stackLines.find((l) => l.includes(".js") || l.includes(".ts")) || "";
|
19
|
+
const match = callerLine.match(/\((.*):\d+:\d+\)$/) || callerLine.match(/at (.*):\d+:\d+/);
|
20
|
+
if (match) return path.dirname(match[1]);
|
21
|
+
return process.cwd();
|
22
|
+
}
|
14
23
|
function getPackageVersion() {
|
15
24
|
try {
|
16
|
-
const
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
25
|
+
const baseDir = getCallerDir();
|
26
|
+
const pkgPath = path.resolve(baseDir, "package.json");
|
27
|
+
const content = fs.readFileSync(pkgPath, "utf-8");
|
28
|
+
const pkg = JSON.parse(content);
|
29
|
+
return pkg.version || "0.0.0";
|
30
|
+
} catch (e) {
|
31
|
+
console.warn("[VersionInjector] Failed to read package.json:", e);
|
32
|
+
return "0.0.0";
|
22
33
|
}
|
23
|
-
return "0.0.0";
|
24
34
|
}
|
25
35
|
function defaultFormatDate(date) {
|
26
36
|
return date.toISOString();
|
package/dist/webpack.js
CHANGED
@@ -38,18 +38,28 @@ module.exports = __toCommonJS(webpack_exports);
|
|
38
38
|
var import_unplugin = require("unplugin");
|
39
39
|
|
40
40
|
// src/utils.ts
|
41
|
-
var
|
42
|
-
var
|
41
|
+
var import_node_path = __toESM(require("path"));
|
42
|
+
var import_node_fs = __toESM(require("fs"));
|
43
|
+
function getCallerDir() {
|
44
|
+
const _stack = new Error().stack;
|
45
|
+
if (!_stack) return process.cwd();
|
46
|
+
const stackLines = _stack.split("\n");
|
47
|
+
const callerLine = stackLines.find((l) => l.includes(".js") || l.includes(".ts")) || "";
|
48
|
+
const match = callerLine.match(/\((.*):\d+:\d+\)$/) || callerLine.match(/at (.*):\d+:\d+/);
|
49
|
+
if (match) return import_node_path.default.dirname(match[1]);
|
50
|
+
return process.cwd();
|
51
|
+
}
|
43
52
|
function getPackageVersion() {
|
44
53
|
try {
|
45
|
-
const
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
54
|
+
const baseDir = getCallerDir();
|
55
|
+
const pkgPath = import_node_path.default.resolve(baseDir, "package.json");
|
56
|
+
const content = import_node_fs.default.readFileSync(pkgPath, "utf-8");
|
57
|
+
const pkg = JSON.parse(content);
|
58
|
+
return pkg.version || "0.0.0";
|
59
|
+
} catch (e) {
|
60
|
+
console.warn("[VersionInjector] Failed to read package.json:", e);
|
61
|
+
return "0.0.0";
|
51
62
|
}
|
52
|
-
return "0.0.0";
|
53
63
|
}
|
54
64
|
function defaultFormatDate(date) {
|
55
65
|
return date.toISOString();
|
package/dist/webpack.mjs
CHANGED
@@ -9,18 +9,28 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
9
9
|
import { createUnplugin } from "unplugin";
|
10
10
|
|
11
11
|
// src/utils.ts
|
12
|
-
import
|
13
|
-
import
|
12
|
+
import path from "node:path";
|
13
|
+
import fs from "node:fs";
|
14
|
+
function getCallerDir() {
|
15
|
+
const _stack = new Error().stack;
|
16
|
+
if (!_stack) return process.cwd();
|
17
|
+
const stackLines = _stack.split("\n");
|
18
|
+
const callerLine = stackLines.find((l) => l.includes(".js") || l.includes(".ts")) || "";
|
19
|
+
const match = callerLine.match(/\((.*):\d+:\d+\)$/) || callerLine.match(/at (.*):\d+:\d+/);
|
20
|
+
if (match) return path.dirname(match[1]);
|
21
|
+
return process.cwd();
|
22
|
+
}
|
14
23
|
function getPackageVersion() {
|
15
24
|
try {
|
16
|
-
const
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
25
|
+
const baseDir = getCallerDir();
|
26
|
+
const pkgPath = path.resolve(baseDir, "package.json");
|
27
|
+
const content = fs.readFileSync(pkgPath, "utf-8");
|
28
|
+
const pkg = JSON.parse(content);
|
29
|
+
return pkg.version || "0.0.0";
|
30
|
+
} catch (e) {
|
31
|
+
console.warn("[VersionInjector] Failed to read package.json:", e);
|
32
|
+
return "0.0.0";
|
22
33
|
}
|
23
|
-
return "0.0.0";
|
24
34
|
}
|
25
35
|
function defaultFormatDate(date) {
|
26
36
|
return date.toISOString();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "unplugin-version-injector",
|
3
|
-
"version": "1.1.1-alpha.
|
3
|
+
"version": "1.1.1-alpha.1",
|
4
4
|
"author": "Nian Yi <nianyi778@gmail.com>",
|
5
5
|
"license": "MIT",
|
6
6
|
"description": "A universal plugin to inject version and build time into HTML (supports Webpack, Vite, Rollup)",
|