voinznext 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.js +21 -2
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  module.exports = { downloadLatest };
3
3
 
4
4
  const { spawnSync } = require("child_process");
5
- const { createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync, renameSync } = require("fs");
5
+ const { createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync, renameSync, unlinkSync } = require("fs");
6
6
  const https = require("https");
7
7
  const { join } = require("path");
8
8
  const { platform, arch } = require("process");
@@ -54,9 +54,28 @@ function download(url, dest) {
54
54
  reject(new Error(`HTTP ${res.statusCode}`));
55
55
  return;
56
56
  }
57
+
58
+ const totalBytes = parseInt(res.headers['content-length'], 10);
59
+ let downloadedBytes = 0;
60
+ let lastPercent = -1;
61
+
62
+ res.on('data', (chunk) => {
63
+ downloadedBytes += chunk.length;
64
+ if (totalBytes) {
65
+ const percent = Math.floor((downloadedBytes / totalBytes) * 100);
66
+ if (percent !== lastPercent && percent % 10 === 0) {
67
+ process.stdout.write(`\r ● Downloading... ${percent}%`);
68
+ lastPercent = percent;
69
+ }
70
+ }
71
+ });
72
+
57
73
  const file = createWriteStream(dest);
58
74
  res.pipe(file);
59
- file.on("finish", () => file.close(resolve));
75
+ file.on("finish", () => {
76
+ if (totalBytes) process.stdout.write(`\r ✔ Download complete\n`);
77
+ file.close(resolve);
78
+ });
60
79
  file.on("error", reject);
61
80
  }).on("error", reject);
62
81
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "voinznext",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Interactive CLI tool for scaffolding Next.js projects with your preferred tech stack",
5
5
  "keywords": [
6
6
  "nextjs",