Comparing version 0.2.2 to 0.3.0
#!/usr/bin/env node | ||
var args = process.argv; | ||
var kleur = require('kleur'); | ||
var which = require('which'); | ||
if (/node(js)?(\.exe)?$/.test(args[0])) { | ||
args = args.slice(2); | ||
} | ||
// or use another library to detect support | ||
kleur.enabled = require('color-support').level > 0; | ||
var { | ||
AwesomeMaven, | ||
log, | ||
logError | ||
} = require('..'); | ||
var args = process.argv.slice(2); | ||
function parseOptions(args) { | ||
@@ -19,12 +26,12 @@ | ||
if (/^(--help)$/.test(a)) { | ||
console.log(); | ||
console.log('usage: amvn [special options] [maven arguments...]'.yellow); | ||
console.log(); | ||
console.log('Special Options: '.yellow); | ||
console.log(' -w,--watch Watch src/main/resources for changes and'.yellow); | ||
console.log(' update target directory'.yellow); | ||
console.log(' -r,--reload Reload app on src/main/java changes'.yellow); | ||
console.log(' --poll Use polling during watch'.yellow); | ||
console.log(); | ||
console.log('mvn help follows...'.yellow); | ||
log(); | ||
log('usage: amvn [special options] [maven arguments...]'); | ||
log(); | ||
log('Special Options: '); | ||
log(' -w,--watch Watch src/main/resources for changes and'); | ||
log(' update target directory'); | ||
log(' -r,--reload Reload app on src/main/java changes'); | ||
log(' --poll Use polling during watch'); | ||
log(); | ||
log('mvn help follows...'); | ||
} | ||
@@ -56,17 +63,23 @@ | ||
var which = require('which'), | ||
amvn = require('../'); | ||
var options = parseOptions(args); | ||
which('mvn', function(err, mvnPath) { | ||
async function run() { | ||
if (err) { | ||
console.error('failed to grab mvn. do you have maven on your path?'.red); | ||
console.error(err.message); | ||
return process.exit(1); | ||
try { | ||
const mvnPath = await which('mvn'); | ||
log('make maven awesome'); | ||
AwesomeMaven(mvnPath, options); | ||
} catch (err) { | ||
logError('failed to grab mvn. do you have maven on your path?'); | ||
logError(err); | ||
process.exit(1); | ||
} | ||
} | ||
console.log('[AMVN] make maven awesome'.yellow); | ||
amvn(mvnPath, options); | ||
}); | ||
run().catch(err => { | ||
logError(err); | ||
process.exit(1); | ||
}); |
47
index.js
'use strict'; | ||
var JAVA_SOURCES = 'src/main/java', | ||
@@ -8,2 +7,4 @@ JAVA_RESOURCES = 'src/main/resources', | ||
var color = require('kleur'); | ||
var spawn = require('child_process').spawn; | ||
@@ -13,9 +14,25 @@ var path = require('path'); | ||
var chokidar = require('chokidar'), | ||
colors = require('colors'), | ||
cp = require('cp'), | ||
mkdirp = require('mkdirp'); | ||
var prefix = '[AMVN]'; | ||
var log = console.log.bind(console); | ||
function log(msg, ...args) { | ||
if (!arguments.length) { | ||
console.log(); | ||
} | ||
console.log(color.yellow(`${prefix} ${msg}`), ...args); | ||
} | ||
function logError(msg, ...args) { | ||
if (msg instanceof Error) { | ||
console.error(msg, ...args); | ||
} else { | ||
console.error(color.red(`${prefix} ${msg}`), ...args); | ||
} | ||
} | ||
function now() { | ||
@@ -40,3 +57,3 @@ return new Date().getTime(); | ||
if (!cleanStart) { | ||
log('[AMVN] restarting mvn...'.yellow); | ||
log('restarting mvn...'); | ||
} | ||
@@ -50,3 +67,3 @@ | ||
if (code && code !== 143) { | ||
log('[AMVN] mvn exited unexpectedly (code=%s)'.red, code); | ||
logError('mvn exited unexpectedly (code=%s)', code); | ||
@@ -71,3 +88,3 @@ process.exit(1); | ||
if (mvn) { | ||
log('[AMVN] sending KILL to mvn...'.yellow); | ||
log('sending KILL to mvn...'); | ||
@@ -77,3 +94,3 @@ try { | ||
} catch (e) { | ||
log(('[AMVN] received <' + e.message + '>. Already dead?').yellow); | ||
log('received <' + e.message + '>. Already dead?'); | ||
} | ||
@@ -86,5 +103,6 @@ } | ||
} catch (e) { | ||
// does not exist | ||
log('[AMVN] mvn gone'.yellow); | ||
log('mvn gone'); | ||
@@ -103,3 +121,3 @@ // clear timer | ||
log('[AMVN] watching for %s changes...'.yellow, JAVA_RESOURCES); | ||
log('watching for %s changes...', JAVA_RESOURCES); | ||
@@ -115,3 +133,3 @@ var watcher = chokidar.watch(JAVA_RESOURCES + '/**/*', { usePolling: options.poll }); | ||
log('[AMVN] %s changed, updating in %s'.yellow, srcPath, JAVA_CLASSES); | ||
log('%s changed, updating in %s', srcPath, JAVA_CLASSES); | ||
@@ -127,3 +145,3 @@ mkdirp.sync(targetDirectory); | ||
function registerReload() { | ||
log('[AMVN] reloading mvn on %s changes...'.yellow, JAVA_SOURCES); | ||
log('reloading mvn on %s changes...', JAVA_SOURCES); | ||
@@ -137,3 +155,2 @@ // One-liner for current directory, ignores .dotfiles | ||
if (options.watch) { | ||
@@ -150,2 +167,6 @@ registerWatch(); | ||
module.exports = AwesomeMaven; | ||
module.exports = { | ||
log, | ||
logError, | ||
AwesomeMaven | ||
}; |
{ | ||
"name": "amvn", | ||
"description": "A Maven wrapper adding change detection and automatic rebuild", | ||
"keywords": [ | ||
"maven", | ||
"java", | ||
"wrapper", | ||
"development", | ||
"tool", | ||
"live-reload", | ||
"change detection" | ||
], | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\"" | ||
"all": "run-s lint test", | ||
"lint": "eslint .", | ||
"test": "node bin/cmd.js --version" | ||
}, | ||
@@ -26,11 +19,28 @@ "bin": { | ||
}, | ||
"bugs": "https://github.com/nikku/amvn/issues", | ||
"keywords": [ | ||
"maven", | ||
"java", | ||
"wrapper", | ||
"development", | ||
"tool", | ||
"live-reload", | ||
"change detection" | ||
], | ||
"dependencies": { | ||
"chokidar": "^1.0.5", | ||
"colors": "^1.1.2", | ||
"chokidar": "^3.5.3", | ||
"color-support": "^1.1.3", | ||
"cp": "^0.2.0", | ||
"debounce": "^1.0.0", | ||
"mkdirp": "^0.5.1", | ||
"which": "^1.1.1" | ||
} | ||
"kleur": "^4.1.4", | ||
"mkdirp": "^1.0.4", | ||
"which": "^2.0.2" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^8.18.0", | ||
"eslint-plugin-bpmn-io": "^0.14.0", | ||
"npm-run-all": "^4.1.5" | ||
}, | ||
"files": [ | ||
"bin", | ||
"index.js" | ||
] | ||
} |
@@ -1,20 +0,10 @@ | ||
# amvn (read: _awesome maven_) | ||
# amvn | ||
`amvn` is a small wrapper around [Maven](https://maven.apache.org/) that adds change detection and automatic rebuild to your projects. | ||
[![CI](https://github.com/nikku/amvn/actions/workflows/CI.yml/badge.svg)](https://github.com/nikku/amvn/actions/workflows/CI.yml) | ||
Use it to get faster feedback on changes in your project. | ||
`amvn` (awesome maven) wraps [Maven](https://maven.apache.org/) to add change detection and automatic rebuild. | ||
## How it works | ||
## Installation | ||
`amvn` keeps the running application in sync with your sources | ||
* keeping `target/classes` up to date with `src/main/resources` | ||
* reloading the underlying `mvn` instance on changes in `src/main/java` | ||
Use it with modern web development stacks such as [Dropwizard](https://dropwizard.github.io/dropwizard/) that bootstrap _fast_. | ||
## Get it | ||
Install the library via [npm](https://www.npmjs.com): | ||
@@ -33,3 +23,2 @@ | ||
[AMVN] watching for src/main/resources changes... | ||
[AMVN] starting mvn... | ||
[INFO] Scanning for projects... | ||
@@ -49,4 +38,14 @@ [INFO] | ||
## How it works | ||
`amvn` keeps the running application in sync with your sources | ||
* keeping `target/classes` up to date with `src/main/resources` | ||
* reloading the underlying `mvn` instance on changes in `src/main/java` | ||
Use it with modern web development stacks that bootstrap _fast_. | ||
## License | ||
MIT | ||
MIT |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
7114
169
2
3
5
49
+ Addedcolor-support@^1.1.3
+ Addedkleur@^4.1.4
+ Addedanymatch@3.1.3(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchokidar@3.6.0(transitive)
+ Addedcolor-support@1.1.3(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedkleur@4.1.5(transitive)
+ Addedmkdirp@1.0.4(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedreaddirp@3.6.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedwhich@2.0.2(transitive)
- Removedcolors@^1.1.2
- Removeddebounce@^1.0.0
- Removedanymatch@1.3.2(transitive)
- Removedarr-diff@2.0.04.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-unique@0.2.10.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedasync-each@1.0.6(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbinary-extensions@1.13.1(transitive)
- Removedbindings@1.5.0(transitive)
- Removedbraces@1.8.52.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedchokidar@1.7.0(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcolors@1.4.0(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddebounce@1.2.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removedexpand-brackets@0.1.52.1.4(transitive)
- Removedexpand-range@1.8.2(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@0.3.22.0.4(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)
- Removedfilename-regex@2.0.1(transitive)
- Removedfill-range@2.2.44.0.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfor-own@0.1.5(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfsevents@1.2.13(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedglob-base@0.3.0(transitive)
- Removedglob-parent@2.0.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-binary-path@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-dotfile@1.0.3(transitive)
- Removedis-equal-shallow@0.1.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-extglob@1.0.0(transitive)
- Removedis-glob@2.0.1(transitive)
- Removedis-number@2.1.03.0.04.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-posix-bracket@0.1.1(transitive)
- Removedis-primitive@2.0.0(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmath-random@1.0.4(transitive)
- Removedmicromatch@2.3.113.1.10(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.0.0(transitive)
- Removednan@2.22.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removednormalize-path@2.1.1(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.omit@2.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedparse-glob@3.0.4(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedpreserve@0.2.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedrandomatic@3.1.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedreaddirp@2.2.1(transitive)
- Removedregex-cache@0.4.4(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedremove-trailing-separator@1.1.0(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwhich@1.3.1(transitive)
Updatedchokidar@^3.5.3
Updatedmkdirp@^1.0.4
Updatedwhich@^2.0.2