repo-util 1.9.5 → 1.10.3
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 +9 -9
- package/src/repo-util-cli.mjs +43 -58
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-util",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,21 +21,21 @@
|
|
|
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": "^
|
|
25
|
-
"bitbucket-repository-provider": "^3.9.
|
|
26
|
-
"commander": "^8.
|
|
27
|
-
"gitea-repository-provider": "^1.16.
|
|
28
|
-
"github-repository-provider": "^7.23.
|
|
29
|
-
"local-repository-provider": "^7.0.
|
|
24
|
+
"aggregation-repository-provider": "^4.0.0",
|
|
25
|
+
"bitbucket-repository-provider": "^3.9.8",
|
|
26
|
+
"commander": "^8.3.0",
|
|
27
|
+
"gitea-repository-provider": "^1.16.33",
|
|
28
|
+
"github-repository-provider": "^7.23.31",
|
|
29
|
+
"local-repository-provider": "^7.0.105"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"ava": "^3.15.0",
|
|
33
33
|
"c8": "^7.10.0",
|
|
34
|
-
"execa": "^
|
|
34
|
+
"execa": "^6.0.0",
|
|
35
35
|
"semantic-release": "^18.0.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=16.
|
|
38
|
+
"node": ">=16.13.0"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
package/src/repo-util-cli.mjs
CHANGED
|
@@ -33,38 +33,37 @@ program
|
|
|
33
33
|
})
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
for (const o of [
|
|
37
|
+
["provider", "providers", ["name"]],
|
|
38
|
+
["repository-group", "repositoryGroups", ["name"]],
|
|
39
|
+
["repository", "repositories", ["name"]],
|
|
40
|
+
["branch", "branches", ["fullName"]]
|
|
41
|
+
]) {
|
|
42
|
+
program
|
|
43
|
+
.command(`${o[0]} <name...>`)
|
|
44
|
+
.option("--json", "output as json")
|
|
45
|
+
.option("-a, --attribute <attributes>", "list attribute", a => a.split(","))
|
|
46
|
+
.action(async (names, options) =>
|
|
47
|
+
list(
|
|
48
|
+
await prepareProvider(options),
|
|
49
|
+
names,
|
|
50
|
+
options,
|
|
51
|
+
o[1],
|
|
52
|
+
options.attribute ? options.attribute : o[2]
|
|
53
|
+
)
|
|
47
54
|
);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
program.command("repository-groups <name...>").action(async name => {
|
|
51
|
-
const provider = await prepareProvider();
|
|
52
|
-
|
|
53
|
-
for await (const group of provider.repositoryGroups(name)) {
|
|
54
|
-
console.log(group.name);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
55
|
+
}
|
|
57
56
|
|
|
58
57
|
program
|
|
59
58
|
.command("hooks <name...>")
|
|
60
59
|
.option("--json", "output as json")
|
|
61
|
-
.action(async (
|
|
60
|
+
.action(async (names, options) => {
|
|
62
61
|
const provider = await prepareProvider();
|
|
63
62
|
|
|
64
63
|
if (options.json) {
|
|
65
64
|
const json = [];
|
|
66
65
|
|
|
67
|
-
for await (const repository of provider.repositories(
|
|
66
|
+
for await (const repository of provider.repositories(names)) {
|
|
68
67
|
const r = { name: repository.fullName, hooks: [] };
|
|
69
68
|
for await (const hook of repository.hooks()) {
|
|
70
69
|
r.hooks.push(hook);
|
|
@@ -76,7 +75,7 @@ program
|
|
|
76
75
|
}
|
|
77
76
|
console.log(JSON.stringify(json));
|
|
78
77
|
} else {
|
|
79
|
-
for await (const repository of provider.repositories(
|
|
78
|
+
for await (const repository of provider.repositories(names)) {
|
|
80
79
|
for await (const hook of repository.hooks()) {
|
|
81
80
|
console.log(repository.fullName);
|
|
82
81
|
console.log(" " + hook.url);
|
|
@@ -85,27 +84,16 @@ program
|
|
|
85
84
|
}
|
|
86
85
|
});
|
|
87
86
|
|
|
88
|
-
program
|
|
89
|
-
.command("branch <name...>")
|
|
90
|
-
.option("--json", "output as json")
|
|
91
|
-
.action(async name => {
|
|
92
|
-
const provider = await prepareProvider();
|
|
93
|
-
|
|
94
|
-
for await (const branch of provider.branches(name)) {
|
|
95
|
-
console.log(branch.fullName);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
87
|
program
|
|
100
88
|
.command("pull-request <name...>")
|
|
101
89
|
.option("--json", "output as json")
|
|
102
90
|
.option("--merge", "merge the pr")
|
|
103
|
-
.action(async (
|
|
91
|
+
.action(async (names, options) => {
|
|
104
92
|
const provider = await prepareProvider();
|
|
105
93
|
|
|
106
94
|
const json = [];
|
|
107
95
|
|
|
108
|
-
for await (const repository of provider.repositories(
|
|
96
|
+
for await (const repository of provider.repositories(names)) {
|
|
109
97
|
if (!repository.isArchived) {
|
|
110
98
|
for await (const pr of repository.pullRequestClass.list(repository)) {
|
|
111
99
|
if (options.json) {
|
|
@@ -126,29 +114,10 @@ program
|
|
|
126
114
|
});
|
|
127
115
|
|
|
128
116
|
program
|
|
129
|
-
.command("repository <name...>")
|
|
130
|
-
.option("--json", "output as json")
|
|
131
|
-
.action(async (name, options) => {
|
|
132
|
-
const provider = await prepareProvider();
|
|
133
|
-
|
|
134
|
-
if (options.json) {
|
|
135
|
-
const json = [];
|
|
136
|
-
for await (const repository of provider.repositories(name)) {
|
|
137
|
-
json.push(repository);
|
|
138
|
-
}
|
|
139
|
-
console.log(JSON.stringify(json));
|
|
140
|
-
} else {
|
|
141
|
-
for await (const repository of provider.repositories(name)) {
|
|
142
|
-
console.log(repository.name);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
program
|
|
148
|
-
.command("update-repository <names...>")
|
|
117
|
+
.command("update-repository <name...>")
|
|
149
118
|
.action(async (names, options) => {
|
|
150
119
|
const provider = await prepareProvider();
|
|
151
|
-
for await (const repository of provider.repositories(
|
|
120
|
+
for await (const repository of provider.repositories(names)) {
|
|
152
121
|
for (const [k, v] of Object.entries(properties)) {
|
|
153
122
|
repository[k] = v;
|
|
154
123
|
}
|
|
@@ -157,7 +126,7 @@ program
|
|
|
157
126
|
});
|
|
158
127
|
|
|
159
128
|
program
|
|
160
|
-
.command("create-repository <
|
|
129
|
+
.command("create-repository <name...>")
|
|
161
130
|
.action(async (names, options) => {
|
|
162
131
|
const provider = await prepareProvider();
|
|
163
132
|
for (const name of names) {
|
|
@@ -166,3 +135,19 @@ program
|
|
|
166
135
|
});
|
|
167
136
|
|
|
168
137
|
program.parse(process.argv);
|
|
138
|
+
|
|
139
|
+
async function list(provider, name, options, slot, attributes) {
|
|
140
|
+
if (options.json) {
|
|
141
|
+
const json = [];
|
|
142
|
+
for await (const object of provider[slot](name)) {
|
|
143
|
+
json.push(object);
|
|
144
|
+
}
|
|
145
|
+
console.log(JSON.stringify(json));
|
|
146
|
+
} else {
|
|
147
|
+
for await (const object of provider[slot](name)) {
|
|
148
|
+
for (const a of attributes) {
|
|
149
|
+
console.log(object[a]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|