repo-util 1.9.6 → 1.10.4
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 +45 -85
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-util",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.4",
|
|
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.1",
|
|
25
|
+
"bitbucket-repository-provider": "^3.9.9",
|
|
26
|
+
"commander": "^8.3.0",
|
|
27
|
+
"gitea-repository-provider": "^1.16.34",
|
|
28
|
+
"github-repository-provider": "^7.23.32",
|
|
29
|
+
"local-repository-provider": "^7.0.106"
|
|
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,79 +33,38 @@ 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", ["fullName"]],
|
|
40
|
+
["branch", "branches", ["fullName"]],
|
|
41
|
+
["hook", "hooks", ["url"]]
|
|
42
|
+
]) {
|
|
43
|
+
program
|
|
44
|
+
.command(`${o[0]} <name...>`)
|
|
45
|
+
.option("--json", "output as json")
|
|
46
|
+
.option("-a, --attribute <attributes>", "list attribute", a => a.split(","))
|
|
47
|
+
.action(async (names, options) =>
|
|
48
|
+
list(
|
|
49
|
+
await prepareProvider(options),
|
|
50
|
+
names,
|
|
51
|
+
options,
|
|
52
|
+
o[1],
|
|
53
|
+
options.attribute ? options.attribute : o[2]
|
|
54
|
+
)
|
|
47
55
|
);
|
|
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
|
-
});
|
|
57
|
-
|
|
58
|
-
program
|
|
59
|
-
.command("hooks <name...>")
|
|
60
|
-
.option("--json", "output as json")
|
|
61
|
-
.action(async (name, options) => {
|
|
62
|
-
const provider = await prepareProvider();
|
|
63
|
-
|
|
64
|
-
if (options.json) {
|
|
65
|
-
const json = [];
|
|
66
|
-
|
|
67
|
-
for await (const repository of provider.repositories(name)) {
|
|
68
|
-
const r = { name: repository.fullName, hooks: [] };
|
|
69
|
-
for await (const hook of repository.hooks()) {
|
|
70
|
-
r.hooks.push(hook);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (r.hooks.length > 0) {
|
|
74
|
-
json.push(r);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
console.log(JSON.stringify(json));
|
|
78
|
-
} else {
|
|
79
|
-
for await (const repository of provider.repositories(name)) {
|
|
80
|
-
for await (const hook of repository.hooks()) {
|
|
81
|
-
console.log(repository.fullName);
|
|
82
|
-
console.log(" " + hook.url);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
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
|
-
});
|
|
56
|
+
}
|
|
98
57
|
|
|
99
58
|
program
|
|
100
59
|
.command("pull-request <name...>")
|
|
101
60
|
.option("--json", "output as json")
|
|
102
61
|
.option("--merge", "merge the pr")
|
|
103
|
-
.action(async (
|
|
62
|
+
.action(async (names, options) => {
|
|
104
63
|
const provider = await prepareProvider();
|
|
105
64
|
|
|
106
65
|
const json = [];
|
|
107
66
|
|
|
108
|
-
for await (const repository of provider.repositories(
|
|
67
|
+
for await (const repository of provider.repositories(names)) {
|
|
109
68
|
if (!repository.isArchived) {
|
|
110
69
|
for await (const pr of repository.pullRequestClass.list(repository)) {
|
|
111
70
|
if (options.json) {
|
|
@@ -126,29 +85,10 @@ program
|
|
|
126
85
|
});
|
|
127
86
|
|
|
128
87
|
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...>")
|
|
88
|
+
.command("update-repository <name...>")
|
|
149
89
|
.action(async (names, options) => {
|
|
150
90
|
const provider = await prepareProvider();
|
|
151
|
-
for await (const repository of provider.repositories(
|
|
91
|
+
for await (const repository of provider.repositories(names)) {
|
|
152
92
|
for (const [k, v] of Object.entries(properties)) {
|
|
153
93
|
repository[k] = v;
|
|
154
94
|
}
|
|
@@ -157,7 +97,7 @@ program
|
|
|
157
97
|
});
|
|
158
98
|
|
|
159
99
|
program
|
|
160
|
-
.command("create-repository <
|
|
100
|
+
.command("create-repository <name...>")
|
|
161
101
|
.action(async (names, options) => {
|
|
162
102
|
const provider = await prepareProvider();
|
|
163
103
|
for (const name of names) {
|
|
@@ -166,3 +106,23 @@ program
|
|
|
166
106
|
});
|
|
167
107
|
|
|
168
108
|
program.parse(process.argv);
|
|
109
|
+
|
|
110
|
+
async function list(provider, name, options, slot, attributes) {
|
|
111
|
+
if (options.json) {
|
|
112
|
+
const json = [];
|
|
113
|
+
for await (const object of provider[slot](name)) {
|
|
114
|
+
json.push(object);
|
|
115
|
+
}
|
|
116
|
+
console.log(JSON.stringify(json));
|
|
117
|
+
} else {
|
|
118
|
+
for await (const object of provider[slot](name)) {
|
|
119
|
+
let prefix= "";
|
|
120
|
+
if(object.repository) {
|
|
121
|
+
prefix = object.repository.fullName + ": ";
|
|
122
|
+
}
|
|
123
|
+
for (const a of attributes) {
|
|
124
|
+
console.log(prefix,object[a]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|