John Cowen
39f15306d9
We need a way to load certain CSS based on the environment you are viewing, i.e. we have debug CSS that we use for our Eng Documentation and various other DX utilities that shouldn't be compiled into our production or test builds. Previously we would compile two entirely different CSS files (app and debug) and the load one or the other depending on which environment you were in. This approach just empties out the debug.css file in certain environments (prod/test) which means we can just import that file from app. When in staging/development this imports the contents of debug.css (quite a bit of CSS) whereas when building for production/test this debug.css is emptied out during the build process. There is a slight little hack in order to have this work, we import _debug.scss which imports the debug.scss file. I couldn't for the life of me figure out how to have broccoli empty out a file during the build process, so instead we essentially copy over debug.scss during dev and create an empty file during prod to _debug.scss. When using make build to build an artifact for production CSS remains at ~58kb (during dev its a lot bigger than this) |
3 years ago | |
---|---|---|
.. | ||
app | ui: Change approach to loading debug.css (#12242) | 3 years ago |
blueprints | ui: Fixup route blueprint to reflect project conventions (#11153) | 3 years ago |
config | ui: Bump our browser support (#11505) | 3 years ago |
docs | ui: Enable theming (#12134) | 3 years ago |
lib | ui: Change approach to loading debug.css (#12242) | 3 years ago |
mock-api | [OSS] Remove remaining references to master (#11827) | 3 years ago |
node-tests/config | ui: Pass primary dc through to uiserver (#11317) | 3 years ago |
public |
…
|
|
server |
…
|
|
tests | ui: Fixup KV folder creation then further creation within that folder (#12081) | 3 years ago |
translations | ui: Fixup names of Meta for instance search, also add Node (#11774) | 3 years ago |
vendor | ui: Runtime Injectable Components (#11969) | 3 years ago |
.docfy-config.js | ui: Fix up wiring or empty state login button (#11981) | 3 years ago |
.editorconfig |
…
|
|
.ember-cli |
…
|
|
.eslintignore |
…
|
|
.eslintrc.js | ui: Add selective no-console eslint rule (#11938) | 3 years ago |
.istanbul.yml |
…
|
|
.nvmrc |
…
|
|
.prettierrc |
…
|
|
.template-lintrc.js |
…
|
|
.watchmanconfig |
…
|
|
GNUmakefile | ui: Change approach to loading debug.css (#12242) | 3 years ago |
README.md | ui: Add initial "How 2 Test UI" docs (#11296) | 3 years ago |
ember-cli-build.js | ui: Change approach to loading debug.css (#12242) | 3 years ago |
package.json | ui: attach-shadow modifier (#12207) | 3 years ago |
testem.js |
…
|
README.md
consul-ui
Prerequisites
You will need the following things properly installed on your computer.
-
Node.js (with npm)
Installation
git clone https://github.com/hashicorp/consul.git
this repositorycd ui/packages/consul-ui
then:
To run the UI
From within ui/packages/consul-ui
directory run:
make start
To run tests
From within ui/packages/consul-ui
directory run:
make test-oss-view
which will run the tests in Chrome
(see below and/or the testing section of the engineering docs for further detail)
Yarn Commands
Most used tooling scripts below primarily use make
which will yarn install
and in turn call node package scripts.
List of available project commands. yarn run <command-name>
Command | Description |
---|---|
build:staging | Builds the UI in staging mode (ready for PR preview site). |
build:ci | Builds the UI for CI. |
build | Builds the UI for production. |
lint | Runs all lint commands. |
lint:hbs | Lints hbs template files. |
lint:js | Lints js files. |
format | Runs all auto-formatters. |
format:js | Auto-formats js files using Prettier. |
format:sass | Auto-formats scss files using Prettier. |
start | Runs the development app on a local server using the mock API. |
start:consul | Runs the development app local server using a real consul instance as the backend. |
start:staging | Runs the staging app local server. |
test | Runs the ember tests in a headless browser. |
test:view | Runs the ember tests in a non-headless browser. |
test:oss | Runs only the OSS ember tests in a headless browser. |
test:oss:view | Runs only the OSS ember tests in a non-headless browser. |
test:coverage:view | Runs only the test specified for coverage in a non-headless browser. |
test:node | Runs tests that can't be run in ember using node. |
doc:toc | Automatically generates a table of contents for this README file. |
Running / Development
The source code comes with a small development mode that runs enough of the consul API as a set of mocks/fixtures to be able to run the UI without having to run consul.
make start
oryarn start
to start the ember app- Visit your app at http://localhost:4200.
You can also run the UI against a normal Consul installation.
consul server -dev
to start consul listening on http://localhost:8500make start-consul
to start the ember app proxying toconsul
(this will respect theCONSUL_HTTP_ADDR
environment variable to locate the Consul installation.- Visit your app at http://localhost:4200.
Example:
CONSUL_HTTP_ADDR=http://10.0.0.1:8500 make start-consul
Environment Variables
See ./docs/index.mdx
Branching
Follow a ui/**/**
branch naming pattern. This branch naming pattern allows front-end focused builds, such as FE tests, to run automatically in Pull Requests. It also adds the theme/ui
label to Pull Requests.
Examples:
ui/feature/add...
ui/bugfix/fix...
ui/enhancement/update...
Contributing/Engineering Documentation
We have an in-app (only during development) component storybook and documentation site which can be visited using the Eng Docs link in the top navigation of the UI. Alternatively all of these docs are also readable via GitHub's UI, so folks can use whatever works best for them.
Browser 'Debug Utility' Functions and 'Environment' Variables
Run make start
then visit http://localhost:4200/ui/docs/bookmarklets for a
list of debug/engineering utilities you can use to help development of the UI
under certain scenarios.
Code Generators
Many classes used in the UI can be generated with ember generators, try ember help generate
for more details
Running Tests
Tests use the mock api (see ./mock-api for details), the mock-api runs automatically during testing, you don't need to run anything separately from the below commands in order for the tests to use the mock-api.
make test
oryarn run test
make test-view
oryarn run test:view
to view the tests running in Chrome
For more guidance on running tests, see the testing section of the engineering docs.
OSS only tests can also be run using:
make test-oss
oryarn run test:oss
make test-oss-view
oryarn run test:oss:view
to view the tests running in Chrome
Linting
make lint
currently runs linting on the majority of js files and hbs files (using ember-template-lint
).
See .eslintrc.js
and .eslintignore
for specific configuration.
Building
make build
builds the UI for production usage (env=production)make build-ci
builds the UI for CI/test usage (env=test)
Static files are built into ./dist
Running Tests in Parallel
You probably don't need to understand this if you are simply running some tests locally.
Alternatively, ember-exam
can be used to split the tests across multiple browser instances for faster results. Most options are the same as ember test
. To see a full list of options, run ember exam --help
.
Note: The EMBER_EXAM_PARALLEL
environment variable must be set to override the default parallel
value of 1
browser instance in testem.js.
To quickly run the tests across 4 parallel browser instances:
make test-parallel
To run manually:
$ EMBER_EXAM_PARALLEL=true ./node_modules/.bin/ember exam --split <num> --parallel
More ways to split tests can be found in the ember-exam README.md.