Skip to content

🔨 Add repository field to package.json files#438

Merged
Robdel12 merged 1 commit intopercy:masterfrom
ybiquitous:add-repository-to-package.json
Jul 26, 2021
Merged

🔨 Add repository field to package.json files#438
Robdel12 merged 1 commit intopercy:masterfrom
ybiquitous:add-repository-to-package.json

Conversation

@ybiquitous
Copy link
Copy Markdown
Contributor

@ybiquitous ybiquitous commented Jul 25, 2021

Close #435

This change is created by the following Bash script:

#!/usr/bin/env bash
set -eu -o pipefail

files=$(git ls-files | grep package.json)
for file in $files; do
  echo "Adding repository to ${file} ..."
  dir=$(dirname $file)
  if [[ $dir == "." ]]; then
    npm pkg set repository.type="git" repository.url="https://github.com/percy/cli"
  else
    npm pkg set repository.type="git" repository.url="https://github.com/percy/cli" repository.directory="$dir" --workspace="$dir"
  fi
done

(Note: npm pkg is available since npm@7.20.0)

Also, the changed package.json files can be verified by the following command:

$ cat .npmpackagejsonlintrc.json
{
  "rules": {
    "require-repository": "error"
  }
}
$ npx npm-package-json-lint .

See also:

@ybiquitous
Copy link
Copy Markdown
Contributor Author

The repository of Jest is an example using the repository field in package.json:

https://github.com/facebook/jest/blob/fdc74af37235354e077edeeee8aa2d1a4a863032/packages/jest-cli/package.json#L47-L51

This change is created by the following Bash script:

```bash
#!/usr/bin/env bash
set -eu -o pipefail

files=$(git ls-files | grep package.json)
pwd=$PWD

for file in $files; do
  echo "Adding repository to ${file} ..."
  dir=$(dirname $file)
  if [[ $dir == "." ]]; then
    npm pkg set repository.type="git" repository.url="https://github.com/percy/cli"
  else
    npm pkg set repository.type="git" repository.url="https://github.com/percy/cli" repository.directory="$dir" --workspace="$dir"
  fi
done
```

Also, the changed `package.json` files can be verified by the following command:

```console
$ cat .npmpackagejsonlintrc.json
{
  "rules": {
    "require-repository": "error"
  }
}
$ npx npm-package-json-lint .
```

See also:
- https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository
- https://npmpackagejsonlint.org
Copy link
Copy Markdown
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏁 Nice, thanks for the PR!

@Robdel12 Robdel12 merged commit 2ae8605 into percy:master Jul 26, 2021
@ybiquitous ybiquitous deleted the add-repository-to-package.json branch July 26, 2021 15:35
@ybiquitous
Copy link
Copy Markdown
Contributor Author

@Robdel12 Thank you for the merge! 😄

@wwilsman wwilsman added the 🧹 maintenance General maintenance label Jul 27, 2021
samarsault pushed a commit that referenced this pull request Mar 3, 2023
Bumps [cypress](https://github.com/cypress-io/cypress) from 9.1.0 to 9.1.1.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js)
- [Commits](cypress-io/cypress@v9.1.0...v9.1.1)

---
updated-dependencies:
- dependency-name: cypress
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧹 maintenance General maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add repository field to package.json

3 participants