-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
3,765 additions
and
518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist/*.js -diff | ||
dist/*.css -diff | ||
dist/*.map -diff | ||
dist/*.zip -diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build | ||
config | ||
img | ||
lex-web-ui | ||
Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,101 @@ | ||
# this Makefile is mainly meant to be called from CodeBuild | ||
# or to setup/run the local dev environment | ||
BUILD_DIR := build | ||
# This Makefile is used to configure and deploy the sample app. | ||
# It is used in CodeBuild by the CloudFormation stack. | ||
# It can also be run from a local dev environment. | ||
# It can either deploy a full build or use the prebuilt library in | ||
# in the dist directory | ||
|
||
# environment file provides config parameters | ||
CONFIG_ENV := config/env.mk | ||
include $(CONFIG_ENV) | ||
|
||
all: build | ||
.PHONY: all | ||
|
||
WEBAPP_DIR := ./lex-web-ui | ||
build: config | ||
@echo "[INFO] Building web app in dir [$(WEBAPP_DIR)]" | ||
cd $(WEBAPP_DIR) && npm run build | ||
.PHONY: build | ||
|
||
dev: config | ||
@echo "[INFO] Running web app in dev mode" | ||
cd $(WEBAPP_DIR) && npm run dev | ||
.PHONY: dev | ||
BUILD_DIR := build | ||
DIST_DIR := dist | ||
SRC_DIR := src | ||
CONFIG_DIR := $(SRC_DIR)/config | ||
WEBSITE_DIR := $(SRC_DIR)/website | ||
|
||
PACKAGE_JSON := $(WEBAPP_DIR)/package.json | ||
install-deps: $(PACKAGE_JSON) | ||
# this install all the npm dependencies needed to build from scratch | ||
install-deps: | ||
@echo "[INFO] Installing npm dependencies" | ||
cd $(WEBAPP_DIR) && npm install | ||
.PHONY: install | ||
.PHONY: install-deps | ||
|
||
# BUILD_TYPE controls whether the configuration is done for a full build or | ||
# for using the prebuilt/dist libraries | ||
# Expected values: full || dist | ||
# If empty, probably this is being run locally or from an external script | ||
BUILD_TYPE ?= $() | ||
|
||
# updates the config files with values from the environment | ||
UPDATE_CONFIG_SCRIPT := $(BUILD_DIR)/update-lex-web-ui-config.js | ||
export IFRAME_CONFIG ?= $(realpath $(WEBAPP_DIR)/static/iframe/config.json) | ||
export WEBAPP_CONFIG_PROD ?= $(realpath $(WEBAPP_DIR)/src/config/config.prod.json) | ||
export WEBAPP_CONFIG_DEV ?= $(realpath $(WEBAPP_DIR)/src/config/config.dev.json) | ||
CONFIG_FILES := $(IFRAME_CONFIG) $(WEBAPP_CONFIG_PROD) $(WEBAPP_CONFIG_DEV) | ||
export WEBAPP_CONFIG_PREBUILT ?= $(realpath $(SRC_DIR)/config/bot-config.json) | ||
export IFRAME_CONFIG_PREBUILT ?= $(realpath $(CONFIG_DIR)/bot-loader-config.json) | ||
CONFIG_FILES := $(IFRAME_CONFIG) $(WEBAPP_CONFIG_PROD) $(WEBAPP_CONFIG_DEV) \ | ||
$(WEBAPP_CONFIG_PREBUILT) $(IFRAME_CONFIG_PREBUILT) | ||
config: $(UPDATE_CONFIG_SCRIPT) $(CONFIG_ENV) $(CONFIG_FILES) | ||
@echo "[INFO] Running config script: [$(<)]" | ||
node $(<) | ||
.PHONY: config | ||
|
||
DIST_DIR := $(WEBAPP_DIR)/dist | ||
s3sync: | ||
@echo "[INFO] synching to S3 webapp bucket: [$(WEBAPP_BUCKET)]" | ||
aws s3 sync --acl public-read "$(DIST_DIR)" "s3://$(WEBAPP_BUCKET)/" | ||
.PHONY: s3sync | ||
build: config | ||
@echo "[INFO] Building web app in dir [$(WEBAPP_DIR)]" | ||
cd $(WEBAPP_DIR) && npm run build | ||
.PHONY: build | ||
|
||
s3deploy: | ||
# used by the Pipeline deployment mode when building from scratch | ||
WEBAPP_DIST_DIR := $(WEBAPP_DIR)/dist | ||
CODEBUILD_BUILD_ID ?= none | ||
deploy-to-s3: | ||
@[ "$(WEBAPP_BUCKET)" ] || \ | ||
(echo "[ERROR] WEBAPP_BUCKET env var not set" ; exit 1) | ||
@echo "[INFO] deploying to S3 webapp bucket: [$(WEBAPP_BUCKET)]" | ||
@echo "[INFO] copying build: [$(CODEBUILD_BUILD_ID)]" | ||
aws s3 cp --recursive "$(DIST_DIR)" \ | ||
aws s3 cp --recursive "$(WEBAPP_DIST_DIR)" \ | ||
"s3://$(WEBAPP_BUCKET)/builds/$(CODEBUILD_BUILD_ID)/" | ||
@echo "[INFO] copying new version" | ||
aws s3 cp --recursive --acl public-read \ | ||
"s3://$(WEBAPP_BUCKET)/builds/$(CODEBUILD_BUILD_ID)/" \ | ||
"s3://$(WEBAPP_BUCKET)/" | ||
@[ "$(PARENT_PAGE_BUCKET)" ] && \ | ||
( echo "[INFO] synching parent page to bucket: [$(PARENT_PAGE_BUCKET)]" ; \ | ||
aws s3 sync --acl public-read "$(DIST_DIR)/static/iframe" \ | ||
aws s3 sync --acl public-read "$(WEBAPP_DIST_DIR)/static/iframe" \ | ||
"s3://$(PARENT_PAGE_BUCKET)/static/iframe" ) || \ | ||
echo "[INFO] no parent bucket to deploy" | ||
@echo "[INFO] all done deploying" | ||
.PHONY: s3deploy | ||
.PHONY: deploy-to-s3 | ||
|
||
# Run by CodeBuild deployment mode when which uses the prebuilt libraries | ||
# Can also be used to easily copy local changes to a bucket | ||
# (e.g. mobile hub created bucket) | ||
# It avoids overwriting the aws-config.js file when using outside of a build | ||
sync-website: | ||
@[ "$(WEBAPP_BUCKET)" ] || \ | ||
(echo "[ERROR] WEBAPP_BUCKET variable not set" ; exit 1) | ||
@echo "[INFO] copying libary files" | ||
aws s3 sync --acl public-read \ | ||
--exclude Makefile \ | ||
--exclude lex-web-ui-mobile-hub.zip \ | ||
$(DIST_DIR) s3://$(WEBAPP_BUCKET) | ||
@echo "[INFO] copying website files" | ||
aws s3 sync --acl public-read \ | ||
$(WEBSITE_DIR) s3://$(WEBAPP_BUCKET) | ||
@echo "[INFO] copying config files" | ||
aws s3 sync --acl public-read \ | ||
--exclude '*' \ | ||
--include 'bot-*config.json' \ | ||
$(CONFIG_DIR) s3://$(WEBAPP_BUCKET) | ||
@[ "$(BUILD_TYPE)" = 'dist' ] && \ | ||
echo "[INFO] copying aws-config.js" ;\ | ||
aws s3 sync --acl public-read \ | ||
--exclude '*' \ | ||
--include 'aws-config.js' \ | ||
$(CONFIG_DIR) s3://$(WEBAPP_BUCKET) | ||
@echo "[INFO] all done deploying" | ||
.PHONY: sync-website |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.