@lntvow/vite-plugin 0.0.7 → 0.0.8
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 +5 -45
- package/dist/index.mjs +5 -35
- package/package.json +11 -5
package/dist/index.cjs
CHANGED
|
@@ -1,50 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const path = require('node:path');
|
|
4
|
-
const fs = require('node:fs');
|
|
5
|
-
const dayjs = require('dayjs');
|
|
6
|
-
const utc = require('dayjs/plugin/utc.js');
|
|
7
|
-
const timezone = require('dayjs/plugin/timezone.js');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
10
|
-
|
|
11
|
-
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
12
|
-
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
13
|
-
const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
|
|
14
|
-
const utc__default = /*#__PURE__*/_interopDefaultCompat(utc);
|
|
15
|
-
const timezone__default = /*#__PURE__*/_interopDefaultCompat(timezone);
|
|
16
|
-
|
|
17
|
-
dayjs__default.extend(utc__default);
|
|
18
|
-
dayjs__default.extend(timezone__default);
|
|
19
|
-
function vitePluginLogs(options) {
|
|
20
|
-
const { name = "LNTVOW_VERSION" } = options;
|
|
21
|
-
let version = options.version;
|
|
22
|
-
if (!version) {
|
|
23
|
-
const packageJsonContent = fs__default.readFileSync(path__default.resolve(process.cwd(), "package.json"), "utf8");
|
|
24
|
-
if (!packageJsonContent)
|
|
25
|
-
throw new Error("package.json not found");
|
|
26
|
-
version = JSON.parse(packageJsonContent).version;
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
name: "vite-plugin-logs",
|
|
30
|
-
transform(code, id) {
|
|
31
|
-
if (id.endsWith("src/main.ts")) {
|
|
32
|
-
const time = dayjs__default().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss");
|
|
33
|
-
return {
|
|
34
|
-
code: `
|
|
1
|
+
"use strict";const m=require("node:path"),a=require("node:fs"),e=require("dayjs"),f=require("dayjs/plugin/utc.js"),p=require("dayjs/plugin/timezone.js");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const m__default=_interopDefaultCompat(m),a__default=_interopDefaultCompat(a),e__default=_interopDefaultCompat(e),f__default=_interopDefaultCompat(f),p__default=_interopDefaultCompat(p);e__default.extend(f__default),e__default.extend(p__default);function vitePluginLogs(t){const{name:r="LNTVOW_VERSION"}=t;let o=t.version;if(!o){const n=a__default.readFileSync(m__default.resolve(process.cwd(),"package.json"),"utf8");if(!n)throw new Error("package.json not found");o=JSON.parse(n).version}return{name:"vite-plugin-logs",transform(n,i){if(i.endsWith("src/main.ts")){const s=e__default().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss");return{code:`
|
|
35
2
|
|
|
36
3
|
import { log } from '@lntvow/utils';
|
|
37
4
|
|
|
38
|
-
${
|
|
39
|
-
|
|
40
|
-
localStorage.setItem('${name}', JSON.stringify(['${time}', '${version}']))
|
|
41
|
-
log('version', '${time}', '${version}')
|
|
5
|
+
${n}
|
|
42
6
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
7
|
+
localStorage.setItem('${r}', JSON.stringify(['${s}', '${o}']))
|
|
8
|
+
log('version', '${s}', '${o}')
|
|
49
9
|
|
|
50
|
-
exports.Logs
|
|
10
|
+
`}}}}}exports.Logs=vitePluginLogs;
|
package/dist/index.mjs
CHANGED
|
@@ -1,40 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
|
-
import utc from 'dayjs/plugin/utc.js';
|
|
5
|
-
import timezone from 'dayjs/plugin/timezone.js';
|
|
6
|
-
|
|
7
|
-
dayjs.extend(utc);
|
|
8
|
-
dayjs.extend(timezone);
|
|
9
|
-
function vitePluginLogs(options) {
|
|
10
|
-
const { name = "LNTVOW_VERSION" } = options;
|
|
11
|
-
let version = options.version;
|
|
12
|
-
if (!version) {
|
|
13
|
-
const packageJsonContent = fs.readFileSync(path.resolve(process.cwd(), "package.json"), "utf8");
|
|
14
|
-
if (!packageJsonContent)
|
|
15
|
-
throw new Error("package.json not found");
|
|
16
|
-
version = JSON.parse(packageJsonContent).version;
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
name: "vite-plugin-logs",
|
|
20
|
-
transform(code, id) {
|
|
21
|
-
if (id.endsWith("src/main.ts")) {
|
|
22
|
-
const time = dayjs().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss");
|
|
23
|
-
return {
|
|
24
|
-
code: `
|
|
1
|
+
import m from"node:path";import a from"node:fs";import t from"dayjs";import f from"dayjs/plugin/utc.js";import p from"dayjs/plugin/timezone.js";t.extend(f),t.extend(p);function c(e){const{name:i="LNTVOW_VERSION"}=e;let o=e.version;if(!o){const r=a.readFileSync(m.resolve(process.cwd(),"package.json"),"utf8");if(!r)throw new Error("package.json not found");o=JSON.parse(r).version}return{name:"vite-plugin-logs",transform(r,s){if(s.endsWith("src/main.ts")){const n=t().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss");return{code:`
|
|
25
2
|
|
|
26
3
|
import { log } from '@lntvow/utils';
|
|
27
4
|
|
|
28
|
-
${
|
|
29
|
-
|
|
30
|
-
localStorage.setItem('${name}', JSON.stringify(['${time}', '${version}']))
|
|
31
|
-
log('version', '${time}', '${version}')
|
|
5
|
+
${r}
|
|
32
6
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
7
|
+
localStorage.setItem('${i}', JSON.stringify(['${n}', '${o}']))
|
|
8
|
+
log('version', '${n}', '${o}')
|
|
39
9
|
|
|
40
|
-
export
|
|
10
|
+
`}}}}}export{c as Logs};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lntvow/vite-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "vite插件",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
"module": "dist/index.mjs",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@lntvow/utils": "^1.8.5",
|
|
16
15
|
"dayjs": "^1.11.10"
|
|
17
16
|
},
|
|
18
17
|
"devDependencies": {
|
|
18
|
+
"@commitlint/cli": "^17.7.1",
|
|
19
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
19
20
|
"unbuild": "^2.0.0",
|
|
20
21
|
"@lntvow/eslint-config": "^8.2.18",
|
|
21
22
|
"bumpp": "^9.1.1",
|
|
@@ -24,10 +25,15 @@
|
|
|
24
25
|
"typescript": "^5.0.4"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
|
-
"vite": "
|
|
28
|
+
"vite": ">=4.0.0"
|
|
28
29
|
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
30
|
+
"lint-staged": {
|
|
31
|
+
"*.{js,jsx,ts,tsx,vue}": [
|
|
32
|
+
"eslint --fix"
|
|
33
|
+
],
|
|
34
|
+
"*.{json,css,scss,md}": [
|
|
35
|
+
"prettier --write"
|
|
36
|
+
]
|
|
31
37
|
},
|
|
32
38
|
"scripts": {
|
|
33
39
|
"build": "unbuild",
|