Skip to content

Commit

Permalink
Standardize repo (#55)
Browse files Browse the repository at this point in the history
...using `metamask-module-template` as a guide.

* Update ESLint config (doesn't allow TypeScript just yet)
* Add JSDoc to satisfy new ESLint rules
* Update Prettier config
* Reformat all files to match new ESLint and Prettier config
* Update .gitignore
* Update README
* Update `package.json`
* Update workflows
  • Loading branch information
mcmire authored Apr 6, 2022
1 parent 481baca commit aa1d975
Show file tree
Hide file tree
Showing 15 changed files with 2,472 additions and 1,094 deletions.
27 changes: 8 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
module.exports = {
root: true,

extends: [
'@metamask/eslint-config',
'@metamask/eslint-config/config/nodejs',
],
extends: ['@metamask/eslint-config'],

parserOptions: {
ecmaVersion: 2017,
ecmaFeatures: {
arrowFunctions: true,
classes: true,
overrides: [
{
files: ['*.js'],
extends: ['@metamask/eslint-config-nodejs'],
},
},
],

overrides: [{
files: [
'.eslintrc.js',
],
parserOptions: {
sourceType: 'script',
},
}],
}
ignorePatterns: ['!.eslintrc.js', '!.prettierrc.js', 'dist/'],
};
50 changes: 50 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Create Release Pull Request

on:
workflow_dispatch:
inputs:
base-branch:
description: 'The base branch for git operations and the pull request.'
default: 'main'
required: true
release-type:
description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".'
required: false
release-version:
description: 'A specific version to bump to. Mutually exclusive with "release-type".'
required: false

jobs:
create-release-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v2
with:
# This is to guarantee that the most recent tag is fetched.
# This can be configured to a more reasonable value by consumers.
fetch-depth: 0
# We check out the specified branch, which will be used as the base
# branch for all git operations and the release PR.
ref: ${{ github.event.inputs.base-branch }}
- name: Get Node.js version
id: nvm
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- uses: MetaMask/action-create-release-pr@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release-type: ${{ github.event.inputs.release-type }}
release-version: ${{ github.event.inputs.release-version }}
artifacts-path: gh-action__release-authors
# Upload the release author artifact for use in subsequent workflows
- uses: actions/upload-artifact@v2
with:
name: release-authors
path: gh-action__release-authors
if-no-files-found: error
54 changes: 40 additions & 14 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,56 @@
name: Lint and Test
name: Build, Lint, and Test

on:
push:
branches: [ main ]
branches: [main]
pull_request:

jobs:
lint-test:
name: Lint and Test
build-lint-test:
name: Build, Lint, and Test
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: yarn lint
- run: yarn test
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Get Yarn cache directory
run: echo "::set-output name=YARN_CACHE_DIR::$(yarn cache dir)"
id: yarn-cache-dir
- name: Get Yarn version
run: echo "::set-output name=YARN_VERSION::$(yarn --version)"
id: yarn-version
- name: Cache yarn dependencies
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}
- run: yarn --frozen-lockfile
- run: yarn allow-scripts
- run: yarn build
- run: yarn lint
- run: yarn test
- name: Validate RC changelog
if: ${{ startsWith(github.head_ref, 'release/') }}
run: yarn auto-changelog validate --rc
- name: Validate changelog
if: ${{ !startsWith(github.head_ref, 'release/') }}
run: yarn auto-changelog validate
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty after building"
exit 1
fi
all-jobs-pass:
name: All jobs pass
runs-on: ubuntu-20.04
needs:
- lint-test
- build-lint-test
steps:
- run: echo "Great success!"
- run: echo "Great success!"
29 changes: 29 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish Release

on:
pull_request:
types: [closed]

jobs:
publish-release:
permissions:
contents: write
if: |
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# We check out the release pull request's base branch, which will be
# used as the base branch for all git operations.
ref: ${{ github.event.pull_request.base.ref }}
- name: Get Node.js version
id: nvm
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- uses: MetaMask/action-publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/require-additional-reviewer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Require Additional Reviewer for Releases

on:
pull_request:
pull_request_review:

jobs:
require-additional-reviewer:
permissions:
actions: read
contents: read
pull-requests: read
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# If the base branch has been merged into the release branch, we
# need to find the earliest common ancestor commit of the base and
# release branches.
fetch-depth: 0
# We want the head / feature branch to be checked out, and we will
# compare it to the base branch in the action.
ref: ${{ github.event.pull_request.head.ref }}
- uses: MetaMask/action-require-additional-reviewer@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
read-org-token: ${{ secrets.ORG_READER }}
70 changes: 26 additions & 44 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
package-lock.json
# Created by https://www.gitignore.io/api/osx,node
.DS_Store
dist/
coverage/

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

Expand All @@ -60,33 +61,14 @@ typings/

# dotenv environment variables file
.env
.env.test

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# End of https://www.gitignore.io/api/osx,node
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// All of these are defaults except singleQuote, but we specify them
// for explicitness
module.exports = {
quoteProps: 'as-needed',
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
};
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-scripts true
18 changes: 6 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [5.1.0] - 2020-09-22

### Changed

- Update RPC packages ([#40](https://github.com/MetaMask/eth-json-rpc-infura/pull/40))
- `json-rpc-engine@5.3.0`
- `eth-json-rpc-middleware@6.0.0`

## [5.0.0] - 2020-09-08

### Changed

- Use Infura API v3 ([#32](https://github.com/MetaMask/eth-json-rpc-infura/pull/32))

## [4.1.0] - 2020-09-03

### Changed

- Use `node-fetch` in place of `cross-fetch` ([#29](https://github.com/MetaMask/eth-json-rpc-infura/pull/28))
- Use `eth-rpc-errors@3.0.0` ([#28](https://github.com/MetaMask/eth-json-rpc-infura/pull/28))
- Use `eth-json-rpc-middleware@4.4.1` ([#15](https://github.com/MetaMask/eth-json-rpc-infura/pull/15))

[Unreleased]:https://github.com/MetaMask/eth-json-rpc-infura/compare/v5.1.0...HEAD
[5.1.0]:https://github.com/MetaMask/eth-json-rpc-infura/compare/v5.0.0...v5.1.0
[5.0.0]:https://github.com/MetaMask/eth-json-rpc-infura/compare/v4.1.0...v5.0.0
[4.1.0]:https://github.com/MetaMask/eth-json-rpc-infura/compare/v4.0.2...v4.1.0
[Unreleased]: https://github.com/MetaMask/eth-json-rpc-infura/compare/v5.1.0...HEAD
[5.1.0]: https://github.com/MetaMask/eth-json-rpc-infura/compare/v5.0.0...v5.1.0
[5.0.0]: https://github.com/MetaMask/eth-json-rpc-infura/compare/v4.1.0...v5.0.0
[4.1.0]: https://github.com/MetaMask/eth-json-rpc-infura/releases/tag/v4.1.0
Loading

0 comments on commit aa1d975

Please sign in to comment.