unplugin-version-injector 1.1.2-beta.1 → 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 CHANGED
@@ -13,20 +13,12 @@ var path__default = /*#__PURE__*/_interopDefault(path);
13
13
  var import_meta = {};
14
14
  function getPackageVersion() {
15
15
  try {
16
- let currentDir;
17
- const isESM = typeof __dirname === "undefined";
18
- if (isESM) {
19
- const metaUrl = import_meta.url || "";
20
- currentDir = path__default.default.dirname(url.fileURLToPath(metaUrl));
21
- } else {
22
- currentDir = __dirname;
23
- }
16
+ const currentDir = getCurrentDir();
24
17
  let dir = currentDir;
25
18
  while (dir !== path__default.default.parse(dir).root) {
26
19
  const pkgPath = path__default.default.join(dir, "package.json");
27
20
  if (fs__default.default.existsSync(pkgPath)) {
28
- const content = fs__default.default.readFileSync(pkgPath, "utf-8");
29
- const pkg = JSON.parse(content);
21
+ const pkg = JSON.parse(fs__default.default.readFileSync(pkgPath, "utf8"));
30
22
  return pkg.version || "0.0.0";
31
23
  }
32
24
  dir = path__default.default.dirname(dir);
@@ -38,6 +30,19 @@ function getPackageVersion() {
38
30
  return "0.0.0";
39
31
  }
40
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");
45
+ }
41
46
  function defaultFormatDate(date) {
42
47
  return date.toISOString();
43
48
  }
package/dist/rollup.mjs CHANGED
@@ -6,20 +6,12 @@ import { fileURLToPath } from 'node:url';
6
6
  var import_meta = {};
7
7
  function getPackageVersion() {
8
8
  try {
9
- let currentDir;
10
- const isESM = typeof __dirname === "undefined";
11
- if (isESM) {
12
- const metaUrl = import_meta.url || "";
13
- currentDir = path.dirname(fileURLToPath(metaUrl));
14
- } else {
15
- currentDir = __dirname;
16
- }
9
+ const currentDir = getCurrentDir();
17
10
  let dir = currentDir;
18
11
  while (dir !== path.parse(dir).root) {
19
12
  const pkgPath = path.join(dir, "package.json");
20
13
  if (fs.existsSync(pkgPath)) {
21
- const content = fs.readFileSync(pkgPath, "utf-8");
22
- const pkg = JSON.parse(content);
14
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
23
15
  return pkg.version || "0.0.0";
24
16
  }
25
17
  dir = path.dirname(dir);
@@ -31,6 +23,19 @@ function getPackageVersion() {
31
23
  return "0.0.0";
32
24
  }
33
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");
38
+ }
34
39
  function defaultFormatDate(date) {
35
40
  return date.toISOString();
36
41
  }
package/dist/vite.js CHANGED
@@ -13,20 +13,12 @@ var path__default = /*#__PURE__*/_interopDefault(path);
13
13
  var import_meta = {};
14
14
  function getPackageVersion() {
15
15
  try {
16
- let currentDir;
17
- const isESM = typeof __dirname === "undefined";
18
- if (isESM) {
19
- const metaUrl = import_meta.url || "";
20
- currentDir = path__default.default.dirname(url.fileURLToPath(metaUrl));
21
- } else {
22
- currentDir = __dirname;
23
- }
16
+ const currentDir = getCurrentDir();
24
17
  let dir = currentDir;
25
18
  while (dir !== path__default.default.parse(dir).root) {
26
19
  const pkgPath = path__default.default.join(dir, "package.json");
27
20
  if (fs__default.default.existsSync(pkgPath)) {
28
- const content = fs__default.default.readFileSync(pkgPath, "utf-8");
29
- const pkg = JSON.parse(content);
21
+ const pkg = JSON.parse(fs__default.default.readFileSync(pkgPath, "utf8"));
30
22
  return pkg.version || "0.0.0";
31
23
  }
32
24
  dir = path__default.default.dirname(dir);
@@ -38,6 +30,19 @@ function getPackageVersion() {
38
30
  return "0.0.0";
39
31
  }
40
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");
45
+ }
41
46
  function defaultFormatDate(date) {
42
47
  return date.toISOString();
43
48
  }
package/dist/vite.mjs CHANGED
@@ -6,20 +6,12 @@ import { fileURLToPath } from 'node:url';
6
6
  var import_meta = {};
7
7
  function getPackageVersion() {
8
8
  try {
9
- let currentDir;
10
- const isESM = typeof __dirname === "undefined";
11
- if (isESM) {
12
- const metaUrl = import_meta.url || "";
13
- currentDir = path.dirname(fileURLToPath(metaUrl));
14
- } else {
15
- currentDir = __dirname;
16
- }
9
+ const currentDir = getCurrentDir();
17
10
  let dir = currentDir;
18
11
  while (dir !== path.parse(dir).root) {
19
12
  const pkgPath = path.join(dir, "package.json");
20
13
  if (fs.existsSync(pkgPath)) {
21
- const content = fs.readFileSync(pkgPath, "utf-8");
22
- const pkg = JSON.parse(content);
14
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
23
15
  return pkg.version || "0.0.0";
24
16
  }
25
17
  dir = path.dirname(dir);
@@ -31,6 +23,19 @@ function getPackageVersion() {
31
23
  return "0.0.0";
32
24
  }
33
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");
38
+ }
34
39
  function defaultFormatDate(date) {
35
40
  return date.toISOString();
36
41
  }
package/dist/webpack.js CHANGED
@@ -13,20 +13,12 @@ var path__default = /*#__PURE__*/_interopDefault(path);
13
13
  var import_meta = {};
14
14
  function getPackageVersion() {
15
15
  try {
16
- let currentDir;
17
- const isESM = typeof __dirname === "undefined";
18
- if (isESM) {
19
- const metaUrl = import_meta.url || "";
20
- currentDir = path__default.default.dirname(url.fileURLToPath(metaUrl));
21
- } else {
22
- currentDir = __dirname;
23
- }
16
+ const currentDir = getCurrentDir();
24
17
  let dir = currentDir;
25
18
  while (dir !== path__default.default.parse(dir).root) {
26
19
  const pkgPath = path__default.default.join(dir, "package.json");
27
20
  if (fs__default.default.existsSync(pkgPath)) {
28
- const content = fs__default.default.readFileSync(pkgPath, "utf-8");
29
- const pkg = JSON.parse(content);
21
+ const pkg = JSON.parse(fs__default.default.readFileSync(pkgPath, "utf8"));
30
22
  return pkg.version || "0.0.0";
31
23
  }
32
24
  dir = path__default.default.dirname(dir);
@@ -38,6 +30,19 @@ function getPackageVersion() {
38
30
  return "0.0.0";
39
31
  }
40
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");
45
+ }
41
46
  function defaultFormatDate(date) {
42
47
  return date.toISOString();
43
48
  }
package/dist/webpack.mjs CHANGED
@@ -6,20 +6,12 @@ import { fileURLToPath } from 'node:url';
6
6
  var import_meta = {};
7
7
  function getPackageVersion() {
8
8
  try {
9
- let currentDir;
10
- const isESM = typeof __dirname === "undefined";
11
- if (isESM) {
12
- const metaUrl = import_meta.url || "";
13
- currentDir = path.dirname(fileURLToPath(metaUrl));
14
- } else {
15
- currentDir = __dirname;
16
- }
9
+ const currentDir = getCurrentDir();
17
10
  let dir = currentDir;
18
11
  while (dir !== path.parse(dir).root) {
19
12
  const pkgPath = path.join(dir, "package.json");
20
13
  if (fs.existsSync(pkgPath)) {
21
- const content = fs.readFileSync(pkgPath, "utf-8");
22
- const pkg = JSON.parse(content);
14
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
23
15
  return pkg.version || "0.0.0";
24
16
  }
25
17
  dir = path.dirname(dir);
@@ -31,6 +23,19 @@ function getPackageVersion() {
31
23
  return "0.0.0";
32
24
  }
33
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");
38
+ }
34
39
  function defaultFormatDate(date) {
35
40
  return date.toISOString();
36
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-version-injector",
3
- "version": "1.1.2-beta.1",
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 };