|
83 | 83 | ); |
84 | 84 | }); |
85 | 85 | }; |
| 86 | + var __asyncValues = |
| 87 | + (this && this.__asyncValues) || |
| 88 | + function (o) { |
| 89 | + if (!Symbol.asyncIterator) |
| 90 | + throw new TypeError('Symbol.asyncIterator is not defined.'); |
| 91 | + var m = o[Symbol.asyncIterator], |
| 92 | + i; |
| 93 | + return m |
| 94 | + ? m.call(o) |
| 95 | + : ((o = |
| 96 | + typeof __values === 'function' |
| 97 | + ? __values(o) |
| 98 | + : o[Symbol.iterator]()), |
| 99 | + (i = {}), |
| 100 | + verb('next'), |
| 101 | + verb('throw'), |
| 102 | + verb('return'), |
| 103 | + (i[Symbol.asyncIterator] = function () { |
| 104 | + return this; |
| 105 | + }), |
| 106 | + i); |
| 107 | + function verb(n) { |
| 108 | + i[n] = |
| 109 | + o[n] && |
| 110 | + function (v) { |
| 111 | + return new Promise(function (resolve, reject) { |
| 112 | + (v = o[n](v)), settle(resolve, reject, v.done, v.value); |
| 113 | + }); |
| 114 | + }; |
| 115 | + } |
| 116 | + function settle(resolve, reject, d, v) { |
| 117 | + Promise.resolve(v).then(function (v) { |
| 118 | + resolve({value: v, done: d}); |
| 119 | + }, reject); |
| 120 | + } |
| 121 | + }; |
86 | 122 | Object.defineProperty(exports, '__esModule', {value: true}); |
87 | 123 | const auth_app_1 = __nccwpck_require__(7541); |
88 | 124 | const rest_1 = __nccwpck_require__(5375); |
89 | 125 | const core = __importStar(__nccwpck_require__(2186)); |
| 126 | + const plugin_paginate_rest_1 = __nccwpck_require__(4193); |
| 127 | + const paginateOctokit = rest_1.Octokit.plugin( |
| 128 | + plugin_paginate_rest_1.paginateRest |
| 129 | + ); |
90 | 130 | function run() { |
91 | 131 | return __awaiter(this, void 0, void 0, function* () { |
92 | 132 | try { |
|
145 | 185 | }); |
146 | 186 | } |
147 | 187 | function isExistRepositoryInGitHubApps(installationToken, repository) { |
| 188 | + var e_1, _a; |
148 | 189 | return __awaiter(this, void 0, void 0, function* () { |
149 | | - const installationOctokit = new rest_1.Octokit({ |
| 190 | + const installationOctokit = new paginateOctokit({ |
150 | 191 | auth: installationToken, |
151 | 192 | baseUrl: process.env.GITHUB_API_URL || 'https://api.github.com', |
152 | 193 | }); |
153 | | - const accessibleRepositories = |
154 | | - yield installationOctokit.apps.listReposAccessibleToInstallation(); |
155 | | - const repo = accessibleRepositories.data.repositories.find( |
156 | | - (item) => item.full_name === repository |
157 | | - ); |
158 | | - if (repo === undefined) { |
159 | | - throw new Error( |
160 | | - `GitHub Apps can't accessible repository (${repository})` |
161 | | - ); |
| 194 | + try { |
| 195 | + for ( |
| 196 | + var _b = __asyncValues( |
| 197 | + installationOctokit.paginate.iterator( |
| 198 | + 'GET /installation/repositories' |
| 199 | + ) |
| 200 | + ), |
| 201 | + _c; |
| 202 | + (_c = yield _b.next()), !_c.done; |
| 203 | + |
| 204 | + ) { |
| 205 | + const response = _c.value; |
| 206 | + if (response.data.find((r) => r.full_name === repository)) { |
| 207 | + return undefined; |
| 208 | + } |
| 209 | + } |
| 210 | + } catch (e_1_1) { |
| 211 | + e_1 = {error: e_1_1}; |
| 212 | + } finally { |
| 213 | + try { |
| 214 | + if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b); |
| 215 | + } finally { |
| 216 | + if (e_1) throw e_1.error; |
| 217 | + } |
162 | 218 | } |
| 219 | + throw new Error( |
| 220 | + `GitHub Apps can't accessible repository (${repository})` |
| 221 | + ); |
163 | 222 | }); |
164 | 223 | } |
165 | 224 | run(); |
|
0 commit comments