repo-util 1.20.1 → 1.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repo-util",
3
- "version": "1.20.1",
3
+ "version": "1.22.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,21 +21,24 @@
21
21
  "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 2m tests/*.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp"
22
22
  },
23
23
  "dependencies": {
24
- "aggregation-repository-provider": "^5.2.28",
25
- "bitbucket-repository-provider": "^4.1.26",
26
- "commander": "^9.2.0",
27
- "gitea-repository-provider": "^2.1.60",
28
- "github-repository-provider": "^7.29.6",
24
+ "aggregation-repository-provider": "^5.2.34",
25
+ "bitbucket-repository-provider": "^4.2.7",
26
+ "commander": "^9.3.0",
27
+ "etag-cache-leveldb": "^1.0.8",
28
+ "gitea-repository-provider": "^2.2.5",
29
+ "github-repository-provider": "^7.30.7",
30
+ "leveldown": "^6.1.1",
31
+ "levelup": "^5.1.1",
29
32
  "local-repository-provider": "^8.0.11"
30
33
  },
31
34
  "devDependencies": {
32
- "ava": "^4.2.0",
35
+ "ava": "^4.3.0",
33
36
  "c8": "^7.11.3",
34
37
  "execa": "^6.1.0",
35
38
  "semantic-release": "^19.0.2"
36
39
  },
37
40
  "engines": {
38
- "node": ">=16.15.0"
41
+ "node": ">=16.15.1"
39
42
  },
40
43
  "repository": {
41
44
  "type": "git",
@@ -1,8 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { readFileSync } from "fs";
4
+ import { mkdir } from "fs/promises";
5
+ import { join } from "path";
6
+ import { homedir } from "os";
4
7
  import { fileURLToPath } from "url";
5
8
  import { program } from "commander";
9
+ import levelup from "levelup";
10
+ import leveldown from "leveldown";
6
11
  import {
7
12
  Repository,
8
13
  RepositoryGroup,
@@ -16,6 +21,7 @@ import {
16
21
  MultiGroupProvider
17
22
  } from "repository-provider";
18
23
  import AggregationProvider from "aggregation-repository-provider";
24
+ import { ETagCacheLevelDB } from "etag-cache-leveldb";
19
25
 
20
26
  process.on("uncaughtException", console.error);
21
27
  process.on("unhandledRejection", console.error);
@@ -33,6 +39,7 @@ program
33
39
  .version(version)
34
40
  .option("--trace", "log level trace")
35
41
  .option("--debug", "log level debug")
42
+ .option("--cache", "cache requests")
36
43
  .option("-D --define <a=b>", "define property", str =>
37
44
  Object.assign(properties, Object.fromEntries([str.split(/=/)]))
38
45
  );
@@ -172,6 +179,13 @@ async function list(provider, names, options, slot, attributes, actions) {
172
179
  }
173
180
  }
174
181
 
182
+ async function createCache() {
183
+ const dir = join(homedir(), ".cache/repository-provider");
184
+ await mkdir(dir, { recursive: true });
185
+ const db = await levelup(leveldown(dir));
186
+ return new ETagCacheLevelDB(db);
187
+ }
188
+
175
189
  async function prepareProvider(options) {
176
190
  const provider = await AggregationProvider.initialize(
177
191
  [],
@@ -179,6 +193,11 @@ async function prepareProvider(options) {
179
193
  process.env
180
194
  );
181
195
 
196
+ if (options.cache) {
197
+ const cache = await createCache();
198
+ provider._providers.forEach(p => (p.cache = cache));
199
+ }
200
+
182
201
  provider.messageDestination = {
183
202
  trace: () => {},
184
203
  info: () => {},