@bagisto-headless/create 1.0.3 → 1.0.4

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/index.js +43 -45
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -22,81 +22,79 @@ async function showBanner() {
22
22
  });
23
23
  }
24
24
 
25
- function renderProgress(progress) {
26
- const width = process.stdout.columns - 20;
27
- const barLength = Math.max(10, Math.floor(width / 3));
28
- const filled = Math.floor((progress / 100) * barLength);
29
- const empty = barLength - filled;
30
- const bar = "█".repeat(filled) + "░".repeat(empty);
25
+ function renderProgress(progress, status = "Installing") {
26
+ const width = 40;
27
+ const filledChar = "█";
28
+ const emptyChar = "░";
29
+
30
+ const filled = Math.floor((progress / 100) * width);
31
+ const empty = width - filled;
32
+
33
+ const bar = bagistoBlue(filledChar.repeat(filled)) + chalk.gray(emptyChar.repeat(empty));
34
+
31
35
  readline.cursorTo(process.stdout, 0);
32
- process.stdout.write(bagistoBlue(`[${bar}] ${progress.toFixed(0)}%`));
36
+ const percentage = chalk.bold(progress.toFixed(0).padStart(3) + "%");
37
+ process.stdout.write(` ${bagistoBlue(status.padEnd(12))} [${bar}] ${percentage} `);
33
38
  }
34
39
 
35
40
  async function installDependencies() {
36
41
  console.log("\n");
37
- console.log(bagistoBlue("Installing dependencies...\n"));
38
42
 
39
- const start = Date.now();
40
43
  let progress = 0;
41
44
  let completed = false;
45
+ let currentStatus = "Initializing";
42
46
 
43
- // Start npm install
44
- const child = execa("npm", ["install"], {
47
+ const child = execa("npm", ["install", "--legacy-peer-deps", "--no-audit", "--no-fund"], {
45
48
  stdio: "pipe",
46
- env: { ...process.env, NODE_ENV: "production" }
49
+ env: { ...process.env }
47
50
  });
48
51
 
49
- // Track progress based on npm output
50
- let packageCount = 0;
51
- let totalPackages = 0;
52
-
52
+ // Event based progress updates
53
53
  child.stderr.on("data", (chunk) => {
54
- const str = chunk.toString();
55
-
56
- // npm outputs progress to stderr
57
- if (str.includes("packages in")) {
58
- progress = 95;
59
- } else if (str.match(/\d+\/\d+/)) {
60
- // Extract current/total from patterns like "123/456"
61
- const match = str.match(/(\d+)\/(\d+)/);
62
- if (match) {
63
- packageCount = parseInt(match[1]);
64
- totalPackages = parseInt(match[2]);
65
- progress = Math.min(90, (packageCount / totalPackages) * 90);
66
- }
54
+ const str = chunk.toString().toLowerCase();
55
+ if (str.includes("resolving")) {
56
+ currentStatus = "Resolving";
57
+ progress = Math.max(progress, 15);
58
+ } else if (str.includes("extract")) {
59
+ currentStatus = "Extracting";
60
+ progress = Math.max(progress, 45);
61
+ } else if (str.includes("linking")) {
62
+ currentStatus = "Linking";
63
+ progress = Math.max(progress, 75);
67
64
  }
68
- renderProgress(progress);
65
+ renderProgress(progress, currentStatus);
69
66
  });
70
67
 
71
68
  child.stdout.on("data", (chunk) => {
72
69
  const str = chunk.toString();
73
-
74
- if (str.includes("added") || str.includes("packages")) {
75
- progress = 95;
76
- } else if (str.includes("up to date")) {
77
- progress = 95;
78
- }
79
- renderProgress(progress);
70
+ if (str.includes("packages")) progress = 95;
71
+ renderProgress(progress, currentStatus);
80
72
  });
81
73
 
82
- // Smooth animation while waiting
74
+ // Smooth background progress
83
75
  const interval = setInterval(() => {
84
- if (!completed && progress < 90) {
85
- progress = Math.min(progress + 0.5, 85);
86
- renderProgress(progress);
76
+ if (!completed) {
77
+ if (progress < 30) progress += 0.8;
78
+ else if (progress < 60) progress += 0.4;
79
+ else if (progress < 90) progress += 0.1;
80
+
81
+ renderProgress(progress, currentStatus);
87
82
  }
88
- }, 200);
83
+ }, 150);
89
84
 
90
85
  try {
91
86
  await child;
92
87
  completed = true;
93
88
  clearInterval(interval);
94
- renderProgress(100);
89
+ renderProgress(100, "Done");
90
+ console.log("\n");
91
+ renderProgress(100, "Success");
95
92
  console.log("\n");
96
- const elapsedSec = ((Date.now() - start) / 1000).toFixed(1);
97
- console.log(chalk.gray(`⏱ Completed in ${elapsedSec}s\n`));
98
93
  } catch (error) {
94
+ completed = true;
99
95
  clearInterval(interval);
96
+ renderProgress(progress, "Failed");
97
+ console.log("\n");
100
98
  throw error;
101
99
  }
102
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bagisto-headless/create",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Create a new Bagisto Headless Commerce project from the official Next.js template.",
5
5
  "keywords": [
6
6
  "bagisto",