Skip to content

Commit

Permalink
Update changelog validation scripts to match MetaMask/core (#2741)
Browse files Browse the repository at this point in the history
In an effort to standardise the repository more, I'm working on matching
different parts of our repository configuration to match
`MetaMask/core`. In this PR I've updated our changelog validation
scripts, and formatted the changelogs using Prettier.

This also solves a long standing issue where we would have to format
changelogs each time after creating a new release PR.

There are a lot of changes in this PR, but the notable changes are in
the `package.json` files:

- `lint:changelog` is now `changelog:validate`.
- `changelog:validate` now accepts a `--fix` parameter which will be
properly forwarded to the validation script.
- There is a new `changelog:update` script.
  • Loading branch information
Mrtenz authored Sep 19, 2024
1 parent e3cbd4a commit 9c208ac
Show file tree
Hide file tree
Showing 98 changed files with 1,626 additions and 144 deletions.
12 changes: 10 additions & 2 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,20 @@ gen_enforced_field(WorkspaceCwd, 'publishConfig.registry', 'https://registry.npm

% The "changelog:validate" script for each published package must run a common
% script with the name of the package as an argument.
gen_enforced_field(WorkspaceCwd, 'scripts.lint:changelog', ChangelogValidationScript) :-
gen_enforced_field(WorkspaceCwd, 'scripts.changelog:validate', ChangelogValidationScript) :-
\+ workspace_field(WorkspaceCwd, 'private', true),
workspace_field(WorkspaceCwd, 'name', WorkspacePackageName),
relative_path(WorkspaceCwd, 'scripts/validate-changelog.sh', BaseChangelogValidationScript),
atomic_list_concat([BaseChangelogValidationScript, ' ', WorkspacePackageName], ChangelogValidationScript).

% The "changelog:update" script for each published package must run a common
% script with the name of the package as an argument.
gen_enforced_field(WorkspaceCwd, 'scripts.changelog:update', ChangelogUpdateScript) :-
\+ workspace_field(WorkspaceCwd, 'private', true),
workspace_field(WorkspaceCwd, 'name', WorkspacePackageName),
relative_path(WorkspaceCwd, 'scripts/update-changelog.sh', BaseChangelogUpdateScript),
atomic_list_concat([BaseChangelogUpdateScript, ' ', WorkspacePackageName], ChangelogUpdateScript).

% The "lint:dependencies" script must be the same for all packages.
gen_enforced_field(WorkspaceCwd, 'scripts.lint:dependencies', 'depcheck') :-
WorkspaceCwd \= '.'.
Expand Down Expand Up @@ -272,7 +280,7 @@ gen_enforced_field(WorkspaceCwd, 'scripts.test', 'yarn test:e2e') :-
is_example(WorkspaceCwd).
gen_enforced_field(WorkspaceCwd, 'scripts.test:e2e', 'jest') :-
is_example(WorkspaceCwd).
gen_enforced_field(WorkspaceCwd, 'scripts.lint', 'yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog && yarn lint:dependencies') :-
gen_enforced_field(WorkspaceCwd, 'scripts.lint', 'yarn lint:eslint && yarn lint:misc --check && yarn changelog:validate && yarn lint:dependencies') :-
is_example(WorkspaceCwd).
gen_enforced_field(WorkspaceCwd, 'scripts.lint:ci', 'yarn lint') :-
is_example(WorkspaceCwd).
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ GitHub action are used to automate the release process.
- Consolidate related changes into one change entry if it makes it easier to
comprehend.

Run `yarn lint:changelogs` to check that all changelogs are correctly
Run `yarn changelog:validates` to check that all changelogs are correctly
formatted.

Commit and push the branch.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
],
"scripts": {
"postinstall": "simple-git-hooks",
"changelog:update": "yarn workspaces foreach --all --parallel --interlaced --verbose run changelog:update",
"changelog:validate": "yarn workspaces foreach --all --parallel --interlaced --verbose run changelog:validate",
"lint:eslint": "eslint . --cache --ext js,jsx,ts,tsx",
"lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn '**/*.json' '**/*.md' '!**/CHANGELOG.md' '**/*.yml' '**/*.html'",
"lint:changelogs": "yarn workspaces foreach --all --parallel --verbose run lint:changelog",
"lint:dependencies": "yarn workspaces foreach --all --parallel --verbose run lint:dependencies && yarn dedupe --check",
"lint:tsconfig": "node scripts/verify-tsconfig.mjs",
"lint": "yarn workspaces foreach --all --parallel run lint:eslint && yarn lint:misc --check && yarn lint:tsconfig && yarn constraints && yarn lint:dependencies",
Expand Down
32 changes: 32 additions & 0 deletions packages/create-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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/),
Expand All @@ -7,68 +8,99 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

## [4.0.4]

### Fixed

- Fix invalid types in type declaration in some cases ([#2714](https://github.com/MetaMask/snaps/pull/2714))

## [4.0.3]

### Fixed

- Fix ESM version of the package ([#2682](https://github.com/MetaMask/snaps/pull/2682))
- This fixes the ESM version of the package to be fully compliant with the ESM
standard.

## [4.0.2]

### Fixed

- Fix detection of minimum Node.js version ([#2292](https://github.com/MetaMask/snaps/pull/2292))

## [4.0.1]

### Fixed

- Fix minor build configuration problems ([#2220](https://github.com/MetaMask/snaps/pull/2220))

## [4.0.0]

### Changed

- **BREAKING:** Update ESM build to be fully compliant with the ESM standard ([#2210](https://github.com/MetaMask/snaps/pull/2210))

## [3.1.1]

### Changed

- Bump several MetaMask dependencies ([#1964](https://github.com/MetaMask/snaps/pull/1964))

## [3.1.0]

### Added

- Create an initial commit when creating a Snap from the template ([#1917](https://github.com/MetaMask/snaps/pull/1917))

### Fixed

- Handle unhandled errors ([#1916](https://github.com/MetaMask/snaps/pull/1916))

## [3.0.1]

### Changed

- Update multiple MetaMask dependencies ([#1841](https://github.com/MetaMask/snaps/pull/1841))

## [3.0.0]

### Changed

- **BREAKING:** Bump minimum Node.js version to `^18.16.0` ([#1741](https://github.com/MetaMask/snaps/pull/1741))

## [2.0.0]

### Changed

- **BREAKING:** Bump minimum Node.js version to `18.6.0` ([#1789](https://github.com/MetaMask/snaps/pull/1789))

## [1.0.1]

### Fixed

- Fix shell command injection ([#1784](https://github.com/MetaMask/snaps/pull/1784))

## [1.0.0]

### Changed

- Initial stable release from main branch ([#1757](https://github.com/MetaMask/snaps/pull/1757))

## [0.37.4-flask.1]

### Changed

- Bump `metamask/utils` and `metamask/snaps-registry` ([#1738](https://github.com/MetaMask/snaps/pull/1738), [#1694](https://github.com/MetaMask/snaps/pull/1694))

## [0.37.3-flask.1]

### Changed

- Remove unused dependencies ([#1674](https://github.com/MetaMask/snaps/pull/1674))

## [0.37.2-flask.1]

### Changed

- Release package independently ([#1600](https://github.com/MetaMask/snaps/pull/1600))
- The version of the package no longer needs to match the version of all other
MetaMask Snaps packages.
Expand Down
7 changes: 4 additions & 3 deletions packages/create-snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@
"posttest": "jest-it-up",
"test:watch": "yarn test --watch",
"test:ci": "yarn test",
"lint:changelog": "../../scripts/validate-changelog.sh @metamask/create-snap",
"lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
"lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" --ignore-path ../../.gitignore",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog && yarn lint:dependencies",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn changelog:validate && yarn lint:dependencies",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"publish:package": "../../scripts/publish-package.sh",
"lint:ci": "yarn lint",
"publish:preview": "yarn npm publish --tag preview",
"lint:dependencies": "depcheck"
"lint:dependencies": "depcheck",
"changelog:update": "../../scripts/update-changelog.sh @metamask/create-snap",
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/create-snap"
},
"dependencies": {
"@metamask/snaps-utils": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" \"!packages/**\" --ignore-path ../../.gitignore",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"lint:ci": "yarn lint:eslint && yarn lint:misc --check",
"lint:changelogs": "yarn workspaces foreach --worktree --parallel --verbose run lint:changelog",
"changelog:validates": "yarn workspaces foreach --worktree --parallel --verbose run changelog:validate",
"lint:dependencies": "depcheck"
},
"devDependencies": {
Expand Down
22 changes: 22 additions & 0 deletions packages/examples/packages/bip32/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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/),
Expand All @@ -7,50 +8,71 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

## [2.2.1]

### Fixed

- Bump MetaMask dependencies

## [2.2.0]

### Added

- Add support for `ed25519Bip32` to the BIP-32 example snap ([#2428](https://github.com/MetaMask/snaps/pull/2428))

## [2.1.2]

### Changed

- Use error wrappers ([#2178](https://github.com/MetaMask/snaps/pull/2178))

## [2.1.1]

### Changed

- Remove snap icon ([#2189](https://github.com/MetaMask/snaps/pull/2189))

## [2.1.0]

### Changed

- Use `@metamask/snaps-sdk` package ([#1930](https://github.com/MetaMask/snaps/pull/1930),
[#1946](https://github.com/MetaMask/snaps/pull/1946), [#1950](https://github.com/MetaMask/snaps/pull/1950),
[#1949](https://github.com/MetaMask/snaps/pull/1949), [#1954](https://github.com/MetaMask/snaps/pull/1954))
- This package replaces the `@metamask/snaps-types` and
- `@metamask/snaps-ui` packages, and is much more lightweight.

## [2.0.1]

### Changed

- Update multiple MetaMask dependencies ([#1841](https://github.com/MetaMask/snaps/pull/1841))

## [2.0.0]

### Changed

- **BREAKING:** Bump minimum Node.js version to `^18.16.0` ([#1741](https://github.com/MetaMask/snaps/pull/1741))

## [1.0.0]

### Changed

- Initial stable release from main branch ([#1757](https://github.com/MetaMask/snaps/pull/1757))

## [0.37.3-flask.1]

### Changed

- Use `polyfills` option for specifying Node.js polyfills ([#1650](https://github.com/MetaMask/snaps/pull/1650))

### Fixed

- Remove unused dependencies ([#1680](https://github.com/MetaMask/snaps/pull/1680))

## [0.37.2-flask.1]

### Changed

- Release package independently ([#1600](https://github.com/MetaMask/snaps/pull/1600))
- The version of the package no longer needs to match the version of all other
MetaMask Snaps packages.
Expand Down
7 changes: 4 additions & 3 deletions packages/examples/packages/bip32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"build": "mm-snap build",
"build:clean": "yarn clean && yarn build",
"clean": "rimraf \"dist\"",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog && yarn lint:dependencies",
"lint:changelog": "../../../../scripts/validate-changelog.sh @metamask/bip32-example-snap",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn changelog:validate && yarn lint:dependencies",
"lint:ci": "yarn lint",
"lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
Expand All @@ -27,7 +26,9 @@
"test": "yarn test:e2e",
"test:e2e": "jest",
"publish:preview": "yarn npm publish --tag preview",
"lint:dependencies": "depcheck"
"lint:dependencies": "depcheck",
"changelog:update": "../../../../scripts/update-changelog.sh @metamask/bip32-example-snap",
"changelog:validate": "../../../../scripts/validate-changelog.sh @metamask/bip32-example-snap"
},
"dependencies": {
"@metamask/key-tree": "^9.1.2",
Expand Down
22 changes: 22 additions & 0 deletions packages/examples/packages/bip44/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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/),
Expand All @@ -7,51 +8,72 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

## [2.1.3]

### Fixed

- Bump MetaMask dependencies

## [2.1.2]

### Changed

- Use error wrappers ([#2178](https://github.com/MetaMask/snaps/pull/2178))

## [2.1.1]

### Changed

- Remove snap icon ([#2189](https://github.com/MetaMask/snaps/pull/2189))

## [2.1.0]

### Changed

- Use `@metamask/snaps-sdk` package ([#1930](https://github.com/MetaMask/snaps/pull/1930),
[#1946](https://github.com/MetaMask/snaps/pull/1946), [#1950](https://github.com/MetaMask/snaps/pull/1950),
[#1949](https://github.com/MetaMask/snaps/pull/1949), [#1954](https://github.com/MetaMask/snaps/pull/1954))
- This package replaces the `@metamask/snaps-types` and
- `@metamask/snaps-ui` packages, and is much more lightweight.

## [2.0.1]

### Changed

- Update multiple MetaMask dependencies ([#1841](https://github.com/MetaMask/snaps/pull/1841))

## [2.0.0]

### Changed

- **BREAKING:** Bump minimum Node.js version to `^18.16.0` ([#1741](https://github.com/MetaMask/snaps/pull/1741))

## [1.0.0]

### Changed

- Initial stable release from main branch ([#1757](https://github.com/MetaMask/snaps/pull/1757))

## [0.38.1-flask.1]

### Changed

- Use `polyfills` option for specifying Node.js polyfills ([#1650](https://github.com/MetaMask/snaps/pull/1650))

### Fixed

- Remove unused dependencies ([#1680](https://github.com/MetaMask/snaps/pull/1680))

## [0.38.0-flask.1]

### Changed

- Update example to the new configuration format ([#1632](https://github.com/MetaMask/snaps/pull/1632))
- The example now uses Webpack instead of Browserify.

## [0.37.2-flask.1]

### Changed

- Release package independently ([#1600](https://github.com/MetaMask/snaps/pull/1600))
- The version of the package no longer needs to match the version of all other
MetaMask Snaps packages.
Expand Down
7 changes: 4 additions & 3 deletions packages/examples/packages/bip44/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"build": "mm-snap build",
"build:clean": "yarn clean && yarn build",
"clean": "rimraf \"dist\"",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog && yarn lint:dependencies",
"lint:changelog": "../../../../scripts/validate-changelog.sh @metamask/bip44-example-snap",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn changelog:validate && yarn lint:dependencies",
"lint:ci": "yarn lint",
"lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
Expand All @@ -27,7 +26,9 @@
"test": "yarn test:e2e",
"test:e2e": "jest",
"publish:preview": "yarn npm publish --tag preview",
"lint:dependencies": "depcheck"
"lint:dependencies": "depcheck",
"changelog:update": "../../../../scripts/update-changelog.sh @metamask/bip44-example-snap",
"changelog:validate": "../../../../scripts/validate-changelog.sh @metamask/bip44-example-snap"
},
"dependencies": {
"@metamask/key-tree": "^9.1.2",
Expand Down
Loading

0 comments on commit 9c208ac

Please sign in to comment.