Quickly setups dependent services and servers for local development
Inspired by Aviator.
Often your application requires other services to run. If you develop locally, starting a particular version
of a service locally, or pointing at a remote can be complicated. Quickly
solves this. Just write
a local quickly.js
file in each project that provides local service or needs other local services.
Then start all other services needed by entering quickly
. If there are multiple configurations,
quickly
will ask you.
Imagine project A depends on the application B to be running. A could be a server and B could be an API.
In the A's root folder create new file quickly.js
module.exports = {
// this project provides service A
A: {
dependencies: {
path: '../B',
service: 'API' // which service to load from ../B/quickly.js
},
// service A starts 'npm run dev'
exec: 'npm',
args: 'run dev'
}
};
Create another quickly.js
file in the project B folder
// project B provides API service
module.exports = {
API: [{
exec: 'npm',
args: 'run watch'
}]
};
When starting a project A using quickly
command all dependent child processes will be started.
When you kill the project A (using Command+C), all child processes will be killed too.
A quickly.js
file can export multiple configurations / services. In this case the system
will ask the user which service to ask. For example, if quickly.js
has
module.exports = {
test1: {
exec: 'echo',
args: 'running test 1'
},
test2: {
exec: 'echo',
args: 'running test 2'
}
};
Then the shell will be
$ quickly
quickly@0.1.4 - Quickly setup dependent services and servers for local development
quickly in "/Users/gleb/git/quickly/test/two-choices" undefined
loading /Users/gleb/git/quickly/test/two-choices/quickly.js
...
no dependencies to start
found multiple services "test1", "test2"
? Pick a service to start: (Use arrow keys)
❯ test1
test2
# picked second
user chose test2
starting "test2" in "/Users/gleb/git/quickly/test/two-choices" command "echo running test 2"
...
test2: running test 2
service "test2" finished with code 0
Other projects can specify which service to start without prompting the service
property
A: {
dependencies: {
path: '../two-choices',
service: 'test2' // do not ask the user, just start test2
},
...
}
For more configuration examples, browser the test folder.
npm install -g quickly
In each project create quickly.js
as shown in the example.
Author: Gleb Bahmutov © 2015 @bahmutov glebbahmutov.com glebbahmutov.com/blog
License: MIT - do anything with the code, but don't blame me if it does not work.
Spread the word: tweet, star on github, etc.
Support: if you find any problems with this module, email / tweet / open issue on Github