create-mb-starter 1.2.0 → 1.3.0
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 +59 -33
- package/package.json +3 -2
- package/template/package-lock.json +86 -2
- package/template/package.json +1 -0
- package/template/src/pages/FelviszFormik.jsx +105 -0
package/index.js
CHANGED
|
@@ -4,52 +4,78 @@ const fs = require("fs");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const { execSync } = require("child_process");
|
|
6
6
|
const chalk = require("chalk");
|
|
7
|
+
const prompts = require("prompts");
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
9
|
+
(async () => {
|
|
10
|
+
// Ask for project name
|
|
11
|
+
const { projectName } = await prompts({
|
|
12
|
+
type: "text",
|
|
13
|
+
name: "projectName",
|
|
14
|
+
message: "Project name:",
|
|
15
|
+
initial: "my-app",
|
|
16
|
+
});
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
19
|
+
const templateDir = path.join(__dirname, "template");
|
|
20
|
+
|
|
21
|
+
// Ask which Felvisz version to use
|
|
22
|
+
const { formVariant } = await prompts({
|
|
23
|
+
type: "select",
|
|
24
|
+
name: "formVariant",
|
|
25
|
+
message: "Which Felvisz version do you want?",
|
|
26
|
+
choices: [
|
|
27
|
+
{ title: "Simple validation", value: "Felvisz.jsx" },
|
|
28
|
+
{ title: "Formik validation", value: "FelviszFormik.jsx" },
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Banner
|
|
33
|
+
console.log(
|
|
34
|
+
chalk.cyan(`
|
|
15
35
|
╔══════════════════════════════════════╗
|
|
16
36
|
║ 🚀 MB STARTER TEMPLATE ║
|
|
17
37
|
╚══════════════════════════════════════╝
|
|
18
38
|
`)
|
|
19
|
-
);
|
|
39
|
+
);
|
|
20
40
|
|
|
21
|
-
console.log(chalk.yellow("📦 Creating project:"), chalk.green(projectName));
|
|
22
|
-
console.log(chalk.gray("--------------------------------------------------"));
|
|
41
|
+
console.log(chalk.yellow("📦 Creating project:"), chalk.green(projectName));
|
|
42
|
+
console.log(chalk.gray("--------------------------------------------------"));
|
|
23
43
|
|
|
24
|
-
// Feature list
|
|
25
|
-
console.log(chalk.magenta("✨ This starter includes:"));
|
|
26
|
-
console.log(chalk.white(" ⚛ React (Vite powered)"));
|
|
27
|
-
console.log(chalk.white(" 🔀 React Router"));
|
|
28
|
-
console.log(chalk.white(" 📡 GET / POST / DELETE examples"));
|
|
29
|
-
console.log(chalk.white(" ✅ Input validation"));
|
|
30
|
-
console.log(chalk.white(" 🎨 Bootstrap styling"));
|
|
31
|
-
console.log(chalk.gray("--------------------------------------------------"));
|
|
44
|
+
// Feature list
|
|
45
|
+
console.log(chalk.magenta("✨ This starter includes:"));
|
|
46
|
+
console.log(chalk.white(" ⚛ React (Vite powered)"));
|
|
47
|
+
console.log(chalk.white(" 🔀 React Router"));
|
|
48
|
+
console.log(chalk.white(" 📡 GET / POST / DELETE examples"));
|
|
49
|
+
console.log(chalk.white(" ✅ Input validation"));
|
|
50
|
+
console.log(chalk.white(" 🎨 Bootstrap styling"));
|
|
51
|
+
console.log(chalk.gray("--------------------------------------------------"));
|
|
32
52
|
|
|
33
|
-
//
|
|
34
|
-
if (fs.existsSync(targetDir)) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
53
|
+
// Check if folder exists
|
|
54
|
+
if (fs.existsSync(targetDir)) {
|
|
55
|
+
console.log(chalk.red("❌ Folder already exists!"));
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
38
58
|
|
|
39
|
-
|
|
59
|
+
// Copy template
|
|
60
|
+
fs.cpSync(templateDir, targetDir, { recursive: true });
|
|
40
61
|
|
|
41
|
-
|
|
62
|
+
// Overwrite Felvisz.jsx with chosen variant
|
|
63
|
+
const srcFormFile = path.join(templateDir, "src", "pages", formVariant);
|
|
64
|
+
const destFormDir = path.join(targetDir, "src", "pages");
|
|
65
|
+
fs.copyFileSync(srcFormFile, path.join(destFormDir, "Felvisz.jsx"));
|
|
42
66
|
|
|
43
|
-
|
|
67
|
+
console.log(chalk.blue("\n📥 Installing dependencies...\n"));
|
|
68
|
+
execSync("npm install", { cwd: targetDir, stdio: "inherit" });
|
|
44
69
|
|
|
45
|
-
// Success message
|
|
46
|
-
console.log(
|
|
47
|
-
|
|
70
|
+
// Success message
|
|
71
|
+
console.log(
|
|
72
|
+
chalk.green(`
|
|
48
73
|
🎉 Project successfully created!
|
|
49
74
|
`)
|
|
50
|
-
);
|
|
75
|
+
);
|
|
51
76
|
|
|
52
|
-
console.log(chalk.cyan("👉 Next steps:"));
|
|
53
|
-
console.log(chalk.white(` cd ${projectName}`));
|
|
54
|
-
console.log(chalk.white(` npm run dev`));
|
|
55
|
-
console.log(chalk.gray("\nHappy coding! 💻🔥\n"));
|
|
77
|
+
console.log(chalk.cyan("👉 Next steps:"));
|
|
78
|
+
console.log(chalk.white(` cd ${projectName}`));
|
|
79
|
+
console.log(chalk.white(` npm run dev`));
|
|
80
|
+
console.log(chalk.gray("\nHappy coding! 💻🔥\n"));
|
|
81
|
+
})();
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"": {
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"bootstrap": "^5.3.8",
|
|
10
|
+
"formik": "^2.4.6",
|
|
10
11
|
"react": "^18.3.1",
|
|
11
12
|
"react-dom": "^18.3.1",
|
|
12
13
|
"react-router": "^7.13.0",
|
|
@@ -1285,6 +1286,18 @@
|
|
|
1285
1286
|
"dev": true,
|
|
1286
1287
|
"license": "MIT"
|
|
1287
1288
|
},
|
|
1289
|
+
"node_modules/@types/hoist-non-react-statics": {
|
|
1290
|
+
"version": "3.3.7",
|
|
1291
|
+
"resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.7.tgz",
|
|
1292
|
+
"integrity": "sha512-PQTyIulDkIDro8P+IHbKCsw7U2xxBYflVzW/FgWdCAePD9xGSidgA76/GeJ6lBKoblyhf9pBY763gbrN+1dI8g==",
|
|
1293
|
+
"license": "MIT",
|
|
1294
|
+
"dependencies": {
|
|
1295
|
+
"hoist-non-react-statics": "^3.3.0"
|
|
1296
|
+
},
|
|
1297
|
+
"peerDependencies": {
|
|
1298
|
+
"@types/react": "*"
|
|
1299
|
+
}
|
|
1300
|
+
},
|
|
1288
1301
|
"node_modules/@types/json-schema": {
|
|
1289
1302
|
"version": "7.0.15",
|
|
1290
1303
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
|
@@ -1296,14 +1309,12 @@
|
|
|
1296
1309
|
"version": "15.7.15",
|
|
1297
1310
|
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz",
|
|
1298
1311
|
"integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==",
|
|
1299
|
-
"dev": true,
|
|
1300
1312
|
"license": "MIT"
|
|
1301
1313
|
},
|
|
1302
1314
|
"node_modules/@types/react": {
|
|
1303
1315
|
"version": "18.3.28",
|
|
1304
1316
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.28.tgz",
|
|
1305
1317
|
"integrity": "sha512-z9VXpC7MWrhfWipitjNdgCauoMLRdIILQsAEV+ZesIzBq/oUlxk0m3ApZuMFCXdnS4U7KrI+l3WRUEGQ8K1QKw==",
|
|
1306
|
-
"dev": true,
|
|
1307
1318
|
"license": "MIT",
|
|
1308
1319
|
"dependencies": {
|
|
1309
1320
|
"@types/prop-types": "*",
|
|
@@ -1821,6 +1832,15 @@
|
|
|
1821
1832
|
"dev": true,
|
|
1822
1833
|
"license": "MIT"
|
|
1823
1834
|
},
|
|
1835
|
+
"node_modules/deepmerge": {
|
|
1836
|
+
"version": "2.2.1",
|
|
1837
|
+
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz",
|
|
1838
|
+
"integrity": "sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA==",
|
|
1839
|
+
"license": "MIT",
|
|
1840
|
+
"engines": {
|
|
1841
|
+
"node": ">=0.10.0"
|
|
1842
|
+
}
|
|
1843
|
+
},
|
|
1824
1844
|
"node_modules/define-data-property": {
|
|
1825
1845
|
"version": "1.1.4",
|
|
1826
1846
|
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
|
|
@@ -2443,6 +2463,37 @@
|
|
|
2443
2463
|
"url": "https://github.com/sponsors/ljharb"
|
|
2444
2464
|
}
|
|
2445
2465
|
},
|
|
2466
|
+
"node_modules/formik": {
|
|
2467
|
+
"version": "2.4.9",
|
|
2468
|
+
"resolved": "https://registry.npmjs.org/formik/-/formik-2.4.9.tgz",
|
|
2469
|
+
"integrity": "sha512-5nI94BMnlFDdQRBY4Sz39WkhxajZJ57Fzs8wVbtsQlm5ScKIR1QLYqv/ultBnobObtlUyxpxoLodpixrsf36Og==",
|
|
2470
|
+
"funding": [
|
|
2471
|
+
{
|
|
2472
|
+
"type": "individual",
|
|
2473
|
+
"url": "https://opencollective.com/formik"
|
|
2474
|
+
}
|
|
2475
|
+
],
|
|
2476
|
+
"license": "Apache-2.0",
|
|
2477
|
+
"dependencies": {
|
|
2478
|
+
"@types/hoist-non-react-statics": "^3.3.1",
|
|
2479
|
+
"deepmerge": "^2.1.1",
|
|
2480
|
+
"hoist-non-react-statics": "^3.3.0",
|
|
2481
|
+
"lodash": "^4.17.21",
|
|
2482
|
+
"lodash-es": "^4.17.21",
|
|
2483
|
+
"react-fast-compare": "^2.0.1",
|
|
2484
|
+
"tiny-warning": "^1.0.2",
|
|
2485
|
+
"tslib": "^2.0.0"
|
|
2486
|
+
},
|
|
2487
|
+
"peerDependencies": {
|
|
2488
|
+
"react": ">=16.8.0"
|
|
2489
|
+
}
|
|
2490
|
+
},
|
|
2491
|
+
"node_modules/formik/node_modules/react-fast-compare": {
|
|
2492
|
+
"version": "2.0.4",
|
|
2493
|
+
"resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-2.0.4.tgz",
|
|
2494
|
+
"integrity": "sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==",
|
|
2495
|
+
"license": "MIT"
|
|
2496
|
+
},
|
|
2446
2497
|
"node_modules/fsevents": {
|
|
2447
2498
|
"version": "2.3.3",
|
|
2448
2499
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
|
@@ -2716,6 +2767,15 @@
|
|
|
2716
2767
|
"node": ">= 0.4"
|
|
2717
2768
|
}
|
|
2718
2769
|
},
|
|
2770
|
+
"node_modules/hoist-non-react-statics": {
|
|
2771
|
+
"version": "3.3.2",
|
|
2772
|
+
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz",
|
|
2773
|
+
"integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==",
|
|
2774
|
+
"license": "BSD-3-Clause",
|
|
2775
|
+
"dependencies": {
|
|
2776
|
+
"react-is": "^16.7.0"
|
|
2777
|
+
}
|
|
2778
|
+
},
|
|
2719
2779
|
"node_modules/ignore": {
|
|
2720
2780
|
"version": "5.3.2",
|
|
2721
2781
|
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
|
@@ -3278,6 +3338,18 @@
|
|
|
3278
3338
|
"url": "https://github.com/sponsors/sindresorhus"
|
|
3279
3339
|
}
|
|
3280
3340
|
},
|
|
3341
|
+
"node_modules/lodash": {
|
|
3342
|
+
"version": "4.17.23",
|
|
3343
|
+
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
|
|
3344
|
+
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
|
|
3345
|
+
"license": "MIT"
|
|
3346
|
+
},
|
|
3347
|
+
"node_modules/lodash-es": {
|
|
3348
|
+
"version": "4.17.23",
|
|
3349
|
+
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.23.tgz",
|
|
3350
|
+
"integrity": "sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==",
|
|
3351
|
+
"license": "MIT"
|
|
3352
|
+
},
|
|
3281
3353
|
"node_modules/lodash.merge": {
|
|
3282
3354
|
"version": "4.6.2",
|
|
3283
3355
|
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
|
|
@@ -4297,6 +4369,12 @@
|
|
|
4297
4369
|
"url": "https://github.com/sponsors/ljharb"
|
|
4298
4370
|
}
|
|
4299
4371
|
},
|
|
4372
|
+
"node_modules/tiny-warning": {
|
|
4373
|
+
"version": "1.0.3",
|
|
4374
|
+
"resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz",
|
|
4375
|
+
"integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==",
|
|
4376
|
+
"license": "MIT"
|
|
4377
|
+
},
|
|
4300
4378
|
"node_modules/tinyglobby": {
|
|
4301
4379
|
"version": "0.2.15",
|
|
4302
4380
|
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz",
|
|
@@ -4314,6 +4392,12 @@
|
|
|
4314
4392
|
"url": "https://github.com/sponsors/SuperchupuDev"
|
|
4315
4393
|
}
|
|
4316
4394
|
},
|
|
4395
|
+
"node_modules/tslib": {
|
|
4396
|
+
"version": "2.8.1",
|
|
4397
|
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
|
4398
|
+
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
|
4399
|
+
"license": "0BSD"
|
|
4400
|
+
},
|
|
4317
4401
|
"node_modules/type-check": {
|
|
4318
4402
|
"version": "0.4.0",
|
|
4319
4403
|
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
package/template/package.json
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { useNavigate } from 'react-router'
|
|
2
|
+
import { Formik, Field, Form, ErrorMessage } from 'formik'
|
|
3
|
+
|
|
4
|
+
const FelviszFormik = ({ onAdd }) => {
|
|
5
|
+
const nav = useNavigate()
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<Formik
|
|
9
|
+
initialValues={{
|
|
10
|
+
modell: 'asdasdasd',
|
|
11
|
+
gyartoId: 1,
|
|
12
|
+
kategoriaId: 8,
|
|
13
|
+
motor: '8.0L W16 Quad-Turbo',
|
|
14
|
+
teljesitmeny: 1500,
|
|
15
|
+
ar: 2550000000,
|
|
16
|
+
gyartas_eve: '2019-03-15'
|
|
17
|
+
}}
|
|
18
|
+
validate={(values) => {
|
|
19
|
+
const errors = {}
|
|
20
|
+
if (!values.modell.trim()) errors.modell = 'A modell megadása kötelező.'
|
|
21
|
+
if (!values.gyartoId || values.gyartoId <= 0) errors.gyartoId = 'A gyártó ID pozitív szám kell legyen.'
|
|
22
|
+
if (!values.kategoriaId || values.kategoriaId <= 0) errors.kategoriaId = 'A kategória ID pozitív szám kell legyen.'
|
|
23
|
+
if (!values.motor.trim()) errors.motor = 'A motor megadása kötelező.'
|
|
24
|
+
if (!values.teljesitmeny || values.teljesitmeny <= 0) errors.teljesitmeny = 'A teljesítmény pozitív szám kell legyen.'
|
|
25
|
+
if (!values.ar || values.ar <= 0) errors.ar = 'Az ár pozitív szám kell legyen.'
|
|
26
|
+
if (!values.gyartas_eve) errors.gyartas_eve = 'A gyártás évének megadása kötelező.'
|
|
27
|
+
return errors
|
|
28
|
+
}}
|
|
29
|
+
onSubmit={async (values, { setStatus, setSubmitting }) => {
|
|
30
|
+
try {
|
|
31
|
+
const res = await fetch('http://localhost:3000/api/autok', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { 'Content-Type': 'application/json' },
|
|
34
|
+
body: JSON.stringify(values)
|
|
35
|
+
})
|
|
36
|
+
const dataRes = await res.json()
|
|
37
|
+
if (!res.ok) {
|
|
38
|
+
setStatus(dataRes.message || 'Hiba a felvitel során')
|
|
39
|
+
setSubmitting(false)
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
onAdd()
|
|
43
|
+
nav('/')
|
|
44
|
+
} catch (err) {
|
|
45
|
+
setStatus('Szerverhiba történt.')
|
|
46
|
+
setSubmitting(false)
|
|
47
|
+
}
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{({ isSubmitting, status }) => (
|
|
51
|
+
<Form>
|
|
52
|
+
{status && <p className="text-danger">{status}</p>}
|
|
53
|
+
|
|
54
|
+
<div className="mb-3">
|
|
55
|
+
<label htmlFor="modell" className="form-label">Modell</label>
|
|
56
|
+
<Field type="text" id="modell" name="modell" className="form-control" />
|
|
57
|
+
<ErrorMessage name="modell" component="div" className="text-danger" />
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div className="mb-3">
|
|
61
|
+
<label htmlFor="gyartoId" className="form-label">Gyártó Id</label>
|
|
62
|
+
<Field type="number" id="gyartoId" name="gyartoId" className="form-control" />
|
|
63
|
+
<ErrorMessage name="gyartoId" component="div" className="text-danger" />
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div className="mb-3">
|
|
67
|
+
<label htmlFor="kategoriaId" className="form-label">Kategória Id</label>
|
|
68
|
+
<Field type="number" id="kategoriaId" name="kategoriaId" className="form-control" />
|
|
69
|
+
<ErrorMessage name="kategoriaId" component="div" className="text-danger" />
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div className="mb-3">
|
|
73
|
+
<label htmlFor="motor" className="form-label">Motor</label>
|
|
74
|
+
<Field type="text" id="motor" name="motor" className="form-control" />
|
|
75
|
+
<ErrorMessage name="motor" component="div" className="text-danger" />
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div className="mb-3">
|
|
79
|
+
<label htmlFor="teljesitmeny" className="form-label">Teljesítmény</label>
|
|
80
|
+
<Field type="number" id="teljesitmeny" name="teljesitmeny" className="form-control" />
|
|
81
|
+
<ErrorMessage name="teljesitmeny" component="div" className="text-danger" />
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<div className="mb-3">
|
|
85
|
+
<label htmlFor="ar" className="form-label">Ár</label>
|
|
86
|
+
<Field type="number" id="ar" name="ar" className="form-control" />
|
|
87
|
+
<ErrorMessage name="ar" component="div" className="text-danger" />
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div className="mb-3">
|
|
91
|
+
<label htmlFor="gyartas_eve" className="form-label">Gyártás éve</label>
|
|
92
|
+
<Field type="date" id="gyartas_eve" name="gyartas_eve" className="form-control" />
|
|
93
|
+
<ErrorMessage name="gyartas_eve" component="div" className="text-danger" />
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<button type="submit" className="btn btn-primary" disabled={isSubmitting}>
|
|
97
|
+
{isSubmitting ? 'Küldés...' : 'Submit'}
|
|
98
|
+
</button>
|
|
99
|
+
</Form>
|
|
100
|
+
)}
|
|
101
|
+
</Formik>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default FelviszFormik
|