@tricoteuses/assemblee 2.5.17 → 2.5.19
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/lib/git.d.ts +1 -0
- package/lib/git.js +44 -33
- package/package.json +1 -1
package/lib/git.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function initRepo(repositoryDir: string): void;
|
|
1
2
|
export declare function commit(repositoryDir: string, message: string): boolean;
|
|
2
3
|
export declare function commitAndPush(repositoryDir: string, message: string, remotes?: string[]): number;
|
|
3
4
|
export declare function resetAndPull(gitDir: string): boolean;
|
package/lib/git.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { execSync as i } from "node:child_process";
|
|
2
|
+
import u from "fs-extra";
|
|
3
|
+
import d from "node:path";
|
|
2
4
|
const r = 50 * 1024 * 1024;
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
+
function f(t) {
|
|
6
|
+
u.existsSync(d.join(t, ".git")) || (u.ensureDirSync(t), i("git init", {
|
|
7
|
+
cwd: t,
|
|
8
|
+
env: process.env,
|
|
9
|
+
encoding: "utf-8",
|
|
10
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
function g(t, o) {
|
|
14
|
+
f(t), i("git add .", {
|
|
5
15
|
cwd: t,
|
|
6
16
|
env: process.env,
|
|
7
17
|
encoding: "utf-8",
|
|
@@ -9,21 +19,21 @@ function u(t, n) {
|
|
|
9
19
|
maxBuffer: r
|
|
10
20
|
});
|
|
11
21
|
try {
|
|
12
|
-
return i(`git commit -m "${
|
|
22
|
+
return i(`git commit -m "${o}" --quiet`, {
|
|
13
23
|
cwd: t,
|
|
14
24
|
env: process.env,
|
|
15
25
|
encoding: "utf-8",
|
|
16
26
|
stdio: ["ignore", "pipe", "pipe"]
|
|
17
27
|
}), !0;
|
|
18
28
|
} catch (e) {
|
|
19
|
-
if (e.stdout === null || !/nothing to commit/.test(e.stdout))
|
|
29
|
+
if (e.stdout === null || !/nothing to commit|rien à valider/.test(e.stdout))
|
|
20
30
|
throw console.error(e.output), e;
|
|
21
31
|
return !1;
|
|
22
32
|
}
|
|
23
33
|
}
|
|
24
|
-
function
|
|
25
|
-
let
|
|
26
|
-
if (
|
|
34
|
+
function a(t, o, e) {
|
|
35
|
+
let n = 0;
|
|
36
|
+
if (g(t, o))
|
|
27
37
|
for (const c of e || [])
|
|
28
38
|
try {
|
|
29
39
|
i(`git push ${c} master`, {
|
|
@@ -33,13 +43,13 @@ function f(t, n, e) {
|
|
|
33
43
|
stdio: ["ignore", "ignore", "pipe"]
|
|
34
44
|
});
|
|
35
45
|
} catch (s) {
|
|
36
|
-
console.error(s.output),
|
|
46
|
+
console.error(s.output), n = s.status;
|
|
37
47
|
}
|
|
38
48
|
else
|
|
39
|
-
|
|
40
|
-
return
|
|
49
|
+
n = 10;
|
|
50
|
+
return n;
|
|
41
51
|
}
|
|
42
|
-
function
|
|
52
|
+
function h(t) {
|
|
43
53
|
return i("git reset --hard origin/master", {
|
|
44
54
|
cwd: t,
|
|
45
55
|
env: process.env,
|
|
@@ -52,47 +62,48 @@ function g(t) {
|
|
|
52
62
|
stdio: ["ignore", "ignore", "pipe"]
|
|
53
63
|
}), !0;
|
|
54
64
|
}
|
|
55
|
-
function
|
|
56
|
-
t !== void 0 && i(`git clone ${t}/${
|
|
65
|
+
function v(t, o, e) {
|
|
66
|
+
t !== void 0 && i(`git clone ${t}/${o}.git`, {
|
|
57
67
|
cwd: e,
|
|
58
68
|
env: process.env,
|
|
59
69
|
encoding: "utf-8",
|
|
60
70
|
stdio: ["ignore", "ignore", "pipe"]
|
|
61
71
|
});
|
|
62
72
|
}
|
|
63
|
-
function
|
|
73
|
+
function w(t, o, e) {
|
|
64
74
|
try {
|
|
65
|
-
e && console.log(`git -C ${t} ${
|
|
66
|
-
const
|
|
75
|
+
e && console.log(`git -C ${t} ${o}`);
|
|
76
|
+
const n = i(`git ${o}`, {
|
|
67
77
|
cwd: t,
|
|
68
78
|
maxBuffer: r
|
|
69
79
|
}).toString().trim();
|
|
70
|
-
return e && console.log(
|
|
71
|
-
} catch (
|
|
80
|
+
return e && console.log(n), n;
|
|
81
|
+
} catch (n) {
|
|
72
82
|
for (const c of ["stdout", "stderr"])
|
|
73
|
-
console.error(`${c}: ${
|
|
74
|
-
throw
|
|
83
|
+
console.error(`${c}: ${n[c]}`);
|
|
84
|
+
throw n;
|
|
75
85
|
}
|
|
76
86
|
}
|
|
77
|
-
function
|
|
87
|
+
function $(t, o, e) {
|
|
78
88
|
try {
|
|
79
|
-
e && console.log(`git -C ${t} ${
|
|
80
|
-
const
|
|
89
|
+
e && console.log(`git -C ${t} ${o}`);
|
|
90
|
+
const n = i(`git ${o}`, {
|
|
81
91
|
cwd: t,
|
|
82
92
|
stdio: ["ignore", "pipe", "pipe"],
|
|
83
93
|
maxBuffer: r
|
|
84
94
|
}).toString().trim();
|
|
85
|
-
return e && console.log(
|
|
86
|
-
} catch (
|
|
87
|
-
if (
|
|
88
|
-
throw
|
|
95
|
+
return e && console.log(n), !0;
|
|
96
|
+
} catch (n) {
|
|
97
|
+
if (n.status != 0) return !1;
|
|
98
|
+
throw n;
|
|
89
99
|
}
|
|
90
100
|
}
|
|
91
101
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
v as clone,
|
|
103
|
+
g as commit,
|
|
104
|
+
a as commitAndPush,
|
|
105
|
+
f as initRepo,
|
|
106
|
+
h as resetAndPull,
|
|
107
|
+
w as run,
|
|
108
|
+
$ as test
|
|
98
109
|
};
|