repo-util 1.22.8 → 1.23.2
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 +6 -6
- package/src/repo-util-cli.mjs +42 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-util",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.2",
|
|
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/*.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"aggregation-repository-provider": "^5.2.
|
|
24
|
+
"aggregation-repository-provider": "^5.2.36",
|
|
25
25
|
"bitbucket-repository-provider": "^4.2.10",
|
|
26
26
|
"commander": "^9.3.0",
|
|
27
|
-
"etag-cache-leveldb": "^1.1
|
|
28
|
-
"gitea-repository-provider": "^2.2.
|
|
29
|
-
"github-repository-provider": "^7.30.
|
|
27
|
+
"etag-cache-leveldb": "^1.2.1",
|
|
28
|
+
"gitea-repository-provider": "^2.2.11",
|
|
29
|
+
"github-repository-provider": "^7.30.12",
|
|
30
30
|
"leveldown": "^6.1.1",
|
|
31
31
|
"levelup": "^5.1.1",
|
|
32
32
|
"local-repository-provider": "^8.0.12"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"semantic-release": "^19.0.3"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
41
|
+
"node": ">=18.3.0"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|
package/src/repo-util-cli.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
3
|
import { mkdir } from "node:fs/promises";
|
|
5
4
|
import { join } from "node:path";
|
|
6
5
|
import { homedir } from "node:os";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
6
|
import { program } from "commander";
|
|
9
7
|
import levelup from "levelup";
|
|
10
8
|
import leveldown from "leveldown";
|
|
@@ -22,21 +20,16 @@ import {
|
|
|
22
20
|
} from "repository-provider";
|
|
23
21
|
import AggregationProvider from "aggregation-repository-provider";
|
|
24
22
|
import { ETagCacheLevelDB } from "etag-cache-leveldb";
|
|
23
|
+
import pkg from "../package.json" assert { type: "json" };
|
|
25
24
|
|
|
26
25
|
process.on("uncaughtException", console.error);
|
|
27
26
|
process.on("unhandledRejection", console.error);
|
|
28
27
|
|
|
29
|
-
const { version, description } = JSON.parse(
|
|
30
|
-
readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), {
|
|
31
|
-
encoding: "utf8"
|
|
32
|
-
})
|
|
33
|
-
);
|
|
34
|
-
|
|
35
28
|
const properties = {};
|
|
36
29
|
|
|
37
30
|
program
|
|
38
|
-
.description(description)
|
|
39
|
-
.version(version)
|
|
31
|
+
.description(pkg.description)
|
|
32
|
+
.version(pkg.version)
|
|
40
33
|
.option("-D --define <a=b>", "define property", str =>
|
|
41
34
|
Object.assign(properties, Object.fromEntries([str.split(/=/)]))
|
|
42
35
|
);
|
|
@@ -88,7 +81,8 @@ for (const o of [
|
|
|
88
81
|
command
|
|
89
82
|
.option("--trace", "log level trace")
|
|
90
83
|
.option("--debug", "log level debug")
|
|
91
|
-
.option("--cache", "cache requests")
|
|
84
|
+
.option("--no-cache", "cache requests")
|
|
85
|
+
.option("--statistics", "cache statistics")
|
|
92
86
|
.option("--json", "output as json")
|
|
93
87
|
.option("--no-identifier", "do not output identifier, show attributes only")
|
|
94
88
|
.option("-a, --attribute <attributes>", "list attribute", a =>
|
|
@@ -135,6 +129,36 @@ function normalize(names) {
|
|
|
135
129
|
return names.length === 0 ? ["*"] : names;
|
|
136
130
|
}
|
|
137
131
|
|
|
132
|
+
function listAttributes(object, attributes, options) {
|
|
133
|
+
const values = {};
|
|
134
|
+
let maxKeyLength = 0;
|
|
135
|
+
|
|
136
|
+
for (const a of attributes) {
|
|
137
|
+
let value = object[a];
|
|
138
|
+
if (Array.isArray(value)) {
|
|
139
|
+
value = value.join(" ");
|
|
140
|
+
} else if (value instanceof Set) {
|
|
141
|
+
value = [...value].join(" ");
|
|
142
|
+
} else if (value === undefined) {
|
|
143
|
+
value = "";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (a.length > maxKeyLength) {
|
|
147
|
+
maxKeyLength = a.length;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
values[a] = value;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
for (const [k, v] of Object.entries(values)) {
|
|
154
|
+
if (options.identifier) {
|
|
155
|
+
console.log(" ".repeat(maxKeyLength - k.length + 2) + k + `: ${v}`);
|
|
156
|
+
} else {
|
|
157
|
+
console.log(v);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
138
162
|
async function list(provider, names, options, slot, attributes, actions) {
|
|
139
163
|
const json = [];
|
|
140
164
|
|
|
@@ -150,33 +174,20 @@ async function list(provider, names, options, slot, attributes, actions) {
|
|
|
150
174
|
if (options.json) {
|
|
151
175
|
json.push(object);
|
|
152
176
|
} else {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (Array.isArray(value)) {
|
|
156
|
-
value = value.join(" ");
|
|
157
|
-
} else if (value instanceof Set) {
|
|
158
|
-
value = [...value].join(" ");
|
|
159
|
-
} else if (value === undefined) {
|
|
160
|
-
value = "";
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (options.identifier === false) {
|
|
164
|
-
console.log(value);
|
|
165
|
-
} else {
|
|
166
|
-
console.log(
|
|
167
|
-
attributes.indexOf(a) === 0
|
|
168
|
-
? object.fullName + ":"
|
|
169
|
-
: " ".substring(a.length) + a + ":",
|
|
170
|
-
value
|
|
171
|
-
);
|
|
172
|
-
}
|
|
177
|
+
if (options.identifier) {
|
|
178
|
+
console.log(`${object.fullName}:`);
|
|
173
179
|
}
|
|
180
|
+
listAttributes(object, attributes, options);
|
|
174
181
|
}
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
if (options.json) {
|
|
178
185
|
console.log(JSON.stringify(json));
|
|
179
186
|
}
|
|
187
|
+
|
|
188
|
+
if (options.statistics) {
|
|
189
|
+
console.error(provider._providers[0].cache.statistics);
|
|
190
|
+
}
|
|
180
191
|
}
|
|
181
192
|
|
|
182
193
|
async function createCache() {
|