**DEPRECATED & UNMAINTAINED** The payments frontend interface
Перейти к файлу
Stuart Colville 52981a0d83 Merge pull request #213 from muffinresearch/hot-module-charles
Hot module charles
2015-07-21 16:10:37 +01:00
charles Add rewrite config for charles 2015-07-21 16:08:55 +01:00
node_modules Merge pull request #149 from muffinresearch/update-braintree-web 2015-07-02 10:15:14 +01:00
public background-url is now correctly set in the template 2015-07-20 11:41:14 -07:00
styleguide Fix spinner button regression (#195) 2015-07-16 20:13:40 +01:00
tasks Add rewrite config for charles 2015-07-21 16:08:55 +01:00
tests Add initial Saucelabs test setup 2015-07-13 12:23:34 +01:00
.csslintrc Fix CSS lint warnings 2015-07-17 14:42:09 +01:00
.eslintrc Switch to rewire for mocking 2015-06-17 16:53:49 -05:00
.gitignore Use new version of COG (fixes #37) 2015-07-06 17:59:16 +01:00
.travis.yml Move to individual account 2015-07-13 12:27:59 +01:00
Dockerfile FETCH_HEAD doesn't exist 2015-07-07 11:04:13 -07:00
Gruntfile.js Build styleguide when files are changed (fixes #6) 2015-07-16 20:05:27 +01:00
LICENSE Add LICENSE 2015-04-21 18:10:58 +01:00
README.md Add rewrite config for charles 2015-07-21 16:08:55 +01:00
karma.conf.js Move karma.config.shared.js -> karma.shared.js 2015-07-13 12:25:12 +01:00
karma.conf.sauce.js Move karma.config.shared.js -> karma.shared.js 2015-07-13 12:25:12 +01:00
karma.shared.js Add hot module reloading (fixes #199) 2015-07-16 15:34:40 +01:00
package.json Merge pull request #200 from muffinresearch/hot-reloading 2015-07-17 10:56:39 +01:00
webpack.config.js Step back to babel stage 2 (fixes #207) 2015-07-17 17:35:50 +01:00

README.md

Build Status Dependency Status devDependency Status

Sauce Test Status

Note Sauce Labs tests are only run on PRs from the main repo or commits to master.

Payments UI

This project comprises all styles, behaviour and interfaces for mozilla/payments.

Developers

Email Styles

To get the right paths for the email CSS and rebuild files as they change run:

DEV=1 grunt start-email

Dependency installation and updates

Install grunt-cli globally with npm install -g grunt-cli Then run npm install to install the local deps needed for development.

npm deps only

We're aiming to only use npm packaged deps rather than bower. This is to be able to track dep versions in one place.

Libraries + external deps

Normally built artifacts aren't committed. However, to manage dep changes more tightly, production libs (JS, CSS + fonts) are committed to the tree.

JS libs are committed from node_modules as webpack knows how to find deps in node_modules.

Whilst this creates noise it does help ensure deps in the browser are identical and can't get mangled by a broken deps installation.

Watching for file changes in development.

If you're using payments-env to run the complete payments system then you'll want to use grunt start on your host to watch for file changes. In other words, start docker to run all the things but keep a shell open on the host machine just to compile static assets for the docker VM to serve.

Hot module reloading

If you run the webpack-dev-server you can get hot module reloading. This turns on a feature where the code automatically updates in the browser as you change the code in your editor.

For example run grunt serve to run the webpack-dev-server.

And then visit:

http://localhost:8080/webpack-dev-server/management.html

You should find that changes to the react modules are reflected immediately without refresh.

Developing with webpack-dev-server + docker for hot reloading.

To be able to use hot module reloading in conjunction with our docker environment you can use Charles Proxy to rewrite API requests to pay.dev. This allows webpack-dev-server to be used to serve the front-end whilst continuing to allow API requests to be serviced via docker.

There are two steps to getting this working:

  • Create an /etc/hosts entry pay.webpack 127.0.0.1
  • Install Charles Proxy and import the rewrite files from the charles directory.

To see the payment interface with hot module loading enabled visit:

http://pay.dev?webpack

To see the management interface:

http://pay.webpack:8080/webpack-dev-server/management.html

JavaScript Linting

We're using eslint for JavaScript linting. Most editors will have instructions for enabling eslint (see below for how to configure vim + syntastic). Alternatively just run the grunt eslint command which is self-contained.

Eslint Vim settings (Syntastic)

You'll need the packages listed below installed globally:

npm install -g eslint babel-eslint eslint-plugin-react

Using syntastic, the following snippet turns on eslint selectively for projects with a .eslintrc.

autocmd FileType javascript let b:syntastic_checkers = findfile('.eslintrc', '.;') != '' ? ['eslint'] : ['jshint']

Tests

To run the tests locally run: grunt test. This will run the unit tests against Firefox.

Cross-browser testing

The tests are run only on Firefox when a PR is submitted. When that code is landed on master, Travis will run the tests on Sauce Labs.

Running Sauce Labs on a PR [Team Only]

If you're a member of the payments team and you want to get Sauce Labs coverage for a PR - push the branch to the main mozilla/payments-ui repo and make a PR from that.

Running the tests on SauceLabs locally

First Sign-up for a Sauce Labs 'Open Sauce' account to get your keys.

Then you'll need to export the SauceLabs username and access key as env vars:

export SAUCE_USERNAME=<YOUR_OPEN_SAUCE_USERNAME>
export SAUCE_ACCESS_KEY=<YOUR_ACCESS_KEY>

Then you should find you can run: grunt karma:sauce and run all the tests on SauceLabs.

Styleguide

The styleguide is based on the styles and templates that live in the tree.

It can be build statically with the grunt build-styleguide command.

The styleguide is published here.

Updating the styleguide

Run grunt publish-styleguide

Running the styleguide locally

Run grunt styleguide (defaults to running on localhost:4001).

Localization (l10n)

We're using grunt-i18n-abide to run the extraction commands.

Because we're using React we need to operate on the compiled JS file. This also means we aren't running extraction on un-used code.

To run an extraction, checkout out the payments-l10n repository so that it has the same parent directory as payments-ui (../payments-l10n from the current location). Then do the following:

npm install
grunt webpack abideExtract