repo-util 1.24.53 → 1.24.55
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 +4 -4
- package/src/repo-util-cli.mjs +11 -45
- package/src/setup-provider.mjs +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-util",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.55",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 2m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"aggregation-repository-provider": "^5.3.
|
|
24
|
+
"aggregation-repository-provider": "^5.3.6",
|
|
25
25
|
"bitbucket-repository-provider": "^4.4.13",
|
|
26
26
|
"commander": "^9.4.1",
|
|
27
27
|
"etag-cache-leveldb": "^1.4.0",
|
|
28
|
-
"gitea-repository-provider": "^2.4.
|
|
29
|
-
"github-repository-provider": "^7.33.
|
|
28
|
+
"gitea-repository-provider": "^2.4.9",
|
|
29
|
+
"github-repository-provider": "^7.33.11",
|
|
30
30
|
"leveldown": "^6.1.1",
|
|
31
31
|
"levelup": "^5.1.1",
|
|
32
32
|
"local-repository-provider": "^8.1.3"
|
package/src/repo-util-cli.mjs
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { mkdir } from "node:fs/promises";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { homedir } from "node:os";
|
|
6
3
|
import { program } from "commander";
|
|
7
|
-
import levelup from "levelup";
|
|
8
|
-
import leveldown from "leveldown";
|
|
9
4
|
import {
|
|
10
5
|
Repository,
|
|
11
6
|
RepositoryGroup,
|
|
@@ -18,9 +13,8 @@ import {
|
|
|
18
13
|
PullRequest,
|
|
19
14
|
MultiGroupProvider
|
|
20
15
|
} from "repository-provider";
|
|
21
|
-
import AggregationProvider from "aggregation-repository-provider";
|
|
22
|
-
import { ETagCacheLevelDB } from "etag-cache-leveldb";
|
|
23
16
|
import pkg from "../package.json" assert { type: "json" };
|
|
17
|
+
import { initializeRepositoryProvider } from "./setup-provider.mjs";
|
|
24
18
|
|
|
25
19
|
process.on("uncaughtException", console.error);
|
|
26
20
|
process.on("unhandledRejection", console.error);
|
|
@@ -34,6 +28,8 @@ program
|
|
|
34
28
|
Object.assign(properties, Object.fromEntries([str.split(/=/)]))
|
|
35
29
|
);
|
|
36
30
|
|
|
31
|
+
const { provider } = await initializeRepositoryProvider(program);
|
|
32
|
+
|
|
37
33
|
for (const o of [
|
|
38
34
|
type(MultiGroupProvider),
|
|
39
35
|
type(RepositoryGroup),
|
|
@@ -84,14 +80,18 @@ for (const o of [
|
|
|
84
80
|
.option("--no-cache", "cache requests")
|
|
85
81
|
.option("--statistics", "show cache statistics")
|
|
86
82
|
.option("--json", "output as json")
|
|
87
|
-
.option(
|
|
83
|
+
.option(
|
|
84
|
+
"--no-identifier",
|
|
85
|
+
"do not output identifier, show attribute values only"
|
|
86
|
+
)
|
|
88
87
|
.option("--no-undefined", "do not output undefined attribute values")
|
|
89
88
|
.option("-a, --attribute <attributes>", "list attribute", a =>
|
|
90
89
|
a.split(",")
|
|
91
90
|
);
|
|
91
|
+
|
|
92
92
|
command.action(async (names, options) =>
|
|
93
93
|
list(
|
|
94
|
-
|
|
94
|
+
provider,
|
|
95
95
|
names,
|
|
96
96
|
options,
|
|
97
97
|
o[1],
|
|
@@ -110,11 +110,7 @@ for (const o of [
|
|
|
110
110
|
);
|
|
111
111
|
|
|
112
112
|
command.action(async (names, options) => {
|
|
113
|
-
await actionOptions.execute(
|
|
114
|
-
await prepareProvider(options),
|
|
115
|
-
names,
|
|
116
|
-
options
|
|
117
|
-
);
|
|
113
|
+
await actionOptions.execute(provider, names, options);
|
|
118
114
|
});
|
|
119
115
|
}
|
|
120
116
|
if (actionOptions.executeInstance) {
|
|
@@ -141,8 +137,7 @@ function listAttributes(object, attributes, options) {
|
|
|
141
137
|
} else if (value instanceof Set) {
|
|
142
138
|
value = [...value].join(" ");
|
|
143
139
|
} else if (value === undefined) {
|
|
144
|
-
if(options["undefined"])
|
|
145
|
-
value = "";
|
|
140
|
+
if (options["undefined"]) value = "";
|
|
146
141
|
}
|
|
147
142
|
|
|
148
143
|
if (a.length > maxKeyLength) {
|
|
@@ -192,35 +187,6 @@ async function list(provider, names, options, slot, attributes, actions) {
|
|
|
192
187
|
}
|
|
193
188
|
}
|
|
194
189
|
|
|
195
|
-
async function createCache() {
|
|
196
|
-
const dir = join(homedir(), ".cache/repository-provider");
|
|
197
|
-
await mkdir(dir, { recursive: true });
|
|
198
|
-
const db = await levelup(leveldown(dir));
|
|
199
|
-
return new ETagCacheLevelDB(db);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
async function prepareProvider(options) {
|
|
203
|
-
const provider = await AggregationProvider.initialize(
|
|
204
|
-
[],
|
|
205
|
-
properties,
|
|
206
|
-
process.env
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
if (options.cache) {
|
|
210
|
-
const cache = await createCache();
|
|
211
|
-
provider._providers.forEach(p => (p.cache = cache));
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
provider.messageDestination = {
|
|
215
|
-
trace: options.trace ? console.log : () => {},
|
|
216
|
-
info: console.log,
|
|
217
|
-
warn: console.warn,
|
|
218
|
-
error: console.error
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
return provider;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
190
|
function visibleAttributes(object) {
|
|
225
191
|
return Object.fromEntries(
|
|
226
192
|
Object.entries(object.attributes).filter(
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import AggregationProvider from "aggregation-repository-provider";
|
|
2
|
+
import { ETagCacheLevelDB } from "etag-cache-leveldb";
|
|
3
|
+
import levelup from "levelup";
|
|
4
|
+
import leveldown from "leveldown";
|
|
5
|
+
import { mkdir } from "node:fs/promises";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
|
|
9
|
+
async function createCache() {
|
|
10
|
+
const dir = join(homedir(), ".cache/repository-provider");
|
|
11
|
+
await mkdir(dir, { recursive: true });
|
|
12
|
+
const db = await levelup(leveldown(dir));
|
|
13
|
+
return new ETagCacheLevelDB(db);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function initializeRepositoryProvider(program, properties) {
|
|
17
|
+
const provider = await AggregationProvider.initialize(
|
|
18
|
+
[],
|
|
19
|
+
properties,
|
|
20
|
+
process.env
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const options = program.opts();
|
|
24
|
+
|
|
25
|
+
provider.messageDestination = {
|
|
26
|
+
trace: options.trace ? console.log : () => {},
|
|
27
|
+
info: console.log,
|
|
28
|
+
warn: console.warn,
|
|
29
|
+
error: console.error
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (options.cache) {
|
|
33
|
+
const cache = await createCache();
|
|
34
|
+
provider._providers.forEach(p => (p.cache = cache));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return { provider, options };
|
|
38
|
+
}
|