@bagisto-headless/create 1.0.2 → 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.
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
  }
@@ -108,18 +106,11 @@ async function promptEnvVariables(projectName) {
108
106
  });
109
107
 
110
108
  const questions = [
111
- { key: "NEXT_PUBLIC_API_URL", message: "Enter NEXT_PUBLIC_API_URL:" },
112
- { key: "NEXT_PUBLIC_SITE_NAME", message: "Enter NEXT_PUBLIC_SITE_NAME:", default: projectName },
113
- { key: "NEXTAUTH_URL", message: "Enter NEXTAUTH_URL:" },
114
- { key: "IMAGE_DOMAIN", message: "Enter IMAGE_DOMAIN:" },
115
- { key: "BAGISTO_STORE_DOMAIN", message: "Enter BAGISTO_STORE_DOMAIN:" },
116
- { key: "BAGISTO_SESSION", message: "Enter BAGISTO_SESSION:" },
117
- { key: "COMPANY_NAME", message: "Enter COMPANY_NAME:" },
118
- { key: "SITE_NAME", message: "Enter SITE_NAME:" },
119
- { key: "TWITTER_CREATOR", message: "Enter TWITTER_CREATOR:" },
120
- { key: "TWITTER_SITE", message: "Enter TWITTER_SITE:" },
121
- { key: "REVALIDATION_DURATION", message: "Enter REVALIDATION_DURATION (seconds):" },
122
- { key: "NEXTAUTH_SECRET", message: "Enter NEXTAUTH_SECRET:" },
109
+ { key: "NEXT_PUBLIC_BAGISTO_ENDPOINT", message: "Enter Your graphQL API URL:" },
110
+ { key: "NEXT_PUBLIC_APP_URL", message: "Enter Your app URL:" },
111
+ { key: "NEXT_PUBLIC_NEXT_AUTH_URL", message: "Enter Your auth URL:" },
112
+ { key: "NEXT_PUBLIC_NEXT_AUTH_SECRET", message: "Enter Your auth secret:" },
113
+ { key: "COMPANY_NAME", message: "Enter Your company name:", default: "Webkul Software (Registered in India)" },
123
114
  ];
124
115
 
125
116
  const answers = {};
@@ -180,6 +171,12 @@ async function main() {
180
171
  console.log(bagistoBlue.bold("📘 Explore more:"));
181
172
  console.log(chalk.white("👉 https://bagisto.com/en/headless-ecommerce/\n"));
182
173
 
174
+ console.log(bagistoBlue.bold("📘 Check Bagisto Headless Documentation:"));
175
+ console.log(chalk.white("👉 https://headless-doc.bagisto.com/\n"));
176
+
177
+ console.log(bagistoBlue.bold("📘 Check Bagisto API Documentation:"));
178
+ console.log(chalk.white("👉 https://api-docs.bagisto.com/\n"));
179
+
183
180
  console.log(bagistoBlue.bold("💻 GitHub:"));
184
181
  console.log(chalk.white("👉 https://github.com/bagisto/nextjs-commerce\n"));
185
182
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bagisto-headless/create",
3
- "version": "1.0.2",
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",
@@ -28,4 +28,4 @@
28
28
  "readline": "^1.3.0"
29
29
  },
30
30
  "devDependencies": {}
31
- }
31
+ }
@@ -1,3 +0,0 @@
1
- {
2
- "kiroAgent.configureMCP": "Disabled"
3
- }