From 2d221c69f4c827a4f03ead513cf77b2f61e00ca2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 10:28:11 -0700 Subject: [PATCH 01/10] chore: bump @npmcli/template-oss from 2.9.2 to 3.2.0 (#135) * chore: bump @npmcli/template-oss from 2.9.2 to 3.2.0 Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 2.9.2 to 3.2.0. - [Release notes](https://github.com/npm/template-oss/releases) - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/template-oss/compare/v2.9.2...v3.2.0) --- updated-dependencies: - dependency-name: "@npmcli/template-oss" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * chore: postinstall for dependabot template-oss PR Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Gar --- .commitlintrc.js | 5 +- .eslintrc.js | 2 +- .github/CODEOWNERS | 4 +- .github/ISSUE_TEMPLATE/bug.yml | 88 +++++++++++++-------------- .github/dependabot.yml | 25 ++++---- .github/workflows/audit.yml | 22 ++++--- .github/workflows/ci.yml | 60 ++++++++++++------ .github/workflows/codeql-analysis.yml | 30 +++++---- .github/workflows/post-dependabot.yml | 26 +++++--- .github/workflows/pull-request.yml | 25 +++++--- .github/workflows/release-please.yml | 16 ++--- .gitignore | 26 ++++---- .npmrc | 2 +- CHANGELOG.md | 5 +- lib/index.js | 4 +- package.json | 22 ++++--- 16 files changed, 210 insertions(+), 152 deletions(-) diff --git a/.commitlintrc.js b/.commitlintrc.js index cf8f3d76..5b0b1a52 100644 --- a/.commitlintrc.js +++ b/.commitlintrc.js @@ -1,10 +1,9 @@ -// This file is automatically added by @npmcli/template-oss. Do not edit. +/* This file is automatically added by @npmcli/template-oss. Do not edit. */ module.exports = { extends: ['@commitlint/config-conventional'], - // If you change rules be sure to also update release-please.yml rules: { - 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'chore', 'deps']], + 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']], 'header-max-length': [2, 'always', 80], 'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']], }, diff --git a/.eslintrc.js b/.eslintrc.js index 022767bc..8204f234 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,4 @@ -// This file is automatically added by @npmcli/template-oss. Do not edit. +/* This file is automatically added by @npmcli/template-oss. Do not edit. */ const { readdirSync: readdir } = require('fs') diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ef874313..2c54b0d2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1,3 @@ -* @npm/cli-team +# This file is automatically added by @npmcli/template-oss. Do not edit. + +* @npm/cli-team diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index fa80b2de..d043192f 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -3,52 +3,52 @@ name: Bug description: File a bug/issue title: "[BUG] " -labels: [Bug, Needs Triage] +labels: [ Bug, Needs Triage ] + body: -- type: checkboxes - attributes: - label: Is there an existing issue for this? - description: Please [search here](./issues) to see if an issue already exists for your problem. - options: - - label: I have searched the existing issues - required: true -- type: textarea - attributes: - label: Current Behavior - description: A clear & concise description of what you're experiencing. - validations: - required: false -- type: textarea - attributes: - label: Expected Behavior - description: A clear & concise description of what you expected to happen. - validations: - required: false -- type: textarea - attributes: - label: Steps To Reproduce - description: Steps to reproduce the behavior. - value: | - 1. In this environment... - 2. With this config... - 3. Run '...' - 4. See error... - validations: - required: false -- type: textarea - attributes: - label: Environment - description: | - examples: - - **npm**: 7.6.3 - - **Node**: 13.14.0 - - **OS**: Ubuntu 20.04 - - **platform**: Macbook Pro - value: | + - type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please [search here](./issues) to see if an issue already exists for your problem. + options: + - label: I have searched the existing issues + required: true + - type: textarea + attributes: + label: Current Behavior + description: A clear & concise description of what you're experiencing. + validations: + required: false + - type: textarea + attributes: + label: Expected Behavior + description: A clear & concise description of what you expected to happen. + validations: + required: false + - type: textarea + attributes: + label: Steps To Reproduce + description: Steps to reproduce the behavior. + value: | + 1. In this environment... + 2. With this config... + 3. Run '...' + 4. See error... + validations: + required: false + - type: textarea + attributes: + label: Environment + description: | + examples: + - **npm**: 7.6.3 + - **Node**: 13.14.0 + - **OS**: Ubuntu 20.04 + - **platform**: Macbook Pro + value: | - npm: - Node: - OS: - platform: - validations: - required: false - + validations: + required: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4c8e23f4..96d8eafb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,16 +1,17 @@ # This file is automatically added by @npmcli/template-oss. Do not edit. version: 2 + updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - allow: - - dependency-type: direct - versioning-strategy: increase - commit-message: - prefix: deps - prefix-development: chore - labels: - - "Dependencies" + - package-ecosystem: npm + directory: "/" + schedule: + interval: daily + allow: + - dependency-type: direct + versioning-strategy: increase-if-necessary + commit-message: + prefix: deps + prefix-development: chore + labels: + - "Dependencies" diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 5f07e044..549243ae 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -3,21 +3,25 @@ name: Audit on: + workflow_dispatch: schedule: # "At 01:00 on Monday" https://crontab.guru/#0_1_*_*_1 - cron: "0 1 * * 1" - workflow_dispatch: jobs: audit: - name: npm audit runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - name: Setup git user + run: | + git config --global user.email "ops+npm-cli@npmjs.com" + git config --global user.name "npm cli ops bot" + - uses: actions/setup-node@v3 with: - node-version: '16' - - name: Install deps - run: npm i --package-lock - - name: Audit - run: npm audit + node-version: 16.x + - name: Update npm to latest + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - run: npm -v + - run: npm i --ignore-scripts --package-lock + - run: npm audit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 175457e2..8067c86d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,10 @@ name: CI on: + workflow_dispatch: pull_request: + branches: + - '*' push: branches: - main @@ -16,38 +19,54 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - name: Setup git user + run: | + git config --global user.email "ops+npm-cli@npmjs.com" + git config --global user.name "npm cli ops bot" + - uses: actions/setup-node@v3 with: - node-version: '16' - - run: npm i --prefer-online -g npm@latest - - run: npm i + node-version: 16.x + - name: Update npm to latest + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - run: npm -v + - run: npm i --ignore-scripts - run: npm run lint test: strategy: fail-fast: false matrix: - node-version: [12.13.0, 12.x, 14.15.0, 14.x, 16.13.0, 16.x] + node-version: + - 12.13.0 + - 12.x + - 14.15.0 + - 14.x + - 16.0.0 + - 16.x platform: - - os: ubuntu-latest - shell: bash - - os: macos-latest - shell: bash - - os: windows-latest - shell: cmd + - os: ubuntu-latest + shell: bash + - os: macos-latest + shell: bash + - os: windows-latest + shell: cmd runs-on: ${{ matrix.platform.os }} defaults: run: shell: ${{ matrix.platform.shell }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - name: Setup git user + run: | + git config --global user.email "ops+npm-cli@npmjs.com" + git config --global user.name "npm cli ops bot" + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows - name: Update to workable npm (windows) - if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12') || startsWith(matrix.node-version, '14')) + # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows + if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.')) run: | curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz tar xf npm-7.5.4.tgz @@ -55,8 +74,13 @@ jobs: node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz cd .. rmdir /s /q package - - name: Update npm + - name: Update npm to 7 + # If we do test on npm 10 it needs npm7 + if: startsWith(matrix.node-version, '10.') + run: npm i --prefer-online --no-fund --no-audit -g npm@7 + - name: Update npm to latest + if: ${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - run: npm -v - - run: npm i + - run: npm i --ignore-scripts - run: npm test --ignore-scripts diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c7694c49..56cd7b9c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -4,10 +4,14 @@ name: "CodeQL" on: push: - branches: [ main ] + branches: + - main + - latest pull_request: # The branches below must be a subset of the branches above - branches: [ main ] + branches: + - main + - latest schedule: # "At 03:00 on Monday" https://crontab.guru/#0_3_*_*_1 - cron: "0 3 * * 1" @@ -24,15 +28,17 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript' ] + language: [ javascript ] steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - uses: actions/checkout@v3 + - name: Setup git user + run: | + git config --global user.email "ops+npm-cli@npmjs.com" + git config --global user.name "npm cli ops bot" + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/post-dependabot.yml b/.github/workflows/post-dependabot.yml index 3093c306..bae1d8d2 100644 --- a/.github/workflows/post-dependabot.yml +++ b/.github/workflows/post-dependabot.yml @@ -1,35 +1,43 @@ # This file is automatically added by @npmcli/template-oss. Do not edit. -name: "Post Dependabot Actions" +name: Post Dependabot Actions + on: pull_request # https://docs.github.com/en/rest/overview/permissions-required-for-github-apps permissions: + actions: write contents: write jobs: Install: runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} + if: github.actor == 'dependabot[bot]' steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - name: Setup git user + run: | + git config --global user.email "ops+npm-cli@npmjs.com" + git config --global user.name "npm cli ops bot" + - uses: actions/setup-node@v3 with: - node-version: '16' + node-version: 16.x + - name: Update npm to latest + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - run: npm -v - name: Dependabot metadata id: metadata uses: dependabot/fetch-metadata@v1.1.1 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: npm install and commit - if: ${{contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')}} + if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - git config --local user.email "ops+npm-cli@npmjs.com" - git config --local user.name "npm cli ops bot" gh pr checkout ${{ github.event.pull_request.number }} - npm install + npm install --ignore-scripts + npm run template-oss-apply git add . git commit -am "chore: postinstall for dependabot template-oss PR" git push diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 948960e7..93a5c3c9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -4,24 +4,35 @@ name: Pull Request Linting on: pull_request: - types: [opened, reopened, edited, synchronize] + types: + - opened + - reopened + - edited + - synchronize jobs: check: name: Check PR Title or Commits runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-node@v2 + - name: Setup git user + run: | + git config --global user.email "ops+npm-cli@npmjs.com" + git config --global user.name "npm cli ops bot" + - uses: actions/setup-node@v3 with: - node-version: '16' + node-version: 16.x + - name: Update npm to latest + run: npm i --prefer-online --no-fund --no-audit -g npm@latest + - run: npm -v - name: Install deps - run: | - npm i -D @commitlint/cli @commitlint/config-conventional + run: npm i -D @commitlint/cli @commitlint/config-conventional - name: Check commits OR PR title env: PR_TITLE: ${{ github.event.pull_request.title }} run: | - npx commitlint -x @commitlint/config-conventional -V --from origin/main --to ${{ github.event.pull_request.head.sha }} || echo $PR_TITLE | npx commitlint -x @commitlint/config-conventional -V + npx --offline commitlint -V --from origin/main --to ${{ github.event.pull_request.head.sha }} \ + || echo $PR_TITLE | npx --offline commitlint -V diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index c5a165f3..ab3a9105 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -6,19 +6,21 @@ on: push: branches: - main + - latest jobs: release-please: runs-on: ubuntu-latest steps: - - uses: google-github-actions/release-please-action@v2 + - uses: google-github-actions/release-please-action@v3 id: release with: release-type: node - # If you change changelog-types be sure to also update commitlintrc.js changelog-types: > - [{"type":"feat","section":"Features","hidden":false}, - {"type":"fix","section":"Bug Fixes","hidden":false}, - {"type":"docs","section":"Documentation","hidden":false}, - {"type":"deps","section":"Dependencies","hidden":false}, - {"type":"chore","hidden":true}] + [ + {"type":"feat","section":"Features","hidden":false}, + {"type":"fix","section":"Bug Fixes","hidden":false}, + {"type":"docs","section":"Documentation","hidden":false}, + {"type":"deps","section":"Dependencies","hidden":false}, + {"type":"chore","hidden":true} + ] diff --git a/.gitignore b/.gitignore index 6ed44c72..bf011b1d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,20 +4,22 @@ /* # keep these -!/.commitlintrc.js -!/.npmrc -!/.eslintrc* -!/.github +!/.eslintrc.local.* !**/.gitignore -!/package.json -!/docs -!/bin -!/lib +!/docs/ +!/tap-snapshots/ +!/test/ !/map.js -!/tap-snapshots -!/test -!/scripts +!/scripts/ !/README* !/LICENSE* -!/SECURITY* !/CHANGELOG* +!/.commitlintrc.js +!/.eslintrc.js +!/.github/ +!/.gitignore +!/.npmrc +!/SECURITY.md +!/bin/ +!/lib/ +!/package.json diff --git a/.npmrc b/.npmrc index 878b7dde..529f93e7 100644 --- a/.npmrc +++ b/.npmrc @@ -1,3 +1,3 @@ -;This file is automatically added by @npmcli/template-oss. Do not edit. +; This file is automatically added by @npmcli/template-oss. Do not edit. package-lock=false diff --git a/CHANGELOG.md b/CHANGELOG.md index f729cbbb..97731e6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,5 @@ -# Change Log +# Changelog -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - -<a name="4.0.0"></a> ## [5.0.0](https://www.github.com/npm/hosted-git-info/compare/v4.1.0...v5.0.0) (2022-03-14) diff --git a/lib/index.js b/lib/index.js index 8bce6b3c..183b6cf4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -46,8 +46,8 @@ function fromUrl (giturl, opts) { return } - const url = isGitHubShorthand(giturl) ? 'github:' + giturl : correctProtocol(giturl) - const parsed = parseGitUrl(url) + const correctedUrl = isGitHubShorthand(giturl) ? 'github:' + giturl : correctProtocol(giturl) + const parsed = parseGitUrl(correctedUrl) if (!parsed) { return parsed } diff --git a/package.json b/package.json index 0153b085..809a584d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "./lib/index.js", "repository": { "type": "git", - "url": "git+https://github.com/npm/hosted-git-info.git" + "url": "https://github.com/npm/hosted-git-info.git" }, "keywords": [ "git", @@ -27,30 +27,32 @@ "snap": "tap", "test": "tap", "test:coverage": "tap --coverage-report=html", - "lint": "eslint '**/*.js'", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force", - "lintfix": "npm run lint -- --fix" + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "lintfix": "npm run lint -- --fix", + "template-oss-apply": "template-oss-apply --force" }, "dependencies": { "lru-cache": "^7.5.1" }, "devDependencies": { - "@npmcli/template-oss": "^2.9.2", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.0", "tap": "^15.1.6" }, "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "tap": { "color": 1, "coverage": true }, "templateOSS": { - "version": "2.9.2" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.0" } } From 05769bcc82a812592c73889a3bbeb045290daf7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 10:34:34 -0700 Subject: [PATCH 02/10] chore: bump tap from 15.2.3 to 16.0.1 (#136) Bumps [tap](https://github.com/tapjs/node-tap) from 15.2.3 to 16.0.1. - [Release notes](https://github.com/tapjs/node-tap/releases) - [Commits](https://github.com/tapjs/node-tap/compare/v15.2.3...v16.0.1) --- updated-dependencies: - dependency-name: tap dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 809a584d..470a4667 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "devDependencies": { "@npmcli/eslint-config": "^3.0.1", "@npmcli/template-oss": "3.2.0", - "tap": "^15.1.6" + "tap": "^16.0.1" }, "files": [ "bin/", From 03146d2bd964acfa8dbdabbbed1e12e0cd9efb90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 02:20:18 -0700 Subject: [PATCH 03/10] chore: bump @npmcli/template-oss from 3.2.0 to 3.4.1 (#139) * chore: bump @npmcli/template-oss from 3.2.0 to 3.4.1 Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 3.2.0 to 3.4.1. - [Release notes](https://github.com/npm/template-oss/releases) - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/template-oss/compare/v3.2.0...v3.4.1) --- updated-dependencies: - dependency-name: "@npmcli/template-oss" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * chore: postinstall for dependabot template-oss PR Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Luke Karrys <luke@lukekarrys.com> --- .eslintrc.js | 1 + .github/workflows/audit.yml | 6 +++--- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/codeql-analysis.yml | 4 ++-- .github/workflows/post-dependabot.yml | 12 ++++++------ .github/workflows/pull-request.yml | 4 ++-- package.json | 4 ++-- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8204f234..0e8ad007 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,6 +7,7 @@ const localConfigs = readdir(__dirname) .map((file) => `./${file}`) module.exports = { + root: true, extends: [ '@npmcli', ...localConfigs, diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 549243ae..7f48d351 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -15,13 +15,13 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+npm-cli@npmjs.com" - git config --global user.name "npm cli ops bot" + git config --global user.email "npm team" + git config --global user.name "ops+robot@npmjs.com" - uses: actions/setup-node@v3 with: node-version: 16.x - name: Update npm to latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - run: npm -v - - run: npm i --ignore-scripts --package-lock + - run: npm i --ignore-scripts --no-audit --no-fund --package-lock - run: npm audit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8067c86d..287a8696 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,15 +22,15 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+npm-cli@npmjs.com" - git config --global user.name "npm cli ops bot" + git config --global user.email "npm team" + git config --global user.name "ops+robot@npmjs.com" - uses: actions/setup-node@v3 with: node-version: 16.x - name: Update npm to latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - run: npm -v - - run: npm i --ignore-scripts + - run: npm i --ignore-scripts --no-audit --no-fund - run: npm run lint test: @@ -59,8 +59,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+npm-cli@npmjs.com" - git config --global user.name "npm cli ops bot" + git config --global user.email "npm team" + git config --global user.name "ops+robot@npmjs.com" - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} @@ -82,5 +82,5 @@ jobs: if: ${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - run: npm -v - - run: npm i --ignore-scripts + - run: npm i --ignore-scripts --no-audit --no-fund - run: npm test --ignore-scripts diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 56cd7b9c..0067fc1b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,8 +34,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+npm-cli@npmjs.com" - git config --global user.name "npm cli ops bot" + git config --global user.email "npm team" + git config --global user.name "ops+robot@npmjs.com" - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: diff --git a/.github/workflows/post-dependabot.yml b/.github/workflows/post-dependabot.yml index bae1d8d2..4dd83131 100644 --- a/.github/workflows/post-dependabot.yml +++ b/.github/workflows/post-dependabot.yml @@ -4,21 +4,20 @@ name: Post Dependabot Actions on: pull_request -# https://docs.github.com/en/rest/overview/permissions-required-for-github-apps +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions permissions: - actions: write contents: write jobs: - Install: + template-oss-apply: runs-on: ubuntu-latest if: github.actor == 'dependabot[bot]' steps: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+npm-cli@npmjs.com" - git config --global user.name "npm cli ops bot" + git config --global user.email "npm team" + git config --global user.name "ops+robot@npmjs.com" - uses: actions/setup-node@v3 with: node-version: 16.x @@ -36,8 +35,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh pr checkout ${{ github.event.pull_request.number }} - npm install --ignore-scripts + npm install --ignore-scripts --no-audit --no-fund npm run template-oss-apply git add . git commit -am "chore: postinstall for dependabot template-oss PR" git push + npm run lint diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 93a5c3c9..bf86a7da 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,8 +20,8 @@ jobs: fetch-depth: 0 - name: Setup git user run: | - git config --global user.email "ops+npm-cli@npmjs.com" - git config --global user.name "npm cli ops bot" + git config --global user.email "npm team" + git config --global user.name "ops+robot@npmjs.com" - uses: actions/setup-node@v3 with: node-version: 16.x diff --git a/package.json b/package.json index 470a4667..331078c4 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@npmcli/eslint-config": "^3.0.1", - "@npmcli/template-oss": "3.2.0", + "@npmcli/template-oss": "3.4.1", "tap": "^16.0.1" }, "files": [ @@ -53,6 +53,6 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "3.2.0" + "version": "3.4.1" } } From fd70306db5cf2fe167fed20a3d3c50c4b6972e05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Apr 2022 09:40:48 +0000 Subject: [PATCH 04/10] chore: bump @npmcli/template-oss from 3.4.1 to 3.4.2 Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 3.4.1 to 3.4.2. - [Release notes](https://github.com/npm/template-oss/releases) - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/template-oss/compare/v3.4.1...v3.4.2) --- updated-dependencies: - dependency-name: "@npmcli/template-oss" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 331078c4..d51dd934 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@npmcli/eslint-config": "^3.0.1", - "@npmcli/template-oss": "3.4.1", + "@npmcli/template-oss": "3.4.2", "tap": "^16.0.1" }, "files": [ From e50cadb72b434f5395d8086ee1afbc6db0891084 Mon Sep 17 00:00:00 2001 From: Luke Karrys <luke@lukekarrys.com> Date: Wed, 27 Apr 2022 15:27:25 -0700 Subject: [PATCH 05/10] chore: postinstall for dependabot template-oss PR --- .github/workflows/audit.yml | 4 ++-- .github/workflows/ci.yml | 8 ++++---- .github/workflows/codeql-analysis.yml | 4 ++-- .github/workflows/post-dependabot.yml | 4 ++-- .github/workflows/pull-request.yml | 4 ++-- package.json | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 7f48d351..1e35e279 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -15,8 +15,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "npm team" - git config --global user.name "ops+robot@npmjs.com" + git config --global user.email "ops+robot@npmjs.com" + git config --global user.name "npm team" - uses: actions/setup-node@v3 with: node-version: 16.x diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 287a8696..eda41a7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "npm team" - git config --global user.name "ops+robot@npmjs.com" + git config --global user.email "ops+robot@npmjs.com" + git config --global user.name "npm team" - uses: actions/setup-node@v3 with: node-version: 16.x @@ -59,8 +59,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "npm team" - git config --global user.name "ops+robot@npmjs.com" + git config --global user.email "ops+robot@npmjs.com" + git config --global user.name "npm team" - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0067fc1b..2fbb6309 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,8 +34,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "npm team" - git config --global user.name "ops+robot@npmjs.com" + git config --global user.email "ops+robot@npmjs.com" + git config --global user.name "npm team" - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: diff --git a/.github/workflows/post-dependabot.yml b/.github/workflows/post-dependabot.yml index 4dd83131..94f5a8fd 100644 --- a/.github/workflows/post-dependabot.yml +++ b/.github/workflows/post-dependabot.yml @@ -16,8 +16,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "npm team" - git config --global user.name "ops+robot@npmjs.com" + git config --global user.email "ops+robot@npmjs.com" + git config --global user.name "npm team" - uses: actions/setup-node@v3 with: node-version: 16.x diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index bf86a7da..d2bc7dab 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,8 +20,8 @@ jobs: fetch-depth: 0 - name: Setup git user run: | - git config --global user.email "npm team" - git config --global user.name "ops+robot@npmjs.com" + git config --global user.email "ops+robot@npmjs.com" + git config --global user.name "npm team" - uses: actions/setup-node@v3 with: node-version: 16.x diff --git a/package.json b/package.json index d51dd934..347387c5 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,6 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "3.4.1" + "version": "3.4.2" } } From afcf39b749595809ff6d8bd5d7092961309e38a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Jun 2022 14:14:45 -0700 Subject: [PATCH 06/10] chore: bump @npmcli/template-oss from 3.4.2 to 3.4.3 (#141) * chore: bump @npmcli/template-oss from 3.4.2 to 3.4.3 Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 3.4.2 to 3.4.3. - [Release notes](https://github.com/npm/template-oss/releases) - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/template-oss/compare/v3.4.2...v3.4.3) --- updated-dependencies: - dependency-name: "@npmcli/template-oss" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * chore: postinstall for dependabot template-oss PR * chore: postinstall for dependabot template-oss PR Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: npm team <ops+robot@npmjs.com> Co-authored-by: Luke Karrys <luke@lukekarrys.com> --- .eslintrc.js | 2 ++ .github/workflows/audit.yml | 4 ++-- .github/workflows/ci.yml | 8 ++++---- .github/workflows/codeql-analysis.yml | 4 ++-- .github/workflows/post-dependabot.yml | 4 ++-- .github/workflows/pull-request.yml | 4 ++-- .gitignore | 1 + CODE_OF_CONDUCT.md | 7 +++++++ package.json | 4 ++-- 9 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 CODE_OF_CONDUCT.md diff --git a/.eslintrc.js b/.eslintrc.js index 0e8ad007..5db9f815 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,7 @@ /* This file is automatically added by @npmcli/template-oss. Do not edit. */ +'use strict' + const { readdirSync: readdir } = require('fs') const localConfigs = readdir(__dirname) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 1e35e279..64716120 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -15,8 +15,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+robot@npmjs.com" - git config --global user.name "npm team" + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" - uses: actions/setup-node@v3 with: node-version: 16.x diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eda41a7b..7a62d9a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+robot@npmjs.com" - git config --global user.name "npm team" + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" - uses: actions/setup-node@v3 with: node-version: 16.x @@ -59,8 +59,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+robot@npmjs.com" - git config --global user.name "npm team" + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2fbb6309..5d974116 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,8 +34,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+robot@npmjs.com" - git config --global user.name "npm team" + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: diff --git a/.github/workflows/post-dependabot.yml b/.github/workflows/post-dependabot.yml index 94f5a8fd..b6e81e6e 100644 --- a/.github/workflows/post-dependabot.yml +++ b/.github/workflows/post-dependabot.yml @@ -16,8 +16,8 @@ jobs: - uses: actions/checkout@v3 - name: Setup git user run: | - git config --global user.email "ops+robot@npmjs.com" - git config --global user.name "npm team" + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" - uses: actions/setup-node@v3 with: node-version: 16.x diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d2bc7dab..72230764 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,8 +20,8 @@ jobs: fetch-depth: 0 - name: Setup git user run: | - git config --global user.email "ops+robot@npmjs.com" - git config --global user.name "npm team" + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" - uses: actions/setup-node@v3 with: node-version: 16.x diff --git a/.gitignore b/.gitignore index bf011b1d..be5771f0 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ !/.github/ !/.gitignore !/.npmrc +!/CODE_OF_CONDUCT.md !/SECURITY.md !/bin/ !/lib/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..167043c2 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,7 @@ +<!-- This file is automatically added by @npmcli/template-oss. Do not edit. --> + +All interactions in this repo are covered by the [npm Code of +Conduct](https://docs.npmjs.com/policies/conduct) + +The npm cli team may, at its own discretion, moderate, remove, or edit +any interactions such as pull requests, issues, and comments. diff --git a/package.json b/package.json index 347387c5..c4624f5e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ }, "devDependencies": { "@npmcli/eslint-config": "^3.0.1", - "@npmcli/template-oss": "3.4.2", + "@npmcli/template-oss": "3.5.0", "tap": "^16.0.1" }, "files": [ @@ -53,6 +53,6 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "3.4.2" + "version": "3.5.0" } } From ad02952f89fbdc99e67ae0d5308029395bde3331 Mon Sep 17 00:00:00 2001 From: Luke Karrys <luke@lukekarrys.com> Date: Mon, 8 Aug 2022 12:18:05 -0700 Subject: [PATCH 07/10] feat: add method to get an edit link to a file --- lib/git-host-info.js | 7 +++++++ lib/git-host.js | 4 ++++ test/bitbucket.js | 2 ++ test/gist.js | 2 ++ test/github.js | 3 +++ test/gitlab.js | 2 ++ test/sourcehut.js | 2 ++ 7 files changed, 22 insertions(+) diff --git a/lib/git-host-info.js b/lib/git-host-info.js index 9a9720fa..cdc1e460 100644 --- a/lib/git-host-info.js +++ b/lib/git-host-info.js @@ -6,6 +6,7 @@ const maybeEncode = (arg) => arg ? encodeURIComponent(arg) : '' const defaults = { sshtemplate: ({ domain, user, project, committish }) => `git@${domain}:${user}/${project}.git${maybeJoin('#', committish)}`, sshurltemplate: ({ domain, user, project, committish }) => `git+ssh://git@${domain}/${user}/${project}.git${maybeJoin('#', committish)}`, + edittemplate: ({ domain, user, project, committish, editpath, path }) => `https://${domain}/${user}/${project}${maybeJoin('/', editpath, '/', maybeEncode(committish || 'master'), '/', path)}`, browsetemplate: ({ domain, user, project, committish, treepath }) => `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish))}`, browsefiletemplate: ({ domain, user, project, committish, treepath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || 'master')}/${path}${maybeJoin('#', hashformat(fragment || ''))}`, docstemplate: ({ domain, user, project, treepath, committish }) => `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish))}#readme`, @@ -24,6 +25,7 @@ gitHosts.github = Object.assign({}, defaults, { protocols: ['git:', 'http:', 'git+ssh:', 'git+https:', 'ssh:', 'https:'], domain: 'github.com', treepath: 'tree', + editpath: 'edit', filetemplate: ({ auth, user, project, committish, path }) => `https://${maybeJoin(auth, '@')}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish) || 'master'}/${path}`, gittemplate: ({ auth, domain, user, project, committish }) => `git://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`, tarballtemplate: ({ domain, user, project, committish }) => `https://codeload.${domain}/${user}/${project}/tar.gz/${maybeEncode(committish) || 'master'}`, @@ -53,6 +55,8 @@ gitHosts.bitbucket = Object.assign({}, defaults, { protocols: ['git+ssh:', 'git+https:', 'ssh:', 'https:'], domain: 'bitbucket.org', treepath: 'src', + editpath: '?mode=edit', + edittemplate: ({ domain, user, project, committish, treepath, path, editpath }) => `https://${domain}/${user}/${project}${maybeJoin('/', treepath, '/', maybeEncode(committish || 'master'), '/', path, editpath)}`, tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/get/${maybeEncode(committish) || 'master'}.tar.gz`, extract: (url) => { let [, user, project, aux] = url.pathname.split('/', 4) @@ -76,6 +80,7 @@ gitHosts.gitlab = Object.assign({}, defaults, { protocols: ['git+ssh:', 'git+https:', 'ssh:', 'https:'], domain: 'gitlab.com', treepath: 'tree', + editpath: '-/edit', httpstemplate: ({ auth, domain, user, project, committish }) => `git+https://${maybeJoin(auth, '@')}${domain}/${user}/${project}.git${maybeJoin('#', committish)}`, tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/repository/archive.tar.gz?ref=${maybeEncode(committish) || 'master'}`, extract: (url) => { @@ -102,8 +107,10 @@ gitHosts.gitlab = Object.assign({}, defaults, { gitHosts.gist = Object.assign({}, defaults, { protocols: ['git:', 'git+ssh:', 'git+https:', 'ssh:', 'https:'], domain: 'gist.github.com', + editpath: 'edit', sshtemplate: ({ domain, project, committish }) => `git@${domain}:${project}.git${maybeJoin('#', committish)}`, sshurltemplate: ({ domain, project, committish }) => `git+ssh://git@${domain}/${project}.git${maybeJoin('#', committish)}`, + edittemplate: ({ domain, user, project, committish, editpath }) => `https://${domain}/${user}/${project}${maybeJoin('/', maybeEncode(committish))}/${editpath}`, browsetemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}`, browsefiletemplate: ({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}${maybeJoin('#', hashformat(path))}`, docstemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin('/', maybeEncode(committish))}`, diff --git a/lib/git-host.js b/lib/git-host.js index 8a975e92..bb65d4d9 100644 --- a/lib/git-host.js +++ b/lib/git-host.js @@ -95,6 +95,10 @@ class GitHost { return this._fill(this.filetemplate, { ...opts, path }) } + edit (path, opts) { + return this._fill(this.edittemplate, { ...opts, path }) + } + getDefaultRepresentation () { return this.default } diff --git a/test/bitbucket.js b/test/bitbucket.js index 4668e594..88795f41 100644 --- a/test/bitbucket.js +++ b/test/bitbucket.js @@ -181,6 +181,8 @@ t.test('string methods populate correctly', t => { t.equal(parsed.hash(), '', 'hash() returns empty string when committish is unset') t.equal(parsed.ssh(), 'git@bitbucket.org:foo/bar.git') t.equal(parsed.sshurl(), 'git+ssh://git@bitbucket.org/foo/bar.git') + t.equal(parsed.edit(), 'https://bitbucket.org/foo/bar') + t.equal(parsed.edit('/lib/index.js'), 'https://bitbucket.org/foo/bar/src/master/lib/index.js?mode=edit') t.equal(parsed.browse(), 'https://bitbucket.org/foo/bar') t.equal(parsed.browse('/lib/index.js'), 'https://bitbucket.org/foo/bar/src/master/lib/index.js') t.equal(parsed.browse('/lib/index.js', 'L100'), 'https://bitbucket.org/foo/bar/src/master/lib/index.js#l100') diff --git a/test/gist.js b/test/gist.js index 93135507..09c8392c 100644 --- a/test/gist.js +++ b/test/gist.js @@ -345,6 +345,8 @@ t.test('string methods populate correctly', t => { t.equal(parsed.hash(), '', 'hash() returns empty string when committish is unset') t.equal(parsed.ssh(), 'git@gist.github.com:feedbeef.git') t.equal(parsed.sshurl(), 'git+ssh://git@gist.github.com/feedbeef.git') + t.equal(parsed.edit(), 'https://gist.github.com/foo/feedbeef/edit', 'gist link only redirects with a user') + t.equal(parsed.edit('/lib/index.js'), 'https://gist.github.com/foo/feedbeef/edit', 'gist link only redirects with a user') t.equal(parsed.browse(), 'https://gist.github.com/feedbeef') t.equal(parsed.browse('/lib/index.js'), 'https://gist.github.com/feedbeef#file-libindex-js') t.equal(parsed.browse('/lib/index.js', 'L100'), 'https://gist.github.com/feedbeef#file-libindex-js') diff --git a/test/github.js b/test/github.js index 23be1412..3311f32e 100644 --- a/test/github.js +++ b/test/github.js @@ -230,6 +230,9 @@ t.test('string methods populate correctly', t => { t.equal(parsed.hash(), '', 'hash() returns empty string when committish is unset') t.equal(parsed.ssh(), 'git@github.com:foo/bar.git') t.equal(parsed.sshurl(), 'git+ssh://git@github.com/foo/bar.git') + t.equal(parsed.edit(), 'https://github.com/foo/bar') + t.equal(parsed.edit('/lib/index.js'), 'https://github.com/foo/bar/edit/master/lib/index.js') + t.equal(parsed.edit('/lib/index.js', { committish: 'docs' }), 'https://github.com/foo/bar/edit/docs/lib/index.js') t.equal(parsed.browse(), 'https://github.com/foo/bar') t.equal(parsed.browse('/lib/index.js'), 'https://github.com/foo/bar/tree/master/lib/index.js') t.equal(parsed.browse('/lib/index.js', 'L100'), 'https://github.com/foo/bar/tree/master/lib/index.js#l100') diff --git a/test/gitlab.js b/test/gitlab.js index 1975b3e6..be5187b8 100644 --- a/test/gitlab.js +++ b/test/gitlab.js @@ -287,6 +287,8 @@ t.test('string methods populate correctly', t => { t.equal(parsed.hash(), '', 'hash() returns empty string when committish is unset') t.equal(parsed.ssh(), 'git@gitlab.com:foo/bar.git') t.equal(parsed.sshurl(), 'git+ssh://git@gitlab.com/foo/bar.git') + t.equal(parsed.edit(), 'https://gitlab.com/foo/bar') + t.equal(parsed.edit('/lib/index.js'), 'https://gitlab.com/foo/bar/-/edit/master/lib/index.js') t.equal(parsed.browse(), 'https://gitlab.com/foo/bar') t.equal(parsed.browse('/lib/index.js'), 'https://gitlab.com/foo/bar/tree/master/lib/index.js') t.equal(parsed.browse('/lib/index.js', 'L100'), 'https://gitlab.com/foo/bar/tree/master/lib/index.js#l100') diff --git a/test/sourcehut.js b/test/sourcehut.js index 779bacd6..f0f3a765 100644 --- a/test/sourcehut.js +++ b/test/sourcehut.js @@ -94,6 +94,8 @@ t.test('string methods populate correctly', t => { t.equal(parsed.hash(), '', 'hash() returns empty string when committish is unset') t.equal(parsed.ssh(), 'git@git.sr.ht:~foo/bar.git') t.equal(parsed.sshurl(), 'git+ssh://git@git.sr.ht/~foo/bar.git') + t.equal(parsed.edit('/lib/index.js'), 'https://git.sr.ht/~foo/bar', 'no editing, link to browse') + t.equal(parsed.edit(), 'https://git.sr.ht/~foo/bar', 'no editing, link to browse') t.equal(parsed.browse(), 'https://git.sr.ht/~foo/bar') t.equal(parsed.browse('/lib/index.js'), 'https://git.sr.ht/~foo/bar/tree/main/lib/index.js') t.equal( From bcb0d8100597599f2c91bd17657c08e82c61e950 Mon Sep 17 00:00:00 2001 From: Luke Karrys <luke@lukekarrys.com> Date: Mon, 8 Aug 2022 15:16:49 -0700 Subject: [PATCH 08/10] chore: fix linting --- lib/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 183b6cf4..d5d63c66 100644 --- a/lib/index.js +++ b/lib/index.js @@ -229,7 +229,9 @@ const parseGitUrl = (giturl) => { let result try { result = new url.URL(giturl) - } catch (err) {} + } catch { + // this fn should never throw + } if (result) { return result @@ -238,7 +240,9 @@ const parseGitUrl = (giturl) => { const correctedUrl = correctUrl(giturl) try { result = new url.URL(correctedUrl) - } catch (err) {} + } catch { + // this fn should never throw + } return result } From 70a770d1202128e15887d69dfd5c930e4ff29a00 Mon Sep 17 00:00:00 2001 From: Luke Karrys <luke@lukekarrys.com> Date: Tue, 9 Aug 2022 11:49:34 -0700 Subject: [PATCH 09/10] fix: add comments to empty catch blocks for linting From 4560e2de386e9c1532a8414f377ca84404348182 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 9 Aug 2022 13:05:49 -0700 Subject: [PATCH 10/10] chore(main): release 5.1.0 (#151) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97731e6b..d7481a29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [5.1.0](https://github.com/npm/hosted-git-info/compare/v5.0.0...v5.1.0) (2022-08-09) + + +### Features + +* add method to get an edit link to a file ([ad02952](https://github.com/npm/hosted-git-info/commit/ad02952f89fbdc99e67ae0d5308029395bde3331)) + + +### Bug Fixes + +* add comments to empty catch blocks for linting ([70a770d](https://github.com/npm/hosted-git-info/commit/70a770d1202128e15887d69dfd5c930e4ff29a00)) + ## [5.0.0](https://www.github.com/npm/hosted-git-info/compare/v4.1.0...v5.0.0) (2022-03-14) diff --git a/package.json b/package.json index c4624f5e..07a5587c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hosted-git-info", - "version": "5.0.0", + "version": "5.1.0", "description": "Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab", "main": "./lib/index.js", "repository": {