create-aziz-app 1.0.0 → 1.0.2
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/bin/create-aziz-app.js +45 -0
- package/package.json +11 -4
- package/template/app.html +55 -0
- package/template/app.js +83 -0
- package/{components → template/components}/Header.jsx +1 -1
- package/.vscode/settings.json +0 -2
- package/app.html +0 -110
- /package/{components → template/components}/Counter.jsx +0 -0
- /package/{components → template/components}/Footer.jsx +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
// The folder name comes from the command line argument
|
|
7
|
+
// e.g. npm create aziz-app my-app → projectName = "my-app"
|
|
8
|
+
const projectName = process.argv[2] || "my-aziz-app";
|
|
9
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
10
|
+
const templateDir = path.join(__dirname, "../template");
|
|
11
|
+
|
|
12
|
+
// Create the project folder
|
|
13
|
+
if (fs.existsSync(targetDir)) {
|
|
14
|
+
console.log(`❌ Folder "${projectName}" already exists.`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
19
|
+
|
|
20
|
+
// Copy all template files into the new project folder
|
|
21
|
+
copyDir(templateDir, targetDir);
|
|
22
|
+
|
|
23
|
+
console.log(`
|
|
24
|
+
✅ Project "${projectName}" created!
|
|
25
|
+
|
|
26
|
+
👉 Next steps:
|
|
27
|
+
cd ${projectName}
|
|
28
|
+
Open app.html with Live Server and start coding!
|
|
29
|
+
`);
|
|
30
|
+
|
|
31
|
+
// Helper: copy a folder recursively
|
|
32
|
+
function copyDir(src, dest) {
|
|
33
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
34
|
+
|
|
35
|
+
for (let file of fs.readdirSync(src)) {
|
|
36
|
+
const srcPath = path.join(src, file);
|
|
37
|
+
const destPath = path.join(dest, file);
|
|
38
|
+
|
|
39
|
+
if (fs.statSync(srcPath).isDirectory()) {
|
|
40
|
+
copyDir(srcPath, destPath);
|
|
41
|
+
} else {
|
|
42
|
+
fs.copyFileSync(srcPath, destPath);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-aziz-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "so close to react ~~ just joking",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"hrml",
|
|
6
|
+
"html",
|
|
8
7
|
"css",
|
|
9
|
-
"
|
|
8
|
+
"js",
|
|
9
|
+
"react like"
|
|
10
10
|
],
|
|
11
11
|
"license": "Aziz",
|
|
12
12
|
"author": "Syed Muhammad Aziz Ahmed",
|
|
13
13
|
"type": "commonjs",
|
|
14
|
+
"files": [
|
|
15
|
+
"bin",
|
|
16
|
+
"template"
|
|
17
|
+
],
|
|
18
|
+
"bin": {
|
|
19
|
+
"create-aziz-app": "bin/create-aziz-app.js"
|
|
20
|
+
},
|
|
14
21
|
"main": "app.js",
|
|
15
22
|
"scripts": {
|
|
16
23
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>My Aziz Js App</title>
|
|
7
|
+
|
|
8
|
+
<!-- Babel compiles JSX in the browser -->
|
|
9
|
+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
13
|
+
body {
|
|
14
|
+
font-family: Arial, sans-serif;
|
|
15
|
+
background-color: #f0f0f0;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
align-items: center;
|
|
19
|
+
min-height: 100vh;
|
|
20
|
+
}
|
|
21
|
+
.header {
|
|
22
|
+
width: 100%;
|
|
23
|
+
background-color: #282c34;
|
|
24
|
+
color: white;
|
|
25
|
+
padding: 20px;
|
|
26
|
+
text-align: center;
|
|
27
|
+
}
|
|
28
|
+
.main { margin-top: 60px; text-align: center; }
|
|
29
|
+
.counter-box {
|
|
30
|
+
background-color: white;
|
|
31
|
+
padding: 40px 60px;
|
|
32
|
+
border-radius: 12px;
|
|
33
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
34
|
+
}
|
|
35
|
+
.counter-box h2 { margin-bottom: 20px; color: #333; }
|
|
36
|
+
.count-display { font-size: 64px; font-weight: bold; color: #282c34; margin: 20px 0; }
|
|
37
|
+
.btn { padding: 12px 28px; margin: 0 8px; font-size: 24px; border: none; border-radius: 8px; cursor: pointer; transition: background-color 0.2s; }
|
|
38
|
+
.btn-plus { background-color: #61dafb; color: #282c34; }
|
|
39
|
+
.btn-minus { background-color: #ff6b6b; color: white; }
|
|
40
|
+
.btn-reset { background-color: #ccc; color: #333; font-size: 16px; padding: 12px 24px; margin-top: 20px; display: block; width: 100%; border-radius: 8px; border: none; cursor: pointer; }
|
|
41
|
+
.btn:hover { opacity: 0.85; }
|
|
42
|
+
.footer { margin-top: auto; padding: 20px; color: #888; font-size: 14px; }
|
|
43
|
+
</style>
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
<div id="root"></div>
|
|
48
|
+
|
|
49
|
+
<script type="text/babel" src="components/Header.jsx"></script>
|
|
50
|
+
<script type="text/babel" src="components/Counter.jsx"></script>
|
|
51
|
+
<script type="text/babel" src="components/Footer.jsx"></script>
|
|
52
|
+
<script type="text/babel" src="app.js"></script>
|
|
53
|
+
|
|
54
|
+
</body>
|
|
55
|
+
</html>
|
package/template/app.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** @jsx h */
|
|
2
|
+
|
|
3
|
+
// ==============================
|
|
4
|
+
// h() — our own createElement
|
|
5
|
+
// Babel compiles JSX like <div class="x"> into h("div", { class: "x" }, ...children)
|
|
6
|
+
// This function turns that into a real DOM element
|
|
7
|
+
// ==============================
|
|
8
|
+
function h(tag, props, ...children) {
|
|
9
|
+
if (typeof tag === "function") {
|
|
10
|
+
return tag(props, ...children);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const el = document.createElement(tag);
|
|
14
|
+
|
|
15
|
+
if (props) {
|
|
16
|
+
for (let key in props) {
|
|
17
|
+
if (key.startsWith("on")) {
|
|
18
|
+
const eventName = key.slice(2).toLowerCase();
|
|
19
|
+
el.addEventListener(eventName, props[key]);
|
|
20
|
+
} else if (key === "className") {
|
|
21
|
+
el.className = props[key];
|
|
22
|
+
} else {
|
|
23
|
+
el.setAttribute(key, props[key]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (let child of children) {
|
|
29
|
+
if (child === null || child === undefined) continue;
|
|
30
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
31
|
+
el.appendChild(document.createTextNode(child));
|
|
32
|
+
} else {
|
|
33
|
+
el.appendChild(child);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return el;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// ==============================
|
|
42
|
+
// STATE
|
|
43
|
+
// ==============================
|
|
44
|
+
let state = {
|
|
45
|
+
count: 0
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// ==============================
|
|
50
|
+
// RENDER
|
|
51
|
+
// ==============================
|
|
52
|
+
function render() {
|
|
53
|
+
const root = document.getElementById("root");
|
|
54
|
+
root.innerHTML = "";
|
|
55
|
+
root.appendChild(Header());
|
|
56
|
+
root.appendChild(Counter());
|
|
57
|
+
root.appendChild(Footer());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
// ==============================
|
|
62
|
+
// STATE UPDATER FUNCTIONS
|
|
63
|
+
// ==============================
|
|
64
|
+
function increment() {
|
|
65
|
+
state.count = state.count + 1;
|
|
66
|
+
render();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function decrement() {
|
|
70
|
+
state.count = state.count - 1;
|
|
71
|
+
render();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function reset() {
|
|
75
|
+
state.count = 0;
|
|
76
|
+
render();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
// ==============================
|
|
81
|
+
// FIRST RENDER
|
|
82
|
+
// ==============================
|
|
83
|
+
render();
|
package/.vscode/settings.json
DELETED
package/app.html
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>My Vanilla JS App</title>
|
|
7
|
-
|
|
8
|
-
<!-- Babel compiles our JSX in the browser -->
|
|
9
|
-
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
|
10
|
-
|
|
11
|
-
<style>
|
|
12
|
-
* {
|
|
13
|
-
margin: 0;
|
|
14
|
-
padding: 0;
|
|
15
|
-
box-sizing: border-box;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
body {
|
|
19
|
-
font-family: Arial, sans-serif;
|
|
20
|
-
background-color: #f0f0f0;
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
align-items: center;
|
|
24
|
-
min-height: 100vh;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.header {
|
|
28
|
-
width: 100%;
|
|
29
|
-
background-color: #282c34;
|
|
30
|
-
color: white;
|
|
31
|
-
padding: 20px;
|
|
32
|
-
text-align: center;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.main {
|
|
36
|
-
margin-top: 60px;
|
|
37
|
-
text-align: center;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.counter-box {
|
|
41
|
-
background-color: white;
|
|
42
|
-
padding: 40px 60px;
|
|
43
|
-
border-radius: 12px;
|
|
44
|
-
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.counter-box h2 {
|
|
48
|
-
margin-bottom: 20px;
|
|
49
|
-
color: #333;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.count-display {
|
|
53
|
-
font-size: 64px;
|
|
54
|
-
font-weight: bold;
|
|
55
|
-
color: #282c34;
|
|
56
|
-
margin: 20px 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.btn {
|
|
60
|
-
padding: 12px 28px;
|
|
61
|
-
margin: 0 8px;
|
|
62
|
-
font-size: 24px;
|
|
63
|
-
border: none;
|
|
64
|
-
border-radius: 8px;
|
|
65
|
-
cursor: pointer;
|
|
66
|
-
transition: background-color 0.2s;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.btn-plus { background-color: #61dafb; color: #282c34; }
|
|
70
|
-
.btn-minus { background-color: #ff6b6b; color: white; }
|
|
71
|
-
|
|
72
|
-
.btn-reset {
|
|
73
|
-
background-color: #ccc;
|
|
74
|
-
color: #333;
|
|
75
|
-
font-size: 16px;
|
|
76
|
-
padding: 12px 24px;
|
|
77
|
-
margin-top: 20px;
|
|
78
|
-
display: block;
|
|
79
|
-
width: 100%;
|
|
80
|
-
border-radius: 8px;
|
|
81
|
-
border: none;
|
|
82
|
-
cursor: pointer;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.btn:hover { opacity: 0.85; }
|
|
86
|
-
|
|
87
|
-
.footer {
|
|
88
|
-
margin-top: auto;
|
|
89
|
-
padding: 20px;
|
|
90
|
-
color: #888;
|
|
91
|
-
font-size: 14px;
|
|
92
|
-
}
|
|
93
|
-
</style>
|
|
94
|
-
</head>
|
|
95
|
-
<body>
|
|
96
|
-
|
|
97
|
-
<div id="root">
|
|
98
|
-
</div>
|
|
99
|
-
|
|
100
|
-
<!-- Load components first (Babel compiles each one) -->
|
|
101
|
-
|
|
102
|
-
<script type="text/babel" src="components/Header.jsx"></script>
|
|
103
|
-
<script type="text/babel" src="components/Counter.jsx"></script>
|
|
104
|
-
<script type="text/babel" src="components/Footer.jsx"></script>
|
|
105
|
-
|
|
106
|
-
<!-- Then load the main app -->
|
|
107
|
-
<script type="text/babel" src="app.js"></script>
|
|
108
|
-
|
|
109
|
-
</body>
|
|
110
|
-
</html>
|
|
File without changes
|
|
File without changes
|