maven-deploy
Advanced tools
Comparing version 0.0.2 to 0.0.3
48
index.js
var fs = require('fs'); | ||
var path = require('path'); | ||
var walk = require('fs-walk'); | ||
var JSZip = require('jszip'); | ||
var extend = require('util-extend'); | ||
@@ -9,2 +8,3 @@ var exec = require('child_process').exec; | ||
var semver = require('semver'); | ||
var archiver = require('archiver'); | ||
@@ -14,3 +14,4 @@ var config = { | ||
finalName: '{name}', | ||
type: 'war' | ||
type: 'war', | ||
fileEncoding: 'utf-8' | ||
}, | ||
@@ -22,3 +23,4 @@ validateConfig = defineOpts({ | ||
config.finalName + '"', | ||
type : '?|string - "jar" or "war". default "' + config.type + '".' | ||
type : '?|string - "jar" or "war". default "' + config.type + '".', | ||
fileEncoding : '?|string - valid file encoding. default "' + config.fileEncoding + '"' | ||
}), | ||
@@ -32,3 +34,3 @@ validateRepos = defineOpts({ | ||
}), | ||
pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8')); | ||
pkg = JSON.parse(fs.readFileSync('./package.json', config.fileEncoding)); | ||
@@ -47,3 +49,3 @@ function filterConfig () { | ||
function warPath () { | ||
function archivePath () { | ||
return path.join(config.buildDir, config.finalName + '.' + config.type); | ||
@@ -53,5 +55,6 @@ } | ||
function mvnArgs (repoId, isSnapshot) { | ||
var pkg = JSON.parse(fs.readFileSync('./package.json', config.fileEncoding)); | ||
var args = { | ||
packaging : config.type, | ||
file : warPath(), | ||
file : archivePath(), | ||
groupId : config.groupId, | ||
@@ -111,15 +114,26 @@ artifactId : pkg.name, | ||
package: function (done) { | ||
var war = new JSZip(); | ||
walk.walkSync(config.buildDir, function (base, file, stat) { | ||
if (stat.isDirectory() || file.indexOf(config.finalName) >= 0) { | ||
return; | ||
} | ||
var filePath = path.join(base, file); | ||
var data = fs.readFileSync(filePath, {encoding: 'utf-8'}); | ||
war.file(path.relative(config.buildDir, filePath), data); | ||
}); | ||
var output = fs.createWriteStream(archivePath()); | ||
var buffer = war.generate({type:"nodebuffer", compression:'DEFLATE'}); | ||
fs.writeFileSync(warPath(), buffer); | ||
var archive; | ||
switch(config.type) { | ||
case 'war': | ||
case 'jar': | ||
archive = archiver('zip'); | ||
break; | ||
case 'tar.gz': | ||
archive = archiver('tar', { gzip: true }); | ||
break; | ||
default: | ||
archive = archiver(config.type); | ||
}; | ||
archive.pipe(output); | ||
archive.bulk([ | ||
{ expand: true, cwd: config.buildDir, src: ['**', '!' + config.finalName + '.' + config.type] } | ||
]); | ||
archive.finalize(); | ||
if (done) { done(); } | ||
@@ -126,0 +140,0 @@ }, |
{ | ||
"name": "maven-deploy", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A simple Node.js module to create a war-/jar-package and install/deploy to a local/remote Maven repository", | ||
@@ -28,5 +28,5 @@ "main": "index.js", | ||
"define-options": "0.1.x", | ||
"jszip": "2.x", | ||
"semver": "2.x" | ||
"semver": "2.x", | ||
"archiver": "0.10.x" | ||
} | ||
} |
@@ -18,2 +18,3 @@ # maven-deploy | ||
"type" : "war", // type of package. "war" or "jar" supported. | ||
"fileEncoding" : "utf-8" // file encoding when traversing the file system, default is UTF-8 | ||
"repositories" : [ // array of repositories, each with id and url to a Maven repository. | ||
@@ -20,0 +21,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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
8463
129
73
2
+ Addedarchiver@0.10.x
+ Addedarchiver@0.10.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbl@0.9.5(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcrc32-stream@0.2.0(transitive)
+ Addeddebug@1.0.5(transitive)
+ Addeddeflate-crc32-stream@0.1.2(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedfile-utils@0.2.2(transitive)
+ Addedfindup-sync@0.2.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@4.3.54.5.37.2.3(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedisbinaryfile@2.0.4(transitive)
+ Addedlazystream@0.1.0(transitive)
+ Addedlodash@2.4.2(transitive)
+ Addedminimatch@2.0.103.1.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedtar-stream@0.4.7(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxtend@4.0.2(transitive)
+ Addedzip-stream@0.3.7(transitive)
- Removedjszip@2.x
- Removedjszip@2.7.0(transitive)
- Removedpako@1.0.11(transitive)