-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from Financial-Times/build
nicer non-maintainer dev experience
- Loading branch information
Showing
10 changed files
with
82 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}, | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"packages": [ | ||
"packages/*", | ||
"private/*" | ||
"packages/*" | ||
], | ||
"version": "1.0.0-1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../x-workbench/dist/storybook/ | ||
../node_modules/@financial-times/x-workbench/dist/storybook/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters