unplugin-version-injector 1.1.2-beta.0 → 1.1.2-beta.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/rollup.js +30 -12
- package/dist/rollup.mjs +30 -12
- package/dist/vite.js +30 -12
- package/dist/vite.mjs +30 -12
- package/dist/webpack.js +30 -12
- package/dist/webpack.mjs +30 -12
- package/package.json +1 -1
- package/dist/rollup.d.mts +0 -11
- package/dist/rollup.d.ts +0 -11
package/dist/rollup.js
CHANGED
@@ -2,28 +2,46 @@
|
|
2
2
|
|
3
3
|
var fs = require('fs');
|
4
4
|
var path = require('path');
|
5
|
+
var url = require('url');
|
5
6
|
|
6
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
7
8
|
|
8
9
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
9
10
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
}) : x)(function(x) {
|
14
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
15
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
16
|
-
});
|
12
|
+
// src/shared/utils.ts
|
13
|
+
var import_meta = {};
|
17
14
|
function getPackageVersion() {
|
18
15
|
try {
|
19
|
-
const
|
20
|
-
|
21
|
-
|
16
|
+
const currentDir = getCurrentDir();
|
17
|
+
let dir = currentDir;
|
18
|
+
while (dir !== path__default.default.parse(dir).root) {
|
19
|
+
const pkgPath = path__default.default.join(dir, "package.json");
|
20
|
+
if (fs__default.default.existsSync(pkgPath)) {
|
21
|
+
const pkg = JSON.parse(fs__default.default.readFileSync(pkgPath, "utf8"));
|
22
|
+
return pkg.version || "0.0.0";
|
23
|
+
}
|
24
|
+
dir = path__default.default.dirname(dir);
|
22
25
|
}
|
23
|
-
|
24
|
-
|
26
|
+
console.warn("[VersionInjector] package.json not found");
|
27
|
+
return "0.0.0";
|
28
|
+
} catch (err) {
|
29
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
30
|
+
return "0.0.0";
|
31
|
+
}
|
32
|
+
}
|
33
|
+
function getCurrentDir() {
|
34
|
+
try {
|
35
|
+
return path__default.default.dirname(url.fileURLToPath(getCallerImportMetaUrl()));
|
36
|
+
} catch (err) {
|
37
|
+
return process.cwd();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
function getCallerImportMetaUrl() {
|
41
|
+
if (typeof import_meta !== "undefined" && import_meta.url) {
|
42
|
+
return import_meta.url;
|
25
43
|
}
|
26
|
-
|
44
|
+
throw new Error("[VersionInjector] import.meta.url not available");
|
27
45
|
}
|
28
46
|
function defaultFormatDate(date) {
|
29
47
|
return date.toISOString();
|
package/dist/rollup.mjs
CHANGED
@@ -1,22 +1,40 @@
|
|
1
1
|
import fs from 'fs';
|
2
2
|
import path from 'path';
|
3
|
+
import { fileURLToPath } from 'node:url';
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
}) : x)(function(x) {
|
7
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
8
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
9
|
-
});
|
5
|
+
// src/shared/utils.ts
|
6
|
+
var import_meta = {};
|
10
7
|
function getPackageVersion() {
|
11
8
|
try {
|
12
|
-
const
|
13
|
-
|
14
|
-
|
9
|
+
const currentDir = getCurrentDir();
|
10
|
+
let dir = currentDir;
|
11
|
+
while (dir !== path.parse(dir).root) {
|
12
|
+
const pkgPath = path.join(dir, "package.json");
|
13
|
+
if (fs.existsSync(pkgPath)) {
|
14
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
15
|
+
return pkg.version || "0.0.0";
|
16
|
+
}
|
17
|
+
dir = path.dirname(dir);
|
15
18
|
}
|
16
|
-
|
17
|
-
|
19
|
+
console.warn("[VersionInjector] package.json not found");
|
20
|
+
return "0.0.0";
|
21
|
+
} catch (err) {
|
22
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
23
|
+
return "0.0.0";
|
24
|
+
}
|
25
|
+
}
|
26
|
+
function getCurrentDir() {
|
27
|
+
try {
|
28
|
+
return path.dirname(fileURLToPath(getCallerImportMetaUrl()));
|
29
|
+
} catch (err) {
|
30
|
+
return process.cwd();
|
31
|
+
}
|
32
|
+
}
|
33
|
+
function getCallerImportMetaUrl() {
|
34
|
+
if (typeof import_meta !== "undefined" && import_meta.url) {
|
35
|
+
return import_meta.url;
|
18
36
|
}
|
19
|
-
|
37
|
+
throw new Error("[VersionInjector] import.meta.url not available");
|
20
38
|
}
|
21
39
|
function defaultFormatDate(date) {
|
22
40
|
return date.toISOString();
|
package/dist/vite.js
CHANGED
@@ -2,28 +2,46 @@
|
|
2
2
|
|
3
3
|
var fs = require('fs');
|
4
4
|
var path = require('path');
|
5
|
+
var url = require('url');
|
5
6
|
|
6
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
7
8
|
|
8
9
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
9
10
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
}) : x)(function(x) {
|
14
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
15
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
16
|
-
});
|
12
|
+
// src/shared/utils.ts
|
13
|
+
var import_meta = {};
|
17
14
|
function getPackageVersion() {
|
18
15
|
try {
|
19
|
-
const
|
20
|
-
|
21
|
-
|
16
|
+
const currentDir = getCurrentDir();
|
17
|
+
let dir = currentDir;
|
18
|
+
while (dir !== path__default.default.parse(dir).root) {
|
19
|
+
const pkgPath = path__default.default.join(dir, "package.json");
|
20
|
+
if (fs__default.default.existsSync(pkgPath)) {
|
21
|
+
const pkg = JSON.parse(fs__default.default.readFileSync(pkgPath, "utf8"));
|
22
|
+
return pkg.version || "0.0.0";
|
23
|
+
}
|
24
|
+
dir = path__default.default.dirname(dir);
|
22
25
|
}
|
23
|
-
|
24
|
-
|
26
|
+
console.warn("[VersionInjector] package.json not found");
|
27
|
+
return "0.0.0";
|
28
|
+
} catch (err) {
|
29
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
30
|
+
return "0.0.0";
|
25
31
|
}
|
26
|
-
|
32
|
+
}
|
33
|
+
function getCurrentDir() {
|
34
|
+
try {
|
35
|
+
return path__default.default.dirname(url.fileURLToPath(getCallerImportMetaUrl()));
|
36
|
+
} catch (err) {
|
37
|
+
return process.cwd();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
function getCallerImportMetaUrl() {
|
41
|
+
if (typeof import_meta !== "undefined" && import_meta.url) {
|
42
|
+
return import_meta.url;
|
43
|
+
}
|
44
|
+
throw new Error("[VersionInjector] import.meta.url not available");
|
27
45
|
}
|
28
46
|
function defaultFormatDate(date) {
|
29
47
|
return date.toISOString();
|
package/dist/vite.mjs
CHANGED
@@ -1,22 +1,40 @@
|
|
1
1
|
import fs from 'fs';
|
2
2
|
import path from 'path';
|
3
|
+
import { fileURLToPath } from 'node:url';
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
}) : x)(function(x) {
|
7
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
8
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
9
|
-
});
|
5
|
+
// src/shared/utils.ts
|
6
|
+
var import_meta = {};
|
10
7
|
function getPackageVersion() {
|
11
8
|
try {
|
12
|
-
const
|
13
|
-
|
14
|
-
|
9
|
+
const currentDir = getCurrentDir();
|
10
|
+
let dir = currentDir;
|
11
|
+
while (dir !== path.parse(dir).root) {
|
12
|
+
const pkgPath = path.join(dir, "package.json");
|
13
|
+
if (fs.existsSync(pkgPath)) {
|
14
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
15
|
+
return pkg.version || "0.0.0";
|
16
|
+
}
|
17
|
+
dir = path.dirname(dir);
|
15
18
|
}
|
16
|
-
|
17
|
-
|
19
|
+
console.warn("[VersionInjector] package.json not found");
|
20
|
+
return "0.0.0";
|
21
|
+
} catch (err) {
|
22
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
23
|
+
return "0.0.0";
|
18
24
|
}
|
19
|
-
|
25
|
+
}
|
26
|
+
function getCurrentDir() {
|
27
|
+
try {
|
28
|
+
return path.dirname(fileURLToPath(getCallerImportMetaUrl()));
|
29
|
+
} catch (err) {
|
30
|
+
return process.cwd();
|
31
|
+
}
|
32
|
+
}
|
33
|
+
function getCallerImportMetaUrl() {
|
34
|
+
if (typeof import_meta !== "undefined" && import_meta.url) {
|
35
|
+
return import_meta.url;
|
36
|
+
}
|
37
|
+
throw new Error("[VersionInjector] import.meta.url not available");
|
20
38
|
}
|
21
39
|
function defaultFormatDate(date) {
|
22
40
|
return date.toISOString();
|
package/dist/webpack.js
CHANGED
@@ -2,28 +2,46 @@
|
|
2
2
|
|
3
3
|
var fs = require('fs');
|
4
4
|
var path = require('path');
|
5
|
+
var url = require('url');
|
5
6
|
|
6
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
7
8
|
|
8
9
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
9
10
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
}) : x)(function(x) {
|
14
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
15
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
16
|
-
});
|
12
|
+
// src/shared/utils.ts
|
13
|
+
var import_meta = {};
|
17
14
|
function getPackageVersion() {
|
18
15
|
try {
|
19
|
-
const
|
20
|
-
|
21
|
-
|
16
|
+
const currentDir = getCurrentDir();
|
17
|
+
let dir = currentDir;
|
18
|
+
while (dir !== path__default.default.parse(dir).root) {
|
19
|
+
const pkgPath = path__default.default.join(dir, "package.json");
|
20
|
+
if (fs__default.default.existsSync(pkgPath)) {
|
21
|
+
const pkg = JSON.parse(fs__default.default.readFileSync(pkgPath, "utf8"));
|
22
|
+
return pkg.version || "0.0.0";
|
23
|
+
}
|
24
|
+
dir = path__default.default.dirname(dir);
|
22
25
|
}
|
23
|
-
|
24
|
-
|
26
|
+
console.warn("[VersionInjector] package.json not found");
|
27
|
+
return "0.0.0";
|
28
|
+
} catch (err) {
|
29
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
30
|
+
return "0.0.0";
|
25
31
|
}
|
26
|
-
|
32
|
+
}
|
33
|
+
function getCurrentDir() {
|
34
|
+
try {
|
35
|
+
return path__default.default.dirname(url.fileURLToPath(getCallerImportMetaUrl()));
|
36
|
+
} catch (err) {
|
37
|
+
return process.cwd();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
function getCallerImportMetaUrl() {
|
41
|
+
if (typeof import_meta !== "undefined" && import_meta.url) {
|
42
|
+
return import_meta.url;
|
43
|
+
}
|
44
|
+
throw new Error("[VersionInjector] import.meta.url not available");
|
27
45
|
}
|
28
46
|
function defaultFormatDate(date) {
|
29
47
|
return date.toISOString();
|
package/dist/webpack.mjs
CHANGED
@@ -1,22 +1,40 @@
|
|
1
1
|
import fs from 'fs';
|
2
2
|
import path from 'path';
|
3
|
+
import { fileURLToPath } from 'node:url';
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
}) : x)(function(x) {
|
7
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
8
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
9
|
-
});
|
5
|
+
// src/shared/utils.ts
|
6
|
+
var import_meta = {};
|
10
7
|
function getPackageVersion() {
|
11
8
|
try {
|
12
|
-
const
|
13
|
-
|
14
|
-
|
9
|
+
const currentDir = getCurrentDir();
|
10
|
+
let dir = currentDir;
|
11
|
+
while (dir !== path.parse(dir).root) {
|
12
|
+
const pkgPath = path.join(dir, "package.json");
|
13
|
+
if (fs.existsSync(pkgPath)) {
|
14
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
15
|
+
return pkg.version || "0.0.0";
|
16
|
+
}
|
17
|
+
dir = path.dirname(dir);
|
15
18
|
}
|
16
|
-
|
17
|
-
|
19
|
+
console.warn("[VersionInjector] package.json not found");
|
20
|
+
return "0.0.0";
|
21
|
+
} catch (err) {
|
22
|
+
console.warn("[VersionInjector] Failed to read package.json:", err);
|
23
|
+
return "0.0.0";
|
18
24
|
}
|
19
|
-
|
25
|
+
}
|
26
|
+
function getCurrentDir() {
|
27
|
+
try {
|
28
|
+
return path.dirname(fileURLToPath(getCallerImportMetaUrl()));
|
29
|
+
} catch (err) {
|
30
|
+
return process.cwd();
|
31
|
+
}
|
32
|
+
}
|
33
|
+
function getCallerImportMetaUrl() {
|
34
|
+
if (typeof import_meta !== "undefined" && import_meta.url) {
|
35
|
+
return import_meta.url;
|
36
|
+
}
|
37
|
+
throw new Error("[VersionInjector] import.meta.url not available");
|
20
38
|
}
|
21
39
|
function defaultFormatDate(date) {
|
22
40
|
return date.toISOString();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "unplugin-version-injector",
|
3
|
-
"version": "1.1.2-beta.
|
3
|
+
"version": "1.1.2-beta.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)",
|
package/dist/rollup.d.mts
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import { Plugin } from 'rollup';
|
2
|
-
|
3
|
-
interface VersionInjectorOptions {
|
4
|
-
version?: string;
|
5
|
-
log?: boolean;
|
6
|
-
formatDate?: (date: Date) => string;
|
7
|
-
}
|
8
|
-
|
9
|
-
declare function versionInjector(options?: VersionInjectorOptions): Plugin;
|
10
|
-
|
11
|
-
export { versionInjector as default };
|
package/dist/rollup.d.ts
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import { Plugin } from 'rollup';
|
2
|
-
|
3
|
-
interface VersionInjectorOptions {
|
4
|
-
version?: string;
|
5
|
-
log?: boolean;
|
6
|
-
formatDate?: (date: Date) => string;
|
7
|
-
}
|
8
|
-
|
9
|
-
declare function versionInjector(options?: VersionInjectorOptions): Plugin;
|
10
|
-
|
11
|
-
export { versionInjector as default };
|