@lntvow/vite-plugin 1.1.14 → 1.2.0
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 +10 -10
- package/dist/index.d.ts +9 -10
- package/dist/index.mjs +15 -15
- package/package.json +3 -4
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
${
|
|
1
|
+
"use strict";var M=Object.create;var f=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var k=(t,n)=>{for(var o in n)f(t,o,{get:n[o],enumerable:!0})},v=(t,n,o,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of S(n))!E.call(t,r)&&r!==o&&f(t,r,{get:()=>n[r],enumerable:!(s=z(n,r))||s.enumerable});return t};var u=(t,n,o)=>(o=t!=null?M(w(t)):{},v(n||!t||!t.__esModule?f(o,"default",{value:t,enumerable:!0}):o,t)),q=t=>v(f({},"__esModule",{value:!0}),t);var R={};k(R,{vitePluginEnvRibbon:()=>P,vitePluginVersionLog:()=>L});module.exports=q(R);var a=require("path"),m=require("fs"),d=u(require("dayjs"),1),$=u(require("dayjs/plugin/timezone.js"),1),b=u(require("dayjs/plugin/utc.js"),1);d.default.extend(b.default);d.default.extend($.default);function L(t={}){let{name:n="LNTVOW_VERSION",timezone:o="Asia/Shanghai",entry:s}=t,{version:r}=t,g=["src/main.ts","src/main.js"].map(e=>(0,a.resolve)(process.cwd(),e)),p;s?p=(0,a.resolve)(process.cwd(),s):p=g.find(i=>(0,m.existsSync)(i))??g[0];let c=(0,d.default)().tz(o).format("YYYY-MM-DD HH:mm:ss");if(!r)try{let e=(0,m.readFileSync)((0,a.resolve)(process.cwd(),"package.json"),"utf8");r=JSON.parse(e).version}catch(e){r="unknown",console.log("error: ",e)}return{name:"vite-plugin-version-log",transform(e,i){if((0,a.normalize)(i)===(0,a.normalize)(p))return{code:`
|
|
2
|
+
${e}
|
|
3
3
|
|
|
4
|
-
localStorage.setItem('${
|
|
5
|
-
console.log('[Log] version:', ['${
|
|
6
|
-
`}}}}function
|
|
4
|
+
localStorage.setItem('${n}', JSON.stringify(['${c}', '${r}']))
|
|
5
|
+
console.log('[Log] version:', ['${c}', '${r}']);
|
|
6
|
+
`}}}}function P(t={}){let{width:n=150,height:o=20,fontSize:s=12,backgroundColor:r="hsla(0, 100%, 33%, 0.733)",color:g="#fff",position:p="top-right",envMap:c={}}=t,e;return{name:"vite-plugin-env-ribbon",transformIndexHtml(i){if(e==="production")return i;let x=c[e]||e;if(!x)return i;let l=p==="top-left",y=l?`translate(-${o/Math.sqrt(2)}px, -${o/Math.sqrt(2)}px) translate(0, ${n/Math.sqrt(2)}px) rotate(-45deg)`:`translate(${o/Math.sqrt(2)}px, -${o/Math.sqrt(2)}px) translate(0, ${n/Math.sqrt(2)}px) rotate(45deg)`,O=`
|
|
7
7
|
position: fixed;
|
|
8
|
-
width: ${
|
|
8
|
+
width: ${n}px;
|
|
9
9
|
height: ${o}px;
|
|
10
|
-
background: ${
|
|
11
|
-
color: ${
|
|
12
|
-
font-size: ${
|
|
10
|
+
background: ${r};
|
|
11
|
+
color: ${g};
|
|
12
|
+
font-size: ${s}px;
|
|
13
13
|
line-height: ${o}px;
|
|
14
14
|
transform: ${y};
|
|
15
15
|
transform-origin: ${l?"left top":"right top"};
|
|
@@ -21,4 +21,4 @@
|
|
|
21
21
|
pointer-events: none;
|
|
22
22
|
user-select: none;
|
|
23
23
|
overflow: hidden;
|
|
24
|
-
`;return{html:
|
|
24
|
+
`;return{html:i,tags:[{tag:"div",attrs:{style:O.replace(/\s+/g," ").trim(),id:"vite-plugin-env-ribbon"},children:x,injectTo:"body"}]}},configResolved(i){e=i.mode}}}0&&(module.exports={vitePluginEnvRibbon,vitePluginVersionLog});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { PluginOption } from 'vite';
|
|
2
|
-
import { Arrayable } from '@lntvow/utils';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
* This Vite plugin injects version and build time information into specified entry
|
|
4
|
+
* This Vite plugin injects version and build time information into a specified entry file.
|
|
6
5
|
* It automatically writes the current build time and project version (read from package.json by default)
|
|
7
6
|
* to localStorage and prints them to the console at runtime.
|
|
8
7
|
*
|
|
9
8
|
* This is useful for tracking deployment versions and build times in frontend projects,
|
|
10
9
|
* making it easier to identify which version is currently deployed and when it was built.
|
|
11
10
|
*
|
|
12
|
-
*
|
|
13
|
-
* You can customize the localStorage key, version, timezone, and the entry files to inject via plugin options.
|
|
11
|
+
* You can customize the localStorage key, version, timezone, and the entry file to inject via plugin options.
|
|
14
12
|
*
|
|
15
13
|
* @example
|
|
16
14
|
* import { vitePluginVersionLog } from '@lntvow/vite-plugin'
|
|
@@ -25,7 +23,7 @@ import { Arrayable } from '@lntvow/utils';
|
|
|
25
23
|
* - Automatically reads version from package.json if not provided
|
|
26
24
|
* - Supports custom timezone for build time formatting
|
|
27
25
|
* - Configurable localStorage key name
|
|
28
|
-
* -
|
|
26
|
+
* - Auto-detects entry file from 'src/main.ts' or 'src/main.js' if not specified
|
|
29
27
|
*/
|
|
30
28
|
declare function vitePluginVersionLog(options?: VersionLogOptions): PluginOption;
|
|
31
29
|
interface VersionLogOptions {
|
|
@@ -49,12 +47,13 @@ interface VersionLogOptions {
|
|
|
49
47
|
*/
|
|
50
48
|
timezone?: string;
|
|
51
49
|
/**
|
|
52
|
-
* The entry
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
50
|
+
* The entry file where version information will be injected.
|
|
51
|
+
* If not provided, the plugin will automatically find the main entry file
|
|
52
|
+
* by checking for the existence of 'src/main.ts' or 'src/main.js' in that order.
|
|
53
|
+
* Path is resolved from the command line working directory (process.cwd()).
|
|
54
|
+
* @default Auto-detected from ['src/main.ts', 'src/main.js']
|
|
56
55
|
*/
|
|
57
|
-
|
|
56
|
+
entry?: string;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import{normalize as
|
|
1
|
+
import{normalize as h,resolve as l}from"path";import{readFileSync as $,existsSync as b}from"fs";import d from"dayjs";import y from"dayjs/plugin/timezone.js";import O from"dayjs/plugin/utc.js";d.extend(O);d.extend(y);function P(s={}){let{name:e="LNTVOW_VERSION",timezone:o="Asia/Shanghai",entry:a}=s,{version:r}=s,p=["src/main.ts","src/main.js"].map(t=>l(process.cwd(),t)),i;a?i=l(process.cwd(),a):i=p.find(n=>b(n))??p[0];let g=d().tz(o).format("YYYY-MM-DD HH:mm:ss");if(!r)try{let t=$(l(process.cwd(),"package.json"),"utf8");r=JSON.parse(t).version}catch(t){r="unknown",console.log("error: ",t)}return{name:"vite-plugin-version-log",transform(t,n){if(h(n)===h(i))return{code:`
|
|
2
2
|
${t}
|
|
3
3
|
|
|
4
|
-
localStorage.setItem('${
|
|
5
|
-
console.log('[Log] version:', ['${
|
|
6
|
-
`}}}}function N(
|
|
4
|
+
localStorage.setItem('${e}', JSON.stringify(['${g}', '${r}']))
|
|
5
|
+
console.log('[Log] version:', ['${g}', '${r}']);
|
|
6
|
+
`}}}}function N(s={}){let{width:e=150,height:o=20,fontSize:a=12,backgroundColor:r="hsla(0, 100%, 33%, 0.733)",color:p="#fff",position:i="top-right",envMap:g={}}=s,t;return{name:"vite-plugin-env-ribbon",transformIndexHtml(n){if(t==="production")return n;let u=g[t]||t;if(!u)return n;let c=i==="top-left",x=c?`translate(-${o/Math.sqrt(2)}px, -${o/Math.sqrt(2)}px) translate(0, ${e/Math.sqrt(2)}px) rotate(-45deg)`:`translate(${o/Math.sqrt(2)}px, -${o/Math.sqrt(2)}px) translate(0, ${e/Math.sqrt(2)}px) rotate(45deg)`,v=`
|
|
7
7
|
position: fixed;
|
|
8
|
-
width: ${
|
|
9
|
-
height: ${
|
|
10
|
-
background: ${
|
|
11
|
-
color: ${
|
|
12
|
-
font-size: ${
|
|
13
|
-
line-height: ${
|
|
14
|
-
transform: ${
|
|
15
|
-
transform-origin: ${
|
|
8
|
+
width: ${e}px;
|
|
9
|
+
height: ${o}px;
|
|
10
|
+
background: ${r};
|
|
11
|
+
color: ${p};
|
|
12
|
+
font-size: ${a}px;
|
|
13
|
+
line-height: ${o}px;
|
|
14
|
+
transform: ${x};
|
|
15
|
+
transform-origin: ${c?"left top":"right top"};
|
|
16
16
|
top: 0;
|
|
17
|
-
right: ${
|
|
18
|
-
left: ${
|
|
17
|
+
right: ${c?"auto":"0"};
|
|
18
|
+
left: ${c?"0":"auto"};
|
|
19
19
|
z-index: 9999;
|
|
20
20
|
text-align: center;
|
|
21
21
|
pointer-events: none;
|
|
22
22
|
user-select: none;
|
|
23
23
|
overflow: hidden;
|
|
24
|
-
`;return{html:
|
|
24
|
+
`;return{html:n,tags:[{tag:"div",attrs:{style:v.replace(/\s+/g," ").trim(),id:"vite-plugin-env-ribbon"},children:u,injectTo:"body"}]}},configResolved(n){t=n.mode}}}export{N as vitePluginEnvRibbon,P as vitePluginVersionLog};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lntvow/vite-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Collection of custom vite plugins",
|
|
6
6
|
"keywords": [
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"import": "./dist/index.mjs"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lntvow/utils": "^4.4.8",
|
|
27
26
|
"dayjs": "^1.11.13"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
@@ -33,8 +32,8 @@
|
|
|
33
32
|
"bumpp": "^10.2.2",
|
|
34
33
|
"commitizen": "^4.3.1",
|
|
35
34
|
"cz-conventional-changelog": "^3.3.0",
|
|
36
|
-
"eslint": "^9.
|
|
37
|
-
"lint-staged": "^16.1.
|
|
35
|
+
"eslint": "^9.33.0",
|
|
36
|
+
"lint-staged": "^16.1.5",
|
|
38
37
|
"npm-run-all": "^4.1.5",
|
|
39
38
|
"prettier": "^3.6.2",
|
|
40
39
|
"simple-git-hooks": "^2.13.1",
|