Skip to content

Commit 0c03d45

Browse files
Merge pull request #141 from Bhumikagarggg/feature/makefile-pkg-json-standardize
chore: Standardize Makefile npm scripts
2 parents ca612ef + 054128b commit 0c03d45

4 files changed

Lines changed: 167 additions & 73 deletions

File tree

.htmltest.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# htmltest configuration.
2+
# Checks the built HTML in public/ for broken links, images, and scripts.
3+
# External links are skipped at runtime via the -s flag in the check:links script.
4+
5+
DirectoryPath: "public"
6+
7+
CheckInternal: true
8+
CheckExternal: true # skipped at runtime by -s; left true for when you drop -s
9+
EnforceHTTPS: true # still flags real http:// links (e.g. exoscale.com) to fix
10+
11+
# --- Silence intentional or non-blocking findings ---
12+
13+
# Hugo serves pages as directories, so a link to "./foo" (no trailing slash)
14+
# only causes a redirect, not a break. Don't treat these as errors.
15+
IgnoreDirectoryMissingTrailingSlash: true
16+
17+
# Alt-text issues are an accessibility backlog, not broken links. Empty alt is
18+
# valid for decorative images. Re-enable (set these false) when you work the
19+
# accessibility pass.
20+
IgnoreAltEmpty: true
21+
IgnoreAltMissing: true
22+
23+
# Deliberate example URLs in workshop content (intentionally http, not real
24+
# reachable hosts). These skip HTTPS enforcement; genuine http links elsewhere
25+
# (exoscale.com, etc.) are NOT listed here, so they still surface for fixing.
26+
IgnoreHTTPS:
27+
- '^http://localhost'
28+
- 'votingapp\.(com|cc)'
29+
- 'nip\.io'
30+
- 'thesecretlivesofdata\.com'
31+
32+
# Directories in public/ to skip entirely (adjust per repo as needed).
33+
# Theme/shortcode demonstration pages full of intentional example links and
34+
# placeholder image paths. Not real content; skip the whole section.
35+
IgnoreDirs:
36+
- 'content-formatting-examples'
37+
38+
# Cache external-link results for fast repeat runs (stored under tmp/.htmltest;
39+
# add tmp/ to .gitignore). Harmless under -s.
40+
CacheExpires: "336h"
41+
42+
43+
# Known-noisy or intentionally-unreachable URLs to ignore (regex).
44+
# IgnoreURLs:
45+
# - "^https://linkedin\\.com/"

Makefile

Lines changed: 74 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@
1515
include .github/build/Makefile.core.mk
1616
include .github/build/Makefile.show-help.mk
1717

18-
#----------------------------------------------------------------------------
18+
# Changes to any main recipe in this Makefile, require a corresponding change in all other repositories subscribed to the 'meshery-academy' topic.
19+
20+
# htmltest is fetched and run on demand via 'go run' (no install step). Pin it for
21+
# reproducible link checks; leave as 'latest' to always use the newest release.
22+
HTMLTEST_VERSION ?= latest
23+
export HTMLTEST_VERSION
24+
25+
# ---------------------------------------------------------------------------
1926
# Academy
2027
# ---------------------------------------------------------------------------
2128

22-
## ------------------------------------------------------------
23-
----LOCAL_BUILDS: Show help for available targets
24-
25-
## Local: Install site dependencies
26-
setup:
27-
npm i
29+
# ---------------------------------------------------------------------------
30+
# MAINTENANCE: Show help for available targets
31+
# ---------------------------------------------------------------------------
2832

2933
## Verify required commands and local dependencies are present.
3034
check-deps:
@@ -33,50 +37,79 @@ check-deps:
3337
@test -x node_modules/.bin/hugo || { echo "Error: Hugo binary not found in node_modules. Please run 'make setup' first."; exit 1; }
3438
@echo "Dependencies check passed."
3539

36-
## Build site for production (no drafts, no future, no expired content).
37-
build: check-deps check-go
38-
npm run build:production
40+
## Validate Go is installed
41+
check-go:
42+
@echo "Checking if Go is installed..."
43+
@command -v go > /dev/null || { echo "Go is not installed. Please install it before proceeding."; exit 1; }
44+
@echo "Go is installed."
45+
46+
## Update the academy-theme package to latest version
47+
theme-update: check-go check-deps
48+
@echo "Updating to latest academy-theme..."
49+
npm run update:theme
50+
51+
# ---------------------------------------------------------------------------
52+
# LOCAL BUILDS: Show help for available targets
53+
# ---------------------------------------------------------------------------
54+
55+
## Install site dependencies
56+
setup:
57+
npm install
3958

40-
## Build site for preview (includes drafts, future, and expired content) with dynamically set baseURL.
41-
build-preview: check-deps check-go
59+
## Build the site locally with draft and future content enabled.
60+
build: check-go check-deps
61+
npm run build
62+
63+
## Build the site for a deploy preview.
64+
build-preview: check-go check-deps
4265
npm run build:preview
4366

44-
## Local: Build and run site locally with draft and future content enabled.
45-
site: check-deps check-go
46-
npm run dev:site
67+
## Build the site for production.
68+
build-production: check-go check-deps
69+
npm run build:production
4770

48-
## Local: Run site locally in serve mode (without file watching).
49-
serve: check-deps check-go
50-
npm run dev:serve
71+
## Build and run the site locally with live reload (draft and future content enabled).
72+
site: check-go check-deps
73+
npm run site
5174

52-
## Empty build cache and run on your local machine.
75+
## Build and serve the site once with the file-watcher off (no live reload).
76+
site-no-watch: check-go check-deps
77+
npm run site:no-watch
78+
79+
## Empty the build cache, reinstall dependencies, and run the site locally.
5380
clean:
5481
npm run clean
5582
$(MAKE) setup
5683
$(MAKE) site
5784

58-
## Fix Markdown linting issues
59-
lint-fix:
60-
@echo "Checking for markdownlint-cli2..."
61-
@command -v markdownlint-cli2 > /dev/null || { \
62-
echo "markdownlint-cli2 not found. Attempting to install globally..."; \
63-
command -v npm > /dev/null || { echo "npm is not installed. Please install Node.js/npm and re-run 'make lint-fix'."; exit 1; }; \
64-
npm install -g markdownlint-cli2; \
65-
}
66-
@echo "Running markdownlint-cli2 --fix..."
67-
@markdownlint-cli2 --fix "**/*.md" "#node_modules" "#public" "#resources"
68-
69-
## ------------------------------------------------------------
70-
----MAINTENANCE: Show help for available targets
85+
## Check internal links in the built site (htmltest is fetched on demand via 'go run').
86+
check-links: check-go check-deps
87+
npm run check:links
7188

72-
check-go:
73-
@echo "Checking if Go is installed..."
74-
@command -v go > /dev/null || (echo "Go is not installed. Please install it before proceeding."; exit 1)
75-
@echo "Go is installed."
89+
## Format code using Prettier
90+
format:
91+
npm run format
7692

77-
## Update the academy-theme package to latest version
78-
theme-update: check-deps check-go
79-
@echo "Updating to latest academy-theme..."
80-
npm run update:theme
93+
## Check formatting without writing changes.
94+
format-check:
95+
npm run format:check
96+
97+
## Fix Markdown linting issues
98+
lint-fix:
99+
npx --yes markdownlint-cli2 --fix "content/**/*.md"
81100

82-
.PHONY: setup check-deps check-go build build-preview site serve clean lint-fix theme-update
101+
.PHONY: \
102+
setup \
103+
build \
104+
build-preview \
105+
build-production \
106+
site \
107+
site-no-watch \
108+
clean \
109+
check-links \
110+
format \
111+
format-check \
112+
lint-fix \
113+
check-deps \
114+
check-go \
115+
theme-update

package-lock.json

Lines changed: 27 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,49 @@
88
"author": "Docsy Authors",
99
"license": "Apache-2.0",
1010
"bugs": "https://github.com/google/docsy-example/issues",
11+
"private": true,
1112
"spelling": "cSpell:ignore docsy hugo htmltest precheck postbuild rtlcss -",
1213
"scripts": {
13-
"_build": "npm run _hugo-dev --",
14-
"_check:links": "echo IMPLEMENTATION PENDING for check-links; echo",
1514
"_hugo": "hugo --cleanDestinationDir",
16-
"_hugo-dev": "hugo --cleanDestinationDir -e dev -DFE",
17-
"_local": "cross-env HUGO_MODULE_WORKSPACE=docsy.work",
18-
"_serve": "npm run _hugo-dev -- server --minify --renderToMemory",
15+
"_hugo-dev": "npm run _hugo -- -e dev -DFE",
16+
"_build": "npm run _hugo-dev",
17+
"_site": "npm run _hugo-dev -- --minify server",
18+
"_check:links": "echo \"Skipped: go run github.com/wjdp/htmltest@${HTMLTEST_VERSION:-latest} -s\"",
19+
"_local": "npx cross-env HUGO_MODULE_WORKSPACE=exoscale-academy.work",
20+
"build": "npm run _build",
1921
"build:preview": "npm run _hugo-dev -- --minify --baseURL \"${DEPLOY_PRIME_URL:-/}\"",
20-
"build:production": "npm run _hugo -- --minify",
21-
"build": "npm run _build -- ",
22-
"check:links:all": "HTMLTEST_ARGS= npm run _check:links",
23-
"check:links": "npm run _check:links",
22+
"build:production": "npm run _hugo -- --minify --gc",
23+
"site": "npm run _site",
24+
"site:no-watch": "npm run _hugo-dev -- --minify --watch=false server",
2425
"clean": "rm -Rf public/* resources",
25-
"dev:build": "npm run _hugo-dev --",
26-
"dev:serve": "npm run _hugo-dev -- server --watch=false",
27-
"dev:site": "npm run _hugo-dev -- server",
28-
"local": "npm run _local -- npm run",
2926
"make:public": "git init -b main public",
30-
"precheck:links:all": "npm run build",
27+
"local": "npm run _local -- npm run",
28+
"check:links": "npm run _check:links",
3129
"precheck:links": "npm run build",
3230
"postbuild:preview": "npm run _check:links",
3331
"postbuild:production": "npm run _check:links",
34-
"serve": "npm run _serve",
3532
"test": "npm run check:links",
36-
"update:dep": "npm install --save-dev autoprefixer@latest postcss-cli@latest",
37-
"update:hugo": "npm install --save-dev --save-exact hugo-extended@latest",
38-
"update:pkgs": "npm exec npm-check-updates -u",
33+
"format": "prettier --write .",
34+
"format:check": "prettier --check .",
35+
"update:pkg:dep": "npm install --save-dev autoprefixer@latest postcss-cli@latest",
36+
"update:pkg:hugo": "npm install --save-dev --save-exact hugo-extended@latest",
37+
"update:pkgs": "npx npm-check-updates -u",
3938
"update:theme": "hugo mod get github.com/layer5io/academy-theme"
4039
},
4140
"devDependencies": {
42-
"autoprefixer": "^10.4.21",
41+
"autoprefixer": "^10.4.27",
4342
"cross-env": "^7.0.3",
4443
"hugo-extended": "0.158.0",
45-
"postcss": "^8.5.6",
44+
"postcss": "^8.5.12",
4645
"postcss-cli": "^11.0.1",
46+
"prettier": "3.8.3",
4747
"rtlcss": "^4.3.0"
4848
},
4949
"optionalDependencies": {
5050
"npm-check-updates": "^18.0.1"
5151
},
52-
"private": true,
5352
"prettier": {
5453
"proseWrap": "always",
5554
"singleQuote": true
5655
}
57-
}
56+
}

0 commit comments

Comments
 (0)