forked from ipfs-inactive/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (91 loc) · 3.48 KB
/
Makefile
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
SHELL=/bin/bash
DOMAIN="ipfs.io"
IPFSLOCAL="http://localhost:8080/ipfs/"
IPFSGATEWAY="https://ipfs.io/ipfs/"
NPM=npm
NPMBIN=./node_modules/.bin
OUTPUTDIR=public
PKGDIR=content/reference/pkg
PORT=1313
ifeq ($(DEBUG), true)
PREPEND=
APPEND=
else
PREPEND=@
APPEND=1>/dev/null
endif
# Where Hugo should be installed locally
HUGO_LOCAL=./bin/hugo
# Path to Hugo binary to use when building the site
HUGO_BINARY=$(HUGO_LOCAL)
HUGO_VERSION=0.45.1
PLATFORM:=$(shell uname)
ifeq ('$(PLATFORM)', 'Darwin')
PLATFORM=macOS
endif
MACH:=$(shell uname -m)
ifeq ('$(MACH)', 'x86_64')
MACH=64bit
else
MACH=32bit
endif
HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v$(HUGO_VERSION)/hugo_$(HUGO_VERSION)_$(PLATFORM)-$(MACH).tar.gz"
node_modules:
$(PREPEND)$(NPM) install $(APPEND)
ipfs-theme:
$(PREPEND)[ -d build/assets/fonts ] || mkdir -p build/assets/fonts
$(PREPEND)cp ./node_modules/ipfs-css/fonts/Montserrat* ./build/assets/fonts/ $(APPEND)
$(PREPEND)cp ./node_modules/ipfs-css/fonts/Inter-UI* ./build/assets/fonts/ $(APPEND)
$(PREPEND)node scripts/ipfs-css-constants.js $(APPEND)
packages:
# The JS packages don't actually generate useful docs right now, so skip them
# $(PREPEND)scripts/pkg2md.sh github.com/ipfs/js-ipfs-api master $(PKGDIR) pkg
# $(PREPEND)scripts/pkg2md.sh github.com/ipfs/js-ipfs master $(PKGDIR) pkg
$(PREPEND)scripts/pkg2md.sh github.com/ipfs/go-ipfs-api v1.2.1 $(PKGDIR) go/pkg
$(PREPEND)scripts/pkg2md.sh github.com/ipfs/go-ipfs/core/coreapi v0.4.15 $(PKGDIR) go/pkg
$(PREPEND)scripts/pkg2md.sh github.com/ipfs/go-ipfs/core/coreapi/interface v0.4.15 $(PKGDIR) go/pkg
$(PREPEND)scripts/pkg2md.sh github.com/ipfs/go-ipfs/core/coreapi/interface/options v0.4.15 $(PKGDIR) go/pkg
bin/hugo:
@echo "Installing Hugo to $(HUGO_LOCAL)..."
$(PREPEND)mkdir -p tmp_hugo $(APPEND)
$(PREPEND)curl --location "$(HUGO_URL)" | tar -xzf - -C tmp_hugo && chmod +x tmp_hugo/hugo && mv tmp_hugo/hugo $(HUGO_LOCAL) $(APPEND)
$(PREPEND)rm -rf tmp_hugo $(APPEND)
resources: ipfs-theme packages
install: bin/hugo node_modules resources
css:
# Dual calls to less because there seems to be a bug with multiple plugins in v3 :(
# https://github.com/less/less.js/issues/3187
$(PREPEND)$(NPMBIN)/lessc -clean-css --autoprefix src/styles/main.less build/assets/main.css $(APPEND)
js:
$(PREPEND)$(NPMBIN)/browserify src/js/main.js -o build/assets/main.js --debug $(APPEND)
minify-js: js
$(PREPEND)$(NPMBIN)/uglifyjs --compress --output build/assets/main.js -- build/assets/main.js $(APPEND)
lint:
$(NPMBIN)/standard src/js/**/*.js
build: clean install lint css js minify-js
$(PREPEND)$(HUGO_BINARY) && \
echo "" && \
echo "Site built out to ./$(OUTPUTDIR)"
dev: css
$(PREPEND)( \
$(NPMBIN)/nodemon --watch src/styles --ext less,css --exec "$(NPMBIN)/lessc -clean-css --autoprefix src/styles/main.less build/assets/main.css" & \
$(NPMBIN)/watchify src/js/main.js -o build/assets/main.js --debug & \
$(HUGO_BINARY) server -w --port $(PORT) --bind 0.0.0.0 \
)
serve:
$(PREPEND)$(HUGO_BINARY) server
deploy:
export hash=`ipfs add -r -Q $(OUTPUTDIR)`; \
echo ""; \
echo "published website:"; \
echo "- $(IPFSLOCAL)$$hash"; \
echo "- $(IPFSGATEWAY)$$hash"; \
echo ""; \
echo "next steps:"; \
echo "- ipfs pin add -r /ipfs/$$hash"; \
echo "- make publish-to-domain"
clean:
$(PREPEND)[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
$(PREPEND)[ ! -d $(PKGDIR) ] || rm -rf $(PKGDIR)/*/
$(PREPEND)[ ! -d build/assets ] || rm -rf build/assets/*
.PHONY: packages build help deploy publish-to-domain clean