Comparing version 1.0.5 to 1.0.6
@@ -0,1 +1,81 @@ | ||
var Terminal = (function () { | ||
function Terminal(stdout, stderr) { | ||
this.needSave = false; | ||
this.savedString = ""; | ||
this.stdout = stdout; | ||
this.stderr = stderr; | ||
} | ||
Terminal.prototype.saveCursor = function () { | ||
this.needSave = true; | ||
this.savedString = ""; | ||
}; | ||
Terminal.prototype.restoreCursorAndClear = function () { | ||
if (this.stdout.isTTY && this.savedString) { | ||
var lines = this.savedString.split("\n"); | ||
if (lines[lines.length - 1] == "") { | ||
lines.pop(); | ||
} | ||
var columns = this.stdout.columns; | ||
var lineCount = 0; | ||
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) { | ||
var line = lines_1[_i]; | ||
while (line.length > columns) { | ||
line = line.substr(columns); | ||
lineCount++; | ||
} | ||
lineCount++; | ||
} | ||
var readLine = require("readline"); | ||
readLine.moveCursor(this.stdout, 0, -lineCount); | ||
readLine.clearScreenDown(this.stdout); | ||
} | ||
this.needSave = false; | ||
this.savedString = ""; | ||
}; | ||
Terminal.formatString = function (format) { | ||
var objects = new Array(arguments.length); | ||
for (var index = 0; index < arguments.length; index++) { | ||
objects[index] = arguments[index]; | ||
} | ||
return objects.join(' '); | ||
}; | ||
Terminal.prototype.log = function (message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
var text = Terminal.formatString.apply(this, arguments); | ||
if (this.needSave) { | ||
this.savedString += text + "\n"; | ||
} | ||
this.stdout.write(text + "\n"); | ||
}; | ||
Terminal.prototype.assert = function (assertion, message) { | ||
var optionalParams = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
optionalParams[_i - 2] = arguments[_i]; | ||
} | ||
if (!assertion) { | ||
this.stderr.write(message + "\n"); | ||
} | ||
}; | ||
Terminal.prototype.warn = function (message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
var text = Terminal.formatString.apply(this, arguments); | ||
this.stderr.write(text + "\n"); | ||
}; | ||
Terminal.prototype.error = function (message) { | ||
var optionalParams = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
optionalParams[_i - 1] = arguments[_i]; | ||
} | ||
var text = Terminal.formatString.apply(this, arguments); | ||
this.stderr.write(text + "\n"); | ||
}; | ||
return Terminal; | ||
}()); | ||
var terminal = new Terminal(process.stdout, process.stderr); | ||
var Utils; | ||
@@ -150,3 +230,3 @@ (function (Utils) { | ||
catch (e) { | ||
console.log("The DEPS config file is not a JSON file: " + configFileName); | ||
terminal.log("The DEPS config file is not a JSON file: " + configFileName); | ||
process.exit(1); | ||
@@ -468,3 +548,2 @@ } | ||
var ProgressBar = require("progress"); | ||
var terminal = require('terminal-kit').terminal; | ||
function downloadFiles(list, platform, callback) { | ||
@@ -510,4 +589,4 @@ if (!list) { | ||
if (error) { | ||
console.log("downloading... " + item.url); | ||
console.log("Cannot download file : " + error.message); | ||
terminal.log("downloading... " + item.url); | ||
terminal.log("Cannot download file : " + error.message); | ||
process.exit(1); | ||
@@ -520,7 +599,6 @@ return; | ||
unzipFile(filePath, item.dir); | ||
terminal.restoreCursor(); | ||
terminal.eraseDisplayBelow(); | ||
terminal.restoreCursorAndClear(); | ||
} | ||
catch (e) { | ||
console.log("Cannot unzip file: " + filePath); | ||
terminal.log("Cannot unzip file: " + filePath); | ||
process.exit(1); | ||
@@ -542,3 +620,3 @@ } | ||
function unzipFile(filePath, dir) { | ||
console.log("unzipping... " + filePath); | ||
terminal.log("unzipping... " + filePath); | ||
var zip = new AdmZip(filePath); | ||
@@ -599,11 +677,10 @@ var entries = zip.getEntries(); | ||
terminal.saveCursor(); | ||
console.log("downloading... " + url); | ||
terminal.log("downloading... " + url); | ||
loadSingleFileWithTimeOut(url, filePath, onFinish, options); | ||
function onFinish(error) { | ||
terminal.restoreCursor(); | ||
terminal.eraseDisplayBelow(); | ||
terminal.restoreCursorAndClear(); | ||
if (error && error.message == "timeout" && retryTimes < 3) { | ||
retryTimes++; | ||
terminal.saveCursor(); | ||
console.log("download retry " + retryTimes + "... " + url); | ||
terminal.log("download retry " + retryTimes + "... " + url); | ||
loadSingleFileWithTimeOut(url, filePath, onFinish, options); | ||
@@ -622,3 +699,3 @@ } | ||
catch (e) { | ||
console.log("Cannot create directory: " + path.dirname(filePath)); | ||
terminal.log("Cannot create directory: " + path.dirname(filePath)); | ||
process.exit(1); | ||
@@ -628,2 +705,3 @@ } | ||
var outputError; | ||
var hasProgressBar = false; | ||
file.on("close", function () { | ||
@@ -643,4 +721,6 @@ callback && callback(outputError); | ||
width: 80, | ||
total: length | ||
total: length, | ||
clear: true | ||
}); | ||
hasProgressBar = true; | ||
response.on('data', function (chunk) { | ||
@@ -668,3 +748,2 @@ file.write(chunk); | ||
var childProcess = require('child_process'); | ||
var terminal = require('terminal-kit').terminal; | ||
function executeActions(list, platform, callback) { | ||
@@ -691,12 +770,11 @@ if (!list) { | ||
terminal.saveCursor(); | ||
console.log("executing... " + item.command); | ||
terminal.log("executing... " + item.command); | ||
childProcess.exec(item.command, { cwd: item.dir }, onFinish); | ||
function onFinish(error, stdout, stderr) { | ||
if (error) { | ||
console.error(stderr); | ||
console.log(stdout); | ||
terminal.error(stderr); | ||
terminal.log(stdout); | ||
process.exit(1); | ||
} | ||
terminal.restoreCursor(); | ||
terminal.eraseDisplayBelow(); | ||
terminal.restoreCursorAndClear(); | ||
doExecuteActions(list, callback); | ||
@@ -716,7 +794,7 @@ } | ||
var path = require("path"); | ||
var VERSION = "1.0.5"; | ||
var VERSION = "1.0.6"; | ||
function run(args) { | ||
var commandOptions = CommandLine.parse(args); | ||
if (commandOptions.errors.length > 0) { | ||
console.log(commandOptions.errors.join("\n") + "\n"); | ||
terminal.log(commandOptions.errors.join("\n") + "\n"); | ||
process.exit(1); | ||
@@ -742,3 +820,3 @@ } | ||
if (!fs.existsSync(configFileName)) { | ||
console.log("Cannot find a DEPS file at the specified directory: " + commandOptions.project + "\n"); | ||
terminal.log("Cannot find a DEPS file at the specified directory: " + commandOptions.project + "\n"); | ||
process.exit(1); | ||
@@ -758,5 +836,5 @@ } | ||
if (compareVersion(VERSION, config.version) < 0) { | ||
console.log("DEPS file requires version: " + config.version); | ||
console.log("The current depsync version: " + VERSION); | ||
console.log("Please update the depsync tool and then try again."); | ||
terminal.log("DEPS file requires version: " + config.version); | ||
terminal.log("The current depsync version: " + VERSION); | ||
terminal.log("Please update the depsync tool and then try again."); | ||
process.exit(1); | ||
@@ -773,3 +851,3 @@ } | ||
function printVersion() { | ||
console.log("Version " + VERSION + "\n"); | ||
terminal.log("Version " + VERSION + "\n"); | ||
} | ||
@@ -816,3 +894,3 @@ function compareVersion(versionA, versionB) { | ||
}); | ||
console.log(output); | ||
terminal.log(output); | ||
} | ||
@@ -819,0 +897,0 @@ function makePadding(paddingLength) { |
{ | ||
"name": "depsync", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"author": "Dom Chen", | ||
@@ -28,4 +28,3 @@ "homepage": "http://www.idom.me/", | ||
"follow-redirects": "latest", | ||
"progress": "latest", | ||
"terminal-kit": "latest" | ||
"progress": "latest" | ||
}, | ||
@@ -32,0 +31,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
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
37172
3
903
- Removedterminal-kit@latest
- Removed@cronvel/get-pixels@3.4.1(transitive)
- Removedchroma-js@2.6.0(transitive)
- Removedcwise-compiler@1.1.3(transitive)
- Removediota-array@1.0.0(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedjpeg-js@0.4.4(transitive)
- Removedlazyness@1.2.0(transitive)
- Removedndarray@1.0.19(transitive)
- Removedndarray-pack@1.2.1(transitive)
- Removednextgen-events@1.5.3(transitive)
- Removednode-bitmap@0.0.1(transitive)
- Removedomggif@1.0.10(transitive)
- Removedpngjs@6.0.0(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedseventh@0.9.2(transitive)
- Removedstring-kit@0.18.3(transitive)
- Removedterminal-kit@3.1.1(transitive)
- Removedtree-kit@0.8.7(transitive)
- Removeduniq@1.0.1(transitive)