Skip to content

Commit ce9b74d

Browse files
committed
feat: restructure to the 7-stage standard, deepen stages 1-3, add starter project, CI, Docker and releases
1 parent abea8cb commit ce9b74d

33 files changed

Lines changed: 10567 additions & 6728 deletions

‎.dockerignore‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.git
2+
.github
3+
**/node_modules
4+
**/.venv
5+
**/__pycache__
6+
**/target
7+
**/obj
8+
**/dist
9+
**/build
10+
**/coverage
11+
**/.angular
12+
**/.next
13+
*.md
14+
!README.md
15+
Dockerfile
16+
.dockerignore
17+
coverage
18+
.env
19+
.env.*

‎.editorconfig‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_style = space
8+
indent_size = 2
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.{py,rs,java,kt,kts,cs,php}]
13+
indent_size = 4
14+
15+
[*.go]
16+
indent_style = tab
17+
indent_size = 4
18+
19+
[{Makefile,*.mk}]
20+
indent_style = tab
21+
22+
[*.md]
23+
max_line_length = off
24+
trim_trailing_whitespace = false

‎.github/workflows/ci.yml‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
# Must match EXPOSE in the Dockerfile and the port the process listens on.
18+
APP_PORT: "8080"
19+
HEALTH_PATH: "/health"
20+
21+
jobs:
22+
test:
23+
name: Install, test, build (Node ${{ matrix.node }})
24+
runs-on: ubuntu-latest
25+
strategy:
26+
matrix:
27+
node: [22, 24, 26]
28+
steps:
29+
- uses: actions/checkout@v5
30+
- uses: actions/setup-node@v5
31+
with:
32+
node-version: ${{ matrix.node }}
33+
cache: npm
34+
- run: npm ci
35+
- run: npm run lint --if-present
36+
- run: npm test
37+
- run: npm run build --if-present
38+
39+
docker:
40+
name: Docker image builds and answers on APP_PORT
41+
needs: test
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v5
45+
- uses: docker/setup-buildx-action@v3
46+
- name: Build image
47+
uses: docker/build-push-action@v6
48+
with:
49+
context: .
50+
load: true
51+
push: false
52+
tags: guide-app:ci
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max
55+
- name: Smoke test the container
56+
run: |
57+
docker run -d --name app -p 8080:${APP_PORT} guide-app:ci
58+
for _ in $(seq 1 30); do
59+
if curl -fsS "http://localhost:8080${HEALTH_PATH}" > /dev/null; then
60+
echo "Container answered on port ${APP_PORT}"; exit 0
61+
fi
62+
sleep 2
63+
done
64+
docker logs app
65+
exit 1

‎.github/workflows/docker.yml‎

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,49 @@
1+
# Optional: publish the image to Docker Hub on every push to main.
2+
# Skips cleanly when DOCKERHUB_USERNAME / DOCKERHUB_PASSWORD are not set.
13
name: Build and Publish Docker Image to DockerHub
24

35
on:
46
push:
57
branches: ["main"]
68

9+
permissions:
10+
contents: read
11+
712
jobs:
813
build:
914
runs-on: ubuntu-latest
1015

1116
steps:
12-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v5
18+
19+
- name: Check DockerHub Credentials
20+
id: check_creds
21+
run: |
22+
if [ -n "${{ secrets.DOCKERHUB_USERNAME }}" ] && [ -n "${{ secrets.DOCKERHUB_PASSWORD }}" ]; then
23+
echo "has_creds=true" >> $GITHUB_OUTPUT
24+
else
25+
echo "has_creds=false" >> $GITHUB_OUTPUT
26+
echo "DockerHub credentials not provided; skipping image push."
27+
fi
1328
1429
- name: DockerHub Login
15-
uses: docker/login-action@v2.1.0
30+
if: steps.check_creds.outputs.has_creds == 'true'
31+
uses: docker/login-action@v3
1632
with:
1733
username: ${{ secrets.DOCKERHUB_USERNAME }}
1834
password: ${{ secrets.DOCKERHUB_PASSWORD }}
1935

20-
- name: Build the Docker image
21-
run: docker build . --file Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/learn-javascript
36+
- name: Set up Docker Buildx
37+
if: steps.check_creds.outputs.has_creds == 'true'
38+
uses: docker/setup-buildx-action@v3
2239

23-
- name: Docker Push
24-
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/learn-javascript
40+
- name: Build and Push Docker image
41+
if: steps.check_creds.outputs.has_creds == 'true'
42+
uses: docker/build-push-action@v6
43+
with:
44+
context: .
45+
file: ./Dockerfile
46+
push: true
47+
tags: |
48+
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:latest
49+
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{ github.sha }}

‎.github/workflows/releases.yml‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,39 @@ on:
44
branches:
55
- main
66

7+
permissions:
8+
contents: write
9+
710
jobs:
811
changelog:
912
runs-on: ubuntu-latest
1013

1114
steps:
12-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
16+
17+
- name: Check Personal Access Token
18+
id: check_token
19+
run: |
20+
if [ -n "${{ secrets.PA_TOKEN }}" ]; then
21+
echo "has_token=true" >> $GITHUB_OUTPUT
22+
else
23+
echo "has_token=false" >> $GITHUB_OUTPUT
24+
echo "PA_TOKEN secret not configured; skipping automated release creation."
25+
fi
1326
14-
- name: conventional Changelog Action
27+
- name: Conventional Changelog Action
28+
if: steps.check_token.outputs.has_token == 'true'
1529
id: changelog
16-
uses: TriPSs/conventional-changelog-action@v3.7.1
30+
uses: TriPSs/conventional-changelog-action@v5
1731
with:
1832
github-token: ${{ secrets.PA_TOKEN }}
1933
version-file: './releases.json,./package.json'
2034

21-
- name: create release
22-
uses: actions/create-release@v1
23-
if: ${{ steps.changelog.outputs.skipped == 'false' }}
24-
env:
25-
GITHUB_TOKEN: ${{ secrets.PA_TOKEN }}
35+
- name: Create Release
36+
if: steps.check_token.outputs.has_token == 'true' && steps.changelog.outputs.skipped == 'false'
37+
uses: softprops/action-gh-release@v2
2638
with:
39+
token: ${{ secrets.PA_TOKEN }}
2740
tag_name: ${{ steps.changelog.outputs.tag }}
28-
release_name: ${{ steps.changelog.outputs.tag }}
29-
body: ${{ steps.changelog.outputs.clean_changelog }}
41+
name: ${{ steps.changelog.outputs.tag }}
42+
body: ${{ steps.changelog.outputs.clean_changelog }}

‎.gitignore‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,22 @@ dist_electron_release/
3838
# OS generated files
3939
.DS_Store
4040
Thumbs.db
41+
42+
# --- merged from the standard node template ---
43+
# Node / TypeScript
44+
out-tsc/
45+
coverage/
46+
.angular/cache
47+
.next/
48+
.nuxt/
49+
.turbo/
50+
*.tsbuildinfo
51+
yarn-error.log*
52+
pnpm-debug.log*
53+
# Editors and OS
54+
.vscode/*
55+
!.vscode/settings.json
56+
!.vscode/extensions.json
57+
# Env files (never commit secrets)
58+
.env.*
59+
!.env.example

‎.prettierignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
coverage/
3+
package-lock.json
4+
CHANGELOG.md
5+
README.md
6+
public/

‎.prettierrc‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"endOfLine": "lf"
5+
}

‎CHANGELOG.md‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
1-
## [1.18.1](https://github.com/manthanank/learn-javascript/compare/v1.18.0...v1.18.1) (2025-02-04)
1+
# [1.19.0](https://github.com/TheLearningHubOrg/learn-javascript/compare/v1.18.1...v1.19.0) (2026-11-03)
2+
3+
4+
### Features
5+
6+
* restructure the README into the 7-stage standard with numbered sections, a versions and migration section, and deeper Stages 1-3
7+
* add a dependency-free Node.js starter API (`src/server.js`, `src/app.js`, `src/lib/`) with node:test suites for Stages 1-3
8+
* add CI (ESLint, node:test on Node 22/24/26, Docker smoke test), a multi-stage Dockerfile and the PA_TOKEN-guarded release workflow
9+
10+
11+
12+
## [1.18.1](https://github.com/TheLearningHubOrg/learn-javascript/compare/v1.18.0...v1.18.1) (2025-02-04)
213

314

415
### Bug Fixes
516

6-
* Correct console output comments in README.md for arithmetic operations ([8f233a9](https://github.com/manthanank/learn-javascript/commit/8f233a991ae4c3b9bec97e7f26b983dd82ccdfbc))
17+
* Correct console output comments in README.md for arithmetic operations ([8f233a9](https://github.com/TheLearningHubOrg/learn-javascript/commit/8f233a991ae4c3b9bec97e7f26b983dd82ccdfbc))
718

819

920

10-
# [1.18.0](https://github.com/manthanank/learn-javascript/compare/v1.17.0...v1.18.0) (2024-10-15)
21+
# [1.18.0](https://github.com/TheLearningHubOrg/learn-javascript/compare/v1.17.0...v1.18.0) (2024-10-15)
1122

1223

1324
### Features
1425

15-
* Add functions for string manipulation and binary tree operations ([dbfda3d](https://github.com/manthanank/learn-javascript/commit/dbfda3d3f3bbaef81b9e1604decccde69ee4ba8f))
26+
* Add functions for string manipulation and binary tree operations ([dbfda3d](https://github.com/TheLearningHubOrg/learn-javascript/commit/dbfda3d3f3bbaef81b9e1604decccde69ee4ba8f))
1627

1728

1829

19-
# [1.17.0](https://github.com/manthanank/learn-javascript/compare/v1.16.0...v1.17.0) (2024-10-15)
30+
# [1.17.0](https://github.com/TheLearningHubOrg/learn-javascript/compare/v1.16.0...v1.17.0) (2024-10-15)
2031

2132

2233
### Features
2334

24-
* Add functions for finding the largest and smallest elements in an array ([7425631](https://github.com/manthanank/learn-javascript/commit/7425631c79c690b239e205907ba112eea46fc907))
35+
* Add functions for finding the largest and smallest elements in an array ([7425631](https://github.com/TheLearningHubOrg/learn-javascript/commit/7425631c79c690b239e205907ba112eea46fc907))
2536

2637

2738

28-
# [1.16.0](https://github.com/manthanank/learn-javascript/compare/v1.15.0...v1.16.0) (2024-10-07)
39+
# [1.16.0](https://github.com/TheLearningHubOrg/learn-javascript/compare/v1.15.0...v1.16.0) (2024-10-07)
2940

3041

3142
### Features
3243

33-
* Add functions for sorting, finding max/min, sum/average, prime/palindrome checks, and duplicate removal ([4042709](https://github.com/manthanank/learn-javascript/commit/40427091267a271b2ec3160f4d47563fd53a2a07))
44+
* Add functions for sorting, finding max/min, sum/average, prime/palindrome checks, and duplicate removal ([4042709](https://github.com/TheLearningHubOrg/learn-javascript/commit/40427091267a271b2ec3160f4d47563fd53a2a07))
3445

3546

3647

37-
# [1.15.0](https://github.com/manthanank/learn-javascript/compare/v1.14.0...v1.15.0) (2024-10-06)
48+
# [1.15.0](https://github.com/TheLearningHubOrg/learn-javascript/compare/v1.14.0...v1.15.0) (2024-10-06)
3849

3950

4051
### Features
4152

42-
* Add functions for sorting, finding max/min, sum/average, prime/palindrome checks, and duplicate removal ([76cba6f](https://github.com/manthanank/learn-javascript/commit/76cba6fb77c9126281e2920b6a04017900b04a74))
53+
* Add functions for sorting, finding max/min, sum/average, prime/palindrome checks, and duplicate removal ([76cba6f](https://github.com/TheLearningHubOrg/learn-javascript/commit/76cba6fb77c9126281e2920b6a04017900b04a74))
4354

4455

4556

‎Dockerfile‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
# Multi-stage Dockerfile for learn-javascript
2-
FROM node:22-alpine AS builder
1+
# learn-javascript starter API: plain JavaScript on node:http, no runtime dependencies.
2+
3+
# ---- test: install dev tooling, lint and run the test suite -----------------
4+
FROM node:24-alpine AS test
35
WORKDIR /app
4-
COPY package.json ./
5-
COPY src/ ./src/
6-
COPY tests/ ./tests/
7-
RUN npm test
6+
COPY package.json package-lock.json ./
7+
RUN npm ci
8+
COPY eslint.config.js ./
9+
COPY src ./src
10+
COPY tests ./tests
11+
RUN npm run lint && npm test
812

9-
FROM node:22-alpine AS runner
13+
# ---- runtime: only package.json and src, run as the unprivileged node user ---
14+
FROM node:24-alpine AS runtime
15+
ENV NODE_ENV=production \
16+
PORT=8080
1017
WORKDIR /app
11-
COPY --from=builder /app /app
18+
COPY --from=test --chown=node:node /app/package.json ./
19+
COPY --from=test --chown=node:node /app/src ./src
1220
USER node
13-
CMD ["node", "src/index.js"]
21+
EXPOSE 8080
22+
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
23+
CMD wget -qO- "http://127.0.0.1:${PORT}/health" > /dev/null || exit 1
24+
CMD ["node", "src/server.js"]

0 commit comments

Comments
 (0)