Skip to content

Commit d790558

Browse files
committed
chore: migrate to package.json-based linting package management
Move version definition of npm packages to package.json & package-lock.json: - doctoc - markdown-link-check - prettier Update linting workflows. Enable npm updating through Dependabot. Add scripts and documentation to aid local linting.
1 parent a61eacf commit d790558

11 files changed

Lines changed: 2429 additions & 37 deletions

File tree

.github/dependabot.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
version: 2
22
updates:
33
- package-ecosystem: github-actions
4-
directory: '/'
4+
directory: /
55
schedule:
6-
interval: daily
6+
interval: weekly
77
open-pull-requests-limit: 10
8+
- package-ecosystem: npm
9+
directory: /
10+
schedule:
11+
interval: weekly
12+
cooldown:
13+
default-days: 5

.github/workflows/doctoc.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ name: Check generated TOCs
33
on:
44
pull_request:
55
paths:
6-
- 'README.md'
7-
- 'docs/BestPractices.md'
8-
- '.github/workflows/doctoc.yml'
6+
- README.md
7+
- CONTRIBUTING.md
8+
- docs/BestPractices.md
9+
- .github/workflows/doctoc.yml
10+
- 'package*.json'
11+
workflow_dispatch:
912

1013
permissions:
1114
contents: read
@@ -15,17 +18,14 @@ jobs:
1518
name: Doc TOC Check
1619
runs-on: ubuntu-latest
1720
steps:
18-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
19-
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
21+
- name: Check out repo
22+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23+
- name: Set up Node.js
24+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
2025
with:
21-
node-version: 'lts/*'
22-
- name: Install doctoc
23-
run: npm i -g doctoc
24-
- name: Create README copy and diff with doctoc
25-
run: cp README.md README.md.tmp &&
26-
doctoc --title='## Table of Contents' --github README.md &&
27-
diff -q README.md README.md.tmp
28-
- name: Create "docs/BestPractices.md" copy and diff with doctoc
29-
run: cp docs/BestPractices.md docs/BestPractices.md.tmp &&
30-
doctoc --title='## Table of Contents' --github docs/BestPractices.md &&
31-
diff -q docs/BestPractices.md docs/BestPractices.md.tmp
26+
node-version-file: .node-version
27+
cache: npm
28+
- name: Install dependencies
29+
run: npm ci
30+
- name: Run doctoc
31+
run: npm run format:toc:check

.github/workflows/markdown-link-check.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ on:
44
pull_request:
55
paths:
66
- '**/*.md'
7-
- 'markdown_link_check_config.json'
8-
- '.github/workflows/markdown-link-check.yml'
7+
- markdown_link_check_config.json
8+
- .github/workflows/markdown-link-check.yml
9+
- 'package*.json'
10+
workflow_dispatch:
911

1012
permissions:
1113
contents: read
@@ -14,11 +16,14 @@ jobs:
1416
markdown-link-check:
1517
runs-on: ubuntu-latest
1618
steps:
17-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
18-
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
19+
- name: Check out repo
20+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
21+
- name: Set up Node.js
22+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
1923
with:
20-
node-version: 'lts/*'
21-
- name: Install markdown-link-check
22-
run: npm i -g markdown-link-check@3.14.2
24+
node-version-file: .node-version
25+
cache: npm
26+
- name: Install dependencies
27+
run: npm ci
2328
- name: Run markdown-link-check on MD files
24-
run: find . -name "*.md" | xargs -n 1 markdown-link-check -c markdown_link_check_config.json -q
29+
run: npm run check:markdown-links

.github/workflows/prettier.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Check Prettier formatting
22

3-
on: [pull_request]
3+
on: [pull_request, workflow_dispatch]
44

55
permissions:
66
contents: read
@@ -9,8 +9,14 @@ jobs:
99
prettier:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
13-
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
12+
- name: Check out repo
13+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
14+
- name: Set up Node.js
15+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
1416
with:
15-
node-version: 'lts/*'
16-
- run: npx prettier@3.9.5 --check .
17+
node-version-file: .node-version
18+
cache: npm
19+
- name: Install dependencies
20+
run: npm ci
21+
- name: Run Prettier
22+
run: npm run format:prettier:check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
min-release-age=5
2+
save-exact=true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

CONTRIBUTING.md

Lines changed: 88 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
# Contributing to docker-node
22

3-
Thank you for your contribution. Here are a set of guidelines for contributing to the docker-node project.
3+
Thank you for your contribution. Here are guidelines for contributing to the docker-node project.
4+
5+
<!-- prettier-ignore-start -->
6+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
7+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
8+
## Table of Contents
9+
10+
- [Governance and decision making](#governance-and-decision-making)
11+
- [Discussion Areas](#discussion-areas)
12+
- [Prerequisites](#prerequisites)
13+
- [Pull requests](#pull-requests)
14+
- [Linting](#linting)
15+
- [Link checks](#link-checks)
16+
- [Version Updates](#version-updates)
17+
- [Image Creation Automation](#image-creation-automation)
18+
- [Image Creation Manually](#image-creation-manually)
19+
- [Adding dependencies to the base images](#adding-dependencies-to-the-base-images)
20+
21+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
22+
<!-- prettier-ignore-end -->
423

524
## Governance and decision making
625

@@ -24,6 +43,71 @@ You can use Node.js channels (prefixed by `#nodejs-`) in the [OpenJSF Slack](htt
2443

2544
- [#nodejs-release](https://openjs-foundation.slack.com/archives/C019MGJQ8RH) is linked to the [Node.js Release Working Group](https://github.com/nodejs/release#readme) responsible for the upstream releases of Node.js used by this repo.
2645

46+
## Prerequisites
47+
48+
To contribute to this repo, install:
49+
50+
- [git](https://git-scm.com/)
51+
- [Docker](https://docs.docker.com/get-started/get-docker/)
52+
- [Node.js](https://nodejs.org/en/download) LTS version as specified in [.node-version](./.node-version)
53+
54+
[fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) and [clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) this repo, then install npm dependencies.
55+
Replace `<my-github-username>` with the username of your fork in the instructions below:
56+
57+
```shell
58+
git clone https://github.com/<my-github-username>/docker-node
59+
cd docker-node
60+
git remote add upstream https://github.com/nodejs/docker-node
61+
git remote update
62+
npm ci # install npm dependencies
63+
```
64+
65+
## Pull requests
66+
67+
Contributions are handled through GitHub pull requests. Branch from the default branch `main` and create a new branch, for example:
68+
69+
```shell
70+
git checkout main
71+
git checkout -b my-branch
72+
```
73+
74+
Make changes in your branch and then submit your contribution as a [pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) (PR), targeting the branch `main`.
75+
76+
## Linting
77+
78+
After making changes, execute the following to check for correct formatting.
79+
This runs the linting scripts `format:toc:check` and `format:prettier:check`.
80+
81+
```shell
82+
npm run lint
83+
```
84+
85+
To fix any linting issues that are automatically fixable, execute:
86+
87+
```shell
88+
npm run lint:fix
89+
```
90+
91+
Alternatively use any of the following commands to call one of the underlying linting utilities:
92+
93+
| Command | Purpose |
94+
| ------------------------------- | --------------------------------------- |
95+
| `npm run format:toc` | Reformats any Table of Contents |
96+
| `npm run format:toc:check` | Read-only Table of Contents check |
97+
| `npm run format:prettier` | Reformats multiple types of source code |
98+
| `npm run format:prettier:check` | Read-only prettier check |
99+
100+
## Link checks
101+
102+
Execute the following to check links in Markdown files:
103+
104+
```shell
105+
npm run check:markdown-links
106+
```
107+
108+
If you are running on Microsoft Windows, run the above command in a Git Bash terminal window.
109+
[Git for Windows](https://gitforwindows.org/) includes Git Bash.
110+
27111
## Version Updates
28112

29113
New **Node.js** releases are released as soon as possible.
@@ -59,14 +143,12 @@ If you believe there is a need for a manual PR, and you are not a member of the
59143
please first open an issue to describe the update problem
60144
and your suggestion to resolve it.
61145

62-
To set up a version update PR, follow these instructions:
146+
To set up a version update pull request, see the [Pull Requests](#pull-requests) section above and follow these instructions:
63147

64-
1. [Fork this project.](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
65-
1. [Clone the forked repository.](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)
66-
1. Create a branch for the update PR. For example, `git checkout main; git checkout -b version-update`.
148+
1. Create a `version-update` branch
67149
1. Run `./update.sh`. You can see additional options by using the built-in help documentation with `./update.sh -h`. This script will automatically update the appropriate files with the latest versions and checksums.
68150
1. Commit the modified files to the `version-update` branch and push the branch to your fork.
69-
1. [Create a PR to merge the branch from your fork into this project's default branch.](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).
151+
1. Create a pull request.
70152

71153
When a new Node.js release line is expected, additional preparation is necessary, including updates to the
72154
[versions.json](./versions.json) file and creation of a major version directory, populated with generated files.

0 commit comments

Comments
 (0)