create-kywi-app 0.31.0 → 0.33.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/README.md +7 -0
- package/assets/agent-patterns.md +67 -7
- package/bin/create-kywi-app.mjs +34 -8
- package/lib/eject.mjs +51 -11
- package/lib/templates.mjs +8 -2
- package/lib/upgrade.mjs +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ Options:
|
|
|
22
22
|
--yes, -y Use defaults, skip prompts
|
|
23
23
|
--mode <mode> coupled | headless | decoupled (default: coupled)
|
|
24
24
|
--db <provider> postgresql | mysql (default: postgresql)
|
|
25
|
+
mysql is schema only, NOT supported at runtime
|
|
25
26
|
--auth <list> comma-separated: credentials,google,github (default: credentials)
|
|
26
27
|
--force, -f agents: overwrite existing guidance files (default: skip them)
|
|
27
28
|
--help, -h Show this help
|
|
@@ -31,6 +32,12 @@ With no flags and a TTY, it prompts interactively (project name, DB provider,
|
|
|
31
32
|
auth providers, deployment mode). Pass `--yes` (or run non-interactively, e.g.
|
|
32
33
|
in CI) to skip straight to defaults + flags.
|
|
33
34
|
|
|
35
|
+
**Use PostgreSQL.** It is the supported database. The `mysql` choice is still
|
|
36
|
+
accepted (Kywi ships a MySQL schema), but the query layer is PostgreSQL-only,
|
|
37
|
+
so a MySQL project migrates and then fails at runtime. Choosing it, by prompt
|
|
38
|
+
or by `--db mysql`, prints a warning and writes a warning comment into
|
|
39
|
+
`kywi.config.ts`.
|
|
40
|
+
|
|
34
41
|
```bash
|
|
35
42
|
npx create-kywi-app my-site --yes
|
|
36
43
|
npx create-kywi-app blog --mode headless --auth credentials,google
|
package/assets/agent-patterns.md
CHANGED
|
@@ -312,11 +312,26 @@ rejected at the door, because detaching would copy it into every page that links
|
|
|
312
312
|
And a `section` or `variantContainer` definition may not contain an **A/B tested**
|
|
313
313
|
module container, for the shared-run reason above.
|
|
314
314
|
|
|
315
|
-
**
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
definition
|
|
319
|
-
|
|
315
|
+
**A definition write is a publish; below editor it goes through review.** A
|
|
316
|
+
`PUT` with a definition is live on every linking page the moment it returns,
|
|
317
|
+
with no draft or schedule step. Below editor (an author, or a `write`-scoped
|
|
318
|
+
key), a definition or `moduleType` change to a component placed on a published
|
|
319
|
+
or approved page answers 409 `SUBMIT_REVISION_REQUIRED`: send it to
|
|
320
|
+
`POST /api/v1/components/:id/revisions` (MCP `submit_component_revision`)
|
|
321
|
+
instead, and it waits for an editor, changing nothing until approved. Editors
|
|
322
|
+
review with `GET /api/v1/components/revisions` and
|
|
323
|
+
`POST …/revisions/:revisionId/approve` or `…/reject` (MCP
|
|
324
|
+
`list_component_revisions`, `approve_component_revision`,
|
|
325
|
+
`reject_component_revision`), or in the admin's Approvals queue. Listing is
|
|
326
|
+
read-only, so a `read`-scoped key is enough, but it goes by the key owner's own
|
|
327
|
+
role: an author or above lists a component's revisions, an editor or above the
|
|
328
|
+
site queue, and only an editor (`publish` scope) approves or rejects. A
|
|
329
|
+
submitter follows their own with `GET /api/v1/components/revisions/mine` (MCP
|
|
330
|
+
`list_my_component_revisions`; a rejected one carries the reason in
|
|
331
|
+
`reviewNote`). An approve
|
|
332
|
+
answers 409 `REVISION_STALE` when the component's definition changed after the
|
|
333
|
+
submit (a rename does not count); re-send with `{ "force": true }` only after
|
|
334
|
+
comparing. Component changes are not part of changesets.
|
|
320
335
|
|
|
321
336
|
## 5. Page layouts & modules — not hardcoded JSX
|
|
322
337
|
|
|
@@ -831,8 +846,38 @@ configure the workflow rather than letting everything publish directly:
|
|
|
831
846
|
specific sections (e.g. only Legal edits `/legal/*`).
|
|
832
847
|
- Published pages accept **pending revisions** — edits go through review while
|
|
833
848
|
the live page keeps serving — so review doesn't mean taking pages down.
|
|
834
|
-
|
|
835
|
-
|
|
849
|
+
Below editor (an author, or an author-scoped `write` key) a published page
|
|
850
|
+
can only change this way: a direct content or layout write to it answers
|
|
851
|
+
409 `SUBMIT_REVISION_REQUIRED`; send the edit to `POST …/submit` instead.
|
|
852
|
+
- **Find the queue first.** `GET /api/v1/content/revisions/pending` (MCP
|
|
853
|
+
`list_pending_content_revisions`; SDK `sdk.content.revisions.listPending()`;
|
|
854
|
+
editor or above, `read` scope is enough) lists each pending revision with its
|
|
855
|
+
`versionId`, `contentId`, `contentTypeName` and a `changedFields` diff against
|
|
856
|
+
the live page: read the diff before approving.
|
|
857
|
+
- **Approve with edits.** An editor (or an editor's `publish`-scope key) reviews
|
|
858
|
+
a pending revision by approving it: `POST /api/v1/content/:type/:id/revisions/:versionId/approve`
|
|
859
|
+
(MCP `approve_content_revision`; SDK `sdk.content.revisions.approve(type, id,
|
|
860
|
+
versionId, { layout, expectedUpdatedAt })`). Send nothing to publish the
|
|
861
|
+
revision as submitted. To fix a block first, send the whole `layout` you want
|
|
862
|
+
live (read the revision's layout, change it, send it back): it replaces the
|
|
863
|
+
revision's own layout in the same transaction, so the approve and your edits
|
|
864
|
+
record one version, and nothing is written if any check fails. Send
|
|
865
|
+
`expectedUpdatedAt` (the page's `updatedAt` as you loaded it) so a page saved
|
|
866
|
+
meanwhile answers 409 `LAYOUT_CONFLICT` (details `currentUpdatedAt`,
|
|
867
|
+
`updatedBy`; the SDK throws `KywiLayoutConflictError`) instead of being
|
|
868
|
+
overwritten: re-read, merge, retry with the new `updatedAt`. The answer's
|
|
869
|
+
`data.removedProps` lists props the revision carried that no module declares
|
|
870
|
+
(they are dropped); a prop *you* add that no module declares is refused with
|
|
871
|
+
400 `UNKNOWN_MODULE_PROP`. Other answers: 409 `REVISION_STAGED` (the revision
|
|
872
|
+
is staged in an open changeset: remove it from the changeset or publish the
|
|
873
|
+
changeset), 403 `FORBIDDEN` / `FORBIDDEN_FIELD` / `FORBIDDEN_MODULE` (an
|
|
874
|
+
admin-only module type, or a layout you may not write), 423 `LOCKED` (someone
|
|
875
|
+
else, or a publish, holds the page: try later), 503 `WRITE_BUSY` (retry).
|
|
876
|
+
- Every save records a **version** with restore — field saves and layout
|
|
877
|
+
saves alike; approvers see field-level diffs. Consecutive saves by the same
|
|
878
|
+
person on the same page within 10 minutes update one "Saved" version rather
|
|
879
|
+
than adding one per save, so an agent iterating on a page keeps the history
|
|
880
|
+
readable. Mention this at handover: "you can always roll back."
|
|
836
881
|
|
|
837
882
|
Solo-owner sites can publish directly — but still enable it before the team
|
|
838
883
|
grows past one.
|
|
@@ -845,6 +890,21 @@ grows past one.
|
|
|
845
890
|
- **Changesets** batch related edits (a product launch touching six pages) and
|
|
846
891
|
publish them together, optionally on a schedule. Use one whenever a launch
|
|
847
892
|
spans multiple nodes — partial launches are worse than late ones.
|
|
893
|
+
- **Changesets don't delete pages.** To take a page down with a launch, stage a
|
|
894
|
+
change that hides it (Unpublish At, hide from navigation, or an expiration
|
|
895
|
+
date); delete a page directly, not through a changeset. Unpublish At takes
|
|
896
|
+
the page down at publish; an expiration date takes effect when the
|
|
897
|
+
scheduler's expiry job runs, not at publish. A staged change can't set
|
|
898
|
+
`status`, `publishedAt`, `sortOrder` or `isLocked` (400
|
|
899
|
+
`FIELD_NOT_STAGEABLE`): the publish sets the first two, and the others are
|
|
900
|
+
changed on the page directly. A delete item staged before 0.33.0 must be
|
|
901
|
+
removed before its changeset can publish or be scheduled.
|
|
902
|
+
- **To hand a staged changeset to QA or a client**, set its preview visibility to
|
|
903
|
+
`public` (`set_changeset_preview_visibility`), then create a preview link
|
|
904
|
+
(`create_changeset_preview_link`). The URL is shown once, so pass it on
|
|
905
|
+
immediately. Add a passcode (8+ characters) for sensitive content. Links end
|
|
906
|
+
when they expire, when the changeset publishes, or when it goes private
|
|
907
|
+
(which revokes every link for good).
|
|
848
908
|
|
|
849
909
|
## 11. Multilingual sites
|
|
850
910
|
|
package/bin/create-kywi-app.mjs
CHANGED
|
@@ -25,6 +25,17 @@ import { planEject, applyEject, wiringHints } from '../lib/eject.mjs'
|
|
|
25
25
|
|
|
26
26
|
const MODES = ['coupled', 'headless', 'decoupled']
|
|
27
27
|
const DB_PROVIDERS = ['postgresql', 'mysql']
|
|
28
|
+
// PostgreSQL is the supported database. Kywi ships a MySQL schema (kept in
|
|
29
|
+
// parity with the Postgres one) but its query layer is Postgres-only, so a
|
|
30
|
+
// mysql project migrates and then fails at runtime. The choice stays offered
|
|
31
|
+
// for anyone working on the port, behind this warning.
|
|
32
|
+
const MYSQL_PROMPT_LABEL = 'mysql = schema only, not supported at runtime'
|
|
33
|
+
const MYSQL_WARNING = `
|
|
34
|
+
⚠ MySQL is not supported at runtime. Kywi's MySQL schema exists and migrates,
|
|
35
|
+
but the query layer is PostgreSQL-only, so the site and admin will fail
|
|
36
|
+
against a MySQL database. Use --db postgresql (the default) for a working
|
|
37
|
+
project. See docs/hosting.md "Database providers" in the kywi-cms repo.
|
|
38
|
+
`
|
|
28
39
|
const AUTH_CHOICES = ['credentials', 'google', 'github']
|
|
29
40
|
|
|
30
41
|
const KYWI_VERSION = readKywiVersion()
|
|
@@ -109,6 +120,7 @@ Options:
|
|
|
109
120
|
--yes, -y Use defaults, skip prompts
|
|
110
121
|
--mode <mode> coupled | headless | decoupled (default: coupled)
|
|
111
122
|
--db <provider> postgresql | mysql (default: postgresql)
|
|
123
|
+
mysql is schema only, NOT supported at runtime
|
|
112
124
|
--auth <list> comma-separated: credentials,google,github (default: credentials)
|
|
113
125
|
--site <id> eject: which site's layer (default: the first site in kywi.config.ts)
|
|
114
126
|
--theme <name> eject: which theme's layer (default: that site's theme)
|
|
@@ -138,8 +150,9 @@ or its kywi.config.ts could not be read.
|
|
|
138
150
|
|
|
139
151
|
// ── Prompting ─────────────────────────────────────────────────────────────────
|
|
140
152
|
|
|
141
|
-
async function prompt(rl, question, def, choices) {
|
|
142
|
-
const
|
|
153
|
+
async function prompt(rl, question, def, choices, note) {
|
|
154
|
+
const listed = choices ? choices.join('/') + (note ? `; ${note}` : '') : ''
|
|
155
|
+
const hint = choices ? ` (${listed})` : def ? ` (${def})` : ''
|
|
143
156
|
const answer = (await rl.question(`${question}${hint}: `)).trim()
|
|
144
157
|
return answer || def
|
|
145
158
|
}
|
|
@@ -158,7 +171,7 @@ async function resolveAnswers(opts) {
|
|
|
158
171
|
const rl = createInterface({ input: stdin, output: stdout })
|
|
159
172
|
try {
|
|
160
173
|
const projectName = opts.name || (await prompt(rl, 'Project name', 'my-kywi-app'))
|
|
161
|
-
const dbProvider = opts.db || (await prompt(rl, 'Database provider', 'postgresql', DB_PROVIDERS))
|
|
174
|
+
const dbProvider = opts.db || (await prompt(rl, 'Database provider', 'postgresql', DB_PROVIDERS, MYSQL_PROMPT_LABEL))
|
|
162
175
|
const auth = opts.auth || (await prompt(rl, 'Auth providers (comma-separated)', 'credentials'))
|
|
163
176
|
const mode = opts.mode || (await prompt(rl, 'Deployment mode', 'coupled', MODES))
|
|
164
177
|
return normalize({ projectName, mode, dbProvider, auth })
|
|
@@ -180,11 +193,19 @@ function normalize({ projectName, mode, dbProvider, auth }) {
|
|
|
180
193
|
}
|
|
181
194
|
if (authProviders.length === 0) authProviders.push('credentials')
|
|
182
195
|
if (errors.length) {
|
|
183
|
-
const err = new Error(errors.join('\n'))
|
|
196
|
+
const err = /** @type {Error & { userFacing?: boolean }} */ (new Error(errors.join('\n')))
|
|
184
197
|
err.userFacing = true
|
|
185
198
|
throw err
|
|
186
199
|
}
|
|
187
|
-
|
|
200
|
+
// The checks above reject anything outside MODES / DB_PROVIDERS, so the
|
|
201
|
+
// widened strings are the unions here.
|
|
202
|
+
return /** @type {import('../lib/templates.mjs').Answers} */ ({
|
|
203
|
+
projectName,
|
|
204
|
+
mode,
|
|
205
|
+
dbProvider,
|
|
206
|
+
authProviders,
|
|
207
|
+
kywiVersion: KYWI_VERSION,
|
|
208
|
+
})
|
|
188
209
|
}
|
|
189
210
|
|
|
190
211
|
// ── Generation ────────────────────────────────────────────────────────────────
|
|
@@ -224,12 +245,13 @@ function readProjectName(dir) {
|
|
|
224
245
|
* Detect the deployment mode from kywi.config.ts (`mode: 'coupled'|'headless'|
|
|
225
246
|
* 'decoupled'`). Returns coupled with detected:false when absent/unmatched, so the
|
|
226
247
|
* caller can print a note.
|
|
248
|
+
* @returns {{ mode: import('../lib/config-scan.mjs').KywiMode, detected: boolean }}
|
|
227
249
|
*/
|
|
228
250
|
function detectMode(dir) {
|
|
229
251
|
try {
|
|
230
252
|
const cfg = readFileSync(join(dir, 'kywi.config.ts'), 'utf8')
|
|
231
253
|
const m = cfg.match(/mode:\s*['"](coupled|headless|decoupled)['"]/)
|
|
232
|
-
if (m && DETECTABLE_MODES.includes(m[1])) return { mode: m[1], detected: true }
|
|
254
|
+
if (m && DETECTABLE_MODES.includes(m[1])) return { mode: /** @type {import('../lib/config-scan.mjs').KywiMode} */ (m[1]), detected: true }
|
|
233
255
|
} catch {
|
|
234
256
|
/* unreadable config — handled by the caller's kywi.config.ts existence gate */
|
|
235
257
|
}
|
|
@@ -265,6 +287,7 @@ async function runAgentsCommand(opts) {
|
|
|
265
287
|
|
|
266
288
|
// The guidance files depend only on projectName + mode (+ detected landmarks);
|
|
267
289
|
// the other answers fields are irrelevant here but kept shape-complete.
|
|
290
|
+
/** @type {import('../lib/templates.mjs').Answers} */
|
|
268
291
|
const answers = {
|
|
269
292
|
projectName,
|
|
270
293
|
mode,
|
|
@@ -373,9 +396,10 @@ async function runEjectCommand(opts) {
|
|
|
373
396
|
if (result.wired) {
|
|
374
397
|
stdout.write(`wired: ${plan.indexRel}\n`)
|
|
375
398
|
} else {
|
|
376
|
-
const
|
|
399
|
+
const hints = wiringHints(plan)
|
|
400
|
+
const entryLine = hints.pop()
|
|
377
401
|
stdout.write(`not wired (edit by hand): ${plan.indexRel}\n`)
|
|
378
|
-
stdout.write(` ${importLine}\n`)
|
|
402
|
+
for (const importLine of hints) stdout.write(` ${importLine}\n`)
|
|
379
403
|
stdout.write(` ${entryLine} ← inside its \`templates\` object\n`)
|
|
380
404
|
}
|
|
381
405
|
|
|
@@ -423,6 +447,8 @@ async function main() {
|
|
|
423
447
|
return 1
|
|
424
448
|
}
|
|
425
449
|
|
|
450
|
+
if (answers.dbProvider === 'mysql') stdout.write(MYSQL_WARNING)
|
|
451
|
+
|
|
426
452
|
const targetDir = resolve(process.cwd(), answers.projectName)
|
|
427
453
|
// Edge case (TC-01.001): existing non-empty directory — clear error, no overwrite.
|
|
428
454
|
if (await isNonEmptyDir(targetDir)) {
|
package/lib/eject.mjs
CHANGED
|
@@ -109,7 +109,7 @@ function installedCoreVersion(coreDir) {
|
|
|
109
109
|
* project already has.
|
|
110
110
|
* @param {string} projectDir
|
|
111
111
|
* @param {string|undefined} artifact
|
|
112
|
-
* @returns {{ coreDir: string, coreVersion: string, artifact: string, file: string, exportName: string, sourcePath: string, sourceText: string }}
|
|
112
|
+
* @returns {{ coreDir: string, coreVersion: string, artifact: string, file: string, exportName: string, wrapper: { exportName: string, from: string } | null, sourcePath: string, sourceText: string }}
|
|
113
113
|
*/
|
|
114
114
|
export function resolveEjectSource(projectDir, artifact) {
|
|
115
115
|
const coreDir = findCoreDir(projectDir)
|
|
@@ -155,11 +155,29 @@ export function resolveEjectSource(projectDir, artifact) {
|
|
|
155
155
|
artifact,
|
|
156
156
|
file: entry.file,
|
|
157
157
|
exportName: entry.exportName,
|
|
158
|
+
wrapper: validWrapper(entry.wrapper),
|
|
158
159
|
sourcePath,
|
|
159
160
|
sourceText: readFileSync(sourcePath, 'utf8'),
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
/**
|
|
165
|
+
* A manifest's optional `wrapper` (`{ exportName, from }`): a function the layer
|
|
166
|
+
* entry wraps the export in. Core names `withEditContextSupport` for the front
|
|
167
|
+
* editor, because a client module's own static flags cannot be read on the
|
|
168
|
+
* server. Anything not shaped like an identifier and a core subpath is ignored,
|
|
169
|
+
* since both are spliced into the project's source.
|
|
170
|
+
* @param {unknown} wrapper
|
|
171
|
+
* @returns {{ exportName: string, from: string } | null}
|
|
172
|
+
*/
|
|
173
|
+
function validWrapper(wrapper) {
|
|
174
|
+
if (!wrapper || typeof wrapper !== 'object') return null
|
|
175
|
+
const { exportName, from } = /** @type {Record<string, unknown>} */ (wrapper)
|
|
176
|
+
if (typeof exportName !== 'string' || !/^[A-Za-z_$][\w$]*$/.test(exportName)) return null
|
|
177
|
+
if (typeof from !== 'string' || !/^@kywi-software\/core(\/[\w./-]+)?$/.test(from)) return null
|
|
178
|
+
return { exportName, from }
|
|
179
|
+
}
|
|
180
|
+
|
|
163
181
|
// ── the copied file ───────────────────────────────────────────────────────────
|
|
164
182
|
|
|
165
183
|
const USE_CLIENT_RE = /^\s*(['"])use client\1\s*;?\s*$/
|
|
@@ -191,9 +209,26 @@ function importSpecifier(file) {
|
|
|
191
209
|
return `./${file.replace(/\.(tsx|ts|jsx|js)$/, '')}`
|
|
192
210
|
}
|
|
193
211
|
|
|
194
|
-
/**
|
|
195
|
-
|
|
196
|
-
return
|
|
212
|
+
/** `KywiFrontEdit`, or `withEditContextSupport(KywiFrontEdit)` when the manifest names a wrapper. */
|
|
213
|
+
function entryValue(exportName, wrapper) {
|
|
214
|
+
return wrapper ? `${wrapper.exportName}(${exportName})` : exportName
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** The import a wrapper needs, on its own line so a re-eject can recognise it. */
|
|
218
|
+
function wrapperImport(wrapper) {
|
|
219
|
+
return `import { ${wrapper.exportName} } from '${wrapper.from}'`
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The lines an owner must add by hand when the index is not a shape we
|
|
224
|
+
* generate: the import(s), then the `templates` entry, which is always last.
|
|
225
|
+
*/
|
|
226
|
+
export function wiringHints({ artifact, exportName, file, wrapper = null }) {
|
|
227
|
+
return [
|
|
228
|
+
`import { ${exportName} } from '${importSpecifier(file)}'`,
|
|
229
|
+
...(wrapper ? [wrapperImport(wrapper)] : []),
|
|
230
|
+
`${artifact}: ${entryValue(exportName, wrapper)},`,
|
|
231
|
+
]
|
|
197
232
|
}
|
|
198
233
|
|
|
199
234
|
/** Local bindings an import clause introduces (`{ A, B as C }`, `D`, `* as N`). */
|
|
@@ -259,11 +294,13 @@ function insertImport(lines, line) {
|
|
|
259
294
|
* - anything else, including a templates object whose entries are not one
|
|
260
295
|
* `key: value,` per line: returned unchanged with `wired: false`.
|
|
261
296
|
* @param {string} indexText
|
|
262
|
-
* @param {{ artifact: string, exportName: string, file: string }} target
|
|
297
|
+
* @param {{ artifact: string, exportName: string, file: string, wrapper?: { exportName: string, from: string } | null }} target
|
|
263
298
|
* @returns {{ text: string, wired: boolean }}
|
|
264
299
|
*/
|
|
265
|
-
export function wireLayerIndex(indexText, { artifact, exportName, file }) {
|
|
300
|
+
export function wireLayerIndex(indexText, { artifact, exportName, file, wrapper = null }) {
|
|
266
301
|
const importLine = `import { ${exportName} } from '${importSpecifier(file)}'`
|
|
302
|
+
const importLines = wrapper ? [importLine, wrapperImport(wrapper)] : [importLine]
|
|
303
|
+
const value = entryValue(exportName, wrapper)
|
|
267
304
|
const anchor = indexText.indexOf(TEMPLATES_ANCHOR)
|
|
268
305
|
|
|
269
306
|
// ── shape 3: the generated site index, no templates export yet ──
|
|
@@ -272,8 +309,8 @@ export function wireLayerIndex(indexText, { artifact, exportName, file }) {
|
|
|
272
309
|
const body = indexText.endsWith('\n') ? indexText : `${indexText}\n`
|
|
273
310
|
return {
|
|
274
311
|
text:
|
|
275
|
-
`${body}\n${
|
|
276
|
-
`export const templates = {\n ${artifact}: ${
|
|
312
|
+
`${body}\n${importLines.join('\n')}\n${TEMPLATES_TYPE_IMPORT}\n\n` +
|
|
313
|
+
`export const templates = {\n ${artifact}: ${value},\n} satisfies NonNullable<KywiLayerModule['templates']>\n`,
|
|
277
314
|
wired: true,
|
|
278
315
|
}
|
|
279
316
|
}
|
|
@@ -299,18 +336,20 @@ export function wireLayerIndex(indexText, { artifact, exportName, file }) {
|
|
|
299
336
|
kept.push(line.trimEnd())
|
|
300
337
|
continue
|
|
301
338
|
}
|
|
302
|
-
|
|
339
|
+
// `Nav` or `wrap(Nav)`: the binding to drop is the component, never a
|
|
340
|
+
// wrapper, whose import other entries (or this one, re-ejected) may need.
|
|
341
|
+
const binding = /^(?:[A-Za-z_$][\w$]*\s*\(\s*)?([A-Za-z_$][\w$]*)/.exec(m[2].trim())
|
|
303
342
|
replacedBinding = binding ? binding[1] : null
|
|
304
343
|
}
|
|
305
344
|
|
|
306
|
-
const newInner = ['', ` ${artifact}: ${
|
|
345
|
+
const newInner = ['', ` ${artifact}: ${value},`, ...kept, ''].join('\n')
|
|
307
346
|
const rewritten = indexText.slice(0, open + 1) + newInner + indexText.slice(close)
|
|
308
347
|
|
|
309
348
|
let lines = rewritten.split('\n')
|
|
310
349
|
// Drop the import the replaced entry pointed at — including our own, on a
|
|
311
350
|
// re-eject, so `--force` stays idempotent instead of stacking imports.
|
|
312
351
|
if (replacedBinding) lines = lines.filter((line) => !importsBinding(line, replacedBinding))
|
|
313
|
-
if (!lines.some((
|
|
352
|
+
for (const line of importLines) if (!lines.some((l) => l === line)) lines = insertImport(lines, line)
|
|
314
353
|
|
|
315
354
|
return { text: lines.join('\n'), wired: true }
|
|
316
355
|
}
|
|
@@ -383,6 +422,7 @@ export function planEject(projectDir, { artifact, site, theme, layer } = {}) {
|
|
|
383
422
|
artifact: source.artifact,
|
|
384
423
|
exportName: source.exportName,
|
|
385
424
|
file: source.file,
|
|
425
|
+
wrapper: source.wrapper,
|
|
386
426
|
coreVersion: source.coreVersion,
|
|
387
427
|
layer: layerName,
|
|
388
428
|
site: siteId,
|
package/lib/templates.mjs
CHANGED
|
@@ -209,7 +209,9 @@ export default defineKywiConfig({
|
|
|
209
209
|
// 'decoupled' — API + admin here; a separate frontend consumes @kywi-software/sdk.
|
|
210
210
|
mode: '${a.mode}',
|
|
211
211
|
|
|
212
|
-
db: {
|
|
212
|
+
db: {${a.dbProvider === 'mysql' ? `
|
|
213
|
+
// WARNING: MySQL is schema only. Kywi's query layer is PostgreSQL-only, so
|
|
214
|
+
// this project migrates but fails at runtime. Use 'postgresql' to run it.` : ''}
|
|
213
215
|
provider: '${a.dbProvider}',
|
|
214
216
|
url: process.env.DATABASE_URL ?? 'postgres://localhost:5432/${slugify(a.projectName)}',
|
|
215
217
|
},
|
|
@@ -1188,8 +1190,12 @@ function siteStyles(a) {
|
|
|
1188
1190
|
/* Main content column */
|
|
1189
1191
|
.site-main {
|
|
1190
1192
|
flex: 1;
|
|
1193
|
+
/* border-box: width 100% INCLUDES the side padding below. Without it the
|
|
1194
|
+
column is the viewport plus 2rem, and phones scroll sideways. */
|
|
1195
|
+
box-sizing: border-box;
|
|
1191
1196
|
width: 100%;
|
|
1192
|
-
|
|
1197
|
+
/* ...so the cap adds the same side padding back: 760px of TEXT on desktop. */
|
|
1198
|
+
max-width: calc(760px + 2 * var(--kywi-spacing-md, 1rem));
|
|
1193
1199
|
margin: 0 auto;
|
|
1194
1200
|
padding: var(--kywi-spacing-xl, 2.5rem) var(--kywi-spacing-md, 1rem);
|
|
1195
1201
|
}
|
package/lib/upgrade.mjs
CHANGED
|
@@ -104,7 +104,7 @@ const GUIDANCE_STAMP_RE = /^<!-- kywi-agent-guidance v(\d+) \(create-kywi-app ([
|
|
|
104
104
|
* @returns {{
|
|
105
105
|
* projectDir: string, projectName: string, force: boolean, dryRun: boolean,
|
|
106
106
|
* ok: boolean, gate: { kind: 'no-project'|'scan', problems: string[] }|null,
|
|
107
|
-
* mode:
|
|
107
|
+
* mode: import('./config-scan.mjs').KywiMode|null, modeDetected: boolean,
|
|
108
108
|
* entries: UpgradeEntry[], warns: string[], notes: string[], backupDir: string|null,
|
|
109
109
|
* }}
|
|
110
110
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-kywi-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Scaffold a new Kywi CMS project — npx create-kywi-app my-site",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/Kywi-Software/kywi-cms#readme",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"vitest": "^1.6.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"test": "vitest run"
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"typecheck:tests": "tsc -p tsconfig.check.json && tsc -p tsconfig.tests.json"
|
|
37
38
|
}
|
|
38
39
|
}
|