gemstack-cli 0.2.5 → 0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -25
- data/README.md +6 -17
- data/exe/gemstack +8 -1
- metadata +6 -159
- data/lib/gemstack/cli/add_generator.rb +0 -239
- data/lib/gemstack/cli/app_generator.rb +0 -142
- data/lib/gemstack/cli/commands/db.rb +0 -135
- data/lib/gemstack/cli/commands/jobs.rb +0 -96
- data/lib/gemstack/cli/controller_generator.rb +0 -73
- data/lib/gemstack/cli/deploy_generator.rb +0 -102
- data/lib/gemstack/cli/doctor.rb +0 -308
- data/lib/gemstack/cli/generator.rb +0 -144
- data/lib/gemstack/cli/job_generator.rb +0 -48
- data/lib/gemstack/cli/migration_generator.rb +0 -52
- data/lib/gemstack/cli/policy_generator.rb +0 -35
- data/lib/gemstack/cli/project.rb +0 -53
- data/lib/gemstack/cli/resource_generator.rb +0 -170
- data/lib/gemstack/cli/resource_spec.rb +0 -95
- data/lib/gemstack/cli.rb +0 -304
- data/templates/app/Gemfile.tt +0 -44
- data/templates/app/README.md.tt +0 -29
- data/templates/app/app/controllers/application_controller.rb +0 -6
- data/templates/app/app/jobs/application_job.rb +0 -9
- data/templates/app/app/mailers/application_mailer.rb +0 -8
- data/templates/app/app/mailers/templates/dot_keep +0 -0
- data/templates/app/app/models/application_model.rb +0 -19
- data/templates/app/app/serializers/application_serializer.rb +0 -6
- data/templates/app/bin/gemstack +0 -7
- data/templates/app/config/app.rb.tt +0 -54
- data/templates/app/config/database.yml.tt +0 -61
- data/templates/app/config/environments/development.rb.tt +0 -35
- data/templates/app/config/environments/production.rb.tt +0 -40
- data/templates/app/config/environments/test.rb.tt +0 -21
- data/templates/app/config/puma.rb +0 -21
- data/templates/app/config/routes.rb +0 -10
- data/templates/app/config.ru +0 -6
- data/templates/app/db/migrations/dot_keep +0 -0
- data/templates/app/db/seeds.rb +0 -5
- data/templates/app/dot_env.example.tt +0 -19
- data/templates/app/dot_gitignore +0 -16
- data/templates/app/dot_node-version.tt +0 -1
- data/templates/app/dot_nvmrc.tt +0 -1
- data/templates/app/dot_ruby-version.tt +0 -1
- data/templates/app/dot_tool-versions.tt +0 -4
- data/templates/app/test/health_test.rb +0 -18
- data/templates/app/test/test_helper.rb.tt +0 -25
- data/templates/auth/app/controllers/api_tokens_controller.rb +0 -35
- data/templates/auth/app/controllers/email_verifications_controller.rb +0 -31
- data/templates/auth/app/controllers/password_resets_controller.rb +0 -40
- data/templates/auth/app/controllers/registrations_controller.rb +0 -19
- data/templates/auth/app/controllers/sessions_controller.rb +0 -29
- data/templates/auth/app/mailers/auth_mailer.rb +0 -20
- data/templates/auth/app/mailers/templates/auth_mailer/email_verification.html.erb +0 -2
- data/templates/auth/app/mailers/templates/auth_mailer/email_verification.text.erb +0 -2
- data/templates/auth/app/mailers/templates/auth_mailer/password_reset.html.erb +0 -3
- data/templates/auth/app/mailers/templates/auth_mailer/password_reset.text.erb +0 -6
- data/templates/auth/app/models/auth_token.rb +0 -15
- data/templates/auth/app/models/user.rb +0 -12
- data/templates/auth/app/policies/application_policy.rb +0 -6
- data/templates/auth/app/serializers/api_token_serializer.rb +0 -6
- data/templates/auth/app/serializers/new_api_token_serializer.rb +0 -9
- data/templates/auth/app/serializers/user_serializer.rb +0 -6
- data/templates/auth/db/migrations/%timestamp%_create_auth_tables.rb +0 -41
- data/templates/auth/frontend/app/account/page.tsx +0 -116
- data/templates/auth/frontend/app/forgot-password/page.tsx +0 -48
- data/templates/auth/frontend/app/login/page.tsx +0 -26
- data/templates/auth/frontend/app/reset-password/page.tsx +0 -11
- data/templates/auth/frontend/app/signup/page.tsx +0 -27
- data/templates/auth/frontend/app/verify-email/page.tsx +0 -11
- data/templates/auth/frontend/components/auth/CredentialsForm.tsx +0 -58
- data/templates/auth/frontend/components/auth/ResetPasswordForm.tsx +0 -43
- data/templates/auth/frontend/components/auth/VerifyEmail.tsx +0 -28
- data/templates/auth/frontend/lib/auth.ts +0 -113
- data/templates/auth/test/controllers/auth_test.rb +0 -108
- data/templates/controller/app/controllers/%file_name%_controller.rb.tt +0 -10
- data/templates/controller/test/controllers/%file_name%_controller_test.rb.tt +0 -14
- data/templates/deploy/Caddyfile.tt +0 -19
- data/templates/deploy/Dockerfile.tt +0 -63
- data/templates/deploy/Procfile.tt +0 -6
- data/templates/deploy/compose.yaml.tt +0 -129
- data/templates/deploy/dot_dockerignore +0 -14
- data/templates/frontend/app/globals.css +0 -171
- data/templates/frontend/app/layout.tsx.tt +0 -19
- data/templates/frontend/app/page.module.css +0 -315
- data/templates/frontend/app/page.tsx.tt +0 -183
- data/templates/frontend/app/providers.tsx +0 -24
- data/templates/frontend/lib/gemstack/client.ts +0 -125
- data/templates/frontend/next-env.d.ts +0 -5
- data/templates/frontend/next.config.ts +0 -17
- data/templates/frontend/package.json.tt +0 -23
- data/templates/frontend/tsconfig.json +0 -21
- data/templates/job/app/jobs/%file_name%.rb.tt +0 -15
- data/templates/job/test/jobs/%file_name%_test.rb.tt +0 -15
- data/templates/migration/db/migrations/%timestamp%_%file_name%.rb.tt +0 -17
- data/templates/policy/app/policies/%file_name%_policy.rb.tt +0 -21
- data/templates/policy/test/policies/%file_name%_policy_test.rb.tt +0 -9
- data/templates/realtime/config/channels.rb +0 -14
- data/templates/realtime/frontend/lib/gemstack/realtime.ts +0 -120
- data/templates/resource/controller/app/controllers/%plural%_controller.rb.tt +0 -51
- data/templates/resource/controller/test/controllers/%plural%_controller_test.rb.tt +0 -74
- data/templates/resource/frontend/frontend/app/%url_segment%/[id]/edit/page.tsx.tt +0 -45
- data/templates/resource/frontend/frontend/app/%url_segment%/[id]/page.tsx.tt +0 -49
- data/templates/resource/frontend/frontend/app/%url_segment%/new/page.tsx.tt +0 -27
- data/templates/resource/frontend/frontend/app/%url_segment%/page.tsx.tt +0 -51
- data/templates/resource/frontend/frontend/components/%url_segment%/%class_name%Card.tsx.tt +0 -15
- data/templates/resource/frontend/frontend/components/%url_segment%/%class_name%Form.tsx.tt +0 -98
- data/templates/resource/frontend/frontend/components/%url_segment%/%class_name%Table.tsx.tt +0 -36
- data/templates/resource/frontend/frontend/lib/format.ts +0 -12
- data/templates/resource/frontend/frontend/lib/queries/%url_segment%.ts.tt +0 -64
- data/templates/resource/migration/db/migrations/%timestamp%_create_%table%.rb.tt +0 -18
- data/templates/resource/model/app/models/%file_name%.rb.tt +0 -15
- data/templates/resource/model/test/models/%file_name%_test.rb.tt +0 -29
- data/templates/resource/serializer/app/serializers/%file_name%_serializer.rb.tt +0 -7
- data/templates/storage/app/controllers/uploads_controller.rb.tt +0 -33
- data/templates/storage/app/serializers/upload_serializer.rb +0 -11
- data/templates/storage/frontend/lib/upload.ts +0 -52
- data/templates/storage/test/controllers/uploads_test.rb.tt +0 -30
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
/* The GemStack welcome page (app/page.tsx). Delete both files when you replace it. */
|
|
2
|
-
|
|
3
|
-
.shell {
|
|
4
|
-
--ruby: #e11d48;
|
|
5
|
-
--violet: #7c3aed;
|
|
6
|
-
--ink: #16181d;
|
|
7
|
-
--muted: #5b6170;
|
|
8
|
-
--surface: rgba(255, 255, 255, 0.72);
|
|
9
|
-
--border: rgba(22, 24, 29, 0.09);
|
|
10
|
-
--code: #f3f4f7;
|
|
11
|
-
--ok: #16a34a;
|
|
12
|
-
--pending: #d99a1e;
|
|
13
|
-
--error: #dc2626;
|
|
14
|
-
|
|
15
|
-
min-height: 100vh;
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
color: var(--ink);
|
|
19
|
-
background:
|
|
20
|
-
radial-gradient(60rem 30rem at 10% -10%, rgba(225, 29, 72, 0.12), transparent 60%),
|
|
21
|
-
radial-gradient(50rem 30rem at 100% 0%, rgba(124, 58, 237, 0.12), transparent 60%),
|
|
22
|
-
#fbfbfd;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@media (prefers-color-scheme: dark) {
|
|
26
|
-
.shell {
|
|
27
|
-
--ink: #eceef4;
|
|
28
|
-
--muted: #9aa0ad;
|
|
29
|
-
--surface: rgba(24, 27, 36, 0.72);
|
|
30
|
-
--border: rgba(255, 255, 255, 0.08);
|
|
31
|
-
--code: rgba(255, 255, 255, 0.06);
|
|
32
|
-
--ok: #4ade80;
|
|
33
|
-
--pending: #fbbf24;
|
|
34
|
-
--error: #f87171;
|
|
35
|
-
|
|
36
|
-
background:
|
|
37
|
-
radial-gradient(60rem 30rem at 10% -10%, rgba(225, 29, 72, 0.22), transparent 60%),
|
|
38
|
-
radial-gradient(50rem 30rem at 100% 0%, rgba(124, 58, 237, 0.22), transparent 60%),
|
|
39
|
-
#0c0d12;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.main {
|
|
44
|
-
flex: 1;
|
|
45
|
-
width: 100%;
|
|
46
|
-
max-width: 68rem;
|
|
47
|
-
margin: 0 auto;
|
|
48
|
-
padding: clamp(3rem, 8vw, 6rem) 1.25rem 3rem;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/* Hero */
|
|
52
|
-
|
|
53
|
-
.hero {
|
|
54
|
-
text-align: center;
|
|
55
|
-
margin-bottom: clamp(2.5rem, 6vw, 4rem);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.logo {
|
|
59
|
-
width: 5rem;
|
|
60
|
-
height: 5rem;
|
|
61
|
-
filter: drop-shadow(0 12px 24px rgba(225, 29, 72, 0.35));
|
|
62
|
-
animation: float 6s ease-in-out infinite;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@keyframes float {
|
|
66
|
-
50% {
|
|
67
|
-
transform: translateY(-6px) rotate(-2deg);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@media (prefers-reduced-motion: reduce) {
|
|
72
|
-
.logo {
|
|
73
|
-
animation: none;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.eyebrow {
|
|
78
|
-
margin: 1rem 0 0.5rem;
|
|
79
|
-
font-size: 0.8rem;
|
|
80
|
-
font-weight: 700;
|
|
81
|
-
letter-spacing: 0.18em;
|
|
82
|
-
text-transform: uppercase;
|
|
83
|
-
color: var(--muted);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.title {
|
|
87
|
-
margin: 0;
|
|
88
|
-
font-size: clamp(2.2rem, 6vw, 3.6rem);
|
|
89
|
-
line-height: 1.1;
|
|
90
|
-
letter-spacing: -0.03em;
|
|
91
|
-
font-weight: 800;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.accent {
|
|
95
|
-
background: linear-gradient(120deg, #ff5f8f, var(--ruby) 45%, var(--violet));
|
|
96
|
-
-webkit-background-clip: text;
|
|
97
|
-
background-clip: text;
|
|
98
|
-
color: transparent;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.lead {
|
|
102
|
-
max-width: 38rem;
|
|
103
|
-
margin: 1.1rem auto 0;
|
|
104
|
-
font-size: clamp(1.02rem, 2.2vw, 1.2rem);
|
|
105
|
-
color: var(--muted);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.lead strong {
|
|
109
|
-
color: var(--ink);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/* Live checks */
|
|
113
|
-
|
|
114
|
-
.checks {
|
|
115
|
-
display: flex;
|
|
116
|
-
flex-wrap: wrap;
|
|
117
|
-
justify-content: center;
|
|
118
|
-
gap: 0.6rem;
|
|
119
|
-
margin-top: 2rem;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.check {
|
|
123
|
-
display: inline-flex;
|
|
124
|
-
align-items: center;
|
|
125
|
-
gap: 0.55rem;
|
|
126
|
-
padding: 0.5rem 0.95rem;
|
|
127
|
-
border: 1px solid var(--border);
|
|
128
|
-
border-radius: 999px;
|
|
129
|
-
background: var(--surface);
|
|
130
|
-
backdrop-filter: blur(8px);
|
|
131
|
-
font-size: 0.92rem;
|
|
132
|
-
overflow-wrap: anywhere;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.check code {
|
|
136
|
-
font-size: 0.85em;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.dot {
|
|
140
|
-
width: 0.55rem;
|
|
141
|
-
height: 0.55rem;
|
|
142
|
-
flex: none;
|
|
143
|
-
border-radius: 50%;
|
|
144
|
-
background: currentColor;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.ok .dot {
|
|
148
|
-
background: var(--ok);
|
|
149
|
-
box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.pending .dot {
|
|
153
|
-
background: var(--pending);
|
|
154
|
-
animation: pulse 1.2s ease-in-out infinite;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.error .dot {
|
|
158
|
-
background: var(--error);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
@keyframes pulse {
|
|
162
|
-
50% {
|
|
163
|
-
opacity: 0.35;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/* Cards */
|
|
168
|
-
|
|
169
|
-
.grid {
|
|
170
|
-
display: grid;
|
|
171
|
-
grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
|
|
172
|
-
gap: 1rem;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.card {
|
|
176
|
-
position: relative;
|
|
177
|
-
display: flex;
|
|
178
|
-
flex-direction: column;
|
|
179
|
-
gap: 0.6rem;
|
|
180
|
-
padding: 1.4rem;
|
|
181
|
-
border: 1px solid var(--border);
|
|
182
|
-
border-radius: 16px;
|
|
183
|
-
background: var(--surface);
|
|
184
|
-
backdrop-filter: blur(8px);
|
|
185
|
-
transition:
|
|
186
|
-
transform 0.2s ease,
|
|
187
|
-
border-color 0.2s ease,
|
|
188
|
-
box-shadow 0.2s ease;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.card:hover {
|
|
192
|
-
transform: translateY(-2px);
|
|
193
|
-
border-color: color-mix(in srgb, var(--ruby) 35%, var(--border));
|
|
194
|
-
box-shadow: 0 16px 40px -24px rgba(225, 29, 72, 0.45);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.step {
|
|
198
|
-
display: grid;
|
|
199
|
-
place-items: center;
|
|
200
|
-
width: 1.9rem;
|
|
201
|
-
height: 1.9rem;
|
|
202
|
-
border-radius: 10px;
|
|
203
|
-
background: linear-gradient(135deg, var(--ruby), var(--violet));
|
|
204
|
-
color: #fff;
|
|
205
|
-
font-size: 0.85rem;
|
|
206
|
-
font-weight: 700;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.cardTitle {
|
|
210
|
-
margin: 0.3rem 0 0;
|
|
211
|
-
font-size: 1.08rem;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.cardText {
|
|
215
|
-
flex: 1;
|
|
216
|
-
margin: 0;
|
|
217
|
-
color: var(--muted);
|
|
218
|
-
font-size: 0.93rem;
|
|
219
|
-
line-height: 1.5;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.command {
|
|
223
|
-
display: flex;
|
|
224
|
-
align-items: flex-start;
|
|
225
|
-
gap: 0.5rem;
|
|
226
|
-
padding: 0.55rem 0.6rem 0.55rem 0.8rem;
|
|
227
|
-
border-radius: 10px;
|
|
228
|
-
background: var(--code);
|
|
229
|
-
font-size: 0.82rem;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.command code {
|
|
233
|
-
flex: 1;
|
|
234
|
-
min-width: 0;
|
|
235
|
-
padding: 0.15rem 0 0;
|
|
236
|
-
background: none;
|
|
237
|
-
line-height: 1.5;
|
|
238
|
-
overflow-wrap: anywhere; /* long commands wrap instead of being cut off */
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.prompt {
|
|
242
|
-
color: var(--ruby);
|
|
243
|
-
user-select: none;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.copy {
|
|
247
|
-
flex: none;
|
|
248
|
-
padding: 0.25rem 0.6rem;
|
|
249
|
-
border: 1px solid var(--border);
|
|
250
|
-
border-radius: 7px;
|
|
251
|
-
background: transparent;
|
|
252
|
-
color: var(--ink);
|
|
253
|
-
font: inherit;
|
|
254
|
-
font-size: 0.75rem;
|
|
255
|
-
cursor: pointer;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.copy:hover,
|
|
259
|
-
.copy:focus-visible {
|
|
260
|
-
border-color: var(--ruby);
|
|
261
|
-
color: var(--ruby);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.link {
|
|
265
|
-
align-self: flex-start;
|
|
266
|
-
color: var(--ruby);
|
|
267
|
-
font-weight: 600;
|
|
268
|
-
text-decoration: none;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.link:hover,
|
|
272
|
-
.link:focus-visible {
|
|
273
|
-
text-decoration: underline;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.edit {
|
|
277
|
-
margin: 2.5rem 0 0;
|
|
278
|
-
text-align: center;
|
|
279
|
-
color: var(--muted);
|
|
280
|
-
font-size: 0.92rem;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/* Footer */
|
|
284
|
-
|
|
285
|
-
.footer {
|
|
286
|
-
display: flex;
|
|
287
|
-
flex-wrap: wrap;
|
|
288
|
-
justify-content: space-between;
|
|
289
|
-
gap: 0.5rem 1.5rem;
|
|
290
|
-
width: 100%;
|
|
291
|
-
max-width: 68rem;
|
|
292
|
-
margin: 0 auto;
|
|
293
|
-
padding: 1.5rem 1.25rem 2rem;
|
|
294
|
-
border-top: 1px solid var(--border);
|
|
295
|
-
color: var(--muted);
|
|
296
|
-
font-size: 0.85rem;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
.footer a {
|
|
300
|
-
color: var(--ink);
|
|
301
|
-
font-weight: 600;
|
|
302
|
-
text-decoration: none;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.footer a:hover,
|
|
306
|
-
.footer a:focus-visible {
|
|
307
|
-
color: var(--ruby);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
@media (max-width: 40rem) {
|
|
311
|
-
.footer {
|
|
312
|
-
justify-content: center;
|
|
313
|
-
text-align: center;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useQuery } from "@tanstack/react-query";
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
import { api, API_PATH } from "@/lib/gemstack/client";
|
|
6
|
-
import styles from "./page.module.css";
|
|
7
|
-
|
|
8
|
-
// The GemStack welcome page: shows that Next.js renders and that the browser
|
|
9
|
-
// reaches the Ruby API through the same origin. Replace it with your app —
|
|
10
|
-
// this file and app/page.module.css are yours to delete.
|
|
11
|
-
|
|
12
|
-
const DOCS = "https://github.com/gemstack-rb/gemstack/tree/main/docs";
|
|
13
|
-
|
|
14
|
-
export default function Welcome() {
|
|
15
|
-
const health = useQuery({
|
|
16
|
-
queryKey: ["gemstack", "health"],
|
|
17
|
-
queryFn: async () => {
|
|
18
|
-
const started = performance.now();
|
|
19
|
-
const body = await api.get<{ status: string }>("/health");
|
|
20
|
-
return { ...body, ms: Math.round(performance.now() - started) };
|
|
21
|
-
},
|
|
22
|
-
retry: 1,
|
|
23
|
-
});
|
|
24
|
-
const apiState = health.isPending ? "pending" : health.isError ? "error" : "ok";
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<div className={styles.shell}>
|
|
28
|
-
<main className={styles.main}>
|
|
29
|
-
<header className={styles.hero}>
|
|
30
|
-
<GemLogo className={styles.logo} />
|
|
31
|
-
<p className={styles.eyebrow}>GemStack</p>
|
|
32
|
-
<h1 className={styles.title}>
|
|
33
|
-
Yay! You're on <span className={styles.accent}>GemStack</span>.
|
|
34
|
-
</h1>
|
|
35
|
-
<p className={styles.lead}>
|
|
36
|
-
<strong><%= module_name %></strong> is running: a Next.js frontend and a Ruby API, served from one origin.
|
|
37
|
-
</p>
|
|
38
|
-
|
|
39
|
-
<div className={styles.checks} role="status" aria-live="polite">
|
|
40
|
-
<span className={`${styles.check} ${styles.ok}`}>
|
|
41
|
-
<span className={styles.dot} aria-hidden="true" /> Next.js rendering
|
|
42
|
-
</span>
|
|
43
|
-
<span className={`${styles.check} ${styles[apiState]}`}>
|
|
44
|
-
<span className={styles.dot} aria-hidden="true" />
|
|
45
|
-
{apiState === "pending" && "Connecting to the Ruby API…"}
|
|
46
|
-
{apiState === "ok" && (
|
|
47
|
-
<>
|
|
48
|
-
Ruby API connected · <code>GET {API_PATH}/health</code> in {health.data?.ms} ms
|
|
49
|
-
</>
|
|
50
|
-
)}
|
|
51
|
-
{apiState === "error" && <>Ruby API unreachable: {health.error?.message}</>}
|
|
52
|
-
</span>
|
|
53
|
-
</div>
|
|
54
|
-
</header>
|
|
55
|
-
|
|
56
|
-
<section className={styles.grid} aria-label="Next steps">
|
|
57
|
-
<Card
|
|
58
|
-
step="1"
|
|
59
|
-
title="Generate a resource"
|
|
60
|
-
text="Migration, model, API, typed TypeScript client and Next.js pages — in one command."
|
|
61
|
-
command="gemstack g resource Product name:string"
|
|
62
|
-
/>
|
|
63
|
-
<Card
|
|
64
|
-
step="2"
|
|
65
|
-
title="Explore your API"
|
|
66
|
-
text="Every endpoint with its types, and a form to try requests from the browser."
|
|
67
|
-
href={`${API_PATH}/docs`}
|
|
68
|
-
linkLabel={`Open ${API_PATH}/docs`}
|
|
69
|
-
/>
|
|
70
|
-
<Card
|
|
71
|
-
step="3"
|
|
72
|
-
title="Check your setup"
|
|
73
|
-
text="Ruby, Node.js, the database, migrations and the TypeScript contract — with the fix for anything off."
|
|
74
|
-
command="gemstack doctor"
|
|
75
|
-
/>
|
|
76
|
-
<Card
|
|
77
|
-
step="4"
|
|
78
|
-
title="Read the guides"
|
|
79
|
-
text="Models, controllers, jobs, realtime, authentication, storage and deployment."
|
|
80
|
-
href={DOCS}
|
|
81
|
-
linkLabel="Open the guides"
|
|
82
|
-
external
|
|
83
|
-
/>
|
|
84
|
-
</section>
|
|
85
|
-
|
|
86
|
-
<p className={styles.edit}>
|
|
87
|
-
Edit <code>frontend/app/page.tsx</code> to replace this page · API code lives in <code>app/</code>
|
|
88
|
-
</p>
|
|
89
|
-
</main>
|
|
90
|
-
|
|
91
|
-
<footer className={styles.footer}>
|
|
92
|
-
<span>
|
|
93
|
-
GemStack <%= version %> · Ruby <%= ruby_version %> · Next.js
|
|
94
|
-
</span>
|
|
95
|
-
<span>
|
|
96
|
-
Open source by{" "}
|
|
97
|
-
<a href="https://www.adwaretech.com" target="_blank" rel="noreferrer">
|
|
98
|
-
Adware Technologies
|
|
99
|
-
</a>
|
|
100
|
-
</span>
|
|
101
|
-
</footer>
|
|
102
|
-
</div>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function Card(props: {
|
|
107
|
-
step: string;
|
|
108
|
-
title: string;
|
|
109
|
-
text: string;
|
|
110
|
-
command?: string;
|
|
111
|
-
href?: string;
|
|
112
|
-
linkLabel?: string;
|
|
113
|
-
external?: boolean;
|
|
114
|
-
}) {
|
|
115
|
-
return (
|
|
116
|
-
<article className={styles.card}>
|
|
117
|
-
<span className={styles.step} aria-hidden="true">
|
|
118
|
-
{props.step}
|
|
119
|
-
</span>
|
|
120
|
-
<h2 className={styles.cardTitle}>{props.title}</h2>
|
|
121
|
-
<p className={styles.cardText}>{props.text}</p>
|
|
122
|
-
{props.command && <Command text={props.command} />}
|
|
123
|
-
{props.href && (
|
|
124
|
-
<a
|
|
125
|
-
className={styles.link}
|
|
126
|
-
href={props.href}
|
|
127
|
-
{...(props.external ? { target: "_blank", rel: "noreferrer" } : {})}
|
|
128
|
-
>
|
|
129
|
-
{props.linkLabel} <span aria-hidden="true">→</span>
|
|
130
|
-
</a>
|
|
131
|
-
)}
|
|
132
|
-
</article>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function Command({ text }: { text: string }) {
|
|
137
|
-
const [copied, setCopied] = useState(false);
|
|
138
|
-
async function copy() {
|
|
139
|
-
try {
|
|
140
|
-
await navigator.clipboard.writeText(text);
|
|
141
|
-
setCopied(true);
|
|
142
|
-
setTimeout(() => setCopied(false), 1500);
|
|
143
|
-
} catch {
|
|
144
|
-
// Clipboard unavailable (e.g. not a secure context): the command stays selectable.
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return (
|
|
148
|
-
<div className={styles.command}>
|
|
149
|
-
<code>
|
|
150
|
-
<span className={styles.prompt} aria-hidden="true">
|
|
151
|
-
$
|
|
152
|
-
</span>{" "}
|
|
153
|
-
{text}
|
|
154
|
-
</code>
|
|
155
|
-
<button type="button" className={styles.copy} onClick={copy} aria-label={`Copy: ${text}`}>
|
|
156
|
-
{copied ? "Copied" : "Copy"}
|
|
157
|
-
</button>
|
|
158
|
-
</div>
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function GemLogo({ className }: { className?: string }) {
|
|
163
|
-
return (
|
|
164
|
-
<svg className={className} viewBox="0 0 64 64" role="img" aria-label="GemStack">
|
|
165
|
-
<defs>
|
|
166
|
-
<linearGradient id="gemstack-gem" x1="0" y1="0" x2="1" y2="1">
|
|
167
|
-
<stop offset="0" stopColor="#ff5f8f" />
|
|
168
|
-
<stop offset="0.55" stopColor="#e11d48" />
|
|
169
|
-
<stop offset="1" stopColor="#7c3aed" />
|
|
170
|
-
</linearGradient>
|
|
171
|
-
</defs>
|
|
172
|
-
<path d="M18 8h28l12 15-26 34L6 23z" fill="url(#gemstack-gem)" />
|
|
173
|
-
<path
|
|
174
|
-
d="M6 23h52M18 8l7 15 7-15 7 15 7-15M25 23l7 34 7-34"
|
|
175
|
-
fill="none"
|
|
176
|
-
stroke="rgba(255,255,255,0.55)"
|
|
177
|
-
strokeWidth="1.4"
|
|
178
|
-
strokeLinejoin="round"
|
|
179
|
-
/>
|
|
180
|
-
<path d="M18 8h28l-7 15H25z" fill="rgba(255,255,255,0.18)" />
|
|
181
|
-
</svg>
|
|
182
|
-
);
|
|
183
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
-
import { useState, type ReactNode } from "react";
|
|
5
|
-
import { ApiError } from "@/lib/gemstack/client";
|
|
6
|
-
|
|
7
|
-
// Server state lives in TanStack Query; local UI state is plain React state;
|
|
8
|
-
// URL state uses Next.js search params. No global store is needed by default.
|
|
9
|
-
export function Providers({ children }: { children: ReactNode }) {
|
|
10
|
-
const [queryClient] = useState(
|
|
11
|
-
() =>
|
|
12
|
-
new QueryClient({
|
|
13
|
-
defaultOptions: {
|
|
14
|
-
queries: {
|
|
15
|
-
staleTime: 30_000,
|
|
16
|
-
// Don't retry requests the API rejected (4xx); retry transient failures twice.
|
|
17
|
-
retry: (failureCount, error) => !(error instanceof ApiError && error.isClientError) && failureCount < 2,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
}),
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
|
|
24
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GemStack API client runtime.
|
|
3
|
-
*
|
|
4
|
-
* This file belongs to your application (it is not a hidden dependency):
|
|
5
|
-
* add auth headers, interceptors or logging here as needed.
|
|
6
|
-
*
|
|
7
|
-
* Where requests go:
|
|
8
|
-
* - Browser: relative URLs ("/api/..."), i.e. the same origin — no CORS, no config.
|
|
9
|
-
* - Server Components / Route Handlers: GEMSTACK_API_URL (injected by `gemstack dev`,
|
|
10
|
-
* set by you in production) so the Next.js server calls Ruby directly.
|
|
11
|
-
* - API on another domain: set NEXT_PUBLIC_GEMSTACK_API_URL.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export const API_PATH = process.env.NEXT_PUBLIC_GEMSTACK_API_PATH ?? "/api";
|
|
15
|
-
|
|
16
|
-
/** The JSON error envelope every GemStack API error uses. */
|
|
17
|
-
export interface ApiErrorBody {
|
|
18
|
-
error: { code: string; message: string; request_id?: string };
|
|
19
|
-
/** Field-level validation messages, e.g. { name: ["is required"] }. */
|
|
20
|
-
errors?: Record<string, string[]>;
|
|
21
|
-
/** Development only (config.http.show_exceptions): the server-side exception. */
|
|
22
|
-
exception?: { class: string; message: string; backtrace: string[] };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class ApiError extends Error {
|
|
26
|
-
readonly status: number;
|
|
27
|
-
readonly code: string;
|
|
28
|
-
readonly requestId?: string;
|
|
29
|
-
readonly errors: Record<string, string[]>;
|
|
30
|
-
|
|
31
|
-
constructor(status: number, body: ApiErrorBody | null, fallbackMessage: string) {
|
|
32
|
-
super(body?.error?.message ?? fallbackMessage);
|
|
33
|
-
this.name = "ApiError";
|
|
34
|
-
this.status = status;
|
|
35
|
-
this.code = body?.error?.code ?? "http_error";
|
|
36
|
-
this.requestId = body?.error?.request_id;
|
|
37
|
-
this.errors = body?.errors ?? {};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** True for 4xx responses: retrying the same request won't help. */
|
|
41
|
-
get isClientError(): boolean {
|
|
42
|
-
return this.status >= 400 && this.status < 500;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type QueryValue = string | number | boolean | null | undefined;
|
|
47
|
-
export type Query = Record<string, QueryValue | QueryValue[]>;
|
|
48
|
-
|
|
49
|
-
export interface RequestOptions extends Omit<RequestInit, "body" | "method"> {
|
|
50
|
-
query?: Query;
|
|
51
|
-
body?: unknown;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function baseUrl(): string {
|
|
55
|
-
const publicUrl = process.env.NEXT_PUBLIC_GEMSTACK_API_URL;
|
|
56
|
-
if (publicUrl) return publicUrl.replace(/\/$/, "");
|
|
57
|
-
if (typeof window === "undefined") {
|
|
58
|
-
return (process.env.GEMSTACK_API_URL ?? "http://127.0.0.1:4000").replace(/\/$/, "");
|
|
59
|
-
}
|
|
60
|
-
return "";
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** Builds a URL for an API path: apiUrl("/products", { page: 2 }) → "/api/products?page=2". */
|
|
64
|
-
export function apiUrl(path: string, query?: Query): string {
|
|
65
|
-
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
66
|
-
let url = `${baseUrl()}${API_PATH}${normalized}`;
|
|
67
|
-
if (query) {
|
|
68
|
-
const params = new URLSearchParams();
|
|
69
|
-
for (const [key, value] of Object.entries(query)) {
|
|
70
|
-
const values = Array.isArray(value) ? value : [value];
|
|
71
|
-
for (const item of values) {
|
|
72
|
-
if (item !== undefined && item !== null) params.append(Array.isArray(value) ? `${key}[]` : key, String(item));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const qs = params.toString();
|
|
76
|
-
if (qs) url += `?${qs}`;
|
|
77
|
-
}
|
|
78
|
-
return url;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function parse(text: string): unknown {
|
|
82
|
-
try {
|
|
83
|
-
return JSON.parse(text);
|
|
84
|
-
} catch {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export async function request<T>(method: string, path: string, options: RequestOptions = {}): Promise<T> {
|
|
90
|
-
const { query, body, headers, ...init } = options;
|
|
91
|
-
const requestHeaders = new Headers(headers);
|
|
92
|
-
requestHeaders.set("accept", "application/json");
|
|
93
|
-
|
|
94
|
-
let payload: BodyInit | undefined;
|
|
95
|
-
if (body !== undefined) {
|
|
96
|
-
if (body instanceof FormData || body instanceof Blob || body instanceof URLSearchParams) {
|
|
97
|
-
payload = body;
|
|
98
|
-
} else {
|
|
99
|
-
payload = JSON.stringify(body);
|
|
100
|
-
requestHeaders.set("content-type", "application/json");
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const response = await fetch(apiUrl(path, query), { ...init, method, headers: requestHeaders, body: payload });
|
|
105
|
-
const text = response.status === 204 ? "" : await response.text();
|
|
106
|
-
const data = text ? parse(text) : null;
|
|
107
|
-
|
|
108
|
-
if (!response.ok) {
|
|
109
|
-
const exception = (data as ApiErrorBody | null)?.exception;
|
|
110
|
-
if (exception && process.env.NODE_ENV !== "production") {
|
|
111
|
-
// The Ruby exception behind a 500, so it shows up next to the failing request.
|
|
112
|
-
console.error(`[GemStack API] ${method} ${path} → ${exception.class}: ${exception.message}\n ${exception.backtrace.slice(0, 8).join("\n ")}`);
|
|
113
|
-
}
|
|
114
|
-
throw new ApiError(response.status, data as ApiErrorBody | null, response.statusText || `HTTP ${response.status}`);
|
|
115
|
-
}
|
|
116
|
-
return data as T;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export const api = {
|
|
120
|
-
get: <T>(path: string, options?: RequestOptions) => request<T>("GET", path, options),
|
|
121
|
-
post: <T>(path: string, body?: unknown, options?: RequestOptions) => request<T>("POST", path, { ...options, body }),
|
|
122
|
-
put: <T>(path: string, body?: unknown, options?: RequestOptions) => request<T>("PUT", path, { ...options, body }),
|
|
123
|
-
patch: <T>(path: string, body?: unknown, options?: RequestOptions) => request<T>("PATCH", path, { ...options, body }),
|
|
124
|
-
delete: <T = void>(path: string, options?: RequestOptions) => request<T>("DELETE", path, options),
|
|
125
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { NextConfig } from "next";
|
|
2
|
-
|
|
3
|
-
// One public origin, in every environment:
|
|
4
|
-
// - `gemstack dev`: the GemStack gateway routes /api/* to Ruby before requests reach Next.js.
|
|
5
|
-
// - Production: set GEMSTACK_API_URL (e.g. http://api.internal:4000) and Next.js proxies
|
|
6
|
-
// /api/* to the Ruby API. Leave it unset if a reverse proxy already routes /api/*.
|
|
7
|
-
const apiUrl = process.env.GEMSTACK_API_URL?.replace(/\/$/, "");
|
|
8
|
-
const apiPath = process.env.NEXT_PUBLIC_GEMSTACK_API_PATH ?? "/api";
|
|
9
|
-
|
|
10
|
-
const nextConfig: NextConfig = {
|
|
11
|
-
async rewrites() {
|
|
12
|
-
if (!apiUrl) return [];
|
|
13
|
-
return [{ source: `${apiPath}/:path*`, destination: `${apiUrl}${apiPath}/:path*` }];
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default nextConfig;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<%= name %>-frontend",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "next dev",
|
|
7
|
-
"build": "next build",
|
|
8
|
-
"start": "next start",
|
|
9
|
-
"typecheck": "tsc --noEmit"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@tanstack/react-query": "^5.104.0",
|
|
13
|
-
"next": "^16.3.6",
|
|
14
|
-
"react": "^19.3.0",
|
|
15
|
-
"react-dom": "^19.3.0"
|
|
16
|
-
},
|
|
17
|
-
"devDependencies": {
|
|
18
|
-
"@types/node": "^22.0.0",
|
|
19
|
-
"@types/react": "^19.3.0",
|
|
20
|
-
"@types/react-dom": "^19.3.0",
|
|
21
|
-
"typescript": "~5.9.3"
|
|
22
|
-
}
|
|
23
|
-
}
|