mirror of
https://github.com/actions/stale.git
synced 2025-12-23 08:58:17 +00:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e611bf905b | ||
|
|
1e900bc060 | ||
|
|
3838b887be | ||
|
|
4f9b6a7a5c | ||
|
|
8743296016 | ||
|
|
7328f2e6e5 | ||
|
|
2b063ba4d4 | ||
|
|
ae2c5c5308 | ||
|
|
a23bda33c4 | ||
|
|
78921b6863 | ||
|
|
29c3838f9a | ||
|
|
ae12f32ff1 | ||
|
|
aad6ffa865 | ||
|
|
6127f8ef7a | ||
|
|
e78f171ed1 | ||
|
|
60b5a6b134 | ||
|
|
d179b42b05 | ||
|
|
7ba95148ac | ||
|
|
e9da8a66a5 | ||
|
|
3d5d474504 | ||
|
|
54897a34f9 | ||
|
|
c5c8bac9c4 | ||
|
|
ee2e3ba115 | ||
|
|
0d6a8e5314 | ||
|
|
eb8d275a4a | ||
|
|
c2f51ac751 | ||
|
|
d6c1b70646 | ||
|
|
1a8e37e7ad | ||
|
|
8588c16319 | ||
|
|
b8e29997c6 | ||
|
|
2521dbb244 | ||
|
|
08796943dd | ||
|
|
ded3b10c18 | ||
|
|
9f69ef12ad |
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
dist/
|
||||||
|
lib/
|
||||||
|
node_modules/
|
||||||
55
.eslintrc.json
Normal file
55
.eslintrc.json
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["jest", "@typescript-eslint"],
|
||||||
|
"extends": ["plugin:github/es6"],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 9,
|
||||||
|
"sourceType": "module",
|
||||||
|
"project": "./tsconfig.json"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"eslint-comments/no-use": "off",
|
||||||
|
"import/no-namespace": "off",
|
||||||
|
"no-unused-vars": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": "error",
|
||||||
|
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
|
||||||
|
"@typescript-eslint/no-require-imports": "error",
|
||||||
|
"@typescript-eslint/array-type": "error",
|
||||||
|
"@typescript-eslint/await-thenable": "error",
|
||||||
|
"@typescript-eslint/ban-ts-ignore": "error",
|
||||||
|
"camelcase": "off",
|
||||||
|
"@typescript-eslint/class-name-casing": "error",
|
||||||
|
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||||
|
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"],
|
||||||
|
"@typescript-eslint/no-array-constructor": "error",
|
||||||
|
"@typescript-eslint/no-empty-interface": "error",
|
||||||
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"@typescript-eslint/no-extraneous-class": "error",
|
||||||
|
"@typescript-eslint/no-for-in-array": "error",
|
||||||
|
"@typescript-eslint/no-inferrable-types": "error",
|
||||||
|
"@typescript-eslint/no-misused-new": "error",
|
||||||
|
"@typescript-eslint/no-namespace": "error",
|
||||||
|
"@typescript-eslint/no-non-null-assertion": "warn",
|
||||||
|
"@typescript-eslint/no-object-literal-type-assertion": "error",
|
||||||
|
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||||
|
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||||
|
"@typescript-eslint/no-useless-constructor": "error",
|
||||||
|
"@typescript-eslint/no-var-requires": "error",
|
||||||
|
"@typescript-eslint/prefer-for-of": "warn",
|
||||||
|
"@typescript-eslint/prefer-function-type": "warn",
|
||||||
|
"@typescript-eslint/prefer-includes": "error",
|
||||||
|
"@typescript-eslint/prefer-interface": "error",
|
||||||
|
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
||||||
|
"@typescript-eslint/promise-function-async": "error",
|
||||||
|
"@typescript-eslint/require-array-sort-compare": "error",
|
||||||
|
"@typescript-eslint/restrict-plus-operands": "error",
|
||||||
|
"semi": "off",
|
||||||
|
"@typescript-eslint/type-annotation-spacing": "error",
|
||||||
|
"@typescript-eslint/unbound-method": "off"
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"es6": true,
|
||||||
|
"jest/globals": true
|
||||||
|
}
|
||||||
|
}
|
||||||
26
.github/workflows/test.yml
vendored
Normal file
26
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: "Build"
|
||||||
|
on: # rebuild any PRs and main branch changes
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- 'releases/*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build: # make sure build/ci work properly
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- run: |
|
||||||
|
npm install
|
||||||
|
npm run all
|
||||||
|
test: # make sure the action works on a clean machine without building
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ./
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
stale-issue-message: 'This issue is stale'
|
||||||
|
stale-pr-message: 'This PR is stale'
|
||||||
|
debug-only: true
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
.DS_Store
|
||||||
node_modules/
|
node_modules/
|
||||||
lib/
|
lib/
|
||||||
__tests__/runner/*
|
__tests__/runner/*
|
||||||
|
|||||||
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug Jest Tests",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceRoot}/node_modules/jest/bin/jest",
|
||||||
|
"args": [
|
||||||
|
"-i"
|
||||||
|
],
|
||||||
|
"preLaunchTask": "tsc: build - tsconfig.json",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart",
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceRoot}/build/dist/**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
43
README.md
43
README.md
@@ -2,22 +2,39 @@
|
|||||||
|
|
||||||
Warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
Warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
||||||
|
|
||||||
|
### Building and testing
|
||||||
|
|
||||||
|
Install the dependencies
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
Build the typescript and package it for distribution
|
||||||
|
```bash
|
||||||
|
$ npm run build && npm run pack
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the tests :heavy_check_mark:
|
||||||
|
```bash
|
||||||
|
$ npm test
|
||||||
|
```
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
See [action.yml](./action.yml) For comprehensive list of options.
|
See [action.yml](./action.yml) For comprehensive list of options.
|
||||||
|
|
||||||
Basic:
|
Basic:
|
||||||
```
|
```yaml
|
||||||
name: "Close stale issues"
|
name: "Close stale issues"
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 * * * *"
|
- cron: "0 0 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v1
|
- uses: actions/stale@v3
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-issue-message: 'Message to comment on stale issues. If none provided, will not mark issues stale'
|
stale-issue-message: 'Message to comment on stale issues. If none provided, will not mark issues stale'
|
||||||
@@ -25,17 +42,17 @@ jobs:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Configure stale timeouts:
|
Configure stale timeouts:
|
||||||
```
|
```yaml
|
||||||
name: "Close stale issues"
|
name: "Close stale issues"
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 * * * *"
|
- cron: "0 0 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v1
|
- uses: actions/stale@v3
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
|
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
|
||||||
@@ -44,21 +61,27 @@ jobs:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Configure labels:
|
Configure labels:
|
||||||
```
|
```yaml
|
||||||
name: "Close stale issues"
|
name: "Close stale issues"
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 * * * *"
|
- cron: "0 0 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v1
|
- uses: actions/stale@v3
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-issue-message: 'Stale issue message'
|
stale-issue-message: 'Stale issue message'
|
||||||
stale-pr-message: 'Stale issue message'
|
stale-pr-message: 'Stale pull request message'
|
||||||
stale-issue-label: 'no-issue-activity'
|
stale-issue-label: 'no-issue-activity'
|
||||||
|
exempt-issue-labels: 'awaiting-approval,work-in-progress'
|
||||||
stale-pr-label: 'no-pr-activity'
|
stale-pr-label: 'no-pr-activity'
|
||||||
|
exempt-pr-labels: 'awaiting-approval,work-in-progress'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Debugging
|
||||||
|
|
||||||
|
To see debug output from this action, you must set the secret `ACTIONS_STEP_DEBUG` to `true` in your repository. You can run this action in debug only mode (no actions will be taken on your issues) by passing `debug-only` `true` as an argument to the action.
|
||||||
|
|||||||
@@ -1,3 +1,506 @@
|
|||||||
describe('TODO - Add a test suite', () => {
|
import * as core from '@actions/core';
|
||||||
it('TODO - Add a test', async () => {});
|
import * as github from '@actions/github';
|
||||||
|
import {Octokit} from '@octokit/rest';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IssueProcessor,
|
||||||
|
Issue,
|
||||||
|
Label,
|
||||||
|
IssueProcessorOptions
|
||||||
|
} from '../src/IssueProcessor';
|
||||||
|
|
||||||
|
function generateIssue(
|
||||||
|
id: number,
|
||||||
|
title: string,
|
||||||
|
updatedAt: string,
|
||||||
|
isPullRequest: boolean = false,
|
||||||
|
labels: string[] = [],
|
||||||
|
isClosed: boolean = false,
|
||||||
|
isLocked: boolean = false
|
||||||
|
): Issue {
|
||||||
|
return {
|
||||||
|
number: id,
|
||||||
|
labels: labels.map(l => {
|
||||||
|
return {name: l};
|
||||||
|
}),
|
||||||
|
title: title,
|
||||||
|
updated_at: updatedAt,
|
||||||
|
pull_request: isPullRequest ? {} : null,
|
||||||
|
state: isClosed ? 'closed' : 'open',
|
||||||
|
locked: isLocked
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const DefaultProcessorOptions: IssueProcessorOptions = {
|
||||||
|
repoToken: 'none',
|
||||||
|
staleIssueMessage: 'This issue is stale',
|
||||||
|
stalePrMessage: 'This PR is stale',
|
||||||
|
daysBeforeStale: 1,
|
||||||
|
daysBeforeClose: 30,
|
||||||
|
staleIssueLabel: 'Stale',
|
||||||
|
exemptIssueLabels: '',
|
||||||
|
stalePrLabel: 'Stale',
|
||||||
|
exemptPrLabels: '',
|
||||||
|
onlyLabels: '',
|
||||||
|
operationsPerRun: 100,
|
||||||
|
debugOnly: true,
|
||||||
|
removeStaleWhenUpdated: false
|
||||||
|
};
|
||||||
|
|
||||||
|
test('empty issue list results in 1 operation', async () => {
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async () => [],
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
const operationsLeft = await processor.processIssues(1);
|
||||||
|
|
||||||
|
// processing an empty issue list should result in 1 operation
|
||||||
|
expect(operationsLeft).toEqual(99);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processing an issue with no label will make it stale and close it, if it is old enough', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(1, 'An issue with no label', '2020-01-01T17:00:00Z')
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(1);
|
||||||
|
expect(processor.closedIssues.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processing an issue with no label will make it stale but not close it', async () => {
|
||||||
|
// issue should be from 2 days ago so it will be
|
||||||
|
// stale but not close-able, based on default settings
|
||||||
|
let issueDate = new Date();
|
||||||
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
|
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(1, 'An issue with no label', issueDate.toDateString())
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(1);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processing a stale issue will close it', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A stale issue that should be closed',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
['Stale']
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processing a stale PR will close it', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A stale PR that should be closed',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
true,
|
||||||
|
['Stale']
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('closed issues will not be marked stale', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A closed issue that will not be marked',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
[],
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => []
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('stale closed issues will not be closed', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A stale closed issue',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
['Stale'],
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('closed prs will not be marked stale', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A closed PR that will not be marked',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
true,
|
||||||
|
[],
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('stale closed prs will not be closed', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A stale closed PR that will not be closed again',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
true,
|
||||||
|
['Stale'],
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('locked issues will not be marked stale', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A locked issue that will not be stale',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
[],
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(DefaultProcessorOptions, async p =>
|
||||||
|
p == 1 ? TestIssueList : []
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('stale locked issues will not be closed', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A stale locked issue that will not be closed',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
['Stale'],
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('locked prs will not be marked stale', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A locked PR that will not be marked stale',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
true,
|
||||||
|
[],
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(DefaultProcessorOptions, async p =>
|
||||||
|
p == 1 ? TestIssueList : []
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('stale locked prs will not be closed', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'A stale locked PR that will not be closed',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
true,
|
||||||
|
['Stale'],
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
DefaultProcessorOptions,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('exempt issue labels will not be marked stale', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, [
|
||||||
|
'Exempt'
|
||||||
|
])
|
||||||
|
];
|
||||||
|
|
||||||
|
const opts = {...DefaultProcessorOptions};
|
||||||
|
opts.exemptIssueLabels = 'Exempt';
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('exempt issue labels will not be marked stale (multi issue label with spaces)', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, ['Cool'])
|
||||||
|
];
|
||||||
|
|
||||||
|
const opts = {...DefaultProcessorOptions};
|
||||||
|
opts.exemptIssueLabels = 'Exempt, Cool, None';
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('exempt issue labels will not be marked stale (multi issue label)', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, ['Cool'])
|
||||||
|
];
|
||||||
|
|
||||||
|
const opts = {...DefaultProcessorOptions};
|
||||||
|
opts.exemptIssueLabels = 'Exempt,Cool,None';
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('exempt pr labels will not be marked stale', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, ['Cool']),
|
||||||
|
generateIssue(2, 'My first PR', '2020-01-01T17:00:00Z', true, ['Cool']),
|
||||||
|
generateIssue(3, 'Another issue', '2020-01-01T17:00:00Z', false)
|
||||||
|
];
|
||||||
|
|
||||||
|
const opts = {...DefaultProcessorOptions};
|
||||||
|
opts.exemptIssueLabels = 'Cool';
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.staleIssues.length).toEqual(2); // PR should get processed even though it has an exempt **issue** label
|
||||||
|
});
|
||||||
|
|
||||||
|
test('stale issues should not be closed if days is set to -1', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, [
|
||||||
|
'Stale'
|
||||||
|
]),
|
||||||
|
generateIssue(2, 'My first PR', '2020-01-01T17:00:00Z', true, ['Stale']),
|
||||||
|
generateIssue(3, 'Another issue', '2020-01-01T17:00:00Z', false, ['Stale'])
|
||||||
|
];
|
||||||
|
|
||||||
|
const opts = {...DefaultProcessorOptions};
|
||||||
|
opts.daysBeforeClose = -1;
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [],
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('stale label should be removed if a comment was added to a stale issue', async () => {
|
||||||
|
const TestIssueList: Issue[] = [
|
||||||
|
generateIssue(
|
||||||
|
1,
|
||||||
|
'An issue that should un-stale',
|
||||||
|
'2020-01-01T17:00:00Z',
|
||||||
|
false,
|
||||||
|
['Stale']
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
const opts = DefaultProcessorOptions;
|
||||||
|
opts.removeStaleWhenUpdated = true;
|
||||||
|
|
||||||
|
const processor = new IssueProcessor(
|
||||||
|
opts,
|
||||||
|
async p => (p == 1 ? TestIssueList : []),
|
||||||
|
async (num, dt) => [{user: {type: 'User'}}], // return a fake comment so indicate there was an update
|
||||||
|
async (issue, label) => new Date().toDateString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// process our fake issue list
|
||||||
|
await processor.processIssues(1);
|
||||||
|
|
||||||
|
expect(processor.closedIssues.length).toEqual(0);
|
||||||
|
expect(processor.staleIssues.length).toEqual(0);
|
||||||
|
expect(processor.removedLabelIssues.length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|||||||
31
action.yml
31
action.yml
@@ -1,29 +1,44 @@
|
|||||||
name: 'Close Stale Issues'
|
name: 'Close Stale Issues'
|
||||||
description: 'Action to close stale issues'
|
description: 'Close issues and pull requests with no recent activity'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
repo-token:
|
repo-token:
|
||||||
description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}'
|
description: 'Token for the repository. Can be passed in using `{{ secrets.GITHUB_TOKEN }}`.'
|
||||||
required: true
|
required: true
|
||||||
stale-issue-message:
|
stale-issue-message:
|
||||||
description: 'The message to post on the issue when tagging it. If none provided, will not mark issues stale.'
|
description: 'The message to post on the issue when tagging it. If none provided, will not mark issues stale.'
|
||||||
stale-pr-message:
|
stale-pr-message:
|
||||||
description: 'The message to post on the pr when tagging it. If none provided, will not mark pull requests stale.'
|
description: 'The message to post on the pr when tagging it. If none provided, will not mark pull requests stale.'
|
||||||
days-before-stale:
|
days-before-stale:
|
||||||
description: 'The number of days old an issue can be before marking it stale'
|
description: 'The number of days old an issue can be before marking it stale.'
|
||||||
default: 60
|
default: 60
|
||||||
days-before-close:
|
days-before-close:
|
||||||
description: 'The number of days to wait to close an issue or pull request after it being marked stale'
|
description: 'The number of days to wait to close an issue or pull request after it being marked stale. Set to -1 to never close stale issues.'
|
||||||
default: 7
|
default: 7
|
||||||
stale-issue-label:
|
stale-issue-label:
|
||||||
description: 'The label to apply when an issue is stale'
|
description: 'The label to apply when an issue is stale.'
|
||||||
default: 'Stale'
|
default: 'Stale'
|
||||||
|
exempt-issue-labels:
|
||||||
|
description: 'The labels to apply when an issue is exempt from being marked stale. Separate multiple labels with commas (eg. "label1,label2")'
|
||||||
|
default: ''
|
||||||
stale-pr-label:
|
stale-pr-label:
|
||||||
description: 'The label to apply when a pull request is stale'
|
description: 'The label to apply when a pull request is stale.'
|
||||||
default: 'Stale'
|
default: 'Stale'
|
||||||
|
exempt-pr-labels:
|
||||||
|
description: 'The labels to apply when a pull request is exempt from being marked stale. Separate multiple labels with commas (eg. "label1,label2")'
|
||||||
|
default: ''
|
||||||
|
only-labels:
|
||||||
|
description: 'Only issues or pull requests with all of these labels are checked if stale. Defaults to `[]` (disabled) and can be a comma-separated list of labels.'
|
||||||
|
default: ''
|
||||||
operations-per-run:
|
operations-per-run:
|
||||||
description: 'The maximum number of operations per run, used to control rate limiting'
|
description: 'The maximum number of operations per run, used to control rate limiting.'
|
||||||
default: 30
|
default: 30
|
||||||
|
remove-stale-when-updated:
|
||||||
|
description: 'Remove stale labels from issues when they are updated or commented on.'
|
||||||
|
default: true
|
||||||
|
debug-only:
|
||||||
|
description: 'Run the processor in debug mode without actually performing any operations on live issues.'
|
||||||
|
default: false
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'lib/main.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
25644
dist/index.js
vendored
Normal file
25644
dist/index.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4158
package-lock.json
generated
4158
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
43
package.json
43
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "stale-action",
|
"name": "stale-action",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Marks old issues and PRs as stale",
|
"description": "Marks old issues and PRs as stale",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
@@ -8,7 +8,10 @@
|
|||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
"test": "jest"
|
"lint": "eslint src/**/*.ts",
|
||||||
|
"pack": "ncc build",
|
||||||
|
"test": "jest",
|
||||||
|
"all": "npm run build && npm run format && npm run lint && npm run pack && npm test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -22,29 +25,25 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "file:toolkit/actions-core-0.0.0.tgz",
|
"@actions/core": "^1.2.3",
|
||||||
"@actions/exec": "file:toolkit/actions-exec-0.0.0.tgz",
|
"@actions/github": "^2.2.0",
|
||||||
"@actions/github": "file:toolkit/actions-github-0.0.0.tgz",
|
"@octokit/rest": "^16.43.1",
|
||||||
"@actions/io": "file:toolkit/actions-io-0.0.0.tgz",
|
|
||||||
"@actions/tool-cache": "file:toolkit/actions-tool-cache-0.0.0.tgz",
|
|
||||||
"semver": "^6.1.1"
|
"semver": "^6.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.13",
|
|
||||||
"@types/node": "^12.6.8",
|
|
||||||
"@types/semver": "^6.0.0",
|
"@types/semver": "^6.0.0",
|
||||||
"husky": "^2.3.0",
|
"@types/jest": "^24.0.23",
|
||||||
"jest": "^24.8.0",
|
"@types/node": "^12.7.12",
|
||||||
"jest-circus": "^24.7.1",
|
"@typescript-eslint/parser": "^2.8.0",
|
||||||
"prettier": "^1.17.1",
|
"@zeit/ncc": "^0.20.5",
|
||||||
"ts-jest": "^24.0.2",
|
"eslint": "^5.16.0",
|
||||||
"typescript": "^3.5.1"
|
"eslint-plugin-github": "^2.0.0",
|
||||||
},
|
"eslint-plugin-jest": "^22.21.0",
|
||||||
"husky": {
|
"jest": "^24.9.0",
|
||||||
"skipCI": true,
|
"jest-circus": "^24.9.0",
|
||||||
"hooks": {
|
"js-yaml": "^3.13.1",
|
||||||
"pre-commit": "npm run build && npm run format",
|
"prettier": "^1.19.1",
|
||||||
"post-commit": "npm prune --production && git add node_modules/* && git commit -m \"Husky commit correct node modules\""
|
"ts-jest": "^24.2.0",
|
||||||
}
|
"typescript": "^3.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
400
src/IssueProcessor.ts
Normal file
400
src/IssueProcessor.ts
Normal file
@@ -0,0 +1,400 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as github from '@actions/github';
|
||||||
|
import {Octokit} from '@octokit/rest';
|
||||||
|
|
||||||
|
type OctoKitIssueList = Octokit.Response<Octokit.IssuesListForRepoResponse>;
|
||||||
|
|
||||||
|
export interface Issue {
|
||||||
|
title: string;
|
||||||
|
number: number;
|
||||||
|
updated_at: string;
|
||||||
|
labels: Label[];
|
||||||
|
pull_request: any;
|
||||||
|
state: string;
|
||||||
|
locked: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface User {
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Comment {
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IssueEvent {
|
||||||
|
created_at: string;
|
||||||
|
event: string;
|
||||||
|
label: Label;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Label {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IssueProcessorOptions {
|
||||||
|
repoToken: string;
|
||||||
|
staleIssueMessage: string;
|
||||||
|
stalePrMessage: string;
|
||||||
|
daysBeforeStale: number;
|
||||||
|
daysBeforeClose: number;
|
||||||
|
staleIssueLabel: string;
|
||||||
|
exemptIssueLabels: string;
|
||||||
|
stalePrLabel: string;
|
||||||
|
exemptPrLabels: string;
|
||||||
|
onlyLabels: string;
|
||||||
|
operationsPerRun: number;
|
||||||
|
removeStaleWhenUpdated: boolean;
|
||||||
|
debugOnly: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Handle processing of issues for staleness/closure.
|
||||||
|
*/
|
||||||
|
export class IssueProcessor {
|
||||||
|
readonly client: github.GitHub;
|
||||||
|
readonly options: IssueProcessorOptions;
|
||||||
|
private operationsLeft: number = 0;
|
||||||
|
|
||||||
|
readonly staleIssues: Issue[] = [];
|
||||||
|
readonly closedIssues: Issue[] = [];
|
||||||
|
readonly removedLabelIssues: Issue[] = [];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
options: IssueProcessorOptions,
|
||||||
|
getIssues?: (page: number) => Promise<Issue[]>,
|
||||||
|
listIssueComments?: (
|
||||||
|
issueNumber: number,
|
||||||
|
sinceDate: string
|
||||||
|
) => Promise<Comment[]>,
|
||||||
|
getLabelCreationDate?: (issue: Issue, label: string) => Promise<string>
|
||||||
|
) {
|
||||||
|
this.options = options;
|
||||||
|
this.operationsLeft = options.operationsPerRun;
|
||||||
|
this.client = new github.GitHub(options.repoToken);
|
||||||
|
|
||||||
|
if (getIssues) {
|
||||||
|
this.getIssues = getIssues;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listIssueComments) {
|
||||||
|
this.listIssueComments = listIssueComments;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getLabelCreationDate) {
|
||||||
|
this.getLabelCreationDate = getLabelCreationDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.options.debugOnly) {
|
||||||
|
core.warning(
|
||||||
|
'Executing in debug mode. Debug output will be written but no issues will be processed.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async processIssues(page: number = 1): Promise<number> {
|
||||||
|
if (this.operationsLeft <= 0) {
|
||||||
|
core.warning('Reached max number of operations to process. Exiting.');
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the next batch of issues
|
||||||
|
const issues: Issue[] = await this.getIssues(page);
|
||||||
|
this.operationsLeft -= 1;
|
||||||
|
|
||||||
|
if (issues.length <= 0) {
|
||||||
|
core.debug('No more issues found to process. Exiting.');
|
||||||
|
return this.operationsLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const issue of issues.values()) {
|
||||||
|
const isPr = !!issue.pull_request;
|
||||||
|
|
||||||
|
core.debug(
|
||||||
|
`Found issue: issue #${issue.number} - ${issue.title} last updated ${issue.updated_at} (is pr? ${isPr})`
|
||||||
|
);
|
||||||
|
|
||||||
|
// calculate string based messages for this issue
|
||||||
|
const staleMessage: string = isPr
|
||||||
|
? this.options.stalePrMessage
|
||||||
|
: this.options.staleIssueMessage;
|
||||||
|
const staleLabel: string = isPr
|
||||||
|
? this.options.stalePrLabel
|
||||||
|
: this.options.staleIssueLabel;
|
||||||
|
const exemptLabels = IssueProcessor.parseCommaSeparatedString(
|
||||||
|
isPr ? this.options.exemptPrLabels : this.options.exemptIssueLabels
|
||||||
|
);
|
||||||
|
const issueType: string = isPr ? 'pr' : 'issue';
|
||||||
|
|
||||||
|
if (!staleMessage) {
|
||||||
|
core.debug(`Skipping ${issueType} due to empty stale message`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (issue.state === 'closed') {
|
||||||
|
core.debug(`Skipping ${issueType} because it is closed`);
|
||||||
|
continue; // don't process closed issues
|
||||||
|
}
|
||||||
|
|
||||||
|
if (issue.locked) {
|
||||||
|
core.debug(`Skipping ${issueType} because it is locked`);
|
||||||
|
continue; // don't process locked issues
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
exemptLabels.some((exemptLabel: string) =>
|
||||||
|
IssueProcessor.isLabeled(issue, exemptLabel)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
core.debug(`Skipping ${issueType} because it has an exempt label`);
|
||||||
|
continue; // don't process exempt issues
|
||||||
|
}
|
||||||
|
|
||||||
|
// does this issue have a stale label?
|
||||||
|
let isStale = IssueProcessor.isLabeled(issue, staleLabel);
|
||||||
|
|
||||||
|
// determine if this issue needs to be marked stale first
|
||||||
|
if (
|
||||||
|
!isStale &&
|
||||||
|
!IssueProcessor.updatedSince(
|
||||||
|
issue.updated_at,
|
||||||
|
this.options.daysBeforeStale
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
core.debug(
|
||||||
|
`Marking ${issueType} stale because it was last updated on ${issue.updated_at} and it does not have a stale label`
|
||||||
|
);
|
||||||
|
await this.markStale(issue, staleMessage, staleLabel);
|
||||||
|
this.operationsLeft -= 2;
|
||||||
|
isStale = true; // this issue is now considered stale
|
||||||
|
}
|
||||||
|
|
||||||
|
// process any issues marked stale (including the issue above, if it was marked)
|
||||||
|
if (isStale) {
|
||||||
|
core.debug(`Found a stale ${issueType}`);
|
||||||
|
await this.processStaleIssue(issue, issueType, staleLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// do the next batch
|
||||||
|
return this.processIssues(page + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle all of the stale issue logic when we find a stale issue
|
||||||
|
private async processStaleIssue(
|
||||||
|
issue: Issue,
|
||||||
|
issueType: string,
|
||||||
|
staleLabel: string
|
||||||
|
) {
|
||||||
|
if (this.options.daysBeforeClose < 0) {
|
||||||
|
return; // nothing to do because we aren't closing stale issues
|
||||||
|
}
|
||||||
|
|
||||||
|
const markedStaleOn: string = await this.getLabelCreationDate(
|
||||||
|
issue,
|
||||||
|
staleLabel
|
||||||
|
);
|
||||||
|
const issueHasComments: boolean = await this.isIssueStillStale(
|
||||||
|
issue,
|
||||||
|
markedStaleOn
|
||||||
|
);
|
||||||
|
|
||||||
|
const issueHasUpdate: boolean = IssueProcessor.updatedSince(
|
||||||
|
issue.updated_at,
|
||||||
|
this.options.daysBeforeClose
|
||||||
|
);
|
||||||
|
|
||||||
|
core.debug(`Issue #${issue.number} marked stale on: ${markedStaleOn}`);
|
||||||
|
core.debug(`Issue #${issue.number} has been updated: ${issueHasUpdate}`);
|
||||||
|
core.debug(
|
||||||
|
`Issue #${issue.number} has been commented on: ${issueHasComments}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!issueHasComments && !issueHasUpdate) {
|
||||||
|
core.debug(
|
||||||
|
`Closing ${issueType} because it was last updated on ${issue.updated_at}`
|
||||||
|
);
|
||||||
|
await this.closeIssue(issue);
|
||||||
|
} else {
|
||||||
|
if (this.options.removeStaleWhenUpdated) {
|
||||||
|
await this.removeLabel(issue, staleLabel);
|
||||||
|
}
|
||||||
|
core.debug(`Ignoring stale ${issueType} because it was updated recenlty`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// checks to see if a given issue is still stale (has had activity on it)
|
||||||
|
private async isIssueStillStale(
|
||||||
|
issue: Issue,
|
||||||
|
sinceDate: string
|
||||||
|
): Promise<boolean> {
|
||||||
|
core.debug(
|
||||||
|
`Checking for comments on issue #${issue.number} since ${sinceDate} to see if it is still stale`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!sinceDate) {
|
||||||
|
return true; // if no date was provided then the issue was marked stale a long time ago
|
||||||
|
}
|
||||||
|
|
||||||
|
this.operationsLeft -= 1;
|
||||||
|
|
||||||
|
// find any comments since the stale label
|
||||||
|
const comments = await this.listIssueComments(issue.number, sinceDate);
|
||||||
|
|
||||||
|
// if there are any user comments returned, issue is not stale anymore
|
||||||
|
return comments.filter(comment => comment.user.type === 'User').length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// grab comments for an issue since a given date
|
||||||
|
private async listIssueComments(
|
||||||
|
issueNumber: number,
|
||||||
|
sinceDate: string
|
||||||
|
): Promise<Comment[]> {
|
||||||
|
// find any comments since date on the given issue
|
||||||
|
const comments = await this.client.issues.listComments({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
since: sinceDate
|
||||||
|
});
|
||||||
|
|
||||||
|
return comments.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// grab issues from github in baches of 100
|
||||||
|
private async getIssues(page: number): Promise<Issue[]> {
|
||||||
|
const issueResult: OctoKitIssueList = await this.client.issues.listForRepo({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
state: 'open',
|
||||||
|
labels: this.options.onlyLabels,
|
||||||
|
per_page: 100,
|
||||||
|
page
|
||||||
|
});
|
||||||
|
|
||||||
|
return issueResult.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark an issue as stale with a comment and a label
|
||||||
|
private async markStale(
|
||||||
|
issue: Issue,
|
||||||
|
staleMessage: string,
|
||||||
|
staleLabel: string
|
||||||
|
): Promise<void> {
|
||||||
|
core.debug(`Marking issue #${issue.number} - ${issue.title} as stale`);
|
||||||
|
|
||||||
|
this.staleIssues.push(issue);
|
||||||
|
|
||||||
|
this.operationsLeft -= 2;
|
||||||
|
|
||||||
|
if (this.options.debugOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.client.issues.createComment({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
body: staleMessage
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.client.issues.addLabels({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
labels: [staleLabel]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close an issue based on staleness
|
||||||
|
private async closeIssue(issue: Issue): Promise<void> {
|
||||||
|
core.debug(
|
||||||
|
`Closing issue #${issue.number} - ${issue.title} for being stale`
|
||||||
|
);
|
||||||
|
|
||||||
|
this.closedIssues.push(issue);
|
||||||
|
|
||||||
|
this.operationsLeft -= 1;
|
||||||
|
|
||||||
|
if (this.options.debugOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.client.issues.update({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
state: 'closed'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove a label from an issue
|
||||||
|
private async removeLabel(issue: Issue, label: string): Promise<void> {
|
||||||
|
core.debug(
|
||||||
|
`Removing label ${label} from issue #${issue.number} - ${issue.title}`
|
||||||
|
);
|
||||||
|
|
||||||
|
this.removedLabelIssues.push(issue);
|
||||||
|
|
||||||
|
this.operationsLeft -= 1;
|
||||||
|
|
||||||
|
if (this.options.debugOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.client.issues.removeLabel({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
name: encodeURIComponent(label) // A label can have a "?" in the name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the creation date of a given label on an issue (or nothing if no label existed)
|
||||||
|
///see https://developer.github.com/v3/activity/events/
|
||||||
|
private async getLabelCreationDate(
|
||||||
|
issue: Issue,
|
||||||
|
label: string
|
||||||
|
): Promise<string> {
|
||||||
|
core.debug(`Checking for label ${label} on issue #${issue.number}`);
|
||||||
|
|
||||||
|
this.operationsLeft -= 1;
|
||||||
|
|
||||||
|
const options = this.client.issues.listEvents.endpoint.merge({
|
||||||
|
owner: github.context.repo.owner,
|
||||||
|
repo: github.context.repo.repo,
|
||||||
|
per_page: 100,
|
||||||
|
issue_number: issue.number
|
||||||
|
});
|
||||||
|
|
||||||
|
const events: IssueEvent[] = await this.client.paginate(options);
|
||||||
|
const reversedEvents = events.reverse();
|
||||||
|
|
||||||
|
const staleLabeledEvent = reversedEvents.find(
|
||||||
|
event => event.event === 'labeled' && event.label.name === label
|
||||||
|
);
|
||||||
|
|
||||||
|
return staleLabeledEvent!.created_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static isLabeled(issue: Issue, label: string): boolean {
|
||||||
|
const labelComparer: (l: Label) => boolean = l =>
|
||||||
|
label.localeCompare(l.name, undefined, {sensitivity: 'accent'}) === 0;
|
||||||
|
return issue.labels.filter(labelComparer).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static updatedSince(timestamp: string, num_days: number): boolean {
|
||||||
|
const daysInMillis = 1000 * 60 * 60 * 24 * num_days;
|
||||||
|
const millisSinceLastUpdated =
|
||||||
|
new Date().getTime() - new Date(timestamp).getTime();
|
||||||
|
|
||||||
|
return millisSinceLastUpdated < daysInMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static parseCommaSeparatedString(s: string): string[] {
|
||||||
|
// String.prototype.split defaults to [''] when called on an empty string
|
||||||
|
// In this case, we'd prefer to just return an empty array indicating no labels
|
||||||
|
if (!s.length) return [];
|
||||||
|
return s.split(',').map(l => l.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
147
src/main.ts
147
src/main.ts
@@ -1,145 +1,19 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as github from '@actions/github';
|
import {IssueProcessor, IssueProcessorOptions} from './IssueProcessor';
|
||||||
import * as Octokit from '@octokit/rest';
|
|
||||||
|
|
||||||
type Issue = Octokit.IssuesListForRepoResponseItem;
|
async function run(): Promise<void> {
|
||||||
type IssueLabel = Octokit.IssuesListForRepoResponseItemLabelsItem;
|
|
||||||
|
|
||||||
type Args = {
|
|
||||||
repoToken: string;
|
|
||||||
staleIssueMessage: string;
|
|
||||||
stalePrMessage: string;
|
|
||||||
daysBeforeStale: number;
|
|
||||||
daysBeforeClose: number;
|
|
||||||
staleIssueLabel: string;
|
|
||||||
stalePrLabel: string;
|
|
||||||
operationsPerRun: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
async function run() {
|
|
||||||
try {
|
try {
|
||||||
const args = getAndValidateArgs();
|
const args = getAndValidateArgs();
|
||||||
|
|
||||||
const client = new github.GitHub(args.repoToken);
|
const processor: IssueProcessor = new IssueProcessor(args);
|
||||||
await processIssues(client, args, args.operationsPerRun);
|
await processor.processIssues();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processIssues(
|
function getAndValidateArgs(): IssueProcessorOptions {
|
||||||
client: github.GitHub,
|
|
||||||
args: Args,
|
|
||||||
operationsLeft: number,
|
|
||||||
page: number = 1
|
|
||||||
): Promise<number> {
|
|
||||||
const issues = await client.issues.listForRepo({
|
|
||||||
owner: github.context.repo.owner,
|
|
||||||
repo: github.context.repo.repo,
|
|
||||||
state: 'open',
|
|
||||||
per_page: 100,
|
|
||||||
page: page
|
|
||||||
});
|
|
||||||
|
|
||||||
operationsLeft -= 1;
|
|
||||||
|
|
||||||
if (issues.data.length === 0 || operationsLeft === 0) {
|
|
||||||
return operationsLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var issue of issues.data.values()) {
|
|
||||||
core.debug(`found issue: ${issue.title} last updated ${issue.updated_at}`);
|
|
||||||
let isPr = !!issue.pull_request;
|
|
||||||
|
|
||||||
let staleMessage = isPr ? args.stalePrMessage : args.staleIssueMessage;
|
|
||||||
if (!staleMessage) {
|
|
||||||
core.debug(`skipping ${isPr ? 'pr' : 'issue'} due to empty message`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let staleLabel = isPr ? args.stalePrLabel : args.staleIssueLabel;
|
|
||||||
|
|
||||||
if (isLabeledStale(issue, staleLabel)) {
|
|
||||||
if (wasLastUpdatedBefore(issue, args.daysBeforeClose)) {
|
|
||||||
operationsLeft -= await closeIssue(client, issue);
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if (wasLastUpdatedBefore(issue, args.daysBeforeStale)) {
|
|
||||||
operationsLeft -= await markStale(
|
|
||||||
client,
|
|
||||||
issue,
|
|
||||||
staleMessage,
|
|
||||||
staleLabel
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (operationsLeft <= 0) {
|
|
||||||
core.warning(
|
|
||||||
`performed ${args.operationsPerRun} operations, exiting to avoid rate limit`
|
|
||||||
);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return await processIssues(client, args, operationsLeft, page + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isLabeledStale(issue: Issue, label: string): boolean {
|
|
||||||
const labelComparer: (l: IssueLabel) => boolean = l =>
|
|
||||||
label.localeCompare(l.name, undefined, {sensitivity: 'accent'}) === 0;
|
|
||||||
return issue.labels.filter(labelComparer).length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function wasLastUpdatedBefore(issue: Issue, num_days: number): boolean {
|
|
||||||
const daysInMillis = 1000 * 60 * 60 * 24 * num_days;
|
|
||||||
const millisSinceLastUpdated =
|
|
||||||
new Date().getTime() - new Date(issue.updated_at).getTime();
|
|
||||||
return millisSinceLastUpdated >= daysInMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function markStale(
|
|
||||||
client: github.GitHub,
|
|
||||||
issue: Issue,
|
|
||||||
staleMessage: string,
|
|
||||||
staleLabel: string
|
|
||||||
): Promise<number> {
|
|
||||||
core.debug(`marking issue${issue.title} as stale`);
|
|
||||||
|
|
||||||
await client.issues.createComment({
|
|
||||||
owner: github.context.repo.owner,
|
|
||||||
repo: github.context.repo.repo,
|
|
||||||
issue_number: issue.number,
|
|
||||||
body: staleMessage
|
|
||||||
});
|
|
||||||
|
|
||||||
await client.issues.addLabels({
|
|
||||||
owner: github.context.repo.owner,
|
|
||||||
repo: github.context.repo.repo,
|
|
||||||
issue_number: issue.number,
|
|
||||||
labels: [staleLabel]
|
|
||||||
});
|
|
||||||
|
|
||||||
return 2; // operations performed
|
|
||||||
}
|
|
||||||
|
|
||||||
async function closeIssue(
|
|
||||||
client: github.GitHub,
|
|
||||||
issue: Issue
|
|
||||||
): Promise<number> {
|
|
||||||
core.debug(`closing issue ${issue.title} for being stale`);
|
|
||||||
|
|
||||||
await client.issues.update({
|
|
||||||
owner: github.context.repo.owner,
|
|
||||||
repo: github.context.repo.repo,
|
|
||||||
issue_number: issue.number,
|
|
||||||
state: 'closed'
|
|
||||||
});
|
|
||||||
|
|
||||||
return 1; // operations performed
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAndValidateArgs(): Args {
|
|
||||||
const args = {
|
const args = {
|
||||||
repoToken: core.getInput('repo-token', {required: true}),
|
repoToken: core.getInput('repo-token', {required: true}),
|
||||||
staleIssueMessage: core.getInput('stale-issue-message'),
|
staleIssueMessage: core.getInput('stale-issue-message'),
|
||||||
@@ -151,13 +25,20 @@ function getAndValidateArgs(): Args {
|
|||||||
core.getInput('days-before-close', {required: true})
|
core.getInput('days-before-close', {required: true})
|
||||||
),
|
),
|
||||||
staleIssueLabel: core.getInput('stale-issue-label', {required: true}),
|
staleIssueLabel: core.getInput('stale-issue-label', {required: true}),
|
||||||
|
exemptIssueLabels: core.getInput('exempt-issue-labels'),
|
||||||
stalePrLabel: core.getInput('stale-pr-label', {required: true}),
|
stalePrLabel: core.getInput('stale-pr-label', {required: true}),
|
||||||
|
exemptPrLabels: core.getInput('exempt-pr-labels'),
|
||||||
|
onlyLabels: core.getInput('only-labels'),
|
||||||
operationsPerRun: parseInt(
|
operationsPerRun: parseInt(
|
||||||
core.getInput('operations-per-run', {required: true})
|
core.getInput('operations-per-run', {required: true})
|
||||||
)
|
),
|
||||||
|
removeStaleWhenUpdated: !(
|
||||||
|
core.getInput('remove-stale-when-updated') === 'false'
|
||||||
|
),
|
||||||
|
debugOnly: core.getInput('debug-only') === 'true'
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var numberInput of [
|
for (const numberInput of [
|
||||||
'days-before-stale',
|
'days-before-stale',
|
||||||
'days-before-close',
|
'days-before-close',
|
||||||
'operations-per-run'
|
'operations-per-run'
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,63 +1,13 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
/* Basic Options */
|
|
||||||
// "incremental": true, /* Enable incremental compilation */
|
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
|
||||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
||||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
||||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
||||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
||||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
||||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
"outDir": "./lib", /* Redirect output structure to the directory. */
|
||||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
// "composite": true, /* Enable project compilation */
|
|
||||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
||||||
// "removeComments": true, /* Do not emit comments to output. */
|
|
||||||
// "noEmit": true, /* Do not emit outputs. */
|
|
||||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
||||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
||||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
||||||
|
|
||||||
/* Strict Type-Checking Options */
|
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
//"sourceMap": true
|
||||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
||||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
||||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
||||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
||||||
|
|
||||||
/* Additional Checks */
|
|
||||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
||||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
||||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
||||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
||||||
|
|
||||||
/* Module Resolution Options */
|
|
||||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
||||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
||||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
||||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
||||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
||||||
// "types": [], /* Type declaration files to be included in compilation. */
|
|
||||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
||||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
||||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
||||||
|
|
||||||
/* Source Map Options */
|
|
||||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
||||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
||||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
||||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
||||||
|
|
||||||
/* Experimental Options */
|
|
||||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
||||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
"exclude": ["node_modules", "**/*.test.ts"]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user