diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fc12afc9..cf49673d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,6 +39,26 @@ The Practical Zero Trust articles are a bit different. They are templated, rather than freeform Markdown. Look at existing examples in [`src/pzt`](src/pzt) for reference. +## Prerequisites + +- [Node.js](https://nodejs.org/) >= 18 +- [pnpm](https://pnpm.io/) (`corepack enable` will activate it) +- [Vale](https://vale.sh/) +- [markdown-link-check](https://github.com/tcort/markdown-link-check) (`pnpm add -g markdown-link-check`) + +## Linting scripts + +After cloning the repository, run `pnpm install` and `vale sync`. + +```bash +pnpm check # lint prose + check links on changed files +pnpm check:all # lint prose + check links on all files +pnpm vale # lint all prose +pnpm vale:changed # lint prose in changed files only +pnpm links # check links in all files +pnpm links:changed # check links in changed files only +``` + ## Prose linting with vale We use [Vale](https://vale.sh/) to enforce consistent prose style. @@ -72,27 +92,29 @@ pnpm add -g mdx2vast ### Usage +The simplest way to run Vale is via pnpm scripts (see above). You can also run it directly: + ```bash -# Check all files -vale . +# Check all files (excluding auto-generated CLI reference) +vale --no-wrap --glob='!step-cli/reference/**' . # Check specific folder -vale step-ca/ +vale --no-wrap --glob='!step-cli/reference/**' step-ca/ # Check changed files only -git diff --name-only HEAD | grep '\.mdx$' | xargs vale +git diff --name-only origin/main -- '*.mdx' '*.md' | xargs -r vale --no-wrap --glob='!step-cli/reference/**' ``` ## Checking links locally -First: +Install markdown-link-check: ``` -npm install -g markdown-link-check +pnpm add -g markdown-link-check ``` -Then run: +The simplest way to check links is via pnpm scripts (see above). You can also run it directly: ``` -find . -name \*.mdx -not -path './node_modules/*' -print0 | xargs -0 -n1 markdown-link-check -q -c .github/mdl.config.json +find . -name '*.mdx' -not -path './node_modules/*' -print0 | xargs -0 -n1 markdown-link-check -q -c .github/mdl.config.json ``` diff --git a/package.json b/package.json new file mode 100644 index 00000000..573a14a4 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "smallstep-docs", + "version": "1.0.0", + "private": true, + "description": "Documentation for Smallstep projects and products", + "repository": { + "type": "git", + "url": "git+https://github.com/smallstep/docs.git" + }, + "license": "UNLICENSED", + "scripts": { + "vale": "vale --no-wrap --glob='!step-cli/reference/**' .", + "vale:changed": "git diff --name-only origin/main -- '*.mdx' '*.md' | xargs -r vale --no-wrap --glob='!step-cli/reference/**'", + "links": "find . -name '*.mdx' -not -path './node_modules/*' -print0 | xargs -0 -n1 markdown-link-check -q -c .github/mdl.config.json", + "links:changed": "git diff --name-only origin/main -- '*.mdx' | xargs -r -n1 markdown-link-check -q -c .github/mdl.config.json", + "check": "pnpm vale:changed && pnpm links:changed", + "check:all": "pnpm vale && pnpm links" + }, + "engines": { + "node": ">=18" + }, + "packageManager": "pnpm@9.0.5+sha1.6db99351548f394a1d96aa1de98dec032aef8823" +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 00000000..2b9f1883 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,5 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false