Skip to content

Commit e4e4e27

Browse files
authored
Standardize repo (minus tests) (#97)
* Add missing workflows from template repo * Replace `.gitattributes`, `.editorconfig`, `.gitignore` with version from template repo * Add NPM scripts in template repo but missing here * Add `allow-scripts` and run it via `yarn setup` * Update TypeScript config to match template repo * Exclude test files * Use ES2020 `.d.ts` instead of ES2017 * Upgrade Node to v14 * Lint JSON files with `eslint-plugin-packagejson` instead of `prettier-plugin-json` * Update README to match template repo * Update and backfill changelog
1 parent e7c075a commit e4e4e27

16 files changed

+823
-221
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.eslintrc.js

-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ module.exports = {
1313
files: ['*.js'],
1414
extends: ['@metamask/eslint-config-nodejs'],
1515
},
16-
17-
{
18-
files: ['*.json'],
19-
extends: ['plugin:json/recommended'],
20-
},
2116
],
2217

2318
ignorePatterns: ['!.eslintrc.js', '!.prettierrc.js', 'dist/'],

.gitattributes

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
* text=auto
22

3-
# Reviewing the lockfile contents is an important step in verifying that
4-
# we're using the dependencies we expect to be using
5-
package-lock.json linguist-generated=false
63
yarn.lock linguist-generated=false

.github/dependabot.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Please see the documentation for all configuration options:
2+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
- package-ecosystem: 'npm'
7+
directory: '/'
8+
schedule:
9+
interval: 'daily'
10+
time: '06:00'
11+
allow:
12+
- dependency-name: '@metamask/*'
13+
target-branch: 'main'
14+
versioning-strategy: 'increase-if-necessary'
15+
open-pull-requests-limit: 10

.github/workflows/build-test.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-20.04
1212
strategy:
1313
matrix:
14-
node-version: [12.x]
14+
node-version: [12.x, 14.x, 16.x]
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: Use Node.js ${{ matrix.node-version }}
@@ -30,9 +30,23 @@ jobs:
3030
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
3131
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}
3232
- run: yarn --frozen-lockfile
33+
- run: yarn allow-scripts
3334
- run: yarn build
3435
- run: yarn lint
3536
- run: yarn test
37+
- name: Validate RC changelog
38+
if: ${{ startsWith(github.head_ref, 'release/') }}
39+
run: yarn auto-changelog validate --rc
40+
- name: Validate changelog
41+
if: ${{ !startsWith(github.head_ref, 'release/') }}
42+
run: yarn auto-changelog validate
43+
- name: Require clean working directory
44+
shell: bash
45+
run: |
46+
if ! git diff --exit-code; then
47+
echo "Working tree dirty after building"
48+
exit 1
49+
fi
3650
all-jobs-pass:
3751
name: All jobs pass
3852
runs-on: ubuntu-20.04
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Create Release Pull Request
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
base-branch:
7+
description: 'The base branch for git operations and the pull request.'
8+
default: 'main'
9+
required: true
10+
release-type:
11+
description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".'
12+
required: false
13+
release-version:
14+
description: 'A specific version to bump to. Mutually exclusive with "release-type".'
15+
required: false
16+
17+
jobs:
18+
create-release-pr:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
pull-requests: write
23+
steps:
24+
- uses: actions/checkout@v2
25+
with:
26+
# This is to guarantee that the most recent tag is fetched.
27+
# This can be configured to a more reasonable value by consumers.
28+
fetch-depth: 0
29+
# We check out the specified branch, which will be used as the base
30+
# branch for all git operations and the release PR.
31+
ref: ${{ github.event.inputs.base-branch }}
32+
- name: Get Node.js version
33+
id: nvm
34+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
35+
- uses: actions/setup-node@v2
36+
with:
37+
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
38+
- uses: MetaMask/action-create-release-pr@v1
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
with:
42+
release-type: ${{ github.event.inputs.release-type }}
43+
release-version: ${{ github.event.inputs.release-version }}
44+
artifacts-path: gh-action__release-authors
45+
# Upload the release author artifact for use in subsequent workflows
46+
- uses: actions/upload-artifact@v2
47+
with:
48+
name: release-authors
49+
path: gh-action__release-authors
50+
if-no-files-found: error

.github/workflows/publish-release.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
publish-release:
9+
permissions:
10+
contents: write
11+
if: |
12+
github.event.pull_request.merged == true &&
13+
startsWith(github.event.pull_request.head.ref, 'release/')
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
# We check out the release pull request's base branch, which will be
19+
# used as the base branch for all git operations.
20+
ref: ${{ github.event.pull_request.base.ref }}
21+
- name: Get Node.js version
22+
id: nvm
23+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
24+
- uses: actions/setup-node@v2
25+
with:
26+
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
27+
- uses: MetaMask/action-publish-release@v1
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Require Additional Reviewer for Releases
2+
3+
on:
4+
pull_request:
5+
pull_request_review:
6+
7+
jobs:
8+
require-additional-reviewer:
9+
permissions:
10+
actions: read
11+
contents: read
12+
pull-requests: read
13+
statuses: write
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
# If the base branch has been merged into the release branch, we
19+
# need to find the earliest common ancestor commit of the base and
20+
# release branches.
21+
fetch-depth: 0
22+
# We want the head / feature branch to be checked out, and we will
23+
# compare it to the base branch in the action.
24+
ref: ${{ github.event.pull_request.head.ref }}
25+
- uses: MetaMask/action-require-additional-reviewer@v1
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
with:
29+
read-org-token: ${{ secrets.ORG_READER }}

.gitignore

+30-48
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,55 @@
1+
.DS_Store
2+
dist/
3+
coverage/
14

2-
# Created by https://www.gitignore.io/api/osx,node
3-
4-
# Build directory
5-
/dist/
6-
7-
### Node ###
85
# Logs
96
logs
107
*.log
118
npm-debug.log*
12-
package-lock.json
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1315

1416
# Runtime data
1517
pids
1618
*.pid
1719
*.seed
1820
*.pid.lock
1921

20-
# Directory for instrumented libs generated by jscoverage/JSCover
21-
lib-cov
22-
2322
# Coverage directory used by tools like istanbul
2423
coverage
24+
*.lcov
2525

2626
# nyc test coverage
2727
.nyc_output
2828

29-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
30-
.grunt
31-
32-
# Bower dependency directory (https://bower.io/)
33-
bower_components
34-
3529
# node-waf configuration
3630
.lock-wscript
3731

38-
# Compiled binary addons (http://nodejs.org/api/addons.html)
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
3933
build/Release
4034

4135
# Dependency directories
42-
node_modules
43-
jspm_packages
36+
node_modules/
37+
38+
# TypeScript cache
39+
*.tsbuildinfo
4440

4541
# Optional npm cache directory
4642
.npm
4743

4844
# Optional eslint cache
4945
.eslintcache
5046

47+
# Microbundle cache
48+
.rpt2_cache/
49+
.rts2_cache_cjs/
50+
.rts2_cache_es/
51+
.rts2_cache_umd/
52+
5153
# Optional REPL history
5254
.node_repl_history
5355

@@ -59,34 +61,14 @@ jspm_packages
5961

6062
# dotenv environment variables file
6163
.env
64+
.env.test
6265

66+
# Stores VSCode versions used for testing VSCode extensions
67+
.vscode-test
6368

64-
### OSX ###
65-
*.DS_Store
66-
.AppleDouble
67-
.LSOverride
68-
69-
# Icon must end with two \r
70-
Icon
71-
72-
73-
# Thumbnails
74-
._*
75-
76-
# Files that might appear in the root of a volume
77-
.DocumentRevisions-V100
78-
.fseventsd
79-
.Spotlight-V100
80-
.TemporaryItems
81-
.Trashes
82-
.VolumeIcon.icns
83-
.com.apple.timemachine.donotpresent
84-
85-
# Directories potentially created on remote AFP share
86-
.AppleDB
87-
.AppleDesktop
88-
Network Trash Folder
89-
Temporary Items
90-
.apdisk
91-
92-
# End of https://www.gitignore.io/api/osx,node
69+
# yarn v2
70+
.yarn/cache
71+
.yarn/unplugged
72+
.yarn/build-state.yml
73+
.yarn/install-state.gz
74+
.pnp.*

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v12
1+
v14

.yarnrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ignore-scripts true

0 commit comments

Comments
 (0)