unplugin-version-injector 1.1.1-alpha.1 → 1.1.1-alpha.2
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 -17
- package/dist/core.mjs +19 -17
- package/dist/webpack.js +19 -17
- package/dist/webpack.mjs +19 -17
- package/package.json +1 -1
package/dist/core.js
CHANGED
@@ -37,26 +37,28 @@ module.exports = __toCommonJS(core_exports);
|
|
37
37
|
var import_unplugin = require("unplugin");
|
38
38
|
|
39
39
|
// src/utils.ts
|
40
|
-
var import_node_path = __toESM(require("path"));
|
41
40
|
var import_node_fs = __toESM(require("fs"));
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
}
|
41
|
+
var import_node_path = __toESM(require("path"));
|
42
|
+
var import_node_url = require("url");
|
43
|
+
var import_meta = {};
|
51
44
|
function getPackageVersion() {
|
52
45
|
try {
|
53
|
-
const
|
54
|
-
const
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
46
|
+
const __filename = (0, import_node_url.fileURLToPath)(import_meta.url);
|
47
|
+
const __dirname = import_node_path.default.dirname(__filename);
|
48
|
+
let dir = __dirname;
|
49
|
+
while (dir !== import_node_path.default.parse(dir).root) {
|
50
|
+
const pkgPath = import_node_path.default.join(dir, "package.json");
|
51
|
+
if (import_node_fs.default.existsSync(pkgPath)) {
|
52
|
+
const content = import_node_fs.default.readFileSync(pkgPath, "utf-8");
|
53
|
+
const pkg = JSON.parse(content);
|
54
|
+
return pkg.version || "0.0.0";
|
55
|
+
}
|
56
|
+
dir = import_node_path.default.dirname(dir);
|
57
|
+
}
|
58
|
+
console.warn("[VersionInjector] package.json not found");
|
59
|
+
return "0.0.0";
|
60
|
+
} catch (err) {
|
61
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
60
62
|
return "0.0.0";
|
61
63
|
}
|
62
64
|
}
|
package/dist/core.mjs
CHANGED
@@ -9,26 +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 path from "node:path";
|
13
12
|
import fs from "node:fs";
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
}
|
13
|
+
import path from "node:path";
|
14
|
+
import { fileURLToPath } from "node:url";
|
15
|
+
var import_meta = {};
|
23
16
|
function getPackageVersion() {
|
24
17
|
try {
|
25
|
-
const
|
26
|
-
const
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
18
|
+
const __filename = fileURLToPath(import_meta.url);
|
19
|
+
const __dirname = path.dirname(__filename);
|
20
|
+
let dir = __dirname;
|
21
|
+
while (dir !== path.parse(dir).root) {
|
22
|
+
const pkgPath = path.join(dir, "package.json");
|
23
|
+
if (fs.existsSync(pkgPath)) {
|
24
|
+
const content = fs.readFileSync(pkgPath, "utf-8");
|
25
|
+
const pkg = JSON.parse(content);
|
26
|
+
return pkg.version || "0.0.0";
|
27
|
+
}
|
28
|
+
dir = path.dirname(dir);
|
29
|
+
}
|
30
|
+
console.warn("[VersionInjector] package.json not found");
|
31
|
+
return "0.0.0";
|
32
|
+
} catch (err) {
|
33
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
32
34
|
return "0.0.0";
|
33
35
|
}
|
34
36
|
}
|
package/dist/webpack.js
CHANGED
@@ -38,26 +38,28 @@ module.exports = __toCommonJS(webpack_exports);
|
|
38
38
|
var import_unplugin = require("unplugin");
|
39
39
|
|
40
40
|
// src/utils.ts
|
41
|
-
var import_node_path = __toESM(require("path"));
|
42
41
|
var import_node_fs = __toESM(require("fs"));
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
}
|
42
|
+
var import_node_path = __toESM(require("path"));
|
43
|
+
var import_node_url = require("url");
|
44
|
+
var import_meta = {};
|
52
45
|
function getPackageVersion() {
|
53
46
|
try {
|
54
|
-
const
|
55
|
-
const
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
47
|
+
const __filename = (0, import_node_url.fileURLToPath)(import_meta.url);
|
48
|
+
const __dirname = import_node_path.default.dirname(__filename);
|
49
|
+
let dir = __dirname;
|
50
|
+
while (dir !== import_node_path.default.parse(dir).root) {
|
51
|
+
const pkgPath = import_node_path.default.join(dir, "package.json");
|
52
|
+
if (import_node_fs.default.existsSync(pkgPath)) {
|
53
|
+
const content = import_node_fs.default.readFileSync(pkgPath, "utf-8");
|
54
|
+
const pkg = JSON.parse(content);
|
55
|
+
return pkg.version || "0.0.0";
|
56
|
+
}
|
57
|
+
dir = import_node_path.default.dirname(dir);
|
58
|
+
}
|
59
|
+
console.warn("[VersionInjector] package.json not found");
|
60
|
+
return "0.0.0";
|
61
|
+
} catch (err) {
|
62
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
61
63
|
return "0.0.0";
|
62
64
|
}
|
63
65
|
}
|
package/dist/webpack.mjs
CHANGED
@@ -9,26 +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 path from "node:path";
|
13
12
|
import fs from "node:fs";
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
}
|
13
|
+
import path from "node:path";
|
14
|
+
import { fileURLToPath } from "node:url";
|
15
|
+
var import_meta = {};
|
23
16
|
function getPackageVersion() {
|
24
17
|
try {
|
25
|
-
const
|
26
|
-
const
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
18
|
+
const __filename = fileURLToPath(import_meta.url);
|
19
|
+
const __dirname = path.dirname(__filename);
|
20
|
+
let dir = __dirname;
|
21
|
+
while (dir !== path.parse(dir).root) {
|
22
|
+
const pkgPath = path.join(dir, "package.json");
|
23
|
+
if (fs.existsSync(pkgPath)) {
|
24
|
+
const content = fs.readFileSync(pkgPath, "utf-8");
|
25
|
+
const pkg = JSON.parse(content);
|
26
|
+
return pkg.version || "0.0.0";
|
27
|
+
}
|
28
|
+
dir = path.dirname(dir);
|
29
|
+
}
|
30
|
+
console.warn("[VersionInjector] package.json not found");
|
31
|
+
return "0.0.0";
|
32
|
+
} catch (err) {
|
33
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
32
34
|
return "0.0.0";
|
33
35
|
}
|
34
36
|
}
|
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.2",
|
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)",
|