repo-util 1.23.1 → 1.24.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 +2 -2
- package/src/repo-util-cli.mjs +36 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-util",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,7 +24,7 @@
|
|
|
24
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.2.
|
|
27
|
+
"etag-cache-leveldb": "^1.2.2",
|
|
28
28
|
"gitea-repository-provider": "^2.2.11",
|
|
29
29
|
"github-repository-provider": "^7.30.12",
|
|
30
30
|
"leveldown": "^6.1.1",
|
package/src/repo-util-cli.mjs
CHANGED
|
@@ -84,7 +84,8 @@ for (const o of [
|
|
|
84
84
|
.option("--no-cache", "cache requests")
|
|
85
85
|
.option("--statistics", "cache statistics")
|
|
86
86
|
.option("--json", "output as json")
|
|
87
|
-
.option("--no-identifier", "do not output identifier, show
|
|
87
|
+
.option("--no-identifier", "do not output identifier, show attribute values only")
|
|
88
|
+
.option("--no-undefined", "do not output undefined attribute values")
|
|
88
89
|
.option("-a, --attribute <attributes>", "list attribute", a =>
|
|
89
90
|
a.split(",")
|
|
90
91
|
);
|
|
@@ -129,6 +130,37 @@ function normalize(names) {
|
|
|
129
130
|
return names.length === 0 ? ["*"] : names;
|
|
130
131
|
}
|
|
131
132
|
|
|
133
|
+
function listAttributes(object, attributes, options) {
|
|
134
|
+
const values = {};
|
|
135
|
+
let maxKeyLength = 0;
|
|
136
|
+
|
|
137
|
+
for (const a of attributes) {
|
|
138
|
+
let value = object[a];
|
|
139
|
+
if (Array.isArray(value)) {
|
|
140
|
+
value = value.join(" ");
|
|
141
|
+
} else if (value instanceof Set) {
|
|
142
|
+
value = [...value].join(" ");
|
|
143
|
+
} else if (value === undefined) {
|
|
144
|
+
if(options["undefined"])
|
|
145
|
+
value = "";
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (a.length > maxKeyLength) {
|
|
149
|
+
maxKeyLength = a.length;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
values[a] = value;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
for (const [k, v] of Object.entries(values)) {
|
|
156
|
+
if (options.identifier) {
|
|
157
|
+
console.log(" ".repeat(maxKeyLength - k.length + 2) + k + `: ${v}`);
|
|
158
|
+
} else {
|
|
159
|
+
console.log(v);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
132
164
|
async function list(provider, names, options, slot, attributes, actions) {
|
|
133
165
|
const json = [];
|
|
134
166
|
|
|
@@ -144,27 +176,10 @@ async function list(provider, names, options, slot, attributes, actions) {
|
|
|
144
176
|
if (options.json) {
|
|
145
177
|
json.push(object);
|
|
146
178
|
} else {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (Array.isArray(value)) {
|
|
150
|
-
value = value.join(" ");
|
|
151
|
-
} else if (value instanceof Set) {
|
|
152
|
-
value = [...value].join(" ");
|
|
153
|
-
} else if (value === undefined) {
|
|
154
|
-
value = "";
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (options.identifier === false) {
|
|
158
|
-
console.log(value);
|
|
159
|
-
} else {
|
|
160
|
-
console.log(
|
|
161
|
-
attributes.indexOf(a) === 0
|
|
162
|
-
? object.fullName + ":"
|
|
163
|
-
: " ".substring(a.length) + a + ":",
|
|
164
|
-
value
|
|
165
|
-
);
|
|
166
|
-
}
|
|
179
|
+
if (options.identifier) {
|
|
180
|
+
console.log(`${object.fullName}:`);
|
|
167
181
|
}
|
|
182
|
+
listAttributes(object, attributes, options);
|
|
168
183
|
}
|
|
169
184
|
}
|
|
170
185
|
|