Skip to content

Commit 6589cbb

Browse files
authored
ui: Move to Workspaced Structure (hashicorp#8994)
* ui: Add the most basic workspace root in /ui * We already have a LICENSE file in the repository root * Change directory path in build scripts ui-v2 -> ui * Make yarn install flags configurable from elsewhere * Minimal workspace root makefile * Call the new docker specific target * Update yarn in the docker build image * Reconfigure the netlify target and move to the higher makefile * Move ui-v2 -> ui/packages/consul-ui * Change repo root to refleect new folder structure * Temporarily don't hoist consul-api-double * Fixup CI configuration * Fixup lint errors * Fixup Netlify target
1 parent bdd5e1e commit 6589cbb

File tree

1,704 files changed

+13655
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,704 files changed

+13655
-85
lines changed

.circleci/config.yml

+23-22
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ references:
1111
test-results: &TEST_RESULTS_DIR /tmp/test-results
1212

1313
cache:
14-
yarn: &YARN_CACHE_KEY consul-ui-v2-{{ checksum "ui-v2/yarn.lock" }}
14+
yarn: &YARN_CACHE_KEY consul-ui-v3-{{ checksum "ui/packages/consul-ui/yarn.lock" }}
1515
rubygem: &RUBYGEM_CACHE_KEY static-site-gems-v1-{{ checksum "Gemfile.lock" }}
1616

1717
environment: &ENVIRONMENT
@@ -559,12 +559,13 @@ jobs:
559559

560560
- run:
561561
name: install yarn packages
562-
command: cd ui-v2 && yarn install
562+
command: cd ui/packages/consul-ui && yarn install --focus
563563

564564
- save_cache:
565565
key: *YARN_CACHE_KEY
566566
paths:
567-
- ui-v2/node_modules
567+
- ui/node_modules
568+
- ui/packages/consul-ui/node_modules
568569
- run: *notify-slack-failure
569570

570571
# build ember so frontend tests run faster
@@ -578,13 +579,13 @@ jobs:
578579
- checkout
579580
- restore_cache:
580581
key: *YARN_CACHE_KEY
581-
- run: cd ui-v2 && make build-ci
582+
- run: cd ui/packages/consul-ui && make build-ci
582583

583584
# saves the build to a workspace to be passed to a downstream job
584585
- persist_to_workspace:
585-
root: ui-v2
586+
root: ui
586587
paths:
587-
- dist
588+
- packages/consul-ui/dist
588589
- run: *notify-slack-failure
589590

590591
# build ember so frontend tests run faster
@@ -604,13 +605,13 @@ jobs:
604605
- checkout
605606
- restore_cache:
606607
key: *YARN_CACHE_KEY
607-
- run: cd ui-v2 && make
608+
- run: cd ui && make
608609

609610
# saves the build to a workspace to be passed to a downstream job
610611
- persist_to_workspace:
611-
root: ui-v2
612+
root: ui
612613
paths:
613-
- dist
614+
- packages/consul-ui/dist
614615
- run: *notify-slack-failure
615616

616617
# build static-assets file
@@ -644,10 +645,10 @@ jobs:
644645
- run:
645646
name: commit agent/uiserver/bindata_assetfs.go if there are UI changes
646647
command: |
647-
# check if there are any changes in ui-v2/
648+
# check if there are any changes in ui/
648649
# if there are, we commit the ui static asset file
649650
# HEAD^! is shorthand for HEAD^..HEAD (parent of HEAD and HEAD)
650-
if ! git diff --quiet --exit-code HEAD^! ui-v2/; then
651+
if ! git diff --quiet --exit-code HEAD^! ui/; then
651652
git config --local user.email "[email protected]"
652653
git config --local user.name "hashicorp-ci"
653654
@@ -669,9 +670,9 @@ jobs:
669670
- restore_cache:
670671
key: *YARN_CACHE_KEY
671672
- attach_workspace:
672-
at: ui-v2
673+
at: ui
673674
- run:
674-
working_directory: ui-v2
675+
working_directory: ui/packages/consul-ui
675676
command: make test-node
676677
- run: *notify-slack-failure
677678

@@ -689,12 +690,12 @@ jobs:
689690
- restore_cache:
690691
key: *YARN_CACHE_KEY
691692
- attach_workspace:
692-
at: ui-v2
693+
at: ui
693694
- run:
694-
working_directory: ui-v2
695+
working_directory: ui/packages/consul-ui
695696
command: node_modules/.bin/ember exam --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` --path dist --silent -r xunit
696697
- store_test_results:
697-
path: ui-v2/test-results
698+
path: ui/packages/consul-ui/test-results
698699
- run: *notify-slack-failure
699700

700701
# run ember frontend tests
@@ -711,12 +712,12 @@ jobs:
711712
- restore_cache:
712713
key: *YARN_CACHE_KEY
713714
- attach_workspace:
714-
at: ui-v2
715+
at: ui
715716
- run:
716-
working_directory: ui-v2
717+
working_directory: ui/packages/consul-ui
717718
command: node_modules/.bin/ember exam --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` --path dist --silent -r xunit
718719
- store_test_results:
719-
path: ui-v2/test-results
720+
path: ui/packages/consul-ui/test-results
720721
- run: *notify-slack-failure
721722

722723
# run ember frontend unit tests to produce coverage report
@@ -728,13 +729,13 @@ jobs:
728729
- restore_cache:
729730
key: *YARN_CACHE_KEY
730731
- attach_workspace:
731-
at: ui-v2
732+
at: ui
732733
- run:
733-
working_directory: ui-v2
734+
working_directory: ui/packages/consul-ui
734735
command: make test-coverage-ci
735736
- run:
736737
name: codecov ui upload
737-
working_directory: ui-v2
738+
working_directory: ui/packages/consul-ui
738739
command: bash <(curl -s https://codecov.io/bash) -v -c -C $CIRCLE_SHA1 -F ui
739740
- run: *notify-slack-failure
740741

build-support/docker/Build-UI.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM alpine:${ALPINE_VERSION}
33

44
ARG NODEJS_VERSION=12.15.0-r1
55
ARG MAKE_VERSION=4.2.1-r2
6-
ARG YARN_VERSION=1.19.1
6+
ARG YARN_VERSION=1.22.5
77

88
RUN apk update && \
99
apk add nodejs=${NODEJS_VERSION} nodejs-npm=${NODEJS_VERSION} make=${MAKE_VERSION} && \
@@ -12,4 +12,4 @@ RUN apk update && \
1212
mkdir /consul-src
1313

1414
WORKDIR /consul-src
15-
CMD make
15+
CMD make dist-docker

build-support/functions/20-build.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function build_ui {
4949
fi
5050

5151
local sdir="$1"
52-
local ui_dir="${1}/ui-v2"
52+
local ui_dir="${1}/ui"
5353

5454
# parse the version
5555
version=$(parse_version "${sdir}")
@@ -89,8 +89,8 @@ function build_ui {
8989
(
9090
tar -c $(ls -A | grep -v "^(node_modules\|dist\|tmp)") | docker cp - ${container_id}:/consul-src &&
9191
status "Running build in container" && docker start -i ${container_id} &&
92-
rm -rf ${1}/ui-v2/dist &&
93-
status "Copying back artifacts" && docker cp ${container_id}:/consul-src/dist ${1}/ui-v2/dist
92+
rm -rf ${1}/ui/dist &&
93+
status "Copying back artifacts" && docker cp ${container_id}:/consul-src/packages/consul-ui/dist ${1}/ui/dist
9494
)
9595
ret=$?
9696
docker rm ${container_id} > /dev/null
@@ -99,7 +99,7 @@ function build_ui {
9999
# Check the version is baked in correctly
100100
if test ${ret} -eq 0
101101
then
102-
local ui_vers=$(ui_version "${1}/ui-v2/dist/index.html")
102+
local ui_vers=$(ui_version "${1}/ui/dist/index.html")
103103
if test "${version}" != "${ui_vers}"
104104
then
105105
err "ERROR: UI version mismatch. Expecting: '${version}' found '${ui_vers}'"
@@ -110,7 +110,7 @@ function build_ui {
110110
# Check the logo is baked in correctly
111111
if test ${ret} -eq 0
112112
then
113-
local ui_logo_type=$(ui_logo_type "${1}/ui-v2/dist/index.html")
113+
local ui_logo_type=$(ui_logo_type "${1}/ui/dist/index.html")
114114
if test "${logo_type}" != "${ui_logo_type}"
115115
then
116116
err "ERROR: UI logo type mismatch. Expecting: '${logo_type}' found '${ui_logo_type}'"
@@ -123,7 +123,7 @@ function build_ui {
123123
then
124124
rm -rf ${1}/pkg/web_ui
125125
mkdir -p ${1}/pkg
126-
cp -r ${1}/ui-v2/dist ${1}/pkg/web_ui
126+
cp -r ${1}/ui/dist ${1}/pkg/web_ui
127127
fi
128128

129129
popd > /dev/null
@@ -316,7 +316,7 @@ function build_consul {
316316
then
317317
status "Copying the source from '${sdir}' to /consul"
318318
(
319-
tar -c $(ls | grep -v "^(ui\|ui-v2\|website\|bin\|pkg\|.git)") | docker cp - ${container_id}:/consul &&
319+
tar -c $(ls | grep -v "^(ui\|website\|bin\|pkg\|.git)") | docker cp - ${container_id}:/consul &&
320320
status "Running build in container" &&
321321
docker start -i ${container_id} &&
322322
status "Copying back artifacts" &&

ui/.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
!bin
2+
# See https://help.github.com/ignore-files/ for more about ignoring files.
3+
4+
# compiled output
5+
/dist/
6+
/tmp/
7+
8+
# dependencies
9+
/node_modules/
10+
11+
# misc
12+
/.env*
13+
/.pnp*
14+
/.sass-cache
15+
/connect.lock
16+
/coverage/
17+
/libpeerconnection.log
18+
/npm-debug.log*
19+
/testem.log
20+
/yarn-error.log
21+
22+
# ember-try
23+
/.node_modules.ember-try/
24+
/bower.json.ember-try
25+
/package.json.ember-try

ui/GNUmakefile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.PHONY: clean dist dist-docker dist-netlify
2+
# Called from the build ui docker image
3+
dist-docker: dist
4+
5+
clean:
6+
rm -rf ./dist
7+
8+
# Build a distribution of the UI using the minimal amount of dependencies
9+
dist: clean
10+
cd packages/consul-ui && \
11+
CONSUL_UI_INSTALL_FLAGS=--focus \
12+
$(MAKE)
13+
14+
# Build a distribution of the UI for Netlify previews.
15+
# The distribution must be copied into the ui/ subfolder
16+
# in order to mirror the go binary
17+
#
18+
# Netlify Settings:
19+
# ---
20+
# base-directory: ui
21+
# build command: make dist-netlify
22+
# publish directory: ui/dist
23+
dist-netlify: clean
24+
mkdir -p dist/ui && \
25+
cd packages/consul-ui && \
26+
CONSUL_UI_INSTALL_FLAGS=--focus \
27+
$(MAKE) build-staging && \
28+
mv dist/* ../../dist/ui && \
29+
cp _redirects ../../dist/_redirects

ui/README.md

+60

ui/package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"private": true,
3+
"description": "Monorepo for Consul UI, packages and addons.",
4+
"license": "MPL-2.0",
5+
"author": "HashiCorp",
6+
"workspaces": {
7+
"packages": [
8+
"packages/*"
9+
],
10+
"nohoist": [
11+
"**/@hashicorp/consul-api-double",
12+
"**/@hashicorp/consul-api-double/**"
13+
]
14+
},
15+
"scripts": {
16+
"doc:toc": "doctoc README.md"
17+
},
18+
"devDependencies": {
19+
"doctoc": "^1.4.0"
20+
}
21+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

ui-v2/GNUmakefile renamed to ui/packages/consul-ui/GNUmakefile

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ROOT:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2+
CONSUL_UI_INSTALL_FLAGS?=
23

34
all: build
45

@@ -7,16 +8,6 @@ deps: node_modules clean
78
clean:
89
rm -rf ./tmp
910

10-
# target for netlify ui previews
11-
# Netlify Settings
12-
# base-directory: ui-v2
13-
# build command: make netlify
14-
# publish directory: ui-v2/ui-dist
15-
netlify: build-staging
16-
mkdir -p ui-dist/ui \
17-
&& mv dist/* ui-dist/ui/ \
18-
&& cp _redirects ui-dist/_redirects
19-
2011
build-staging: deps
2112
yarn run build:staging
2213

@@ -77,7 +68,6 @@ test-coverage-ci: deps
7768
test-parallel: deps
7869
yarn run test:parallel
7970

80-
8171
lint: deps
8272
yarn run lint:hbs && yarn run lint:js
8373

@@ -88,6 +78,6 @@ steps:
8878
yarn run steps:list
8979

9080
node_modules: yarn.lock package.json
91-
yarn install
81+
yarn install $(CONSUL_UI_INSTALL_FLAGS)
9282

9383
.PHONY: all deps build start test test-view lint format clean
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)