vite-plugin-version-info 1.1.0 → 1.1.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/index.cjs +12 -14
- package/dist/index.d.ts +9 -9
- package/dist/index.mjs +12 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -89,27 +89,25 @@ function sliceCommitHash(hash, length) {
|
|
|
89
89
|
return hash.slice(0, length);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function plugin({
|
|
93
|
-
locale,
|
|
94
|
-
commitHashLength,
|
|
95
|
-
intlOptions,
|
|
96
|
-
noLicenseSuffix,
|
|
97
|
-
pattern
|
|
98
|
-
} = {}) {
|
|
92
|
+
function plugin(versionInfo = {}) {
|
|
93
|
+
const { locale, commitHashLength, intlOptions, noLicenseSuffix, pattern } = versionInfo;
|
|
99
94
|
return {
|
|
100
95
|
name: "vite-plugin-version-info",
|
|
101
|
-
config(
|
|
96
|
+
config() {
|
|
102
97
|
return {
|
|
103
98
|
define: {
|
|
104
99
|
__APP_VERSION__: JSON.stringify(
|
|
105
|
-
getVersionString(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
getVersionString(
|
|
101
|
+
{
|
|
102
|
+
commitHashLength: commitHashLength ?? 8,
|
|
103
|
+
noLicenseSuffix: noLicenseSuffix ?? "-nonfree",
|
|
104
|
+
pattern: pattern ?? "{version}{noLicenseSuffix} {currentBranch}-{commitHash}{branchSuffix}"
|
|
105
|
+
},
|
|
106
|
+
versionInfo
|
|
107
|
+
)
|
|
110
108
|
),
|
|
111
109
|
__COMMIT_DATE__: JSON.stringify(
|
|
112
|
-
|
|
110
|
+
versionInfo.commitDate ?? getCommitDate({
|
|
113
111
|
locale: locale ?? "en-US",
|
|
114
112
|
intlOptions: intlOptions ?? {
|
|
115
113
|
dateStyle: "long"
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
type PrecomputedVersionInfo = {
|
|
2
|
+
commitHash?: string;
|
|
3
|
+
gitBranch?: string;
|
|
4
|
+
commitDate?: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* Options for formatting the Git commit date.
|
|
3
9
|
*/
|
|
@@ -31,13 +37,7 @@ type VersionStringOptions = {
|
|
|
31
37
|
/**
|
|
32
38
|
* Combined plugin options for version and commit date customization.
|
|
33
39
|
*/
|
|
34
|
-
type VersionInfoPluginOptions = CommitDateOptions & VersionStringOptions;
|
|
35
|
-
|
|
36
|
-
type VersionInfoParameters = {
|
|
37
|
-
commitHash?: string;
|
|
38
|
-
gitBranch?: string;
|
|
39
|
-
commitDate?: string;
|
|
40
|
-
};
|
|
40
|
+
type VersionInfoPluginOptions = CommitDateOptions & VersionStringOptions & PrecomputedVersionInfo;
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Vite plugin that injects Git version info and commit metadata into your frontend app.
|
|
@@ -53,9 +53,9 @@ type VersionInfoParameters = {
|
|
|
53
53
|
* @param options - Plugin options to customize formatting and metadata injection
|
|
54
54
|
* @returns A Vite-compatible plugin object
|
|
55
55
|
*/
|
|
56
|
-
declare function plugin(
|
|
56
|
+
declare function plugin(versionInfo?: VersionInfoPluginOptions): {
|
|
57
57
|
name: string;
|
|
58
|
-
config(
|
|
58
|
+
config(): {
|
|
59
59
|
define: {
|
|
60
60
|
__APP_VERSION__: string;
|
|
61
61
|
__COMMIT_DATE__: string;
|
package/dist/index.mjs
CHANGED
|
@@ -65,27 +65,25 @@ function sliceCommitHash(hash, length) {
|
|
|
65
65
|
return hash.slice(0, length);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function plugin({
|
|
69
|
-
locale,
|
|
70
|
-
commitHashLength,
|
|
71
|
-
intlOptions,
|
|
72
|
-
noLicenseSuffix,
|
|
73
|
-
pattern
|
|
74
|
-
} = {}) {
|
|
68
|
+
function plugin(versionInfo = {}) {
|
|
69
|
+
const { locale, commitHashLength, intlOptions, noLicenseSuffix, pattern } = versionInfo;
|
|
75
70
|
return {
|
|
76
71
|
name: "vite-plugin-version-info",
|
|
77
|
-
config(
|
|
72
|
+
config() {
|
|
78
73
|
return {
|
|
79
74
|
define: {
|
|
80
75
|
__APP_VERSION__: JSON.stringify(
|
|
81
|
-
getVersionString(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
getVersionString(
|
|
77
|
+
{
|
|
78
|
+
commitHashLength: commitHashLength ?? 8,
|
|
79
|
+
noLicenseSuffix: noLicenseSuffix ?? "-nonfree",
|
|
80
|
+
pattern: pattern ?? "{version}{noLicenseSuffix} {currentBranch}-{commitHash}{branchSuffix}"
|
|
81
|
+
},
|
|
82
|
+
versionInfo
|
|
83
|
+
)
|
|
86
84
|
),
|
|
87
85
|
__COMMIT_DATE__: JSON.stringify(
|
|
88
|
-
|
|
86
|
+
versionInfo.commitDate ?? getCommitDate({
|
|
89
87
|
locale: locale ?? "en-US",
|
|
90
88
|
intlOptions: intlOptions ?? {
|
|
91
89
|
dateStyle: "long"
|
package/package.json
CHANGED