-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (50 loc) · 2.11 KB
/
Makefile
File metadata and controls
59 lines (50 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.PHONY: install-git-hooks
install-git-hooks:
git config core.hooksPath scripts
.PHONY: pre-commit
pre-commit:
@if git diff --cached --name-only | grep -q '^src/'; then $(MAKE) -C src lint; fi
.PHONY: pre-push
pre-push: pkgs/npm/README.md src/README.md test
.PHONY: test
test:
@$(MAKE) -C src test
.PHONY: setup
setup:
go -C src mod tidy
pkgs/npm/README.md src/README.md: README.md
@awk '/^## Develop Once, Deploy Anywhere\./{p=1} (/^## /||/^### /){if(p&&!/^## Develop Once, Deploy Anywhere\./){exit}} p' $< > src/README.md
@awk '/^## Defang CLI/{p=1} (/^## /||/^### /){if(p&&!/^## Defang CLI/){exit}} p' $< >> src/README.md
@awk '/^## Getting started/{p=1} (/^## /||/^### /){if(p&&!/^## Getting started/){exit}} p' $< >> src/README.md
@awk '/^## Support/{p=1} (/^## /||/^### /){if(p&&!/^## Support/){exit}} p' $< >> src/README.md
@awk '/^## Environment Variables/{p=1} (/^## /||/^### /){if(p&&!/^## Environment Variables/){exit}} p' $< >> src/README.md
@cp src/README.md pkgs/npm/README.md
@git diff --quiet $@ || (git add $@ && echo 'README files synced. Please add the changes to your commit.' && false)
.PHONY: test-nix
test-nix:
ifneq (,$(shell which nix))
+@$(MAKE) nix-run; \
if [ $$? -ne 0 ]; then \
$(MAKE) update-nix-vendor-hash; \
fi
endif
.PHONY: update-nix-vendor-hash
update-nix-vendor-hash:
sed -i.bak -E 's|(vendorHash = "sha256-)[A-Za-z0-9+/=]+(")|\10AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\2|' pkgs/defang/cli.nix
@NEW_HASH=$$($(MAKE) nix-run 2>&1 | grep -o 'sha256-[A-Za-z0-9+/=]\+' | tail -n1); \
if [ -z "$$NEW_HASH" ]; then \
echo '❌ Failed to extract new vendorHash from nix build output; restoring cli.nix'; \
mv pkgs/defang/cli.nix.bak pkgs/defang/cli.nix; \
exit 2; \
fi; \
sed -i.bak -E "s|(vendorHash = \")[^\"]+(\")|\\1$$NEW_HASH\\2|" pkgs/defang/cli.nix; \
rm pkgs/defang/cli.nix.bak; \
git add pkgs/defang/cli.nix; \
echo 'cli.nix vendorHash has been updated; commit and push'; \
exit 1
.PHONY: nix-run
nix-run:
nix run .#defang-cli --extra-experimental-features flakes --extra-experimental-features nix-command -- help
.PHONY: clean distclean
clean distclean:
$(MAKE) -C src $@