repo-util 1.18.1 → 1.20.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repo-util",
3
- "version": "1.18.1",
3
+ "version": "1.20.0",
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.23",
25
- "bitbucket-repository-provider": "^4.1.21",
24
+ "aggregation-repository-provider": "^5.2.26",
25
+ "bitbucket-repository-provider": "^4.1.24",
26
26
  "commander": "^9.2.0",
27
- "gitea-repository-provider": "^2.1.52",
28
- "github-repository-provider": "^7.28.1",
29
- "local-repository-provider": "^8.0.9"
27
+ "gitea-repository-provider": "^2.1.57",
28
+ "github-repository-provider": "^7.29.2",
29
+ "local-repository-provider": "^8.0.11"
30
30
  },
31
31
  "devDependencies": {
32
32
  "ava": "^4.2.0",
@@ -2,7 +2,19 @@
2
2
 
3
3
  import { readFileSync } from "fs";
4
4
  import { fileURLToPath } from "url";
5
- import { program, Option } from "commander";
5
+ import { program } from "commander";
6
+ import {
7
+ Repository,
8
+ RepositoryGroup,
9
+ Branch,
10
+ Tag,
11
+ Application,
12
+ Project,
13
+ Milestone,
14
+ Hook,
15
+ PullRequest,
16
+ MultiGroupProvider
17
+ } from "repository-provider";
6
18
  import AggregationProvider from "aggregation-repository-provider";
7
19
 
8
20
  process.on("uncaughtException", console.error);
@@ -26,90 +38,47 @@ program
26
38
  );
27
39
 
28
40
  for (const o of [
29
- [
30
- "provider",
31
- "providers",
32
- ["fullName", ...Object.keys(visibleAttributes(AggregationProvider))],
33
- {
34
- update: {
35
- description: "update provider attributes",
36
- executeInstance: async provider => provider.update(properties)
37
- }
38
- }
39
- ],
40
- ["group", "repositoryGroups", ["fullName"],
41
- {
42
- update: {
43
- description: "update group attributes",
44
- executeInstance: async group => group.update(properties)
45
- }
46
- }
47
- ],
48
- [
49
- "repository",
50
- "repositories",
51
- ["fullName"],
52
- {
53
- update: {
54
- description: "update repository attributes",
55
- executeInstance: async repository => repository.update(properties)
56
- },
57
- create: {
58
- suffix: "<names>",
59
- description: "create repositories",
60
- execute: async (provider, names, options) => {
61
- for (const name of names) {
62
- await provider.createRepository(name, properties);
63
- }
41
+ type(MultiGroupProvider),
42
+ type(RepositoryGroup),
43
+ type(Repository, {
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);
64
50
  }
65
51
  }
66
52
  }
67
- ],
68
- ["branch", "branches", ["fullName"]],
69
- ["project", "projects", ["fullName"]],
70
- ["milestone", "milestones", ["fullName"]],
71
- ["application", "applications", ["fullName"]],
72
- [
73
- "hook",
74
- "hooks",
75
- ["url", "events", "active"],
76
- {
77
- create: {
78
- suffix: "<name>",
79
- description: "create a hook",
80
- execute: () => {
81
- console.log("create a hook");
82
- }
83
- },
84
- update: {
85
- description: "update hook attributes",
86
- executeInstance: hook => hook.update(properties)
87
- },
88
- delete: {
89
- description: "delete a hook",
90
- executeInstance: hook => hook.delete()
53
+ }),
54
+ type(Branch),
55
+ type(Tag),
56
+ type(Project),
57
+ type(Milestone),
58
+ type(Application),
59
+ type(Hook, {
60
+ create: {
61
+ suffix: "<name>",
62
+ description: "create a hook",
63
+ execute: () => {
64
+ console.log("create a hook");
91
65
  }
66
+ },
67
+ delete: {
68
+ description: "delete a hook",
69
+ executeInstance: hook => hook.delete()
92
70
  }
93
- ],
94
- [
95
- "pull-request",
96
- "pullRequests",
97
- ["url"],
98
- {
99
- update: {
100
- description: "update pr attributes",
101
- executeInstance: pr => pr.update(properties)
102
- },
103
- merge: {
104
- description: "merge the pr",
105
- executeInstance: pr => pr.merge()
106
- },
107
- decline: {
108
- description: "decline the pr",
109
- executeInstance: pr => pr.decline()
110
- }
71
+ }),
72
+ type(PullRequest, {
73
+ merge: {
74
+ description: "merge the pr",
75
+ executeInstance: pr => pr.merge()
76
+ },
77
+ decline: {
78
+ description: "decline the pr",
79
+ executeInstance: pr => pr.decline()
111
80
  }
112
- ]
81
+ })
113
82
  ]) {
114
83
  const command = program.command(`${o[0]} [name...]`);
115
84
  command
@@ -234,3 +203,18 @@ function visibleAttributes(object) {
234
203
  )
235
204
  );
236
205
  }
206
+
207
+ function type(clazz, extra) {
208
+ return [
209
+ clazz.type,
210
+ clazz.collectionName,
211
+ ["fullName", ...Object.keys(visibleAttributes(clazz))],
212
+ {
213
+ update: {
214
+ description: `update ${clazz.type} attributes`,
215
+ executeInstance: object => object.update(properties)
216
+ },
217
+ ...extra
218
+ }
219
+ ];
220
+ }