repo-util 1.15.9 → 1.18.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.15.9",
3
+ "version": "1.18.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.15",
25
- "bitbucket-repository-provider": "^4.1.19",
24
+ "aggregation-repository-provider": "^5.2.21",
25
+ "bitbucket-repository-provider": "^4.1.20",
26
26
  "commander": "^9.2.0",
27
- "gitea-repository-provider": "^2.1.43",
28
- "github-repository-provider": "^7.26.30",
27
+ "gitea-repository-provider": "^2.1.51",
28
+ "github-repository-provider": "^7.26.39",
29
29
  "local-repository-provider": "^8.0.8"
30
30
  },
31
31
  "devDependencies": {
32
32
  "ava": "^4.2.0",
33
- "c8": "^7.11.2",
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.14.2"
38
+ "node": ">=16.15.0"
39
39
  },
40
40
  "repository": {
41
41
  "type": "git",
@@ -29,43 +29,95 @@ for (const o of [
29
29
  [
30
30
  "provider",
31
31
  "providers",
32
- ["fullName", ...Object.keys(visibleAttributes(AggregationProvider))]
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
+ }
64
+ }
65
+ }
66
+ }
33
67
  ],
34
- ["group", "repositoryGroups", ["fullName"]],
35
- ["repository", "repositories", ["fullName"]],
36
68
  ["branch", "branches", ["fullName"]],
37
69
  ["project", "projects", ["fullName"]],
38
70
  ["milestone", "milestones", ["fullName"]],
71
+ ["application", "applications", ["fullName"]],
39
72
  [
40
73
  "hook",
41
74
  "hooks",
42
75
  ["url", "events", "active"],
43
- { create: { description: "create a hook", execute: () => {} } }
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()
91
+ }
92
+ }
44
93
  ],
45
94
  [
46
95
  "pull-request",
47
96
  "pullRequests",
48
97
  ["url"],
49
- { merge: { description: "merge the pr", execute: pr => pr.merge() } }
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
+ }
111
+ }
50
112
  ]
51
113
  ]) {
52
114
  const command = program.command(`${o[0]} [name...]`);
53
-
54
115
  command
55
116
  .option("--json", "output as json")
56
- .option("--no-identifier", "do not output identifier attributes only")
117
+ .option("--no-identifier", "do not output identifier, show attributes only")
57
118
  .option("-a, --attribute <attributes>", "list attribute", a =>
58
119
  a.split(",")
59
120
  );
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
121
  command.action(async (names, options) =>
70
122
  list(
71
123
  await prepareProvider(options),
@@ -76,16 +128,30 @@ for (const o of [
76
128
  actions
77
129
  )
78
130
  );
79
- }
80
131
 
81
- program
82
- .command("create-repository <name...>")
83
- .action(async (names, options) => {
84
- const provider = await prepareProvider();
85
- for (const name of names) {
86
- await provider.createRepository(name, properties);
132
+ const actions = o[3];
133
+
134
+ if (actions) {
135
+ for (const [an, actionOptions] of Object.entries(actions)) {
136
+ if (actionOptions.execute) {
137
+ const command = program.command(
138
+ `${o[0]}-${an} ${actionOptions.suffix}`
139
+ );
140
+
141
+ command.action(async (names, options) => {
142
+ await actionOptions.execute(
143
+ await prepareProvider(options),
144
+ names,
145
+ options
146
+ );
147
+ });
148
+ }
149
+ if (actionOptions.executeInstance) {
150
+ command.option(`--${an}`, actionOptions.description);
151
+ }
87
152
  }
88
- });
153
+ }
154
+ }
89
155
 
90
156
  program.parse(process.argv);
91
157
 
@@ -99,8 +165,8 @@ async function list(provider, names, options, slot, attributes, actions) {
99
165
  for await (const object of provider[slot](normalize(names))) {
100
166
  if (actions) {
101
167
  for (const [name, action] of Object.entries(actions)) {
102
- if (options[name]) {
103
- await action.execute();
168
+ if (options[name] && action.executeInstance) {
169
+ await action.executeInstance(object, options);
104
170
  }
105
171
  }
106
172
  }