From 52dca57572e3f7601eb7bfadcab2b5c96cd272c8 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Wed, 5 Jun 2024 18:52:04 +0200 Subject: [PATCH 01/14] fix(init): update `@sentry/node` due to error while running the init command (#1381) (#1382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Andrés Martínez <78830288+andresmarpz@users.noreply.github.com> --- packages/init/package.json | 2 +- yarn.lock | 97 +++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/packages/init/package.json b/packages/init/package.json index 1cc3eb3050..e8ee787c37 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -53,7 +53,7 @@ "dependencies": { "@antfu/ni": "^0.20.0", "@lihbr/listr-update-renderer": "^0.5.3", - "@sentry/node": "^7.70.0", + "@sentry/node": "^7.116.0", "@slicemachine/manager": "workspace:*", "chalk": "^4.1.2", "giget": "^1.1.2", diff --git a/yarn.lock b/yarn.lock index 6f6ae6c1c0..ba62c51e18 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7876,15 +7876,14 @@ __metadata: languageName: node linkType: hard -"@sentry-internal/tracing@npm:7.70.0": - version: 7.70.0 - resolution: "@sentry-internal/tracing@npm:7.70.0" +"@sentry-internal/tracing@npm:7.116.0": + version: 7.116.0 + resolution: "@sentry-internal/tracing@npm:7.116.0" dependencies: - "@sentry/core": 7.70.0 - "@sentry/types": 7.70.0 - "@sentry/utils": 7.70.0 - tslib: ^2.4.1 || ^1.9.3 - checksum: 51fe662ae5b4e26a9698515dbd47427714966c4e3f5df6f19d3d26c21150e17260e4b8c53e814a7e9274e8ca7b7994a4fac2838a71233cadcd4a30f394f9227e + "@sentry/core": 7.116.0 + "@sentry/types": 7.116.0 + "@sentry/utils": 7.116.0 + checksum: 494e639fb1ea4a7565a96da27da03e8d26ffe6304b32686e4f325bf7323ca0465a48d6936faa325022b11a035882992b7ef4b87efba21fb5e12beb69e3de959a languageName: node linkType: hard @@ -7917,6 +7916,16 @@ __metadata: languageName: node linkType: hard +"@sentry/core@npm:7.116.0": + version: 7.116.0 + resolution: "@sentry/core@npm:7.116.0" + dependencies: + "@sentry/types": 7.116.0 + "@sentry/utils": 7.116.0 + checksum: b3000b31e144c056af64805e4f0aba6e145374593d157db7f6cdf2e97fb43d538161fc5a8cadc4a74f665a29c6ace0772924d7d204ef28b84317c1540b814b20 + languageName: node + linkType: hard + "@sentry/core@npm:7.43.0": version: 7.43.0 resolution: "@sentry/core@npm:7.43.0" @@ -7928,14 +7937,15 @@ __metadata: languageName: node linkType: hard -"@sentry/core@npm:7.70.0": - version: 7.70.0 - resolution: "@sentry/core@npm:7.70.0" +"@sentry/integrations@npm:7.116.0": + version: 7.116.0 + resolution: "@sentry/integrations@npm:7.116.0" dependencies: - "@sentry/types": 7.70.0 - "@sentry/utils": 7.70.0 - tslib: ^2.4.1 || ^1.9.3 - checksum: 550ff55f8232fbbe8263b05deca997b6fe98ae19fe445f39d90915cc515bdcc8d6c2ec09df6976fcf750547adc39aefb5714ebfd5f039b32e94c5c5320f4cfab + "@sentry/core": 7.116.0 + "@sentry/types": 7.116.0 + "@sentry/utils": 7.116.0 + localforage: ^1.8.1 + checksum: 6868594a78dfd689ab4a9f9c7f765ec7869c7f3395a619d3fba02d8dcb3da46ee04f26f847f59fcbad20ff01d035eb60e1f133a4be207590399e6fd74202b051 languageName: node linkType: hard @@ -7994,19 +8004,16 @@ __metadata: languageName: node linkType: hard -"@sentry/node@npm:^7.70.0": - version: 7.70.0 - resolution: "@sentry/node@npm:7.70.0" +"@sentry/node@npm:^7.116.0": + version: 7.116.0 + resolution: "@sentry/node@npm:7.116.0" dependencies: - "@sentry-internal/tracing": 7.70.0 - "@sentry/core": 7.70.0 - "@sentry/types": 7.70.0 - "@sentry/utils": 7.70.0 - cookie: ^0.5.0 - https-proxy-agent: ^5.0.0 - lru_map: ^0.3.3 - tslib: ^2.4.1 || ^1.9.3 - checksum: 4d60023f0ddfca92ee15e42b5a207d998d683570103655282ce6e1a07a3bccbb86675810778f5500229cf21daef34e1f0fd48e0dbe3665d3df19d7b97c2788e5 + "@sentry-internal/tracing": 7.116.0 + "@sentry/core": 7.116.0 + "@sentry/integrations": 7.116.0 + "@sentry/types": 7.116.0 + "@sentry/utils": 7.116.0 + checksum: 9c300254e6006e84d8c7876a1ad4bfd229232a4276c7fb0fcb05e98e58f31af196589e8c8ce4a1ef0f3bd83ec7a37484fe69de4c3fdd41726562a6457309cbfa languageName: node linkType: hard @@ -8048,6 +8055,13 @@ __metadata: languageName: node linkType: hard +"@sentry/types@npm:7.116.0": + version: 7.116.0 + resolution: "@sentry/types@npm:7.116.0" + checksum: d2ed11ce814201531c3c426f52c25dd32160eda434426ad10963f694f670218d2c40fecc4741acb1c921b826c8c99ef2e60716aff78e74f85f8a091623a0705d + languageName: node + linkType: hard + "@sentry/types@npm:7.43.0": version: 7.43.0 resolution: "@sentry/types@npm:7.43.0" @@ -8055,10 +8069,12 @@ __metadata: languageName: node linkType: hard -"@sentry/types@npm:7.70.0": - version: 7.70.0 - resolution: "@sentry/types@npm:7.70.0" - checksum: 0a38f47ccf0d995d8d5ab0353c332bd2573f044d993d746ec9ecee5e185da773ffdc13db3f29d525b4377ed3ce9235eaa0dc728c039739eb23050d0411667222 +"@sentry/utils@npm:7.116.0": + version: 7.116.0 + resolution: "@sentry/utils@npm:7.116.0" + dependencies: + "@sentry/types": 7.116.0 + checksum: f8d2f7fd61409fd52376665f6e87fe7b74706c4a9eb6f05b4d85c2c2fa3dc4cb1c31a4cadddc248a3798a6f01906b16ff8317356a0ab4767cb13e38b0f3f90f0 languageName: node linkType: hard @@ -8072,16 +8088,6 @@ __metadata: languageName: node linkType: hard -"@sentry/utils@npm:7.70.0": - version: 7.70.0 - resolution: "@sentry/utils@npm:7.70.0" - dependencies: - "@sentry/types": 7.70.0 - tslib: ^2.4.1 || ^1.9.3 - checksum: a1590f5e752667910638262bb8e85f2e2c26e722df4087e79c39b11d1d81dbefaea8f426826a50b0832c079e77092ff7c2335d48e63a2d11c32b1c0b59b10eee - languageName: node - linkType: hard - "@sentry/webpack-plugin@npm:1.20.0": version: 1.20.0 resolution: "@sentry/webpack-plugin@npm:1.20.0" @@ -8361,7 +8367,7 @@ __metadata: dependencies: "@antfu/ni": ^0.20.0 "@lihbr/listr-update-renderer": ^0.5.3 - "@sentry/node": ^7.70.0 + "@sentry/node": ^7.116.0 "@size-limit/preset-small-lib": 8.2.4 "@slicemachine/manager": "workspace:*" "@slicemachine/plugin-kit": "workspace:*" @@ -31924,13 +31930,6 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.4.1 || ^1.9.3": - version: 2.6.2 - resolution: "tslib@npm:2.6.2" - checksum: 329ea56123005922f39642318e3d1f0f8265d1e7fcb92c633e0809521da75eeaca28d2cf96d7248229deb40e5c19adf408259f4b9640afd20d13aecc1430f3ad - languageName: node - linkType: hard - "tsutils@npm:^3.21.0": version: 3.21.0 resolution: "tsutils@npm:3.21.0" From bcd8a93eba7cd678d3aaefe3fc313ce703604cea Mon Sep 17 00:00:00 2001 From: xrutayisire <19946868+xrutayisire@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:08:28 +0000 Subject: [PATCH 02/14] release: 9 new packages --- packages/adapter-next/package.json | 2 +- packages/adapter-nuxt/package.json | 2 +- packages/adapter-nuxt2/package.json | 2 +- packages/adapter-sveltekit/package.json | 2 +- packages/init/package.json | 2 +- packages/manager/package.json | 2 +- packages/plugin-kit/package.json | 2 +- packages/slice-machine/package.json | 2 +- packages/start-slicemachine/package.json | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/adapter-next/package.json b/packages/adapter-next/package.json index 9cf3e817d5..5041a53491 100644 --- a/packages/adapter-next/package.json +++ b/packages/adapter-next/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-next", - "version": "0.3.40", + "version": "0.3.41", "description": "Slice Machine adapter for Next.js.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt/package.json b/packages/adapter-nuxt/package.json index 0074fc0a44..a77216fa05 100644 --- a/packages/adapter-nuxt/package.json +++ b/packages/adapter-nuxt/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt", - "version": "0.3.40", + "version": "0.3.41", "description": "Slice Machine adapter for Nuxt 3.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt2/package.json b/packages/adapter-nuxt2/package.json index d8bff8b072..72e3e46143 100644 --- a/packages/adapter-nuxt2/package.json +++ b/packages/adapter-nuxt2/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt2", - "version": "0.3.40", + "version": "0.3.41", "description": "Slice Machine adapter for Nuxt 2.", "keywords": [ "typescript", diff --git a/packages/adapter-sveltekit/package.json b/packages/adapter-sveltekit/package.json index 67b99ea34d..6cdd0780f7 100644 --- a/packages/adapter-sveltekit/package.json +++ b/packages/adapter-sveltekit/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-sveltekit", - "version": "0.3.40", + "version": "0.3.41", "description": "Slice Machine adapter for SvelteKit.", "keywords": [ "typescript", diff --git a/packages/init/package.json b/packages/init/package.json index e8ee787c37..89a63063bd 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/init", - "version": "2.9.18", + "version": "2.9.19", "description": "Init Prismic Slice Machine in your project", "keywords": [ "typescript", diff --git a/packages/manager/package.json b/packages/manager/package.json index 2dfc6cf83d..020bc414dd 100644 --- a/packages/manager/package.json +++ b/packages/manager/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/manager", - "version": "0.19.1", + "version": "0.19.2", "description": "Manage all aspects of a Slice Machine project.", "repository": { "type": "git", diff --git a/packages/plugin-kit/package.json b/packages/plugin-kit/package.json index e3ce188de8..57c6b17490 100644 --- a/packages/plugin-kit/package.json +++ b/packages/plugin-kit/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/plugin-kit", - "version": "0.4.40", + "version": "0.4.41", "description": "A set of helpers to develop and run Slice Machine plugins", "keywords": [ "typescript", diff --git a/packages/slice-machine/package.json b/packages/slice-machine/package.json index 0df24b69d2..00b0c06e52 100644 --- a/packages/slice-machine/package.json +++ b/packages/slice-machine/package.json @@ -1,6 +1,6 @@ { "name": "slice-machine-ui", - "version": "2.1.0", + "version": "2.2.0", "license": "MIT", "description": "A visual builder for your Slice Models with all the tools you need to generate data models and mock CMS content locally.", "repository": { diff --git a/packages/start-slicemachine/package.json b/packages/start-slicemachine/package.json index b80d344cf4..63f0d31ca3 100644 --- a/packages/start-slicemachine/package.json +++ b/packages/start-slicemachine/package.json @@ -1,6 +1,6 @@ { "name": "start-slicemachine", - "version": "0.12.20", + "version": "0.12.21", "description": "Start Slice Machine from within a project.", "repository": { "type": "git", From 56bb21f6de4e81dc90c8cb487993719027bbb694 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Mon, 10 Jun 2024 18:08:32 +0200 Subject: [PATCH 03/14] docs(CODEOWNERS): Update code owner team (#1384) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ada265a87f..2382dab2a6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,4 +4,4 @@ # the repo. Unless a later match takes precedence, # @global-owner1 and @global-owner2 will be requested for # review when someone opens a pull request. -* @prismicio/devs \ No newline at end of file +* @prismicio/dev-tools From bcac1423fa18b208433cb272dc3eec862806f07c Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Mon, 17 Jun 2024 10:49:50 -1000 Subject: [PATCH 04/14] fix: correctly generate types for groups in slices (#1391) --- packages/adapter-next/package.json | 4 +-- packages/adapter-nuxt/package.json | 4 +-- packages/adapter-nuxt2/package.json | 4 +-- packages/adapter-sveltekit/package.json | 4 +-- packages/plugin-kit/package.json | 2 +- yarn.lock | 45 +++++-------------------- 6 files changed, 18 insertions(+), 45 deletions(-) diff --git a/packages/adapter-next/package.json b/packages/adapter-next/package.json index 5041a53491..dcb9676baa 100644 --- a/packages/adapter-next/package.json +++ b/packages/adapter-next/package.json @@ -76,8 +76,7 @@ "lz-string": "1.5.0", "monocle-ts": "^2.3.13", "newtype-ts": "^0.3.5", - "pascal-case": "^3.1.2", - "prismic-ts-codegen": "^0.1.17" + "pascal-case": "^3.1.2" }, "devDependencies": { "@prismicio/mock": "0.2.0", @@ -96,6 +95,7 @@ "next": "14.1.3", "prettier": "3.0.3", "prettier-plugin-jsdoc": "1.1.1", + "prismic-ts-codegen": "^0.1.20", "react": "18.2.0", "rollup-plugin-preserve-directives": "0.2.0", "size-limit": "8.2.4", diff --git a/packages/adapter-nuxt/package.json b/packages/adapter-nuxt/package.json index a77216fa05..6b0d93d711 100644 --- a/packages/adapter-nuxt/package.json +++ b/packages/adapter-nuxt/package.json @@ -69,8 +69,7 @@ "magicast": "^0.3.4", "monocle-ts": "^2.3.13", "newtype-ts": "^0.3.5", - "pascal-case": "^3.1.2", - "prismic-ts-codegen": "^0.1.17" + "pascal-case": "^3.1.2" }, "devDependencies": { "@prismicio/mock": "0.2.0", @@ -87,6 +86,7 @@ "nuxt": "3.3.3", "prettier": "3.0.3", "prettier-plugin-jsdoc": "1.1.1", + "prismic-ts-codegen": "^0.1.20", "size-limit": "8.2.4", "ts-morph": "17.0.1", "typescript": "4.9.5", diff --git a/packages/adapter-nuxt2/package.json b/packages/adapter-nuxt2/package.json index 72e3e46143..d9adb43775 100644 --- a/packages/adapter-nuxt2/package.json +++ b/packages/adapter-nuxt2/package.json @@ -69,8 +69,7 @@ "magicast": "^0.3.4", "monocle-ts": "^2.3.13", "newtype-ts": "^0.3.5", - "pascal-case": "^3.1.2", - "prismic-ts-codegen": "^0.1.17" + "pascal-case": "^3.1.2" }, "devDependencies": { "@prismicio/mock": "0.2.0", @@ -86,6 +85,7 @@ "nuxt": "2.16.3", "prettier": "3.0.3", "prettier-plugin-jsdoc": "1.1.1", + "prismic-ts-codegen": "^0.1.20", "size-limit": "8.2.4", "ts-morph": "17.0.1", "typescript": "4.9.5", diff --git a/packages/adapter-sveltekit/package.json b/packages/adapter-sveltekit/package.json index 6cdd0780f7..a04066f538 100644 --- a/packages/adapter-sveltekit/package.json +++ b/packages/adapter-sveltekit/package.json @@ -72,8 +72,7 @@ "monocle-ts": "^2.3.13", "newtype-ts": "^0.3.5", "pascal-case": "^3.1.2", - "prettier-plugin-svelte": "^3.0.3", - "prismic-ts-codegen": "^0.1.17" + "prettier-plugin-svelte": "^3.0.3" }, "devDependencies": { "@prismicio/mock": "0.2.0", @@ -94,6 +93,7 @@ "eslint-plugin-tsdoc": "0.2.17", "prettier": "3.0.3", "prettier-plugin-jsdoc": "1.1.1", + "prismic-ts-codegen": "^0.1.20", "size-limit": "8.2.4", "svelte": "4.2.0", "typescript": "4.9.5", diff --git a/packages/plugin-kit/package.json b/packages/plugin-kit/package.json index 57c6b17490..a2aa178e71 100644 --- a/packages/plugin-kit/package.json +++ b/packages/plugin-kit/package.json @@ -72,7 +72,7 @@ "io-ts-reporters": "^2.0.1", "p-limit": "^4.0.0", "prettier": "^3.0.3", - "prismic-ts-codegen": "^0.1.19" + "prismic-ts-codegen": "^0.1.20" }, "devDependencies": { "@prismicio/mock": "0.2.0", diff --git a/yarn.lock b/yarn.lock index ba62c51e18..699da91519 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8194,7 +8194,7 @@ __metadata: pascal-case: ^3.1.2 prettier: 3.0.3 prettier-plugin-jsdoc: 1.1.1 - prismic-ts-codegen: ^0.1.17 + prismic-ts-codegen: ^0.1.20 react: 18.2.0 rollup-plugin-preserve-directives: 0.2.0 size-limit: 8.2.4 @@ -8236,7 +8236,7 @@ __metadata: pascal-case: ^3.1.2 prettier: 3.0.3 prettier-plugin-jsdoc: 1.1.1 - prismic-ts-codegen: ^0.1.17 + prismic-ts-codegen: ^0.1.20 size-limit: 8.2.4 ts-morph: 17.0.1 typescript: 4.9.5 @@ -8278,7 +8278,7 @@ __metadata: pascal-case: ^3.1.2 prettier: 3.0.3 prettier-plugin-jsdoc: 1.1.1 - prismic-ts-codegen: ^0.1.17 + prismic-ts-codegen: ^0.1.20 size-limit: 8.2.4 ts-morph: 17.0.1 typescript: 4.9.5 @@ -8324,7 +8324,7 @@ __metadata: prettier: 3.0.3 prettier-plugin-jsdoc: 1.1.1 prettier-plugin-svelte: ^3.0.3 - prismic-ts-codegen: ^0.1.17 + prismic-ts-codegen: ^0.1.20 size-limit: 8.2.4 svelte: 4.2.0 typescript: 4.9.5 @@ -8503,7 +8503,7 @@ __metadata: p-limit: ^4.0.0 prettier: ^3.0.3 prettier-plugin-jsdoc: 1.1.1 - prismic-ts-codegen: ^0.1.19 + prismic-ts-codegen: ^0.1.20 size-limit: 8.2.4 typescript: 4.9.5 vite: 4.3.9 @@ -27179,36 +27179,9 @@ __metadata: languageName: node linkType: hard -"prismic-ts-codegen@npm:^0.1.17": - version: 0.1.17 - resolution: "prismic-ts-codegen@npm:0.1.17" - dependencies: - "@prismicio/custom-types-client": ^1.1.0 - common-tags: ^1.8.2 - fast-glob: ^3.2.12 - jiti: ^1.18.2 - joi: ^17.9.2 - meow: ^12.0.1 - node-fetch: ^3.3.1 - pascal-case: ^3.1.2 - quick-lru: ^6.1.1 - peerDependencies: - "@prismicio/client": ^6.6 || ^7 - "@prismicio/types": ^0.2.8 - peerDependenciesMeta: - "@prismicio/client": - optional: true - "@prismicio/types": - optional: true - bin: - prismic-ts-codegen: bin/prismic-ts-codegen.js - checksum: 0dac0d18086facb475ee14d2851adbe1bf4c3ac05cf93bd20aae80bcdf9efbd6f455a1cd88c5aa8cb10bce07b03fc0dd270838d6f8c9682fa81c02840a124a1b - languageName: node - linkType: hard - -"prismic-ts-codegen@npm:^0.1.19": - version: 0.1.19 - resolution: "prismic-ts-codegen@npm:0.1.19" +"prismic-ts-codegen@npm:^0.1.20": + version: 0.1.20 + resolution: "prismic-ts-codegen@npm:0.1.20" dependencies: "@prismicio/custom-types-client": ^1.1.0 common-tags: ^1.8.2 @@ -27229,7 +27202,7 @@ __metadata: optional: true bin: prismic-ts-codegen: bin/prismic-ts-codegen.js - checksum: 18fdb161d276170786cf2a0300250f32a372810cb5fa8d2810e8c894249e162a8d918a4d0b61ba19196eab9e09c022b4a2a06fe33c0dd669c93f4b1cc12c19c8 + checksum: 575ddabb75ce31c047d32aed882c5bbef8d59a8390b5ea1721871f27e1b66ebe5a3de22db95ea40a0b31f5d6cc6e870a05789bb8bf54d8543d1c2c3e035e599b languageName: node linkType: hard From 052fbd64f39acbd0546dbc80bca14fbebc652bf5 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Mon, 17 Jun 2024 10:56:08 -1000 Subject: [PATCH 05/14] fix: move default "Meta Title" to the first field (#1389) --- packages/slice-machine/src/domain/customType.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/slice-machine/src/domain/customType.ts b/packages/slice-machine/src/domain/customType.ts index 84007ee41a..274af81a45 100644 --- a/packages/slice-machine/src/domain/customType.ts +++ b/packages/slice-machine/src/domain/customType.ts @@ -538,6 +538,14 @@ const DEFAULT_MAIN_WITH_UID_AND_SLICE_ZONE: CustomType["json"] = { const DEFAULT_SEO_TAB: CustomType["json"] = { "SEO & Metadata": { + meta_title: { + config: { + label: "Meta Title", + placeholder: + "A title of the page used for social media and search engines", + }, + type: "Text", + }, meta_description: { config: { label: "Meta Description", @@ -556,13 +564,5 @@ const DEFAULT_SEO_TAB: CustomType["json"] = { }, type: "Image", }, - meta_title: { - config: { - label: "Meta Title", - placeholder: - "A title of the page used for social media and search engines", - }, - type: "Text", - }, }, }; From 60fdb77d2aa6a7c8966dc727de371386b1c59c38 Mon Sep 17 00:00:00 2001 From: xrutayisire <19946868+xrutayisire@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:00:56 +0000 Subject: [PATCH 06/14] release: 9 new packages --- packages/adapter-next/package.json | 2 +- packages/adapter-nuxt/package.json | 2 +- packages/adapter-nuxt2/package.json | 2 +- packages/adapter-sveltekit/package.json | 2 +- packages/init/package.json | 2 +- packages/manager/package.json | 2 +- packages/plugin-kit/package.json | 2 +- packages/slice-machine/package.json | 2 +- packages/start-slicemachine/package.json | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/adapter-next/package.json b/packages/adapter-next/package.json index dcb9676baa..787dd3d8bd 100644 --- a/packages/adapter-next/package.json +++ b/packages/adapter-next/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-next", - "version": "0.3.41", + "version": "0.3.42", "description": "Slice Machine adapter for Next.js.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt/package.json b/packages/adapter-nuxt/package.json index 6b0d93d711..42f064afe4 100644 --- a/packages/adapter-nuxt/package.json +++ b/packages/adapter-nuxt/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt", - "version": "0.3.41", + "version": "0.3.42", "description": "Slice Machine adapter for Nuxt 3.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt2/package.json b/packages/adapter-nuxt2/package.json index d9adb43775..1732db200e 100644 --- a/packages/adapter-nuxt2/package.json +++ b/packages/adapter-nuxt2/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt2", - "version": "0.3.41", + "version": "0.3.42", "description": "Slice Machine adapter for Nuxt 2.", "keywords": [ "typescript", diff --git a/packages/adapter-sveltekit/package.json b/packages/adapter-sveltekit/package.json index a04066f538..0ab4eecd7e 100644 --- a/packages/adapter-sveltekit/package.json +++ b/packages/adapter-sveltekit/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-sveltekit", - "version": "0.3.41", + "version": "0.3.42", "description": "Slice Machine adapter for SvelteKit.", "keywords": [ "typescript", diff --git a/packages/init/package.json b/packages/init/package.json index 89a63063bd..d5362cce21 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/init", - "version": "2.9.19", + "version": "2.9.20", "description": "Init Prismic Slice Machine in your project", "keywords": [ "typescript", diff --git a/packages/manager/package.json b/packages/manager/package.json index 020bc414dd..17cc1d7fc4 100644 --- a/packages/manager/package.json +++ b/packages/manager/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/manager", - "version": "0.19.2", + "version": "0.19.3", "description": "Manage all aspects of a Slice Machine project.", "repository": { "type": "git", diff --git a/packages/plugin-kit/package.json b/packages/plugin-kit/package.json index a2aa178e71..01d52731ec 100644 --- a/packages/plugin-kit/package.json +++ b/packages/plugin-kit/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/plugin-kit", - "version": "0.4.41", + "version": "0.4.42", "description": "A set of helpers to develop and run Slice Machine plugins", "keywords": [ "typescript", diff --git a/packages/slice-machine/package.json b/packages/slice-machine/package.json index 00b0c06e52..1896db483c 100644 --- a/packages/slice-machine/package.json +++ b/packages/slice-machine/package.json @@ -1,6 +1,6 @@ { "name": "slice-machine-ui", - "version": "2.2.0", + "version": "2.2.1", "license": "MIT", "description": "A visual builder for your Slice Models with all the tools you need to generate data models and mock CMS content locally.", "repository": { diff --git a/packages/start-slicemachine/package.json b/packages/start-slicemachine/package.json index 63f0d31ca3..94ee4adcf5 100644 --- a/packages/start-slicemachine/package.json +++ b/packages/start-slicemachine/package.json @@ -1,6 +1,6 @@ { "name": "start-slicemachine", - "version": "0.12.21", + "version": "0.12.22", "description": "Start Slice Machine from within a project.", "repository": { "type": "git", From 6ef86c5c0c2720782b501a28ea9a6942e588644d Mon Sep 17 00:00:00 2001 From: Lucie <25330882+lihbr@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:03:15 +0200 Subject: [PATCH 07/14] feat: support nuxt 4 (#1388) Co-authored-by: lihbr Co-authored-by: Angelo Ashmore --- .../adapter-next/src/hooks/project-init.ts | 87 ++-- packages/adapter-next/src/lib/buildSrcPath.ts | 16 + .../adapter-next/src/lib/checkHasAppRouter.ts | 11 +- .../src/lib/checkHasSrcDirectory.ts | 18 - .../adapter-nuxt/src/hooks/project-init.ts | 94 ++-- packages/adapter-nuxt/src/lib/buildSrcPath.ts | 31 ++ .../src/lib/checkHasSrcDirectory.ts | 18 - .../test/plugin-project-init.test.ts | 412 ++++++++++-------- .../adapter-nuxt2/src/hooks/project-init.ts | 16 +- .../adapter-nuxt2/src/lib/buildSrcPath.ts | 20 + .../src/lib/checkHasSrcDirectory.ts | 18 - packages/init/src/lib/framework.ts | 12 +- 12 files changed, 403 insertions(+), 350 deletions(-) create mode 100644 packages/adapter-next/src/lib/buildSrcPath.ts delete mode 100644 packages/adapter-next/src/lib/checkHasSrcDirectory.ts create mode 100644 packages/adapter-nuxt/src/lib/buildSrcPath.ts delete mode 100644 packages/adapter-nuxt/src/lib/checkHasSrcDirectory.ts create mode 100644 packages/adapter-nuxt2/src/lib/buildSrcPath.ts delete mode 100644 packages/adapter-nuxt2/src/lib/checkHasSrcDirectory.ts diff --git a/packages/adapter-next/src/hooks/project-init.ts b/packages/adapter-next/src/hooks/project-init.ts index 6039197d69..c95cc7ad0e 100644 --- a/packages/adapter-next/src/hooks/project-init.ts +++ b/packages/adapter-next/src/hooks/project-init.ts @@ -1,4 +1,3 @@ -import * as path from "node:path"; import type { ProjectInitHook, ProjectInitHookData, @@ -10,8 +9,8 @@ import { } from "@slicemachine/plugin-kit/fs"; import { source } from "common-tags"; +import { buildSrcPath } from "../lib/buildSrcPath"; import { checkHasAppRouter } from "../lib/checkHasAppRouter"; -import { checkHasSrcDirectory } from "../lib/checkHasSrcDirectory"; import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject"; import { getJSFileExtension } from "../lib/getJSFileExtension"; import { rejectIfNecessary } from "../lib/rejectIfNecessary"; @@ -45,15 +44,17 @@ const createPrismicIOFile = async ({ helpers, options, }); - const hasSrcDirectory = await checkHasSrcDirectory({ helpers }); + const hasSrcDirectory = await checkHasProjectFile({ + filename: "src", + helpers, + }); const hasAppRouter = await checkHasAppRouter({ helpers }); const extension = await getJSFileExtension({ helpers, options }); - const filename = path.join( - ...[hasSrcDirectory ? "src" : undefined, `prismicio.${extension}`].filter( - (segment): segment is NonNullable => Boolean(segment), - ), - ); + const filename = await buildSrcPath({ + filename: `prismicio.${extension}`, + helpers, + }); if (await checkHasProjectFile({ filename, helpers })) { return; @@ -255,20 +256,15 @@ const createSliceSimulatorPage = async ({ helpers, options, }); - const hasSrcDirectory = await checkHasSrcDirectory({ helpers }); const hasAppRouter = await checkHasAppRouter({ helpers }); const extension = await getJSFileExtension({ helpers, options, jsx: true }); - const filename = path.join( - ...[ - hasSrcDirectory ? "src" : undefined, - hasAppRouter - ? `app/slice-simulator/page.${extension}` - : `pages/slice-simulator.${extension}`, - ].filter((segment): segment is NonNullable => - Boolean(segment), - ), - ); + const filename = await buildSrcPath({ + filename: hasAppRouter + ? `app/slice-simulator/page.${extension}` + : `pages/slice-simulator.${extension}`, + helpers, + }); if (await checkHasProjectFile({ filename, helpers })) { return; @@ -350,7 +346,6 @@ const createPreviewRoute = async ({ helpers, options, }: SliceMachineContext) => { - const hasSrcDirectory = await checkHasSrcDirectory({ helpers }); const hasAppRouter = await checkHasAppRouter({ helpers }); const isTypeScriptProject = await checkIsTypeScriptProject({ helpers, @@ -358,16 +353,12 @@ const createPreviewRoute = async ({ }); const extension = await getJSFileExtension({ helpers, options }); - const filename = path.join( - ...[ - hasSrcDirectory ? "src" : undefined, - hasAppRouter - ? `app/api/preview/route.${extension}` - : `pages/api/preview.${extension}`, - ].filter((segment): segment is NonNullable => - Boolean(segment), - ), - ); + const filename = await buildSrcPath({ + filename: hasAppRouter + ? `app/api/preview/route.${extension}` + : `pages/api/preview.${extension}`, + helpers, + }); if (await checkHasProjectFile({ filename, helpers })) { return; @@ -447,7 +438,6 @@ const createExitPreviewRoute = async ({ helpers, options, }: SliceMachineContext) => { - const hasSrcDirectory = await checkHasSrcDirectory({ helpers }); const hasAppRouter = await checkHasAppRouter({ helpers }); const isTypeScriptProject = await checkIsTypeScriptProject({ helpers, @@ -455,16 +445,12 @@ const createExitPreviewRoute = async ({ }); const extension = await getJSFileExtension({ helpers, options }); - const filename = path.join( - ...[ - hasSrcDirectory ? "src" : undefined, - hasAppRouter - ? `app/api/exit-preview/route.${extension}` - : `pages/api/exit-preview.${extension}`, - ].filter((segment): segment is NonNullable => - Boolean(segment), - ), - ); + const filename = await buildSrcPath({ + filename: hasAppRouter + ? `app/api/exit-preview/route.${extension}` + : `pages/api/exit-preview.${extension}`, + helpers, + }); if (await checkHasProjectFile({ filename, helpers })) { return; @@ -514,7 +500,10 @@ const modifySliceMachineConfig = async ({ options, actions, }: SliceMachineContext) => { - const hasSrcDirectory = await checkHasSrcDirectory({ helpers }); + const hasSrcDirectory = await checkHasProjectFile({ + filename: "src", + helpers, + }); const project = await helpers.getProject(); // Add Slice Simulator URL. @@ -552,17 +541,11 @@ const createRevalidateRoute = async ({ return; } - const hasSrcDirectory = await checkHasSrcDirectory({ helpers }); - const extension = await getJSFileExtension({ helpers, options }); - const filename = path.join( - ...[ - hasSrcDirectory ? "src" : undefined, - `app/api/revalidate/route.${extension}`, - ].filter((segment): segment is NonNullable => - Boolean(segment), - ), - ); + const filename = await buildSrcPath({ + filename: `app/api/revalidate/route.${extension}`, + helpers, + }); if (await checkHasProjectFile({ filename, helpers })) { return; diff --git a/packages/adapter-next/src/lib/buildSrcPath.ts b/packages/adapter-next/src/lib/buildSrcPath.ts new file mode 100644 index 0000000000..a04ba336cd --- /dev/null +++ b/packages/adapter-next/src/lib/buildSrcPath.ts @@ -0,0 +1,16 @@ +import * as path from "node:path"; + +import type { SliceMachineHelpers } from "@slicemachine/plugin-kit"; +import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs"; + +export async function buildSrcPath(args: { + filename: string; + helpers: SliceMachineHelpers; +}): Promise { + const hasSrcDirectory = await checkHasProjectFile({ + filename: "src", + helpers: args.helpers, + }); + + return hasSrcDirectory ? path.join("src", args.filename) : args.filename; +} diff --git a/packages/adapter-next/src/lib/checkHasAppRouter.ts b/packages/adapter-next/src/lib/checkHasAppRouter.ts index 49fd47ce5f..e0219283c1 100644 --- a/packages/adapter-next/src/lib/checkHasAppRouter.ts +++ b/packages/adapter-next/src/lib/checkHasAppRouter.ts @@ -1,9 +1,9 @@ import { SliceMachineContext } from "@slicemachine/plugin-kit"; import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs"; -import * as path from "node:path"; import { PluginOptions } from "../types"; -import { checkHasSrcDirectory } from "./checkHasSrcDirectory"; + +import { buildSrcPath } from "./buildSrcPath"; type CheckHasAppRouterArgs = Pick< SliceMachineContext, @@ -13,10 +13,13 @@ type CheckHasAppRouterArgs = Pick< export async function checkHasAppRouter( args: CheckHasAppRouterArgs, ): Promise { - const hasSrcDirectory = await checkHasSrcDirectory({ helpers: args.helpers }); + const appRouterPath = await buildSrcPath({ + filename: "app", + helpers: args.helpers, + }); return await checkHasProjectFile({ - filename: hasSrcDirectory ? path.join("src", "app") : "app", + filename: appRouterPath, helpers: args.helpers, }); } diff --git a/packages/adapter-next/src/lib/checkHasSrcDirectory.ts b/packages/adapter-next/src/lib/checkHasSrcDirectory.ts deleted file mode 100644 index 8c38cf321b..0000000000 --- a/packages/adapter-next/src/lib/checkHasSrcDirectory.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { SliceMachineContext } from "@slicemachine/plugin-kit"; -import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs"; - -import { PluginOptions } from "../types"; - -type CheckHasSrcDirectoryArgs = Pick< - SliceMachineContext, - "helpers" ->; - -export async function checkHasSrcDirectory( - args: CheckHasSrcDirectoryArgs, -): Promise { - return await checkHasProjectFile({ - filename: "src", - helpers: args.helpers, - }); -} diff --git a/packages/adapter-nuxt/src/hooks/project-init.ts b/packages/adapter-nuxt/src/hooks/project-init.ts index f3319e4dbd..8f5e51714b 100644 --- a/packages/adapter-nuxt/src/hooks/project-init.ts +++ b/packages/adapter-nuxt/src/hooks/project-init.ts @@ -13,9 +13,9 @@ import { import { stripIndent } from "common-tags"; import { builders, loadFile, writeFile } from "magicast"; +import { buildSrcPath } from "../lib/buildSrcPath"; import { rejectIfNecessary } from "../lib/rejectIfNecessary"; import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject"; -import { checkHasSrcDirectory } from "../lib/checkHasSrcDirectory"; import type { PluginOptions } from "../types"; @@ -28,23 +28,12 @@ type InstallDependenciesArgs = { const installDependencies = async ({ installDependencies, }: InstallDependenciesArgs) => { - try { - await installDependencies({ - dependencies: { - [NUXT_PRISMIC]: "^3.0.0", - }, - dev: true, - }); - } catch (error) { - // TODO: Remove when latest is published and documented - // Fallback to RC if latest is still not available - await installDependencies({ - dependencies: { - [NUXT_PRISMIC]: "rc", - }, - dev: true, - }); - } + await installDependencies({ + dependencies: { + [NUXT_PRISMIC]: "^3.3.0", + }, + dev: true, + }); }; type ConfigurePrismicModuleArgs = SliceMachineContext; @@ -125,15 +114,36 @@ const createSliceSimulatorPage = async ({ options, }); + const appPagesDirectoryExists = await checkHasProjectFile({ + filename: "app/pages", + helpers, + }); + const srcPagesDirectoryExists = await checkHasProjectFile({ filename: "src/pages", helpers, }); - const filename = path.join( - srcPagesDirectoryExists ? "src/pages" : "pages", - "slice-simulator.vue", - ); + const pagesDirectoryExists = await checkHasProjectFile({ + filename: "pages", + helpers, + }); + + let filename: string; + // We first give priority to existing `pages` directory, then to `srcDir` + // because there could be conflicts with legacy `app` directory. + if (appPagesDirectoryExists) { + filename = path.join("app/pages", "slice-simulator.vue"); + } else if (srcPagesDirectoryExists) { + filename = path.join("src/pages", "slice-simulator.vue"); + } else if (pagesDirectoryExists) { + filename = path.join("pages", "slice-simulator.vue"); + } else { + filename = await buildSrcPath({ + filename: path.join("pages", "slice-simulator.vue"), + helpers, + }); + } if (await checkHasProjectFile({ filename, helpers })) { return; @@ -169,14 +179,9 @@ const moveOrDeleteAppVue = async ({ helpers, options, }: CreateSliceSimulatorPageArgs) => { - const srcDirectoryExists = await checkHasProjectFile({ - filename: "src", - helpers, - }); + const filenameAppVue = await buildSrcPath({ filename: "app.vue", helpers }); - const filenameAppVue = path.join(srcDirectoryExists ? "src" : "", "app.vue"); - - // If there's not `app.vue`, there's nothing to do. + // If there's no `app.vue`, there's nothing to do. if (!(await checkHasProjectFile({ filename: filenameAppVue, helpers }))) { return; } @@ -187,21 +192,17 @@ const moveOrDeleteAppVue = async ({ encoding: "utf-8", }); - // We check for app.vue to contain Nuxt default welcome component to determine if we need to consider it as the default one or not. + // We check for app.vue to contain Nuxt default welcome component to determine + // if we need to consider it as the default one or not. if (!filecontentAppVue.includes(") => { - const hasSrcDirectory = await checkHasSrcDirectory({ helpers }); + const hasAppDirectory = await checkHasProjectFile({ + filename: "app", + helpers, + }); + const hasSrcDirectory = await checkHasProjectFile({ + filename: "src", + helpers, + }); const project = await helpers.getProject(); // Add Slice Simulator URL. project.config.localSliceSimulatorURL ||= "http://localhost:3000/slice-simulator"; - // Nest the default Slice Library in the src directory if it exists and - // is empty. + // Nest the default Slice Library in the `app` or `src` directory if it + // exists and is empty. if ( - hasSrcDirectory && + (hasAppDirectory || hasSrcDirectory) && project.config.libraries && JSON.stringify(project.config.libraries) === JSON.stringify(["./slices"]) ) { @@ -243,7 +251,9 @@ const modifySliceMachineConfig = async ({ }); if (sliceLibrary.sliceIDs.length < 1) { - project.config.libraries = ["./src/slices"]; + project.config.libraries = hasAppDirectory + ? ["./app/slices"] + : ["./src/slices"]; } } diff --git a/packages/adapter-nuxt/src/lib/buildSrcPath.ts b/packages/adapter-nuxt/src/lib/buildSrcPath.ts new file mode 100644 index 0000000000..e9da41422e --- /dev/null +++ b/packages/adapter-nuxt/src/lib/buildSrcPath.ts @@ -0,0 +1,31 @@ +// TODO: If Nuxt provides a way to read `nuxt.config.js`'s `srcDir` value, we +// can use the exact value given. The current implementation does not support +// custom values different than "app" or "src". + +import * as path from "node:path"; + +import { SliceMachineHelpers } from "@slicemachine/plugin-kit"; +import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs"; + +export async function buildSrcPath(args: { + filename: string; + helpers: SliceMachineHelpers; +}): Promise { + const hasAppDirectory = await checkHasProjectFile({ + filename: "app", + helpers: args.helpers, + }); + if (hasAppDirectory) { + return path.join("app", args.filename); + } + + const hasSrcDirectory = await checkHasProjectFile({ + filename: "src", + helpers: args.helpers, + }); + if (hasSrcDirectory) { + return path.join("src", args.filename); + } + + return args.filename; +} diff --git a/packages/adapter-nuxt/src/lib/checkHasSrcDirectory.ts b/packages/adapter-nuxt/src/lib/checkHasSrcDirectory.ts deleted file mode 100644 index 8c38cf321b..0000000000 --- a/packages/adapter-nuxt/src/lib/checkHasSrcDirectory.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { SliceMachineContext } from "@slicemachine/plugin-kit"; -import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs"; - -import { PluginOptions } from "../types"; - -type CheckHasSrcDirectoryArgs = Pick< - SliceMachineContext, - "helpers" ->; - -export async function checkHasSrcDirectory( - args: CheckHasSrcDirectoryArgs, -): Promise { - return await checkHasProjectFile({ - filename: "src", - helpers: args.helpers, - }); -} diff --git a/packages/adapter-nuxt/test/plugin-project-init.test.ts b/packages/adapter-nuxt/test/plugin-project-init.test.ts index 4a8dd145d3..4fbedc9da4 100644 --- a/packages/adapter-nuxt/test/plugin-project-init.test.ts +++ b/packages/adapter-nuxt/test/plugin-project-init.test.ts @@ -14,7 +14,7 @@ test("installs dependencies", async (ctx) => { expect(installDependencies).toHaveBeenCalledWith({ dependencies: { - "@nuxtjs/prismic": "^3.0.0", + "@nuxtjs/prismic": "^3.3.0", }, dev: true, }); @@ -108,169 +108,208 @@ export default defineNuxtConfig({ }); }); -describe("Slice Simulator page", () => { - test("creates a Slice Simulator page file", async (ctx) => { - const log = vi.fn(); - const installDependencies = vi.fn(); +describe.each(["./app", "./src", "./"])( + "Slice Simulator page (srcDir: %s)", + (srcDir) => { + test("creates a Slice Simulator page file", async (ctx) => { + const log = vi.fn(); + const installDependencies = vi.fn(); - await ctx.pluginRunner.callHook("project:init", { - log, - installDependencies, - }); + await fs.mkdir(path.join(ctx.project.root, srcDir), { + recursive: true, + }); - const contents = await fs.readFile( - path.join(ctx.project.root, "pages", "slice-simulator.vue"), - "utf8", - ); + await ctx.pluginRunner.callHook("project:init", { + log, + installDependencies, + }); - expect(contents).toMatchInlineSnapshot(` - " - - - " - `); - }); + const contents = await fs.readFile( + path.join(ctx.project.root, srcDir, "pages", "slice-simulator.vue"), + "utf8", + ); - test("creates a TypeScript Slice Simulator page file when TypeScript is enabled", async (ctx) => { - ctx.project.config.adapter.options.typescript = true; - const pluginRunner = createSliceMachinePluginRunner({ - project: ctx.project, - nativePlugins: { - [ctx.project.config.adapter.resolve]: adapter, - }, - }); - await pluginRunner.init(); + expect(contents).toBe(` - const log = vi.fn(); - const installDependencies = vi.fn(); + +`); + }); - await pluginRunner.callHook("project:init", { log, installDependencies }); + test("creates a TypeScript Slice Simulator page file when TypeScript is enabled", async (ctx) => { + ctx.project.config.adapter.options.typescript = true; + const pluginRunner = createSliceMachinePluginRunner({ + project: ctx.project, + nativePlugins: { + [ctx.project.config.adapter.resolve]: adapter, + }, + }); + await pluginRunner.init(); - const contents = await fs.readFile( - path.join(ctx.project.root, "pages", "slice-simulator.vue"), - "utf8", - ); + const log = vi.fn(); + const installDependencies = vi.fn(); - expect(contents).toMatchInlineSnapshot(` - " - - - " - `); - }); + await fs.mkdir(path.join(ctx.project.root, srcDir), { + recursive: true, + }); - test("does not overwrite Slice Simulator page file if it already exists", async (ctx) => { - const log = vi.fn(); - const installDependencies = vi.fn(); + await pluginRunner.callHook("project:init", { log, installDependencies }); - const filePath = path.join( - ctx.project.root, - "pages", - "slice-simulator.vue", - ); - const contents = "foo"; + const contents = await fs.readFile( + path.join(ctx.project.root, srcDir, "pages", "slice-simulator.vue"), + "utf8", + ); - await fs.mkdir(path.dirname(filePath), { recursive: true }); - await fs.writeFile(filePath, contents); + expect(contents).toBe(` - await ctx.pluginRunner.callHook("project:init", { - log, - installDependencies, + +`); }); - const postHookContents = await fs.readFile(filePath, "utf8"); - - expect(postHookContents).toBe(contents); - }); + test("does not overwrite Slice Simulator page file if it already exists", async (ctx) => { + const log = vi.fn(); + const installDependencies = vi.fn(); - test("creates Slice Simulator page file in the src directory if it exists", async (ctx) => { - const log = vi.fn(); - const installDependencies = vi.fn(); + await fs.mkdir(path.join(ctx.project.root, srcDir), { + recursive: true, + }); - await fs.mkdir(path.join(ctx.project.root, "src/pages"), { - recursive: true, - }); - - await ctx.pluginRunner.callHook("project:init", { - log, - installDependencies, - }); + const filePath = path.join( + ctx.project.root, + srcDir, + "pages", + "slice-simulator.vue", + ); + const contents = "foo"; - const pagesDir = await fs.readdir( - path.join(ctx.project.root, "src", "pages"), - ); + await fs.mkdir(path.dirname(filePath), { recursive: true }); + await fs.writeFile(filePath, contents); - expect(pagesDir).toContain("slice-simulator.vue"); - }); + await ctx.pluginRunner.callHook("project:init", { + log, + installDependencies, + }); - test("Slice Simulator page file is formatted by default", async (ctx) => { - const log = vi.fn(); - const installDependencies = vi.fn(); + const postHookContents = await fs.readFile(filePath, "utf8"); - await ctx.pluginRunner.callHook("project:init", { - log, - installDependencies, + expect(postHookContents).toBe(contents); }); - const contents = await fs.readFile( - path.join(ctx.project.root, "pages", "slice-simulator.vue"), - "utf8", - ); - - expect(contents).toBe(await prettier.format(contents, { parser: "vue" })); - }); + describe.each(["./app/pages", "./src/pages", "./pages"])( + "(pagesDir: %s)", + (pagesDir) => { + test("prefers existing pages directory over assumed srcDir", async (ctx) => { + const log = vi.fn(); + const installDependencies = vi.fn(); + + await fs.mkdir(path.join(ctx.project.root, srcDir), { + recursive: true, + }); + await fs.mkdir(path.join(ctx.project.root, pagesDir), { + recursive: true, + }); + + await ctx.pluginRunner.callHook("project:init", { + log, + installDependencies, + }); + + const contents = await fs.readFile( + path.join(ctx.project.root, pagesDir, "slice-simulator.vue"), + "utf8", + ); + + expect(contents).toBe(` - test("Slice Simulator page file is not formatted if formatting is disabled", async (ctx) => { - ctx.project.config.adapter.options.format = false; - const pluginRunner = createSliceMachinePluginRunner({ - project: ctx.project, - nativePlugins: { - [ctx.project.config.adapter.resolve]: adapter, + +`); + }); }, - }); - await pluginRunner.init(); - - // Force unusual formatting to detect that formatting did not happen. - const prettierOptions = { printWidth: 10 }; - await fs.writeFile( - path.join(ctx.project.root, ".prettierrc"), - JSON.stringify(prettierOptions), ); - const log = vi.fn(); - const installDependencies = vi.fn(); + test("Slice Simulator page file is formatted by default", async (ctx) => { + const log = vi.fn(); + const installDependencies = vi.fn(); - await pluginRunner.callHook("project:init", { log, installDependencies }); + await fs.mkdir(path.join(ctx.project.root, srcDir), { + recursive: true, + }); - const contents = await fs.readFile( - path.join(ctx.project.root, "pages", "slice-simulator.vue"), - "utf8", - ); + await ctx.pluginRunner.callHook("project:init", { + log, + installDependencies, + }); - expect(contents).not.toBe( - await prettier.format(contents, { - ...prettierOptions, - parser: "vue", - }), - ); - }); -}); + const contents = await fs.readFile( + path.join(ctx.project.root, srcDir, "pages", "slice-simulator.vue"), + "utf8", + ); -describe("app.vue", () => { + expect(contents).toBe(await prettier.format(contents, { parser: "vue" })); + }); + + test("Slice Simulator page file is not formatted if formatting is disabled", async (ctx) => { + ctx.project.config.adapter.options.format = false; + const pluginRunner = createSliceMachinePluginRunner({ + project: ctx.project, + nativePlugins: { + [ctx.project.config.adapter.resolve]: adapter, + }, + }); + await pluginRunner.init(); + + // Force unusual formatting to detect that formatting did not happen. + const prettierOptions = { printWidth: 10 }; + await fs.writeFile( + path.join(ctx.project.root, ".prettierrc"), + JSON.stringify(prettierOptions), + ); + + const log = vi.fn(); + const installDependencies = vi.fn(); + + await fs.mkdir(path.join(ctx.project.root, srcDir), { + recursive: true, + }); + + await pluginRunner.callHook("project:init", { log, installDependencies }); + + const contents = await fs.readFile( + path.join(ctx.project.root, srcDir, "pages", "slice-simulator.vue"), + "utf8", + ); + + expect(contents).not.toBe( + await prettier.format(contents, { + ...prettierOptions, + parser: "vue", + }), + ); + }); + }, +); + +describe.each(["./app", "./src", "./"])("app.vue (srcDir: %s)", (srcDir) => { const NUXT_DEFAULT_APP_VUE = /* html */ ` `; - test("deletes default app.vue and creates a new index page if non-existent", async (ctx) => { + test(`deletes default app.vue and creates a new index page if non-existent`, async (ctx) => { const log = vi.fn(); const installDependencies = vi.fn(); - const filePathAppVue = path.join(ctx.project.root, "app.vue"); + const filePathAppVue = path.join(ctx.project.root, srcDir, "app.vue"); await fs.mkdir(path.dirname(filePathAppVue), { recursive: true }); await fs.writeFile(filePathAppVue, NUXT_DEFAULT_APP_VUE); @@ -293,7 +332,7 @@ describe("app.vue", () => { }); const contents = await fs.readFile( - path.join(ctx.project.root, "pages", "index.vue"), + path.join(ctx.project.root, srcDir, "pages", "index.vue"), "utf8", ); @@ -303,16 +342,21 @@ describe("app.vue", () => { expect(contents).toBe(NUXT_DEFAULT_APP_VUE); }); - test("deletes default app.vue and doesn't create a new index page if existent", async (ctx) => { + test(`deletes default app.vue and doesn't create a new index page if existent`, async (ctx) => { const log = vi.fn(); const installDependencies = vi.fn(); - const filePathAppVue = path.join(ctx.project.root, "app.vue"); + const filePathAppVue = path.join(ctx.project.root, srcDir, "app.vue"); await fs.mkdir(path.dirname(filePathAppVue), { recursive: true }); await fs.writeFile(filePathAppVue, NUXT_DEFAULT_APP_VUE); - const filePathIndexVue = path.join(ctx.project.root, "pages", "index.vue"); + const filePathIndexVue = path.join( + ctx.project.root, + srcDir, + "pages", + "index.vue", + ); const contents = "foo"; await fs.mkdir(path.dirname(filePathIndexVue), { recursive: true }); @@ -331,11 +375,11 @@ describe("app.vue", () => { expect(postHookContents).toBe(contents); }); - test("doesn't delete app.vue is it's not the default one", async (ctx) => { + test(`doesn't delete app.vue is it's not the default one`, async (ctx) => { const log = vi.fn(); const installDependencies = vi.fn(); - const filePathAppVue = path.join(ctx.project.root, "app.vue"); + const filePathAppVue = path.join(ctx.project.root, srcDir, "app.vue"); const contents = "foo"; await fs.mkdir(path.dirname(filePathAppVue), { recursive: true }); @@ -404,54 +448,56 @@ describe("modify slicemachine.config.json", () => { ); }); - test("nests default Slice Library under src directory if it exists", async (ctx) => { - const log = vi.fn(); - const installDependencies = vi.fn(); + describe.each(["./app", "./src"])("(srcDir: %s)", (dir) => { + test(`nests default Slice Library under ${dir} directory if it exists`, async (ctx) => { + const log = vi.fn(); + const installDependencies = vi.fn(); - await fs.mkdir(path.join(ctx.project.root, "src"), { recursive: true }); + await fs.mkdir(path.join(ctx.project.root, dir), { recursive: true }); - await ctx.pluginRunner.callHook("project:init", { - log, - installDependencies, - }); - - const contents = JSON.parse( - await fs.readFile( - path.join(ctx.project.root, "slicemachine.config.json"), - "utf8", - ), - ); - - expect(contents.libraries).toStrictEqual(["./src/slices"]); - }); + await ctx.pluginRunner.callHook("project:init", { + log, + installDependencies, + }); - test("does not nest the default Slice Library under src directory if it is not empty", async (ctx) => { - const log = vi.fn(); - const installDependencies = vi.fn(); - - await fs.mkdir(path.join(ctx.project.root, "src"), { recursive: true }); + const contents = JSON.parse( + await fs.readFile( + path.join(ctx.project.root, "slicemachine.config.json"), + "utf8", + ), + ); - await fs.mkdir(path.join(ctx.project.root, "slices", "FooBar"), { - recursive: true, + expect(contents.libraries).toStrictEqual([`${dir}/slices`]); }); - await fs.writeFile( - path.join(ctx.project.root, "slices", "FooBar", "model.json"), - JSON.stringify(ctx.mock.model.sharedSlice()), - ); - await ctx.pluginRunner.callHook("project:init", { - log, - installDependencies, + test(`does not nest the default Slice Library under ${dir} directory if it is not empty`, async (ctx) => { + const log = vi.fn(); + const installDependencies = vi.fn(); + + await fs.mkdir(path.join(ctx.project.root, dir), { recursive: true }); + + await fs.mkdir(path.join(ctx.project.root, "slices", "FooBar"), { + recursive: true, + }); + await fs.writeFile( + path.join(ctx.project.root, "slices", "FooBar", "model.json"), + JSON.stringify(ctx.mock.model.sharedSlice()), + ); + + await ctx.pluginRunner.callHook("project:init", { + log, + installDependencies, + }); + + const contents = JSON.parse( + await fs.readFile( + path.join(ctx.project.root, "slicemachine.config.json"), + "utf8", + ), + ); + + expect(contents.libraries).toStrictEqual(["./slices"]); }); - - const contents = JSON.parse( - await fs.readFile( - path.join(ctx.project.root, "slicemachine.config.json"), - "utf8", - ), - ); - - expect(contents.libraries).toStrictEqual(["./slices"]); }); test("does not modify Slice Library if it is not the default", async (ctx) => { diff --git a/packages/adapter-nuxt2/src/hooks/project-init.ts b/packages/adapter-nuxt2/src/hooks/project-init.ts index 8d681b9913..def3d36cb3 100644 --- a/packages/adapter-nuxt2/src/hooks/project-init.ts +++ b/packages/adapter-nuxt2/src/hooks/project-init.ts @@ -11,8 +11,8 @@ import { import { stripIndent } from "common-tags"; import { builders, loadFile, writeFile } from "magicast"; +import { buildSrcPath } from "../lib/buildSrcPath"; import { rejectIfNecessary } from "../lib/rejectIfNecessary"; -import { checkHasSrcDirectory } from "../lib/checkHasSrcDirectory"; import type { PluginOptions } from "../types"; @@ -141,16 +141,11 @@ const createSliceSimulatorPage = async ({ helpers, options, }: CreateSliceSimulatorPageArgs) => { - const srcPagesDirectoryExists = await checkHasProjectFile({ - filename: "src/pages", + const filename = await buildSrcPath({ + filename: path.join("pages", "slice-simulator.vue"), helpers, }); - const filename = path.join( - srcPagesDirectoryExists ? "src/pages" : "pages", - "slice-simulator.vue", - ); - if (await checkHasProjectFile({ filename, helpers })) { return; } @@ -190,7 +185,10 @@ const modifySliceMachineConfig = async ({ options, actions, }: SliceMachineContext) => { - const hasSrcDirectory = await checkHasSrcDirectory({ helpers }); + const hasSrcDirectory = await checkHasProjectFile({ + filename: "src", + helpers, + }); const project = await helpers.getProject(); // Add Slice Simulator URL. diff --git a/packages/adapter-nuxt2/src/lib/buildSrcPath.ts b/packages/adapter-nuxt2/src/lib/buildSrcPath.ts new file mode 100644 index 0000000000..fb6a612ddc --- /dev/null +++ b/packages/adapter-nuxt2/src/lib/buildSrcPath.ts @@ -0,0 +1,20 @@ +// TODO: If Nuxt provides a way to read `nuxt.config.js`'s `srcDir` value, we +// can use the exact value given. The current implementation does not support +// custom values different than "src". + +import * as path from "node:path"; + +import type { SliceMachineHelpers } from "@slicemachine/plugin-kit"; +import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs"; + +export async function buildSrcPath(args: { + filename: string; + helpers: SliceMachineHelpers; +}): Promise { + const hasSrcDirectory = await checkHasProjectFile({ + filename: "src", + helpers: args.helpers, + }); + + return hasSrcDirectory ? path.join("src", args.filename) : args.filename; +} diff --git a/packages/adapter-nuxt2/src/lib/checkHasSrcDirectory.ts b/packages/adapter-nuxt2/src/lib/checkHasSrcDirectory.ts deleted file mode 100644 index 8c38cf321b..0000000000 --- a/packages/adapter-nuxt2/src/lib/checkHasSrcDirectory.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { SliceMachineContext } from "@slicemachine/plugin-kit"; -import { checkHasProjectFile } from "@slicemachine/plugin-kit/fs"; - -import { PluginOptions } from "../types"; - -type CheckHasSrcDirectoryArgs = Pick< - SliceMachineContext, - "helpers" ->; - -export async function checkHasSrcDirectory( - args: CheckHasSrcDirectoryArgs, -): Promise { - return await checkHasProjectFile({ - filename: "src", - helpers: args.helpers, - }); -} diff --git a/packages/init/src/lib/framework.ts b/packages/init/src/lib/framework.ts index d500973dd0..339a9ebaa3 100644 --- a/packages/init/src/lib/framework.ts +++ b/packages/init/src/lib/framework.ts @@ -18,7 +18,7 @@ export type Framework = { sliceMachineTelemetryID: | "next" | "nuxt-2" - | "nuxt-3" + | "nuxt" | "sveltekit-1" | "sveltekit-2" | "universal"; @@ -94,14 +94,14 @@ export const FRAMEWORKS: Record = { "@slicemachine/adapter-nuxt2": npmDistributionTag, }, }, - "nuxt-3": { - name: "Nuxt 3", - sliceMachineTelemetryID: "nuxt-3", + nuxt: { + name: "Nuxt", + sliceMachineTelemetryID: "nuxt", wroomTelemetryID: "nuxt", - prismicDocumentation: "https://prismic.dev/init/nuxt-3", + prismicDocumentation: "https://prismic.dev/init/nuxt", adapterName: "@slicemachine/adapter-nuxt", compatibility: { - nuxt: "^3.0.0", + nuxt: "^3.0.0 || ^4.0.0-rc.0", }, devDependencies: { ...DEFAULT_DEV_DEPENDENCIES, From f182231815e61cf6b3450d44634e78c1de5c53bd Mon Sep 17 00:00:00 2001 From: Levi Mykel Gable <9385378+levimykel@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:11:41 +0200 Subject: [PATCH 08/14] fix (next config): roll back to a previous import of package.json (#1385) --- packages/slice-machine/next.config.mjs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/slice-machine/next.config.mjs b/packages/slice-machine/next.config.mjs index dba1e54c39..69560d2175 100644 --- a/packages/slice-machine/next.config.mjs +++ b/packages/slice-machine/next.config.mjs @@ -1,7 +1,17 @@ +import * as fs from "node:fs"; +import * as path from "node:path"; +import * as url from "node:url"; + import { withSentryConfig } from "@sentry/nextjs"; import semver from "semver"; -import pkg from "./package.json" assert { type: "json" }; +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); + +/** @type {{ name: string, version: string }} */ +// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment +const pkg = JSON.parse( + fs.readFileSync(path.resolve(__dirname, "package.json"), "utf8"), +); const parsedPkgVersion = semver.parse(pkg.version); if (parsedPkgVersion === null) { From ed935a5bfa2294a5c76c3d51e99346b6d56b341d Mon Sep 17 00:00:00 2001 From: Levi Mykel Gable <9385378+levimykel@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:20:24 +0200 Subject: [PATCH 09/14] feat(slice-machine-ui): add support for advanced groups (#1383) --- package.json | 2 +- packages/adapter-next/package.json | 4 +- .../adapter-next/src/hooks/snippet-read.ts | 6 +- .../test/plugin-snippet-read.test.ts | 11 +- packages/adapter-nuxt/package.json | 4 +- .../adapter-nuxt/src/hooks/snippet-read.ts | 6 +- .../test/plugin-snippet-read.test.ts | 11 +- packages/adapter-nuxt2/package.json | 4 +- .../adapter-nuxt2/src/hooks/snippet-read.ts | 6 +- .../test/plugin-snippet-read.test.ts | 11 +- packages/adapter-sveltekit/package.json | 4 +- .../src/hooks/snippet-read.ts | 6 +- .../test/plugin-snippet-read.test.ts | 11 +- packages/manager/package.json | 8 +- packages/plugin-kit/package.json | 8 +- packages/plugin-kit/src/hooks/snippet-read.ts | 6 + packages/slice-machine/package.json | 12 +- .../src/hooks/useNestedGroupExperiment.ts | 8 + .../src/legacy/components/ListItem/index.tsx | 2 +- .../CustomTypeBuilder/TabZone/index.tsx | 24 +- .../SliceBuilder/FieldZones/index.tsx | 29 +- .../SliceBuilder/VariationsList/index.tsx | 6 +- .../lib/builders/SliceBuilder/index.tsx | 2 +- .../lib/builders/common/EditModal/index.jsx | 2 +- .../Zone/Card/components/Hints/index.tsx | 9 +- .../common/Zone/Card/components/NewField.tsx | 2 +- .../lib/builders/common/Zone/Card/index.jsx | 4 +- .../src/legacy/lib/builders/utils/index.ts | 8 + .../src/legacy/lib/models/common/Group.ts | 79 +++-- .../common/widgets/Group/ListItem/index.jsx | 30 +- .../common/widgets/Group/createGroupWidget.ts | 83 +++++ .../lib/models/common/widgets/Group/index.ts | 44 --- .../lib/models/common/widgets/Group/index.tsx | 72 +++++ .../common/widgets/NestedGroup/index.tsx | 40 +++ .../lib/models/common/widgets/Widget.ts | 11 +- .../models/common/widgets/ctBuilderArray.ts | 20 -- .../common/widgets/groupBuilderArray.ts | 18 -- .../lib/models/common/widgets/groupWidgets.ts | 7 + .../legacy/lib/models/common/widgets/index.ts | 38 +-- .../models/common/widgets/nonGroupWidgets.ts | 33 ++ .../common/widgets/sliceBuilderArray.ts | 19 -- .../lib/models/common/widgets/withGroup.ts | 2 - .../test/lib/builders/buildersUtils.test.ts | 2 +- .../lib/models/common/widgets/index.test.ts | 2 +- packages/start-slicemachine/package.json | 4 +- playwright/package.json | 2 +- playwright/pages/SliceBuilderPage.ts | 19 +- playwright/pages/shared/TypeBuilderPage.ts | 15 +- .../pageTypes/pageTypeBuilderFields.spec.ts | 265 +++++++++++++++ .../tests/slices/sliceBuilderFields.spec.ts | 269 ++++++++++++++++ yarn.lock | 303 ++++++------------ 51 files changed, 1137 insertions(+), 456 deletions(-) create mode 100644 packages/slice-machine/src/hooks/useNestedGroupExperiment.ts create mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/Group/createGroupWidget.ts delete mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/Group/index.ts create mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/Group/index.tsx create mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/NestedGroup/index.tsx delete mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/ctBuilderArray.ts delete mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/groupBuilderArray.ts create mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/groupWidgets.ts create mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/nonGroupWidgets.ts delete mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/sliceBuilderArray.ts delete mode 100644 packages/slice-machine/src/legacy/lib/models/common/widgets/withGroup.ts diff --git a/package.json b/package.json index ee93faf733..da061c65bd 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "resolutions": { "connected-next-router/react-redux": "8.0.7", "react-beautiful-dnd/react-redux": "8.0.7", - "@prismicio/types-internal": "2.4.1" + "@prismicio/types-internal": "2.5.0" }, "workspaces": [ "e2e-projects/next", diff --git a/packages/adapter-next/package.json b/packages/adapter-next/package.json index 787dd3d8bd..b3fd5e26fc 100644 --- a/packages/adapter-next/package.json +++ b/packages/adapter-next/package.json @@ -67,7 +67,7 @@ }, "dependencies": { "@prismicio/simulator": "^0.1.4", - "@prismicio/types-internal": "^2.4.1", + "@prismicio/types-internal": "^2.5.0", "@slicemachine/plugin-kit": "workspace:*", "common-tags": "^1.8.2", "fp-ts": "^2.13.1", @@ -95,7 +95,7 @@ "next": "14.1.3", "prettier": "3.0.3", "prettier-plugin-jsdoc": "1.1.1", - "prismic-ts-codegen": "^0.1.20", + "prismic-ts-codegen": "^0.1.21", "react": "18.2.0", "rollup-plugin-preserve-directives": "0.2.0", "size-limit": "8.2.4", diff --git a/packages/adapter-next/src/hooks/snippet-read.ts b/packages/adapter-next/src/hooks/snippet-read.ts index 2f2b52ccdd..552be5725b 100644 --- a/packages/adapter-next/src/hooks/snippet-read.ts +++ b/packages/adapter-next/src/hooks/snippet-read.ts @@ -28,7 +28,7 @@ export const snippetRead: SnippetReadHook = async ( data, { helpers }, ) => { - const { fieldPath } = data; + const { fieldPath, itemName } = data; const label = "React"; @@ -88,8 +88,8 @@ export const snippetRead: SnippetReadHook = async ( const code = await format( stripIndent` <> - {${dotPath(fieldPath)}.map((item) => { - // Render the item + {${dotPath(fieldPath)}.map((${itemName}) => { + // Render the ${itemName} })} `, diff --git a/packages/adapter-next/test/plugin-snippet-read.test.ts b/packages/adapter-next/test/plugin-snippet-read.test.ts index 53a1d8d1aa..9519af1448 100644 --- a/packages/adapter-next/test/plugin-snippet-read.test.ts +++ b/packages/adapter-next/test/plugin-snippet-read.test.ts @@ -1,5 +1,6 @@ import { test, expect } from "vitest"; import { createMockFactory } from "@prismicio/mock"; +import { GroupFieldType } from "@prismicio/types-internal/lib/customtypes"; import { Snippet } from "@slicemachine/plugin-kit"; import prettier from "prettier"; @@ -36,6 +37,8 @@ const model = mock.model.customType({ }, }); +const itemName = "item"; + const testSnippet = ( fieldName: keyof typeof model.json.Main, expected: string | Snippet[], @@ -46,6 +49,10 @@ const testSnippet = ( } = await ctx.pluginRunner.callHook("snippet:read", { fieldPath: [model.id, "data", fieldName], model: model.json.Main[fieldName], + itemName: + model.json.Main[fieldName].type === GroupFieldType + ? itemName + : undefined, }); if (Array.isArray(expected)) { @@ -101,8 +108,8 @@ testSnippet( testSnippet( "group", - `<>{${model.id}.data.group.map((item) => { -// Render the item + `<>{${model.id}.data.group.map((${itemName}) => { +// Render the ${itemName} })}`, ); diff --git a/packages/adapter-nuxt/package.json b/packages/adapter-nuxt/package.json index 42f064afe4..5cbf55fafa 100644 --- a/packages/adapter-nuxt/package.json +++ b/packages/adapter-nuxt/package.json @@ -60,7 +60,7 @@ }, "dependencies": { "@prismicio/simulator": "^0.1.4", - "@prismicio/types-internal": "^2.4.1", + "@prismicio/types-internal": "^2.5.0", "@slicemachine/plugin-kit": "workspace:*", "common-tags": "^1.8.2", "fp-ts": "^2.13.1", @@ -86,7 +86,7 @@ "nuxt": "3.3.3", "prettier": "3.0.3", "prettier-plugin-jsdoc": "1.1.1", - "prismic-ts-codegen": "^0.1.20", + "prismic-ts-codegen": "^0.1.21", "size-limit": "8.2.4", "ts-morph": "17.0.1", "typescript": "4.9.5", diff --git a/packages/adapter-nuxt/src/hooks/snippet-read.ts b/packages/adapter-nuxt/src/hooks/snippet-read.ts index 10c112f604..1ad7ef3554 100644 --- a/packages/adapter-nuxt/src/hooks/snippet-read.ts +++ b/packages/adapter-nuxt/src/hooks/snippet-read.ts @@ -27,7 +27,7 @@ export const snippetRead: SnippetReadHook = async ( data, { helpers }, ) => { - const { fieldPath } = data; + const { fieldPath, itemName } = data; const label = "Vue"; @@ -102,8 +102,8 @@ export const snippetRead: SnippetReadHook = async ( language: "vue", code: await format( stripIndent` -