vite-plugin-zip-file 2.2.0 → 3.0.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/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  Zip files at build time.
7
7
 
8
+ **Tips: Node.js 16+ is required.**
9
+
8
10
  # Install
9
11
 
10
12
  ```
package/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("path"),n=require("fs"),P=require("node:module"),F=P.createRequire(typeof document>"u"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("index.cjs",document.baseURI).href),r=t.sep,{cwd:h}=process,Z={enabled:!0,folderPath:t.join(h(),"/dist"),outPath:t.resolve(h()),zipName:"",deleteFolder:!1},z=v=>{let g={...Z,...v},{enabled:f,folderPath:c,outPath:s,zipName:o,deleteFolder:b}=g;if(f=Boolean(f),!c||!s)throw new Error("config.folderPath and config.outPath is required.");c=t.resolve(c),s=t.resolve(s),o=o||c.split(r).pop()+".zip";const j=()=>{const q=F("jszip"),p=new q,a=function(e,i,l=""){const d=n.readdirSync(i);l+=i.split(r).pop()+r,d.forEach(m=>{const u=t.join(i,r,m);n.statSync(u).isDirectory()?a(e,u,l):e.file(l+m,n.readFileSync(u))})},y=(e=o)=>{const i=t.join(s,r+e);n.existsSync(i)&&n.unlinkSync(i)},S=e=>{n.readdirSync(e).forEach(l=>{const d=e+r+l;n.statSync(d).isDirectory()?S(d):n.unlinkSync(d)}),n.rmdirSync(e)},w=function(){a(p,c),p.generateAsync({type:"nodebuffer",compression:"DEFLATE",compressionOptions:{level:9}}).then(e=>{y(o),n.writeFileSync(t.join(s,r,o),e),b&&S(c)})};y(o),w()};return{name:"vite-plugin-zip-file",apply:"build",closeBundle(){f&&j()}}};exports.viteZip=z;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("path"),n=require("fs"),w=require("node:module");var h=typeof document<"u"?document.currentScript:null;const Z=w.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:h&&h.src||new URL("index.cjs",document.baseURI).href),r=t.sep,{cwd:v}=process,z={enabled:!0,folderPath:t.join(v(),"/dist"),outPath:t.resolve(v()),zipName:"",deleteFolder:!1},E=g=>{let b={...z,...g},{enabled:u,folderPath:c,outPath:s,zipName:o,deleteFolder:j}=b;if(u=!!u,!c||!s)throw new Error("config.folderPath and config.outPath is required.");c=t.resolve(c),s=t.resolve(s),o=o||c.split(r).pop()+".zip";const q=()=>{const F=Z("jszip"),p=new F,a=function(e,i,l=""){const d=n.readdirSync(i);l+=i.split(r).pop()+r,d.forEach(S=>{const f=t.join(i,r,S);n.statSync(f).isDirectory()?a(e,f,l):e.file(l+S,n.readFileSync(f))})},y=(e=o)=>{const i=t.join(s,r+e);n.existsSync(i)&&n.unlinkSync(i)},m=e=>{n.readdirSync(e).forEach(l=>{const d=e+r+l;n.statSync(d).isDirectory()?m(d):n.unlinkSync(d)}),n.rmdirSync(e)},P=function(){a(p,c),p.generateAsync({type:"nodebuffer",compression:"DEFLATE",compressionOptions:{level:9}}).then(e=>{y(o),n.writeFileSync(t.join(s,r,o),e),j&&m(c)})};y(o),P()};return{name:"vite-plugin-zip-file",apply:"build",closeBundle(){u&&q()}}};exports.viteZip=E;
package/lib/index.mjs CHANGED
@@ -12,7 +12,7 @@ const E = z(import.meta.url), r = t.sep, { cwd: h } = process, Z = {
12
12
  ...Z,
13
13
  ...v
14
14
  }, { enabled: f, folderPath: s, outPath: c, zipName: n, deleteFolder: F } = g;
15
- if (f = Boolean(f), !s || !c)
15
+ if (f = !!f, !s || !c)
16
16
  throw new Error("config.folderPath and config.outPath is required.");
17
17
  s = t.resolve(s), c = t.resolve(c), n = n || s.split(r).pop() + ".zip";
18
18
  const P = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-zip-file",
3
- "version": "2.2.0",
3
+ "version": "3.0.0",
4
4
  "description": "zip files at build time.",
5
5
  "type": "module",
6
6
  "main": "lib/index.cjs",
@@ -36,7 +36,10 @@
36
36
  "jszip": "^3.10.1"
37
37
  },
38
38
  "devDependencies": {
39
- "vite": "^4.0.4",
40
- "@rollup/plugin-node-resolve": "^13.3.0"
39
+ "vite": "^5.1.0",
40
+ "@rollup/plugin-node-resolve": "^15.2.0"
41
+ },
42
+ "peerDependencies": {
43
+ "vite": ">=2.0.0"
41
44
  }
42
45
  }