@adonisjs-ecommerce-core/create 1.0.0 → 1.0.1
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/dist/index.js +93 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,13 +9,52 @@ import fs from "fs-extra";
|
|
|
9
9
|
import path from "path";
|
|
10
10
|
import { execSync } from "child_process";
|
|
11
11
|
import validatePackageName from "validate-npm-package-name";
|
|
12
|
-
var TEMPLATE_REPO = "github:haliltoma/adonisjs-ecommerce-core/templates/default";
|
|
13
|
-
var VERSION = "1.0.
|
|
14
|
-
|
|
12
|
+
var TEMPLATE_REPO = "github:haliltoma/adonisjs-ecommerce-core/templates/default#main";
|
|
13
|
+
var VERSION = "1.0.1";
|
|
14
|
+
function printBanner() {
|
|
15
|
+
const lines = [
|
|
16
|
+
"",
|
|
17
|
+
" $$\\ $$\\ $$$$$$\\ ",
|
|
18
|
+
" $$ | $$ | $$ __$$\\ ",
|
|
19
|
+
" $$ | $$$$$$\\ $$$$$$$\\ $$$$$$\\ $$$$$$\\ $$ | $$\\ $$$$$$\\ $$$$$$\\ $$ / \\__|",
|
|
20
|
+
" $$ | \\____$$\\ $$ _____|$$ __$$\\ $$ __$$\\ $$ | $$ |$$ __$$\\ $$ __$$\\$$$$\\ ",
|
|
21
|
+
" $$ | $$$$$$$ |\\$$$$$$\\ $$$$$$$$ |$$ | \\__|$$$$$$ / $$ / $$ |$$ / $$ $$ _| ",
|
|
22
|
+
" $$ |$$ __$$ | \\____$$\\ $$ ____|$$ | $$ _$$< $$ | $$ |$$ | $$ $$ | ",
|
|
23
|
+
" $$ |\\$$$$$$$ |$$$$$$$ |\\$$$$$$$\\ $$ | $$ | \\$$\\ \\$$$$$$ |$$$$$$$ $$ | ",
|
|
24
|
+
" \\__| \\_______|\\_______/ \\_______|\\__| \\__| \\__| \\______/ $$ ____/ \\__| ",
|
|
25
|
+
" $$ | ",
|
|
26
|
+
" $$ | ",
|
|
27
|
+
" \\__| "
|
|
28
|
+
];
|
|
29
|
+
const gradientColors = [
|
|
30
|
+
"#5E35B1",
|
|
31
|
+
"#5C37B5",
|
|
32
|
+
"#5939B9",
|
|
33
|
+
"#573BBD",
|
|
34
|
+
"#543DC1",
|
|
35
|
+
"#5240C5",
|
|
36
|
+
"#4F42C9",
|
|
37
|
+
"#4D44CD",
|
|
38
|
+
"#4A46D1",
|
|
39
|
+
"#4748D5",
|
|
40
|
+
"#454AD9",
|
|
41
|
+
"#424CDD"
|
|
42
|
+
];
|
|
43
|
+
for (let i = 0; i < lines.length; i++) {
|
|
44
|
+
const color = gradientColors[i % gradientColors.length];
|
|
45
|
+
console.log(chalk.hex(color)(lines[i]));
|
|
46
|
+
}
|
|
15
47
|
console.log();
|
|
16
|
-
console.log(
|
|
17
|
-
|
|
48
|
+
console.log(
|
|
49
|
+
chalk.hex("#7C4DFF").bold(" AdonisJS E-Commerce") + chalk.gray(" | ") + chalk.hex("#B388FF")(`v${VERSION}`)
|
|
50
|
+
);
|
|
51
|
+
console.log(chalk.gray(" Modern e-commerce platform powered by AdonisJS 6 + React"));
|
|
18
52
|
console.log();
|
|
53
|
+
console.log(chalk.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
54
|
+
console.log();
|
|
55
|
+
}
|
|
56
|
+
async function main() {
|
|
57
|
+
printBanner();
|
|
19
58
|
program.name("create-adonisjs-ecommerce-core").description("Create a new AdonisJS E-Commerce application").version(VERSION).argument("[project-name]", "Name of the project").option("-t, --template <name>", "Template to use", "default").option("--npm", "Use npm as package manager").option("--yarn", "Use yarn as package manager").option("--pnpm", "Use pnpm as package manager").option("--no-git", "Skip git initialization").option("--no-install", "Skip dependency installation").option("--docker", "Initialize with Docker setup").action(async (projectName, options) => {
|
|
20
59
|
try {
|
|
21
60
|
const config = await getProjectConfig(projectName, options);
|
|
@@ -99,9 +138,20 @@ async function createProject(config) {
|
|
|
99
138
|
await fs.remove(targetDir);
|
|
100
139
|
}
|
|
101
140
|
console.log();
|
|
102
|
-
const spinner = ora(
|
|
141
|
+
const spinner = ora({
|
|
142
|
+
text: chalk.hex("#B388FF")("Scaffolding your store..."),
|
|
143
|
+
spinner: {
|
|
144
|
+
frames: [" >", " >>", " >>>", ">>>>", ">>>>", " >>>", " >>", " >"],
|
|
145
|
+
interval: 100
|
|
146
|
+
},
|
|
147
|
+
color: "magenta"
|
|
148
|
+
}).start();
|
|
103
149
|
try {
|
|
104
|
-
spinner.text = "Downloading template...";
|
|
150
|
+
spinner.text = chalk.hex("#B388FF")("Downloading template...");
|
|
151
|
+
spinner.spinner = {
|
|
152
|
+
frames: [" *", " **", " ***", "****", "****", " ***", " **", " *"],
|
|
153
|
+
interval: 100
|
|
154
|
+
};
|
|
105
155
|
const degit = (await import("degit")).default;
|
|
106
156
|
const emitter = degit(TEMPLATE_REPO, {
|
|
107
157
|
cache: false,
|
|
@@ -109,7 +159,11 @@ async function createProject(config) {
|
|
|
109
159
|
verbose: false
|
|
110
160
|
});
|
|
111
161
|
await emitter.clone(targetDir);
|
|
112
|
-
spinner.text = "Configuring project...";
|
|
162
|
+
spinner.text = chalk.hex("#B388FF")("Configuring project...");
|
|
163
|
+
spinner.spinner = {
|
|
164
|
+
frames: ["[ ]", "[= ]", "[== ]", "[=== ]", "[ ===]", "[ ==]", "[ =]", "[ ]"],
|
|
165
|
+
interval: 100
|
|
166
|
+
};
|
|
113
167
|
const packageJsonPath = path.join(targetDir, "package.json");
|
|
114
168
|
const packageJson = await fs.readJson(packageJsonPath);
|
|
115
169
|
packageJson.name = config.projectName;
|
|
@@ -155,9 +209,13 @@ async function createProject(config) {
|
|
|
155
209
|
pkgJson.scripts = scripts;
|
|
156
210
|
await fs.writeJson(packageJsonPath, pkgJson, { spaces: 2 });
|
|
157
211
|
}
|
|
158
|
-
spinner.succeed("Project created");
|
|
212
|
+
spinner.succeed(chalk.hex("#7C4DFF")("Project created"));
|
|
159
213
|
if (config.git) {
|
|
160
|
-
spinner.start(
|
|
214
|
+
spinner.start({
|
|
215
|
+
text: chalk.hex("#B388FF")("Initializing git..."),
|
|
216
|
+
spinner: "dots",
|
|
217
|
+
color: "magenta"
|
|
218
|
+
});
|
|
161
219
|
try {
|
|
162
220
|
execSync("git init", { cwd: targetDir, stdio: "ignore" });
|
|
163
221
|
execSync("git add -A", { cwd: targetDir, stdio: "ignore" });
|
|
@@ -165,41 +223,51 @@ async function createProject(config) {
|
|
|
165
223
|
cwd: targetDir,
|
|
166
224
|
stdio: "ignore"
|
|
167
225
|
});
|
|
168
|
-
spinner.succeed("Git initialized");
|
|
226
|
+
spinner.succeed(chalk.hex("#7C4DFF")("Git initialized"));
|
|
169
227
|
} catch {
|
|
170
|
-
spinner.warn("Git initialization failed");
|
|
228
|
+
spinner.warn(chalk.yellow("Git initialization failed"));
|
|
171
229
|
}
|
|
172
230
|
}
|
|
173
231
|
if (config.install) {
|
|
174
|
-
spinner.start(
|
|
232
|
+
spinner.start({
|
|
233
|
+
text: chalk.hex("#B388FF")("Installing dependencies... (this may take a moment)"),
|
|
234
|
+
spinner: {
|
|
235
|
+
frames: ["[> ]", "[=> ]", "[==> ]", "[ ==> ]", "[ ==> ]", "[ ==> ]", "[ ==> ]", "[ ==> ]", "[ ==> ]", "[ ==>]", "[ =>]", "[ >]"],
|
|
236
|
+
interval: 80
|
|
237
|
+
},
|
|
238
|
+
color: "magenta"
|
|
239
|
+
});
|
|
175
240
|
try {
|
|
176
241
|
const installCmd = getInstallCommand(config.packageManager);
|
|
177
242
|
execSync(installCmd, { cwd: targetDir, stdio: "ignore" });
|
|
178
|
-
spinner.succeed("Dependencies installed");
|
|
243
|
+
spinner.succeed(chalk.hex("#7C4DFF")("Dependencies installed"));
|
|
179
244
|
} catch {
|
|
180
|
-
spinner.warn("Dependency installation failed. Run install manually.");
|
|
245
|
+
spinner.warn(chalk.yellow("Dependency installation failed. Run install manually."));
|
|
181
246
|
}
|
|
182
247
|
}
|
|
183
248
|
console.log();
|
|
184
|
-
console.log(chalk.
|
|
249
|
+
console.log(chalk.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
250
|
+
console.log();
|
|
251
|
+
console.log(chalk.hex("#7C4DFF").bold(" Your store is ready!"));
|
|
185
252
|
console.log();
|
|
186
|
-
console.log("Next steps:");
|
|
253
|
+
console.log(chalk.white(" Next steps:"));
|
|
187
254
|
console.log();
|
|
188
|
-
console.log(chalk.
|
|
255
|
+
console.log(chalk.hex("#B388FF")(` $ cd ${config.projectName}`));
|
|
189
256
|
if (!config.install) {
|
|
190
|
-
console.log(chalk.
|
|
257
|
+
console.log(chalk.hex("#B388FF")(` $ ${config.packageManager} install`));
|
|
191
258
|
}
|
|
192
259
|
if (config.docker) {
|
|
193
260
|
console.log();
|
|
194
|
-
console.log(chalk.gray("
|
|
195
|
-
console.log(chalk.
|
|
196
|
-
console.log(chalk.
|
|
261
|
+
console.log(chalk.gray(" # Start with Docker (recommended):"));
|
|
262
|
+
console.log(chalk.hex("#B388FF")(" $ make docker-dev"));
|
|
263
|
+
console.log(chalk.hex("#B388FF")(" $ make docker-db-reset"));
|
|
197
264
|
console.log();
|
|
198
|
-
console.log(chalk.gray("
|
|
265
|
+
console.log(chalk.gray(" # Or without Docker:"));
|
|
199
266
|
}
|
|
200
|
-
console.log(chalk.
|
|
267
|
+
console.log(chalk.hex("#B388FF")(` $ ${config.packageManager === "npm" ? "npm run" : config.packageManager} dev`));
|
|
201
268
|
console.log();
|
|
202
|
-
console.log(chalk.gray("
|
|
269
|
+
console.log(chalk.gray(" Docs ") + chalk.hex("#7C4DFF").underline("https://github.com/haliltoma/adonisjs-ecommerce-core"));
|
|
270
|
+
console.log(chalk.gray(" Made with ") + chalk.hex("#E040FB")("<3") + chalk.gray(" by ") + chalk.hex("#7C4DFF").bold("laserkopf"));
|
|
203
271
|
console.log();
|
|
204
272
|
} catch (error) {
|
|
205
273
|
spinner.fail("Failed to create project");
|