@elcrm/deploy 0.0.9 → 0.0.10
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.js +22 -104
- package/package.json +24 -24
package/dist/index.js
CHANGED
|
@@ -1,106 +1,24 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
1
|
// @bun
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
r.command = t;
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
return { command: r.command, options: r.options, flags: r.flags };
|
|
20
|
-
},
|
|
21
|
-
m = () => {
|
|
22
|
-
return (
|
|
23
|
-
process.argv.slice(2).forEach((t) => {
|
|
24
|
-
B(t);
|
|
25
|
-
}),
|
|
26
|
-
r
|
|
27
|
-
);
|
|
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();
|
|
28
15
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
await w();
|
|
39
|
-
let e = t.dir || "./out",
|
|
40
|
-
s = t.name || "api";
|
|
41
|
-
if (i.includes("client")) {
|
|
42
|
-
let o = Bun.spawn(["bun", "run", "build"], {
|
|
43
|
-
stdout: "pipe",
|
|
44
|
-
stderr: "pipe",
|
|
45
|
-
}),
|
|
46
|
-
n = await new Response(o.stdout).text(),
|
|
47
|
-
a = await new Response(o.stderr).text();
|
|
48
|
-
await o.exited,
|
|
49
|
-
console.log("stdout:", n),
|
|
50
|
-
console.log("stderr:", a),
|
|
51
|
-
console.log("\u2699\uFE0F Build completed"),
|
|
52
|
-
await Bun.spawn(["tar", "czf", "build.tar", "build"]).exited;
|
|
53
|
-
let u = Bun.file("./build.tar"),
|
|
54
|
-
p = new FormData();
|
|
55
|
-
p.append("upload", u);
|
|
56
|
-
let g = await (await fetch(t.url, { method: "POST", body: p })).text();
|
|
57
|
-
console.log(g);
|
|
58
|
-
} else {
|
|
59
|
-
let o = await Bun.build({
|
|
60
|
-
entrypoints: ["./src/index.js"],
|
|
61
|
-
outdir: e,
|
|
62
|
-
minify: !0,
|
|
63
|
-
target: "bun",
|
|
64
|
-
naming: `${s}.js`,
|
|
65
|
-
});
|
|
66
|
-
if (!o.success) {
|
|
67
|
-
console.error("Build failed");
|
|
68
|
-
for (let n of o.logs) console.error(n);
|
|
69
|
-
} else if (t.url) {
|
|
70
|
-
let n = Bun.file(`${e}/${s}.js`),
|
|
71
|
-
a = new FormData();
|
|
72
|
-
a.append("upload", n), a.append("name", s);
|
|
73
|
-
let u = await (
|
|
74
|
-
await fetch(t.url, { method: "POST", body: a })
|
|
75
|
-
).text();
|
|
76
|
-
console.log(u);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var c = {};
|
|
81
|
-
c.build = f;
|
|
82
|
-
var x;
|
|
83
|
-
((d) => (
|
|
84
|
-
(d.client = async (e) => {
|
|
85
|
-
await Bun.write("build.tar", e.upload),
|
|
86
|
-
await Bun.spawn(["tar", "-xzvf", "build.tar"]).exited,
|
|
87
|
-
await Bun.spawn(["rm", "build.tar"]).exited;
|
|
88
|
-
let o = process.env.pm_id || "0",
|
|
89
|
-
n = Bun.spawn(["pm2", "restart", o]);
|
|
90
|
-
await n.exited, n.kill();
|
|
91
|
-
}),
|
|
92
|
-
(d.server = async (e) => {
|
|
93
|
-
await Bun.write(`${e.name}.js`, e.upload);
|
|
94
|
-
let s = process.env.pm_id || "0",
|
|
95
|
-
l = Bun.spawn(["pm2", "restart", s]);
|
|
96
|
-
await l.exited, l.kill();
|
|
97
|
-
})
|
|
98
|
-
))((x ||= {}));
|
|
99
|
-
var T = () => {
|
|
100
|
-
let t = m();
|
|
101
|
-
if (t.flags.includes("dev")) console.log(t);
|
|
102
|
-
if (c[t.command]) c[t.command](t.options, t.flags);
|
|
103
|
-
else console.log("Command not found");
|
|
104
|
-
};
|
|
105
|
-
T();
|
|
106
|
-
export { x as upload };
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
2
|
+
"name": "@elcrm/deploy",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"description": "plugin for elCRM",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "MaSkal <dev@elcrm.online>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"bin": {
|
|
12
|
+
"el": "./bin/index.js",
|
|
13
|
+
"elcrm": "./bin/index.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"elcrm",
|
|
20
|
+
"deploy"
|
|
21
|
+
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/bun": "^1.2.18"
|
|
24
|
+
}
|
|
25
|
+
}
|