Skip to content

Commit 8f9dc3d

Browse files
committed
Added metamask module template
1 parent 537b90c commit 8f9dc3d

34 files changed

+12454
-5351
lines changed

.depcheckrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"ignores": [
3+
"@lavamoat/allow-scripts",
4+
"@lavamoat/preinstall-always-fail",
5+
"@metamask/auto-changelog",
6+
"@types/*",
7+
"prettier-plugin-packagejson",
8+
"ts-node",
9+
"typedoc"
10+
]
11+
}

.editorconfig

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
# EditorConfig is awesome: http://EditorConfig.org
2-
3-
# top-most EditorConfig file
41
root = true
52

6-
# Unix-style newlines with a newline ending every file
73
[*]
84
indent_style = space
95
indent_size = 2
10-
tab_width = 2
116
end_of_line = lf
127
charset = utf-8
138
trim_trailing_whitespace = true
14-
insert_final_newline = true
9+
insert_final_newline = true

.eslintrc.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
root: true,
3+
4+
extends: ['@metamask/eslint-config'],
5+
6+
overrides: [
7+
{
8+
files: ['*.ts'],
9+
extends: ['@metamask/eslint-config-typescript'],
10+
},
11+
12+
{
13+
files: ['*.js'],
14+
parserOptions: {
15+
sourceType: 'script',
16+
},
17+
extends: ['@metamask/eslint-config-nodejs'],
18+
},
19+
20+
{
21+
files: ['*.test.ts', '*.test.js'],
22+
extends: [
23+
'@metamask/eslint-config-jest',
24+
'@metamask/eslint-config-nodejs',
25+
],
26+
},
27+
],
28+
29+
ignorePatterns: [
30+
'!.eslintrc.js',
31+
'!.prettierrc.js',
32+
'dist/',
33+
'docs/',
34+
'.yarn/',
35+
],
36+
};

.gitattributes

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* text=auto
2+
3+
yarn.lock linguist-generated=false
4+
5+
# yarn v3
6+
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
7+
/.yarn/releases/** binary
8+
/.yarn/plugins/** binary

.github/CODEOWNERS

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Lines starting with '#' are comments.
2+
# Each line is a file pattern followed by one or more owners.
3+
4+
* @MetaMask/devs

.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/pull_request_template.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!--
2+
Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes:
3+
4+
* What is the current state of things and why does it need to change?
5+
* What is the solution your changes offer and how does it work?
6+
7+
Are there any issues or other links reviewers should consult to understand this pull request better? For instance:
8+
9+
* Fixes #12345
10+
* See: #67890
11+
-->
12+
13+
## Examples
14+
15+
<!--
16+
Are there any examples of this change being used in another repository?
17+
18+
When considering changes to the MetaMask module template, it's strongly preferred that the change be experimented with in another repository first. This gives reviewers a better sense of how the change works, making it less likely the change will need to be reverted or adjusted later.
19+
-->

.github/workflows/build-lint-test.yml

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Build, Lint, and Test
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
prepare:
8+
name: Prepare
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Use Node.js
13+
uses: actions/setup-node@v3
14+
with:
15+
node-version-file: '.nvmrc'
16+
cache: 'yarn'
17+
- name: Install Yarn dependencies
18+
run: yarn --immutable
19+
20+
build:
21+
name: Build
22+
runs-on: ubuntu-latest
23+
needs:
24+
- prepare
25+
strategy:
26+
matrix:
27+
node-version: [16.x, 18.x, 20.x]
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: Use Node.js ${{ matrix.node-version }}
31+
uses: actions/setup-node@v3
32+
with:
33+
node-version: ${{ matrix.node-version }}
34+
cache: 'yarn'
35+
- run: yarn --immutable --immutable-cache
36+
- run: yarn build
37+
- name: Require clean working directory
38+
shell: bash
39+
run: |
40+
if ! git diff --exit-code; then
41+
echo "Working tree dirty at end of job"
42+
exit 1
43+
fi
44+
45+
lint:
46+
name: Lint
47+
runs-on: ubuntu-latest
48+
needs:
49+
- prepare
50+
strategy:
51+
matrix:
52+
node-version: [16.x, 18.x, 20.x]
53+
steps:
54+
- uses: actions/checkout@v3
55+
- name: Use Node.js ${{ matrix.node-version }}
56+
uses: actions/setup-node@v3
57+
with:
58+
node-version: ${{ matrix.node-version }}
59+
cache: 'yarn'
60+
- run: yarn --immutable --immutable-cache
61+
- run: yarn lint
62+
- name: Validate RC changelog
63+
if: ${{ startsWith(github.head_ref, 'release/') }}
64+
run: yarn auto-changelog validate --rc
65+
- name: Validate changelog
66+
if: ${{ !startsWith(github.head_ref, 'release/') }}
67+
run: yarn auto-changelog validate
68+
- name: Require clean working directory
69+
shell: bash
70+
run: |
71+
if ! git diff --exit-code; then
72+
echo "Working tree dirty at end of job"
73+
exit 1
74+
fi
75+
76+
test:
77+
name: Test
78+
runs-on: ubuntu-latest
79+
needs:
80+
- prepare
81+
strategy:
82+
matrix:
83+
node-version: [16.x, 18.x, 20.x]
84+
steps:
85+
- uses: actions/checkout@v3
86+
- name: Use Node.js ${{ matrix.node-version }}
87+
uses: actions/setup-node@v3
88+
with:
89+
node-version: ${{ matrix.node-version }}
90+
cache: 'yarn'
91+
- run: yarn --immutable --immutable-cache
92+
- run: yarn test
93+
- name: Require clean working directory
94+
shell: bash
95+
run: |
96+
if ! git diff --exit-code; then
97+
echo "Working tree dirty at end of job"
98+
exit 1
99+
fi
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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, or patch. 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@v3
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: Setup Node.js
33+
uses: actions/setup-node@v3
34+
with:
35+
node-version-file: '.nvmrc'
36+
- uses: MetaMask/action-create-release-pr@v1
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
with:
40+
release-type: ${{ github.event.inputs.release-type }}
41+
release-version: ${{ github.event.inputs.release-version }}

.github/workflows/main.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
check-workflows:
10+
name: Check workflows
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Download actionlint
15+
id: download-actionlint
16+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23
17+
shell: bash
18+
- name: Check workflow files
19+
run: ${{ steps.download-actionlint.outputs.executable }} -color
20+
shell: bash
21+
22+
build-lint-test:
23+
name: Build, lint, and test
24+
uses: ./.github/workflows/build-lint-test.yml
25+
26+
all-jobs-completed:
27+
name: All jobs completed
28+
runs-on: ubuntu-latest
29+
needs:
30+
- check-workflows
31+
- build-lint-test
32+
outputs:
33+
PASSED: ${{ steps.set-output.outputs.PASSED }}
34+
steps:
35+
- name: Set PASSED output
36+
id: set-output
37+
run: echo "PASSED=true" >> "$GITHUB_OUTPUT"
38+
39+
all-jobs-pass:
40+
name: All jobs pass
41+
if: ${{ always() }}
42+
runs-on: ubuntu-latest
43+
needs: all-jobs-completed
44+
steps:
45+
- name: Check that all jobs have passed
46+
run: |
47+
passed="${{ needs.all-jobs-completed.outputs.PASSED }}"
48+
if [[ $passed != "true" ]]; then
49+
exit 1
50+
fi
51+
52+
is-release:
53+
# Filtering by `push` events ensures that we only release from the `main` branch, which is a
54+
# requirement for our npm publishing environment.
55+
# The commit author should always be 'github-actions' for releases created by the
56+
# 'create-release-pr' workflow, so we filter by that as well to prevent accidentally
57+
# triggering a release.
58+
if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions')
59+
needs: all-jobs-pass
60+
outputs:
61+
IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }}
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: MetaMask/action-is-release@v1
65+
id: is-release
66+
67+
publish-release:
68+
needs: is-release
69+
if: needs.is-release.outputs.IS_RELEASE == 'true'
70+
name: Publish release
71+
permissions:
72+
contents: write
73+
uses: ./.github/workflows/publish-release.yml
74+
secrets:
75+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
76+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
77+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/publish-docs.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish docs to GitHub Pages
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
destination_dir:
7+
required: true
8+
type: string
9+
secrets:
10+
PUBLISH_DOCS_TOKEN:
11+
required: true
12+
13+
jobs:
14+
publish-docs-to-gh-pages:
15+
name: Publish docs to GitHub Pages
16+
runs-on: ubuntu-latest
17+
environment: github-pages
18+
permissions:
19+
contents: write
20+
steps:
21+
- name: Ensure `destination_dir` is not empty
22+
if: ${{ inputs.destination_dir == '' }}
23+
run: exit 1
24+
- name: Checkout the repository
25+
uses: actions/checkout@v3
26+
- name: Use Node.js
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version-file: '.nvmrc'
30+
cache: 'yarn'
31+
- name: Install npm dependencies
32+
run: yarn --immutable
33+
- name: Run build script
34+
run: yarn build:docs
35+
- name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch
36+
uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935
37+
with:
38+
# This `PUBLISH_DOCS_TOKEN` needs to be manually set per-repository.
39+
# Look in the repository settings under "Environments", and set this token in the `github-pages` environment.
40+
personal_token: ${{ secrets.PUBLISH_DOCS_TOKEN }}
41+
publish_dir: ./docs
42+
destination_dir: ${{ inputs.destination_dir }}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Publish main branch docs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: main
6+
7+
jobs:
8+
publish-to-gh-pages:
9+
name: Publish docs to `staging` directory of `gh-pages` branch
10+
permissions:
11+
contents: write
12+
uses: ./.github/workflows/publish-docs.yml
13+
with:
14+
destination_dir: staging
15+
secrets:
16+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}

0 commit comments

Comments
 (0)