ms-vite-plugin 0.0.1 → 0.0.3

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/MSPlugin.js CHANGED
@@ -1,21 +1,43 @@
1
1
  import t from "fs-extra";
2
- import e from "path";
3
- import * as w from "7zip-min";
4
- function l({
5
- resDir: c,
6
- outDir: o,
7
- distDir: r
8
- }) {
2
+ import s from "path";
3
+ import * as m from "7zip-min";
4
+ async function l(c, i) {
5
+ const e = [];
6
+ async function a(r) {
7
+ const o = await t.readdir(r, { withFileTypes: !0 });
8
+ for (const n of o) {
9
+ const p = s.resolve(r, n.name);
10
+ n.isDirectory() ? await a(p) : n.isFile() && /\.(js|ts)$/.test(n.name) && e.push(s.relative(i, p));
11
+ }
12
+ }
13
+ return await a(c), e;
14
+ }
15
+ function w() {
16
+ const c = s.join(process.cwd(), "scripts");
9
17
  return {
10
- name: "magic-script-plugin",
18
+ name: "ms-main-plugin",
19
+ async config(i) {
20
+ const e = await l(c, c);
21
+ i.build = {
22
+ lib: {
23
+ entry: [
24
+ "./scripts/main.js",
25
+ ...e.map((a) => `./scripts/${a}`)
26
+ ],
27
+ formats: ["cjs"]
28
+ },
29
+ outDir: "msbundle/ms"
30
+ };
31
+ },
11
32
  async closeBundle() {
12
- const s = e.join(process.cwd(), o), i = e.join(process.cwd(), r), p = e.join(process.cwd(), "package.json"), d = e.join(s, "package.json"), a = await t.readJSON(p);
13
- delete a.scripts, delete a.devDependencies, delete a.dependencies, await t.writeJSON(d, a, { spaces: 2 }), await t.copy(c, e.join(s, "ms", "res")), await t.emptyDir(i);
14
- const n = e.join(i, "ms.zip"), m = e.join(i, "ms.msbundle");
15
- await w.pack(s + "/*", n), await t.rename(n, m), await t.rm(s, { recursive: !0 });
33
+ await t.copy("./res", s.join("msbundle", "ms", "res")), await t.copy("./ui", s.join("msbundle", "ms", "ui"));
34
+ const i = s.join(process.cwd(), "msbundle"), e = s.join(process.cwd(), "dist"), a = s.join(process.cwd(), "package.json"), r = s.join(i, "package.json"), o = await t.readJSON(a);
35
+ delete o.scripts, delete o.devDependencies, delete o.dependencies, await t.writeJSON(r, o, { spaces: 2 }), await t.emptyDir(e);
36
+ const n = s.join(e, "ms.zip"), p = s.join(e, "ms.msbundle");
37
+ await m.pack(i + "/*", n), await t.rename(n, p), await t.rm(i, { recursive: !0 });
16
38
  }
17
39
  };
18
40
  }
19
41
  export {
20
- l as MagicScriptPlugin
42
+ w as MSMainPlugin
21
43
  };
@@ -1 +1 @@
1
- (function(n,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("fs-extra"),require("path"),require("7zip-min")):typeof define=="function"&&define.amd?define(["exports","fs-extra","path","7zip-min"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.MSPlugin={},n.fsExtra,n.path,n._7z))})(this,function(n,e,t,d){"use strict";function p(i){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const s in i)if(s!=="default"){const c=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(o,s,c.get?c:{enumerable:!0,get:()=>i[s]})}}return o.default=i,Object.freeze(o)}const f=p(d);function l({resDir:i,outDir:o,distDir:s}){return{name:"magic-script-plugin",async closeBundle(){const c=t.join(process.cwd(),o),a=t.join(process.cwd(),s),m=t.join(process.cwd(),"package.json"),j=t.join(c,"package.json"),r=await e.readJSON(m);delete r.scripts,delete r.devDependencies,delete r.dependencies,await e.writeJSON(j,r,{spaces:2}),await e.copy(i,t.join(c,"ms","res")),await e.emptyDir(a);const u=t.join(a,"ms.zip"),g=t.join(a,"ms.msbundle");await f.pack(c+"/*",u),await e.rename(u,g),await e.rm(c,{recursive:!0})}}}n.MagicScriptPlugin=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("fs-extra"),require("path"),require("7zip-min")):typeof define=="function"&&define.amd?define(["exports","fs-extra","path","7zip-min"],n):(o=typeof globalThis<"u"?globalThis:o||self,n(o.MSPlugin={},o.fsExtra,o.path,o._7z))})(this,function(o,n,i,l){"use strict";function p(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const c=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(s,e,c.get?c:{enumerable:!0,get:()=>t[e]})}}return s.default=t,Object.freeze(s)}const m=p(l);async function f(t,s){const e=[];async function c(u){const a=await n.readdir(u,{withFileTypes:!0});for(const r of a){const d=i.resolve(u,r.name);r.isDirectory()?await c(d):r.isFile()&&/\.(js|ts)$/.test(r.name)&&e.push(i.relative(s,d))}}return await c(t),e}function j(){const t=i.join(process.cwd(),"scripts");return{name:"ms-main-plugin",async config(s){const e=await f(t,t);s.build={lib:{entry:["./scripts/main.js",...e.map(c=>`./scripts/${c}`)],formats:["cjs"]},outDir:"msbundle/ms"}},async closeBundle(){await n.copy("./res",i.join("msbundle","ms","res")),await n.copy("./ui",i.join("msbundle","ms","ui"));const s=i.join(process.cwd(),"msbundle"),e=i.join(process.cwd(),"dist"),c=i.join(process.cwd(),"package.json"),u=i.join(s,"package.json"),a=await n.readJSON(c);delete a.scripts,delete a.devDependencies,delete a.dependencies,await n.writeJSON(u,a,{spaces:2}),await n.emptyDir(e);const r=i.join(e,"ms.zip"),d=i.join(e,"ms.msbundle");await m.pack(s+"/*",r),await n.rename(r,d),await n.rm(s,{recursive:!0})}}}o.MSMainPlugin=j,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/dist/index.d.ts CHANGED
@@ -1,6 +1,2 @@
1
1
  import { Plugin } from 'vite';
2
- export declare function MagicScriptPlugin({ resDir, outDir, distDir, }: {
3
- resDir: string;
4
- outDir: string;
5
- distDir: string;
6
- }): Plugin;
2
+ export declare function MSMainPlugin(): Plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {