unplugin-version-injector 1.1.1-alpha.0 → 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 +20 -8
- package/dist/core.mjs +20 -8
- package/dist/webpack.js +20 -8
- package/dist/webpack.mjs +20 -8
- package/package.json +1 -1
package/dist/core.js
CHANGED
@@ -37,18 +37,30 @@ 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_fs = __toESM(require("fs"));
|
41
|
+
var import_node_path = __toESM(require("path"));
|
42
|
+
var import_node_url = require("url");
|
43
|
+
var import_meta = {};
|
42
44
|
function getPackageVersion() {
|
43
45
|
try {
|
44
|
-
const
|
45
|
-
|
46
|
-
|
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);
|
47
57
|
}
|
48
|
-
|
49
|
-
|
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);
|
62
|
+
return "0.0.0";
|
50
63
|
}
|
51
|
-
return "0.0.0";
|
52
64
|
}
|
53
65
|
function defaultFormatDate(date) {
|
54
66
|
return date.toISOString();
|
package/dist/core.mjs
CHANGED
@@ -9,18 +9,30 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
9
9
|
import { createUnplugin } from "unplugin";
|
10
10
|
|
11
11
|
// src/utils.ts
|
12
|
-
import fs from "fs";
|
13
|
-
import path from "path";
|
12
|
+
import fs from "node:fs";
|
13
|
+
import path from "node:path";
|
14
|
+
import { fileURLToPath } from "node:url";
|
15
|
+
var import_meta = {};
|
14
16
|
function getPackageVersion() {
|
15
17
|
try {
|
16
|
-
const
|
17
|
-
|
18
|
-
|
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);
|
19
29
|
}
|
20
|
-
|
21
|
-
|
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);
|
34
|
+
return "0.0.0";
|
22
35
|
}
|
23
|
-
return "0.0.0";
|
24
36
|
}
|
25
37
|
function defaultFormatDate(date) {
|
26
38
|
return date.toISOString();
|
package/dist/webpack.js
CHANGED
@@ -38,18 +38,30 @@ 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_fs = __toESM(require("fs"));
|
42
|
+
var import_node_path = __toESM(require("path"));
|
43
|
+
var import_node_url = require("url");
|
44
|
+
var import_meta = {};
|
43
45
|
function getPackageVersion() {
|
44
46
|
try {
|
45
|
-
const
|
46
|
-
|
47
|
-
|
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);
|
48
58
|
}
|
49
|
-
|
50
|
-
|
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);
|
63
|
+
return "0.0.0";
|
51
64
|
}
|
52
|
-
return "0.0.0";
|
53
65
|
}
|
54
66
|
function defaultFormatDate(date) {
|
55
67
|
return date.toISOString();
|
package/dist/webpack.mjs
CHANGED
@@ -9,18 +9,30 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
9
9
|
import { createUnplugin } from "unplugin";
|
10
10
|
|
11
11
|
// src/utils.ts
|
12
|
-
import fs from "fs";
|
13
|
-
import path from "path";
|
12
|
+
import fs from "node:fs";
|
13
|
+
import path from "node:path";
|
14
|
+
import { fileURLToPath } from "node:url";
|
15
|
+
var import_meta = {};
|
14
16
|
function getPackageVersion() {
|
15
17
|
try {
|
16
|
-
const
|
17
|
-
|
18
|
-
|
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);
|
19
29
|
}
|
20
|
-
|
21
|
-
|
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);
|
34
|
+
return "0.0.0";
|
22
35
|
}
|
23
|
-
return "0.0.0";
|
24
36
|
}
|
25
37
|
function defaultFormatDate(date) {
|
26
38
|
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.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)",
|