repo-util 1.27.1 → 1.27.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repo-util",
3
- "version": "1.27.1",
3
+ "version": "1.27.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -23,9 +23,9 @@
23
23
  "dependencies": {
24
24
  "aggregation-repository-provider": "^5.3.24",
25
25
  "bitbucket-repository-provider": "^5.0.7",
26
- "commander": "^10.0.0",
26
+ "commander": "^10.0.1",
27
27
  "etag-cache-leveldb": "^2.0.1",
28
- "gitea-repository-provider": "^3.0.5",
28
+ "gitea-repository-provider": "^3.0.6",
29
29
  "github-repository-provider": "^8.0.11",
30
30
  "leveldown": "^6.1.1",
31
31
  "levelup": "^5.1.1"
@@ -1,5 +1,4 @@
1
- #!/usr/bin/env node --no-warnings
2
-
1
+ #!/usr/bin/env -S node --no-warnings
3
2
  import { program } from "commander";
4
3
  import {
5
4
  Repository,
@@ -43,10 +42,8 @@ program
43
42
  const { provider, cache } = await initializeRepositoryProvider(program);
44
43
 
45
44
  for (const t of [
46
- type(MultiGroupProvider),
47
- type(RepositoryGroup),
48
- type(Repository, {
49
- create: {
45
+ type(MultiGroupProvider, {
46
+ "create-repository": {
50
47
  suffix: "<names>",
51
48
  description: "create repositories",
52
49
  execute: async (provider, names, options) => {
@@ -54,23 +51,37 @@ for (const t of [
54
51
  await provider.createRepository(name, properties);
55
52
  }
56
53
  }
57
- },
58
- addHook: {
54
+ }
55
+ }),
56
+ type(RepositoryGroup),
57
+ type(Repository, {
58
+ "add-hook": {
59
59
  suffix: "<names>",
60
- description: "add a Hook",
60
+ description: "add a hook",
61
+ prepareCommand(command) {
62
+ command.option("-u, --url <url>", "hook url to be called")
63
+ },
61
64
  executeInstance: async (repository, options) => {
65
+ console.log("ADD HOOK");
66
+ console.log(options);
62
67
  const hook = new repository.hookClass(repository, "hook1", {
63
- id: 77,
64
68
  url: "http://somewere.com/path",
65
69
  events: new Set(["a"])
66
70
  });
67
-
71
+
68
72
  console.log(hook);
69
73
  }
70
74
  }
71
-
72
75
  }),
73
- type(Branch),
76
+ type(Branch, {
77
+ "create-pull-request": {
78
+ suffix: "<name>",
79
+ description: "create a pull-request from a branch",
80
+ execute: () => {
81
+ console.log("create a PR");
82
+ }
83
+ }
84
+ }),
74
85
  type(Tag),
75
86
  type(Project),
76
87
  type(Milestone),
@@ -82,13 +93,6 @@ for (const t of [
82
93
  }
83
94
  }),
84
95
  type(PullRequest, {
85
- create: {
86
- suffix: "<name>",
87
- description: "create a PR",
88
- execute: () => {
89
- console.log("create a PR");
90
- }
91
- },
92
96
  merge: {
93
97
  description: "merge the pr",
94
98
  executeInstance: pr => pr.merge()
@@ -99,7 +103,7 @@ for (const t of [
99
103
  }
100
104
  })
101
105
  ]) {
102
- const command = program.command(`${t.name} [name...]`);
106
+ const command = program.command(`${t.name} [name...]` /*,`list ${t.name}`*/);
103
107
 
104
108
  const actions = t.actions;
105
109
 
@@ -109,13 +113,15 @@ for (const t of [
109
113
  for (const [an, actionOptions] of Object.entries(actions)) {
110
114
  if (actionOptions.execute) {
111
115
  const command = program.command(
112
- `${t.name}-${an} ${actionOptions.suffix}`
116
+ `${t.name}-${an} ${actionOptions.suffix}`,
117
+ actionOptions.description
118
+ );
119
+ command.action(async (names, options) =>
120
+ actionOptions.execute(provider, names, options)
113
121
  );
114
- command.action(async (names, options) => {
115
- await actionOptions.execute(provider, names, options);
116
- });
117
122
  }
118
123
  if (actionOptions.executeInstance) {
124
+ actionOptions.prepareCommand?.(command);
119
125
  command.option(
120
126
  `--${an}`,
121
127
  actionOptions.description,