@@ -26076,18 +26076,43 @@ function wrappy (fn, cb) {
26076
26076
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26077
26077
// See the License for the specific language governing permissions and
26078
26078
// limitations under the License.
26079
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26080
+ if (k2 === undefined) k2 = k;
26081
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
26082
+ }) : (function(o, m, k, k2) {
26083
+ if (k2 === undefined) k2 = k;
26084
+ o[k2] = m[k];
26085
+ }));
26086
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26087
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26088
+ }) : function(o, v) {
26089
+ o["default"] = v;
26090
+ });
26091
+ var __importStar = (this && this.__importStar) || function (mod) {
26092
+ if (mod && mod.__esModule) return mod;
26093
+ var result = {};
26094
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26095
+ __setModuleDefault(result, mod);
26096
+ return result;
26097
+ };
26079
26098
var __importDefault = (this && this.__importDefault) || function (mod) {
26080
26099
return (mod && mod.__esModule) ? mod : { "default": mod };
26081
26100
};
26082
26101
Object.defineProperty(exports, "__esModule", ({ value: true }));
26083
- exports.issueIsClosed = exports.issueExists = exports.exitWithReason = exports.shouldIgnore = exports.createIssue = exports.issueBody = exports.issueTitle = void 0;
26102
+ exports.readIgnoreFiles = exports. issueIsClosed = exports.issueExists = exports.exitWithReason = exports.shouldIgnore = exports.createIssue = exports.issueBody = exports.issueTitle = void 0;
26084
26103
const core_1 = __webpack_require__(2186);
26085
26104
const github_1 = __webpack_require__(5438);
26086
26105
const ignore_1 = __importDefault(__webpack_require__(1230));
26106
+ const fs = __importStar(__webpack_require__(5747));
26107
+ const path = __importStar(__webpack_require__(5622));
26087
26108
let client;
26088
26109
const getClient = () => client || (client = new github_1.GitHub(core_1.getInput('token')));
26089
26110
exports.issueTitle = (upstreamReference) => `upstream reference closed: ${upstreamReference}`;
26090
- exports.issueBody = (upstreamReference, type, thisOwner, thisRepo, foundIn) => `The upstream [${type}](https://${upstreamReference}) got closed. It is referenced in: ${foundIn.map(([file, line]) => `[${file}#L${line}](https://github.com/${thisOwner}/${thisRepo}/blob/master/${file}#L${line})`)}`;
26111
+ exports.issueBody = (upstreamReference, type, thisOwner, thisRepo, foundIn) => `The upstream [${type}](https://${upstreamReference}) got closed. It is referenced in:
26112
+ - [ ] ${foundIn
26113
+ .map(([file, line]) => `[${file}#L${line}](https://github.com/${thisOwner}/${thisRepo}/blob/master/${file}#L${line})`)
26114
+ .join('
26115
+ - [ ] ')}`;
26091
26116
exports.createIssue = (params) => getClient()
26092
26117
.issues.create(params)
26093
26118
.then(() => Promise.resolve());
@@ -26122,6 +26147,11 @@ ${foundIn.map(([file, line]) => ` ${file}#${line}
26122
26147
})
26123
26148
.then((issue) => issue.data.state === 'closed');
26124
26149
};
26150
+ exports.readIgnoreFiles = (dir = '.') => Promise.allSettled(['.reference-ignore', '.gitignore'].map((fn) => fs.promises.readFile(path.join(dir, fn)))).then((files) => files
26151
+ .filter((file) => file.status === 'fulfilled')
26152
+ .map((fulFilled) => fulFilled.value.toString().split('
26153
+ '))
26154
+ .flat(1));
26125
26155
exports.default = {
26126
26156
issueExists: exports.issueExists,
26127
26157
exitWithReason: exports.exitWithReason,
@@ -26159,7 +26189,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26159
26189
Object.defineProperty(exports, "__esModule", ({ value: true }));
26160
26190
const walkdir_1 = __importDefault(__webpack_require__(5200));
26161
26191
const path_1 = __importDefault(__webpack_require__(5622));
26162
- const referenceRegex = /github\.com\/([a-zA-Z\d-]+)\/([a-zA-Z\d.-_ ]+)\/(pull|issues)\/(\d+)/gm;
26192
+ const referenceRegex = /github\.com\/([a-zA-Z\d-]+)\/([a-zA-Z\d._- ]+)\/(pull|issues)\/(\d+)/gm;
26163
26193
const mainRunner = ({ shouldIgnore, exitWithReason, issueTitle, createIssue, issueExists, labels, thisOwner, thisRepo, readFile, ignorePaths, issueIsClosed, directory, issueBody, issueLimit }) => walkdir_1.default.async(directory, { return_object: true }).then((files) => Promise.all(Object.entries(files).reduce((allIssues, [filePath, stats]) => stats.isDirectory() ||
26164
26194
shouldIgnore(ignorePaths, path_1.default.relative(directory, filePath))
26165
26195
? allIssues
@@ -26218,41 +26248,23 @@ exports.default = mainRunner;
26218
26248
26219
26249
"use strict";
26220
26250
26221
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26222
- if (k2 === undefined) k2 = k;
26223
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
26224
- }) : (function(o, m, k, k2) {
26225
- if (k2 === undefined) k2 = k;
26226
- o[k2] = m[k];
26227
- }));
26228
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26229
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26230
- }) : function(o, v) {
26231
- o["default"] = v;
26232
- });
26233
- var __importStar = (this && this.__importStar) || function (mod) {
26234
- if (mod && mod.__esModule) return mod;
26235
- var result = {};
26236
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26237
- __setModuleDefault(result, mod);
26238
- return result;
26239
- };
26240
26251
var __importDefault = (this && this.__importDefault) || function (mod) {
26241
26252
return (mod && mod.__esModule) ? mod : { "default": mod };
26242
26253
};
26243
26254
Object.defineProperty(exports, "__esModule", ({ value: true }));
26244
26255
const mainRunner_1 = __importDefault(__webpack_require__(2765));
26245
26256
const helpers_1 = __webpack_require__(3015);
26246
- const fs = __importStar(__webpack_require__(5747));
26247
- switch (process.argv[2]) {
26257
+ const fs_1 = __importDefault(__webpack_require__(5747));
26258
+ const [dir = '-h', ignore = '.git'] = process.argv.slice(2);
26259
+ switch (dir) {
26248
26260
case '-help':
26249
26261
case '-h':
26250
26262
case '--help':
26251
26263
console.log(`Usage:
26252
26264
npx closed-reference-notifier <dir> <ignore>
26253
26265
26254
26266
<dir>: the directory to traverse
26255
- <ignore>: comma separated list of gitignore style entries to ignore
26267
+ <ignore>: comma separated list of gitignore style entries to ignore, defaults to '.git'
26256
26268
`);
26257
26269
process.exit(0);
26258
26270
}
@@ -26263,21 +26275,23 @@ npx closed-reference-notifier <dir> <ignore>
26263
26275
thisOwner: '',
26264
26276
issueExists: () => Promise.resolve(false),
26265
26277
issueTitle: () => '',
26266
- issueBody: (ref, type, thisOwner, thisRepo, file) => `Found reference "${ref}" in file ${file}`,
26278
+ issueBody: (ref, type, thisOwner, thisRepo, files) => `Found reference "${ref}" in files
26279
+ ${files.map((file) => file.join('#')).join('
26280
+ ')}`,
26267
26281
issueIsClosed: () => Promise.resolve(true),
26268
- ignorePaths: process.argv[3] ? process.argv[3]. split(',') : [ ],
26282
+ ignorePaths: [...ignore. split(','), ...(await helpers_1.readIgnoreFiles(dir)) ],
26269
26283
createIssue: (issue) => {
26270
26284
console.log(issue.body);
26271
26285
return Promise.resolve();
26272
26286
},
26273
26287
shouldIgnore: helpers_1.shouldIgnore,
26274
- directory: process.argv[2] ,
26288
+ directory: dir ,
26275
26289
exitWithReason: (err) => {
26276
26290
console.log('unexpected error:', err);
26277
26291
process.exit(1);
26278
26292
},
26279
26293
labels: [],
26280
- readFile: fs .promises.readFile,
26294
+ readFile: fs_1.default .promises.readFile,
26281
26295
issueLimit: Number.POSITIVE_INFINITY
26282
26296
});
26283
26297
})();
0 commit comments