Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d003767

Browse files
aslilacmatifali
andauthored
chore: only run pnpm when node_modules are out of date in Makefile (#16017)
Co-authored-by: Muhammad Atif Ali <[email protected]>
1 parent 94f5d52 commit d003767

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

Makefile

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,24 @@ $(foreach chart,$(charts),build/$(chart)_helm_$(VERSION).tgz): build/%_helm_$(VE
387387
--chart $* \
388388
--output "$@"
389389

390-
site/out/index.html: site/package.json $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \))
390+
node_modules/.installed: package.json
391+
./scripts/pnpm_install.sh
392+
393+
offlinedocs/node_modules/.installed: offlinedocs/package.json
394+
cd offlinedocs
395+
../scripts/pnpm_install.sh
396+
397+
site/node_modules/.installed: site/package.json
398+
cd site
399+
../scripts/pnpm_install.sh
400+
401+
site/out/index.html: site/node_modules/.installed $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \))
391402
cd site
392403
# prevents this directory from getting to big, and causing "too much data" errors
393404
rm -rf out/assets/
394-
../scripts/pnpm_install.sh
395405
pnpm build
396406

397-
offlinedocs/out/index.html: $(shell find ./offlinedocs $(FIND_EXCLUSIONS) -type f) $(shell find ./docs $(FIND_EXCLUSIONS) -type f | sed 's: :\\ :g')
407+
offlinedocs/out/index.html: offlinedocs/node_modules/.installed $(shell find ./offlinedocs $(FIND_EXCLUSIONS) -type f) $(shell find ./docs $(FIND_EXCLUSIONS) -type f | sed 's: :\\ :g')
398408
cd offlinedocs
399409
../scripts/pnpm_install.sh
400410
pnpm export
@@ -427,7 +437,7 @@ fmt/go:
427437
xargs -0 go run mvdan.cc/[email protected] -w -l
428438
.PHONY: fmt/go
429439

430-
fmt/ts:
440+
fmt/ts: site/node_modules/.installed
431441
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/ts$(RESET)"
432442
cd site
433443
# Avoid writing files in CI to reduce file write activity
@@ -438,7 +448,7 @@ else
438448
endif
439449
.PHONY: fmt/ts
440450

441-
fmt/biome:
451+
fmt/biome: site/node_modules/.installed
442452
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/biome$(RESET)"
443453
cd site
444454
# Avoid writing files in CI to reduce file write activity
@@ -464,9 +474,8 @@ else
464474
endif
465475
.PHONY: fmt/shfmt
466476

467-
fmt/markdown:
477+
fmt/markdown: node_modules/.installed
468478
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/markdown$(RESET)"
469-
./scripts/pnpm_install.sh
470479
pnpm format-docs
471480
.PHONY: fmt/markdown
472481

@@ -477,7 +486,7 @@ lint/site-icons:
477486
./scripts/check_site_icons.sh
478487
.PHONY: lint/site-icons
479488

480-
lint/ts:
489+
lint/ts: site/node_modules/.installed
481490
cd site
482491
pnpm lint
483492
.PHONY: lint/ts
@@ -504,8 +513,7 @@ lint/helm:
504513
make lint
505514
.PHONY: lint/helm
506515

507-
lint/markdown:
508-
./scripts/pnpm_install.sh
516+
lint/markdown: node_modules/.installed
509517
pnpm lint-docs
510518
.PHONY: lint/markdown
511519

@@ -653,22 +661,19 @@ vpn/vpn.pb.go: vpn/vpn.proto
653661
--go_opt=paths=source_relative \
654662
./vpn/vpn.proto
655663

656-
site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
664+
site/src/api/typesGenerated.ts: site/node_modules/.installed $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
657665
# -C sets the directory for the go run command
658666
go run -C ./scripts/apitypings main.go > $@
659667
cd site
660-
../scripts/pnpm_install.sh
661668
pnpm exec biome format --write src/api/typesGenerated.ts
662669

663-
site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go
670+
site/e2e/provisionerGenerated.ts: site/node_modules/.installed provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go
664671
cd site
665-
../scripts/pnpm_install.sh
666672
pnpm run gen:provisioner
667673

668-
site/src/theme/icons.json: $(wildcard scripts/gensite/*) $(wildcard site/static/icon/*)
674+
site/src/theme/icons.json: site/node_modules/.installed $(wildcard scripts/gensite/*) $(wildcard site/static/icon/*)
669675
go run ./scripts/gensite/ -icons "$@"
670676
cd site
671-
../scripts/pnpm_install.sh
672677
pnpm exec biome format --write src/theme/icons.json
673678

674679
examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates)
@@ -686,46 +691,38 @@ codersdk/rbacresources_gen.go: scripts/typegen/codersdk.gotmpl scripts/typegen/m
686691
go run scripts/typegen/main.go rbac codersdk > /tmp/rbacresources_gen.go
687692
mv /tmp/rbacresources_gen.go codersdk/rbacresources_gen.go
688693

689-
site/src/api/rbacresourcesGenerated.ts: scripts/typegen/codersdk.gotmpl scripts/typegen/main.go coderd/rbac/object.go coderd/rbac/policy/policy.go
694+
site/src/api/rbacresourcesGenerated.ts: site/node_modules/.installed scripts/typegen/codersdk.gotmpl scripts/typegen/main.go coderd/rbac/object.go coderd/rbac/policy/policy.go
690695
go run scripts/typegen/main.go rbac typescript > "$@"
691696
cd site
692-
../scripts/pnpm_install.sh
693697
pnpm exec biome format --write src/api/rbacresourcesGenerated.ts
694698

695-
site/src/api/countriesGenerated.ts: scripts/typegen/countries.tstmpl scripts/typegen/main.go codersdk/countries.go
699+
site/src/api/countriesGenerated.ts: site/node_modules/.installed scripts/typegen/countries.tstmpl scripts/typegen/main.go codersdk/countries.go
696700
go run scripts/typegen/main.go countries > "$@"
697701
cd site
698-
../scripts/pnpm_install.sh
699702
pnpm exec biome format --write src/api/countriesGenerated.ts
700703

701-
docs/admin/integrations/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics
704+
docs/admin/integrations/prometheus.md: node_modules/.installed scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics
702705
go run scripts/metricsdocgen/main.go
703-
./scripts/pnpm_install.sh
704706
pnpm exec markdownlint-cli2 --fix ./docs/admin/integrations/prometheus.md
705707
pnpm exec markdown-table-formatter ./docs/admin/integrations/prometheus.md
706708

707-
docs/reference/cli/index.md: scripts/clidocgen/main.go examples/examples.gen.json $(GO_SRC_FILES)
709+
docs/reference/cli/index.md: node_modules/.installed site/node_modules/.installed scripts/clidocgen/main.go examples/examples.gen.json $(GO_SRC_FILES)
708710
CI=true BASE_PATH="." go run ./scripts/clidocgen
709-
./scripts/pnpm_install.sh
710711
pnpm exec markdownlint-cli2 --fix ./docs/reference/cli/*.md
711712
pnpm exec markdown-table-formatter ./docs/reference/cli/*.md
712713
cd site
713-
../scripts/pnpm_install.sh
714714
pnpm exec biome format --write ../docs/manifest.json
715715

716-
docs/admin/security/audit-logs.md: coderd/database/querier.go scripts/auditdocgen/main.go enterprise/audit/table.go coderd/rbac/object_gen.go
716+
docs/admin/security/audit-logs.md: node_modules/.installed coderd/database/querier.go scripts/auditdocgen/main.go enterprise/audit/table.go coderd/rbac/object_gen.go
717717
go run scripts/auditdocgen/main.go
718-
./scripts/pnpm_install.sh
719718
pnpm exec markdownlint-cli2 --fix ./docs/admin/security/audit-logs.md
720719
pnpm exec markdown-table-formatter ./docs/admin/security/audit-logs.md
721720

722-
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) $(DB_GEN_FILES) .swaggo docs/manifest.json coderd/rbac/object_gen.go
721+
coderd/apidoc/swagger.json: node_modules/.installed site/node_modules/.installed $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) $(DB_GEN_FILES) .swaggo docs/manifest.json coderd/rbac/object_gen.go
723722
./scripts/apidocgen/generate.sh
724-
./scripts/pnpm_install.sh
725723
pnpm exec markdownlint-cli2 --fix ./docs/reference/api/*.md
726724
pnpm exec markdown-table-formatter ./docs/reference/api/*.md
727725
cd site
728-
../scripts/pnpm_install.sh
729726
pnpm exec biome format --write ../docs/manifest.json ../coderd/apidoc/swagger.json
730727

731728
update-golden-files: \
@@ -909,5 +906,5 @@ test-clean:
909906
.PHONY: test-clean
910907

911908
.PHONY: test-e2e
912-
test-e2e:
909+
test-e2e: site/node_modules/.installed
913910
cd ./site && DEBUG=pw:api pnpm playwright:test --forbid-only --workers 1

scripts/pnpm_install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ pnpm_flags+=("$@")
3333

3434
echo "+ pnpm install ${pnpm_flags[*]}"
3535
pnpm install "${pnpm_flags[@]}"
36+
37+
# Used for Makefile optimizations
38+
touch node_modules/.installed

0 commit comments

Comments
 (0)