@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 +54 -57
- package/package.json +2 -2
- package/.vscode/settings.json +0 -3
package/index.js
CHANGED
|
@@ -22,81 +22,79 @@ async function showBanner() {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
function renderProgress(progress) {
|
|
26
|
-
const width =
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
49
|
+
env: { ...process.env }
|
|
47
50
|
});
|
|
48
51
|
|
|
49
|
-
//
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
|
74
|
+
// Smooth background progress
|
|
83
75
|
const interval = setInterval(() => {
|
|
84
|
-
if (!completed
|
|
85
|
-
progress
|
|
86
|
-
|
|
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
|
-
},
|
|
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: "
|
|
112
|
-
{ key: "
|
|
113
|
-
{ key: "
|
|
114
|
-
{ key: "
|
|
115
|
-
{ key: "
|
|
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.
|
|
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
|
+
}
|
package/.vscode/settings.json
DELETED