@lntvow/vite-plugin 0.0.6 → 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 CHANGED
@@ -1,53 +1,10 @@
1
- 'use strict';
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(
24
- path__default.resolve(process.cwd(), "package.json"),
25
- "utf8"
26
- );
27
- if (!packageJsonContent)
28
- throw new Error("package.json not found");
29
- version = JSON.parse(packageJsonContent).version;
30
- }
31
- return {
32
- name: "vite-plugin-logs",
33
- transform(code, id) {
34
- if (id.endsWith("src/main.ts")) {
35
- const time = dayjs__default().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss");
36
- return {
37
- 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:`
38
2
 
39
3
  import { log } from '@lntvow/utils';
40
4
 
41
- ${code}
42
-
43
- localStorage.setItem('${name}', JSON.stringify(['${time}', '${version}']))
44
- log('version', '${time}', '${version}')
5
+ ${n}
45
6
 
46
- `
47
- };
48
- }
49
- }
50
- };
51
- }
7
+ localStorage.setItem('${r}', JSON.stringify(['${s}', '${o}']))
8
+ log('version', '${s}', '${o}')
52
9
 
53
- exports.Logs = vitePluginLogs;
10
+ `}}}}}exports.Logs=vitePluginLogs;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- declare function vitePluginLogs(options?: Options): Plugin;
3
+ declare function vitePluginLogs(options: Options): Plugin;
4
4
  interface Options {
5
5
  /**
6
6
  * @description localStorage key
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- declare function vitePluginLogs(options?: Options): Plugin;
3
+ declare function vitePluginLogs(options: Options): Plugin;
4
4
  interface Options {
5
5
  /**
6
6
  * @description localStorage key
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- declare function vitePluginLogs(options?: Options): Plugin;
3
+ declare function vitePluginLogs(options: Options): Plugin;
4
4
  interface Options {
5
5
  /**
6
6
  * @description localStorage key
package/dist/index.mjs CHANGED
@@ -1,43 +1,10 @@
1
- import path from 'node:path';
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(
14
- path.resolve(process.cwd(), "package.json"),
15
- "utf8"
16
- );
17
- if (!packageJsonContent)
18
- throw new Error("package.json not found");
19
- version = JSON.parse(packageJsonContent).version;
20
- }
21
- return {
22
- name: "vite-plugin-logs",
23
- transform(code, id) {
24
- if (id.endsWith("src/main.ts")) {
25
- const time = dayjs().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss");
26
- return {
27
- 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:`
28
2
 
29
3
  import { log } from '@lntvow/utils';
30
4
 
31
- ${code}
32
-
33
- localStorage.setItem('${name}', JSON.stringify(['${time}', '${version}']))
34
- log('version', '${time}', '${version}')
5
+ ${r}
35
6
 
36
- `
37
- };
38
- }
39
- }
40
- };
41
- }
7
+ localStorage.setItem('${i}', JSON.stringify(['${n}', '${o}']))
8
+ log('version', '${n}', '${o}')
42
9
 
43
- export { vitePluginLogs as Logs };
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.6",
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": "^4.4.6"
28
+ "vite": ">=4.0.0"
28
29
  },
29
- "resolutions": {
30
- "bin-wrapper": "npm:bin-wrapper-china"
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",