-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (52 loc) · 2.12 KB
/
Copy pathMakefile
File metadata and controls
66 lines (52 loc) · 2.12 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
60
61
62
63
64
65
66
# Scrapfly TypeScript SDK — release/dev Makefile.
# Target names mirror sdk/python & sdk/rust Makefiles for muscle-memory parity.
# Source of truth for the version is deno.json; build.ts copies it into npm/package.json.
# Publishes to npm (via dnt output in ./npm) and JSR (via publish-jsr.sh).
VERSION ?=
NEXT_VERSION ?=
.PHONY: init install dev bump generate-docs release fmt lint test build publish-npm publish-jsr
init:
@command -v deno >/dev/null || { echo "deno is required"; exit 2; }
install:
deno cache src/main.ts
cd npm && npm install
dev:
deno task build-npm
bump:
@if [ -z "$(VERSION)" ]; then echo "Usage: make bump VERSION=x.y.z"; exit 2; fi
@# deno.json is the single source of truth; build.ts reads it and stamps npm/package.json.
sed -i "s/^\( \"version\": \"\)[^\"]*\(\"\)/\1$(VERSION)\2/" deno.json
git add deno.json
git commit -m "bump version to $(VERSION)"
git push
generate-docs:
@# TypeScript SDK relies on README + JSR-generated docs; nothing to build locally.
@true
build:
deno task build-npm
test:
deno task test
fmt:
deno task fmt
lint:
@# deno lint stays advisory; wired here so `make lint` is never a 404.
deno lint src
publish-npm:
cd npm && npm publish --access public
publish-jsr:
./publish-jsr.sh
release:
@if [ -z "$(VERSION)" ]; then echo "Usage: make release VERSION=x.y.z [NEXT_VERSION=x.y.(z+1)]"; exit 2; fi
@[ "$$(git rev-parse --abbrev-ref HEAD)" = main ] || { echo "release must run on main"; exit 1; }
git pull origin main
@# Stamp deno.json to the release version BEFORE build so npm/package.json gets it.
sed -i "s/^\( \"version\": \"\)[^\"]*\(\"\)/\1$(VERSION)\2/" deno.json
@if [ -z "$(SKIP_TESTS)" ]; then $(MAKE) test; else echo "SKIP_TESTS set, skipping test gate"; fi
$(MAKE) build
git add deno.json
-git commit -m "Release $(VERSION)"
-git push origin main
git tag -a v$(VERSION) -m "Version $(VERSION)"
git push origin v$(VERSION)
@if [ -z "$(SKIP_PUBLISH)" ]; then $(MAKE) publish-npm; $(MAKE) publish-jsr; else echo "SKIP_PUBLISH set, leaving npm+JSR to CI (publish.yaml on v-tag)"; fi
@if [ -n "$(NEXT_VERSION)" ]; then $(MAKE) bump VERSION=$(NEXT_VERSION); fi