@repository-settings/app 4.1.8 → 5.0.0-beta.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.
@@ -12,21 +12,21 @@ export default class Collaborators extends Diffable {
12
12
  }
13
13
  }
14
14
 
15
- find () {
16
- return this.github.repos
17
- .listCollaborators({ repo: this.repo.repo, owner: this.repo.owner, affiliation: 'direct' })
18
- .then(res => {
19
- return res.data.map(user => {
20
- return {
21
- // Force all usernames to lowercase to avoid comparison issues.
22
- username: user.login.toLowerCase(),
23
- permission:
24
- (user.permissions.admin && 'admin') ||
25
- (user.permissions.push && 'push') ||
26
- (user.permissions.pull && 'pull')
27
- }
28
- })
29
- })
15
+ async find () {
16
+ const { data: collaborators } = await this.github.request('GET /repos/{owner}/{repo}/collaborators', {
17
+ repo: this.repo.repo,
18
+ owner: this.repo.owner,
19
+ affiliation: 'direct'
20
+ })
21
+
22
+ return collaborators.map(collaborator => ({
23
+ // Force all usernames to lowercase to avoid comparison issues.
24
+ username: collaborator.login.toLowerCase(),
25
+ permission:
26
+ (collaborator.permissions.admin && 'admin') ||
27
+ (collaborator.permissions.push && 'push') ||
28
+ (collaborator.permissions.pull && 'pull')
29
+ }))
30
30
  }
31
31
 
32
32
  comparator (existing, attrs) {
@@ -42,10 +42,13 @@ export default class Collaborators extends Diffable {
42
42
  }
43
43
 
44
44
  add (attrs) {
45
- return this.github.repos.addCollaborator(Object.assign({}, attrs, this.repo))
45
+ return this.github.request('PUT /repos/{owner}/{repo}/collaborators/{username}', { ...attrs, ...this.repo })
46
46
  }
47
47
 
48
48
  remove (existing) {
49
- return this.github.repos.removeCollaborator(Object.assign({ username: existing.username }, this.repo))
49
+ return this.github.request('DELETE /repos/{owner}/{repo}/collaborators/{username}', {
50
+ username: existing.username,
51
+ ...this.repo
52
+ })
50
53
  }
51
54
  }
@@ -19,8 +19,7 @@ export default class Labels extends Diffable {
19
19
  }
20
20
 
21
21
  find () {
22
- const options = this.github.issues.listLabelsForRepo.endpoint.merge(this.wrapAttrs({ per_page: 100 }))
23
- return this.github.paginate(options)
22
+ return this.github.paginate('GET /repos/{owner}/{repo}/labels', this.wrapAttrs({ per_page: 100 }))
24
23
  }
25
24
 
26
25
  comparator (existing, attrs) {
@@ -32,15 +31,15 @@ export default class Labels extends Diffable {
32
31
  }
33
32
 
34
33
  update (existing, attrs) {
35
- return this.github.issues.updateLabel(this.wrapAttrs(attrs))
34
+ return this.github.request('PATCH /repos/{owner}/{repo}/labels/{name}', this.wrapAttrs(attrs))
36
35
  }
37
36
 
38
37
  add (attrs) {
39
- return this.github.issues.createLabel(this.wrapAttrs(attrs))
38
+ return this.github.request('POST /repos/{owner}/{repo}/labels', this.wrapAttrs(attrs))
40
39
  }
41
40
 
42
41
  remove (existing) {
43
- return this.github.issues.deleteLabel(this.wrapAttrs({ name: existing.name }))
42
+ return this.github.request('DELETE /repos/{owner}/{repo}/labels/{name}', this.wrapAttrs({ name: existing.name }))
44
43
  }
45
44
 
46
45
  wrapAttrs (attrs) {
@@ -14,10 +14,7 @@ export default class Milestones extends Diffable {
14
14
  }
15
15
 
16
16
  find () {
17
- const options = this.github.issues.listMilestones.endpoint.merge(
18
- Object.assign({ per_page: 100, state: 'all' }, this.repo)
19
- )
20
- return this.github.paginate(options)
17
+ return this.github.paginate('GET /repos/{owner}/{repo}/milestones', { per_page: 100, state: 'all', ...this.repo })
21
18
  }
22
19
 
23
20
  comparator (existing, attrs) {
@@ -31,20 +28,31 @@ export default class Milestones extends Diffable {
31
28
  update (existing, attrs) {
32
29
  const { owner, repo } = this.repo
33
30
 
34
- return this.github.issues.updateMilestone(
35
- Object.assign({ milestone_number: existing.number }, attrs, { owner, repo })
36
- )
31
+ return this.github.request('PATCH /repos/{owner}/{repo}/milestones/{milestone_number}', {
32
+ milestone_number: existing.number,
33
+ ...attrs,
34
+ owner,
35
+ repo
36
+ })
37
37
  }
38
38
 
39
39
  add (attrs) {
40
40
  const { owner, repo } = this.repo
41
41
 
42
- return this.github.issues.createMilestone(Object.assign({}, attrs, { owner, repo }))
42
+ return this.github.request('POST /repos/{owner}/{repo}/milestones', {
43
+ ...attrs,
44
+ owner,
45
+ repo
46
+ })
43
47
  }
44
48
 
45
49
  remove (existing) {
46
50
  const { owner, repo } = this.repo
47
51
 
48
- return this.github.issues.deleteMilestone(Object.assign({ milestone_number: existing.number }, { owner, repo }))
52
+ return this.github.request('DELETE /repos/{owner}/{repo}/milestones/{milestone_number}', {
53
+ milestone_number: existing.number,
54
+ owner,
55
+ repo
56
+ })
49
57
  }
50
58
  }
@@ -3,16 +3,15 @@ const enableAutomatedSecurityFixes = ({ github, settings, enabled }) => {
3
3
  return Promise.resolve()
4
4
  }
5
5
 
6
- const args = {
6
+ const verb = enabled ? 'PUT' : 'DELETE'
7
+
8
+ return github.request(`${verb} /repos/{owner}/{repo}/automated-security-fixes`, {
7
9
  owner: settings.owner,
8
10
  repo: settings.repo,
9
11
  mediaType: {
10
12
  previews: ['london']
11
13
  }
12
- }
13
- const methodName = enabled ? 'enableAutomatedSecurityFixes' : 'disableAutomatedSecurityFixes'
14
-
15
- return github.repos[methodName](args)
14
+ })
16
15
  }
17
16
 
18
17
  const enableVulnerabilityAlerts = ({ github, settings, enabled }) => {
@@ -20,16 +19,15 @@ const enableVulnerabilityAlerts = ({ github, settings, enabled }) => {
20
19
  return Promise.resolve()
21
20
  }
22
21
 
23
- const args = {
22
+ const verb = enabled ? 'PUT' : 'DELETE'
23
+
24
+ return github.request(`${verb} /repos/{owner}/{repo}/vulnerability-alerts`, {
24
25
  owner: settings.owner,
25
26
  repo: settings.repo,
26
27
  mediaType: {
27
28
  previews: ['dorian']
28
29
  }
29
- }
30
- const methodName = enabled ? 'enableVulnerabilityAlerts' : 'disableVulnerabilityAlerts'
31
-
32
- return github.repos[methodName](args)
30
+ })
33
31
  }
34
32
 
35
33
  export default class Repository {
@@ -46,23 +44,23 @@ export default class Repository {
46
44
  delete this.settings.enable_automated_security_fixes
47
45
  }
48
46
 
49
- sync () {
47
+ async sync () {
50
48
  this.settings.name = this.settings.name || this.settings.repo
51
- return this.github.repos
52
- .update(this.settings)
53
- .then(() => {
54
- if (this.topics) {
55
- return this.github.repos.replaceAllTopics({
56
- owner: this.settings.owner,
57
- repo: this.settings.repo,
58
- names: this.topics.split(/\s*,\s*/),
59
- mediaType: {
60
- previews: ['mercy']
61
- }
62
- })
49
+
50
+ await this.github.request('PATCH /repos/{owner}/{repo}', this.settings)
51
+
52
+ if (this.topics) {
53
+ await this.github.request('PUT /repos/{owner}/{repo}/topics', {
54
+ owner: this.settings.owner,
55
+ repo: this.settings.repo,
56
+ names: this.topics.split(/\s*,\s*/),
57
+ mediaType: {
58
+ previews: ['mercy']
63
59
  }
64
60
  })
65
- .then(() => enableVulnerabilityAlerts({ enabled: this.enableVulnerabilityAlerts, ...this }))
66
- .then(() => enableAutomatedSecurityFixes({ enabled: this.enableAutomatedSecurityFixes, ...this }))
61
+ }
62
+
63
+ await enableVulnerabilityAlerts({ enabled: this.enableVulnerabilityAlerts, ...this })
64
+ await enableAutomatedSecurityFixes({ enabled: this.enableAutomatedSecurityFixes, ...this })
67
65
  }
68
66
  }
@@ -4,10 +4,15 @@ import Diffable from './diffable.js'
4
4
 
5
5
  export default class Rulesets extends Diffable {
6
6
  async find () {
7
- const { data: rulesets } = await this.github.repos.getRepoRulesets({ ...this.repo, includes_parents: false })
7
+ const { data: rulesets } = await this.github.request('GET /repos/{owner}/{repo}/rulesets', {
8
+ ...this.repo,
9
+ includes_parents: false
10
+ })
8
11
 
9
12
  const expandedRulesetsData = await Promise.all(
10
- rulesets.map(({ id }) => this.github.repos.getRepoRuleset({ ...this.repo, ruleset_id: id }))
13
+ rulesets.map(({ id }) =>
14
+ this.github.request('GET /repos/{owner}/{repo}/rulesets/{ruleset_id}', { ...this.repo, ruleset_id: id })
15
+ )
11
16
  )
12
17
 
13
18
  return expandedRulesetsData.map(({ data }) => data)
@@ -34,14 +39,21 @@ export default class Rulesets extends Diffable {
34
39
  }
35
40
 
36
41
  update (existing, attrs) {
37
- return this.github.repos.updateRepoRuleset({ ...this.repo, ruleset_id: existing.id, ...attrs })
42
+ return this.github.request('PUT /repos/{owner}/{repo}/rulesets/{ruleset_id}', {
43
+ ...this.repo,
44
+ ruleset_id: existing.id,
45
+ ...attrs
46
+ })
38
47
  }
39
48
 
40
49
  remove (existing) {
41
- return this.github.repos.deleteRepoRuleset({ ...this.repo, ruleset_id: existing.id })
50
+ return this.github.request('DELETE /repos/{owner}/{repo}/rulesets/{ruleset_id}', {
51
+ ...this.repo,
52
+ ruleset_id: existing.id
53
+ })
42
54
  }
43
55
 
44
56
  async add (attrs) {
45
- await this.github.repos.createRepoRuleset({ ...this.repo, ...attrs })
57
+ await this.github.request('POST /repos/{owner}/{repo}/rulesets', { ...this.repo, ...attrs })
46
58
  }
47
59
  }
@@ -2,11 +2,11 @@ import Diffable from './diffable.js'
2
2
 
3
3
  // it is necessary to use this endpoint until GitHub Enterprise supports
4
4
  // the modern version under /orgs
5
- const teamRepoEndpoint = '/teams/:team_id/repos/:owner/:repo'
5
+ const teamRepoEndpoint = '/teams/{team_id}/repos/{owner}/{repo}'
6
6
 
7
7
  export default class Teams extends Diffable {
8
8
  find () {
9
- return this.github.repos.listTeams(this.repo).then(res => res.data)
9
+ return this.github.request('GET /repos/{owner}/{repo}/teams', this.repo).then(res => res.data)
10
10
  }
11
11
 
12
12
  comparator (existing, attrs) {
@@ -22,7 +22,7 @@ export default class Teams extends Diffable {
22
22
  }
23
23
 
24
24
  async add (attrs) {
25
- const { data: existing } = await this.github.request('GET /orgs/:org/teams/:team_slug', {
25
+ const { data: existing } = await this.github.request('GET /orgs/{org}/teams/{team_slug}', {
26
26
  org: this.repo.owner,
27
27
  team_slug: attrs.name
28
28
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repository-settings/app",
3
- "version": "4.1.8",
3
+ "version": "5.0.0-beta.1",
4
4
  "description": "Pull Requests for GitHub repository settings",
5
5
  "repository": "github:repository-settings/app",
6
6
  "type": "module",
@@ -32,23 +32,23 @@
32
32
  "deep-equal": "2.2.3",
33
33
  "deepmerge": "4.3.1",
34
34
  "js-yaml": "4.1.0",
35
- "probot": "13.3.9"
35
+ "probot": "14.0.2"
36
36
  },
37
37
  "devDependencies": {
38
- "@cucumber/cucumber": "11.2.0",
38
+ "@cucumber/cucumber": "11.3.0",
39
39
  "@form8ion/remark-preset": "1.0.5",
40
40
  "@travi/any": "3.1.2",
41
41
  "http-status-codes": "2.3.0",
42
- "jest": "29.7.0",
42
+ "jest": "30.0.5",
43
43
  "jest-when": "3.7.0",
44
- "lockfile-lint": "4.14.0",
44
+ "lockfile-lint": "4.14.1",
45
45
  "ls-engines": "0.9.3",
46
46
  "msw": "2.6.8",
47
- "nodemon": "3.1.9",
48
- "npm-run-all2": "7.0.2",
47
+ "nodemon": "3.1.10",
48
+ "npm-run-all2": "8.0.4",
49
49
  "prettier-standard": "16.4.1",
50
- "publint": "0.3.5",
51
- "smee-client": "3.0.0",
50
+ "publint": "0.3.12",
51
+ "smee-client": "4.3.1",
52
52
  "standard": "17.1.2"
53
53
  },
54
54
  "standard": {
@@ -57,7 +57,7 @@
57
57
  ]
58
58
  },
59
59
  "engines": {
60
- "node": "^18.17 || >=20.6.1"
60
+ "node": "^20.18.0 || ^22.11.0 || >=24.5.0"
61
61
  },
62
62
  "jest": {
63
63
  "testEnvironment": "node"
@@ -77,5 +77,5 @@
77
77
  "access": "public",
78
78
  "provenance": true
79
79
  },
80
- "packageManager": "npm@11.1.0"
80
+ "packageManager": "npm@11.5.2"
81
81
  }