|
1 |
| -SHELL := /bin/bash |
2 | 1 | .DEFAULT_GOAL = help
|
| 2 | +SHELL := /bin/bash |
| 3 | +VENDOR_DIR := vendor/react-notion-x |
3 | 4 |
|
4 |
| -##@ Repo Initialization |
| 5 | +# Load environment variables from .env |
| 6 | +ifneq (,$(wildcard ./.env)) |
| 7 | + include .env |
| 8 | + export |
| 9 | +endif |
5 | 10 |
|
6 |
| -prerequisite: ## Install prerequisite tools |
| 11 | +##============================================================================= |
| 12 | +##@ Repo Initialization |
| 13 | +##============================================================================= |
| 14 | + |
| 15 | +PLUGINS := \ |
| 16 | + direnv https://github.com/asdf-community/asdf-direnv.git \ |
| 17 | + pre-commit https://github.com/jonathanmorley/asdf-pre-commit.git \ |
| 18 | + nodejs https://github.com/asdf-vm/asdf-nodejs.git \ |
| 19 | + pnpm https://github.com/jonathanmorley/asdf-pnpm.git \ |
| 20 | + yarn https://github.com/twuni/asdf-yarn.git \ |
| 21 | + supabase-cli https://github.com/gavinying/asdf-supabase-cli.git \ |
| 22 | + terraform https://github.com/asdf-community/asdf-hashicorp.git |
| 23 | + |
| 24 | +prerequisites: ## Install prerequisite tools |
7 | 25 | @echo "Checking and installing required plugins."
|
8 |
| - @plugins=( \ |
9 |
| - "terraform https://github.com/asdf-community/asdf-hashicorp.git" \ |
10 |
| - "pnpm https://github.com/jonathanmorley/asdf-pnpm.git" \ |
11 |
| - "yarn https://github.com/twuni/asdf-yarn.git" \ |
12 |
| - "nodejs https://github.com/asdf-vm/asdf-nodejs.git" \ |
13 |
| - "pre-commit https://github.com/jonathanmorley/asdf-pre-commit.git" \ |
14 |
| - ); \ |
15 |
| - for info in "$${plugins[@]}"; do \ |
16 |
| - read plugin url <<< "$$info"; \ |
| 26 | + @echo "${PLUGINS}" | tr ' ' '\n' | paste - - | while read -r plugin url; do \ |
17 | 27 | if asdf plugin-list | grep -q $$plugin; then \
|
18 | 28 | echo "Plugin '$$plugin' is already installed."; \
|
19 | 29 | else \
|
20 | 30 | echo "Adding plugin '$$plugin'."; \
|
21 | 31 | asdf plugin-add $$plugin $$url; \
|
22 | 32 | fi; \
|
23 |
| - done; |
| 33 | + done |
24 | 34 | @echo "Installing specified versions."
|
25 | 35 | asdf install
|
26 | 36 | @echo "Currently installed versions:"
|
27 | 37 | asdf current
|
28 |
| -.PHONY: prerequisite |
| 38 | +.PHONY: prerequisites |
| 39 | + |
| 40 | +env: ## Create .env file if it doesn't exist |
| 41 | + @if ! [ -e .env ]; then \ |
| 42 | + cp .env.example .env; \ |
| 43 | + echo "Created .env file. Please edit it according to your setup."; \ |
| 44 | + fi |
| 45 | +.PHONY: env |
29 | 46 |
|
30 | 47 | deps-notion: ## Install dependencies for react-notion-x
|
31 | 48 | @echo "Installing dependencies for react-notion-x."
|
32 |
| - git submodule update --init --recursive |
33 |
| - cd vendor/react-notion-x && yarn install --frozen-lockfile |
34 |
| -.PHONY: notion-deps |
| 49 | + @git submodule update --init --recursive |
| 50 | + @cd ${VENDOR_DIR} && yarn install --frozen-lockfile |
| 51 | +.PHONY: deps-notion |
35 | 52 |
|
36 | 53 | deps: deps-notion ## Install repo dependencies
|
37 | 54 | @echo "Installing dependencies."
|
38 |
| - pnpm install |
| 55 | + @pnpm install |
39 | 56 | .PHONY: deps
|
40 | 57 |
|
41 | 58 | deps-prod: deps-notion ## Install production dependencies
|
42 | 59 | @echo "Installing production dependencies."
|
43 |
| - pnpm install --frozen-lockfile |
| 60 | + @pnpm install --frozen-lockfile |
44 | 61 | .PHONY: deps-prod
|
45 | 62 |
|
46 | 63 | pre-commit: ## Install pre-commit hooks
|
47 | 64 | @echo "Installing pre-commit hooks."
|
48 |
| - pre-commit install -t pre-commit -t commit-msg |
| 65 | + @pre-commit install -t pre-commit -t commit-msg |
| 66 | +.PHONY: pre-commit |
49 | 67 |
|
50 |
| -init: prerequisite deps pre-commit ## Initialize local environment for development |
| 68 | +init: prerequisites env deps pre-commit ## Initialize local environment for development |
51 | 69 | .PHONY: init
|
52 | 70 |
|
| 71 | +##============================================================================= |
53 | 72 | ##@ Scripts
|
| 73 | +##============================================================================= |
54 | 74 |
|
55 | 75 | build-notion: ## Build react-notion-x
|
56 | 76 | @echo "Building react-notion-x."
|
57 |
| - cd vendor/react-notion-x && yarn build |
| 77 | + @cd ${VENDOR_DIR} && yarn build |
58 | 78 | .PHONY: build-notion
|
59 | 79 |
|
60 | 80 | build: build-notion ## Build project
|
61 | 81 | @echo "Building project."
|
62 |
| - pnpm run build |
| 82 | + @pnpm run build |
63 | 83 | .PHONY: build
|
64 | 84 |
|
65 | 85 | run-dev: ## Run development server
|
66 | 86 | @echo "Running development server."
|
67 |
| - pnpm run dev |
| 87 | + @pnpm run dev |
68 | 88 | .PHONY: run-dev
|
69 | 89 |
|
70 | 90 | run-prod: build ## Run production server
|
71 | 91 | @echo "Starting server."
|
72 |
| - pnpm run start |
| 92 | + @pnpm run start |
73 | 93 | .PHONY: run-prod
|
74 | 94 |
|
75 | 95 | lint: ## Lint project
|
76 | 96 | @echo "Linting project."
|
77 |
| - pnpm run lint && pnpm run stylelint && pnpm run typecheck |
| 97 | + @pnpm run lint && pnpm run stylelint && pnpm run typecheck |
78 | 98 | .PHONY: lint
|
79 | 99 |
|
80 | 100 | format: ## Format project
|
81 | 101 | @echo "Formatting project."
|
82 |
| - pnpm run format |
| 102 | + @pnpm run format |
83 | 103 | .PHONY: format
|
84 | 104 |
|
| 105 | +##============================================================================= |
| 106 | +##@ Supabase |
| 107 | +##============================================================================= |
| 108 | + |
| 109 | +supabase-start: ## Start supabase containers |
| 110 | + @echo "Starting supabase." |
| 111 | + @supabase start |
| 112 | +.PHONY: supabase-start |
| 113 | + |
| 114 | +supabase-status: ## Check supabase status |
| 115 | + @echo "Checking supabase status." |
| 116 | + @supabase status |
| 117 | +.PHONY: supabase-status |
| 118 | + |
| 119 | +supabase-reset: ## Reset supabase database (runs migrations and seeds) |
| 120 | + @echo "Resetting supabase database." |
| 121 | + @supabase db reset |
| 122 | +.PHONY: supabase-reset |
| 123 | + |
| 124 | +supabase-migration-%: ## Create supabase migration |
| 125 | + @echo "Creating custom migration: supabase/migrations/some_timestamp_$*.sql" |
| 126 | + @supabase db diff --use-migra -f $* |
| 127 | +.PHONY: supabase-migration-% |
| 128 | + |
| 129 | +supabase-generate-types: ## Generate supabase types |
| 130 | + @echo "Generating supabase types." |
| 131 | + @supabase gen types typescript --local > app/integrations/supabase/database.types.ts |
| 132 | +.PHONY: supabase-generate-types |
| 133 | + |
| 134 | +supabase-stop: ## Stop supabase containers |
| 135 | + @echo "Stopping supabase." |
| 136 | + @supabase stop |
| 137 | +.PHONY: supabase-stop |
| 138 | + |
| 139 | +#============================================================================== |
| 140 | +##@ Ngrok |
| 141 | +##============================================================================== |
| 142 | + |
85 | 143 | ngrok-dev: ## Run ngrok for development server
|
86 | 144 | @echo "Running ngrok."
|
87 |
| - ngrok http 5173 |
| 145 | + @ngrok http 5173 |
88 | 146 | .PHONY: ngrok-dev
|
89 | 147 |
|
90 | 148 | ngrok-prod: ## Run ngrok for production server
|
91 | 149 | @echo "Running ngrok."
|
92 |
| - ngrok http 3000 |
| 150 | + @ngrok http 55203 |
93 | 151 | .PHONY: ngrok-prod
|
94 | 152 |
|
95 |
| -##@ Miscullaneous |
| 153 | +#============================================================================== |
| 154 | +##@ Security |
| 155 | +##============================================================================== |
96 | 156 |
|
97 |
| -create-secrets-baseline: ## Create secrets baseline file |
98 |
| - detect-secrets scan > .secrets.baseline |
| 157 | +create-secrets-baseline: ## Create secrets baseline file |
| 158 | + @detect-secrets scan > .secrets.baseline |
99 | 159 | .PHONY: create-secrets-baseline
|
100 | 160 |
|
101 |
| -audit-secrets-baseline: ## Check updated .secrets.baseline file |
102 |
| - detect-secrets audit .secrets.baseline |
103 |
| - git commit .secrets.baseline --no-verify -m "build(security): update secrets.baseline" |
| 161 | +audit-secrets-baseline: ## Check updated .secrets.baseline file |
| 162 | + @detect-secrets audit .secrets.baseline |
104 | 163 | .PHONY: audit-secrets-baseline
|
105 | 164 |
|
106 |
| -update-pre-commit-hooks: ## Update pre-commit hooks |
107 |
| - pre-commit autoupdate |
| 165 | +detect-secrets: ## Scan for secrets |
| 166 | + @detect-secrets scan --baseline .secrets.baseline |
| 167 | +.PHONY: detect-secrets |
| 168 | + |
| 169 | +##============================================================================= |
| 170 | +##@ Miscellaneous |
| 171 | +##============================================================================= |
| 172 | + |
| 173 | +update-pre-commit-hooks: ## Update pre-commit hooks |
| 174 | + @pre-commit autoupdate |
108 | 175 | .PHONY: update-pre-commit-hooks
|
109 | 176 |
|
110 | 177 | clean: ## Clean project
|
111 | 178 | @echo "Cleaning project."
|
112 |
| - rm -rf node_modules build |
113 |
| - find vendor/react-notion-x -type d -name 'build' -exec rm -rf {} + |
114 |
| - find vendor/react-notion-x -type d -name 'node_modules' -exec rm -rf {} + |
| 179 | + @rm -rf node_modules build |
| 180 | + @find ${VENDOR_DIR} -type d -name 'build' -exec rm -rf {} + |
| 181 | + @find ${VENDOR_DIR} -type d -name 'node_modules' -exec rm -rf {} + |
115 | 182 | .PHONY: clean
|
116 | 183 |
|
| 184 | +##============================================================================= |
117 | 185 | ##@ Helper
|
| 186 | +##============================================================================= |
118 | 187 |
|
119 |
| -help: ## Display help |
120 |
| - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage: \033[36m\033[0m\n"} /^[a-zA-Z\.\%-]+:.*?##/ { printf " \033[36m%-24s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
| 188 | +help: ## Display help |
| 189 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} \ |
| 190 | + /^[a-zA-Z_-]+%?:.*?##/ { printf " \033[36m%-24s\033[0m %s\n", $$1, $$2 } \ |
| 191 | + /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
121 | 192 | .PHONY: help
|
0 commit comments