@socialgouv/matomo-postgres 2.2.0-beta.1 → 2.2.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
@@ -2,21 +2,19 @@
2
2
 
3
3
  import { db } from '../dist/db.js'
4
4
  import run from '../dist/index.js'
5
- import migrate from '../dist/migrate-latest.js'
5
+ import { startMigration } from '../dist/migrate-latest.js'
6
6
 
7
7
  async function start(date) {
8
8
  console.log(`\nRunning migrations\n`)
9
- await migrate()
9
+ await startMigration()
10
10
  console.log(`\nStarting import\n`)
11
11
  await run(date)
12
12
  db.destroy()
13
13
  }
14
14
 
15
- if (import.meta.url === `file://${process.argv[1]}`) {
16
- const date =
17
- (process.argv[process.argv.length - 1].match(/^\d\d\d\d-\d\d-\d\d$/) &&
18
- process.argv[process.argv.length - 1]) ||
19
- ''
20
- console.log(`\nRunning @socialgouv/matomo-postgres ${date}\n`)
21
- start(date)
22
- }
15
+ const date =
16
+ (process.argv[process.argv.length - 1].match(/^\d\d\d\d-\d\d-\d\d$/) &&
17
+ process.argv[process.argv.length - 1]) ||
18
+ ''
19
+ console.log(`\nRunning @socialgouv/matomo-postgres ${date}\n`)
20
+ start(date)
package/dist/index.js CHANGED
@@ -78,21 +78,6 @@ function run(date) {
78
78
  return res;
79
79
  });
80
80
  }
81
- export default run;
82
- if (import.meta.url === `file://${process.argv[1]}`) {
83
- ;
84
- (() => __awaiter(void 0, void 0, void 0, function* () {
85
- if (!MATOMO_SITE)
86
- return console.error('Missing env MATOMO_SITE');
87
- if (!MATOMO_KEY)
88
- return console.error('Missing env MATOMO_KEY');
89
- if (!PGDATABASE)
90
- return console.error('Missing env PGDATABASE');
91
- yield run();
92
- debug('run finished');
93
- db.destroy();
94
- }))();
95
- }
96
81
  function findLastEventInMatomo(db) {
97
82
  return __awaiter(this, void 0, void 0, function* () {
98
83
  const latest = yield db
@@ -109,3 +94,15 @@ function findLastEventInMatomo(db) {
109
94
  return null;
110
95
  });
111
96
  }
97
+ export default run;
98
+ (() => __awaiter(void 0, void 0, void 0, function* () {
99
+ if (!MATOMO_SITE)
100
+ return console.error('Missing env MATOMO_SITE');
101
+ if (!MATOMO_KEY)
102
+ return console.error('Missing env MATOMO_KEY');
103
+ if (!PGDATABASE)
104
+ return console.error('Missing env PGDATABASE');
105
+ yield run();
106
+ debug('run finished');
107
+ db.destroy();
108
+ }))();
@@ -50,12 +50,9 @@ function migrateToLatest() {
50
50
  });
51
51
  }
52
52
  export default migrateToLatest;
53
- function start() {
53
+ export function startMigration() {
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
55
  yield migrateToLatest();
56
56
  yield db.destroy();
57
57
  });
58
58
  }
59
- if (import.meta.url === `file://${process.argv[1]}`) {
60
- start();
61
- }
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.2.0-beta.1",
4
+ "version": "2.2.0-beta.3",
5
5
  "types": "types/index.d.ts",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/index.js",