maven-deploy
Advanced tools
Comparing version 1.2.1 to 1.3.0
# Changelog | ||
## Next release | ||
## Next major release | ||
* BREAKING CHANGE: Do not exit if `mvn` command fails. Pass error, stdout and stderr to callback instead. | ||
## 1.3.0 | ||
* Revert breaking change accidentally shipped in 1.2.1 | ||
* {version} in finalName for a snapshot should use the new snapshot-version | ||
## 1.2.1 | ||
@@ -7,0 +11,0 @@ * Strip undefined mvn arguments |
45
index.js
@@ -11,3 +11,3 @@ var fs = require('fs'); | ||
var pkg, validateConfig, validateRepos, validateRepo, userConfig; | ||
var validateConfig, validateRepos, validateRepo, userConfig; | ||
@@ -19,3 +19,4 @@ const DEFAULT_CONFIG = { | ||
type: 'war', | ||
fileEncoding: 'utf-8' | ||
fileEncoding: 'utf-8', | ||
version: '{version}' | ||
}; | ||
@@ -68,4 +69,4 @@ | ||
function archivePath () { | ||
var conf = getConfig(); | ||
function archivePath (isSnapshot) { | ||
var conf = getConfig(isSnapshot); | ||
return path.join(conf.buildDir, conf.finalName + '.' + conf.type); | ||
@@ -75,10 +76,11 @@ } | ||
function mvnArgs (repoId, isSnapshot) { | ||
var conf = getConfig(); | ||
var conf = getConfig(isSnapshot); | ||
var args = { | ||
packaging : conf.type, | ||
file : archivePath(), | ||
file : archivePath(isSnapshot), | ||
groupId : conf.groupId, | ||
artifactId : conf.artifactId, | ||
classifier : conf.classifier, | ||
version : pkg.version | ||
version : conf.version | ||
}; | ||
@@ -95,5 +97,2 @@ | ||
} | ||
if (isSnapshot) { | ||
args.version = semver.inc(args.version, 'patch') + '-SNAPSHOT'; | ||
} | ||
@@ -115,2 +114,3 @@ return Object.keys(args).filter(function (key) { | ||
} | ||
exit(); | ||
} | ||
@@ -131,6 +131,16 @@ } | ||
function getConfig () { | ||
function exit(){ | ||
process.exit(1); | ||
} | ||
function getConfig (isSnapshot) { | ||
var configTmpl = extend({}, DEFAULT_CONFIG); | ||
if (userConfig) { configTmpl = extend(configTmpl, userConfig); } | ||
pkg = readPackageJSON(configTmpl.fileEncoding); | ||
var pkg = readPackageJSON(configTmpl.fileEncoding); | ||
if (isSnapshot) { | ||
pkg.version = semver.inc(pkg.version, 'patch') + '-SNAPSHOT'; | ||
} | ||
return filterConfig(configTmpl, pkg); | ||
@@ -147,5 +157,6 @@ } | ||
package: function (done) { | ||
package: function (isSnapshot, done) { | ||
if (typeof isSnapshot == 'function') { done = isSnapshot; isSnapshot = false; } | ||
var archive = new JSZip(); | ||
var conf = getConfig(); | ||
var conf = getConfig(isSnapshot); | ||
@@ -169,3 +180,3 @@ walk.walkSync(conf.buildDir, function (base, file, stat) { | ||
var buffer = archive.generate({type:'nodebuffer', compression:'DEFLATE'}); | ||
var arPath = archivePath(); | ||
var arPath = archivePath(isSnapshot); | ||
console.log('archive path', arPath); | ||
@@ -178,3 +189,3 @@ fs.writeFileSync(arPath, buffer); | ||
install: function (done) { | ||
this.package(); | ||
this.package(true); | ||
mvn(['install:install-file'], null, true, done); | ||
@@ -191,3 +202,3 @@ }, | ||
conf.repositories.forEach(validateRepo); | ||
this.package(); | ||
this.package(isSnapshot); | ||
mvn(['deploy:deploy-file'], repoId, isSnapshot, done); | ||
@@ -194,0 +205,0 @@ } |
{ | ||
"name": "maven-deploy", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A simple Node.js module to create a war-/jar-package and install/deploy to a local/remote Maven repository", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
24
test.js
@@ -184,2 +184,14 @@ /* globals describe, it, beforeEach, afterEach */ | ||
}); | ||
it('should include -SNAPSHOT in the filename if finalName includes {version}', function () { | ||
var EXPECTED_FILENAME = TEST_PKG_JSON.name + '-' + semver.inc(TEST_PKG_JSON.version, 'patch') + | ||
'-SNAPSHOT.war'; | ||
var config = extend({}, TEST_CONFIG); | ||
config.finalName = '{name}-{version}'; | ||
maven.config(config); | ||
maven.install(); | ||
assertWarFileToEqual(EXPECTED_FILENAME); | ||
}); | ||
}); | ||
@@ -204,14 +216,2 @@ | ||
}); | ||
it('should call callback with err if something goes wrong', function () { | ||
maven.config(TEST_CONFIG); | ||
maven.deploy('dummy-repo', true, function (err) { | ||
assert.ok(err); | ||
assert.ok(err instanceof Error); | ||
assert.equal(err.message, 'something went wrong'); | ||
}); | ||
var execCallback = childProcessMock.exec.firstCall.args[1]; | ||
execCallback(new Error('something went wrong')); | ||
}); | ||
}); | ||
@@ -218,0 +218,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
20835
356
0