diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index ba38c13..9acbabb 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: sha256:1d25dfefd805b689a2a2356d35a25b13f2f67bcce55400246432c43a42e96214 -# created: 2022-04-05T22:42:50.409517925Z + digest: sha256:b9e4584a1fe3c749e3c37c92497b13dce653b2e694f0261f0610eb0e15941357 +# created: 2022-05-05T21:08:42.530332893Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml index 49cf942..4cd91cc 100644 --- a/.github/auto-approve.yml +++ b/.github/auto-approve.yml @@ -1,12 +1,3 @@ -rules: -- author: "release-please[bot]" - title: "^chore: release" - changedFiles: - - "package\\.json$" - - "CHANGELOG\\.md$" - maxFiles: 3 -- author: "renovate-bot" - title: "^(fix|chore)\\(deps\\):" - changedFiles: - - "package\\.json$" - maxFiles: 2 +processes: + - "NodeDependency" + - "OwlBotTemplateChanges" diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml new file mode 100644 index 0000000..d1e8b5e --- /dev/null +++ b/.github/sync-repo-settings.yaml @@ -0,0 +1,17 @@ +branchProtectionRules: + - pattern: main + isAdminEnforced: true + requiredApprovingReviewCount: 1 + requiresCodeOwnerReviews: true + requiresStrictStatusChecks: false + requiredStatusCheckContexts: + - "ci/kokoro: Samples test" + - "ci/kokoro: System test" + - docs + - lint + - test (12) + - test (14) + - test (16) + - cla/google + - windows + - OwlBot Post Processor diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1edb206..f447b84 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,9 +9,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [10, 12, 14, 16] + node: [12, 14, 16] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} @@ -29,7 +29,7 @@ jobs: windows: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 14 @@ -40,7 +40,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 14 @@ -49,7 +49,7 @@ jobs: docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 14 diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg index 27cafe0..00f70ce 100644 --- a/.kokoro/common.cfg +++ b/.kokoro/common.cfg @@ -16,7 +16,7 @@ build_file: "github-repo-automation/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" diff --git a/.kokoro/continuous/node10/common.cfg b/.kokoro/continuous/node10/common.cfg deleted file mode 100644 index cacf8eb..0000000 --- a/.kokoro/continuous/node10/common.cfg +++ /dev/null @@ -1,34 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Bring in codecov.io token into the build as $KOKORO_KEYSTORE_DIR/73713_dpebot_codecov_token -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "dpebot_codecov_token" - } - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "github-repo-automation/.kokoro/trampoline_v2.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/github-repo-automation/.kokoro/test.sh" -} diff --git a/.kokoro/continuous/node10/docs.cfg b/.kokoro/continuous/node10/docs.cfg deleted file mode 100644 index 479ba98..0000000 --- a/.kokoro/continuous/node10/docs.cfg +++ /dev/null @@ -1,4 +0,0 @@ -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/github-repo-automation/.kokoro/docs.sh" -} diff --git a/.kokoro/continuous/node10/test.cfg b/.kokoro/continuous/node10/test.cfg deleted file mode 100644 index 609c0cf..0000000 --- a/.kokoro/continuous/node10/test.cfg +++ /dev/null @@ -1,9 +0,0 @@ -# Bring in codecov.io token into the build as $KOKORO_KEYSTORE_DIR/73713_dpebot_codecov_token -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "dpebot_codecov_token" - } - } -} diff --git a/.kokoro/continuous/node8/common.cfg b/.kokoro/continuous/node8/common.cfg deleted file mode 100644 index e047293..0000000 --- a/.kokoro/continuous/node8/common.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "github-repo-automation/.kokoro/trampoline.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/github-repo-automation/.kokoro/test.sh" -} diff --git a/.kokoro/continuous/node8/test.cfg b/.kokoro/continuous/node8/test.cfg deleted file mode 100644 index e69de29..0000000 diff --git a/.kokoro/presubmit/node10/common.cfg b/.kokoro/presubmit/node10/common.cfg deleted file mode 100644 index cacf8eb..0000000 --- a/.kokoro/presubmit/node10/common.cfg +++ /dev/null @@ -1,34 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Bring in codecov.io token into the build as $KOKORO_KEYSTORE_DIR/73713_dpebot_codecov_token -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "dpebot_codecov_token" - } - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "github-repo-automation/.kokoro/trampoline_v2.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/github-repo-automation/.kokoro/test.sh" -} diff --git a/.kokoro/presubmit/node10/docs.cfg b/.kokoro/presubmit/node10/docs.cfg deleted file mode 100644 index 479ba98..0000000 --- a/.kokoro/presubmit/node10/docs.cfg +++ /dev/null @@ -1,4 +0,0 @@ -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/github-repo-automation/.kokoro/docs.sh" -} diff --git a/.kokoro/presubmit/node10/lint.cfg b/.kokoro/presubmit/node10/lint.cfg deleted file mode 100644 index 8ad71e0..0000000 --- a/.kokoro/presubmit/node10/lint.cfg +++ /dev/null @@ -1,4 +0,0 @@ -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/github-repo-automation/.kokoro/lint.sh" -} diff --git a/.kokoro/presubmit/node10/test.cfg b/.kokoro/presubmit/node10/test.cfg deleted file mode 100644 index e69de29..0000000 diff --git a/.kokoro/presubmit/node8/common.cfg b/.kokoro/presubmit/node8/common.cfg deleted file mode 100644 index e047293..0000000 --- a/.kokoro/presubmit/node8/common.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "github-repo-automation/.kokoro/trampoline.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/github-repo-automation/.kokoro/test.sh" -} diff --git a/.kokoro/presubmit/node8/test.cfg b/.kokoro/presubmit/node8/test.cfg deleted file mode 100644 index e69de29..0000000 diff --git a/.kokoro/release/docs.cfg b/.kokoro/release/docs.cfg index c639fb5..82bccfc 100644 --- a/.kokoro/release/docs.cfg +++ b/.kokoro/release/docs.cfg @@ -11,7 +11,7 @@ before_action { # doc publications use a Python image. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" } # Download trampoline resources. diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index f249d3e..fbc058a 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -56,7 +56,7 @@ fi # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=10 +COVERAGE_NODE=12 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index 0a84045..87fa065 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -49,7 +49,7 @@ npm run system-test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=10 +COVERAGE_NODE=12 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/test.sh b/.kokoro/test.sh index af1ce7e..a5c7ac0 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -39,7 +39,7 @@ npm test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=10 +COVERAGE_NODE=12 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/CHANGELOG.md b/CHANGELOG.md index 75c508f..603b2d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ [1]: https://www.npmjs.com/package/@google/repo?activeTab=versions +## [5.0.0](https://github.com/googleapis/github-repo-automation/compare/v4.8.1...v5.0.0) (2022-05-19) + + +### ⚠ BREAKING CHANGES + +* update library to use Node 12 (#595) + +### Build System + +* update library to use Node 12 ([#595](https://github.com/googleapis/github-repo-automation/issues/595)) ([a10f39d](https://github.com/googleapis/github-repo-automation/commit/a10f39dcb2cfc3f7a39c0c22b76509dc55d7b3ee)) + ### [4.8.1](https://github.com/googleapis/github-repo-automation/compare/v4.8.0...v4.8.1) (2022-04-12) diff --git a/package.json b/package.json index 23e47a5..a8af60b 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "@google/repo", - "version": "4.8.1", + "version": "5.0.0", "repository": "googleapis/github-repo-automation", "description": "A tool for automating multiple GitHub repositories.", "engines": { - "node": ">=10.0.0" + "node": ">=12.0.0" }, "bin": { "repo": "build/src/cli.js" @@ -33,19 +33,20 @@ "devDependencies": { "@compodoc/compodoc": "^1.1.11", "@types/js-yaml": "^4.0.0", - "@types/mocha": "^8.0.0", + "@types/meow": "^6.0.0", + "@types/mocha": "^9.0.0", "@types/node": "^16.0.0", "@types/proxyquire": "^1.3.28", "@types/sinon": "^10.0.0", "@types/update-notifier": "^5.0.0", "c8": "^7.1.0", - "gts": "^3.0.0", + "gts": "^3.1.0", "linkinator": "^2.0.4", - "mocha": "^8.0.0", + "mocha": "^9.2.2", "nock": "^13.0.0", "proxyquire": "^2.1.3", - "sinon": "^13.0.0", - "typescript": "~3.8.3" + "sinon": "^14.0.0", + "typescript": "^4.6.4" }, "scripts": { "lint": "gts check", diff --git a/samples/package.json b/samples/package.json index 8bb1534..51c3f97 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "license": "Apache-2.0", "author": "Google LLC", "engines": { - "node": ">=8" + "node": ">=12.0.0" }, "files": [ "*.js" @@ -14,7 +14,7 @@ "test": "mocha system-test" }, "dependencies": { - "@google/repo": "^4.8.1" + "@google/repo": "^5.0.0" }, "devDependencies": { "mocha": "^8.0.0" diff --git a/src/approve-prs.ts b/src/approve-prs.ts index 8d5ce9e..aba5653 100644 --- a/src/approve-prs.ts +++ b/src/approve-prs.ts @@ -30,7 +30,7 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) { return true; } -export async function approve(cli: meow.Result) { +export async function approve(cli: meow.Result) { return processPRs(cli, { commandName: 'approve', commandNamePastTense: 'approved', diff --git a/src/cli.ts b/src/cli.ts index e0a1999..00c188f 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -71,7 +71,7 @@ export const meowFlags: { author: {type: 'string'}, yespleasedoit: {type: 'boolean'}, }; -const meowOptions: meow.Options = { +const meowOptions: meow.Options = { flags: meowFlags, }; diff --git a/src/lib/asyncItemIterator.ts b/src/lib/asyncItemIterator.ts index c217cc9..617ab98 100644 --- a/src/lib/asyncItemIterator.ts +++ b/src/lib/asyncItemIterator.ts @@ -39,7 +39,7 @@ async function retryException( return result; } catch (err) { if (i < retryStrategy.length) { - debug(`operation failed: ${err.toString()}`); + debug(`operation failed: ${(err as Error).toString()}`); const delay = nextDelay(retryStrategy[i]); debug(`retrying in ${delay}ms`); await delayMs(delay); @@ -99,7 +99,7 @@ export interface PRIteratorOptions extends IteratorOptions { processMethod: ( repository: GitHubRepository, item: PullRequest, - cli: meow.Result + cli: meow.Result ) => Promise; } @@ -107,7 +107,7 @@ export interface IssueIteratorOptions extends IteratorOptions { processMethod: ( repository: GitHubRepository, item: Issue, - cli: meow.Result + cli: meow.Result ) => Promise; } @@ -126,7 +126,7 @@ export interface IteratorOptions { * @param {string[]} args Command line arguments. */ async function process( - cli: meow.Result, + cli: meow.Result, options: PRIteratorOptions | IssueIteratorOptions, processIssues = false ) { @@ -206,9 +206,9 @@ async function process( scanned++; orb1.text = `[${scanned}/${repos.length}] Scanning repos for PRs`; } catch (err) { - error = `cannot list open ${ - processIssues ? 'issue' : 'PR' - }s: ${err.toString()}`; + error = `cannot list open ${processIssues ? 'issue' : 'PR'}s: ${( + err as Error + ).toString()}`; } }; }) @@ -343,7 +343,7 @@ async function process( // Shorthand for processing list of PRs: export async function processPRs( - cli: meow.Result, + cli: meow.Result, options: PRIteratorOptions | IssueIteratorOptions ) { return process(cli, options, false); @@ -351,7 +351,7 @@ export async function processPRs( // Shorthand for processing list of issues: export async function processIssues( - cli: meow.Result, + cli: meow.Result, options: PRIteratorOptions | IssueIteratorOptions ) { return process(cli, options, true); diff --git a/src/lib/update-file-in-branch.ts b/src/lib/update-file-in-branch.ts index cb07859..ffbb7df 100644 --- a/src/lib/update-file-in-branch.ts +++ b/src/lib/update-file-in-branch.ts @@ -44,7 +44,7 @@ async function processRepository( } catch (err) { console.warn( ' cannot get file, skipping this repository:', - err.toString() + (err as Error).toString() ); return; } @@ -75,7 +75,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot commit file ${path} to branch ${branch}, skipping this repository:`, - err.toString() + (err as Error).toString() ); return; } diff --git a/src/lib/update-file.ts b/src/lib/update-file.ts index 602dd3b..23c0325 100644 --- a/src/lib/update-file.ts +++ b/src/lib/update-file.ts @@ -48,7 +48,7 @@ async function processRepository( } catch (err) { console.warn( ' cannot get file, skipping this repository:', - err.toString() + (err as Error).toString() ); return; } @@ -74,7 +74,7 @@ async function processRepository( } catch (err) { console.warn( ' cannot get sha of latest commit, skipping this repository:', - err.toString() + (err as Error).toString() ); return; } @@ -85,7 +85,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot create branch ${branch}, skipping this repository:`, - err.toString() + (err as Error).toString() ); return; } @@ -101,7 +101,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot commit file ${path} to branch ${branch}, skipping this repository:`, - err.toString() + (err as Error).toString() ); return; } @@ -112,7 +112,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot create pull request for branch ${branch} -> base ${repository.baseBranch}! Branch is still there.`, - err.toString() + (err as Error).toString() ); return; } @@ -125,7 +125,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot request review for pull request #${pullRequestNumber}! Pull request is still there.`, - err.toString() + (err as Error).toString() ); return; } diff --git a/src/lib/update-repo.ts b/src/lib/update-repo.ts index 8c8951f..1116c5e 100644 --- a/src/lib/update-repo.ts +++ b/src/lib/update-repo.ts @@ -61,7 +61,7 @@ async function processRepository( } catch (err) { console.warn( ' callback function threw an exception, skipping this repository', - err ? err.stack : '' + err ? (err as Error).stack : '' ); return; } @@ -85,7 +85,7 @@ async function processRepository( } catch (err) { console.warn( ' cannot get sha of latest commit, skipping this repository:', - err.toString() + (err as Error).toString() ); return; } @@ -96,7 +96,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot create branch ${branch}, skipping this repository:`, - err.toString() + (err as Error).toString() ); return; } @@ -120,7 +120,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot read file ${filePath}, skipping this repository:`, - err.toString() + (err as Error).toString() ); return; } @@ -147,7 +147,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot commit file ${filePath} to branch ${branch}, skipping this repository:`, - err.toString() + (err as Error).toString() ); return; } @@ -159,7 +159,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot create pull request for branch ${branch}! Branch is still there.`, - err.toString() + (err as Error).toString() ); return; } @@ -172,7 +172,7 @@ async function processRepository( } catch (err) { console.warn( ` cannot request review for pull request #${pullRequestNumber}! Pull request is still there.`, - err.toString() + (err as Error).toString() ); return; } diff --git a/src/list-issues.ts b/src/list-issues.ts index a2a84e8..62acdb4 100644 --- a/src/list-issues.ts +++ b/src/list-issues.ts @@ -22,7 +22,7 @@ async function processMethod(repository: GitHubRepository, issue: Issue) { return true; } -export async function listIssues(cli: meow.Result) { +export async function listIssues(cli: meow.Result) { return processIssues(cli, { commandName: 'list-issues', commandNamePastTense: 'listed', diff --git a/src/list-prs.ts b/src/list-prs.ts index da71a0b..0cb78f9 100644 --- a/src/list-prs.ts +++ b/src/list-prs.ts @@ -16,7 +16,7 @@ import * as meow from 'meow'; import {meowFlags} from './cli'; import {processPRs} from './lib/asyncItemIterator'; -export async function list(cli: meow.Result) { +export async function list(cli: meow.Result) { return processPRs(cli, { commandName: 'list', commandNamePastTense: 'listed', diff --git a/src/merge-prs.ts b/src/merge-prs.ts index 7188298..bf505d1 100644 --- a/src/merge-prs.ts +++ b/src/merge-prs.ts @@ -19,7 +19,6 @@ */ import * as meow from 'meow'; -import {meowFlags} from './cli'; import {GitHubRepository, PullRequest} from './lib/github'; import {processPRs} from './lib/asyncItemIterator'; @@ -34,7 +33,7 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) { } catch (err) { console.warn( ' cannot get sha of latest commit to the base branch, skipping:', - err.toString() + (err as Error).toString() ); return false; } @@ -48,7 +47,7 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) { } catch (err) { console.warn( ` cannot update branch for PR ${htmlUrl}, skipping:`, - err.toString() + (err as Error).toString() ); return false; } @@ -70,7 +69,7 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) { return true; } -export async function merge(cli: meow.Result) { +export async function merge(cli: meow.Result) { if (!cli.flags.yespleasedoit) { console.error('repo merge might do bad things if you are an admin.'); console.error('It might ignore your CI and merge some bad code.'); diff --git a/src/reject-prs.ts b/src/reject-prs.ts index f7e7d03..020b82f 100644 --- a/src/reject-prs.ts +++ b/src/reject-prs.ts @@ -27,13 +27,16 @@ import {processPRs} from './lib/asyncItemIterator'; async function processMethod( repository: GitHubRepository, pr: PullRequest, - cli: meow.Result + cli: meow.Result ) { const ref = pr.head.ref; try { await repository.closePullRequest(pr); } catch (err) { - console.warn(' cannot close pull request, skipping:', err.toString()); + console.warn( + ' cannot close pull request, skipping:', + (err as Error).toString() + ); return false; } @@ -52,7 +55,7 @@ async function processMethod( return true; } -export async function reject(cli: meow.Result) { +export async function reject(cli: meow.Result) { return processPRs(cli, { commandName: 'reject', commandActive: 'rejecting', diff --git a/src/rename-prs.ts b/src/rename-prs.ts index dcf89fd..7eb649a 100644 --- a/src/rename-prs.ts +++ b/src/rename-prs.ts @@ -25,7 +25,7 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) { return true; } -export async function rename(cli: meow.Result) { +export async function rename(cli: meow.Result) { if (cli.input.length < 2) { console.log('New title name must present.'); return; diff --git a/src/repo-check.ts b/src/repo-check.ts index 33db43c..b0c3f11 100644 --- a/src/repo-check.ts +++ b/src/repo-check.ts @@ -174,7 +174,9 @@ async function checkSamplesPackageDependency( }); } catch (err) { logger.error( - `${repository.name}: [!] cannot download package.json: ${err.toString()}` + `${repository.name}: [!] cannot download package.json: ${( + err as Error + ).toString()}` ); return; } @@ -202,9 +204,9 @@ async function checkSamplesPackageDependency( } } catch (err) { logger.error( - `${ - repository.name - }: cannot check samples package dependencies: ${err.toString()}` + `${repository.name}: cannot check samples package dependencies: ${( + err as Error + ).toString()}` ); } } @@ -223,7 +225,9 @@ async function checkReadmeLinks(logger: Logger, repository: GitHubRepository) { }); } catch (err) { logger.error( - `${repository.name}: [!] cannot download README.md: ${err.toString()}` + `${repository.name}: [!] cannot download README.md: ${( + err as Error + ).toString()}` ); return; } diff --git a/src/sync.ts b/src/sync.ts index 9af4139..e4b48b2 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -49,7 +49,7 @@ function print(res: {stdout: string; stderr: string}) { * Clone all repositories into ~/.repo. * If repo already exists, fetch and reset. */ -export async function sync(cli: meow.Result) { +export async function sync(cli: meow.Result) { const repos = await getRepos(); const rootPath = await getRootPath(); const dirs = await readdir(rootPath); @@ -81,7 +81,7 @@ export async function sync(cli: meow.Result) { orb.succeed('Repo sync complete.'); } -export async function exec(cli: meow.Result) { +export async function exec(cli: meow.Result) { const command = cli.input.slice(1); const rootPath = await getRootPath(); diff --git a/src/tag-prs.ts b/src/tag-prs.ts index 117ccfa..1630d0a 100644 --- a/src/tag-prs.ts +++ b/src/tag-prs.ts @@ -21,18 +21,21 @@ import {processPRs} from './lib/asyncItemIterator'; async function processMethod( repository: GitHubRepository, pr: PullRequest, - cli: meow.Result + cli: meow.Result ) { try { await repository.tagPullRequest(pr, cli.input.slice(1)); } catch (err) { - console.warn(` error trying to tag PR ${pr.html_url}:`, err.toString()); + console.warn( + ` error trying to tag PR ${pr.html_url}:`, + (err as Error).toString() + ); return false; } return true; } -export async function tag(cli: meow.Result) { +export async function tag(cli: meow.Result) { return processPRs(cli, { commandName: 'tag', commandActive: 'tagging', diff --git a/src/untag-prs.ts b/src/untag-prs.ts index bcb7745..a7b0232 100644 --- a/src/untag-prs.ts +++ b/src/untag-prs.ts @@ -26,14 +26,14 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) { } catch (err) { console.warn( ` error trying to untag PR ${pr.html_url}:`, - err.toString() + (err as Error).toString() ); return false; } return true; } -export async function untag(cli: meow.Result) { +export async function untag(cli: meow.Result) { name = cli.input[1]; return processPRs(cli, { commandName: 'untag', diff --git a/src/update-prs.ts b/src/update-prs.ts index c66df66..d9b8892 100644 --- a/src/update-prs.ts +++ b/src/update-prs.ts @@ -19,7 +19,6 @@ */ import * as meow from 'meow'; -import {meowFlags} from './cli'; import {GitHubRepository, PullRequest} from './lib/github'; import {processPRs} from './lib/asyncItemIterator'; @@ -35,7 +34,7 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) { } catch (err) { console.warn( ' cannot get sha of latest commit to the base branch, skipping:', - err.toString() + (err as Error).toString() ); return false; } @@ -47,7 +46,7 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) { } catch (err) { console.warn( ` cannot update branch for PR ${htmlUrl}, skipping:`, - err.toString() + (err as Error).toString() ); return false; } @@ -56,7 +55,7 @@ async function processMethod(repository: GitHubRepository, pr: PullRequest) { return true; } -export async function update(cli: meow.Result) { +export async function update(cli: meow.Result) { return processPRs(cli, { commandName: 'update', commandActive: 'updating', diff --git a/test/config.ts b/test/config.ts index 2c1e586..58b1908 100644 --- a/test/config.ts +++ b/test/config.ts @@ -90,7 +90,6 @@ describe('Config', () => { console.error = () => {}; getConfig('./config3.yaml').catch(err => { assert(err instanceof Error); - delete console.error; done(); }); });