|
1 | | -#!make |
2 | | -.PHONY: all build clean |
3 | | - |
4 | | -src_files := $(shell find src -name '*.ts') |
5 | | -build_files := $(patsubst src/%.ts,build/%.js,$(src_files)) |
| 1 | +# Makefiles are useful for slightly more complex scenarios than npm scripts can easily handle. |
| 2 | +# You can use gulp or whatever other thing you like, but we prefer the simplicity of Make. |
6 | 3 |
|
7 | | -export PGUSER ?= postgres |
8 | | -export PGPASSWORD ?= postgres |
9 | | -export PGHOST ?= localhost |
| 4 | +.PHONY: all build clean |
10 | 5 |
|
11 | 6 | all: service {{#inArray features 'db'}}dbi {{/inArray}}$(word 1, $(build_files)) |
12 | 7 |
|
13 | | -ts: $(word 1, $(build_files)) |
14 | | - |
15 | | -$(word 1, $(build_files)): $(src_files) |
16 | | - ./node_modules/.bin/tsc -p tsconfig.build.json |
17 | | - |
18 | | -clean: |
19 | | - yarn dlx rimraf ./build src/generated |
20 | | - |
21 | | -service: src/generated/service/index.ts |
22 | | - |
23 | | -{{#inArray features 'db'}} |
24 | | -db-ci: |
25 | | - yarn run-pg-sql -q postgres ./migrations/setup/ci_setup.sql |
26 | | - yarn run-pg-sql -q postgres ./migrations/setup/db_setup.sql |
27 | | - yarn migration:apply |
28 | | - yarn run-pg-sql {{dbName}} ./migrations/setup/dev_setup.sql |
29 | | - |
30 | | -db-drop: |
31 | | - yarn run-pg-sql -q {{dbName}} ./migrations/setup/db_clean.sql || true |
32 | | - |
33 | | -db+: |
34 | | - yarn migration:apply |
35 | | - |
36 | | -db-: |
37 | | - yarn migration:undo |
38 | | - |
39 | | -db-clean: db-drop db-ci |
40 | | - |
41 | | -dbi: |
42 | | - echo "Generating database types" |
43 | | - DATABASE_URL=postgres://$(PGUSER):$(PGPASSWORD)@$(PGHOST)/{{dbName}} yarn kysely-codegen \ |
44 | | - --dialect postgres --schema public \ |
45 | | - --out-file src/generated/database.ts |
46 | | -{{/inArray}} |
| 8 | +{{#inArray features 'db'}}export DB_NAME ?= {{dbName}} |
| 9 | +{{/inArray}}export SERVICE_NAME ?= {{dashCase name}} |
47 | 10 |
|
48 | | -src/generated/service/index.ts: api/{{dashCase name}}.yaml |
49 | | - echo "Building service interface" |
50 | | - yarn dlx openapi-typescript-express ./api/{{dashCase name}}.yaml \ |
51 | | - --output ./src/generated/service/index.ts |
52 | | - ./node_modules/.bin/prettier ./src/generated/service/index.ts --write |
| 11 | +include node_modules/@openapi-typescript-infra/service/Makefile |
0 commit comments