-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
94 lines (67 loc) · 2.59 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
export SHELL = /bin/bash
ifeq ($(OS),Windows_NT)
FILE_PATH_SEP := $(strip \)
ENV_PATH_SEP := ;
else
FILE_PATH_SEP := /
ENV_PATH_SEP := :
endif
/ = $(FILE_PATH_SEP)
MAKEFILE_PATH := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
DESKTOP_DIR := $(shell cd $(dir $(MAKEFILE_PATH));pwd)
CALYPSO_DIR := $(dir $(DESKTOP_DIR))
export CONFIG_ENV = release
export NODE_ENV = production
export ELECTRON_BUILDER_ARGS =
export NODE_OPTIONS = --max_old_space_size=8192
.PHONY: build build-ci config server client source package e2e
build-main:
$(info Building app source...)
@cd $(DESKTOP_DIR) && yarn run build:main
build:
$(info Building app...)
@cd $(DESKTOP_DIR) && yarn run build
config:
$(info Building config...)
@cd $(DESKTOP_DIR) && yarn run build:config
secrets:
$(info Making app secrets...)
@cd $(DESKTOP_DIR) && yarn run build:secrets
# Note: cannot prepend desktop/package.json with full path: cannot be resolved on Windows.
package: PACKAGE_ELECTRON_VERSION = $(shell cd $(DESKTOP_DIR) && node -e "console.log(require('./package.json').devDependencies.electron)")
package:
$(info Packaging app...)
@cd $(DESKTOP_DIR) && npx electron-builder ${ELECTRON_BUILDER_ARGS} -c.electronVersion=$(PACKAGE_ELECTRON_VERSION) build --publish never
e2e:
$(info Running end-to-end tests...)
@cd $(CALYPSO_DIR) && yarn run test-desktop:e2e
clean:
@rm -rf $(DESKTOP_DIR)$/release
# Sed to strip leading v to ensure 'v1.2.3' and '1.2.3' can match.
# The .nvmrc file may contain either, `node --version` prints with 'v' prefix.
CALYPSO_NODE_VERSION := $(shell cat $(CALYPSO_DIR)/.nvmrc | sed -n 's/v\{0,1\}\(.*\)/\1/p')
# Docker environment for local development.
# ONESHELL requires GNU make v3.82 or above.
.PHONY: docker-build
.ONESHELL:
docker-build: $(SSH_PRIVATE_KEY_FILE)
docker-build: NODE_VERSION = $(CALYPSO_NODE_VERSION)
docker-build:
$(info Building docker image 'wpdesktop'... )
# !! Ensure this file is removed regardless of success/failure !!
# Note: Ideally we could use a build argument for this, but Docker CE on Windows
# has trouble consuming the SSH key contents when passed as a build arg.
function cleanup {
rm "$(DESKTOP_DIR)/id_rsa"
}
trap cleanup EXIT
cp "$(SSH_PRIVATE_KEY_FILE)" "$(DESKTOP_DIR)/id_rsa"
@docker build --build-arg NODE_VERSION --tag wpdesktop .
.PHONY: docker-run
docker-run:
$(info Initializing docker container for 'wpdesktop', type 'exit' to quit)
docker run -it --rm -v "$(CALYPSO_DIR)"://usr/src/wp-calypso -p 3000:3000 -e SHELL='//bin/bash' wpdesktop bash
.PHONY: docker-clean
docker-clean:
$(info Removing docker image 'wpdesktop'...)
docker image rm wpdesktop