github-repository-provider 9.2.31 → 9.3.1
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 +0 -10
- package/package.json +9 -8
- package/src/github-owner.mjs +9 -13
- package/src/github-provider.mjs +56 -31
- package/src/github-pull-request.mjs +6 -10
- package/src/github-repository.mjs +21 -43
package/README.md
CHANGED
|
@@ -51,7 +51,6 @@ for async (const entry of repository.entries('\*_/_.md')) {
|
|
|
51
51
|
* [Parameters](#parameters-6)
|
|
52
52
|
* [deleteRepository](#deleterepository)
|
|
53
53
|
* [Parameters](#parameters-7)
|
|
54
|
-
* [attributeMapping](#attributemapping)
|
|
55
54
|
* [GithubProvider](#githubprovider)
|
|
56
55
|
* [Examples](#examples)
|
|
57
56
|
* [initializeRepositories](#initializerepositories)
|
|
@@ -68,7 +67,6 @@ for async (const entry of repository.entries('\*_/_.md')) {
|
|
|
68
67
|
* [open](#open)
|
|
69
68
|
* [Parameters](#parameters-10)
|
|
70
69
|
* [GithubRepository](#githubrepository)
|
|
71
|
-
* [defaultBranchName](#defaultbranchname)
|
|
72
70
|
* [commits](#commits)
|
|
73
71
|
* [Parameters](#parameters-11)
|
|
74
72
|
* [commitForSha](#commitforsha)
|
|
@@ -181,10 +179,6 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
|
|
|
181
179
|
|
|
182
180
|
* `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
183
181
|
|
|
184
|
-
### attributeMapping
|
|
185
|
-
|
|
186
|
-
Map attributes between external and internal representation.
|
|
187
|
-
|
|
188
182
|
## GithubProvider
|
|
189
183
|
|
|
190
184
|
**Extends MultiGroupProvider**
|
|
@@ -286,10 +280,6 @@ Returns **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Glob
|
|
|
286
280
|
|
|
287
281
|
Repository on GitHub.
|
|
288
282
|
|
|
289
|
-
### defaultBranchName
|
|
290
|
-
|
|
291
|
-
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** "main"
|
|
292
|
-
|
|
293
283
|
### commits
|
|
294
284
|
|
|
295
285
|
<https://docs.github.com/en/rest/reference/commits#list-commits>
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
7
7
|
},
|
|
8
|
+
"packageManager": "npm@11.6.0+sha512.77f3fb0dbbd881835d7bd1217deabdf7ed77fc4ec4f363df64fc3cb986404abf6c437661041080f5c5d225103508e7c9ea30cb2742b7e942675d05a10af2d7b9",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"default": "./src/github-provider.mjs"
|
|
@@ -32,26 +33,26 @@
|
|
|
32
33
|
"lint:docs": "documentation lint ./src**/*.mjs"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"content-entry": "^14.2.
|
|
36
|
+
"content-entry": "^14.2.5",
|
|
36
37
|
"fetch-link-util": "^1.1.3",
|
|
37
38
|
"fetch-rate-limit-util": "^4.5.4",
|
|
38
39
|
"matching-iterator": "^2.1.4",
|
|
39
40
|
"one-time-execution-method": "^3.1.3",
|
|
40
|
-
"repository-provider": "^35.
|
|
41
|
+
"repository-provider": "^35.6.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^24.
|
|
44
|
+
"@types/node": "^24.5.2",
|
|
44
45
|
"ava": "^6.4.1",
|
|
45
46
|
"c8": "^10.1.3",
|
|
46
47
|
"documentation": "^14.0.3",
|
|
47
|
-
"etag-cache-leveldb": "^2.1.
|
|
48
|
+
"etag-cache-leveldb": "^2.1.16",
|
|
48
49
|
"leveldown": "^6.1.1",
|
|
49
50
|
"levelup": "^5.1.1",
|
|
50
|
-
"repository-provider-test-support": "^
|
|
51
|
-
"semantic-release": "^24.2.
|
|
51
|
+
"repository-provider-test-support": "^4.0.0",
|
|
52
|
+
"semantic-release": "^24.2.9"
|
|
52
53
|
},
|
|
53
54
|
"engines": {
|
|
54
|
-
"node": ">=22.
|
|
55
|
+
"node": ">=22.19.0"
|
|
55
56
|
},
|
|
56
57
|
"repository": {
|
|
57
58
|
"type": "git",
|
package/src/github-owner.mjs
CHANGED
|
@@ -6,20 +6,16 @@ import { RepositoryGroup, Repository } from "repository-provider";
|
|
|
6
6
|
* - organization
|
|
7
7
|
*/
|
|
8
8
|
export class GithubOwner extends RepositoryGroup {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
}
|
|
9
|
+
static attributes = {
|
|
10
|
+
...RepositoryGroup.attributes,
|
|
11
|
+
isAdmin: {
|
|
12
|
+
...RepositoryGroup.attributes.isAdmin,
|
|
13
|
+
externalName: "site_admin"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
18
16
|
|
|
19
17
|
get api() {
|
|
20
|
-
return this.type === "Organization"
|
|
21
|
-
? `orgs/${this.name}`
|
|
22
|
-
: "user";
|
|
18
|
+
return this.type === "Organization" ? `orgs/${this.name}` : "user";
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
/**
|
|
@@ -40,7 +36,7 @@ export class GithubOwner extends RepositoryGroup {
|
|
|
40
36
|
|
|
41
37
|
if (response.ok) {
|
|
42
38
|
this.info(`Repository ${name} created`);
|
|
43
|
-
options.
|
|
39
|
+
options.default_branch = "main";
|
|
44
40
|
return this.addRepository(name, options);
|
|
45
41
|
}
|
|
46
42
|
|
package/src/github-provider.mjs
CHANGED
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
url_attribute,
|
|
5
5
|
priority_attribute,
|
|
6
6
|
hostname_attribute,
|
|
7
|
-
token_attribute
|
|
7
|
+
token_attribute,
|
|
8
|
+
object_attribute
|
|
8
9
|
} from "pacc";
|
|
9
10
|
import { MultiGroupProvider } from "repository-provider";
|
|
10
11
|
import { GithubRepository } from "./github-repository.mjs";
|
|
@@ -56,51 +57,72 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
56
57
|
env: ["{{instanceIdentifier}}HOST", "GH_HOST"],
|
|
57
58
|
default: host
|
|
58
59
|
},
|
|
59
|
-
ssh:
|
|
60
|
-
...url_attribute,
|
|
61
|
-
default: `git@${host}:`
|
|
62
|
-
},
|
|
60
|
+
ssh: url_attribute,
|
|
63
61
|
url: {
|
|
64
62
|
...url_attribute,
|
|
65
|
-
env: "{{instanceIdentifier}}SERVER_URL"
|
|
66
|
-
set: value => (value.endsWith("/") ? value : value + "/"),
|
|
67
|
-
default: `https://${host}/`,
|
|
68
|
-
depends: "host"
|
|
69
|
-
/*get: (attribute, object, properties) =>
|
|
70
|
-
`https://${object.host || properties?.host.value}`*/
|
|
63
|
+
env: "{{instanceIdentifier}}SERVER_URL"
|
|
71
64
|
},
|
|
72
65
|
api: {
|
|
73
66
|
...url_attribute,
|
|
74
|
-
env: "{{instanceIdentifier}}API_URL"
|
|
75
|
-
set: value => value.replace(/\/$/, ""),
|
|
76
|
-
depends: "host",
|
|
77
|
-
default: `https://api.${host}`
|
|
78
|
-
/* get: (attribute, object, properties) =>
|
|
79
|
-
`https://api.${object.host || properties.host.value}`*/
|
|
67
|
+
env: "{{instanceIdentifier}}API_URL"
|
|
80
68
|
},
|
|
81
|
-
|
|
82
|
-
...
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
69
|
+
authentication: {
|
|
70
|
+
...object_attribute,
|
|
71
|
+
attributes: {
|
|
72
|
+
token: {
|
|
73
|
+
...token_attribute,
|
|
74
|
+
// @see https://cli.github.com/manual/gh_help_environment
|
|
75
|
+
env: [
|
|
76
|
+
"{{instanceIdentifier}}TOKEN",
|
|
77
|
+
"GH_TOKEN" // declare GH_ as identifier
|
|
78
|
+
],
|
|
79
|
+
additionalValues: { "authentication.type": "token" },
|
|
80
|
+
mandatory: true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
90
83
|
},
|
|
91
84
|
priority: { ...priority_attribute, default: 1000.0 }
|
|
92
85
|
};
|
|
93
86
|
|
|
87
|
+
set ssh(value) {
|
|
88
|
+
this._ssh = value;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
get ssh() {
|
|
92
|
+
return this._ssh ?? `git@${this.host}:`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
set url(value) {
|
|
96
|
+
this._url = value.endsWith("/") ? value : value + "/";
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
get url() {
|
|
100
|
+
return this._url ?? `https://${this.host}/`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
set api(value) {
|
|
104
|
+
this._api = value.replace(/\/$/, "");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
get api() {
|
|
108
|
+
return this._api ?? `https://api.${this.host}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
94
111
|
fetch(url, options = {}) {
|
|
95
112
|
options.reporter = (url, ...args) => this.trace(url.toString(), ...args);
|
|
96
113
|
options.cache = this.cache;
|
|
97
114
|
options.agent = this.agent;
|
|
98
115
|
|
|
116
|
+
const authorization = {};
|
|
117
|
+
if(this.authentication?.token) {
|
|
118
|
+
authorization.authorization = `token ${this.authentication.token}`
|
|
119
|
+
}
|
|
120
|
+
|
|
99
121
|
return stateActionHandler(new URL(url, this.api), {
|
|
100
122
|
...options,
|
|
101
123
|
headers: {
|
|
102
124
|
accept: "application/vnd.github+json",
|
|
103
|
-
authorization
|
|
125
|
+
...authorization,
|
|
104
126
|
...options.headers
|
|
105
127
|
}
|
|
106
128
|
});
|
|
@@ -123,7 +145,7 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
123
145
|
const url = `user/repos?page=${page}&per_page=100`;
|
|
124
146
|
const { json } = await this.fetchJSON(url);
|
|
125
147
|
|
|
126
|
-
if (json
|
|
148
|
+
if (json?.length === 0 || !Array.isArray(json)) {
|
|
127
149
|
break;
|
|
128
150
|
}
|
|
129
151
|
|
|
@@ -135,7 +157,9 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
135
157
|
);
|
|
136
158
|
});
|
|
137
159
|
}
|
|
138
|
-
} catch {
|
|
160
|
+
} catch (e) {
|
|
161
|
+
throw e;
|
|
162
|
+
}
|
|
139
163
|
}
|
|
140
164
|
|
|
141
165
|
/**
|
|
@@ -149,9 +173,10 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
149
173
|
* @return {string[]} common base urls of all repositories
|
|
150
174
|
*/
|
|
151
175
|
get repositoryBases() {
|
|
176
|
+
const url = this.url;
|
|
152
177
|
return super.repositoryBases.concat([
|
|
153
|
-
|
|
154
|
-
"git+" +
|
|
178
|
+
url,
|
|
179
|
+
"git+" + url,
|
|
155
180
|
`git+ssh://${this.host}`,
|
|
156
181
|
`git://${this.host}/`,
|
|
157
182
|
`git@${this.host}:`
|
|
@@ -12,16 +12,13 @@ export class GithubPullRequest extends PullRequest {
|
|
|
12
12
|
*/
|
|
13
13
|
static validMergeMethods = new Set(["MERGE", "SQUASH", "REBASE"]);
|
|
14
14
|
|
|
15
|
-
static get attributeMapping() {
|
|
16
|
-
return {
|
|
17
|
-
...super.attributeMapping,
|
|
18
|
-
url: "api" // TODO undefined ?
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
15
|
static attributes = {
|
|
23
16
|
...super.attributes,
|
|
24
|
-
maintainer_can_modify: boolean_attribute
|
|
17
|
+
maintainer_can_modify: boolean_attribute,
|
|
18
|
+
url: {
|
|
19
|
+
...PullRequest.attributes.url,
|
|
20
|
+
externalName: "api"
|
|
21
|
+
}
|
|
25
22
|
};
|
|
26
23
|
|
|
27
24
|
/**
|
|
@@ -114,7 +111,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
114
111
|
*
|
|
115
112
|
*/
|
|
116
113
|
async update() {
|
|
117
|
-
|
|
114
|
+
return await this.provider.fetch(this.api, {
|
|
118
115
|
method: "PATCH",
|
|
119
116
|
body: JSON.stringify({
|
|
120
117
|
title: this.title,
|
|
@@ -122,6 +119,5 @@ export class GithubPullRequest extends PullRequest {
|
|
|
122
119
|
state: this.state
|
|
123
120
|
})
|
|
124
121
|
});
|
|
125
|
-
console.log(res);
|
|
126
122
|
}
|
|
127
123
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { replaceWithOneTimeExecutionMethod } from "one-time-execution-method";
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
filterWritable,
|
|
4
|
+
boolean_attribute_writable,
|
|
5
|
+
boolean_attribute_writable_false,
|
|
4
6
|
url_attribute,
|
|
5
7
|
size_attribute,
|
|
6
8
|
language_attribute,
|
|
7
9
|
string_attribute_writable
|
|
8
10
|
} from "pacc";
|
|
9
|
-
import {
|
|
10
|
-
Repository,
|
|
11
|
-
mapAttributesInverse,
|
|
12
|
-
optionJSON,
|
|
13
|
-
Commit
|
|
14
|
-
} from "repository-provider";
|
|
11
|
+
import { Repository, Commit } from "repository-provider";
|
|
15
12
|
import { getHeaderLink } from "fetch-link-util";
|
|
16
13
|
import { defaultStateActions, errorHandler } from "fetch-rate-limit-util";
|
|
17
14
|
|
|
@@ -28,45 +25,31 @@ export class GithubRepository extends Repository {
|
|
|
28
25
|
#trees = new Map();
|
|
29
26
|
#commits = new Map();
|
|
30
27
|
|
|
31
|
-
static get attributeMapping() {
|
|
32
|
-
return {
|
|
33
|
-
...super.attributeMapping,
|
|
34
|
-
disabled: "isDisabled",
|
|
35
|
-
archived: "isArchived",
|
|
36
|
-
is_template: "isTemplate",
|
|
37
|
-
private: "isPrivate",
|
|
38
|
-
fork: "isFork",
|
|
39
|
-
default_branch: "defaultBranchName",
|
|
40
|
-
url: "api"
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
28
|
static attributes = {
|
|
45
29
|
...super.attributes,
|
|
46
|
-
auto_init: boolean_attribute,
|
|
47
|
-
size: size_attribute,
|
|
48
|
-
language: language_attribute,
|
|
49
30
|
gitignore_template: string_attribute_writable,
|
|
50
31
|
license_template: string_attribute_writable,
|
|
51
|
-
allow_squash_merge:
|
|
52
|
-
allow_merge_commit:
|
|
53
|
-
allow_rebase_merge:
|
|
54
|
-
allow_auto_merge:
|
|
55
|
-
delete_branch_on_merge:
|
|
56
|
-
issuesURL: url_attribute,
|
|
32
|
+
allow_squash_merge: boolean_attribute_writable_false,
|
|
33
|
+
allow_merge_commit: boolean_attribute_writable_false,
|
|
34
|
+
allow_rebase_merge: boolean_attribute_writable_false,
|
|
35
|
+
allow_auto_merge: boolean_attribute_writable_false,
|
|
36
|
+
delete_branch_on_merge: boolean_attribute_writable_false,
|
|
57
37
|
squash_merge_commit_title: string_attribute_writable,
|
|
58
38
|
squash_merge_commit_message: string_attribute_writable,
|
|
59
39
|
merge_commit_title: string_attribute_writable,
|
|
60
|
-
merge_commit_message: string_attribute_writable
|
|
61
|
-
|
|
40
|
+
merge_commit_message: string_attribute_writable,
|
|
41
|
+
size: size_attribute,
|
|
42
|
+
language: language_attribute,
|
|
43
|
+
issuesURL: url_attribute,
|
|
44
|
+
auto_init: boolean_attribute_writable_false,
|
|
45
|
+
url: {
|
|
46
|
+
...super.attributes.url,
|
|
47
|
+
externalName: "api"
|
|
48
|
+
},
|
|
49
|
+
isTemplate: { ...super.attributes.isTemplate, externalName: "is_template" }
|
|
62
50
|
};
|
|
63
51
|
|
|
64
|
-
|
|
65
|
-
* @return {string} "main"
|
|
66
|
-
*/
|
|
67
|
-
get defaultBranchName() {
|
|
68
|
-
return "main";
|
|
69
|
-
}
|
|
52
|
+
static defaultBranchName = "main";
|
|
70
53
|
|
|
71
54
|
/**
|
|
72
55
|
* {@link https://docs.github.com/en/rest/reference/commits#list-commits}
|
|
@@ -236,12 +219,7 @@ export class GithubRepository extends Repository {
|
|
|
236
219
|
async update() {
|
|
237
220
|
return this.provider.fetch(this.api, {
|
|
238
221
|
method: "PATCH",
|
|
239
|
-
body: JSON.stringify(
|
|
240
|
-
mapAttributesInverse(
|
|
241
|
-
optionJSON(this, undefined, this.constructor.writableAttributes),
|
|
242
|
-
this.constructor.attributeMapping
|
|
243
|
-
)
|
|
244
|
-
)
|
|
222
|
+
body: JSON.stringify(this.toJSON(filterWritable))
|
|
245
223
|
});
|
|
246
224
|
}
|
|
247
225
|
|