@tricoteuses/assemblee 2.5.18 → 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.
Files changed (3) hide show
  1. package/lib/git.d.ts +1 -0
  2. package/lib/git.js +44 -33
  3. 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 u(t, n) {
4
- i("git add .", {
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 "${n}" --quiet`, {
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 f(t, n, e) {
25
- let o = 0;
26
- if (u(t, n))
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), o = s.status;
46
+ console.error(s.output), n = s.status;
37
47
  }
38
48
  else
39
- o = 10;
40
- return o;
49
+ n = 10;
50
+ return n;
41
51
  }
42
- function g(t) {
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 p(t, n, e) {
56
- t !== void 0 && i(`git clone ${t}/${n}.git`, {
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 l(t, n, e) {
73
+ function w(t, o, e) {
64
74
  try {
65
- e && console.log(`git -C ${t} ${n}`);
66
- const o = i(`git ${n}`, {
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(o), o;
71
- } catch (o) {
80
+ return e && console.log(n), n;
81
+ } catch (n) {
72
82
  for (const c of ["stdout", "stderr"])
73
- console.error(`${c}: ${o[c]}`);
74
- throw o;
83
+ console.error(`${c}: ${n[c]}`);
84
+ throw n;
75
85
  }
76
86
  }
77
- function m(t, n, e) {
87
+ function $(t, o, e) {
78
88
  try {
79
- e && console.log(`git -C ${t} ${n}`);
80
- const o = i(`git ${n}`, {
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(o), !0;
86
- } catch (o) {
87
- if (o.status != 0) return !1;
88
- throw o;
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
- p as clone,
93
- u as commit,
94
- f as commitAndPush,
95
- g as resetAndPull,
96
- l as run,
97
- m as test
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/assemblee",
3
- "version": "2.5.18",
3
+ "version": "2.5.19",
4
4
  "description": "Retrieve, clean up & handle French Assemblée nationale's open data",
5
5
  "keywords": [
6
6
  "Assemblée nationale",