@velastack/patterns 0.3.4 → 0.4.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/README.md +44 -2
- package/dist/chunks/_layout-kkgN0IF7.js +62 -0
- package/dist/chunks/_layout-kkgN0IF7.js.map +1 -0
- package/dist/chunks/{collections-CrOvS2E7.js → collections-Dz2fvKnz.js} +2 -2
- package/dist/chunks/collections-Dz2fvKnz.js.map +1 -0
- package/dist/chunks/{compose-handle-B-CkDcQD.js → compose-handle-D_Rz3Fzo.js} +10 -4
- package/dist/chunks/compose-handle-D_Rz3Fzo.js.map +1 -0
- package/dist/chunks/{config-target-Bln26FJe.js → config-target-Dx3w6WSk.js} +59 -70
- package/dist/chunks/config-target-Dx3w6WSk.js.map +1 -0
- package/dist/chunks/constants-BjyMU5s8.js +6 -0
- package/dist/chunks/constants-BjyMU5s8.js.map +1 -0
- package/dist/chunks/dedent-Gq6Krl4n.js.map +1 -1
- package/dist/chunks/dispatch-CXOXPLFk.js +6 -0
- package/dist/chunks/dispatch-CXOXPLFk.js.map +1 -0
- package/dist/chunks/env-BPfk1VAw.js.map +1 -1
- package/dist/chunks/env-vars-C1NUX-bf.js +268 -0
- package/dist/chunks/env-vars-C1NUX-bf.js.map +1 -0
- package/dist/chunks/env-vars-Cr4lbMD_.js +21 -0
- package/dist/chunks/env-vars-Cr4lbMD_.js.map +1 -0
- package/dist/chunks/env-vars-De0Xs0L2.js +20 -0
- package/dist/chunks/env-vars-De0Xs0L2.js.map +1 -0
- package/dist/chunks/env-vars-file-B_6esJW3.js +34 -0
- package/dist/chunks/env-vars-file-B_6esJW3.js.map +1 -0
- package/dist/chunks/env-vars-mnRA0hOe.js +19 -0
- package/dist/chunks/env-vars-mnRA0hOe.js.map +1 -0
- package/dist/chunks/env.preview-uMRKT5Pc.js.map +1 -1
- package/dist/chunks/errors-DR3gF_7a.js.map +1 -1
- package/dist/chunks/format-result-DZ8De8KY.js.map +1 -1
- package/dist/chunks/generate-BW3l5Fxw.js +252 -0
- package/dist/chunks/generate-BW3l5Fxw.js.map +1 -0
- package/dist/chunks/{generate-CyuY2Ci7.js → generate-DeaBlnK6.js} +25 -24
- package/dist/chunks/generate-DeaBlnK6.js.map +1 -0
- package/dist/chunks/generate-DetW_gbr.js +68 -0
- package/dist/chunks/generate-DetW_gbr.js.map +1 -0
- package/dist/chunks/{generate-DwADTUob.js → generate-Gcc8iRkZ.js} +9 -6
- package/dist/chunks/generate-Gcc8iRkZ.js.map +1 -0
- package/dist/chunks/{generate-DQeWOEPY.js → generate-WMJo3QGZ.js} +9 -6
- package/dist/chunks/generate-WMJo3QGZ.js.map +1 -0
- package/dist/chunks/generate.runtime-1-91UmM8.js +85 -0
- package/dist/chunks/generate.runtime-1-91UmM8.js.map +1 -0
- package/dist/chunks/generate.runtime-6FXJM8hT.js +67 -0
- package/dist/chunks/generate.runtime-6FXJM8hT.js.map +1 -0
- package/dist/chunks/generate.runtime-B1jVAnDI.js +155 -0
- package/dist/chunks/generate.runtime-B1jVAnDI.js.map +1 -0
- package/dist/chunks/generate.runtime-BA3tDKnn.js +147 -0
- package/dist/chunks/generate.runtime-BA3tDKnn.js.map +1 -0
- package/dist/chunks/{generate.runtime-4FDxnvCl.js → generate.runtime-BO778G0r.js} +5 -5
- package/dist/chunks/generate.runtime-BO778G0r.js.map +1 -0
- package/dist/chunks/{generate.runtime-Um77JfwC.js → generate.runtime-B_UVGa3q.js} +7 -7
- package/dist/chunks/generate.runtime-B_UVGa3q.js.map +1 -0
- package/dist/chunks/{generate.runtime-BKiJvE8I.js → generate.runtime-BgTz41Zg.js} +105 -101
- package/dist/chunks/generate.runtime-BgTz41Zg.js.map +1 -0
- package/dist/chunks/{generate.runtime-FdZw277n.js → generate.runtime-C6bSvGMb.js} +108 -142
- package/dist/chunks/generate.runtime-C6bSvGMb.js.map +1 -0
- package/dist/chunks/generate.runtime-C8zJRNYG.js +124 -0
- package/dist/chunks/generate.runtime-C8zJRNYG.js.map +1 -0
- package/dist/chunks/generate.runtime-CCr1lvo4.js +43 -0
- package/dist/chunks/generate.runtime-CCr1lvo4.js.map +1 -0
- package/dist/chunks/generate.runtime-CYagyR5c.js +326 -0
- package/dist/chunks/generate.runtime-CYagyR5c.js.map +1 -0
- package/dist/chunks/{generate.runtime-n9AFWtPp.js → generate.runtime-Ce_rwzNa.js} +4 -4
- package/dist/chunks/generate.runtime-Ce_rwzNa.js.map +1 -0
- package/dist/chunks/{generate.runtime-cQGLxuZM.js → generate.runtime-CexC1Oky.js} +4 -4
- package/dist/chunks/generate.runtime-CexC1Oky.js.map +1 -0
- package/dist/chunks/{generate.runtime-AYQVW1S-.js → generate.runtime-CnPraLKv.js} +35 -31
- package/dist/chunks/generate.runtime-CnPraLKv.js.map +1 -0
- package/dist/chunks/generate.runtime-CslAvllQ.js +112 -0
- package/dist/chunks/generate.runtime-CslAvllQ.js.map +1 -0
- package/dist/chunks/{generate.runtime-onBnOiS7.js → generate.runtime-CuNhY5hn.js} +10 -10
- package/dist/chunks/generate.runtime-CuNhY5hn.js.map +1 -0
- package/dist/chunks/{generate.runtime-B45MvtYm.js → generate.runtime-DD51OSuL.js} +14 -14
- package/dist/chunks/generate.runtime-DD51OSuL.js.map +1 -0
- package/dist/chunks/generate.runtime-DHBRyMAq.js +65 -0
- package/dist/chunks/generate.runtime-DHBRyMAq.js.map +1 -0
- package/dist/chunks/{generate.runtime-D1DNAY6k.js → generate.runtime-DM4o_QYY.js} +9 -9
- package/dist/chunks/generate.runtime-DM4o_QYY.js.map +1 -0
- package/dist/chunks/generate.runtime-DV3WmZtb.js +35 -0
- package/dist/chunks/generate.runtime-DV3WmZtb.js.map +1 -0
- package/dist/chunks/generate.runtime-D_sQOeQa.js +164 -0
- package/dist/chunks/generate.runtime-D_sQOeQa.js.map +1 -0
- package/dist/chunks/{generate.runtime-ofdnLtxS.js → generate.runtime-DqD3PW-W.js} +3 -3
- package/dist/chunks/generate.runtime-DqD3PW-W.js.map +1 -0
- package/dist/chunks/{generate.runtime-VgVwRiiN.js → generate.runtime-Dtgw9IQO.js} +8 -8
- package/dist/chunks/generate.runtime-Dtgw9IQO.js.map +1 -0
- package/dist/chunks/{generate.runtime-CN5c2xH8.js → generate.runtime-IlBCcXvv.js} +14 -14
- package/dist/chunks/generate.runtime-IlBCcXvv.js.map +1 -0
- package/dist/chunks/{generate.runtime-BSRFv4cJ.js → generate.runtime-cwvAoKoH.js} +3 -3
- package/dist/chunks/generate.runtime-cwvAoKoH.js.map +1 -0
- package/dist/chunks/{generate.runtime-DG-3G00z.js → generate.runtime-kvxmTlQb.js} +3 -3
- package/dist/chunks/{generate.runtime-DG-3G00z.js.map → generate.runtime-kvxmTlQb.js.map} +1 -1
- package/dist/chunks/generate.runtime-pVLzzpUM.js +122 -0
- package/dist/chunks/generate.runtime-pVLzzpUM.js.map +1 -0
- package/dist/chunks/{generate.runtime-BFOXm2DD.js → generate.runtime-zJpEufTc.js} +10 -10
- package/dist/chunks/generate.runtime-zJpEufTc.js.map +1 -0
- package/dist/chunks/lib-specifier-Cngo1zF_.js +33 -0
- package/dist/chunks/lib-specifier-Cngo1zF_.js.map +1 -0
- package/dist/chunks/logger-CQONztPm.js.map +1 -1
- package/dist/chunks/{modify-file-Dwfv0dCI.js → modify-file-BlDeeurK.js} +3 -3
- package/dist/chunks/modify-file-BlDeeurK.js.map +1 -0
- package/dist/chunks/{modify-svelte-config-remote-BUU_EaDf.js → modify-svelte-config-remote-p0TfVzxm.js} +8 -10
- package/dist/chunks/modify-svelte-config-remote-p0TfVzxm.js.map +1 -0
- package/dist/chunks/modify-utils-Cw-on_cL.js.map +1 -1
- package/dist/chunks/nav-user-BRIHOOpG.js +6 -0
- package/dist/chunks/nav-user-BRIHOOpG.js.map +1 -0
- package/dist/chunks/package-imports-Bbw3iMPg.js +173 -0
- package/dist/chunks/package-imports-Bbw3iMPg.js.map +1 -0
- package/dist/chunks/pocketbase-C5GS-Dh5.js.map +1 -1
- package/dist/chunks/pocketbase-DpudAAmd.js.map +1 -1
- package/dist/chunks/{pocketbase-BkhUywtb.js → pocketbase-Dry6ry17.js} +2 -2
- package/dist/chunks/pocketbase-Dry6ry17.js.map +1 -0
- package/dist/chunks/{providers-BL9vJP_9.js → providers-BHR6-XZ7.js} +11 -4
- package/dist/chunks/providers-BHR6-XZ7.js.map +1 -0
- package/dist/chunks/{shared-C8GtNxpm.js → shared-CZC4d7Uj.js} +2 -2
- package/dist/chunks/shared-CZC4d7Uj.js.map +1 -0
- package/dist/chunks/{site-BdMX8qrH.js → site-BwCA18Sv.js} +2 -2
- package/dist/chunks/site-BwCA18Sv.js.map +1 -0
- package/dist/chunks/svelte-file-B3RfgVdt.js.map +1 -1
- package/dist/chunks/table-core-AjBpYi-y.js +127 -0
- package/dist/chunks/table-core-AjBpYi-y.js.map +1 -0
- package/dist/chunks/{taggedTemplateLiteral-Dx0fjWiw.js → taggedTemplateLiteral-CswN2AAa.js} +1 -1
- package/dist/chunks/{test-setup-DHEFKEHE.js → test-setup-DEmWd9Ul.js} +76 -67
- package/dist/chunks/test-setup-DEmWd9Ul.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-CeduA--o.js → ts-morph-helpers-CDW4lhox.js} +77 -63
- package/dist/chunks/ts-morph-helpers-CDW4lhox.js.map +1 -0
- package/dist/chunks/ui-DD4NltyN.js.map +1 -1
- package/dist/chunks/{ui-TlEuI2Sz.js → ui-X698F10c.js} +47 -47
- package/dist/chunks/ui-X698F10c.js.map +1 -0
- package/dist/chunks/{unmodify-load-jfdcVZ_a.js → unmodify-load-CyGzC1Hu.js} +2 -2
- package/dist/chunks/unmodify-load-CyGzC1Hu.js.map +1 -0
- package/dist/chunks/util-BLYliuUK.js.map +1 -1
- package/dist/chunks/write-result-B68lvI57.js +511 -0
- package/dist/chunks/write-result-B68lvI57.js.map +1 -0
- package/dist/index.d.ts +224 -1
- package/dist/index.js +2121 -2064
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/chunks/_layout-B7ujvjnA.js +0 -55
- package/dist/chunks/_layout-B7ujvjnA.js.map +0 -1
- package/dist/chunks/collections-CrOvS2E7.js.map +0 -1
- package/dist/chunks/compose-handle-B-CkDcQD.js.map +0 -1
- package/dist/chunks/config-target-Bln26FJe.js.map +0 -1
- package/dist/chunks/constants-BYkd9jeJ.js +0 -6
- package/dist/chunks/constants-BYkd9jeJ.js.map +0 -1
- package/dist/chunks/dispatch-BRnt8PcW.js +0 -6
- package/dist/chunks/dispatch-BRnt8PcW.js.map +0 -1
- package/dist/chunks/generate-6snrlnpA.js +0 -64
- package/dist/chunks/generate-6snrlnpA.js.map +0 -1
- package/dist/chunks/generate-Ca_6FlPi.js +0 -252
- package/dist/chunks/generate-Ca_6FlPi.js.map +0 -1
- package/dist/chunks/generate-CyuY2Ci7.js.map +0 -1
- package/dist/chunks/generate-DQeWOEPY.js.map +0 -1
- package/dist/chunks/generate-DwADTUob.js.map +0 -1
- package/dist/chunks/generate.runtime-4FDxnvCl.js.map +0 -1
- package/dist/chunks/generate.runtime-AYQVW1S-.js.map +0 -1
- package/dist/chunks/generate.runtime-B2aFFaac.js +0 -117
- package/dist/chunks/generate.runtime-B2aFFaac.js.map +0 -1
- package/dist/chunks/generate.runtime-B45MvtYm.js.map +0 -1
- package/dist/chunks/generate.runtime-BFOXm2DD.js.map +0 -1
- package/dist/chunks/generate.runtime-BHkFmI2Y.js +0 -146
- package/dist/chunks/generate.runtime-BHkFmI2Y.js.map +0 -1
- package/dist/chunks/generate.runtime-BKiJvE8I.js.map +0 -1
- package/dist/chunks/generate.runtime-BSRFv4cJ.js.map +0 -1
- package/dist/chunks/generate.runtime-BUqsF3AF.js +0 -123
- package/dist/chunks/generate.runtime-BUqsF3AF.js.map +0 -1
- package/dist/chunks/generate.runtime-BsaSyTnU.js +0 -82
- package/dist/chunks/generate.runtime-BsaSyTnU.js.map +0 -1
- package/dist/chunks/generate.runtime-CMnvmeVt.js +0 -111
- package/dist/chunks/generate.runtime-CMnvmeVt.js.map +0 -1
- package/dist/chunks/generate.runtime-CN5c2xH8.js.map +0 -1
- package/dist/chunks/generate.runtime-CgoSrP55.js +0 -146
- package/dist/chunks/generate.runtime-CgoSrP55.js.map +0 -1
- package/dist/chunks/generate.runtime-D1DNAY6k.js.map +0 -1
- package/dist/chunks/generate.runtime-DQwSY6Nc.js +0 -38
- package/dist/chunks/generate.runtime-DQwSY6Nc.js.map +0 -1
- package/dist/chunks/generate.runtime-D_yqWLcI.js +0 -66
- package/dist/chunks/generate.runtime-D_yqWLcI.js.map +0 -1
- package/dist/chunks/generate.runtime-Drmahmdl.js +0 -313
- package/dist/chunks/generate.runtime-Drmahmdl.js.map +0 -1
- package/dist/chunks/generate.runtime-FdZw277n.js.map +0 -1
- package/dist/chunks/generate.runtime-Lh1cW9Tz.js +0 -94
- package/dist/chunks/generate.runtime-Lh1cW9Tz.js.map +0 -1
- package/dist/chunks/generate.runtime-QGHToXRY.js +0 -32
- package/dist/chunks/generate.runtime-QGHToXRY.js.map +0 -1
- package/dist/chunks/generate.runtime-Um77JfwC.js.map +0 -1
- package/dist/chunks/generate.runtime-VgVwRiiN.js.map +0 -1
- package/dist/chunks/generate.runtime-YyIVd4oy.js +0 -61
- package/dist/chunks/generate.runtime-YyIVd4oy.js.map +0 -1
- package/dist/chunks/generate.runtime-cQGLxuZM.js.map +0 -1
- package/dist/chunks/generate.runtime-n9AFWtPp.js.map +0 -1
- package/dist/chunks/generate.runtime-ofdnLtxS.js.map +0 -1
- package/dist/chunks/generate.runtime-onBnOiS7.js.map +0 -1
- package/dist/chunks/modify-file-Dwfv0dCI.js.map +0 -1
- package/dist/chunks/modify-svelte-config-remote-BUU_EaDf.js.map +0 -1
- package/dist/chunks/nav-user-BYI-h8Od.js +0 -6
- package/dist/chunks/nav-user-BYI-h8Od.js.map +0 -1
- package/dist/chunks/pocketbase-BkhUywtb.js.map +0 -1
- package/dist/chunks/providers-BL9vJP_9.js.map +0 -1
- package/dist/chunks/shared-C8GtNxpm.js.map +0 -1
- package/dist/chunks/site-BdMX8qrH.js.map +0 -1
- package/dist/chunks/table-core-G9Shld4F.js +0 -126
- package/dist/chunks/table-core-G9Shld4F.js.map +0 -1
- package/dist/chunks/test-setup-DHEFKEHE.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +0 -1
- package/dist/chunks/ui-TlEuI2Sz.js.map +0 -1
- package/dist/chunks/unmodify-load-jfdcVZ_a.js.map +0 -1
- package/dist/chunks/write-result-Djy0SZXX.js +0 -376
- package/dist/chunks/write-result-Djy0SZXX.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
The registry for VelaStack patterns.
|
|
4
4
|
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
Patterns write SvelteKit 3 code only, and the package needs Node 22.17 or later (`engines`), the same floor as
|
|
8
|
+
SvelteKit 3. A project with a `svelte.config.*`, or with options still nested under `kit:`, is refused with
|
|
9
|
+
`npx vela@^0.15 migrate sveltekit-3`. Config edits go into the inline `sveltekit({...})` call in `vite.config.ts`.
|
|
10
|
+
|
|
11
|
+
- Imports from `src/lib` use `#lib` (the `"imports"` entries in `package.json`) with sv's extension rules:
|
|
12
|
+
`#lib/server/db.js`, `#lib/components/ui/button/index.js`, `#lib/x.svelte.js` for `x.svelte.ts`, while `.svelte` files
|
|
13
|
+
keep their extension. The SvelteKit 2 alias is still recognised when reading existing imports, never written.
|
|
14
|
+
- Environment variables are read as named imports from `$app/env/private` / `$app/env/public`. A pattern that
|
|
15
|
+
reads one declares it in `src/env.ts` (`modifyEnvVars` in `src/runtime/env-vars.ts`, creating the file when there
|
|
16
|
+
is none) as optional, `schema: (value) => value ?? ''`, so a build with an empty `.env` still passes. Existing
|
|
17
|
+
entries are never changed; `disable-*` removes the names its `enable-*` declares.
|
|
18
|
+
- formsnap 2 peers superforms 2. Installing formsnap, or superforms into a project that has it, writes
|
|
19
|
+
`"overrides": { "formsnap": { "sveltekit-superforms": "<pinned version>" } }` to `package.json` first. superforms
|
|
20
|
+
and flash-message are on `next` releases and are installed with `--save-exact`.
|
|
21
|
+
|
|
5
22
|
## Runtime
|
|
6
23
|
|
|
7
24
|
There's two modes this library can be used. One is in runtime, by the @velastack/cli. The VelaStack CLI uses
|
|
@@ -137,7 +154,7 @@ configures vitest nowhere, the `vitest.config.ts` that loads it, both reported a
|
|
|
137
154
|
lists in `components` is handed to `shadcn-svelte add`, which resolves it from the style-scoped registry
|
|
138
155
|
(`/registry/styles/<style>/`) named by the project's `components.json`.
|
|
139
156
|
|
|
140
|
-
- `customDependencies` must list every
|
|
157
|
+
- `customDependencies` must list every `#lib/components/ui/<x>/index.js` a shipped component imports, and
|
|
141
158
|
`customNpmPackages` every npm package no shadcn item installs for it.
|
|
142
159
|
- `data-table` is a local copy of `@tanstack/svelte-table`'s v9 adapter (`createTable`, `FlexRender`,
|
|
143
160
|
`renderComponent`) over `@tanstack/table-core` alone; `column-header`, `faceted-filter` and `pagination` type
|
|
@@ -181,10 +198,35 @@ npm run test:integration -- integration/enable.test.ts # one suite
|
|
|
181
198
|
npm run test:integration -- integration/stacks.test.ts -t "teams" # one case
|
|
182
199
|
```
|
|
183
200
|
|
|
184
|
-
- `VELA_BIN=/path/to/vela` picks the CLI (default: `vela` on PATH).
|
|
201
|
+
- `VELA_BIN=/path/to/vela` picks the CLI (default: `vela` on PATH). Every `vela` command, `test:server`
|
|
202
|
+
included, runs through it, and the generated projects' own `vela` devDependency is dropped so it cannot shadow
|
|
203
|
+
the build under test.
|
|
185
204
|
- `INTEGRATION_KEEP=1` keeps generated projects; failed cases are always kept.
|
|
186
205
|
- `vela test:server` runs after each checked step in projects that have it; `INTEGRATION_SERVER_TESTS=0` skips it for a faster local loop.
|
|
187
206
|
- `STRIPE_SECRET_KEY` + `STRIPE_PUBLISHABLE_KEY` enable the payments cases; they skip otherwise.
|
|
207
|
+
- `node_modules` is installed once per dependency set and hard-linked into every project from
|
|
208
|
+
`.integration-tests/.cache`, except `node_modules/$app`, which SvelteKit's sync rewrites in place.
|
|
188
209
|
- Failures point at `.integration-tests/<suite>/<case>/.integration/` (`commands.log`, `steps.json`,
|
|
189
210
|
the raw svelte-check output). Expected failures live in `integration/known-failures.ts`, scoped per
|
|
190
211
|
step or case, and turn into visible skips until they stop reproducing.
|
|
212
|
+
|
|
213
|
+
## Against an unreleased CLI
|
|
214
|
+
|
|
215
|
+
Patterns are applied from this checkout, but `vela create`, `vela sync` and `vela test:server` come from the CLI,
|
|
216
|
+
which loads its own installed copy of `@velastack/patterns`. To test a CLI branch with these patterns in it (sibling
|
|
217
|
+
checkouts assumed):
|
|
218
|
+
|
|
219
|
+
```sh
|
|
220
|
+
npm run build && npm pack # here: velastack-patterns-<version>.tgz
|
|
221
|
+
cd ../velastack-cli
|
|
222
|
+
npm install ../velastack-patterns/velastack-patterns-*.tgz # or ../velastack-patterns
|
|
223
|
+
npm run build # dist/bin.js
|
|
224
|
+
cd ../velastack-patterns
|
|
225
|
+
rm -rf .integration-tests/.cache # caches from an older harness or template
|
|
226
|
+
VELA_BIN="$PWD/../velastack-cli/dist/bin.js" npm run test:integration -- integration/enable.test.ts
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The install rewrites the CLI's `package.json` and lockfile; restore them before committing there. In CI, run the
|
|
230
|
+
CI workflow by hand with `vela_ref` set to a branch, tag or SHA of `velastack/vela`: the integration job does the
|
|
231
|
+
same steps and exports `VELA_BIN`. Without `vela_ref` it installs the newest published `vela` that scaffolds
|
|
232
|
+
SvelteKit 3 (`latest`, then `next`), and skips the suites with a warning when there is none.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
|
+
import { i as t, o as n, r } from "./ts-morph-helpers-CDW4lhox.js";
|
|
3
|
+
import { t as i } from "./package-imports-Bbw3iMPg.js";
|
|
4
|
+
import a from "node:fs";
|
|
5
|
+
import o from "node:path";
|
|
6
|
+
import { Project as s, QuoteKind as c } from "ts-morph";
|
|
7
|
+
//#region src/patterns/enable/i18n/modifies/package-imports.ts
|
|
8
|
+
var l = { "#locales/*": "./src/locales/*" };
|
|
9
|
+
function u(e) {
|
|
10
|
+
return i(e, l);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/patterns/enable/i18n/modifies/+layout.ts
|
|
14
|
+
var d = e`
|
|
15
|
+
import { browser } from '$app/env';
|
|
16
|
+
import { loadLocale } from 'wuchale/load-utils';
|
|
17
|
+
|
|
18
|
+
import { getLocale } from '#locales/main.url.js';
|
|
19
|
+
import '#locales/main.loader.svelte.js';
|
|
20
|
+
import '#locales/js.loader.js';
|
|
21
|
+
`, f = e`
|
|
22
|
+
export const load = async ({ url, data }) => {
|
|
23
|
+
const locale = getLocale(url);
|
|
24
|
+
|
|
25
|
+
if (browser) {
|
|
26
|
+
await loadLocale(locale);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
};
|
|
31
|
+
`, p = `${d}\n\n${f}`, m = [
|
|
32
|
+
"Merge the wuchale loader into your existing load function in +layout.ts:",
|
|
33
|
+
"",
|
|
34
|
+
p
|
|
35
|
+
].join("\n");
|
|
36
|
+
function h(e) {
|
|
37
|
+
if (!a.existsSync(e)) return a.mkdirSync(o.dirname(e), { recursive: !0 }), a.writeFileSync(e, p + "\n"), {
|
|
38
|
+
status: "success",
|
|
39
|
+
changed: !0
|
|
40
|
+
};
|
|
41
|
+
let i = a.readFileSync(e, "utf8");
|
|
42
|
+
if (i.includes("loadLocale") || i.includes("translateUrl")) return {
|
|
43
|
+
status: "success",
|
|
44
|
+
changed: !1
|
|
45
|
+
};
|
|
46
|
+
if (/\bexport\s+(const|function)\s+load\b/.test(i)) return {
|
|
47
|
+
status: "failed",
|
|
48
|
+
message: m
|
|
49
|
+
};
|
|
50
|
+
let l = new s({
|
|
51
|
+
compilerOptions: { allowJs: !0 },
|
|
52
|
+
manipulationSettings: { quoteKind: c.Single }
|
|
53
|
+
}).addSourceFileAtPath(e);
|
|
54
|
+
return t(l, "$app/env", "browser"), t(l, "wuchale/load-utils", "loadLocale"), t(l, "#locales/main.url.js", "getLocale"), r(l, [{ moduleSpecifier: "#locales/main.loader.svelte.js" }, { moduleSpecifier: "#locales/js.loader.js" }]), l.addStatements(`\n${f}\n`), n(l), l.saveSync(), {
|
|
55
|
+
status: "success",
|
|
56
|
+
changed: !0
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { u as i, h as n, l as r, f as t };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=_layout-kkgN0IF7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_layout-kkgN0IF7.js","names":["dedent","ensureNamedImport","formatLikeSource","ensurePackageImports","fs","path","LOCALES_IMPORTS","modifyPackageImportsI18n","root","IMPORT_SNIPPET","LOAD_STATEMENT","LOAD_SNIPPET","FAILURE_HINT","ensureRootLayoutI18n","layoutPath","existing","sourceFile","Project","QuoteKind","ensureImports"],"sources":["../../src/patterns/enable/i18n/modifies/package-imports.ts","../../src/patterns/enable/i18n/modifies/+layout.ts"],"sourcesContent":["import {\n ensurePackageImports,\n type PackageJsonEditResult,\n} from \"../../../../runtime/package-imports\";\n\n/**\n * The package.json `imports` entry the app's `#locales/*.js` specifiers\n * resolve through. wuchale writes its loaders and data to `src/locales`;\n * SvelteKit 3 deprecates `alias`, so the directory is mapped the way `#lib`\n * is. wuchale's own generated imports are relative and never go through it.\n */\nexport const LOCALES_IMPORTS = { \"#locales/*\": \"./src/locales/*\" };\n\n/** Add `#locales/*` to package.json `imports`; a different value already there is reported. */\nexport function modifyPackageImportsI18n(root: string): PackageJsonEditResult {\n return ensurePackageImports(root, LOCALES_IMPORTS);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureImports,\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst IMPORT_SNIPPET = dedent`\n import { browser } from '$app/env';\n import { loadLocale } from 'wuchale/load-utils';\n\n import { getLocale } from '#locales/main.url.js';\n import '#locales/main.loader.svelte.js';\n import '#locales/js.loader.js';\n`;\n\n/** The load `disable-i18n` looks for to take it out again. */\nexport const LOAD_STATEMENT = dedent`\n export const load = async ({ url, data }) => {\n const locale = getLocale(url);\n\n if (browser) {\n await loadLocale(locale);\n }\n\n return data;\n };\n`;\n\n/** The whole file, for a project that had no root `+layout.ts`. */\nexport const LOAD_SNIPPET = `${IMPORT_SNIPPET}\\n\\n${LOAD_STATEMENT}`;\n\nconst FAILURE_HINT = [\n \"Merge the wuchale loader into your existing load function in +layout.ts:\",\n \"\",\n LOAD_SNIPPET,\n].join(\"\\n\");\n\nexport function ensureRootLayoutI18n(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n fs.mkdirSync(path.dirname(layoutPath), { recursive: true });\n fs.writeFileSync(layoutPath, LOAD_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const existing = fs.readFileSync(layoutPath, \"utf8\");\n if (existing.includes(\"loadLocale\") || existing.includes(\"translateUrl\")) {\n return { status: \"success\", changed: false };\n }\n\n if (/\\bexport\\s+(const|function)\\s+load\\b/.test(existing)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // No load to merge with, but the file may hold other route options\n // (`export const prerender = true`, say), so the load is added to it\n // rather than written over it.\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n ensureNamedImport(sourceFile, \"$app/env\", \"browser\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils\", \"loadLocale\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"getLocale\");\n ensureImports(sourceFile, [\n { moduleSpecifier: \"#locales/main.loader.svelte.js\" },\n { moduleSpecifier: \"#locales/js.loader.js\" },\n ]);\n\n sourceFile.addStatements(`\\n${LOAD_STATEMENT}\\n`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;;;;;;AAWA,IAAaM,IAAkB,EAAE,cAAc,kBAAkB;AAGjE,SAAgBC,EAAyB,GAAqC;CAC5E,OAAOJ,EAAqBK,GAAMF,CAAe;AACnD;;;ACLA,IAAMG,IAAiB,CAAM;;;;;;;GAUhBC,IAAiB,CAAM;;;;;;;;;;GAavBC,IAAe,GAAGF,EAAe,MAAMC,KAE9CE,IAAe;CACnB;CACA;CACAD;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgBE,EAAqB,GAAmC;CACtE,IAAI,CAACT,EAAG,WAAWU,CAAU,GAG3B,OAFAV,EAAG,UAAUC,EAAK,QAAQS,CAAU,GAAG,EAAE,WAAW,GAAK,CAAC,GAC1DV,EAAG,cAAcU,GAAYH,IAAe,IAAI,GACzC;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMI,IAAWX,EAAG,aAAaU,GAAY,MAAM;CACnD,IAAIC,EAAS,SAAS,YAAY,KAAKA,EAAS,SAAS,cAAc,GACrE,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAI,uCAAuC,KAAKA,CAAQ,GACtD,OAAO;EAAE,QAAQ;EAAU,SAASH;CAAa;CAUnD,IAAMI,IAAa,IAJCC,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBJ,CAAU;CAazD,OAXAb,EAAkBe,GAAY,YAAY,SAAS,GACnDf,EAAkBe,GAAY,sBAAsB,YAAY,GAChEf,EAAkBe,GAAY,wBAAwB,WAAW,GACjEG,EAAcH,GAAY,CACxB,EAAE,iBAAiB,iCAAiC,GACpD,EAAE,iBAAiB,wBAAwB,CAC7C,CAAC,GAEDA,EAAW,cAAc,KAAKN,EAAe,GAAG,GAChDR,EAAiBc,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./errors-DR3gF_7a.js";
|
|
2
2
|
import { a as t } from "./util-BLYliuUK.js";
|
|
3
3
|
import { n, t as r } from "./logger-CQONztPm.js";
|
|
4
|
-
import { i, n as a, t as o } from "./pocketbase-
|
|
4
|
+
import { i, n as a, t as o } from "./pocketbase-Dry6ry17.js";
|
|
5
5
|
import { readFileSync as s } from "node:fs";
|
|
6
6
|
//#region src/runtime/collections.ts
|
|
7
7
|
function c(e) {
|
|
@@ -189,4 +189,4 @@ async function y(e, r) {
|
|
|
189
189
|
//#endregion
|
|
190
190
|
export { m as applyCollectionFieldsPatches, f as applyCollectionRulePatches, u as createCollectionIdempotent, y as createCollections, v as dropCollections, _ as planCollectionDrops };
|
|
191
191
|
|
|
192
|
-
//# sourceMappingURL=collections-
|
|
192
|
+
//# sourceMappingURL=collections-Dz2fvKnz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections-Dz2fvKnz.js","names":["InvalidArgumentError","languageFromPath","NOOP_LOGGER","migrationDelay","getMigrationFile","isCollectionAlreadyExistsError","error","message","resolveRelationTargets","fields","spec","relations","field","existing","pb","ids","c","byName","id","createCollectionIdempotent","name","logger","rulePayloadFromPatch","payload","patch","applyCollectionRulePatches","migrations","patches","escaped","col","options","migrationFile","readFileSync","applyFieldChanges","change","f","index","applyCollectionFieldsPatches","collection","newFields","dropCollectionIdempotent","getCollectionStats","planCollectionDrops","plans","names","stats","dropCollections","specs","getLogger","withPocketbase","dropped","createCollections","collections","created"],"sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type PocketBase from \"pocketbase\";\nimport type { CollectionModel } from \"pocketbase\";\nimport type {\n CollectionDropSpec,\n CollectionFieldSpec,\n CollectionFieldsPatch,\n CollectionRulesPatch,\n CollectionSpec,\n File,\n Options,\n} from \"../core/types\";\nimport { InvalidArgumentError } from \"../core/errors\";\nimport { getLogger, NOOP_LOGGER, type Logger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, migrationDelay, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (\n error.response?.data?.name?.code === \"validation_collection_name_exists\"\n ) {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return (\n message.includes(\"already exists\") || message.includes(\"must be unique\")\n );\n}\n\ntype CollectionCreateInput = Parameters<PocketBase[\"collections\"][\"create\"]>[0];\n\ninterface RelationFieldLike {\n type?: string;\n collectionId?: string;\n}\n\n/**\n * A spec may name the collection a relation points at (`stripe_customers`)\n * where PocketBase wants its id; specs read better by name, and the id is\n * only known once the target exists. Names are swapped for ids here, and a\n * value that already is an id (`_pb_users_auth_`) is left alone.\n */\nasync function resolveRelationTargets(\n pb: PocketBase,\n spec: CollectionCreateInput,\n): Promise<CollectionCreateInput> {\n const fields = (spec as { fields?: RelationFieldLike[] }).fields;\n const relations = (fields ?? []).filter(\n (field) => field.type === \"relation\" && field.collectionId,\n );\n if (relations.length === 0) return spec;\n\n const existing = await pb.collections.getFullList();\n const ids = new Set(existing.map((c) => c.id));\n const byName = new Map(existing.map((c) => [c.name, c.id]));\n if (relations.every((field) => ids.has(field.collectionId!))) return spec;\n\n return {\n ...spec,\n fields: fields!.map((field) => {\n if (field.type !== \"relation\" || !field.collectionId) return field;\n const id = byName.get(field.collectionId);\n return id && !ids.has(field.collectionId)\n ? { ...field, collectionId: id }\n : field;\n }),\n } as CollectionCreateInput;\n}\n\nexport interface CreateCollectionResult {\n collection: CollectionModel;\n created: boolean;\n}\n\n/**\n * Idempotent wrapper around `pb.collections.create`. If the collection already\n * exists, logs and returns the existing model with `created: false` so callers\n * can skip work tied to a fresh create (e.g. appending a newly-generated\n * migration file to the result).\n */\nexport async function createCollectionIdempotent(\n pb: PocketBase,\n spec: CollectionCreateInput,\n logger: Logger = NOOP_LOGGER,\n): Promise<CreateCollectionResult> {\n const name = (spec as { name: string }).name;\n try {\n const collection = await pb.collections.create(\n await resolveRelationTargets(pb, spec),\n );\n return { collection, created: true };\n } catch (error) {\n if (\n !isCollectionAlreadyExistsError(error as PocketBaseCollectionCreateError)\n ) {\n throw error;\n }\n logger.info(`Collection \"${name}\" already exists, skipping`);\n const collection = await pb.collections.getOne(name);\n return { collection, created: false };\n }\n}\n\nfunction rulePayloadFromPatch(\n patch: CollectionRulesPatch,\n): Record<string, unknown> {\n const payload: Record<string, unknown> = {};\n if (patch.listRule !== undefined) payload.listRule = patch.listRule;\n if (patch.viewRule !== undefined) payload.viewRule = patch.viewRule;\n if (patch.createRule !== undefined) payload.createRule = patch.createRule;\n if (patch.updateRule !== undefined) payload.updateRule = patch.updateRule;\n if (patch.deleteRule !== undefined) payload.deleteRule = patch.deleteRule;\n return payload;\n}\n\n/**\n * Applies API rule updates in array order. Call after all referenced collections exist.\n * Collects migration files produced by each update when `options` is provided.\n */\nexport async function applyCollectionRulePatches(\n pb: {\n collections: {\n getFirstListItem: (filter: string) => Promise<{ id: string }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionRulesPatch[],\n options?: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const escaped = patch.collectionName.replace(/'/g, \"''\");\n const col = await pb.collections.getFirstListItem(`name='${escaped}'`);\n logger.info(`Updating rules on collection \"${patch.collectionName}\"`);\n await pb.collections.update(col.id, rulePayloadFromPatch(patch));\n await migrationDelay();\n\n if (options) {\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (migrationFile) {\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n }\n }\n\n return migrations;\n}\n\nfunction applyFieldChanges(\n existing: CollectionFieldSpec[],\n patch: CollectionFieldsPatch,\n): CollectionFieldSpec[] {\n const fields = existing.map((field) => ({ ...field }));\n\n for (const change of patch.changes) {\n if (change.op === \"add\") {\n if (fields.some((f) => f.name === change.field.name)) {\n throw new InvalidArgumentError(\n `Field \"${change.field.name}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n fields.push(change.field);\n continue;\n }\n if (change.op === \"remove\") {\n const index = fields.findIndex((f) => f.name === change.fieldName);\n if (index === -1) {\n throw new InvalidArgumentError(\n `Field \"${change.fieldName}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n fields.splice(index, 1);\n continue;\n }\n if (change.op === \"rename\") {\n const field = fields.find((f) => f.name === change.from);\n if (!field) {\n throw new InvalidArgumentError(\n `Field \"${change.from}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n if (fields.some((f) => f.name === change.to)) {\n throw new InvalidArgumentError(\n `Field \"${change.to}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n field.name = change.to;\n continue;\n }\n }\n\n return fields;\n}\n\nexport async function applyCollectionFieldsPatches(\n pb: {\n collections: {\n getOne: (\n name: string,\n ) => Promise<{ id: string; fields: CollectionFieldSpec[] }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionFieldsPatch[],\n options: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const collection = await pb.collections.getOne(patch.collectionName);\n const newFields = applyFieldChanges(collection.fields, patch);\n logger.info(`Updating fields on collection \"${patch.collectionName}\"`);\n await pb.collections.update(collection.id, { fields: newFields });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n\n return migrations;\n}\n\nexport interface DropCollectionResult {\n dropped: boolean;\n existed: boolean;\n}\n\n/**\n * Idempotent collection drop. Returns `{ existed: false, dropped: false }` if\n * the collection is already gone, matching the idempotency contract of\n * `createCollectionIdempotent`.\n */\nexport async function dropCollectionIdempotent(\n pb: PocketBase,\n name: string,\n logger: Logger = NOOP_LOGGER,\n): Promise<DropCollectionResult> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n logger.info(`Collection \"${name}\" does not exist, skipping drop`);\n return { dropped: false, existed: false };\n }\n throw error;\n }\n await pb.collections.delete(name);\n return { dropped: true, existed: true };\n}\n\nexport interface CollectionStats {\n exists: boolean;\n rowCount: number;\n}\n\nexport async function getCollectionStats(\n pb: PocketBase,\n name: string,\n): Promise<CollectionStats> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n return { exists: false, rowCount: 0 };\n }\n throw error;\n }\n\n try {\n const result = await pb\n .collection(name)\n .getList(1, 1, { skipTotal: false });\n return { exists: true, rowCount: result.totalItems };\n } catch {\n return { exists: true, rowCount: 0 };\n }\n}\n\n/**\n * Resolve the set of collections to drop, with current row counts. Missing\n * collections are included with `exists: false, rowCount: 0` so callers can\n * display the full reversal plan even when some collections were already gone.\n */\nexport async function planCollectionDrops(\n pb: PocketBase,\n names: string[],\n): Promise<CollectionDropSpec[]> {\n const plans: CollectionDropSpec[] = [];\n for (const name of names) {\n const stats = await getCollectionStats(pb, name);\n plans.push({ name, exists: stats.exists, rowCount: stats.rowCount });\n }\n return plans;\n}\n\n/**\n * Drop each of the given collections (skipping those that are already gone)\n * and collect the `_deleted_<name>.js` migration file PocketBase emits for\n * each successful drop. Symmetric to `createCollections`.\n */\nexport async function dropCollections(\n specs: CollectionDropSpec[],\n options: Options,\n): Promise<File[]> {\n if (specs.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const spec of specs) {\n logger.info(`Dropping collection \"${spec.name}\"`);\n const { dropped } = await dropCollectionIdempotent(pb, spec.name, logger);\n if (!dropped) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(spec.name, \"deleted\", options);\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n logger.info(`Creating collection \"${collection.name}\"`);\n const { created } = await createCollectionIdempotent(\n pb,\n collection,\n logger,\n );\n if (!created) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n collection.name,\n \"created\",\n options,\n );\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n"],"mappings":";;;;;;AA4BA,SAASK,EACP,GACS;CACT,IACEC,EAAM,UAAU,MAAM,MAAM,SAAS,qCAErC,OAAO;CAGT,IAAMC,IAAUD,EAAM,SAAS,YAAY,KAAK;CAChD,OACEC,EAAQ,SAAS,gBAAgB,KAAKA,EAAQ,SAAS,gBAAgB;AAE3E;AAeA,eAAeC,EACb,GACA,GACgC;CAChC,IAAMC,IAAUC,EAA0C,QACpDC,KAAaF,KAAU,CAAC,EAAA,CAAG,QAC9B,MAAUG,EAAM,SAAS,cAAcA,EAAM,YAChD;CACA,IAAID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GAAe,MAAM;IAC3C,QAAQ;GACV,CAAC;EACH;CACF,CAAC,GAEML;AACT;AAEA,eAAsByB,EACpB,GACA,GACiB;CACjB,IAAIC,EAAY,WAAW,GACzB,OAAO,CAAC;CAGV,IAAM1B,IAAqB,CAAC,GACtBL,IAAS2B,EAAUlB,CAAO;CA+BhC,OA7BA,MAAMmB,EAAenB,EAAQ,MAAM,OAAO,MAAO;EAC/C,KAAK,IAAMQ,KAAcc,GAAa;GACpC,EAAO,KAAK,wBAAwBd,EAAW,KAAK,EAAE;GACtD,IAAM,EAAE,eAAY,MAAMnB,EACxBL,GACAwB,GACAjB,CACF;GACA,IAAI,CAACgC,GAAS;GACd,MAAMlD,EAAe;GAErB,IAAM4B,IAAgB3B,EACpBkC,EAAW,MACX,WACAR,CACF;GACA,AAAKC,KAILL,EAAW,KAAK;IACd,MAAMK;IACN,UAAU9B,EAAiB8B,CAAa;IACxC,SAASC,EAAaD,GAAe,MAAM;IAC3C,QAAQ;GACV,CAAC;EACH;CACF,CAAC,GAEML;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as e, l as t, m as n, n as r } from "./ts-morph-helpers-
|
|
1
|
+
import { d as e, l as t, m as n, n as r } from "./ts-morph-helpers-CDW4lhox.js";
|
|
2
2
|
import { Node as i, SyntaxKind as a, ts as o } from "ts-morph";
|
|
3
3
|
//#region src/runtime/compose-handle.ts
|
|
4
4
|
var s = "@sveltejs/kit/hooks", c = "handleApp";
|
|
@@ -74,8 +74,14 @@ function f(e, t) {
|
|
|
74
74
|
}
|
|
75
75
|
function p(e, t) {
|
|
76
76
|
if (t.local || t.namespace) return;
|
|
77
|
-
let n = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === s && !e.isTypeOnly() && !e.getNamespaceImport());
|
|
78
|
-
n
|
|
77
|
+
let n = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === s && !e.isTypeOnly() && !e.getNamespaceImport()), r = n ? void 0 : e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === s && e.isTypeOnly() && !e.getDefaultImport() && !e.getNamespaceImport());
|
|
78
|
+
if (n) n.addNamedImport("sequence");
|
|
79
|
+
else if (r) {
|
|
80
|
+
let e = r.getNamedImports();
|
|
81
|
+
r.setIsTypeOnly(!1);
|
|
82
|
+
for (let t of e) t.setIsTypeOnly(!0);
|
|
83
|
+
r.insertNamedImport(0, "sequence");
|
|
84
|
+
} else e.addImportDeclaration({
|
|
79
85
|
namedImports: ["sequence"],
|
|
80
86
|
moduleSpecifier: s
|
|
81
87
|
});
|
|
@@ -319,4 +325,4 @@ function R(e, n, r) {
|
|
|
319
325
|
//#endregion
|
|
320
326
|
export { L as n, R as r, F as t };
|
|
321
327
|
|
|
322
|
-
//# sourceMappingURL=compose-handle-
|
|
328
|
+
//# sourceMappingURL=compose-handle-D_Rz3Fzo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-handle-D_Rz3Fzo.js","names":["removeNamedImportIfUnused","removeAttachedComments","removeStatementWithComments","ensureBlankLineAfterImports","KIT_HOOKS","EXTRACTED","locate","exportedBySpecifier","starExport","ed","sf","fromModule","spec","fn","f","statement","decl","nameNode","Node","SyntaxKind","el","kitSequence","found","namespace","named","isBound","name","d","sequenceCallee","kit","ensureSequenceImport","typeOnly","names","pruneSequenceImport","wasRemoved","isSequenceCall","node","callee","unwrap","isHandle","findInSequence","args","index","arg","inner","references","id","commentTexts","ranges","text","r","pieces","call","openParen","closeParen","result","leadingFrom","prevTrailing","ts","leading","comma","trailing","last","lastArg","from","sameLine","dangling","hasComments","list","p","renderCall","multiline","c","renderAlone","piece","isMultiline","i","rewriteSequence","handleStatement","site","currentStatement","located","changed","unchanged","unsupported","removeWholeHandle","viaSpecifier","s","extract","composed","restoreExtracted","init","variable","decls","target","inlineExport","addHandle","position","blank","extractChecked","core","existing","a","removeHandle","calls","outer","kept","comments","replaceHandle","newName"],"sources":["../../src/runtime/compose-handle.ts"],"sourcesContent":["import {\n Node,\n SyntaxKind,\n ts,\n type CallExpression,\n type Expression,\n type FunctionDeclaration,\n type SourceFile,\n type Statement,\n type VariableDeclaration,\n type VariableStatement,\n} from \"ts-morph\";\nimport {\n ensureBlankLineAfterImports,\n removeAttachedComments,\n removeNamedImportIfUnused,\n removeStatementWithComments,\n} from \"./ts-morph-helpers\";\n\n/**\n * Composes the server `handle` hook in `hooks.server.ts`.\n *\n * Patterns add and subtract handles in the exported `handle` without caring\n * what shape it is in: a lone expression becomes `sequence(new, old)`, a\n * `sequence(...)` gains or loses an argument, and a handle that is a function\n * is moved to a local `handleApp` so it can take part. Subtracting back to one\n * handle unwraps the `sequence` again, and puts a `handleApp` back the way it\n * was written, so enabling then disabling a pattern round-trips.\n *\n * Nothing here formats or saves: callers do, as they always have. A result of\n * `unsupported` means the file was left exactly as it was found.\n */\n\nconst KIT_HOOKS = \"@sveltejs/kit/hooks\";\nconst EXTRACTED = \"handleApp\";\n\nexport interface HandleSpec {\n /** Source text of the sequence argument: `handleWuchale`, `handlePocketbase({ ... })`. */\n expression: string;\n /** Identifier, or callee identifier, that marks this handle. Defaults to `expression`. */\n name?: string;\n /** Where it goes in the chain. */\n position?: \"first\" | \"last\";\n}\n\nexport type Unsupported =\n /** `export { handle } from '…'`, `export { x as handle }`, or `export *` with no local handle. */\n | \"re-export\"\n /** A local `handle` SvelteKit cannot see. */\n | \"not-exported\"\n /** `export const { handle } = …` */\n | \"destructured\"\n /** `export default function handle` */\n | \"default-export\"\n /** `export let handle;` */\n | \"no-initializer\"\n /** A `sequence` in scope that is not `@sveltejs/kit/hooks`'. */\n | \"foreign-sequence\"\n /** The handle has to move to `handleApp`, and the name is taken. */\n | \"name-collision\"\n /** The handle has to move to `handleApp`, and shares its statement with other declarations. */\n | \"multi-declarator\"\n /** The handle is referenced outside the composition (`dev ? a : handleX`, or inside a function handle). */\n | \"ambiguous-reference\";\n\nexport type ComposeResult =\n /** `statement` is the `handle` declaration, when there still is one. */\n | { status: \"changed\"; statement?: Statement }\n | { status: \"unchanged\"; statement?: Statement }\n | { status: \"unsupported\"; reason: Unsupported };\n\ntype Site =\n | {\n kind: \"variable\";\n decl: VariableDeclaration;\n statement: VariableStatement;\n inlineExport: boolean;\n }\n | { kind: \"function\"; fn: FunctionDeclaration; inlineExport: boolean };\n\ntype Located =\n { site: Site | null; starExport: boolean } | { unsupported: Unsupported };\n\n/** A `sequence(...)` argument with the comments that belong to it. */\ninterface Piece {\n leading: string[];\n text: string;\n trailing: string[];\n}\n\n/** How `sequence` from `@sveltejs/kit/hooks` is bound in this file, if at all. */\ninterface KitSequence {\n local: string | null;\n namespace: string | null;\n}\n\n/** Find the exported `handle`, or say why it cannot be composed. */\nfunction locate(sf: SourceFile): Located {\n let exportedBySpecifier = false;\n let starExport = false;\n\n for (const ed of sf.getExportDeclarations()) {\n const fromModule = ed.getModuleSpecifier() !== undefined;\n if (ed.isNamespaceExport()) {\n if (ed.getNamespaceExport()?.getName() === \"handle\") {\n return { unsupported: \"re-export\" };\n }\n if (fromModule) starExport = true;\n continue;\n }\n for (const spec of ed.getNamedExports()) {\n const exported = spec.getAliasNode()?.getText() ?? spec.getName();\n if (exported !== \"handle\") continue;\n if (fromModule || spec.getName() !== \"handle\") {\n return { unsupported: \"re-export\" };\n }\n exportedBySpecifier = true;\n }\n }\n\n const fn = sf.getFunctions().find((f) => f.getName() === \"handle\");\n if (fn) {\n if (fn.isDefaultExport()) return { unsupported: \"default-export\" };\n if (!fn.hasExportKeyword() && !exportedBySpecifier) {\n return { unsupported: \"not-exported\" };\n }\n return {\n site: { kind: \"function\", fn, inlineExport: fn.hasExportKeyword() },\n starExport,\n };\n }\n\n for (const statement of sf.getVariableStatements()) {\n for (const decl of statement.getDeclarations()) {\n const nameNode = decl.getNameNode();\n if (!Node.isIdentifier(nameNode)) {\n const bindsHandle = nameNode\n .getDescendantsOfKind(SyntaxKind.BindingElement)\n .some((el) => el.getNameNode().getText() === \"handle\");\n if (bindsHandle) return { unsupported: \"destructured\" };\n continue;\n }\n if (nameNode.getText() !== \"handle\") continue;\n if (!statement.hasExportKeyword() && !exportedBySpecifier) {\n return { unsupported: \"not-exported\" };\n }\n if (!decl.getInitializer()) return { unsupported: \"no-initializer\" };\n return {\n site: {\n kind: \"variable\",\n decl,\n statement,\n inlineExport: statement.hasExportKeyword(),\n },\n starExport,\n };\n }\n }\n\n // `export { handle }` naming something that is not a local variable or\n // function: an import passed straight through, or a class.\n if (exportedBySpecifier) return { unsupported: \"re-export\" };\n return { site: null, starExport };\n}\n\nfunction kitSequence(sf: SourceFile): KitSequence {\n const found: KitSequence = { local: null, namespace: null };\n for (const decl of sf.getImportDeclarations()) {\n if (decl.getModuleSpecifierValue() !== KIT_HOOKS || decl.isTypeOnly()) {\n continue;\n }\n const namespace = decl.getNamespaceImport();\n if (namespace) found.namespace = namespace.getText();\n for (const named of decl.getNamedImports()) {\n if (named.getName() !== \"sequence\" || named.isTypeOnly()) continue;\n found.local = named.getAliasNode()?.getText() ?? \"sequence\";\n }\n }\n return found;\n}\n\n/** Whether `name` is declared at the top level or imported. */\nfunction isBound(sf: SourceFile, name: string): boolean {\n for (const decl of sf.getImportDeclarations()) {\n if (decl.getDefaultImport()?.getText() === name) return true;\n if (decl.getNamespaceImport()?.getText() === name) return true;\n for (const named of decl.getNamedImports()) {\n if ((named.getAliasNode()?.getText() ?? named.getName()) === name) {\n return true;\n }\n }\n }\n if (sf.getFunction(name) || sf.getClass(name) || sf.getEnum(name)) {\n return true;\n }\n return sf.getVariableDeclarations().some((d) => {\n const nameNode = d.getNameNode();\n if (Node.isIdentifier(nameNode)) return nameNode.getText() === name;\n return nameNode\n .getDescendantsOfKind(SyntaxKind.BindingElement)\n .some((el) => el.getNameNode().getText() === name);\n });\n}\n\n/** The callee to write for a new `sequence(...)`, or null when none can be had. */\nfunction sequenceCallee(sf: SourceFile, kit: KitSequence): string | null {\n if (kit.local) return kit.local;\n if (kit.namespace) return `${kit.namespace}.sequence`;\n return isBound(sf, \"sequence\") ? null : \"sequence\";\n}\n\nfunction ensureSequenceImport(sf: SourceFile, kit: KitSequence): void {\n if (kit.local || kit.namespace) return;\n const decl = sf\n .getImportDeclarations()\n .find(\n (d) =>\n d.getModuleSpecifierValue() === KIT_HOOKS &&\n !d.isTypeOnly() &&\n !d.getNamespaceImport(),\n );\n // `import type { Handle } from '@sveltejs/kit/hooks'` takes `sequence` in:\n // `import { sequence, type Handle }`.\n const typeOnly = decl\n ? undefined\n : sf\n .getImportDeclarations()\n .find(\n (d) =>\n d.getModuleSpecifierValue() === KIT_HOOKS &&\n d.isTypeOnly() &&\n !d.getDefaultImport() &&\n !d.getNamespaceImport(),\n );\n if (decl) decl.addNamedImport(\"sequence\");\n else if (typeOnly) {\n const names = typeOnly.getNamedImports();\n typeOnly.setIsTypeOnly(false);\n for (const named of names) named.setIsTypeOnly(true);\n typeOnly.insertNamedImport(0, \"sequence\");\n } else {\n sf.addImportDeclaration({\n namedImports: [\"sequence\"],\n moduleSpecifier: KIT_HOOKS,\n });\n }\n}\n\nfunction pruneSequenceImport(sf: SourceFile): void {\n // ts-morph takes the blank line after the imports with a removed import.\n const { wasRemoved } = removeNamedImportIfUnused(sf, KIT_HOOKS, \"sequence\");\n if (wasRemoved) ensureBlankLineAfterImports(sf);\n}\n\nfunction isSequenceCall(node: Node, kit: KitSequence): node is CallExpression {\n if (!Node.isCallExpression(node)) return false;\n const callee = node.getExpression();\n if (Node.isIdentifier(callee)) return callee.getText() === kit.local;\n if (Node.isPropertyAccessExpression(callee)) {\n return (\n kit.namespace !== null &&\n callee.getExpression().getText() === kit.namespace &&\n callee.getName() === \"sequence\"\n );\n }\n return false;\n}\n\n/** Strip `( )`, `satisfies T`, `as T`, `<T>` and `!` down to the composition. */\nfunction unwrap(node: Expression): Expression {\n for (;;) {\n if (\n Node.isParenthesizedExpression(node) ||\n Node.isSatisfiesExpression(node) ||\n Node.isAsExpression(node) ||\n Node.isTypeAssertion(node) ||\n Node.isNonNullExpression(node)\n ) {\n node = node.getExpression();\n } else {\n return node;\n }\n }\n}\n\n/** `name`, or a call of `name`: `handleWuchale`, `handlePocketbase({ ... })`. */\nfunction isHandle(node: Node, name: string): boolean {\n if (Node.isIdentifier(node)) return node.getText() === name;\n if (Node.isCallExpression(node)) {\n const callee = node.getExpression();\n return Node.isIdentifier(callee) && callee.getText() === name;\n }\n return false;\n}\n\n/** The chain of `sequence` calls down to the argument that is `name`. */\nfunction findInSequence(\n node: Node,\n name: string,\n kit: KitSequence,\n): { calls: CallExpression[]; index: number } | null {\n if (!isSequenceCall(node, kit)) return null;\n const args = node.getArguments();\n const index = args.findIndex((arg) => isHandle(arg, name));\n if (index >= 0) return { calls: [node], index };\n for (const arg of args) {\n const inner = findInSequence(arg, name, kit);\n if (inner) return { calls: [node, ...inner.calls], index: inner.index };\n }\n return null;\n}\n\nfunction references(node: Node, name: string): boolean {\n if (Node.isIdentifier(node) && node.getText() === name) return true;\n return node\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((id) => id.getText() === name);\n}\n\nfunction commentTexts(text: string, ranges: ts.CommentRange[]): string[] {\n return ranges.map((r) => text.slice(r.pos, r.end));\n}\n\n/**\n * The arguments of a `sequence(...)` call, each with its comments. A comment\n * after an argument's comma on the same line is that argument's; comments on\n * the lines above an argument are its own too.\n */\nfunction pieces(call: CallExpression): Piece[] {\n const text = call.getSourceFile().getFullText();\n const args = call.getArguments();\n const openParen = call.getFirstChildByKindOrThrow(SyntaxKind.OpenParenToken);\n const closeParen = call.getLastChildByKindOrThrow(SyntaxKind.CloseParenToken);\n\n const result = args.map((arg, i): Piece => {\n let leadingFrom = openParen.getEnd();\n if (i > 0) {\n const prevComma = args[i - 1].getNextSiblingIfKind(SyntaxKind.CommaToken);\n leadingFrom = prevComma?.getEnd() ?? args[i - 1].getEnd();\n const prevTrailing = ts.getTrailingCommentRanges(text, leadingFrom);\n if (prevTrailing?.length) {\n leadingFrom = prevTrailing[prevTrailing.length - 1].end;\n }\n }\n const leading = (\n ts.getLeadingCommentRanges(text, leadingFrom) ?? []\n ).filter((r) => r.end <= arg.getStart());\n const comma = arg.getNextSiblingIfKind(SyntaxKind.CommaToken);\n const trailing =\n ts.getTrailingCommentRanges(text, comma?.getEnd() ?? arg.getEnd()) ?? [];\n return {\n leading: commentTexts(text, leading),\n text: arg.getText(),\n trailing: commentTexts(text, trailing),\n };\n });\n\n // Comments on their own lines just before `)` go with the last argument.\n const last = result[result.length - 1];\n if (last) {\n const lastArg = args[args.length - 1];\n let from =\n lastArg.getNextSiblingIfKind(SyntaxKind.CommaToken)?.getEnd() ??\n lastArg.getEnd();\n const sameLine = ts.getTrailingCommentRanges(text, from);\n if (sameLine?.length) from = sameLine[sameLine.length - 1].end;\n const dangling = (ts.getLeadingCommentRanges(text, from) ?? []).filter(\n (r) => r.end <= closeParen.getStart(),\n );\n last.trailing.push(...commentTexts(text, dangling));\n }\n return result;\n}\n\nfunction hasComments(list: Piece[]): boolean {\n return list.some((p) => p.leading.length > 0 || p.trailing.length > 0);\n}\n\nfunction renderCall(callee: string, list: Piece[], multiline: boolean): string {\n if (!multiline && !hasComments(list)) {\n return `${callee}(${list.map((p) => p.text).join(\", \")})`;\n }\n const lines = list.map((p) => {\n const leading = p.leading.map((c) => `${c}\\n`).join(\"\");\n const trailing = p.trailing.length ? ` ${p.trailing.join(\" \")}` : \"\";\n return `${leading}${p.text},${trailing}`;\n });\n return `${callee}(\\n${lines.join(\"\\n\")}\\n)`;\n}\n\n/** A lone argument taken out of a nested `sequence`: its comments go above it. */\nfunction renderAlone(piece: Piece): string {\n const comments = [...piece.leading, ...piece.trailing];\n return comments.map((c) => `${c}\\n`).join(\"\") + piece.text;\n}\n\nfunction isMultiline(call: CallExpression): boolean {\n return call\n .getArguments()\n .some((arg, i, args) =>\n i === 0\n ? false\n : arg.getStartLineNumber() !== args[i - 1].getEndLineNumber(),\n );\n}\n\nfunction rewriteSequence(call: CallExpression, list: Piece[]): Node {\n const multiline = isMultiline(call);\n return call.replaceWithText(\n renderCall(call.getExpression().getText(), list, multiline),\n );\n}\n\nfunction handleStatement(site: Site): Statement {\n return site.kind === \"function\" ? site.fn : site.statement;\n}\n\n/** The `handle` statement as it stands now; nodes go stale on every edit. */\nfunction currentStatement(sf: SourceFile): Statement | undefined {\n const located = locate(sf);\n if (\"unsupported\" in located || !located.site) return undefined;\n return handleStatement(located.site);\n}\n\nfunction changed(sf: SourceFile): ComposeResult {\n return { status: \"changed\", statement: currentStatement(sf) };\n}\n\nfunction unchanged(site: Site | null): ComposeResult {\n return {\n status: \"unchanged\",\n statement: site ? handleStatement(site) : undefined,\n };\n}\n\nfunction unsupported(reason: Unsupported): ComposeResult {\n return { status: \"unsupported\", reason };\n}\n\n/**\n * Take the whole `handle` out: its declarator, or its statement with the\n * comments above it, and an `export { handle }` naming it.\n */\nfunction removeWholeHandle(sf: SourceFile, site: Site): void {\n const viaSpecifier = !site.inlineExport;\n if (site.kind === \"variable\" && site.statement.getDeclarations().length > 1) {\n site.decl.remove();\n } else {\n removeStatementWithComments(sf, handleStatement(site));\n }\n if (!viaSpecifier) return;\n for (const ed of sf.getExportDeclarations()) {\n if (ed.getModuleSpecifier() !== undefined) continue;\n const spec = ed.getNamedExports().find((s) => s.getName() === \"handle\");\n if (!spec) continue;\n if (ed.getNamedExports().length === 1) ed.remove();\n else spec.remove();\n }\n}\n\n/**\n * Move a handle that is a function out of the way: rename it `handleApp`,\n * un-export it, and export `sequence(...)` of it right after, so `handleApp`\n * is declared before anything reads it.\n */\nfunction extract(\n sf: SourceFile,\n site: Site,\n spec: HandleSpec,\n callee: string,\n kit: KitSequence,\n): ComposeResult {\n const position = spec.position ?? \"first\";\n const args =\n position === \"first\"\n ? [spec.expression, EXTRACTED]\n : [EXTRACTED, spec.expression];\n const exportKeyword = site.inlineExport ? \"export \" : \"\";\n const composed = `${exportKeyword}const handle = ${callee}(${args.join(\", \")});`;\n\n if (site.kind === \"function\") {\n if (site.inlineExport) site.fn.setIsExported(false);\n sf.getFunctionOrThrow(\"handle\").getNameNode()!.replaceWithText(EXTRACTED);\n const fn = sf.getFunctionOrThrow(EXTRACTED);\n sf.insertText(fn.getEnd(), `\\n\\n${composed}`);\n } else {\n if (site.inlineExport) site.statement.setIsExported(false);\n sf.getVariableDeclarationOrThrow(\"handle\")\n .getNameNode()\n .replaceWithText(EXTRACTED);\n const statement = sf.getVariableStatementOrThrow(EXTRACTED);\n sf.insertText(statement.getEnd(), `\\n\\n${composed}`);\n }\n ensureSequenceImport(sf, kit);\n return changed(sf);\n}\n\n/**\n * After a `sequence` unwraps to `handleApp` alone, put the function back the\n * way `extract` found it: `handleApp` renamed to `handle` and exported, and\n * the `handle = handleApp` statement gone.\n */\nfunction restoreExtracted(sf: SourceFile): void {\n const located = locate(sf);\n if (\"unsupported\" in located || located.site?.kind !== \"variable\") return;\n const { decl, statement, inlineExport } = located.site;\n const init = decl.getInitializer();\n if (\n !init ||\n !Node.isIdentifier(init) ||\n init.getText() !== EXTRACTED ||\n decl.getTypeNode() ||\n statement.getDeclarations().length > 1\n ) {\n return;\n }\n\n const uses = sf\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .filter((id) => id.getText() === EXTRACTED);\n // Its declaration and the one use in `handle`.\n if (uses.length !== 2) return;\n\n const fn = sf.getFunction(EXTRACTED);\n const variable = sf.getVariableStatements().find((s) => {\n const decls = s.getDeclarations();\n return decls.length === 1 && decls[0].getName() === EXTRACTED;\n });\n const target = fn ?? variable;\n if (!target || target.hasExportKeyword()) return;\n\n statement.remove();\n if (fn) {\n const restored = sf.getFunctionOrThrow(EXTRACTED);\n restored.getNameNode()!.replaceWithText(\"handle\");\n if (inlineExport) sf.getFunctionOrThrow(\"handle\").setIsExported(true);\n } else {\n const restored = sf.getVariableDeclarationOrThrow(EXTRACTED);\n restored.getNameNode().replaceWithText(\"handle\");\n if (inlineExport) {\n sf.getVariableStatementOrThrow(\"handle\").setIsExported(true);\n }\n }\n}\n\n/**\n * Add a handle to the exported `handle`. Already present anywhere in the\n * composition: unchanged. No `handle` yet: `export const handle = <expression>`.\n */\nexport function addHandle(sf: SourceFile, spec: HandleSpec): ComposeResult {\n const name = spec.name ?? spec.expression;\n const position = spec.position ?? \"first\";\n const located = locate(sf);\n if (\"unsupported\" in located) return unsupported(located.unsupported);\n const { site } = located;\n const kit = kitSequence(sf);\n\n if (!site) {\n if (located.starExport) return unsupported(\"re-export\");\n const blank = sf.getStatementsWithComments().length > 0 ? \"\\n\" : \"\";\n sf.addStatements(`${blank}export const handle = ${spec.expression};`);\n return changed(sf);\n }\n\n if (site.kind === \"function\") {\n if (references(site.fn, name)) return unsupported(\"ambiguous-reference\");\n return extractChecked(sf, site, spec, kit);\n }\n\n const core = unwrap(site.decl.getInitializerOrThrow());\n if (isHandle(core, name) || findInSequence(core, name, kit)) {\n return unchanged(site);\n }\n if (references(core, name)) return unsupported(\"ambiguous-reference\");\n\n if (isSequenceCall(core, kit)) {\n const list = pieces(core);\n const piece: Piece = { leading: [], text: spec.expression, trailing: [] };\n if (position === \"first\") list.unshift(piece);\n else list.push(piece);\n rewriteSequence(core, list);\n return changed(sf);\n }\n\n if (Node.isArrowFunction(core) || Node.isFunctionExpression(core)) {\n return extractChecked(sf, site, spec, kit);\n }\n\n const callee = sequenceCallee(sf, kit);\n if (!callee) return unsupported(\"foreign-sequence\");\n const existing = core.getText();\n const args =\n position === \"first\"\n ? [spec.expression, existing]\n : [existing, spec.expression];\n const multiline = args.some((a) => a.includes(\"\\n\"));\n core.replaceWithText(\n renderCall(\n callee,\n args.map((text) => ({ leading: [], text, trailing: [] })),\n multiline,\n ),\n );\n ensureSequenceImport(sf, kit);\n return changed(sf);\n}\n\nfunction extractChecked(\n sf: SourceFile,\n site: Site,\n spec: HandleSpec,\n kit: KitSequence,\n): ComposeResult {\n const callee = sequenceCallee(sf, kit);\n if (!callee) return unsupported(\"foreign-sequence\");\n const taken = sf\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((id) => id.getText() === EXTRACTED);\n if (taken) return unsupported(\"name-collision\");\n if (site.kind === \"variable\" && site.statement.getDeclarations().length > 1) {\n return unsupported(\"multi-declarator\");\n }\n return extract(sf, site, spec, callee, kit);\n}\n\n/**\n * Take a handle out of the exported `handle`. A `sequence` left with one\n * argument unwraps to it; the last handle takes the `handle` export with it.\n */\nexport function removeHandle(sf: SourceFile, name: string): ComposeResult {\n const located = locate(sf);\n if (\"unsupported\" in located) return unsupported(located.unsupported);\n const { site } = located;\n if (!site) return unchanged(null);\n\n if (site.kind === \"function\") {\n return references(site.fn, name)\n ? unsupported(\"ambiguous-reference\")\n : unchanged(site);\n }\n\n const kit = kitSequence(sf);\n const core = unwrap(site.decl.getInitializerOrThrow());\n if (isHandle(core, name)) {\n removeWholeHandle(sf, site);\n pruneSequenceImport(sf);\n return changed(sf);\n }\n\n const found = findInSequence(core, name, kit);\n if (!found) {\n return references(core, name)\n ? unsupported(\"ambiguous-reference\")\n : unchanged(site);\n }\n\n // Innermost call first; a nested `sequence` emptied by the removal is in\n // turn removed from the one around it.\n const calls = [...found.calls];\n let index = found.index;\n for (;;) {\n const call = calls.pop()!;\n const list = pieces(call);\n list.splice(index, 1);\n const outer = calls[calls.length - 1];\n\n if (list.length === 0) {\n if (!outer) {\n removeWholeHandle(sf, site);\n break;\n }\n index = outer.getArguments().indexOf(call);\n continue;\n }\n if (list.length === 1 && outer) {\n call.replaceWithText(renderAlone(list[0]));\n break;\n }\n if (list.length === 1) {\n // `handle = sequence(x)` unwraps to `handle = x`, and x's comments move\n // above the statement rather than dangle after the `=`.\n const [kept] = list;\n const comments = [...kept.leading, ...kept.trailing];\n call.replaceWithText(kept.text);\n if (comments.length === 0) restoreExtracted(sf);\n else {\n const statement = currentStatement(sf)!;\n sf.insertText(\n statement.getStart(true),\n comments.map((c) => `${c}\\n`).join(\"\"),\n );\n }\n break;\n }\n rewriteSequence(call, list);\n break;\n }\n\n pruneSequenceImport(sf);\n return changed(sf);\n}\n\n/**\n * Swap handle `name` for `spec` in the same place in the chain. When `name`\n * was the whole `handle`, the comments above the statement go too: they\n * described the old handle. With `name` absent this is `addHandle`.\n */\nexport function replaceHandle(\n sf: SourceFile,\n name: string,\n spec: HandleSpec,\n): ComposeResult {\n const newName = spec.name ?? spec.expression;\n const located = locate(sf);\n if (\"unsupported\" in located) return unsupported(located.unsupported);\n const { site } = located;\n if (!site || site.kind === \"function\") return addHandle(sf, spec);\n\n const kit = kitSequence(sf);\n const core = unwrap(site.decl.getInitializerOrThrow());\n if (isHandle(core, newName) || findInSequence(core, newName, kit)) {\n const stale = isHandle(core, name) || findInSequence(core, name, kit);\n return stale ? removeHandle(sf, name) : unchanged(site);\n }\n\n if (isHandle(core, name)) {\n core.replaceWithText(spec.expression);\n removeAttachedComments(sf, sf.getVariableStatementOrThrow(\"handle\"));\n return changed(sf);\n }\n\n const found = findInSequence(core, name, kit);\n if (found) {\n const call = found.calls[found.calls.length - 1];\n const list = pieces(call);\n list[found.index] = { ...list[found.index], text: spec.expression };\n rewriteSequence(call, list);\n return changed(sf);\n }\n if (references(core, name)) return unsupported(\"ambiguous-reference\");\n return addHandle(sf, spec);\n}\n\n/**\n * The handles in the exported `handle`, in order: each argument's identifier,\n * or its callee's, or its source text. A function handle is `handle` itself.\n * `null` when there is no `handle` to compose.\n */\nexport function listHandles(sf: SourceFile): string[] | null {\n const located = locate(sf);\n if (\"unsupported\" in located || !located.site) return null;\n if (located.site.kind === \"function\") return [\"handle\"];\n const kit = kitSequence(sf);\n\n const names = (node: Node): string[] => {\n if (isSequenceCall(node, kit)) return node.getArguments().flatMap(names);\n if (Node.isIdentifier(node)) return [node.getText()];\n if (\n Node.isCallExpression(node) &&\n Node.isIdentifier(node.getExpression())\n ) {\n return [node.getExpression().getText()];\n }\n return [node.getText()];\n };\n return names(unwrap(located.site.decl.getInitializerOrThrow()));\n}\n"],"mappings":";;;AAiCA,IAAMI,IAAY,uBACZC,IAAY;AA+DlB,SAASC,EAAO,GAAyB;CACvC,IAAIC,IAAsB,IACtBC,IAAa;CAEjB,KAAK,IAAMC,K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AQxE,CAAE;CAGnB,IAAMY,IAAQkB,EAAe4D,GAAM1E,GAAMG,CAAG;CAC5C,IAAIP,GAAO;EACT,IAAM8B,IAAO9B,EAAM,MAAMA,EAAM,MAAM,SAAS,IACxC8C,IAAOjB,EAAOC,CAAI;EAGxB,OAFA,EAAK9B,EAAM,SAAS;GAAE,GAAG8C,EAAK9C,EAAM;GAAQ,MAAMV,EAAK;EAAW,GAClEiE,EAAgBzB,GAAMgB,CAAI,GACnBc,EAAQxE,CAAE;CACnB;CAEA,OADImC,EAAWuD,GAAM1E,CAAI,IAAU0D,EAAY,qBAAqB,IAC7DY,EAAUtF,GAAIE,CAAI;AAC3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as e } from "./ts-morph-helpers-
|
|
1
|
+
import { o as e } from "./ts-morph-helpers-CDW4lhox.js";
|
|
2
2
|
import t from "node:fs";
|
|
3
3
|
import n from "node:path";
|
|
4
4
|
import { Project as r, QuoteKind as i, SyntaxKind as a } from "ts-morph";
|
|
@@ -13,30 +13,21 @@ var o = [
|
|
|
13
13
|
"svelte.config.js",
|
|
14
14
|
"svelte.config.mjs",
|
|
15
15
|
"svelte.config.cjs"
|
|
16
|
-
];
|
|
17
|
-
function
|
|
16
|
+
], c = "SvelteKit 3 no longer reads svelte.config.* — run `npx vela@^0.15 migrate sveltekit-3` to move it into vite.config.ts.", l = "SvelteKit 3 reads its options at the top level of sveltekit({...}), not under `kit:` — run `npx vela@^0.15 migrate sveltekit-3` to move them.";
|
|
17
|
+
function u(e, r) {
|
|
18
18
|
for (let i of r) {
|
|
19
19
|
let r = n.join(e, i);
|
|
20
20
|
if (t.existsSync(r)) return r;
|
|
21
21
|
}
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function d() {
|
|
25
25
|
return new r({
|
|
26
26
|
compilerOptions: { allowJs: !0 },
|
|
27
27
|
manipulationSettings: { quoteKind: i.Single }
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
let t = e.getExportAssignment((e) => !e.isExportEquals())?.getExpression();
|
|
32
|
-
if (t?.getKind() === a.ObjectLiteralExpression) return t;
|
|
33
|
-
if (t?.getKind() === a.Identifier) {
|
|
34
|
-
let n = t.getText(), r = e.getVariableDeclaration(n)?.getInitializer();
|
|
35
|
-
if (r?.getKind() === a.ObjectLiteralExpression) return r;
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
function d(e, t, n) {
|
|
30
|
+
function f(e, t, n) {
|
|
40
31
|
let r = e.getProperty(t);
|
|
41
32
|
if (!r) {
|
|
42
33
|
e.addPropertyAssignment({
|
|
@@ -58,80 +49,78 @@ function d(e, t, n) {
|
|
|
58
49
|
}
|
|
59
50
|
return i;
|
|
60
51
|
}
|
|
61
|
-
function
|
|
52
|
+
function p(e, t) {
|
|
62
53
|
let n = e.getProperty(t);
|
|
63
54
|
return n ? n.getKind() !== a.PropertyAssignment || n.getInitializer()?.getText() === "true" ? !1 : (n.setInitializer("true"), !0) : (e.addPropertyAssignment({
|
|
64
55
|
name: t,
|
|
65
56
|
initializer: "true"
|
|
66
57
|
}), !0);
|
|
67
58
|
}
|
|
68
|
-
function
|
|
59
|
+
function m(e) {
|
|
69
60
|
return e.getDescendantsOfKind(a.CallExpression).find((e) => e.getExpression().getText() === "sveltekit") ?? null;
|
|
70
61
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
kitContainer: () => n
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function h(e, t, n, r) {
|
|
82
|
-
return {
|
|
83
|
-
kind: "svelte-config",
|
|
84
|
-
sourceFile: e,
|
|
85
|
-
filePath: t,
|
|
86
|
-
configObject: n,
|
|
87
|
-
originalText: r,
|
|
88
|
-
kitContainer: () => d(n, "kit", "{}")
|
|
62
|
+
function h(e, t) {
|
|
63
|
+
let r = t?.notFound ?? "Could not find a Vite config to modify.", i = t?.failed ?? "Could not modify the Vite config.", f = u(e, s);
|
|
64
|
+
if (f) return {
|
|
65
|
+
status: "failed",
|
|
66
|
+
reason: "svelte-config",
|
|
67
|
+
message: c,
|
|
68
|
+
filePath: f
|
|
89
69
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
let e = _?.getArguments()[0];
|
|
96
|
-
e && (e.getKind() === a.ObjectLiteralExpression ? v = e : y = !0);
|
|
97
|
-
}
|
|
98
|
-
if (f && d && v) return {
|
|
99
|
-
status: "resolved",
|
|
100
|
-
target: m(f, d, v, g)
|
|
70
|
+
let p = u(e, o);
|
|
71
|
+
if (!p) return {
|
|
72
|
+
status: "not-found",
|
|
73
|
+
message: r,
|
|
74
|
+
filePath: n.join(e, o[0])
|
|
101
75
|
};
|
|
102
|
-
let
|
|
103
|
-
if (
|
|
104
|
-
status: "
|
|
105
|
-
|
|
76
|
+
let h = d().addSourceFileAtPath(p), g = h.getFullText(), _ = m(h);
|
|
77
|
+
if (!_) return {
|
|
78
|
+
status: "not-found",
|
|
79
|
+
message: r,
|
|
80
|
+
filePath: p
|
|
106
81
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
status: "failed",
|
|
110
|
-
message: i,
|
|
111
|
-
filePath: d
|
|
112
|
-
};
|
|
82
|
+
let v = _.getArguments()[0];
|
|
83
|
+
if (!v) {
|
|
113
84
|
let e = _.addArgument("{}").asKind(a.ObjectLiteralExpression);
|
|
114
85
|
return e ? {
|
|
115
86
|
status: "resolved",
|
|
116
|
-
target:
|
|
87
|
+
target: {
|
|
88
|
+
sourceFile: h,
|
|
89
|
+
filePath: p,
|
|
90
|
+
configObject: e,
|
|
91
|
+
originalText: g,
|
|
92
|
+
addedArgTo: _
|
|
93
|
+
}
|
|
117
94
|
} : {
|
|
118
95
|
status: "failed",
|
|
96
|
+
reason: "non-object-arg",
|
|
119
97
|
message: i,
|
|
120
|
-
filePath:
|
|
98
|
+
filePath: p
|
|
121
99
|
};
|
|
122
100
|
}
|
|
123
|
-
|
|
101
|
+
let y = v.asKind(a.ObjectLiteralExpression);
|
|
102
|
+
return y ? y.getProperty("kit") ? {
|
|
124
103
|
status: "failed",
|
|
125
|
-
|
|
126
|
-
|
|
104
|
+
reason: "kit-nesting",
|
|
105
|
+
message: l,
|
|
106
|
+
filePath: p
|
|
127
107
|
} : {
|
|
128
|
-
status: "
|
|
129
|
-
|
|
130
|
-
|
|
108
|
+
status: "resolved",
|
|
109
|
+
target: {
|
|
110
|
+
sourceFile: h,
|
|
111
|
+
filePath: p,
|
|
112
|
+
configObject: y,
|
|
113
|
+
originalText: g
|
|
114
|
+
}
|
|
115
|
+
} : {
|
|
116
|
+
status: "failed",
|
|
117
|
+
reason: "non-object-arg",
|
|
118
|
+
message: i,
|
|
119
|
+
filePath: p
|
|
131
120
|
};
|
|
132
121
|
}
|
|
133
|
-
function
|
|
134
|
-
return e(t.sourceFile), t.sourceFile.getFullText() === t.originalText ? {
|
|
122
|
+
function g(t) {
|
|
123
|
+
return t.addedArgTo && t.configObject.getProperties().length === 0 && t.addedArgTo.removeArgument(0), e(t.sourceFile), t.sourceFile.getFullText() === t.originalText ? {
|
|
135
124
|
status: "success",
|
|
136
125
|
changed: !1
|
|
137
126
|
} : (t.sourceFile.saveSync(), {
|
|
@@ -139,11 +128,11 @@ function _(t) {
|
|
|
139
128
|
changed: !0
|
|
140
129
|
});
|
|
141
130
|
}
|
|
142
|
-
function
|
|
143
|
-
let r =
|
|
131
|
+
function _(e, t, n) {
|
|
132
|
+
let r = h(e, t);
|
|
144
133
|
return r.status === "resolved" ? n(r.target) ? {
|
|
145
134
|
filePath: r.target.filePath,
|
|
146
|
-
outcome:
|
|
135
|
+
outcome: g(r.target)
|
|
147
136
|
} : {
|
|
148
137
|
filePath: r.target.filePath,
|
|
149
138
|
outcome: {
|
|
@@ -159,6 +148,6 @@ function v(e, t, n) {
|
|
|
159
148
|
};
|
|
160
149
|
}
|
|
161
150
|
//#endregion
|
|
162
|
-
export {
|
|
151
|
+
export { u as a, _ as i, p as n, h as o, f as r, g as s, o as t };
|
|
163
152
|
|
|
164
|
-
//# sourceMappingURL=config-target-
|
|
153
|
+
//# sourceMappingURL=config-target-Dx3w6WSk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-target-Dx3w6WSk.js","names":["formatLikeSource","fs","path","VITE_CONFIG_CANDIDATES","SVELTE_CONFIG_CANDIDATES","SVELTE_CONFIG_MESSAGE","KIT_NESTING_MESSAGE","probeFirstExisting","rel","candidates","abs","root","newProject","Project","QuoteKind","getOrCreateObjectLiteralProperty","prop","obj","name","added","SyntaxKind","init","initializer","init2","ensureBooleanTrue","existing","findSveltekitCall","sourceFile","ce","resolveConfigTarget","notFound","hints","failed","sveltePath","vitePath","originalText","call","arg","created","configObject","saveTarget","target","modifyConfig","res","mutate"],"sources":["../../src/runtime/config-target.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n Project,\n QuoteKind,\n SyntaxKind,\n type CallExpression,\n type ObjectLiteralExpression,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../core/types\";\nimport { formatLikeSource } from \"./ts-morph-helpers\";\n\nexport const VITE_CONFIG_CANDIDATES = [\n \"vite.config.ts\",\n \"vite.config.js\",\n \"vite.config.mjs\",\n \"vite.config.cjs\",\n];\n\n/** SvelteKit 2's config files; SvelteKit 3 refuses to start with any of them. */\nexport const SVELTE_CONFIG_CANDIDATES = [\n \"svelte.config.ts\",\n \"svelte.config.js\",\n \"svelte.config.mjs\",\n \"svelte.config.cjs\",\n];\n\n/**\n * The message every pattern prints for a project still on SvelteKit 2's\n * `svelte.config.*`. SvelteKit 3 refuses to start with one, so editing it\n * would be pointless; the migration moves it into `vite.config.ts`.\n */\nexport const SVELTE_CONFIG_MESSAGE =\n \"SvelteKit 3 no longer reads svelte.config.* — run `npx vela@^0.15 migrate sveltekit-3` to move it into vite.config.ts.\";\n\n/** SvelteKit 3 fails on a leftover `kit: {...}` inside the `sveltekit()` arg. */\nexport const KIT_NESTING_MESSAGE =\n \"SvelteKit 3 reads its options at the top level of sveltekit({...}), not under `kit:` — run `npx vela@^0.15 migrate sveltekit-3` to move them.\";\n\n/**\n * Where SvelteKit 3 reads its configuration: the inline argument object of the\n * `sveltekit()` call in `vite.config.*`. The former `kit.*` options (adapter,\n * alias, experimental, paths, ...) sit at its top level, beside\n * `compilerOptions`, `preprocess` and `extensions`.\n */\nexport interface ConfigTarget {\n /** The file to add imports to and save. */\n sourceFile: SourceFile;\n /** Absolute path of the resolved file. */\n filePath: string;\n /** The `sveltekit()` arg object. */\n configObject: ObjectLiteralExpression;\n /** Full text captured before any mutation, for change detection. */\n originalText: string;\n /**\n * The `sveltekit()` call when resolving it added the `{}` arg; saving drops\n * that arg again while it is still empty.\n */\n addedArgTo?: CallExpression;\n}\n\n/** Why a config could not be resolved for editing. */\nexport type ConfigFailure =\n /** A `svelte.config.*` exists: a SvelteKit 2 project that needs migrating. */\n | \"svelte-config\"\n /** The `sveltekit()` arg still nests options under `kit:`. */\n | \"kit-nesting\"\n /** The `sveltekit()` arg is not an object literal (`sveltekit(config)`). */\n | \"non-object-arg\";\n\nexport type ResolveResult =\n | { status: \"resolved\"; target: ConfigTarget }\n | { status: \"not-found\"; message: string; filePath: string }\n | {\n status: \"failed\";\n reason: ConfigFailure;\n message: string;\n filePath: string;\n };\n\n/** Result shape returned by every config modifier so call sites can build a File. */\nexport interface ConfigModifyResult {\n filePath: string;\n outcome: ModifyOutcome;\n}\n\n/** First candidate that exists under `root`, or null. */\nexport function probeFirstExisting(\n root: string,\n candidates: string[],\n): string | null {\n for (const rel of candidates) {\n const abs = path.join(root, rel);\n if (fs.existsSync(abs)) return abs;\n }\n return null;\n}\n\nfunction newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\n/**\n * Get the object-literal value of property `name` on `obj`, creating it as an\n * empty object if missing (or replacing a non-object initializer). Returns null\n * if the property can't be coerced to an object literal.\n */\nexport function getOrCreateObjectLiteralProperty(\n obj: ObjectLiteralExpression,\n name: string,\n initializer: string,\n): ObjectLiteralExpression | null {\n const prop = obj.getProperty(name);\n if (!prop) {\n obj.addPropertyAssignment({ name, initializer });\n const added = obj.getProperty(name);\n if (!added || added.getKind() !== SyntaxKind.PropertyAssignment)\n return null;\n const init = (\n added as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ObjectLiteralExpression)\n return null;\n return init as ObjectLiteralExpression;\n }\n\n if (prop.getKind() !== SyntaxKind.PropertyAssignment) return null;\n const init = (prop as import(\"ts-morph\").PropertyAssignment).getInitializer();\n if (!init) return null;\n if (init.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n (prop as import(\"ts-morph\").PropertyAssignment).setInitializer(initializer);\n const init2 = (\n prop as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n return init2 && init2.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (init2 as ObjectLiteralExpression)\n : null;\n }\n\n return init as ObjectLiteralExpression;\n}\n\n/** Ensure `obj[name] === true`. Returns whether a change was made. */\nexport function ensureBooleanTrue(\n obj: ObjectLiteralExpression,\n name: string,\n): boolean {\n const existing = obj.getProperty(name);\n if (!existing) {\n obj.addPropertyAssignment({ name, initializer: \"true\" });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (init?.getText() === \"true\") return false;\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\"true\");\n return true;\n}\n\nfunction findSveltekitCall(sourceFile: SourceFile): CallExpression | null {\n return (\n sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"sveltekit\") ?? null\n );\n}\n\n/**\n * Resolve the `sveltekit()` arg in `vite.config.*` for editing:\n * - any `svelte.config.*` → failed (`svelte-config`), even when the inline\n * arg exists too: SvelteKit 3 refuses to start until it is gone;\n * - an object arg with a `kit:` property → failed (`kit-nesting`);\n * - an object arg → resolved;\n * - a bare `sveltekit()` → `{}` is added and resolved;\n * - any other arg → failed (`non-object-arg`);\n * - no vite config, or no `sveltekit()` call in it → not-found.\n *\n * `hints.failed` is the message for a shape that can't be edited; the\n * `svelte-config` and `kit-nesting` failures always carry the migrate message.\n */\nexport function resolveConfigTarget(\n root: string,\n hints?: { notFound?: string; failed?: string },\n): ResolveResult {\n const notFound = hints?.notFound ?? \"Could not find a Vite config to modify.\";\n const failed = hints?.failed ?? \"Could not modify the Vite config.\";\n\n const sveltePath = probeFirstExisting(root, SVELTE_CONFIG_CANDIDATES);\n if (sveltePath) {\n return {\n status: \"failed\",\n reason: \"svelte-config\",\n message: SVELTE_CONFIG_MESSAGE,\n filePath: sveltePath,\n };\n }\n\n const vitePath = probeFirstExisting(root, VITE_CONFIG_CANDIDATES);\n if (!vitePath) {\n return {\n status: \"not-found\",\n message: notFound,\n filePath: path.join(root, VITE_CONFIG_CANDIDATES[0]),\n };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(vitePath);\n const originalText = sourceFile.getFullText();\n const call = findSveltekitCall(sourceFile);\n if (!call) {\n return { status: \"not-found\", message: notFound, filePath: vitePath };\n }\n\n const arg = call.getArguments()[0];\n if (!arg) {\n const created = call\n .addArgument(\"{}\")\n .asKind(SyntaxKind.ObjectLiteralExpression);\n if (!created) {\n return {\n status: \"failed\",\n reason: \"non-object-arg\",\n message: failed,\n filePath: vitePath,\n };\n }\n return {\n status: \"resolved\",\n target: {\n sourceFile,\n filePath: vitePath,\n configObject: created,\n originalText,\n addedArgTo: call,\n },\n };\n }\n\n const configObject = arg.asKind(SyntaxKind.ObjectLiteralExpression);\n if (!configObject) {\n return {\n status: \"failed\",\n reason: \"non-object-arg\",\n message: failed,\n filePath: vitePath,\n };\n }\n if (configObject.getProperty(\"kit\")) {\n return {\n status: \"failed\",\n reason: \"kit-nesting\",\n message: KIT_NESTING_MESSAGE,\n filePath: vitePath,\n };\n }\n return {\n status: \"resolved\",\n target: { sourceFile, filePath: vitePath, configObject, originalText },\n };\n}\n\n/**\n * Format, compare against the captured original, and save only if changed.\n * A `{}` that resolving added to a bare `sveltekit()` is taken out again when\n * nothing went into it, so a no-op edit reports unchanged.\n */\nexport function saveTarget(target: ConfigTarget): ModifyOutcome {\n if (target.addedArgTo && target.configObject.getProperties().length === 0) {\n target.addedArgTo.removeArgument(0);\n }\n formatLikeSource(target.sourceFile);\n const newText = target.sourceFile.getFullText();\n if (newText === target.originalText) {\n return { status: \"success\", changed: false };\n }\n target.sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n\n/**\n * Resolve a config target and run `mutate` against it. Handles the\n * not-found/failed branches and change detection uniformly. `mutate` returns\n * `false` when the config shape can't be safely edited (→ failed).\n */\nexport function modifyConfig(\n root: string,\n hints: { notFound: string; failed: string },\n mutate: (target: ConfigTarget) => boolean,\n): ConfigModifyResult {\n const res = resolveConfigTarget(root, hints);\n if (res.status !== \"resolved\") {\n return {\n filePath: res.filePath,\n outcome: { status: res.status, message: res.message },\n };\n }\n const ok = mutate(res.target);\n if (!ok) {\n return {\n filePath: res.target.filePath,\n outcome: { status: \"failed\", message: hints.failed },\n };\n }\n return { filePath: res.target.filePath, outcome: saveTarget(res.target) };\n}\n"],"mappings":";;;;;AAaA,IAAaG,IAAyB;CACpC;CACA;CACA;CACA;AACF,GAGaC,IAA2B;CACtC;CACA;CACA;CACA;AACF,GAOaC,IACX,0HAGWC,IACX;AAkDF,SAAgBC,EACd,GACA,GACe;CACf,KAAK,IAAMC,KAAOC,GAAY;EAC5B,IAAMC,IAAMR,EAAK,KAAKS,GAAMH,CAAG;EAC/B,IAAIP,EAAG,WAAWS,CAAG,GAAG,OAAOA;CACjC;CACA,OAAO;AACT;AAEA,SAASE,IA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EpCzC,EAAiByC,EAAO,UAAU,GAClBA,EAAO,WAAW,YAC9B,MAAYA,EAAO,eACd;EAAE,QAAQ;EAAW,SAAS;CAAM,KAE7CA,EAAO,WAAW,SAAS,GACpB;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;AAOA,SAAgBC,EACd,GACA,GACA,GACoB;CACpB,IAAMC,IAAMd,EAAoBlB,GAAMoB,CAAK;CAc3C,OAbIY,EAAI,WAAW,aAMRC,EAAOD,EAAI,MACjB,IAME;EAAE,UAAUA,EAAI,OAAO;EAAU,SAASH,EAAWG,EAAI,MAAM;CAAE,IAL/D;EACL,UAAUA,EAAI,OAAO;EACrB,SAAS;GAAE,QAAQ;GAAU,SAASZ,EAAM;EAAO;CACrD,IAVO;EACL,UAAUY,EAAI;EACd,SAAS;GAAE,QAAQA,EAAI;GAAQ,SAASA,EAAI;EAAQ;CACtD;AAUJ"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/core/constants.ts
|
|
2
|
+
var e = "data", t = "migrations", n = "(public)", r = "(app)", i = "@tanstack/table-core@^9.2.4", a = "formsnap@^2.0.1", o = "3.0.0-next.1", s = `sveltekit-superforms@${o}`, c = { formsnap: { "sveltekit-superforms": o } }, l = "sveltekit-flash-message@3.0.0-next.0", u = "@sveltejs/adapter-node@^6.0.0", d = "@sveltejs/adapter-static@^4.0.0", f = "@velastack/kit@^0.4.0", p = "@velastack/pocketbase@^0.4.0", m = "@velastack/cms@^0.6.0", h = "sveltekit-negotiate@^0.3.0", g = "zod@^4.1.11", _ = "wuchale@^0.26.3", v = "@wuchale/svelte@^0.21.1";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { _, l as a, t as c, s as d, o as f, p as g, f as h, e as i, h as l, m, d as n, a as o, i as p, r, c as s, u as t, n as u, v, g as y };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=constants-BjyMU5s8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-BjyMU5s8.js","names":["DATA_DIR","MIGRATIONS_DIR","PUBLIC_DIR","APP_DIR","TANSTACK_TABLE_CORE","FORMSNAP","SUPERFORMS_VERSION","SUPERFORMS","FORMSNAP_OVERRIDES","FLASH","ADAPTER_NODE","ADAPTER_STATIC","VELASTACK_KIT","VELASTACK_POCKETBASE","VELASTACK_CMS","NEGOTIATE","ZOD","WUCHALE","WUCHALE_SVELTE"],"sources":["../../src/core/constants.ts"],"sourcesContent":["export const DATA_DIR = \"data\";\nexport const MIGRATIONS_DIR = \"migrations\";\nexport const FIXTURE_PREFIX = \"vela\";\nexport const PUBLIC_DIR = \"(public)\";\nexport const APP_DIR = \"(app)\";\nexport const AUTHED_REDIRECT_PATH = \"/dashboard\";\nexport const API_URL = \"http://localhost:5173\";\n\n/**\n * The table helpers this repo ships (`data-table`, `column-header`,\n * `faceted-filter`, `pagination`) and the pages the scaffold generators emit\n * target TanStack Table v9, whose API and types are incompatible with v8; see\n * `assertTableCoreV9` for projects that still have the v8 helpers.\n */\nexport const TANSTACK_TABLE_CORE = \"@tanstack/table-core@^9.2.4\";\n\n/** The major `TANSTACK_TABLE_CORE` pins. */\nexport const TANSTACK_TABLE_CORE_MAJOR = 9;\n\n/** `file-form` and `multiselect` build on formsnap's field context. */\nexport const FORMSNAP = \"formsnap@^2.0.1\";\n\n/**\n * The superforms release that supports SvelteKit 3 (its `latest` accepts\n * only Kit 1 and 2). Installed exactly, not with a caret: a caret on a\n * prerelease would follow later `next` builds.\n */\nexport const SUPERFORMS_VERSION = \"3.0.0-next.1\";\n\n/**\n * What a generated superforms page needs. Vela's templates already carry\n * both; a project vela did not create may have neither.\n */\nexport const SUPERFORMS = `sveltekit-superforms@${SUPERFORMS_VERSION}`;\n\n/**\n * formsnap 2 peers `sveltekit-superforms ^2`, so every project that installs\n * it needs this npm override, or `npm install` fails with ERESOLVE. The value\n * is the literal version: `$sveltekit-superforms` breaks on npm 10.\n * `writeResult` adds it before any install that brings formsnap in.\n */\nexport const FORMSNAP_OVERRIDES = {\n formsnap: { \"sveltekit-superforms\": SUPERFORMS_VERSION },\n};\n\n/** The flash-message release that supports SvelteKit 3; installed exactly, like superforms. */\nexport const FLASH = \"sveltekit-flash-message@3.0.0-next.0\";\n\n/** The adapter `vela enable backend` moves a project to. */\nexport const ADAPTER_NODE = \"@sveltejs/adapter-node@^6.0.0\";\n\n/** The adapter a static project builds with (`vela disable backend`). */\nexport const ADAPTER_STATIC = \"@sveltejs/adapter-static@^4.0.0\";\n\n/** The VelaStack libraries' SvelteKit 3 releases. */\nexport const VELASTACK_KIT = \"@velastack/kit@^0.4.0\";\nexport const VELASTACK_POCKETBASE = \"@velastack/pocketbase@^0.4.0\";\nexport const VELASTACK_CMS = \"@velastack/cms@^0.6.0\";\nexport const NEGOTIATE = \"sveltekit-negotiate@^0.3.0\";\nexport const ZOD = \"zod@^4.1.11\";\n\n/** What `vela enable i18n` installs: wuchale and its Svelte adapter. */\nexport const WUCHALE = \"wuchale@^0.26.3\";\nexport const WUCHALE_SVELTE = \"@wuchale/svelte@^0.21.1\";\n"],"mappings":";AAAA,IAAaA,IAAW,QACXC,IAAiB,cAEjBC,IAAa,YACbC,IAAU,SAUVC,IAAsB,+BAMtBC,IAAW,mBAOXC,IAAqB,gBAMrBC,IAAa,wBAAwBD,KAQrCE,IAAqB,EAChC,UAAU,EAAE,wBAAwBF,EAAmB,EACzD,GAGaG,IAAQ,wCAGRC,IAAe,iCAGfC,IAAiB,mCAGjBC,IAAgB,yBAChBC,IAAuB,gCACvBC,IAAgB,yBAChBC,IAAY,8BACZC,IAAM,eAGNC,IAAU,mBACVC,IAAiB"}
|