@socialgouv/matomo-postgres 2.0.0-beta.1 → 2.0.0-beta.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.
package/bin/index.js CHANGED
@@ -1,11 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const { db } = require("../dist/db");
4
+
3
5
  const { default: run } = require("../dist/index");
6
+ const { default: migrate } = require("../dist/migrate-latest");
7
+
8
+ async function start(date) {
9
+ console.log(`\nRunning migrations\n`);
10
+ await migrate();
11
+ console.log(`\nStarting import\n`);
12
+ await run(date);
13
+ db.destroy();
14
+ }
4
15
 
5
16
  if (require.main === module) {
6
17
  const date =
7
18
  (process.argv[process.argv.length - 1].match(/^\d\d\d\d-\d\d-\d\d$/) && process.argv[process.argv.length - 1]) ||
8
19
  "";
9
20
  console.log(`\nRunning @socialgouv/matomo-postgres ${date}\n`);
10
- run(date);
21
+ start(date);
11
22
  }
@@ -61,7 +61,6 @@ jest.mock("piwik-client", () => {
61
61
  api(options, cb) {
62
62
  piwikApiCalls.push(options);
63
63
  cb(null, matomoVisits);
64
- ("");
65
64
  }
66
65
  }
67
66
  return PiwikMock;
@@ -39,13 +39,6 @@ const db_1 = require("./db");
39
39
  const config_1 = require("./config");
40
40
  function migrateToLatest() {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
- const extension = yield db_1.db
43
- .selectFrom("pg_extension")
44
- //@ts-ignore
45
- .select("extname")
46
- //@ts-ignore
47
- .where("extname", "=", "pg_partman")
48
- .executeTakeFirst();
49
42
  const migrator = new kysely_1.Migrator({
50
43
  db: db_1.db,
51
44
  provider: new kysely_1.FileMigrationProvider({
@@ -76,7 +69,15 @@ function migrateToLatest() {
76
69
  console.log("No migration to run");
77
70
  }
78
71
  }
72
+ });
73
+ }
74
+ exports.default = migrateToLatest;
75
+ function start() {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ yield migrateToLatest();
79
78
  yield db_1.db.destroy();
80
79
  });
81
80
  }
82
- migrateToLatest();
81
+ if (require.main === module) {
82
+ start();
83
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@socialgouv/matomo-postgres",
3
3
  "description": "Extract visitor events from Matomo API and push to Postgres",
4
- "version": "2.0.0-beta.1",
4
+ "version": "2.0.0-beta.3",
5
5
  "types": "types/index.d.ts",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/index.js",