create-next-java 1.0.2 → 1.0.3
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/index.js +60 -26
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -32,6 +32,7 @@ const dirs = [
|
|
|
32
32
|
'app',
|
|
33
33
|
'app/api/health',
|
|
34
34
|
'components',
|
|
35
|
+
'public',
|
|
35
36
|
'middleware',
|
|
36
37
|
'models',
|
|
37
38
|
'database/migrations',
|
|
@@ -43,7 +44,39 @@ const dirs = [
|
|
|
43
44
|
|
|
44
45
|
dirs.forEach(d => fs.mkdirSync(path.join(targetDir, d), { recursive: true }));
|
|
45
46
|
|
|
46
|
-
// 1. app/
|
|
47
|
+
// 1. app/globals.css
|
|
48
|
+
fs.writeFileSync(path.join(targetDir, 'app', 'globals.css'), `
|
|
49
|
+
:root {
|
|
50
|
+
--background: #ffffff;
|
|
51
|
+
--foreground: #171717;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (prefers-color-scheme: dark) {
|
|
55
|
+
:root {
|
|
56
|
+
--background: #0a0a0a;
|
|
57
|
+
--foreground: #ededed;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
body {
|
|
62
|
+
color: var(--foreground);
|
|
63
|
+
background: var(--background);
|
|
64
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
65
|
+
margin: 0;
|
|
66
|
+
padding: 0;
|
|
67
|
+
display: flex;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
align-items: center;
|
|
70
|
+
min-height: 100vh;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main {
|
|
74
|
+
text-align: center;
|
|
75
|
+
padding: 4rem;
|
|
76
|
+
}
|
|
77
|
+
`);
|
|
78
|
+
|
|
79
|
+
// 2. app/layout.java
|
|
47
80
|
fs.writeFileSync(path.join(targetDir, 'app', 'layout.java'), `package app;
|
|
48
81
|
|
|
49
82
|
import com.nextjava.ui.Layout;
|
|
@@ -55,46 +88,47 @@ public class layout implements Layout {
|
|
|
55
88
|
public UI render(UI children) {
|
|
56
89
|
return Html(
|
|
57
90
|
Head(
|
|
58
|
-
Title("Next.java App"),
|
|
59
|
-
Meta("viewport", "width=device-width, initial-scale=1")
|
|
91
|
+
Title("Create Next.java App"),
|
|
92
|
+
Meta("viewport", "width=device-width, initial-scale=1"),
|
|
93
|
+
LinkTag("stylesheet", "/globals.css")
|
|
60
94
|
),
|
|
61
95
|
Body(
|
|
62
|
-
|
|
63
|
-
Heading(2, "Next.java").style("color: #0070f3;"),
|
|
64
|
-
Div(Link("/", "Home"))
|
|
65
|
-
),
|
|
66
|
-
Main(children),
|
|
67
|
-
Footer(Paragraph("Powered by Next.java v1.0"))
|
|
96
|
+
Main(children)
|
|
68
97
|
)
|
|
69
98
|
);
|
|
70
99
|
}
|
|
71
100
|
}
|
|
72
101
|
`);
|
|
73
102
|
|
|
74
|
-
//
|
|
103
|
+
// 3. app/page.java & app/page.jsx (In-Process React SSR)
|
|
75
104
|
fs.writeFileSync(path.join(targetDir, 'app', 'page.java'), `package app;
|
|
105
|
+
import com.nextjava.ui.PageData;
|
|
76
106
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
public class page implements Page {
|
|
82
|
-
@Override
|
|
83
|
-
public UI render() {
|
|
84
|
-
return Column(
|
|
85
|
-
Heading(1, "Welcome to Next.java 🚀"),
|
|
86
|
-
Paragraph("The Full-Stack Java Framework with in-process React SSR and Virtual Threads.")
|
|
87
|
-
);
|
|
107
|
+
public class page implements PageData {
|
|
108
|
+
public Object loadData() {
|
|
109
|
+
return java.util.Map.of("framework", "Next.java");
|
|
88
110
|
}
|
|
89
111
|
}
|
|
90
112
|
`);
|
|
91
113
|
|
|
92
|
-
fs.writeFileSync(path.join(targetDir, 'app', 'page.jsx'), `export default function HomePage({
|
|
114
|
+
fs.writeFileSync(path.join(targetDir, 'app', 'page.jsx'), `export default function HomePage({ framework }) {
|
|
93
115
|
return (
|
|
94
|
-
<
|
|
95
|
-
<h1
|
|
96
|
-
|
|
97
|
-
|
|
116
|
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '2rem' }}>
|
|
117
|
+
<h1 style={{ fontSize: '3rem', margin: 0 }}>
|
|
118
|
+
Welcome to <span style={{ color: '#0070f3' }}>{framework}</span>
|
|
119
|
+
</h1>
|
|
120
|
+
<p style={{ fontSize: '1.2rem', color: 'gray' }}>
|
|
121
|
+
Get started by editing <code>app/page.jsx</code> or <code>app/page.java</code>
|
|
122
|
+
</p>
|
|
123
|
+
<div style={{ display: 'flex', gap: '1rem', marginTop: '2rem' }}>
|
|
124
|
+
<a href="/api/health" style={{ padding: '0.8rem 1.5rem', background: '#0070f3', color: 'white', textDecoration: 'none', borderRadius: '8px' }}>
|
|
125
|
+
View API Health
|
|
126
|
+
</a>
|
|
127
|
+
<a href="https://github.com/WAH-ISHAN/next.java" target="_blank" style={{ padding: '0.8rem 1.5rem', background: '#333', color: 'white', textDecoration: 'none', borderRadius: '8px' }}>
|
|
128
|
+
Read Documentation
|
|
129
|
+
</a>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
98
132
|
);
|
|
99
133
|
}
|
|
100
134
|
`);
|