Skip to content

Commit

Permalink
Merge pull request #5627 from cookiecutter/dependabot/docker/{{cookie…
Browse files Browse the repository at this point in the history
…cutter.project_slug}}/compose/local/node/node-22.13-bookworm-slim

Bump node from 22.12 to 22.13
  • Loading branch information
browniebroke authored Jan 9, 2025
2 parents c5b60d2 + 2d54690 commit 1dbaeaa
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ jobs:
run: uv sync
- uses: actions/setup-node@v4
with:
node-version: "22.12"
node-version: "22.13"
- name: Bare Metal ${{ matrix.script.name }}
run: sh tests/test_bare.sh ${{ matrix.script.args }}
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ repos:
hooks:
- id: pyproject-fmt

- repo: local
hooks:
- id: node-version-checker
name: node-version-checker
entry: python scripts/node_version.py
language: python
files: .

ci:
autoupdate_schedule: weekly
skip: []
Expand Down
55 changes: 55 additions & 0 deletions scripts/node_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import json
from pathlib import Path

ROOT = Path(__file__).parent.parent
TEMPLATED_ROOT = ROOT / "{{cookiecutter.project_slug}}"
DOCKERFILE = TEMPLATED_ROOT / "compose" / "local" / "node" / "Dockerfile"
PACKAGE_JSON = TEMPLATED_ROOT / "package.json"
CI_YML = ROOT / ".github" / "workflows" / "ci.yml"


def main():
new_version = get_version_from_dockerfile()
old_version = get_version_from_package_json()
if old_version != new_version:
update_package_json_version(old_version, new_version)
update_ci_node_version(old_version, new_version)


def get_version_from_dockerfile():
# Extract version out of base image name:
# FROM docker.io/node:22.13-bookworm-slim
# -> 22.13
with DOCKERFILE.open("r") as f:
for line in f:
if "FROM docker.io/node:" in line:
_, _, docker_tag = line.partition(":")
version_str, _, _ = docker_tag.partition("-")
return version_str


def get_version_from_package_json():
package_json = json.loads(PACKAGE_JSON.read_text())
return package_json["engines"]["node"]


def update_package_json_version(old_version, new_version):
package_json_text = PACKAGE_JSON.read_text()
package_json_text = package_json_text.replace(
f'"node": "{old_version}"',
f'"node": "{new_version}"',
)
PACKAGE_JSON.write_text(package_json_text)


def update_ci_node_version(old_version, new_version):
yml_content = CI_YML.read_text()
yml_content = yml_content.replace(
f'node-version: "{old_version}"',
f'node-version: "{new_version}"',
)
CI_YML.write_text(yml_content)


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/node:22.12-bookworm-slim
FROM docker.io/node:22.13-bookworm-slim

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"webpack-merge": "^6.0.1"
},
"engines": {
"node": "22.12"
"node": "22.13"
},
"browserslist": [
"last 2 versions"
Expand Down

0 comments on commit 1dbaeaa

Please sign in to comment.