@lemonadecms/create 0.0.0-stage → 0.1.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/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/README.md +42 -2
- package/bin/create-lemonade.mjs +124 -0
- package/dist/catalog.json +772 -0
- package/dist/templates/angular/angular.json +54 -0
- package/dist/templates/angular/locks/npm-lock.json.template +7079 -0
- package/dist/templates/angular/locks/pnpm-lock.yaml.template +4237 -0
- package/dist/templates/angular/locks/yarn.lock.template +4899 -0
- package/dist/templates/angular/package.json +68 -0
- package/dist/templates/angular/src/app/app.config.server.ts +23 -0
- package/dist/templates/angular/src/app/app.config.ts +34 -0
- package/dist/templates/angular/src/app/app.ts +9 -0
- package/dist/templates/angular/src/app/blog.service.ts +74 -0
- package/dist/templates/angular/src/app/journal.html +71 -0
- package/dist/templates/angular/src/app/journal.ts +47 -0
- package/dist/templates/angular/src/index.html +14 -0
- package/dist/templates/angular/src/main.server.ts +5 -0
- package/dist/templates/angular/src/main.ts +6 -0
- package/dist/templates/angular/src/server.ts +79 -0
- package/dist/templates/angular/tsconfig.app.json +8 -0
- package/dist/templates/angular/tsconfig.json +21 -0
- package/dist/templates/angular/vendor/README.md +32 -0
- package/dist/templates/angular/vendor/picomatch-4.0.7-lemonade-sec51.1.tgz +0 -0
- package/dist/templates/angular/vendor/picomatch-4.0.7.patch +59 -0
- package/dist/templates/angular/vendor/provenance.json +29 -0
- package/dist/templates/astro/astro.config.mjs +7 -0
- package/dist/templates/astro/locks/npm-lock.json.template +5478 -0
- package/dist/templates/astro/locks/pnpm-lock.yaml.template +3537 -0
- package/dist/templates/astro/locks/yarn.lock.template +4085 -0
- package/dist/templates/astro/package.json +51 -0
- package/dist/templates/astro/src/components/BlogView.astro +92 -0
- package/dist/templates/astro/src/layouts/Site.astro +23 -0
- package/dist/templates/astro/src/pages/articles/[id].astro +13 -0
- package/dist/templates/astro/src/pages/index.astro +13 -0
- package/dist/templates/astro/src/pages/lemonade/preview/[...path].ts +4 -0
- package/dist/templates/astro/src/pages/lemonade/preview.ts +4 -0
- package/dist/templates/astro/tsconfig.json +9 -0
- package/dist/templates/astro/vendor/README.md +32 -0
- package/dist/templates/astro/vendor/picomatch-2.3.2-lemonade-sec51.1.tgz +0 -0
- package/dist/templates/astro/vendor/picomatch-2.3.2.patch +59 -0
- package/dist/templates/astro/vendor/picomatch-4.0.7-lemonade-sec51.1.tgz +0 -0
- package/dist/templates/astro/vendor/picomatch-4.0.7.patch +59 -0
- package/dist/templates/astro/vendor/provenance.json +43 -0
- package/dist/templates/next/app/articles/[id]/page.tsx +29 -0
- package/dist/templates/next/app/data.ts +12 -0
- package/dist/templates/next/app/error.tsx +15 -0
- package/dist/templates/next/app/layout.tsx +13 -0
- package/dist/templates/next/app/lemonade/preview/[[...path]]/route.ts +7 -0
- package/dist/templates/next/app/loading.tsx +7 -0
- package/dist/templates/next/app/not-found.tsx +8 -0
- package/dist/templates/next/app/page.tsx +17 -0
- package/dist/templates/next/app/view.tsx +111 -0
- package/dist/templates/next/locks/npm-lock.json.template +1158 -0
- package/dist/templates/next/locks/pnpm-lock.yaml.template +715 -0
- package/dist/templates/next/locks/yarn.lock.template +775 -0
- package/dist/templates/next/next-env.d.ts +2 -0
- package/dist/templates/next/next.config.mjs +8 -0
- package/dist/templates/next/package.json +44 -0
- package/dist/templates/next/proxy.ts +19 -0
- package/dist/templates/next/tsconfig.json +25 -0
- package/dist/templates/nuxt/app/app.vue +1 -0
- package/dist/templates/nuxt/app/components/JournalView.vue +75 -0
- package/dist/templates/nuxt/app/pages/articles/[id].vue +8 -0
- package/dist/templates/nuxt/app/pages/index.vue +8 -0
- package/dist/templates/nuxt/locks/npm-lock.json.template +9113 -0
- package/dist/templates/nuxt/locks/pnpm-lock.yaml.template +6471 -0
- package/dist/templates/nuxt/locks/yarn.lock.template +6915 -0
- package/dist/templates/nuxt/nuxt.config.ts +27 -0
- package/dist/templates/nuxt/package.json +66 -0
- package/dist/templates/nuxt/server/api/blog/[id].get.ts +10 -0
- package/dist/templates/nuxt/server/api/blog.get.ts +9 -0
- package/dist/templates/nuxt/server/middleware/preview.ts +9 -0
- package/dist/templates/nuxt/server/utils/cms-environment.ts +15 -0
- package/dist/templates/nuxt/tsconfig.json +7 -0
- package/dist/templates/nuxt/vendor/README.md +32 -0
- package/dist/templates/nuxt/vendor/picomatch-2.3.2-lemonade-sec51.1.tgz +0 -0
- package/dist/templates/nuxt/vendor/picomatch-2.3.2.patch +59 -0
- package/dist/templates/nuxt/vendor/picomatch-4.0.7-lemonade-sec51.1.tgz +0 -0
- package/dist/templates/nuxt/vendor/picomatch-4.0.7.patch +59 -0
- package/dist/templates/nuxt/vendor/provenance.json +43 -0
- package/dist/templates/shared/GETTING_STARTED.md +29 -0
- package/dist/templates/shared/README.md +8 -0
- package/dist/templates/shared/env.example.template +11 -0
- package/dist/templates/shared/gitignore.template +16 -0
- package/dist/templates/shared/model-template.json +75 -0
- package/dist/templates/shared/public/blog.css +255 -0
- package/dist/templates/shared/public/lemonade.svg +5 -0
- package/dist/templates/shared/schema-contract.json +37 -0
- package/dist/templates/shared/scripts/cms-tools.mjs +171 -0
- package/dist/templates/shared/scripts/environment.mjs +68 -0
- package/dist/templates/shared/scripts/run.mjs +122 -0
- package/dist/templates/shared/server/blog.d.mts +35 -0
- package/dist/templates/shared/server/blog.mjs +159 -0
- package/dist/templates/shared/server/config.d.mts +11 -0
- package/dist/templates/shared/server/config.mjs +42 -0
- package/dist/templates/shared/server/preview.d.mts +4 -0
- package/dist/templates/shared/server/preview.mjs +276 -0
- package/dist/templates/shared/src/types/cms-models.ts +37 -0
- package/dist/templates/shared/yarnrc.yml.template +2 -0
- package/package.json +24 -4
- package/src/arguments.mjs +75 -0
- package/src/catalog.mjs +166 -0
- package/src/errors.mjs +10 -0
- package/src/generation.mjs +103 -0
- package/src/paths.mjs +90 -0
- package/src/prompts.mjs +68 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
color-scheme: light dark;
|
|
3
|
+
--paper: #fbfcf8;
|
|
4
|
+
--card: #fff;
|
|
5
|
+
--ink: #18342b;
|
|
6
|
+
--forest: #23583f;
|
|
7
|
+
--lime: #aff33e;
|
|
8
|
+
--muted: #63726b;
|
|
9
|
+
--line: #dbe4d7;
|
|
10
|
+
font-family: 'Avenir Next', Avenir, 'Segoe UI', sans-serif;
|
|
11
|
+
color: var(--ink);
|
|
12
|
+
background: var(--paper);
|
|
13
|
+
}
|
|
14
|
+
* {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
html {
|
|
18
|
+
overflow-wrap: anywhere;
|
|
19
|
+
}
|
|
20
|
+
body {
|
|
21
|
+
margin: 0;
|
|
22
|
+
}
|
|
23
|
+
a {
|
|
24
|
+
color: inherit;
|
|
25
|
+
text-decoration-thickness: 1px;
|
|
26
|
+
text-underline-offset: 4px;
|
|
27
|
+
}
|
|
28
|
+
a:hover {
|
|
29
|
+
color: var(--forest);
|
|
30
|
+
}
|
|
31
|
+
a:focus-visible,
|
|
32
|
+
button:focus-visible {
|
|
33
|
+
outline: 3px solid var(--forest);
|
|
34
|
+
outline-offset: 5px;
|
|
35
|
+
}
|
|
36
|
+
.skip {
|
|
37
|
+
position: absolute;
|
|
38
|
+
left: 12px;
|
|
39
|
+
top: -80px;
|
|
40
|
+
padding: 12px;
|
|
41
|
+
background: var(--lime);
|
|
42
|
+
}
|
|
43
|
+
.skip:focus {
|
|
44
|
+
top: 12px;
|
|
45
|
+
}
|
|
46
|
+
header,
|
|
47
|
+
main,
|
|
48
|
+
footer {
|
|
49
|
+
max-width: 1160px;
|
|
50
|
+
margin: auto;
|
|
51
|
+
padding: 28px 32px;
|
|
52
|
+
}
|
|
53
|
+
header {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-wrap: wrap;
|
|
56
|
+
align-items: center;
|
|
57
|
+
justify-content: space-between;
|
|
58
|
+
border-bottom: 1px solid var(--line);
|
|
59
|
+
gap: 20px;
|
|
60
|
+
}
|
|
61
|
+
.brand {
|
|
62
|
+
font-size: 22px;
|
|
63
|
+
font-weight: 750;
|
|
64
|
+
letter-spacing: -1px;
|
|
65
|
+
text-decoration: none;
|
|
66
|
+
}
|
|
67
|
+
.mark {
|
|
68
|
+
display: inline-block;
|
|
69
|
+
width: 16px;
|
|
70
|
+
height: 16px;
|
|
71
|
+
border: 5px solid var(--forest);
|
|
72
|
+
border-radius: 50%;
|
|
73
|
+
margin-right: 10px;
|
|
74
|
+
vertical-align: baseline;
|
|
75
|
+
}
|
|
76
|
+
.hero {
|
|
77
|
+
padding: 56px 0 46px;
|
|
78
|
+
max-width: 850px;
|
|
79
|
+
}
|
|
80
|
+
.hero h1 {
|
|
81
|
+
font-size: clamp(40px, 7vw, 80px);
|
|
82
|
+
font-weight: 600;
|
|
83
|
+
letter-spacing: -0.055em;
|
|
84
|
+
line-height: 1.08;
|
|
85
|
+
margin: 0 0 24px;
|
|
86
|
+
}
|
|
87
|
+
.hero p {
|
|
88
|
+
font-size: 20px;
|
|
89
|
+
line-height: 1.6;
|
|
90
|
+
max-width: 48ch;
|
|
91
|
+
color: var(--muted);
|
|
92
|
+
}
|
|
93
|
+
.posts {
|
|
94
|
+
display: grid;
|
|
95
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
96
|
+
gap: 36px;
|
|
97
|
+
}
|
|
98
|
+
.post {
|
|
99
|
+
min-width: 0;
|
|
100
|
+
padding: 0 0 28px;
|
|
101
|
+
border-bottom: 1px solid var(--line);
|
|
102
|
+
}
|
|
103
|
+
.post h2 {
|
|
104
|
+
font-size: 28px;
|
|
105
|
+
line-height: 1.2;
|
|
106
|
+
letter-spacing: -0.035em;
|
|
107
|
+
margin: 18px 0 12px;
|
|
108
|
+
}
|
|
109
|
+
.post p {
|
|
110
|
+
color: var(--muted);
|
|
111
|
+
line-height: 1.7;
|
|
112
|
+
max-width: 60ch;
|
|
113
|
+
}
|
|
114
|
+
.post-image {
|
|
115
|
+
width: 100%;
|
|
116
|
+
height: 260px;
|
|
117
|
+
object-fit: cover;
|
|
118
|
+
border-radius: 12px;
|
|
119
|
+
background: var(--line);
|
|
120
|
+
}
|
|
121
|
+
.byline {
|
|
122
|
+
font-size: 14px;
|
|
123
|
+
color: var(--muted);
|
|
124
|
+
display: flex;
|
|
125
|
+
gap: 14px;
|
|
126
|
+
flex-wrap: wrap;
|
|
127
|
+
}
|
|
128
|
+
.pagination {
|
|
129
|
+
display: flex;
|
|
130
|
+
flex-wrap: wrap;
|
|
131
|
+
justify-content: space-between;
|
|
132
|
+
align-items: center;
|
|
133
|
+
gap: 16px;
|
|
134
|
+
margin: 32px 0;
|
|
135
|
+
padding: 20px 0;
|
|
136
|
+
border-top: 1px solid var(--line);
|
|
137
|
+
}
|
|
138
|
+
.article {
|
|
139
|
+
max-width: 760px;
|
|
140
|
+
margin: auto;
|
|
141
|
+
}
|
|
142
|
+
.article h1 {
|
|
143
|
+
font-size: clamp(36px, 6vw, 64px);
|
|
144
|
+
letter-spacing: -0.05em;
|
|
145
|
+
line-height: 1.12;
|
|
146
|
+
overflow-wrap: anywhere;
|
|
147
|
+
}
|
|
148
|
+
.article .body {
|
|
149
|
+
font-size: 19px;
|
|
150
|
+
line-height: 1.85;
|
|
151
|
+
margin: 36px 0;
|
|
152
|
+
}
|
|
153
|
+
.body img {
|
|
154
|
+
max-width: 100%;
|
|
155
|
+
height: auto;
|
|
156
|
+
}
|
|
157
|
+
.body pre {
|
|
158
|
+
overflow: auto;
|
|
159
|
+
padding: 20px;
|
|
160
|
+
background: var(--card);
|
|
161
|
+
border: 1px solid var(--line);
|
|
162
|
+
border-radius: 8px;
|
|
163
|
+
}
|
|
164
|
+
.body a {
|
|
165
|
+
overflow-wrap: anywhere;
|
|
166
|
+
}
|
|
167
|
+
.notice {
|
|
168
|
+
margin: 44px 0;
|
|
169
|
+
padding: 28px;
|
|
170
|
+
border: 1px solid var(--line);
|
|
171
|
+
border-radius: 12px;
|
|
172
|
+
background: var(--card);
|
|
173
|
+
max-width: 760px;
|
|
174
|
+
}
|
|
175
|
+
.notice h1,
|
|
176
|
+
.notice h2 {
|
|
177
|
+
letter-spacing: -0.035em;
|
|
178
|
+
line-height: 1.2;
|
|
179
|
+
}
|
|
180
|
+
.notice p {
|
|
181
|
+
max-width: 64ch;
|
|
182
|
+
line-height: 1.7;
|
|
183
|
+
color: var(--muted);
|
|
184
|
+
}
|
|
185
|
+
.button {
|
|
186
|
+
display: inline-block;
|
|
187
|
+
padding: 12px 18px;
|
|
188
|
+
border: 1px solid var(--line);
|
|
189
|
+
border-radius: 8px;
|
|
190
|
+
background: var(--card);
|
|
191
|
+
color: var(--ink);
|
|
192
|
+
font: inherit;
|
|
193
|
+
text-decoration: none;
|
|
194
|
+
cursor: pointer;
|
|
195
|
+
}
|
|
196
|
+
.button:hover {
|
|
197
|
+
border-color: var(--forest);
|
|
198
|
+
}
|
|
199
|
+
footer {
|
|
200
|
+
border-top: 1px solid var(--line);
|
|
201
|
+
color: var(--muted);
|
|
202
|
+
margin-top: 48px;
|
|
203
|
+
font-size: 14px;
|
|
204
|
+
}
|
|
205
|
+
.preview-banner {
|
|
206
|
+
padding: 16px;
|
|
207
|
+
background: var(--lime);
|
|
208
|
+
color: #18342b;
|
|
209
|
+
display: flex;
|
|
210
|
+
gap: 20px;
|
|
211
|
+
align-items: center;
|
|
212
|
+
justify-content: space-between;
|
|
213
|
+
flex-wrap: wrap;
|
|
214
|
+
}
|
|
215
|
+
.preview-banner p {
|
|
216
|
+
margin: 5px 0;
|
|
217
|
+
}
|
|
218
|
+
@media (max-width: 680px) {
|
|
219
|
+
header,
|
|
220
|
+
main,
|
|
221
|
+
footer {
|
|
222
|
+
padding: 22px;
|
|
223
|
+
}
|
|
224
|
+
.hero {
|
|
225
|
+
padding: 36px 0 28px;
|
|
226
|
+
}
|
|
227
|
+
.posts {
|
|
228
|
+
grid-template-columns: 1fr;
|
|
229
|
+
gap: 24px;
|
|
230
|
+
}
|
|
231
|
+
.post-image {
|
|
232
|
+
height: 210px;
|
|
233
|
+
}
|
|
234
|
+
.article .body {
|
|
235
|
+
font-size: 17px;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
@media (prefers-color-scheme: dark) {
|
|
239
|
+
:root {
|
|
240
|
+
--paper: #12251d;
|
|
241
|
+
--card: #1b3228;
|
|
242
|
+
--ink: #edf3e9;
|
|
243
|
+
--forest: #aff33e;
|
|
244
|
+
--muted: #b7c6b9;
|
|
245
|
+
--line: #365044;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
249
|
+
a,
|
|
250
|
+
button {
|
|
251
|
+
transition:
|
|
252
|
+
color 0.12s,
|
|
253
|
+
border-color 0.12s;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"models": {
|
|
4
|
+
"author": {
|
|
5
|
+
"name": {
|
|
6
|
+
"type": "text"
|
|
7
|
+
},
|
|
8
|
+
"bio": {
|
|
9
|
+
"type": "markdown"
|
|
10
|
+
},
|
|
11
|
+
"portrait": {
|
|
12
|
+
"type": "image"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"article": {
|
|
16
|
+
"title": {
|
|
17
|
+
"type": "text"
|
|
18
|
+
},
|
|
19
|
+
"slug": {
|
|
20
|
+
"type": "text"
|
|
21
|
+
},
|
|
22
|
+
"body": {
|
|
23
|
+
"type": "markdown"
|
|
24
|
+
},
|
|
25
|
+
"author": {
|
|
26
|
+
"type": "reference",
|
|
27
|
+
"target": "author"
|
|
28
|
+
},
|
|
29
|
+
"cover": {
|
|
30
|
+
"type": "image"
|
|
31
|
+
},
|
|
32
|
+
"date": {
|
|
33
|
+
"type": "date"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Uses only the installed SDK's declared public executable, never its internals.
|
|
2
|
+
import { readFile, mkdtemp, rm } from 'node:fs/promises';
|
|
3
|
+
import { resolve, relative } from 'node:path';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { execFile } from 'node:child_process';
|
|
6
|
+
import { promisify } from 'node:util';
|
|
7
|
+
import { environment } from './environment.mjs';
|
|
8
|
+
import { configuration } from '../server/config.mjs';
|
|
9
|
+
const execute = promisify(execFile),
|
|
10
|
+
root = process.cwd(),
|
|
11
|
+
mode = process.argv[2];
|
|
12
|
+
let temporary;
|
|
13
|
+
const controller = new AbortController(),
|
|
14
|
+
stop = () => controller.abort();
|
|
15
|
+
process.on('SIGINT', stop);
|
|
16
|
+
process.on('SIGTERM', stop);
|
|
17
|
+
const failure = (message, code = 4) =>
|
|
18
|
+
Object.assign(new Error(message), { safe: true, exitCode: code });
|
|
19
|
+
try {
|
|
20
|
+
if (!['setup', 'check', 'types'].includes(mode))
|
|
21
|
+
throw failure('Use cms:setup, cms:check or cms:types.');
|
|
22
|
+
const env = await environment(root),
|
|
23
|
+
config = configuration(env);
|
|
24
|
+
if (mode === 'setup') {
|
|
25
|
+
console.log(
|
|
26
|
+
'1. Open https://app.lemonadecms.com and select your workspace/environment.\n2. Create Articles and authors or review model-template.json in Studio.\n3. Create a published read token scoped to article/author, language and media.\n4. Configure the ignored .env; then run cms:check and cms:types.\nNo account, schema, content or credential is changed by this helper.',
|
|
27
|
+
);
|
|
28
|
+
console.log(
|
|
29
|
+
config
|
|
30
|
+
? 'Local configuration is present; access is not yet verified.'
|
|
31
|
+
: 'Connection configuration is missing or invalid. See .env.example.',
|
|
32
|
+
);
|
|
33
|
+
} else {
|
|
34
|
+
if (!config)
|
|
35
|
+
throw failure(
|
|
36
|
+
'Configure CMS_PROJECT_ID, CMS_ENVIRONMENT, CMS_LOCALE, CMS_PUBLIC_KEY and SITE_URL in the ignored .env.',
|
|
37
|
+
);
|
|
38
|
+
const app = JSON.parse(await readFile(resolve(root, 'package.json'), 'utf8'));
|
|
39
|
+
const sdkroot = resolve(root, 'node_modules/@lemonadecms/client');
|
|
40
|
+
const pkg = JSON.parse(await readFile(resolve(sdkroot, 'package.json'), 'utf8'));
|
|
41
|
+
if (
|
|
42
|
+
pkg.name !== '@lemonadecms/client' ||
|
|
43
|
+
pkg.version !== app.dependencies['@lemonadecms/client'] ||
|
|
44
|
+
typeof pkg.bin?.lemonade !== 'string' ||
|
|
45
|
+
relative(sdkroot, resolve(sdkroot, pkg.bin.lemonade)).startsWith('..')
|
|
46
|
+
)
|
|
47
|
+
throw failure('Install the pinned SDK with the selected frozen lockfile.');
|
|
48
|
+
const bin = resolve(sdkroot, pkg.bin.lemonade);
|
|
49
|
+
const safe = Object.fromEntries(
|
|
50
|
+
[
|
|
51
|
+
'PATH',
|
|
52
|
+
'HOME',
|
|
53
|
+
'SYSTEMROOT',
|
|
54
|
+
'SystemRoot',
|
|
55
|
+
'TEMP',
|
|
56
|
+
'TMP',
|
|
57
|
+
'TMPDIR',
|
|
58
|
+
'LANG',
|
|
59
|
+
'SSL_CERT_FILE',
|
|
60
|
+
'NODE_EXTRA_CA_CERTS',
|
|
61
|
+
'NODE_OPTIONS',
|
|
62
|
+
]
|
|
63
|
+
.filter((k) => env[k] !== undefined)
|
|
64
|
+
.map((k) => [k, env[k]]),
|
|
65
|
+
);
|
|
66
|
+
safe.CMS_PUBLIC_KEY = config.publicKey;
|
|
67
|
+
if (env.NODE_TLS_REJECT_UNAUTHORIZED === '0')
|
|
68
|
+
throw failure('TLS verification must remain enabled.');
|
|
69
|
+
temporary = await mkdtemp(resolve(tmpdir(), 'lemonade-schema-'));
|
|
70
|
+
const path = resolve(temporary, 'schema.json');
|
|
71
|
+
const cli = async (args) =>
|
|
72
|
+
execute(process.execPath, [bin, ...args], {
|
|
73
|
+
cwd: root,
|
|
74
|
+
env: safe,
|
|
75
|
+
timeout: 20000,
|
|
76
|
+
maxBuffer: 262144,
|
|
77
|
+
shell: false,
|
|
78
|
+
signal: controller.signal,
|
|
79
|
+
});
|
|
80
|
+
try {
|
|
81
|
+
await cli([
|
|
82
|
+
'schema',
|
|
83
|
+
'pull',
|
|
84
|
+
'--url',
|
|
85
|
+
'https://api.lemonadecms.com',
|
|
86
|
+
'--workspace',
|
|
87
|
+
config.projectId,
|
|
88
|
+
'--environment',
|
|
89
|
+
config.environment,
|
|
90
|
+
'--credential-env',
|
|
91
|
+
'CMS_PUBLIC_KEY',
|
|
92
|
+
'--out',
|
|
93
|
+
path,
|
|
94
|
+
'--json',
|
|
95
|
+
]);
|
|
96
|
+
} catch {
|
|
97
|
+
throw failure(
|
|
98
|
+
'Schema check unavailable. Verify the selected workspace/environment and token scope. The pinned SDK requires a schema without visible JSON fields; scope the read token to article and author. No types were changed.',
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const schema = JSON.parse(await readFile(path, 'utf8'));
|
|
102
|
+
const contract = JSON.parse(
|
|
103
|
+
await readFile(resolve(root, 'schema-contract.json'), 'utf8'),
|
|
104
|
+
);
|
|
105
|
+
if (!schema.locales.includes(config.locale))
|
|
106
|
+
throw failure('The configured locale is not available to this token.');
|
|
107
|
+
for (const [key, expected] of Object.entries(contract.models)) {
|
|
108
|
+
const model = schema.models.find((m) => m.key === key);
|
|
109
|
+
if (!model)
|
|
110
|
+
throw failure(
|
|
111
|
+
'A required model is missing or unavailable. Review article/author grants and model-template.json in Studio.',
|
|
112
|
+
3,
|
|
113
|
+
);
|
|
114
|
+
for (const [field, shape] of Object.entries(expected)) {
|
|
115
|
+
const actual = model.fields.find((f) => f.key === field);
|
|
116
|
+
if (
|
|
117
|
+
!actual ||
|
|
118
|
+
actual.type !== shape.type ||
|
|
119
|
+
(shape.target && actual.target !== shape.target)
|
|
120
|
+
)
|
|
121
|
+
throw failure(
|
|
122
|
+
'The model shape is incompatible. Review the template; existing models were not changed.',
|
|
123
|
+
3,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (mode === 'types') {
|
|
128
|
+
await cli([
|
|
129
|
+
'types',
|
|
130
|
+
'generate',
|
|
131
|
+
'--file',
|
|
132
|
+
path,
|
|
133
|
+
'--out',
|
|
134
|
+
'src/types/cms-models.ts',
|
|
135
|
+
'--json',
|
|
136
|
+
]);
|
|
137
|
+
console.log(
|
|
138
|
+
'Verified schema; generated src/types/cms-models.ts. No CMS content or schema was changed.',
|
|
139
|
+
);
|
|
140
|
+
} else {
|
|
141
|
+
const { createCMSClient } = await import('@lemonadecms/client');
|
|
142
|
+
const client = createCMSClient({
|
|
143
|
+
projectId: config.projectId,
|
|
144
|
+
publicKey: config.publicKey,
|
|
145
|
+
timeoutMs: 5000,
|
|
146
|
+
});
|
|
147
|
+
await client
|
|
148
|
+
.content('author')
|
|
149
|
+
.list({ limit: 1, locale: config.locale, signal: controller.signal });
|
|
150
|
+
const page = await client
|
|
151
|
+
.content('article')
|
|
152
|
+
.list({ limit: 1, locale: config.locale, signal: controller.signal });
|
|
153
|
+
console.log(
|
|
154
|
+
page.data.length
|
|
155
|
+
? 'Schema and a published article read verified. Preview is a separate setup.'
|
|
156
|
+
: 'Schema verified; published collection is empty. Publish an author and article explicitly in Studio.',
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
} catch (e) {
|
|
161
|
+
console.error(
|
|
162
|
+
e?.safe
|
|
163
|
+
? e.message
|
|
164
|
+
: 'CMS check unavailable. No secret values or upstream payloads were printed.',
|
|
165
|
+
);
|
|
166
|
+
process.exitCode = controller.signal.aborted ? 130 : e?.safe ? e.exitCode : 4;
|
|
167
|
+
} finally {
|
|
168
|
+
process.removeListener('SIGINT', stop);
|
|
169
|
+
process.removeListener('SIGTERM', stop);
|
|
170
|
+
if (temporary) await rm(temporary, { recursive: true, force: true });
|
|
171
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The same CMS configuration is loaded before framework startup and CLI checks.
|
|
2
|
+
// Missing values stay empty so framework-specific dotenv files cannot select a
|
|
3
|
+
// different workspace behind the setup check's back. Only this project is read.
|
|
4
|
+
import { lstat, open } from 'node:fs/promises';
|
|
5
|
+
import { parseEnv } from 'node:util';
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
const names = [
|
|
8
|
+
'CMS_PROJECT_ID',
|
|
9
|
+
'CMS_ENVIRONMENT',
|
|
10
|
+
'CMS_LOCALE',
|
|
11
|
+
'CMS_PUBLIC_KEY',
|
|
12
|
+
'SITE_URL',
|
|
13
|
+
'CMS_PREVIEW_ENABLED',
|
|
14
|
+
'CMS_SECRET_KEY',
|
|
15
|
+
'CMS_PREVIEW_URL',
|
|
16
|
+
'CMS_STUDIO_ORIGIN',
|
|
17
|
+
];
|
|
18
|
+
export async function environment(root = process.cwd(), parent = process.env) {
|
|
19
|
+
let values = {};
|
|
20
|
+
try {
|
|
21
|
+
const path = resolve(root, '.env');
|
|
22
|
+
const stat = await lstat(path);
|
|
23
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 65536)
|
|
24
|
+
throw new Error('Invalid environment file.');
|
|
25
|
+
const file = await open(path, 'r');
|
|
26
|
+
try {
|
|
27
|
+
const actual = await file.stat();
|
|
28
|
+
if (actual.ino !== stat.ino || actual.dev !== stat.dev)
|
|
29
|
+
throw new Error('Environment file changed.');
|
|
30
|
+
const bytes = Buffer.alloc(65537);
|
|
31
|
+
let count = 0;
|
|
32
|
+
while (count < bytes.length) {
|
|
33
|
+
const { bytesRead } = await file.read(
|
|
34
|
+
bytes,
|
|
35
|
+
count,
|
|
36
|
+
bytes.length - count,
|
|
37
|
+
count,
|
|
38
|
+
);
|
|
39
|
+
if (!bytesRead) break;
|
|
40
|
+
count += bytesRead;
|
|
41
|
+
}
|
|
42
|
+
const after = await file.stat();
|
|
43
|
+
if (
|
|
44
|
+
count !== actual.size ||
|
|
45
|
+
count > 65536 ||
|
|
46
|
+
after.size !== actual.size ||
|
|
47
|
+
after.mtimeMs !== actual.mtimeMs
|
|
48
|
+
)
|
|
49
|
+
throw new Error('Environment file changed or exceeds 64 KiB.');
|
|
50
|
+
values = parseEnv(
|
|
51
|
+
new TextDecoder('utf-8', { fatal: true }).decode(bytes.subarray(0, count)),
|
|
52
|
+
);
|
|
53
|
+
} finally {
|
|
54
|
+
await file.close();
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (e.code !== 'ENOENT')
|
|
58
|
+
throw new Error(
|
|
59
|
+
'Use a regular UTF-8 .env file of at most 64 KiB. Values were withheld.',
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const output = { ...parent };
|
|
63
|
+
for (const name of names)
|
|
64
|
+
output[name] = Object.hasOwn(parent, name)
|
|
65
|
+
? String(parent[name])
|
|
66
|
+
: String(values[name] || '');
|
|
67
|
+
return output;
|
|
68
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Portable framework launch: no shell interpolation or global framework tools.
|
|
2
|
+
import { readFile, realpath } from 'node:fs/promises';
|
|
3
|
+
import { resolve, relative } from 'node:path';
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { once } from 'node:events';
|
|
6
|
+
import { environment } from './environment.mjs';
|
|
7
|
+
const root = process.cwd(),
|
|
8
|
+
mode = process.argv[2];
|
|
9
|
+
const variants = {
|
|
10
|
+
astro: {
|
|
11
|
+
package: 'astro',
|
|
12
|
+
args: { dev: ['dev', '--host', '127.0.0.1'], build: ['build'], check: ['check'] },
|
|
13
|
+
},
|
|
14
|
+
nuxt: {
|
|
15
|
+
package: 'nuxt',
|
|
16
|
+
args: {
|
|
17
|
+
dev: ['dev', '--host', '127.0.0.1'],
|
|
18
|
+
build: ['build'],
|
|
19
|
+
check: ['typecheck'],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
next: {
|
|
23
|
+
package: 'next',
|
|
24
|
+
args: {
|
|
25
|
+
dev: ['dev', '--hostname', '127.0.0.1'],
|
|
26
|
+
build: ['build'],
|
|
27
|
+
start: ['start', '--hostname', process.env.HOST || '127.0.0.1'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
angular: {
|
|
31
|
+
package: '@angular/cli',
|
|
32
|
+
args: { dev: ['serve', '--host', '127.0.0.1'], build: ['build'] },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
const app = JSON.parse(await readFile(resolve(root, 'package.json'), 'utf8')),
|
|
37
|
+
v = variants[app.lemonade.framework];
|
|
38
|
+
if (!['dev', 'build', 'check', 'start'].includes(mode))
|
|
39
|
+
throw new Error('Unknown command.');
|
|
40
|
+
const env = await environment(root);
|
|
41
|
+
env.NODE_ENV = mode === 'dev' ? 'development' : 'production';
|
|
42
|
+
// Never serialize CMS keys through Nuxt's public runtime config.
|
|
43
|
+
if (app.lemonade.framework === 'nuxt')
|
|
44
|
+
for (const name of [
|
|
45
|
+
'CMS_PROJECT_ID',
|
|
46
|
+
'CMS_PUBLIC_KEY',
|
|
47
|
+
'CMS_ENVIRONMENT',
|
|
48
|
+
'CMS_LOCALE',
|
|
49
|
+
'SITE_URL',
|
|
50
|
+
'CMS_PREVIEW_ENABLED',
|
|
51
|
+
'CMS_SECRET_KEY',
|
|
52
|
+
'CMS_PREVIEW_URL',
|
|
53
|
+
'CMS_STUDIO_ORIGIN',
|
|
54
|
+
])
|
|
55
|
+
env['NUXT_' + name] = env[name];
|
|
56
|
+
let file, args;
|
|
57
|
+
if (mode === 'start' && app.lemonade.framework !== 'next') {
|
|
58
|
+
file = resolve(
|
|
59
|
+
root,
|
|
60
|
+
{
|
|
61
|
+
astro: 'dist/server/entry.mjs',
|
|
62
|
+
nuxt: '.output/server/index.mjs',
|
|
63
|
+
angular: 'dist/blog/server/server.mjs',
|
|
64
|
+
}[app.lemonade.framework],
|
|
65
|
+
);
|
|
66
|
+
args = [];
|
|
67
|
+
} else if (mode === 'check') {
|
|
68
|
+
if (app.lemonade.framework === 'astro') {
|
|
69
|
+
const pkgroot = resolve(root, 'node_modules/@astrojs/check');
|
|
70
|
+
const pkg = JSON.parse(await readFile(resolve(pkgroot, 'package.json'), 'utf8'));
|
|
71
|
+
file = resolve(
|
|
72
|
+
pkgroot,
|
|
73
|
+
typeof pkg.bin === 'string' ? pkg.bin : Object.values(pkg.bin)[0],
|
|
74
|
+
);
|
|
75
|
+
args = [];
|
|
76
|
+
} else if (app.lemonade.framework === 'nuxt') {
|
|
77
|
+
const pkgroot = resolve(root, 'node_modules/@nuxt/cli');
|
|
78
|
+
const pkg = JSON.parse(await readFile(resolve(pkgroot, 'package.json'), 'utf8'));
|
|
79
|
+
file = resolve(
|
|
80
|
+
pkgroot,
|
|
81
|
+
typeof pkg.bin === 'string' ? pkg.bin : Object.values(pkg.bin)[0],
|
|
82
|
+
);
|
|
83
|
+
args = ['typecheck'];
|
|
84
|
+
} else {
|
|
85
|
+
file = resolve(root, 'node_modules/typescript/bin/tsc');
|
|
86
|
+
args = ['--noEmit'];
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
const pkgroot = resolve(root, 'node_modules', v.package);
|
|
90
|
+
const pkg = JSON.parse(await readFile(resolve(pkgroot, 'package.json'), 'utf8'));
|
|
91
|
+
if (pkg.name !== v.package) throw new Error('Unexpected framework package.');
|
|
92
|
+
const bin = typeof pkg.bin === 'string' ? pkg.bin : Object.values(pkg.bin)[0];
|
|
93
|
+
if (!bin || relative(pkgroot, resolve(pkgroot, bin)).startsWith('..'))
|
|
94
|
+
throw new Error('Invalid framework executable.');
|
|
95
|
+
file = await realpath(resolve(pkgroot, bin));
|
|
96
|
+
args = v.args[mode];
|
|
97
|
+
if (!args) throw new Error('Unsupported command.');
|
|
98
|
+
}
|
|
99
|
+
const child = spawn(process.execPath, [file, ...args], {
|
|
100
|
+
cwd: root,
|
|
101
|
+
env,
|
|
102
|
+
stdio: 'inherit',
|
|
103
|
+
shell: false,
|
|
104
|
+
});
|
|
105
|
+
const stop = (signal) => child.kill(signal);
|
|
106
|
+
const interrupt = () => stop('SIGINT'),
|
|
107
|
+
terminate = () => stop('SIGTERM');
|
|
108
|
+
process.on('SIGINT', interrupt);
|
|
109
|
+
process.on('SIGTERM', terminate);
|
|
110
|
+
try {
|
|
111
|
+
const [code, signal] = await once(child, 'exit');
|
|
112
|
+
process.exitCode = code ?? (signal ? 130 : 1);
|
|
113
|
+
} finally {
|
|
114
|
+
process.removeListener('SIGINT', interrupt);
|
|
115
|
+
process.removeListener('SIGTERM', terminate);
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
console.error(
|
|
119
|
+
'The app could not start. Check dependencies and the documented configuration. Private values were withheld.',
|
|
120
|
+
);
|
|
121
|
+
process.exitCode = 1;
|
|
122
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface Post {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
bodyHtml: string;
|
|
6
|
+
image: string | null;
|
|
7
|
+
imageAlt: string;
|
|
8
|
+
date: string;
|
|
9
|
+
author: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface BlogView {
|
|
12
|
+
state: string;
|
|
13
|
+
status: number;
|
|
14
|
+
title: string;
|
|
15
|
+
description: string;
|
|
16
|
+
canonical: string;
|
|
17
|
+
contextKey: string;
|
|
18
|
+
locale: string;
|
|
19
|
+
posts: Post[];
|
|
20
|
+
article: Post | null;
|
|
21
|
+
page: number;
|
|
22
|
+
hasNext: boolean;
|
|
23
|
+
hasPrevious: boolean;
|
|
24
|
+
}
|
|
25
|
+
export const headers: Record<string, string>;
|
|
26
|
+
export function readBlog(
|
|
27
|
+
url: string,
|
|
28
|
+
options?: {
|
|
29
|
+
id?: string | null;
|
|
30
|
+
env?: Record<string, string | undefined>;
|
|
31
|
+
fetcher?: typeof fetch;
|
|
32
|
+
},
|
|
33
|
+
): Promise<BlogView>;
|
|
34
|
+
export function message(state: string): string;
|
|
35
|
+
export function post(entry: unknown, options?: { preview?: boolean }): Post;
|