Skip to content

Commit

Permalink
chore(labware-library): Scaffold out project (#3206)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Mar 13, 2019
1 parent a984fe5 commit a9164c1
Show file tree
Hide file tree
Showing 20 changed files with 641 additions and 20 deletions.
30 changes: 22 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ _deploy_s3: &deploy_s3
skip_cleanup: true
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
region: us-east-2
acl: public_read
on:
repo: Opentrons/opentrons
Expand All @@ -33,6 +34,7 @@ _app_stage_build: &app_stage_build
deploy:
- # deploy Opentrons App to S3
<<: *deploy_s3
region: us-east-1
local-dir: app-shell/dist/publish
bucket: $OT_APP_DEPLOY_BUCKET
upload-dir: $OT_APP_DEPLOY_FOLDER
Expand Down Expand Up @@ -88,7 +90,7 @@ jobs:

# test, build, and upload for JavaScript projects
- stage: test
name: 'JS unit tests; build/deploy Protocol Designer, Components Library'
name: 'JS unit tests; build Protocol Designer, Labware Library, Components Library'
# node version pulled from .nvmrc
language: node_js
install:
Expand All @@ -98,19 +100,25 @@ jobs:
- make lint-js lint-css
- make -C components
- make -C protocol-designer
- make -C labware-library
after_success:
- make coverage
deploy:
- # deploy protocol designer to S3
- # upload protocol designer artifacts to S3
<<: *deploy_s3
region: us-east-2
dot_match: true
local-dir: protocol-designer/dist
bucket: $OT_PD_DEPLOY_BUCKET
upload-dir: $TRAVIS_BRANCH
- # deploy components library to S3

- # upload labware library artifacts to S3
<<: *deploy_s3
local-dir: labware-library/dist
bucket: $OT_LL_DEPLOY_BUCKET
upload-dir: $TRAVIS_BRANCH

- # upload components library artifacts to S3
<<: *deploy_s3
# TODO(mc, 2018-03-26): why is this region not default?
region: us-west-2
local-dir: components/dist
bucket: opentrons-components
Expand Down Expand Up @@ -160,19 +168,25 @@ env:
- OT_TAG: $TRAVIS_TAG
- OT_PD_COMMIT_HASH: $TRAVIS_COMMIT

# TODO(mc, 2019-03-13): move to Travis settings
- OT_CI_TEMP_S3_PATH: s3://opentrons-ci/temp/$OT_BUILD

# TODO(mc, 2019-03-13): move to Travis settings
- OT_APP_DEPLOY_BUCKET: opentrons-app
- OT_APP_DEPLOY_FOLDER: builds

# GITHUB_TOKEN
# TODO(mc, 2019-03-13): move to Travis settings
- secure: f/W7kN4gOvVpIanTQh9QtCwiXOk5UrRnUPo2ZU1Qk8zaFVbNj2za2A1xGKMqSyfZKw7guqIwTjWgc/aF9lxRtfU+5fkedJQdxDi5r7jZFxpqmpZOlhyXVY8WAWNqavEkefQInPlpHVAL8M2eV+Pi1cO9FsMhdyy/Wk7qA2nOiA8//9pFRB+0jgSbe1yqIF5DPyL0kbibd3EwmQvuQtnn25qqJXjneenhL6spflLCrnUjq1N/iOlcGd94eBUtk8RaBtMEjOb2D0Mb0DWKMsppoXg4/mZDus6s/PlmBwUJKNCuRtDiEUn5brE14q3OQh/FkDoXMRl69VND2mYp1LOeh5fgLSu6P+YToyHrh4lhXaRAul6l3JmXuoDC3k8hOAr8rPbtiwH7wGY2eRNv59vUejdXof4KHbAN6FTIH934tTe4uvBH79hRMoFY51pHRe6UiC39e/3hwl0pVKLjkV/40wfdEeYA7xhTZQVux+FAfk2krmggokxGEhbAQhWoyRX/wlH2XfEgassGskJ9SbuumNPNOLmEV9OOISFaXoYqVn+SPXy8mN1Pl2sLfaPFtnmmiY20t6yWsHsmfwi+41lv8n0vwCOGq521suDeNyiFhOH2AqG7xm6nHbIv+CiWt2ntKXgV233J17usvfr1zSK07PMDMlV2lvJx3CXj3hA4Yb4=

# OT_APP_MIXPANEL_ID
- secure: "T0h/KyXFRS4jsaor2sRLlKaUFxVmIH5LXArVLYi6I3Wz45SXvQuiH+gUic775rBLdpI8d+TgxCWyUPm1AJTCvCdaMr5PW/xyHeTT4qz0MKT1nThrO2Vi5cKWAUbZV6P8d8m9EBsJlvhgp7egLymS4K5zaotV07v6OK0qVJWiFo+Zj/ufQhQikIU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ZGBwJW6ykfjG+vyRep/IIW5r0ujnBcmgxT7USVpW0E45QolZBS75t29kkTxP0/EHLMavv7QqP3LNpDJpptPrMQ8mLINxlB7FCQ2AQLbDY="
# TODO(mc, 2019-03-13): move to Travis settings
- secure: 'N/WWTWYdEPF7UfWIefSnOIKYVj9/q8ti7kCiB9DNfeKIsjJwsmg6S5yrwn6N4B/9ZMSp0yswo442n09CvH4jMG99BodXdYxg3JhuJ5dxWReAUTWO0PTiyihWeFhd2sbQ3VZa+o85OoFWFHO8UCXqcG//iUZ4l05t9DY5CGUBsPnyJTptsjPCb+CFUc+xkckv9RBfhLeyGBDWodJVfjU4xb124f5MBVF67OlHJ20HmbuH/kRNLDXSiRW4BD9UIXyWrIaPZHW612dX6inETz0vhUOJbUftgn8kdpjjBqa1394TjnjW5fey1n73KH4KpaDPZeGJ5GnYRpk9Wvw7uQkWH7xjkXbFq6cqd0vIWWS5uYmdsMsNDjUtTyELqG01rj813jbmcItuzK2tAcuQ5kBPwikLsHYeQY/68GKlws9POd444YQXXiTYgCoHgYq8O3nxaLoMZBgabFq6Rtz0xJb3Hu99PkU6flI4hgT82RZGf32PgYSKznaGps9DGf2as8FU+wui/So89eQwkDyhirzGvC31OlRHdZitjWYvI27nGgiPWheuZR5zAtf6tJeZaZ1N/PZGBwJW6ykfjG+vyRep/IIW5r0ujnBcmgxT7USVpW0E45QolZBS75t29kkTxP0/EHLMavv7QqP3LNpDJpptPrMQ8mLINxlB7FCQ2AQLbDY='
13 changes: 12 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
'use strict'

const PRESET_ENV_NO_MODULES = ['@babel/preset-env', {modules: false}]
const PRESET_ENV_NO_MODULES = [
'@babel/preset-env',
{
modules: false,
// TODO(mc, 2019-03-13): uncomment this line to enable babel polyfill
// useBuiltIns: 'usage',
},
]

const PRESET_ENV_CJS_MODULES = ['@babel/preset-env', {modules: 'commonjs'}]

module.exports = {
env: {
production: {
// TODO(mc, 2019-03-13): add '@babel/plugin-transform-runtime'
// along with useBuiltIns TODO above
plugins: ['babel-plugin-unassert'],
},
development: {
Expand All @@ -19,6 +29,7 @@ module.exports = {
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-syntax-dynamic-import',
],
presets: ['@babel/preset-flow', '@babel/preset-react', PRESET_ENV_NO_MODULES],
overrides: [
Expand Down
30 changes: 30 additions & 0 deletions labware-library/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# opentrons labware-library makefile

SHELL := /bin/bash

# add node_modules/.bin to PATH
PATH := $(shell cd .. && yarn bin):$(PATH)

.PHONY: all
all: clean dist

.PHONY: clean
clean:
shx rm -rf dist

# production assets
.PHONY: dist
dist: export NODE_ENV := production
dist:
webpack --profile

# development assets server
.PHONY: dev
dev: export NODE_ENV := development
dev:
webpack-dev-server --hot

# production assets server
.PHONY: serve
serve: all
node ../scripts/serve-static dist
83 changes: 83 additions & 0 deletions labware-library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# labware library

<https://labware.opentrons.com>

> Library of standard labware for use with your OT-2
The Labware Library is an app for OT-2 users to discover, learn about, and use the labware the OT-2 supports.

## development setup

### setup

Follow the top-level [contributing guide][contributing] to set your repository up for development.

```shell
cd opentrons
make install
```

### common tasks

Unit tests, linting, and typechecking are all run from the repository level Makefile. The contributing guide has more details.

```shell
# run unit-tests, lints, and typechecks
make test-js lint-js check-js

# run unit-tests in watch mode
make test-js watch=true
```

[contributing]: ../CONTRIBUTING.md

### labware-library tasks

This directory's Makefile has the following set of labware-library specific development tasks defined.

```shell
# default task: build production artifacts
# these three commands are identical
make -C labware-library
make -C labware-library all
make -C labware-library clean dist

# start a hot-reloading development server
# (optional) specify port with PORT; default is 8080
make -C labware-library dev
make -C labware-library dev PORT=8081

# build production assets and serve them
# (optional) specify port with PORT; default is 9090
make -C labware-library serve
make -C labware-library serve PORT=9091
```

### webpack setup

This project (along with our other front-end projects) uses [webpack][] to generate artifacts.

- Extends our [base webpack config][base-config]
- Entry point is [`labware-library/src/index.js`][entry]
- [Handlebars][] HTML template is [`labware-library/src/index.hbs`][template]
- At template build time, JS entry is run via [prerender-loader][]
- DOM output from JS is then inserted into HTML output
- Global CSS is [`labware-library/src/global.css`][global-style]
- All other CSS is used via [CSS Modules][]
- All artifacts will be output to `labware-library/dist`

[handlebars]: https://handlebarsjs.com/
[css modules]: https://github.com/css-modules/css-modules
[prerender-loader]: https://github.com/GoogleChromeLabs/prerender-loader
[base-config]: ../webpack-config
[entry]: ./src/index.js
[template]: ./src/index.hbs
[global-style]: ./src/global.css

### environment variables

Certain environment variables, when set, will affect the artifact output.

| variable | value | description |
| -------- | ----------------------------- | ------------------------------------------- |
| NODE_ENV | production, development, test | Optimizes output for a specific environment |
21 changes: 21 additions & 0 deletions labware-library/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@opentrons/labware-library",
"productName": "Labware Library",
"version": "3.7.0",
"description": "Opentrons standard labware library",
"main": "src/index.js",
"repository": {
"type": "git",
"url": "https://github.com/Opentrons/opentrons.git",
"directory": "labware-library"
},
"author": {
"name": "Opentrons Labworks",
"email": "[email protected]"
},
"license": "Apache-2.0",
"dependencies": {
"@opentrons/components": "3.7.0",
"react-hot-loader": "^4.8.0"
}
}
12 changes: 12 additions & 0 deletions labware-library/src/components/App/__tests__/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// app tests
import React from 'react'
import Renderer from 'react-test-renderer'

import {App} from '..'

describe('App', () => {
test('component renders', () => {
const tree = Renderer.create(<App />).toJSON()
expect(tree).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`App component renders 1`] = `
<h1
className="title"
>
Opentrons Labware Library
</h1>
`;
12 changes: 12 additions & 0 deletions labware-library/src/components/App/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @flow
// main application wrapper component
import * as React from 'react'
import {hot} from 'react-hot-loader/root'

import styles from './styles.css'

export function App () {
return <h1 className={styles.title}>Opentrons Labware Library</h1>
}

export default hot(App)
6 changes: 6 additions & 0 deletions labware-library/src/components/App/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* app styles */
@import '@opentrons/components';

.title {
@apply --font-huge-dark;
}
6 changes: 6 additions & 0 deletions labware-library/src/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* global styles
*/

@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,800');
@import './styles/reset.css';
14 changes: 14 additions & 0 deletions labware-library/src/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name='description' content='{{htmlWebpackPlugin.options.description}}'>
<meta name='author' content='{{htmlWebpackPlugin.options.author}}'>
<title>{{htmlWebpackPlugin.options.title}}</title>
</head>

<body>
<div id="root"></div>
</body>
</html>
20 changes: 20 additions & 0 deletions labware-library/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @flow
// labware library entry
import * as React from 'react'

import './global.css'
import App from './components/App'

render()

export default function render () {
const $root = document.getElementById('root')

if (!$root) {
throw new Error('fatal: #root not found')
}

return Promise.all([import('react-dom')]).then(([{default: ReactDom}]) => {
ReactDom.hydrate(<App />, $root)
})
}
60 changes: 60 additions & 0 deletions labware-library/src/styles/reset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* basic CSS reset
* TODO(mc, 2019-03-12): copied from Opentrons/opentrons-website; merge somehow
*/

/* use border-box because it's more sane */
*,
*::before,
*::after {
box-sizing: border-box;
}

/* prevent adjustments of font size after mobile orientation changes */
html {
text-size-adjust: 100%;
}

/* remove margin from body and set sane font-size + line-height */
body {
margin: 0;
font-size: 16px;
line-height: 1;
font-family: 'Open Sans', sans-serif;
}

/* ensure <main> works in IE 9, 10, and 11 */
main {
display: block;
}

/* make images responsive */
img {
max-width: 100%;
border-style: none;
}

/* strip margin and padding from text elements */
h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol {
margin: 0;
padding: 0;
}

/* no list style by default */
ul,
ol {
list-style: none;
}

/* no underline on links by default */
a {
text-decoration: none;
}
Loading

0 comments on commit a9164c1

Please sign in to comment.