Skip to content

Commit

Permalink
Merge pull request #44 from Financial-Times/build
Browse files Browse the repository at this point in the history
nicer non-maintainer dev experience
  • Loading branch information
apaleslimghost authored Apr 24, 2018
2 parents 026e5af + 006cd52 commit d5b3273
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 17 deletions.
42 changes: 42 additions & 0 deletions athloi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const open = require('opn');
const tcpPortUsed = require('tcp-port-used');
const url = require('url');

const openUrls = {
docs: 'http://localhost:8000',
storybook: 'http://localhost:9001',
};

module.exports = ({tasks, prompt, addPrompt}) => ({
start: Object.assign({}, tasks.start, {
requiredArgs: ['open'],

choice: addPrompt(
tasks.start.choice,
() => prompt([{
type: 'list',
name: 'open',
message: 'What do you want to open in the browser?',
choices: [
{value: 'docs', short: 'Docs', name: 'The documentation website'},
{value: 'storybook', short: 'Storybook', name: 'The component explorer'},
]
}])
),

run(options) {
const openUrl = openUrls[options.open];
const port = parseInt(url.parse(openUrl).port, 10);

if(port) {
// wait for whatever (storybook/gatsby) to be listening on the port
// try every 500ms and give up after 30s
tcpPortUsed.waitUntilUsed(port, 500, 30000)
.then(() => open(openUrl))
.catch(e => console.error(e.stack));
}

return tasks.start.run(options);
},
}),
});
3 changes: 1 addition & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"packages": [
"packages/*",
"private/*"
"packages/*"
],
"version": "1.0.0-1"
}
19 changes: 19 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# DO NOT ADD TASKS TO THIS MAKEFILE
# these tasks exist for principle-of-least-surprise purposes for people coming
# here from next-land. this makefile should not be used for anything else.
# instead, use per-package npm scripts

install:
@printf "\n \e[1;34m☞\e[0m this is the same as running \e[3;36mnpm install\e[0m\n\n"
@sleep 3
npm install

run:
@printf "\n \e[1;34m☞\e[0m this is the same as running \e[3;36mnpm start\e[0m\n\n"
@sleep 3
npm start

build:
@printf "\n \e[1;34m☞\e[0m this is the same as running \e[3;36mnpm run build\e[0m\n\n"
@sleep 3
npm run build
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@
"postinstall": "lerna bootstrap",
"rebootstrap": "lerna clean --yes && lerna bootstrap",
"add-package": "addpackage() { mkdir packages/$1 ; pushd packages/$1 ; npm init -y --scope=financial-times ; popd ; } ; addpackage",
"pretest": "lerna run build",
"build": "athloi build",
"pretest": "npm run build",
"test": "jest -c jest.config.js",
"start": "athloi",
"precommit": "secret-squirrel",
"commitmsg": "secret-squirrel-commitmsg"
},
"devDependencies": {
"@financial-times/secret-squirrel": "^2.8.0",
"athloi": "^1.2.0",
"husky": "^0.14.3",
"jest": "^22.4.3",
"lerna": "^3.0.0-beta.16",
"opn": "^5.3.0",
"react": "^16.3.1",
"react-test-renderer": "^16.3.1"
"react-test-renderer": "^16.3.1",
"tcp-port-used": "^0.1.2"
},
"x-dash": {
"engine": {
Expand Down
3 changes: 0 additions & 3 deletions packages/x-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
"license": "MIT",
"scripts": {
"build": "gatsby build --prefix-paths",
"build-storybook": "cd ../x-workbench && npm run build && cd ../x-docs",
"prestart": "npm run build-storybook",
"prebuild": "npm run build-storybook",
"start": "nodemon -x 'gatsby develop' -w \"gatsby-*.js\"",
"postinstall": "bower install"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/x-docs/static/storybook
3 changes: 2 additions & 1 deletion packages/x-teaser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"types": "Props.d.ts",
"scripts": {
"prepare": "npm run build",
"build": "rollup -c rollup.config.js"
"build": "rollup -c rollup.config.js",
"start": "rollup --watch -c rollup.config.js"
},
"keywords": [],
"author": "",
Expand Down
5 changes: 3 additions & 2 deletions packages/x-workbench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"description": "",
"main": "stories.js",
"scripts": {
"storybook": "start-storybook -p 9001 -c .storybook",
"build": "build-storybook -c .storybook -o dist/storybook"
"start": "start-storybook -p 9001 -c .storybook",
"build": "build-storybook -c .storybook -o dist/storybook",
"prepare": "npm run build"
},
"keywords": [],
"author": "",
Expand Down
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
</a>
</h1>

## Developer guide

This is a [Lerna](https://github.com/lerna/lerna) monorepo. To get started hacking on x-dash, clone it and `npm install` as usual, and Lerna will install and link together all the individual packages.

Run `npm start` to open the developer interface, which shows a list of tasks. Choose one to run it and it'll tell you a shortcut to run that task in the future.

## What is this?

x-dash is an experiment in building new shared frontend components for FT.com and the FT Apps. A detailed introduction is available in [Google Slides][slides].
Expand All @@ -17,9 +23,3 @@ x-dash is an experiment in building new shared frontend components for FT.com an
Origami components are designed to work across the whole of FT and our sub-brands, making as few assumptions as possible about the tech stack that will be consuming them. Origami components don't contain templating, only styles and behaviour. It's up to each individual app to produce markup for components.

x-dash aims to complement Origami by providing easily reusable and composable templates, flexibly enough to work across Next and Apps apps.

## Developer guide

This is a [Lerna](https://github.com/lerna/lerna) monorepo. To get started hacking on x-dash, clone it and `npm install` as usual, and Lerna will install and link together all the individual packages.

To add a new package, run `npm run add-package -- package-name`.
1 change: 1 addition & 0 deletions secret-squirrel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
files: {
allow: [
'makefile',
'packages/x-docs/.bowerrc',
'packages/x-docs/LICENSE',
'packages/x-docs/static/storybook',
Expand Down

0 comments on commit d5b3273

Please sign in to comment.