@elcrm/deploy 0.0.10 → 0.0.11

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.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ var o={command:"",options:{},flags:[]},b=(t)=>{switch(!0){case t.startsWith("--"):if(t.includes("=")){let[r,e]=t.split("=");o.options[r.slice(2)]=e}else o.flags.push(t);break;case t.startsWith("-"):o.flags.push(t.slice(1));break;case t.startsWith(""):o.command=t;break}return{command:o.command,options:o.options,flags:o.flags}},d=()=>{return process.argv.slice(2).forEach((t)=>{b(t)}),o};var f=async(t)=>{let e=JSON.parse(await Bun.file("./package.json").text()),s=e.version.split(".").map(Number);s[s.length-1]+=1,e.version=s.join("."),console.log("v",e.version),await Bun.write("./package.json",JSON.stringify(e,null,2))};var p=async(t,r)=>{await f();let e=t.dir||"./out",s=t.name||"api";if(r.includes("client")){let n=Bun.spawn(["bun","run","build"],{stdout:"pipe",stderr:"pipe"}),i=await new Response(n.stdout).text(),l=await new Response(n.stderr).text();await n.exited,console.log("stdout:",i),console.log("stderr:",l),console.log("\u2699\uFE0F Build completed"),await Bun.spawn(["tar","czf","build.tar","build"]).exited;let c=Bun.file("./build.tar"),u=new FormData;u.append("upload",c);let w=await(await fetch(t.url,{method:"POST",body:u})).text();console.log(w)}else{let n=await Bun.build({entrypoints:["./src/index.js"],outdir:e,minify:!0,target:"bun",naming:`${s}.js`});if(!n.success){console.error("Build failed");for(let i of n.logs)console.error(i)}else if(t.url){let i=Bun.file(`${e}/${s}.js`),l=new FormData;l.append("upload",i),l.append("name",s);let c=await(await fetch(t.url,{method:"POST",body:l})).text();console.log(c)}}};var a={};a.build=p;var x=()=>{let t=d();if(t.flags.includes("dev"))console.log(t);if(a[t.command])a[t.command](t.options,t.flags);else console.log("Command not found")};x();
@@ -0,0 +1,26 @@
1
+ // @bun
2
+ // src/lib/index.ts
3
+ var upload;
4
+ ((upload) => {
5
+ upload.client = async (body) => {
6
+ await Bun.write("build.tar", body.upload);
7
+ const proc = Bun.spawn(["tar", "-xzvf", "build.tar"]);
8
+ await proc.exited;
9
+ const proc2 = Bun.spawn([`rm`, "build.tar"]);
10
+ await proc2.exited;
11
+ const pmId = process.env.pm_id || "0";
12
+ const p = Bun.spawn([`pm2`, `restart`, pmId]);
13
+ await p.exited;
14
+ p.kill();
15
+ };
16
+ upload.server = async (body) => {
17
+ await Bun.write(`${body.name}.js`, body.upload);
18
+ const pmId = process.env.pm_id || "0";
19
+ const proc = Bun.spawn([`pm2`, `restart`, pmId]);
20
+ await proc.exited;
21
+ proc.kill();
22
+ };
23
+ })(upload ||= {});
24
+ export {
25
+ upload
26
+ };
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@elcrm/deploy",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "plugin for elCRM",
5
5
  "type": "module",
6
6
  "author": "MaSkal <dev@elcrm.online>",
7
7
  "license": "MIT",
8
- "main": "dist/index.js",
9
- "module": "dist/index.js",
10
- "types": "dist/index.d.ts",
8
+ "main": "dist/lib/index.js",
9
+ "module": "dist/lib/index.js",
10
+ "types": "dist/lib/index.d.ts",
11
11
  "bin": {
12
- "el": "./bin/index.js",
13
- "elcrm": "./bin/index.js"
12
+ "el": "./dist/bin/index.js",
13
+ "elcrm": "./dist/bin/index.js"
14
14
  },
15
15
  "files": [
16
16
  "dist"
package/dist/index.js DELETED
@@ -1,24 +0,0 @@
1
- // @bun
2
- // src/lib/index.ts
3
- var upload;
4
- ((upload) => {
5
- upload.client = async (body) => {
6
- await Bun.write("build.tar", body.upload);
7
- const proc = Bun.spawn(["tar", "-xzvf", "build.tar"]);
8
- await proc.exited;
9
- const proc2 = Bun.spawn([`rm`, "build.tar"]);
10
- await proc2.exited;
11
- const pmId = process.env.pm_id || "0";
12
- const p = Bun.spawn([`pm2`, `restart`, pmId]);
13
- await p.exited;
14
- p.kill();
15
- };
16
- upload.server = async (body) => {
17
- await Bun.write(`${body.name}.js`, body.upload);
18
- const pmId = process.env.pm_id || "0";
19
- const proc = Bun.spawn([`pm2`, `restart`, pmId]);
20
- await proc.exited;
21
- proc.kill();
22
- };
23
- })((upload ||= {}));
24
- export { upload };