fis3-deploy-wantu
Advanced tools
Comparing version 0.2.0 to 0.2.1
64
index.js
"use strict"; | ||
var rocketz = require("rocketz"); | ||
var fs = require("fs"); | ||
var path = require("path"); | ||
var cacheDir = ".wantu-cache"; | ||
var cachePath = path.join(__dirname, cacheDir); | ||
var Wantu = require("wantu"); | ||
module.exports = function( options, modified, total, next ) { | ||
if ( !options ) { | ||
fis.log.error("Invalid RocketZ's setting!"); | ||
if ( !(options.accessKey && options.secretKey) ) { | ||
fis.log.error("ACCESS_KEY and SECRET_KEY are required!"); | ||
} | ||
else if ( !options.namespace ) { | ||
fis.log.error("Namespace is required!"); | ||
} | ||
options.assets = options.from; | ||
options.remote = options.to; | ||
if ( !fs.existsSync(cachePath) ) { | ||
fs.mkdirSync(cachePath); | ||
} | ||
rocketz.init(options); | ||
var wantu = new Wantu(options.accessKey, options.secretKey); | ||
if ( rocketz.preview() ) { | ||
rocketz.run(); | ||
} | ||
modified.forEach(function( file ) { | ||
var releasePath = file.getHashRelease(); | ||
var releaseFileName = path.basename(releasePath); | ||
var cacheFilePath = path.join(cachePath, releaseFileName); | ||
next(); | ||
if ( !fs.existsSync(cacheFilePath) ) { | ||
fs.writeFileSync(cacheFilePath, file.getContent()); | ||
} | ||
wantu.singleUpload({ | ||
namespace: options.namespace, | ||
expiration: -1 | ||
}, cacheFilePath, releasePath.replace("/" + releaseFileName, ""), "", "", function( err, res ) { | ||
if ( !err ) { | ||
if ( res.statusCode === 200 ) { | ||
var time = "[" + fis.log.now(true) + "]"; | ||
process.stdout.write( | ||
"\nWantu uploader - ".green.bold + | ||
time.grey + " " + | ||
file.subpath.replace(/^\//, "") + | ||
" >> ".yellow.bold + | ||
JSON.parse(res.data).url | ||
); | ||
fs.unlinkSync(cacheFilePath); | ||
next(); | ||
} | ||
else { | ||
console.log(res); | ||
fis.log.error("Something is wrong when uploading to Wantu!"); | ||
} | ||
} | ||
else { | ||
fis.log.error(err); | ||
} | ||
}); | ||
}); | ||
}; |
{ | ||
"name": "fis3-deploy-wantu", | ||
"version": "0.2.0", | ||
"description": "A RocketZ plug-in for FIS3", | ||
"version": "0.2.1", | ||
"description": "Upload assets to Wantu via FIS3", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
2503
52
1