@renovatebot/osv-offline 1.7.10 → 1.8.0
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/dist/lib/download.js +8 -0
- package/dist/lib/osv-offline.js +7 -0
- package/package.json +4 -2
package/dist/lib/download.js
CHANGED
|
@@ -12,9 +12,12 @@ const path_1 = __importDefault(require("path"));
|
|
|
12
12
|
const luxon_1 = require("luxon");
|
|
13
13
|
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
14
14
|
const types_1 = require("./types");
|
|
15
|
+
const debug_1 = __importDefault(require("debug"));
|
|
16
|
+
const logger = (0, debug_1.default)('osv-offline:download');
|
|
15
17
|
async function tryDownloadDb() {
|
|
16
18
|
await fs_extra_1.default.ensureDir(osv_offline_db_1.OsvOfflineDb.rootDirectory);
|
|
17
19
|
if (process.env.OSV_OFFLINE_DISABLE_DOWNLOAD?.toLowerCase() === 'true') {
|
|
20
|
+
logger('Skipping database download.');
|
|
18
21
|
return (0, types_1.success)();
|
|
19
22
|
}
|
|
20
23
|
// if local database exists and is less than a day old, don't do any network requests
|
|
@@ -27,16 +30,21 @@ async function tryDownloadDb() {
|
|
|
27
30
|
}
|
|
28
31
|
if (stats !== undefined &&
|
|
29
32
|
luxon_1.DateTime.utc().diff(luxon_1.DateTime.fromJSDate(stats.mtime)).as('days') < 1) {
|
|
33
|
+
logger('Skipping download, databases are up-to-date.');
|
|
30
34
|
return (0, types_1.success)();
|
|
31
35
|
}
|
|
32
36
|
// only download databases if local databases are missing or remote is newer
|
|
33
37
|
try {
|
|
38
|
+
logger('Downloading databases ...');
|
|
34
39
|
const stream = got_1.default.stream('https://github.com/renovatebot/osv-offline/releases/latest/download/osv-offline.zip');
|
|
35
40
|
const zipPath = path_1.default.join(osv_offline_db_1.OsvOfflineDb.rootDirectory, 'osv-offline.zip');
|
|
36
41
|
const writeStream = fs_extra_1.default.createWriteStream(zipPath);
|
|
37
42
|
await (0, promises_1.pipeline)(stream, writeStream);
|
|
43
|
+
logger('Downloading databases done.');
|
|
44
|
+
logger('Extracting databases ...');
|
|
38
45
|
const zip = new adm_zip_1.default(zipPath);
|
|
39
46
|
zip.extractAllTo(osv_offline_db_1.OsvOfflineDb.rootDirectory);
|
|
47
|
+
logger('Extracting databases done.');
|
|
40
48
|
}
|
|
41
49
|
catch (err) {
|
|
42
50
|
return (0, types_1.failure)(err);
|
package/dist/lib/osv-offline.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.OsvOffline = void 0;
|
|
4
7
|
const osv_offline_db_1 = require("@renovatebot/osv-offline-db");
|
|
5
8
|
const download_1 = require("./download");
|
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
|
10
|
+
const logger = (0, debug_1.default)('osv-offline:download');
|
|
6
11
|
class OsvOffline {
|
|
7
12
|
osvOfflineDb;
|
|
8
13
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -15,7 +20,9 @@ class OsvOffline {
|
|
|
15
20
|
if (!result.success) {
|
|
16
21
|
throw result.error;
|
|
17
22
|
}
|
|
23
|
+
logger('Initializing databases ...');
|
|
18
24
|
this.osvOfflineDb = await osv_offline_db_1.OsvOfflineDb.create();
|
|
25
|
+
logger('Initializing databases done.');
|
|
19
26
|
}
|
|
20
27
|
/**
|
|
21
28
|
* Asynchronously creates a new instance of {@link OsvOffline}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renovatebot/osv-offline",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,13 +14,15 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"adm-zip": "~0.5.16",
|
|
17
|
+
"debug": "^4.4.3",
|
|
17
18
|
"fs-extra": "^11.3.2",
|
|
18
19
|
"got": "^11.8.6",
|
|
19
20
|
"luxon": "^3.7.2",
|
|
20
|
-
"@renovatebot/osv-offline-db": "1.
|
|
21
|
+
"@renovatebot/osv-offline-db": "1.8.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@types/adm-zip": "0.5.7",
|
|
25
|
+
"@types/debug": "4.1.12",
|
|
24
26
|
"@types/fs-extra": "11.0.4",
|
|
25
27
|
"@types/luxon": "3.7.1",
|
|
26
28
|
"@types/node": "18.19.130"
|