repo-util 1.15.7 → 1.16.0
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/README.md +3 -3
- package/package.json +8 -8
- package/src/repo-util-cli.mjs +68 -25
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
3
3
|
[](https://bundlephobia.com/result?p=repo-util)
|
|
4
4
|
[](https://npmjs.org/package/repo-util)
|
|
5
|
-
[](https://github.com/arlac77/repo-util/issues)
|
|
6
|
+
[](https://actions-badge.atrox.dev/arlac77/repo-util/goto)
|
|
7
|
+
[](https://coveralls.io/github/arlac77/repo-util)
|
|
8
8
|
# repo-util
|
|
9
9
|
operate on remote repositories
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-util",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
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": "^5.2.
|
|
25
|
-
"bitbucket-repository-provider": "^4.1.
|
|
24
|
+
"aggregation-repository-provider": "^5.2.21",
|
|
25
|
+
"bitbucket-repository-provider": "^4.1.19",
|
|
26
26
|
"commander": "^9.2.0",
|
|
27
|
-
"gitea-repository-provider": "^2.1.
|
|
28
|
-
"github-repository-provider": "^7.26.
|
|
29
|
-
"local-repository-provider": "^8.0.
|
|
27
|
+
"gitea-repository-provider": "^2.1.49",
|
|
28
|
+
"github-repository-provider": "^7.26.37",
|
|
29
|
+
"local-repository-provider": "^8.0.8"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"ava": "^4.2.0",
|
|
33
|
-
"c8": "^7.11.
|
|
33
|
+
"c8": "^7.11.3",
|
|
34
34
|
"execa": "^6.1.0",
|
|
35
35
|
"semantic-release": "^19.0.2"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=16.
|
|
38
|
+
"node": ">=16.15.0"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
package/src/repo-util-cli.mjs
CHANGED
|
@@ -29,43 +29,70 @@ for (const o of [
|
|
|
29
29
|
[
|
|
30
30
|
"provider",
|
|
31
31
|
"providers",
|
|
32
|
-
["
|
|
32
|
+
["fullName", ...Object.keys(visibleAttributes(AggregationProvider))]
|
|
33
33
|
],
|
|
34
34
|
["group", "repositoryGroups", ["fullName"]],
|
|
35
|
-
[
|
|
35
|
+
[
|
|
36
|
+
"repository",
|
|
37
|
+
"repositories",
|
|
38
|
+
["fullName"],
|
|
39
|
+
{
|
|
40
|
+
update: {
|
|
41
|
+
description: "update repository attributes",
|
|
42
|
+
executeInstance: async repository => repository.update(properties)
|
|
43
|
+
},
|
|
44
|
+
create: {
|
|
45
|
+
suffix: "<names>",
|
|
46
|
+
description: "create repositories",
|
|
47
|
+
execute: async (provider, names, options) => {
|
|
48
|
+
for (const name of names) {
|
|
49
|
+
await provider.createRepository(name, properties);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
],
|
|
36
55
|
["branch", "branches", ["fullName"]],
|
|
37
56
|
["project", "projects", ["fullName"]],
|
|
38
57
|
["milestone", "milestones", ["fullName"]],
|
|
58
|
+
["application", "applications", ["fullName"]],
|
|
39
59
|
[
|
|
40
60
|
"hook",
|
|
41
61
|
"hooks",
|
|
42
62
|
["url", "events", "active"],
|
|
43
|
-
{
|
|
63
|
+
{
|
|
64
|
+
create: {
|
|
65
|
+
suffix: "<name>",
|
|
66
|
+
description: "create a hook",
|
|
67
|
+
execute: () => {
|
|
68
|
+
console.log("create a hook");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
44
72
|
],
|
|
45
73
|
[
|
|
46
74
|
"pull-request",
|
|
47
75
|
"pullRequests",
|
|
48
76
|
["url"],
|
|
49
|
-
{
|
|
77
|
+
{
|
|
78
|
+
update: {
|
|
79
|
+
description: "update pr attributes",
|
|
80
|
+
executeInstance: async pr => pr.update(properties)
|
|
81
|
+
},
|
|
82
|
+
merge: {
|
|
83
|
+
description: "merge the pr",
|
|
84
|
+
executeInstance: async (pr, options) => pr.merge()
|
|
85
|
+
}
|
|
86
|
+
}
|
|
50
87
|
]
|
|
51
88
|
]) {
|
|
52
89
|
const command = program.command(`${o[0]} [name...]`);
|
|
53
|
-
|
|
54
90
|
command
|
|
55
91
|
.option("--json", "output as json")
|
|
56
92
|
.option("--no-identifier", "do not output identifier attributes only")
|
|
57
93
|
.option("-a, --attribute <attributes>", "list attribute", a =>
|
|
58
94
|
a.split(",")
|
|
59
95
|
);
|
|
60
|
-
|
|
61
|
-
const actions = o[3];
|
|
62
|
-
|
|
63
|
-
if (actions) {
|
|
64
|
-
for (const [an, options] of Object.entries(actions)) {
|
|
65
|
-
command.addOption(new Option(`--${an}`, options.description));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
96
|
command.action(async (names, options) =>
|
|
70
97
|
list(
|
|
71
98
|
await prepareProvider(options),
|
|
@@ -76,16 +103,30 @@ for (const o of [
|
|
|
76
103
|
actions
|
|
77
104
|
)
|
|
78
105
|
);
|
|
79
|
-
}
|
|
80
106
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
107
|
+
const actions = o[3];
|
|
108
|
+
|
|
109
|
+
if (actions) {
|
|
110
|
+
for (const [an, actionOptions] of Object.entries(actions)) {
|
|
111
|
+
if (actionOptions.execute) {
|
|
112
|
+
const command = program.command(
|
|
113
|
+
`${o[0]}-${an} ${actionOptions.suffix}`
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
command.action(async (names, options) => {
|
|
117
|
+
await actionOptions.execute(
|
|
118
|
+
await prepareProvider(options),
|
|
119
|
+
names,
|
|
120
|
+
options
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (actionOptions.executeInstance) {
|
|
125
|
+
command.option(`--${an}`, actionOptions.description);
|
|
126
|
+
}
|
|
87
127
|
}
|
|
88
|
-
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
89
130
|
|
|
90
131
|
program.parse(process.argv);
|
|
91
132
|
|
|
@@ -99,8 +140,8 @@ async function list(provider, names, options, slot, attributes, actions) {
|
|
|
99
140
|
for await (const object of provider[slot](normalize(names))) {
|
|
100
141
|
if (actions) {
|
|
101
142
|
for (const [name, action] of Object.entries(actions)) {
|
|
102
|
-
if (options[name]) {
|
|
103
|
-
await action.
|
|
143
|
+
if (options[name] && action.executeInstance) {
|
|
144
|
+
await action.executeInstance(object, options);
|
|
104
145
|
}
|
|
105
146
|
}
|
|
106
147
|
}
|
|
@@ -163,6 +204,8 @@ async function prepareProvider(options) {
|
|
|
163
204
|
|
|
164
205
|
function visibleAttributes(object) {
|
|
165
206
|
return Object.fromEntries(
|
|
166
|
-
Object.entries(object.attributes).filter(
|
|
207
|
+
Object.entries(object.attributes).filter(
|
|
208
|
+
([k, v]) => k !== "name" && !v.private
|
|
209
|
+
)
|
|
167
210
|
);
|
|
168
211
|
}
|