Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit a860d8d

Browse files
fix(deps): Remove filesize and progress-stream
Remove filesize and progress-stream dependencies as they've been used only in a function that is never called. As the function implements interesting functionality, it is commented, not deleted. However, the dependencies are not used anywhere else, so they can be safely removed.
1 parent 883a0d2 commit a860d8d

File tree

4 files changed

+42
-81
lines changed

4 files changed

+42
-81
lines changed

definitions/filesize.d.ts

-14
This file was deleted.

definitions/progress-stream.d.ts

-22
This file was deleted.

helpers.ts

+42-43
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import { ReadStream } from "tty";
55
import { Configurations } from "./constants";
66
import { EventEmitter } from "events";
77
import * as crypto from "crypto";
8-
import progress = require("progress-stream");
9-
import filesize = require("filesize");
10-
import * as util from "util";
118

129
const Table = require("cli-table");
1310

@@ -36,46 +33,48 @@ export function regExpEscape(input: string): string {
3633
return input.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
3734
}
3835

39-
export function trackDownloadProgress(destinationStream: NodeJS.WritableStream, url: string): NodeJS.ReadableStream {
40-
// \r for carriage return doesn't work on windows in node for some reason so we have to use it's hex representation \x1B[0G
41-
let lastMessageSize = 0;
42-
const carriageReturn = "\x1B[0G";
43-
let timeElapsed = 0;
44-
45-
const isInteractiveTerminal = isInteractive();
46-
const progressStream = progress({ time: 1000 }, (progress: any) => {
47-
timeElapsed = progress.runtime;
48-
49-
if (timeElapsed >= 1) {
50-
if (isInteractiveTerminal) {
51-
this.$logger.write("%s%s", carriageReturn, Array(lastMessageSize + 1).join(" "));
52-
53-
const message = util.format("%sDownload progress ... %s | %s | %s/s",
54-
carriageReturn,
55-
Math.floor(progress.percentage) + "%",
56-
filesize(progress.transferred),
57-
filesize(progress.speed));
58-
59-
this.$logger.write(message);
60-
lastMessageSize = message.length;
61-
}
62-
}
63-
});
64-
65-
progressStream.on("finish", () => {
66-
if (timeElapsed >= 1) {
67-
const msg = `Download of ${url} completed.`;
68-
if (isInteractiveTerminal) {
69-
this.$logger.out("%s%s%s%s", carriageReturn, Array(lastMessageSize + 1).join(" "), carriageReturn, msg);
70-
} else {
71-
this.$logger.out(msg);
72-
}
73-
}
74-
});
75-
76-
progressStream.pipe(destinationStream);
77-
return progressStream;
78-
}
36+
// This function is a state of Art and that's why it has not been deleted.
37+
// However, its code uses some dependencies that are not used anywhere else, so the code is commented, as we decided to remove those dependencies.
38+
// export function trackDownloadProgress(destinationStream: NodeJS.WritableStream, url: string): NodeJS.ReadableStream {
39+
// // \r for carriage return doesn't work on windows in node for some reason so we have to use it's hex representation \x1B[0G
40+
// let lastMessageSize = 0;
41+
// const carriageReturn = "\x1B[0G";
42+
// let timeElapsed = 0;
43+
44+
// const isInteractiveTerminal = isInteractive();
45+
// const progressStream = progress({ time: 1000 }, (progress: any) => {
46+
// timeElapsed = progress.runtime;
47+
48+
// if (timeElapsed >= 1) {
49+
// if (isInteractiveTerminal) {
50+
// this.$logger.write("%s%s", carriageReturn, Array(lastMessageSize + 1).join(" "));
51+
52+
// const message = util.format("%sDownload progress ... %s | %s | %s/s",
53+
// carriageReturn,
54+
// Math.floor(progress.percentage) + "%",
55+
// filesize(progress.transferred),
56+
// filesize(progress.speed));
57+
58+
// this.$logger.write(message);
59+
// lastMessageSize = message.length;
60+
// }
61+
// }
62+
// });
63+
64+
// progressStream.on("finish", () => {
65+
// if (timeElapsed >= 1) {
66+
// const msg = `Download of ${url} completed.`;
67+
// if (isInteractiveTerminal) {
68+
// this.$logger.out("%s%s%s%s", carriageReturn, Array(lastMessageSize + 1).join(" "), carriageReturn, msg);
69+
// } else {
70+
// this.$logger.out(msg);
71+
// }
72+
// }
73+
// });
74+
75+
// progressStream.pipe(destinationStream);
76+
// return progressStream;
77+
// }
7978

8079
export function isAllowedFinalFile(item: string): RegExpMatchArray {
8180
return item.match(/.*\.aar/) ||

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"colors": "0.6.2",
3333
"cookie": "0.1.0",
3434
"esprima": "2.7.0",
35-
"filesize": "2.0.3",
3635
"gaze": "1.0.0",
3736
"iconv-lite": "0.4.3",
3837
"inquirer": "0.8.2",
@@ -51,7 +50,6 @@
5150
"osenv": "0.1.0",
5251
"parse5": "2.2.0",
5352
"plist": "1.1.0",
54-
"progress-stream": "0.5.0",
5553
"proxy-lib": "0.2.0",
5654
"pullstream": "https://github.com/icenium/node-pullstream/tarball/master",
5755
"qr-image": "3.2.0",

0 commit comments

Comments
 (0)