@tricoteuses/assemblee 2.4.1 → 2.4.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.
@@ -0,0 +1,33 @@
1
+ import c from "fs-extra";
2
+ import { glob as f } from "glob";
3
+ import r from "node:path";
4
+ function* l(i, o = []) {
5
+ const t = r.join(i, ...o);
6
+ if (c.existsSync(t))
7
+ for (const s of c.readdirSync(t)) {
8
+ if (s[0] === ".")
9
+ continue;
10
+ const e = r.join(t, s), n = [...o, s];
11
+ c.statSync(e).isDirectory() ? yield* l(i, n) : yield n;
12
+ }
13
+ }
14
+ class a {
15
+ constructor(o) {
16
+ this.message = o;
17
+ }
18
+ }
19
+ function g(i) {
20
+ let o = [];
21
+ function t(s) {
22
+ if (f.hasMagic(s)) {
23
+ const e = f.globSync(s, { cwd: process.cwd() });
24
+ e.length > 0 && (o = o.concat(e));
25
+ } else if (o.push(s), !c.existsSync(s))
26
+ throw new a(`${s} file does not exist`);
27
+ }
28
+ return i.forEach(t), o;
29
+ }
30
+ export {
31
+ g,
32
+ l as w
33
+ };
package/lib/git.js ADDED
@@ -0,0 +1,121 @@
1
+ import l from "fs-extra";
2
+ import { execSync as r } from "node:child_process";
3
+ import $ from "node:path";
4
+ import { g as p } from "./file_systems-CzTtoLWb.js";
5
+ const a = 50 * 1024 * 1024;
6
+ function v(e, c) {
7
+ r("git add .", {
8
+ cwd: e,
9
+ env: process.env,
10
+ encoding: "utf-8",
11
+ stdio: ["ignore", "ignore", "pipe"],
12
+ maxBuffer: a
13
+ });
14
+ try {
15
+ return r(`git commit -m "${c}" --quiet`, {
16
+ cwd: e,
17
+ env: process.env,
18
+ encoding: "utf-8",
19
+ stdio: ["ignore", "pipe", "pipe"]
20
+ }), !0;
21
+ } catch (t) {
22
+ if (t.stdout === null || !/nothing to commit/.test(t.stdout))
23
+ throw console.error(t.output), t;
24
+ return !1;
25
+ }
26
+ }
27
+ function E(e, c, t) {
28
+ let n = 0;
29
+ if (v(e, c))
30
+ for (const s of t || [])
31
+ try {
32
+ r(`git push ${s} master`, {
33
+ cwd: e,
34
+ env: process.env,
35
+ encoding: "utf-8",
36
+ stdio: ["ignore", "ignore", "pipe"]
37
+ });
38
+ } catch (i) {
39
+ console.error(i.output), n = i.status;
40
+ }
41
+ else
42
+ n = 10;
43
+ return n;
44
+ }
45
+ function P(e) {
46
+ return r("git reset --hard origin/master", {
47
+ cwd: e,
48
+ env: process.env,
49
+ encoding: "utf-8",
50
+ stdio: ["ignore", "ignore", "pipe"]
51
+ }), r("git pull --rebase", {
52
+ cwd: e,
53
+ env: process.env,
54
+ encoding: "utf-8",
55
+ stdio: ["ignore", "ignore", "pipe"]
56
+ }), !0;
57
+ }
58
+ function H(e, c, t) {
59
+ e !== void 0 && r(`git clone ${e}/${c}.git`, {
60
+ cwd: t,
61
+ env: process.env,
62
+ encoding: "utf-8",
63
+ stdio: ["ignore", "ignore", "pipe"]
64
+ });
65
+ }
66
+ function o(e, c, t) {
67
+ try {
68
+ t && console.log(`git -C ${e} ${c}`);
69
+ const n = r(`git ${c}`, {
70
+ cwd: e,
71
+ maxBuffer: a
72
+ }).toString().trim();
73
+ return t && console.log(n), n;
74
+ } catch (n) {
75
+ for (const s of ["stdout", "stderr"])
76
+ console.error(`${s}: ${n[s]}`);
77
+ throw n;
78
+ }
79
+ }
80
+ function d(e, c, t) {
81
+ try {
82
+ t && console.log(`git -C ${e} ${c}`);
83
+ const n = r(`git ${c}`, {
84
+ cwd: e,
85
+ stdio: ["ignore", "pipe", "pipe"],
86
+ maxBuffer: a
87
+ }).toString().trim();
88
+ return t && console.log(n), !0;
89
+ } catch (n) {
90
+ if (n.status != 0) return !1;
91
+ throw n;
92
+ }
93
+ }
94
+ function S(e, c, t) {
95
+ const n = o(e, "rev-parse --abbrev-ref HEAD"), s = "uid", i = process.cwd();
96
+ process.chdir(e);
97
+ for (const f of c) {
98
+ const u = `${f}/uid`;
99
+ l.ensureDirSync(u);
100
+ for (const g of p([`${f}/**/*.json`])) {
101
+ const h = $.basename(g);
102
+ l.renameSync(g, `${u}/${h}`);
103
+ }
104
+ }
105
+ process.chdir(i), d(e, `rev-parse remotes/origin/${s}`) ? (o(e, `branch --force ${s} origin/${s}`), o(e, `symbolic-ref HEAD refs/heads/${s}`), o(e, "reset")) : d(e, `rev-parse refs/heads/${s}`) ? (o(e, `symbolic-ref HEAD refs/heads/${s}`), o(e, "reset")) : (o(e, `branch --force ${s} master`), o(e, `symbolic-ref HEAD refs/heads/${s}`), o(e, "reset"), o(e, "rm -r ."));
106
+ for (const f of c) {
107
+ const u = `${f}/uid`;
108
+ o(e, `add ${u}`);
109
+ }
110
+ let m = !1;
111
+ return d(e, "diff --quiet --cached") || (o(e, "commit -m 'Update'"), m = !0), o(e, `symbolic-ref HEAD refs/heads/${n}`), o(e, `reset ${t ? "" : "--hard"}`), m;
112
+ }
113
+ export {
114
+ H as clone,
115
+ v as commit,
116
+ E as commitAndPush,
117
+ P as resetAndPull,
118
+ o as run,
119
+ d as test,
120
+ S as uidBranchUpdate
121
+ };
package/lib/loaders.d.ts CHANGED
@@ -57,44 +57,57 @@ export interface Data {
57
57
  export declare function iterLoadAssembleeActeurs(dataDir: string, legislature: Legislature, options?: {}): Generator<{
58
58
  acteur: Acteur;
59
59
  datasetLegislature: Legislature;
60
+ filePath: string;
60
61
  }, void, unknown>;
61
62
  export declare function iterLoadAssembleeOrganes(dataDir: string, legislature: Legislature, options?: {}): Generator<{
62
63
  organe: Organe;
63
64
  datasetLegislature: Legislature;
65
+ filePath: string;
64
66
  }, void, unknown>;
65
67
  export declare function iterLoadAssembleeAmendements(dataDir: string, legislature: Legislature, options?: {}): Generator<{
66
68
  amendement: Amendement;
67
69
  datasetLegislature: Legislature;
70
+ filePath: string;
68
71
  }, void, unknown>;
69
72
  export declare function iterLoadAssembleeDocuments(dataDir: string, legislature: Legislature, options?: {}): Generator<{
70
73
  document: Document;
71
74
  datasetLegislature: Legislature;
75
+ filePath: string;
72
76
  }, void, unknown>;
73
77
  export declare function iterLoadAssembleeDossiersParlementaires(dataDir: string, legislature: Legislature, options?: {}): Generator<{
74
78
  dossierParlementaire: DossierParlementaire;
75
79
  datasetLegislature: Legislature;
80
+ filePath: string;
76
81
  }, void, unknown>;
77
82
  export declare function iterLoadAssembleeReunions(dataDir: string, legislature: Legislature, options?: {}): Generator<{
78
83
  reunion: Reunion;
79
84
  datasetLegislature: Legislature;
85
+ filePath: string;
80
86
  }, void, unknown>;
81
87
  export declare function iterLoadAssembleeScrutins(dataDir: string, legislature: Legislature, options?: {}): Generator<{
82
88
  scrutin: Scrutin;
83
89
  datasetLegislature: Legislature;
90
+ filePath: string;
84
91
  }, void, unknown>;
85
92
  export declare function iterLoadAssembleeQuestions(dataDir: string, legislature: Legislature, options?: {}): Generator<{
86
93
  question: Question;
87
94
  datasetLegislature: Legislature;
95
+ filePath: string;
88
96
  }, void, unknown>;
89
97
  export declare function iterLoadAssembleeComptesRendus(dataDir: string, legislature: Legislature, options?: {}): Generator<{
90
98
  compteRendu: CompteRendu;
91
99
  datasetLegislature: Legislature;
100
+ filePath: string;
92
101
  }, void, unknown>;
93
- export declare function iterLoadAssembleeComptesRendusCommissions(dataDir: string, legislature: Legislature): Generator<{
102
+ export declare function iterLoadAssembleeComptesRendusCommissions(dataDir: string, legislature: Legislature, { enriched }?: {
103
+ enriched?: boolean | undefined;
104
+ }): Generator<{
94
105
  compteRendu: CompteRendu;
95
106
  datasetLegislature: Legislature;
107
+ filePath: string;
96
108
  }, void, unknown>;
97
- export declare function loadAssembleeData(dataDir: string, enabledDatasets: EnabledDatasets, legislature: Legislature, { log }?: {
109
+ export declare function loadAssembleeData(dataDir: string, enabledDatasets: EnabledDatasets, legislature: Legislature, { enriched, log }?: {
110
+ enriched?: boolean | undefined;
98
111
  log?: boolean | undefined;
99
112
  }): Data;
100
113
  export declare function loadAssembleeDataFromBigFiles(dataDir: string, enabledDatasets: EnabledDatasets, legislature: Legislature, { log }?: {