repository-provider-cli-support 2.1.4 → 2.2.1
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 +15 -14
- package/src/setup-provider.mjs +24 -7
- package/types/setup-provider.d.mts +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repository-provider-cli-support",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -24,33 +24,34 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "BSD-2-Clause",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"prepare": "
|
|
27
|
+
"prepare": "npm run prepare:typescript",
|
|
28
|
+
"prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
|
|
28
29
|
"test": "npm run test:ava",
|
|
29
30
|
"test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
|
|
30
31
|
"cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
|
|
31
32
|
"docs": "documentation readme --section=API ./src/**/*.mjs",
|
|
32
|
-
"lint": "npm run lint:docs && npm run lint:
|
|
33
|
+
"lint": "npm run lint:docs && npm run lint:typescript",
|
|
33
34
|
"lint:docs": "documentation lint ./src/**/*.mjs",
|
|
34
|
-
"lint:
|
|
35
|
+
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"aggregation-repository-provider": "^
|
|
38
|
-
"etag-cache-leveldb": "^2.1.
|
|
38
|
+
"aggregation-repository-provider": "^7.0.0",
|
|
39
|
+
"etag-cache-leveldb": "^2.1.2",
|
|
39
40
|
"leveldown": "^6.1.1",
|
|
40
41
|
"levelup": "^5.1.1"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^20.
|
|
44
|
-
"ava": "^6.1.
|
|
45
|
-
"c8": "^
|
|
46
|
-
"commander": "^12.
|
|
44
|
+
"@types/node": "^20.14.2",
|
|
45
|
+
"ava": "^6.1.3",
|
|
46
|
+
"c8": "^10.0.0",
|
|
47
|
+
"commander": "^12.1.0",
|
|
47
48
|
"documentation": "^14.0.3",
|
|
48
|
-
"github-repository-provider": "^9.0.
|
|
49
|
-
"semantic-release": "^
|
|
50
|
-
"typescript": "^5.
|
|
49
|
+
"github-repository-provider": "^9.0.17",
|
|
50
|
+
"semantic-release": "^24.0.0",
|
|
51
|
+
"typescript": "^5.4.5"
|
|
51
52
|
},
|
|
52
53
|
"engines": {
|
|
53
|
-
"node": ">=20.
|
|
54
|
+
"node": ">=20.12.2"
|
|
54
55
|
},
|
|
55
56
|
"repository": {
|
|
56
57
|
"type": "git",
|
package/src/setup-provider.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import AggregationProvider from "aggregation-repository-provider";
|
|
|
2
2
|
import { ETagCacheLevelDB } from "etag-cache-leveldb";
|
|
3
3
|
import levelup from "levelup";
|
|
4
4
|
import leveldown from "leveldown";
|
|
5
|
-
import { mkdir } from "node:fs/promises";
|
|
5
|
+
import { mkdir, readFile } from "node:fs/promises";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { Agent } from "node:https";
|
|
@@ -20,13 +20,13 @@ async function createCache() {
|
|
|
20
20
|
const httpsAgent = new Agent({ keepAlive: true });
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {*} program
|
|
25
|
-
* @param {Object} properties
|
|
26
|
-
* @returns {Promise<
|
|
23
|
+
*
|
|
24
|
+
* @param {*} program
|
|
25
|
+
* @param {Object} properties
|
|
26
|
+
* @returns {Promise<{provider: AggregationProvider, options: Object, cache: ETagCacheLevelDB|undefined}>}
|
|
27
27
|
*/
|
|
28
28
|
export async function initializeRepositoryProvider(program, properties) {
|
|
29
|
-
const provider = await AggregationProvider.
|
|
29
|
+
const provider = await AggregationProvider.initializeWithProviders(
|
|
30
30
|
[],
|
|
31
31
|
properties,
|
|
32
32
|
process.env
|
|
@@ -34,6 +34,7 @@ export async function initializeRepositoryProvider(program, properties) {
|
|
|
34
34
|
|
|
35
35
|
const options = program.opts();
|
|
36
36
|
|
|
37
|
+
// @ts-ignore
|
|
37
38
|
provider.messageDestination = {
|
|
38
39
|
...console,
|
|
39
40
|
trace: options.trace ? console.log : () => {}
|
|
@@ -52,10 +53,26 @@ export async function initializeRepositoryProvider(program, properties) {
|
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
* Add extra cli options.
|
|
55
|
-
* @param {*} program
|
|
56
|
+
* @param {*} program
|
|
56
57
|
*/
|
|
57
58
|
export function initializeCommandLine(program) {
|
|
58
59
|
program
|
|
59
60
|
.option("--no-cache", "cache requests")
|
|
60
61
|
.option("--statistics", "show cache statistics");
|
|
61
62
|
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Retrieve repository url from a directory.
|
|
66
|
+
* @param {string} dir
|
|
67
|
+
* @returns {string?}
|
|
68
|
+
*/
|
|
69
|
+
export async function repositoryUrl(dir) {
|
|
70
|
+
const cfg = await readFile(join(dir, ".git", "config"), "utf8");
|
|
71
|
+
for (const line of cfg.split(/\n/)) {
|
|
72
|
+
let m;
|
|
73
|
+
|
|
74
|
+
if ((m = line.match(/^\s*url\s*=\s*(.*)/))) {
|
|
75
|
+
return m[1];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
*
|
|
3
3
|
* @param {*} program
|
|
4
4
|
* @param {Object} properties
|
|
5
|
-
* @returns {Promise<
|
|
5
|
+
* @returns {Promise<{provider: AggregationProvider, options: Object, cache: ETagCacheLevelDB|undefined}>}
|
|
6
6
|
*/
|
|
7
|
-
export function initializeRepositoryProvider(program: any, properties: any): Promise<
|
|
7
|
+
export function initializeRepositoryProvider(program: any, properties: any): Promise<{
|
|
8
|
+
provider: AggregationProvider;
|
|
9
|
+
options: any;
|
|
10
|
+
cache: ETagCacheLevelDB | undefined;
|
|
11
|
+
}>;
|
|
8
12
|
/**
|
|
9
13
|
* Add extra cli options.
|
|
10
14
|
* @param {*} program
|
|
11
15
|
*/
|
|
12
16
|
export function initializeCommandLine(program: any): void;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieve repository url from a directory.
|
|
19
|
+
* @param {string} dir
|
|
20
|
+
* @returns {string?}
|
|
21
|
+
*/
|
|
22
|
+
export function repositoryUrl(dir: string): string | null;
|
|
23
|
+
import AggregationProvider from "aggregation-repository-provider";
|
|
24
|
+
import { ETagCacheLevelDB } from "etag-cache-leveldb";
|