Skip to content

Commit

Permalink
feat(yarn-sdks): Add hook to generate Yarn SDKs
Browse files Browse the repository at this point in the history
Ensure Yarn SDKs remain up-to-date. Run Prettier on VSCode settings
within the same hook to prevent formatting conflicts with MegaLinter,
which also runs Prettier. Define the hook as a script since system hooks
don't support running multiple commands.
  • Loading branch information
Kurt-von-Laven committed Sep 20, 2023
1 parent 9228b47 commit d1a6ae6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@
https://yarnpkg.com/cli/npm/audit for more details.
args: [--all, --recursive]

- id: yarn-sdks
name: Generate Yarn SDKs
entry: src/yarn-sdks.sh
language: script
files: \.yarn/sdks/|yarn(-(\d+\.){2}\d+\.cjs|\.lock)
pass_filenames: false
description: >
Generate SDKs and settings for editors specified in
`.yarn/sdks/integrations.yml`. Format VSCode settings with Prettier to
prevent formatting conflicts with MegaLinter. See
https://yarnpkg.com/sdks/cli/default for more details.
- id: yarn-build
name: Build the app
entry: yarn run build
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Hooks for Use With the [pre-commit](https://pre-commit.com) Framework
- [`yarn-install`](#yarn-install)
- [`yarn-dedupe`](#yarn-dedupe)
- [`yarn-audit`](#yarn-audit)
- [`yarn-sdks`](#yarn-sdks)
- [`yarn-build`](#yarn-build)
- [`yarn-test`](#yarn-test)
- [`megalinter-incremental`](#megalinter-incremental)
Expand Down Expand Up @@ -100,6 +101,14 @@ Deduplicate Yarn dependencies by running
Perform security audit of Yarn dependencies by running
[`yarn npm audit --all --recursive`](https://yarnpkg.com/cli/npm/audit).

### `yarn-sdks`

Generate SDKs and settings for editors specified in
`.yarn/sdks/integrations.yml` by running
[`yarn run sdks && yarn run prettier --write .vscode/settings.json`](https://yarnpkg.com/sdks/cli/default).
Format VSCode settings with Prettier to prevent formatting conflicts with
MegaLinter.

### `yarn-build`

Run the `"build"` script in `package.json` via
Expand Down
6 changes: 6 additions & 0 deletions src/yarn-sdks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -o errexit -o noglob -o pipefail -o nounset

yarn run sdks
yarn run prettier --write .vscode/settings.json

0 comments on commit d1a6ae6

Please sign in to comment.