From 6141a7778fb43e913756bd79f62d3604d509aa7f Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Tue, 30 Jan 2024 14:01:54 +0100 Subject: [PATCH] chore(common): restructure starters and update root readme --- README.md | 7 +- .../server/utils/getAppSession.ts | 88 ------------- .../nuxt-base}/.env.example | 0 .../nuxt-base}/.eslintrc.cjs | 0 .../nuxt-base}/.gitignore | 0 .../nuxt-base}/.npmrc | 0 .../nuxt-base}/README.md | 9 +- .../nuxt-base}/app.config.ts | 0 .../nuxt-base}/index.d.ts | 0 .../nuxt-base}/nuxt.config.ts | 0 .../nuxt-base}/package.json | 0 .../nuxt-base}/pages/index.vue | 0 .../nuxt-base}/pnpm-lock.yaml | 0 .../server/api/connect/[...slugs].ts | 0 .../server/middleware/01.handle-401.global.ts | 0 .../server/middleware/02.auth.global.ts | 0 .../nuxt-base}/server/tsconfig.json | 0 .../nuxt-base}/server/utils/auth.ts | 0 .../nuxt-base}/server/utils/env.ts | 0 .../nuxt-base/server/utils/getAppSession.ts | 121 ++++++++++++++++++ .../nuxt-base}/tsconfig.json | 0 .../nuxt-starter}/.env.example | 0 .../nuxt-starter}/.gitignore | 0 .../nuxt-starter}/.npmrc | 0 .../nuxt-starter}/README.md | 10 +- .../nuxt-starter}/assets/css/base.css | 0 .../nuxt-starter}/components/Header.vue | 0 .../nuxt-starter}/docs/install-link.png | Bin .../nuxt-starter}/docs/new-extensions.png | Bin .../nuxt-starter}/docs/oauth.png | Bin .../nuxt-starter}/docs/open-extension.png | Bin .../docs/storyblok-extensions.png | Bin .../nuxt-starter}/docs/urls-for-oauth.png | Bin .../nuxt-starter}/nuxt.config.ts | 7 +- .../nuxt-starter}/package.json | 0 .../nuxt-starter}/pages/index.vue | 0 .../nuxt-starter}/pnpm-lock.yaml | 0 .../nuxt-starter}/public/favicon.ico | Bin .../nuxt-starter}/server/api/stories.ts | 0 .../nuxt-starter}/server/tsconfig.json | 0 .../nuxt-starter}/tailwind.config.js | 0 .../nuxt-starter}/tsconfig.json | 0 .../nuxt-starter}/types/story.ts | 0 .../story-starter}/.env.example | 0 space-plugins/story-starter/.gitignore | 6 + .../story-starter}/.npmrc | 0 .../story-starter}/README.md | 6 + .../story-starter}/docs/deploy-subdir.png | Bin .../story-starter}/package.json | 3 +- .../story-starter}/pnpm-lock.yaml | 98 ++++---------- .../story-starter/pnpm-workspace.yaml | 2 + .../starters/nuxt/.eslintrc.cjs | 0 .../story-starter}/starters/nuxt/.gitignore | 0 .../story-starter}/starters/nuxt/README.md | 0 .../starters/nuxt/assets/css/main.css | 0 .../nuxt/components/BreadcrumbItem.vue | 0 .../starters/nuxt/components/Breadcrumbs.vue | 0 .../starters/nuxt/components/Header.vue | 0 .../starters/nuxt/components/Loader.vue | 0 .../starters/nuxt/components/Pagination.vue | 0 .../starters/nuxt/components/SearchBar.vue | 0 .../nuxt/components/StoryActionBar.vue | 0 .../starters/nuxt/components/StoryList.vue | 0 .../nuxt/components/StoryListHeader.vue | 0 .../nuxt/components/StoryListItem.vue | 0 .../starters/nuxt/composables/useConfig.ts | 0 .../starters/nuxt/composables/useLoader.ts | 0 .../starters/nuxt/composables/useStories.ts | 0 .../story-starter}/starters/nuxt/index.d.ts | 0 .../starters/nuxt/nuxt.config.ts | 8 +- .../story-starter}/starters/nuxt/package.json | 3 +- .../starters/nuxt/pages/index.vue | 0 .../starters/nuxt/pnpm-lock.yaml | 0 .../starters/nuxt/public/favicon.ico | Bin .../starters/nuxt/server/api/stories.ts | 0 .../starters/nuxt/server/tsconfig.json | 0 .../starters/nuxt/server/utils/parse.ts | 0 .../starters/nuxt/shared/auth.ts | 0 .../starters/nuxt/shared/defineStoryConfig.ts | 0 .../starters/nuxt/stories.config.ts | 0 .../starters/nuxt/tailwind.config.js | 0 .../starters/nuxt/tsconfig.json | 0 .../starters/nuxt/types/config.ts | 0 .../starters/nuxt/types/story.ts | 0 story-starter/.gitignore | 2 - story-starter/packages/common/package.json | 13 -- story-starter/packages/common/src/hello.vue | 3 - story-starter/packages/common/src/index.ts | 2 - story-starter/packages/common/tsconfig.json | 13 -- story-starter/pnpm-workspace.yaml | 4 - .../nextjs-starter}/.env.local.example | 0 .../nextjs-starter}/.gitignore | 0 .../.yarn/releases/yarn-3.6.3.cjs | 0 .../nextjs-starter}/.yarnrc.yml | 0 .../nextjs-starter}/README.md | 0 .../nextjs-starter}/next.config.js | 0 .../nextjs-starter}/package.json | 0 .../nextjs-starter}/pnpm-lock.yaml | 0 .../nextjs-starter}/public/tools.svg | 0 .../nextjs-starter}/src/auth.ts | 0 .../nextjs-starter}/src/hooks/getContext.ts | 0 .../nextjs-starter}/src/hooks/index.ts | 0 .../nextjs-starter}/src/hooks/shared.ts | 0 .../src/hooks/useAutoHeight.ts | 0 .../nextjs-starter}/src/pages/401.tsx | 0 .../nextjs-starter}/src/pages/_app.tsx | 0 .../nextjs-starter}/src/pages/_document.tsx | 0 .../src/pages/api/connect/[...slugs].ts | 0 .../nextjs-starter}/src/pages/index.tsx | 0 .../nextjs-starter}/src/styles/globals.css | 0 .../nextjs-starter}/src/utils/index.ts | 0 .../nextjs-starter}/src/utils/isAdmin.ts | 0 .../nextjs-starter}/tsconfig.json | 0 .../nextjs-starter}/yarn.lock | 0 114 files changed, 191 insertions(+), 214 deletions(-) delete mode 100644 space-plugin-nuxt-base/server/utils/getAppSession.ts rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/.env.example (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/.eslintrc.cjs (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/.gitignore (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/.npmrc (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/README.md (76%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/app.config.ts (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/index.d.ts (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/nuxt.config.ts (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/package.json (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/pages/index.vue (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/pnpm-lock.yaml (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/server/api/connect/[...slugs].ts (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/server/middleware/01.handle-401.global.ts (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/server/middleware/02.auth.global.ts (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/server/tsconfig.json (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/server/utils/auth.ts (100%) rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/server/utils/env.ts (100%) create mode 100644 space-plugins/nuxt-base/server/utils/getAppSession.ts rename {space-plugin-nuxt-base => space-plugins/nuxt-base}/tsconfig.json (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/.env.example (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/.gitignore (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/.npmrc (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/README.md (85%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/assets/css/base.css (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/components/Header.vue (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/docs/install-link.png (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/docs/new-extensions.png (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/docs/oauth.png (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/docs/open-extension.png (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/docs/storyblok-extensions.png (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/docs/urls-for-oauth.png (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/nuxt.config.ts (72%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/package.json (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/pages/index.vue (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/pnpm-lock.yaml (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/public/favicon.ico (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/server/api/stories.ts (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/server/tsconfig.json (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/tailwind.config.js (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/tsconfig.json (100%) rename {space-plugin-nuxt-starter => space-plugins/nuxt-starter}/types/story.ts (100%) rename {story-starter/starters/nuxt => space-plugins/story-starter}/.env.example (100%) create mode 100644 space-plugins/story-starter/.gitignore rename {story-starter => space-plugins/story-starter}/.npmrc (100%) rename {story-starter => space-plugins/story-starter}/README.md (74%) rename {space-plugin-nuxt-starter => space-plugins/story-starter}/docs/deploy-subdir.png (100%) rename {story-starter => space-plugins/story-starter}/package.json (86%) rename {story-starter => space-plugins/story-starter}/pnpm-lock.yaml (99%) create mode 100644 space-plugins/story-starter/pnpm-workspace.yaml rename {story-starter => space-plugins/story-starter}/starters/nuxt/.eslintrc.cjs (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/.gitignore (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/README.md (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/assets/css/main.css (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/BreadcrumbItem.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/Breadcrumbs.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/Header.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/Loader.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/Pagination.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/SearchBar.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/StoryActionBar.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/StoryList.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/StoryListHeader.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/components/StoryListItem.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/composables/useConfig.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/composables/useLoader.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/composables/useStories.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/index.d.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/nuxt.config.ts (63%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/package.json (94%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/pages/index.vue (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/pnpm-lock.yaml (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/public/favicon.ico (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/server/api/stories.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/server/tsconfig.json (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/server/utils/parse.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/shared/auth.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/shared/defineStoryConfig.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/stories.config.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/tailwind.config.js (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/tsconfig.json (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/types/config.ts (100%) rename {story-starter => space-plugins/story-starter}/starters/nuxt/types/story.ts (100%) delete mode 100644 story-starter/.gitignore delete mode 100644 story-starter/packages/common/package.json delete mode 100644 story-starter/packages/common/src/hello.vue delete mode 100644 story-starter/packages/common/src/index.ts delete mode 100644 story-starter/packages/common/tsconfig.json delete mode 100644 story-starter/pnpm-workspace.yaml rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/.env.local.example (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/.gitignore (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/.yarn/releases/yarn-3.6.3.cjs (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/.yarnrc.yml (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/README.md (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/next.config.js (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/package.json (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/pnpm-lock.yaml (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/public/tools.svg (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/auth.ts (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/hooks/getContext.ts (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/hooks/index.ts (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/hooks/shared.ts (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/hooks/useAutoHeight.ts (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/pages/401.tsx (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/pages/_app.tsx (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/pages/_document.tsx (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/pages/api/connect/[...slugs].ts (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/pages/index.tsx (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/styles/globals.css (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/utils/index.ts (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/src/utils/isAdmin.ts (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/tsconfig.json (100%) rename {tool-nextjs-starter => tool-plugins/nextjs-starter}/yarn.lock (100%) diff --git a/README.md b/README.md index e14d095..60f5cb4 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,11 @@ This repository is a collection of starters to help developers quickly start bui ## Introduction Inside each project you will find a detailed README.md file that will provide instructions on how to clone and run the code. Here is a short list of all projects inside of this repository: -- [Story starter](story-starter/README.md) -- [Tool Next.js Starter](tool-nextjs-starter/README.md) +- Space Plugins + - [Nuxt Starter](space-plugins/nuxt-starter/README.md) + - [Story Starter](space-plugins/story-starter/README.md) +- Tool Plugins + - [Next.js Starter](tool-plugins/nextjs-starter/README.md) ## Glossary diff --git a/space-plugin-nuxt-base/server/utils/getAppSession.ts b/space-plugin-nuxt-base/server/utils/getAppSession.ts deleted file mode 100644 index 5fd02a3..0000000 --- a/space-plugin-nuxt-base/server/utils/getAppSession.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { - isAppSessionQuery, - sessionCookieStore, -} from '@storyblok/app-extension-auth'; - -import type { H3Event } from 'h3'; - -type AppSessionQuery = { - spaceId: number; - userId: number; -}; - -export const getAppSession = async (event: H3Event) => { - const appSessionQuery = extractAppSessionQuery(event); - if (!isAppSessionQuery(appSessionQuery)) { - return; - } - - const appConfig = useAppConfig(); - const sessionStore = sessionCookieStore(getAuthHandlerParams(appConfig.auth))( - { - req: event.node.req, - res: event.node.res, - } - ); - - return await sessionStore.get(appSessionQuery); -}; - -function extractAppSessionQuery(event: H3Event): AppSessionQuery | undefined { - const appSession = event.context.appSession; - const query = getQuery(event); - - // When a page is already authenticated on the server side, - // and it's rendering a page that includes `useFetch()`, - // Nuxt directly runs the serverless function on the server side - // (without an actual HTTP request). - // - // In that case `event.context.appSession` exists. - if (appSession?.spaceId && appSession?.userId) { - return convertToAppSessionQuery(appSession?.spaceId, appSession?.userId); - } - - // if this is a page request (/?spaceId=xxx&userId=yyy) - if (query.spaceId && query.userId) { - return convertToAppSessionQuery(query.spaceId, query.userId); - } - if (query.space_id && query.user_id) { - return convertToAppSessionQuery(query.space_id, query.user_id); - } - - const referer = getHeader(event, 'referer'); - if (referer) { - const refererParams = new URL(referer).searchParams; - if (refererParams.get('spaceId') && refererParams.get('userId')) { - return convertToAppSessionQuery( - refererParams.get('spaceId'), - refererParams.get('userId') - ); - } - - if (refererParams.get('space_id') && refererParams.get('user_id')) { - return convertToAppSessionQuery( - refererParams.get('space_id'), - refererParams.get('user_id') - ); - } - } -} - -function convertToAppSessionQuery(spaceId: any, userId: any): AppSessionQuery { - return { - spaceId: toNumber(spaceId), - userId: toNumber(userId), - }; -} - -const toNumber = (value: any) => { - if (typeof value === 'string') { - return parseInt(value, 10); - } - if (typeof value === 'number') { - return value; - } - throw new Error( - `Expected to be string or number. Actual value: ${JSON.stringify(value)}` - ); -}; diff --git a/space-plugin-nuxt-base/.env.example b/space-plugins/nuxt-base/.env.example similarity index 100% rename from space-plugin-nuxt-base/.env.example rename to space-plugins/nuxt-base/.env.example diff --git a/space-plugin-nuxt-base/.eslintrc.cjs b/space-plugins/nuxt-base/.eslintrc.cjs similarity index 100% rename from space-plugin-nuxt-base/.eslintrc.cjs rename to space-plugins/nuxt-base/.eslintrc.cjs diff --git a/space-plugin-nuxt-base/.gitignore b/space-plugins/nuxt-base/.gitignore similarity index 100% rename from space-plugin-nuxt-base/.gitignore rename to space-plugins/nuxt-base/.gitignore diff --git a/space-plugin-nuxt-base/.npmrc b/space-plugins/nuxt-base/.npmrc similarity index 100% rename from space-plugin-nuxt-base/.npmrc rename to space-plugins/nuxt-base/.npmrc diff --git a/space-plugin-nuxt-base/README.md b/space-plugins/nuxt-base/README.md similarity index 76% rename from space-plugin-nuxt-base/README.md rename to space-plugins/nuxt-base/README.md index da3fb8c..12a8d5a 100644 --- a/space-plugin-nuxt-base/README.md +++ b/space-plugins/nuxt-base/README.md @@ -1,4 +1,4 @@ -# `space-plugin-nuxt-base` layer +# Space Plugin `nuxt-base` layer This Nuxt layer adds basic authentication flow to your existing Storyblok's Space Plugin app. @@ -8,7 +8,12 @@ In your `nuxt.config.ts`, ```js export default defineNuxtConfig({ - extends: ['github:storyblok/space-tool-plugins/space-plugin-nuxt-base'], + extends: [ + [ + 'github:storyblok/space-tool-plugins/space-plugins/nuxt-base', + { install: true }, + ], + ], }); ``` diff --git a/space-plugin-nuxt-base/app.config.ts b/space-plugins/nuxt-base/app.config.ts similarity index 100% rename from space-plugin-nuxt-base/app.config.ts rename to space-plugins/nuxt-base/app.config.ts diff --git a/space-plugin-nuxt-base/index.d.ts b/space-plugins/nuxt-base/index.d.ts similarity index 100% rename from space-plugin-nuxt-base/index.d.ts rename to space-plugins/nuxt-base/index.d.ts diff --git a/space-plugin-nuxt-base/nuxt.config.ts b/space-plugins/nuxt-base/nuxt.config.ts similarity index 100% rename from space-plugin-nuxt-base/nuxt.config.ts rename to space-plugins/nuxt-base/nuxt.config.ts diff --git a/space-plugin-nuxt-base/package.json b/space-plugins/nuxt-base/package.json similarity index 100% rename from space-plugin-nuxt-base/package.json rename to space-plugins/nuxt-base/package.json diff --git a/space-plugin-nuxt-base/pages/index.vue b/space-plugins/nuxt-base/pages/index.vue similarity index 100% rename from space-plugin-nuxt-base/pages/index.vue rename to space-plugins/nuxt-base/pages/index.vue diff --git a/space-plugin-nuxt-base/pnpm-lock.yaml b/space-plugins/nuxt-base/pnpm-lock.yaml similarity index 100% rename from space-plugin-nuxt-base/pnpm-lock.yaml rename to space-plugins/nuxt-base/pnpm-lock.yaml diff --git a/space-plugin-nuxt-base/server/api/connect/[...slugs].ts b/space-plugins/nuxt-base/server/api/connect/[...slugs].ts similarity index 100% rename from space-plugin-nuxt-base/server/api/connect/[...slugs].ts rename to space-plugins/nuxt-base/server/api/connect/[...slugs].ts diff --git a/space-plugin-nuxt-base/server/middleware/01.handle-401.global.ts b/space-plugins/nuxt-base/server/middleware/01.handle-401.global.ts similarity index 100% rename from space-plugin-nuxt-base/server/middleware/01.handle-401.global.ts rename to space-plugins/nuxt-base/server/middleware/01.handle-401.global.ts diff --git a/space-plugin-nuxt-base/server/middleware/02.auth.global.ts b/space-plugins/nuxt-base/server/middleware/02.auth.global.ts similarity index 100% rename from space-plugin-nuxt-base/server/middleware/02.auth.global.ts rename to space-plugins/nuxt-base/server/middleware/02.auth.global.ts diff --git a/space-plugin-nuxt-base/server/tsconfig.json b/space-plugins/nuxt-base/server/tsconfig.json similarity index 100% rename from space-plugin-nuxt-base/server/tsconfig.json rename to space-plugins/nuxt-base/server/tsconfig.json diff --git a/space-plugin-nuxt-base/server/utils/auth.ts b/space-plugins/nuxt-base/server/utils/auth.ts similarity index 100% rename from space-plugin-nuxt-base/server/utils/auth.ts rename to space-plugins/nuxt-base/server/utils/auth.ts diff --git a/space-plugin-nuxt-base/server/utils/env.ts b/space-plugins/nuxt-base/server/utils/env.ts similarity index 100% rename from space-plugin-nuxt-base/server/utils/env.ts rename to space-plugins/nuxt-base/server/utils/env.ts diff --git a/space-plugins/nuxt-base/server/utils/getAppSession.ts b/space-plugins/nuxt-base/server/utils/getAppSession.ts new file mode 100644 index 0000000..6f6b44b --- /dev/null +++ b/space-plugins/nuxt-base/server/utils/getAppSession.ts @@ -0,0 +1,121 @@ +import { + isAppSessionQuery, + sessionCookieStore, +} from '@storyblok/app-extension-auth'; + +import type { H3Event } from 'h3'; + +type AppSessionQuery = { + spaceId: number; + userId: number; +}; + +// Overall auth flow +// (1) https://app.storyblok.com/v1/spaces/xxxx/app_provisions/xxxx +// (2) https:///?space_id=xxxx&space_is_trial=false&space_name=xxxx&user_id=xxxx&user_name=null&user_lang=en&user_is_admin=true +// (3) https:///api/connect/storyblok +// OAuth Consent Page ↓ +// (4) https://app.storyblok.com/oauth/authorize?client_id=xxxx&scope=read_content%20write_content&response_type=code&redirect_uri=https%3A%2F%2F%2Fapi%2Fconnect%2Fcallback&code_challenge=xxxx&state=xxxx&code_challenge_method=S256 +// (5) https:///api/connect/callback?code=xxxx&space_id=183395 +// The cookie `sb.auth` is not set at this time, so it redirects to ↓ +// (6) https:///401 +// The middleware catches /401 and redirects to ↓ +// (7) https://app.storyblok.com/oauth/app_redirect + +// Now (2) ~ (5) repeats +// (8) https:///?space_id=xxxx&space_is_trial=false&space_name=xxxx&user_id=xxxx&user_name=null&user_lang=en&user_is_admin=true +// (9) https:///api/connect/storyblok +// (10) https:///oauth/authorize?client_id=xxxx&scope=read_content%20write_content&response_type=code&redirect_uri=https%3A%2F%2F%2Fapi%2Fconnect%2Fcallback&code_challenge=xxxx&state=xxxx&code_challenge_method=S256 +// (11) https:///api/connect/callback?code=xxxx&state=xxxx&space_id=xxxx + +// Finished. Authenticated successfully. +// (12) https:///?spaceId=xxxx&userId=xxxx + +// If a user visits this plugin with the `sb.auth` token already set, they will be redirected to ↓ +// (13) https:///?space_id=xxxx&user_id=xxxx +// instead of spaceId and userId. +// It should be more consistent, but at least the `nuxt-base` layer takes care of it now. + +export const getAppSession = async (event: H3Event) => { + const appSessionQuery = extractAppSessionQuery(event); + if (!isAppSessionQuery(appSessionQuery)) { + return; + } + + const appConfig = useAppConfig(); + const sessionStore = sessionCookieStore(getAuthHandlerParams(appConfig.auth))( + { + req: event.node.req, + res: event.node.res, + } + ); + + return await sessionStore.get(appSessionQuery); +}; + +function extractAppSessionQuery(event: H3Event): AppSessionQuery | undefined { + const appSession = event.context.appSession; + const query = getQuery(event); + + if (appSession?.spaceId && appSession?.userId) { + // When a page is already authenticated on the server side, + // and it's rendering a page that includes `useFetch('...', { server: true })`, + // Nuxt directly runs the serverless function on the server side + // (without an actual HTTP request). + // + // In that case `event.context.appSession` exists. + return convertToAppSessionQuery(appSession?.spaceId, appSession?.userId); + } + + // (12) if this is a page request (/?spaceId=xxx&userId=yyy) + if (query.spaceId && query.userId) { + return convertToAppSessionQuery(query.spaceId, query.userId); + } + + // (13) if this is a page request (/?space_id=xxx&user_id=yyy) + if (query.space_id && query.user_id) { + return convertToAppSessionQuery(query.space_id, query.user_id); + } + + const referer = getHeader(event, 'referer'); + // if this is an API request (/api/xxx), the `referer` header exists. + if (referer) { + // `referer` can be one of the following: + // https:///?spaceId=xxxx&userId=xxxx + // or + // https:///?space_id=xxxx&user_id=xxxx + const refererParams = new URL(referer).searchParams; + if (refererParams.get('spaceId') && refererParams.get('userId')) { + return convertToAppSessionQuery( + refererParams.get('spaceId'), + refererParams.get('userId') + ); + } + + if (refererParams.get('space_id') && refererParams.get('user_id')) { + return convertToAppSessionQuery( + refererParams.get('space_id'), + refererParams.get('user_id') + ); + } + } +} + +function convertToAppSessionQuery(spaceId: any, userId: any): AppSessionQuery { + return { + spaceId: toNumber(spaceId), + userId: toNumber(userId), + }; +} + +const toNumber = (value: any) => { + if (typeof value === 'string') { + return parseInt(value, 10); + } + if (typeof value === 'number') { + return value; + } + throw new Error( + `Expected to be string or number. Actual value: ${JSON.stringify(value)}` + ); +}; diff --git a/space-plugin-nuxt-base/tsconfig.json b/space-plugins/nuxt-base/tsconfig.json similarity index 100% rename from space-plugin-nuxt-base/tsconfig.json rename to space-plugins/nuxt-base/tsconfig.json diff --git a/space-plugin-nuxt-starter/.env.example b/space-plugins/nuxt-starter/.env.example similarity index 100% rename from space-plugin-nuxt-starter/.env.example rename to space-plugins/nuxt-starter/.env.example diff --git a/space-plugin-nuxt-starter/.gitignore b/space-plugins/nuxt-starter/.gitignore similarity index 100% rename from space-plugin-nuxt-starter/.gitignore rename to space-plugins/nuxt-starter/.gitignore diff --git a/space-plugin-nuxt-starter/.npmrc b/space-plugins/nuxt-starter/.npmrc similarity index 100% rename from space-plugin-nuxt-starter/.npmrc rename to space-plugins/nuxt-starter/.npmrc diff --git a/space-plugin-nuxt-starter/README.md b/space-plugins/nuxt-starter/README.md similarity index 85% rename from space-plugin-nuxt-starter/README.md rename to space-plugins/nuxt-starter/README.md index 7648249..35b66e5 100644 --- a/space-plugin-nuxt-starter/README.md +++ b/space-plugins/nuxt-starter/README.md @@ -5,7 +5,7 @@ This Nuxt starter is a Storyblok Space Plugin app that includes the basic authen ## Getting Started ```sh -npx giget@latest gh:storyblok/space-tool-plugins/space-plugin-nuxt-starter YOUR-PROJECT-NAME +npx giget@latest gh:storyblok/space-tool-plugins/space-plugins/nuxt-starter YOUR-PROJECT-NAME ``` This repository is developed using [pnpm](https://pnpm.io/). However, you can also use Yarn or NPM. @@ -36,7 +36,7 @@ And then you can find the information. OAuth information -3. Configure the following environment variables in `/starters/nuxt/.env`. +3. Configure the following environment variables in `/.env`. - `CLIENT_ID=`: Client Identifer - `CLIENT_SECRET=`: Client Secret @@ -58,10 +58,6 @@ Ensure that "Production" is the section that contains information about the prod 7. Open the `starters/nuxt/stories.config.ts` file and implement your own actions. You can refer to the existing sample implementation for guidance. -8. Deploying - -The starter is set up as a monorepo, and most hosting platforms support it seamlessly. For instance, Vercel recognizes it as a Nuxt project and automatically configures the root directory for you. - -Vercel Deployment +8. Deployment You should configure the same environment variables on the hosting platform as well. diff --git a/space-plugin-nuxt-starter/assets/css/base.css b/space-plugins/nuxt-starter/assets/css/base.css similarity index 100% rename from space-plugin-nuxt-starter/assets/css/base.css rename to space-plugins/nuxt-starter/assets/css/base.css diff --git a/space-plugin-nuxt-starter/components/Header.vue b/space-plugins/nuxt-starter/components/Header.vue similarity index 100% rename from space-plugin-nuxt-starter/components/Header.vue rename to space-plugins/nuxt-starter/components/Header.vue diff --git a/space-plugin-nuxt-starter/docs/install-link.png b/space-plugins/nuxt-starter/docs/install-link.png similarity index 100% rename from space-plugin-nuxt-starter/docs/install-link.png rename to space-plugins/nuxt-starter/docs/install-link.png diff --git a/space-plugin-nuxt-starter/docs/new-extensions.png b/space-plugins/nuxt-starter/docs/new-extensions.png similarity index 100% rename from space-plugin-nuxt-starter/docs/new-extensions.png rename to space-plugins/nuxt-starter/docs/new-extensions.png diff --git a/space-plugin-nuxt-starter/docs/oauth.png b/space-plugins/nuxt-starter/docs/oauth.png similarity index 100% rename from space-plugin-nuxt-starter/docs/oauth.png rename to space-plugins/nuxt-starter/docs/oauth.png diff --git a/space-plugin-nuxt-starter/docs/open-extension.png b/space-plugins/nuxt-starter/docs/open-extension.png similarity index 100% rename from space-plugin-nuxt-starter/docs/open-extension.png rename to space-plugins/nuxt-starter/docs/open-extension.png diff --git a/space-plugin-nuxt-starter/docs/storyblok-extensions.png b/space-plugins/nuxt-starter/docs/storyblok-extensions.png similarity index 100% rename from space-plugin-nuxt-starter/docs/storyblok-extensions.png rename to space-plugins/nuxt-starter/docs/storyblok-extensions.png diff --git a/space-plugin-nuxt-starter/docs/urls-for-oauth.png b/space-plugins/nuxt-starter/docs/urls-for-oauth.png similarity index 100% rename from space-plugin-nuxt-starter/docs/urls-for-oauth.png rename to space-plugins/nuxt-starter/docs/urls-for-oauth.png diff --git a/space-plugin-nuxt-starter/nuxt.config.ts b/space-plugins/nuxt-starter/nuxt.config.ts similarity index 72% rename from space-plugin-nuxt-starter/nuxt.config.ts rename to space-plugins/nuxt-starter/nuxt.config.ts index 3926fd4..1a30953 100644 --- a/space-plugin-nuxt-starter/nuxt.config.ts +++ b/space-plugins/nuxt-starter/nuxt.config.ts @@ -1,7 +1,12 @@ // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ devtools: { enabled: true }, - extends: ['github:storyblok/space-tool-plugins/space-plugin-nuxt-base'], + extends: [ + [ + 'github:storyblok/space-tool-plugins/space-plugins/nuxt-base', + { install: true }, + ], + ], css: ['~/assets/css/base.css'], modules: ['nuxt-lucide-icons', '@nuxtjs/google-fonts', '@nuxtjs/tailwindcss'], googleFonts: { diff --git a/space-plugin-nuxt-starter/package.json b/space-plugins/nuxt-starter/package.json similarity index 100% rename from space-plugin-nuxt-starter/package.json rename to space-plugins/nuxt-starter/package.json diff --git a/space-plugin-nuxt-starter/pages/index.vue b/space-plugins/nuxt-starter/pages/index.vue similarity index 100% rename from space-plugin-nuxt-starter/pages/index.vue rename to space-plugins/nuxt-starter/pages/index.vue diff --git a/space-plugin-nuxt-starter/pnpm-lock.yaml b/space-plugins/nuxt-starter/pnpm-lock.yaml similarity index 100% rename from space-plugin-nuxt-starter/pnpm-lock.yaml rename to space-plugins/nuxt-starter/pnpm-lock.yaml diff --git a/space-plugin-nuxt-starter/public/favicon.ico b/space-plugins/nuxt-starter/public/favicon.ico similarity index 100% rename from space-plugin-nuxt-starter/public/favicon.ico rename to space-plugins/nuxt-starter/public/favicon.ico diff --git a/space-plugin-nuxt-starter/server/api/stories.ts b/space-plugins/nuxt-starter/server/api/stories.ts similarity index 100% rename from space-plugin-nuxt-starter/server/api/stories.ts rename to space-plugins/nuxt-starter/server/api/stories.ts diff --git a/space-plugin-nuxt-starter/server/tsconfig.json b/space-plugins/nuxt-starter/server/tsconfig.json similarity index 100% rename from space-plugin-nuxt-starter/server/tsconfig.json rename to space-plugins/nuxt-starter/server/tsconfig.json diff --git a/space-plugin-nuxt-starter/tailwind.config.js b/space-plugins/nuxt-starter/tailwind.config.js similarity index 100% rename from space-plugin-nuxt-starter/tailwind.config.js rename to space-plugins/nuxt-starter/tailwind.config.js diff --git a/space-plugin-nuxt-starter/tsconfig.json b/space-plugins/nuxt-starter/tsconfig.json similarity index 100% rename from space-plugin-nuxt-starter/tsconfig.json rename to space-plugins/nuxt-starter/tsconfig.json diff --git a/space-plugin-nuxt-starter/types/story.ts b/space-plugins/nuxt-starter/types/story.ts similarity index 100% rename from space-plugin-nuxt-starter/types/story.ts rename to space-plugins/nuxt-starter/types/story.ts diff --git a/story-starter/starters/nuxt/.env.example b/space-plugins/story-starter/.env.example similarity index 100% rename from story-starter/starters/nuxt/.env.example rename to space-plugins/story-starter/.env.example diff --git a/space-plugins/story-starter/.gitignore b/space-plugins/story-starter/.gitignore new file mode 100644 index 0000000..2055bd6 --- /dev/null +++ b/space-plugins/story-starter/.gitignore @@ -0,0 +1,6 @@ +.env +.env.* +!.env.example + +.idea +**/node_modules \ No newline at end of file diff --git a/story-starter/.npmrc b/space-plugins/story-starter/.npmrc similarity index 100% rename from story-starter/.npmrc rename to space-plugins/story-starter/.npmrc diff --git a/story-starter/README.md b/space-plugins/story-starter/README.md similarity index 74% rename from story-starter/README.md rename to space-plugins/story-starter/README.md index 88468de..ef912f8 100644 --- a/story-starter/README.md +++ b/space-plugins/story-starter/README.md @@ -12,3 +12,9 @@ npx giget@latest gh:storyblok/space-tool-plugins/story-starter YOUR-PROJECT-NAME ``` To learn more about the configuration, read the [space-plugin-nuxt-starter's README](https://github.com/storyblok/space-tool-plugins/blob/main/space-plugin-nuxt-starter/README.md#configuration). + +## Deployment + +The Story Starter is set up as a monorepo, and most hosting platforms support it seamlessly. For instance, Vercel recognizes it as a Nuxt project and automatically configures the root directory for you. + +Vercel Deployment diff --git a/space-plugin-nuxt-starter/docs/deploy-subdir.png b/space-plugins/story-starter/docs/deploy-subdir.png similarity index 100% rename from space-plugin-nuxt-starter/docs/deploy-subdir.png rename to space-plugins/story-starter/docs/deploy-subdir.png diff --git a/story-starter/package.json b/space-plugins/story-starter/package.json similarity index 86% rename from story-starter/package.json rename to space-plugins/story-starter/package.json index 1ab8898..8719c3c 100644 --- a/story-starter/package.json +++ b/space-plugins/story-starter/package.json @@ -4,8 +4,7 @@ "description": "", "private": true, "workspaces": [ - "starters/*", - "packages/*" + "starters/*" ], "scripts": { "dev:nuxt": "pnpm -F nuxt dev" diff --git a/story-starter/pnpm-lock.yaml b/space-plugins/story-starter/pnpm-lock.yaml similarity index 99% rename from story-starter/pnpm-lock.yaml rename to space-plugins/story-starter/pnpm-lock.yaml index 98c1a2d..7c5c6aa 100644 --- a/story-starter/pnpm-lock.yaml +++ b/space-plugins/story-starter/pnpm-lock.yaml @@ -8,8 +8,6 @@ importers: .: {} - packages/common: {} - starters/nuxt: dependencies: '@storyblok/app-extension-auth': @@ -18,9 +16,6 @@ importers: '@types/nprogress': specifier: ^0.2.3 version: 0.2.3 - common: - specifier: workspace:* - version: link:../../packages/common nprogress: specifier: ^0.2.0 version: 0.2.0 @@ -45,10 +40,10 @@ importers: version: 6.11.0 autoprefixer: specifier: 10.4.16 - version: 10.4.16(postcss@8.4.32) + version: 10.4.16(postcss@8.4.33) daisyui: specifier: ^4.4.19 - version: 4.4.19(postcss@8.4.32) + version: 4.4.19(postcss@8.4.33) eslint: specifier: ^8.56.0 version: 8.56.0 @@ -1171,8 +1166,8 @@ packages: nuxt: ^3.9.0 vite: '*' dependencies: - '@nuxt/kit': 3.9.2 - '@nuxt/schema': 3.9.2 + '@nuxt/kit': 3.9.3 + '@nuxt/schema': 3.9.3 execa: 7.2.0 nuxt: 3.8.0(eslint@8.56.0)(typescript@5.3.3)(vite@4.5.0) vite: 4.5.0 @@ -1207,7 +1202,7 @@ packages: '@antfu/utils': 0.7.7 '@nuxt/devtools-kit': 1.0.8(nuxt@3.8.0)(vite@4.5.0) '@nuxt/devtools-wizard': 1.0.8 - '@nuxt/kit': 3.9.2 + '@nuxt/kit': 3.9.3 birpc: 0.2.14 consola: 3.2.3 destr: 2.0.2 @@ -1236,7 +1231,7 @@ packages: sirv: 2.0.4 unimport: 3.7.1 vite: 4.5.0 - vite-plugin-inspect: 0.8.1(@nuxt/kit@3.9.2)(vite@4.5.0) + vite-plugin-inspect: 0.8.1(@nuxt/kit@3.9.3)(vite@4.5.0) vite-plugin-vue-inspector: 4.0.2(vite@4.5.0) which: 3.0.1 ws: 8.16.0 @@ -1317,33 +1312,6 @@ packages: - supports-color dev: true - /@nuxt/kit@3.9.2: - resolution: {integrity: sha512-SmWXnA7z9OJuPXYvrx/8QnnsahRJEfLVciUUxCaVEMOxdRZnr1lUmzoT4wFVcYMQnMJYz1Alo58x4vtty6P73w==} - engines: {node: ^14.18.0 || >=16.10.0} - dependencies: - '@nuxt/schema': 3.9.2 - c12: 1.6.1 - consola: 3.2.3 - defu: 6.1.4 - globby: 14.0.0 - hash-sum: 2.0.0 - ignore: 5.3.0 - jiti: 1.21.0 - knitwork: 1.0.0 - mlly: 1.5.0 - pathe: 1.1.2 - pkg-types: 1.0.3 - scule: 1.2.0 - semver: 7.5.4 - ufo: 1.3.2 - unctx: 2.3.1 - unimport: 3.7.1 - untyped: 1.4.0 - transitivePeerDependencies: - - rollup - - supports-color - dev: true - /@nuxt/kit@3.9.3: resolution: {integrity: sha512-bHGXpTB6E+YJCC1L9tTwrP7txgLZzyuFes/tgy1ZM4dlfrCsGqLK/K4mddROMdC3D81scnH84u7yQsN0JRgoTg==} engines: {node: ^14.18.0 || >=16.10.0} @@ -1411,26 +1379,6 @@ packages: - supports-color dev: true - /@nuxt/schema@3.9.2: - resolution: {integrity: sha512-jLShtgQPBMH2ccRTv/l4wAik1L6cW7Y5H7txHDZXKR4nHAbNuhCdVPCKs8NP/8g8rhBulbH+xy8Lar5ff8ahOQ==} - engines: {node: ^14.18.0 || >=16.10.0} - dependencies: - '@nuxt/ui-templates': 1.3.1 - consola: 3.2.3 - defu: 6.1.4 - hookable: 5.5.3 - pathe: 1.1.2 - pkg-types: 1.0.3 - scule: 1.2.0 - std-env: 3.7.0 - ufo: 1.3.2 - unimport: 3.7.1 - untyped: 1.4.0 - transitivePeerDependencies: - - rollup - - supports-color - dev: true - /@nuxt/schema@3.9.3: resolution: {integrity: sha512-pchkGBYdEJ9TAOoC5DKnLuAaFPjzgn2k0OUTr31QwbtHdTR3Q2Ua/oKsS1g9CPU7KRzSE5Vkf7ECE8zVydqF5A==} engines: {node: ^14.18.0 || >=16.10.0} @@ -2614,6 +2562,22 @@ packages: postcss-value-parser: 4.2.0 dev: true + /autoprefixer@10.4.16(postcss@8.4.33): + resolution: {integrity: sha512-7vd3UC6xKp0HLfua5IjZlcXvGAGy7cBAXTg2lyQ/8WpNhd6SiZ8Be+xm3FyBSYJx5GKcpRCzBh7RH4/0dnY+uQ==} + engines: {node: ^10 || ^12 || >=14} + hasBin: true + peerDependencies: + postcss: ^8.1.0 + dependencies: + browserslist: 4.22.1 + caniuse-lite: 1.0.30001547 + fraction.js: 4.3.7 + normalize-range: 0.1.2 + picocolors: 1.0.0 + postcss: 8.4.33 + postcss-value-parser: 4.2.0 + dev: true + /autoprefixer@10.4.17(postcss@8.4.33): resolution: {integrity: sha512-/cpVNRLSfhOtcGflT13P2794gVSgmPgTR+erw5ifnMLZb0UnSlkK4tquLmkd3BhA+nLo5tX8Cu0upUsGKvKbmg==} engines: {node: ^10 || ^12 || >=14} @@ -3235,14 +3199,14 @@ packages: engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dev: true - /daisyui@4.4.19(postcss@8.4.32): + /daisyui@4.4.19(postcss@8.4.33): resolution: {integrity: sha512-IjOLWwnndD4N7Ut5CDxbUsaVtbqXPeVHM92IcgxGFxpuOd3CCKW/PAXZH6JoBTHFRaN57vB9XqEhdWm5yC+bPA==} engines: {node: '>=16.9.0'} dependencies: css-selector-tokenizer: 0.8.0 culori: 3.3.0 picocolors: 1.0.0 - postcss-js: 4.0.1(postcss@8.4.32) + postcss-js: 4.0.1(postcss@8.4.33) transitivePeerDependencies: - postcss dev: true @@ -6243,16 +6207,6 @@ packages: resolve: 1.22.8 dev: true - /postcss-js@4.0.1(postcss@8.4.32): - resolution: {integrity: sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==} - engines: {node: ^12 || ^14 || >= 16} - peerDependencies: - postcss: ^8.4.21 - dependencies: - camelcase-css: 2.0.1 - postcss: 8.4.32 - dev: true - /postcss-js@4.0.1(postcss@8.4.33): resolution: {integrity: sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==} engines: {node: ^12 || ^14 || >= 16} @@ -7856,7 +7810,7 @@ packages: vscode-uri: 3.0.8 dev: true - /vite-plugin-inspect@0.8.1(@nuxt/kit@3.9.2)(vite@4.5.0): + /vite-plugin-inspect@0.8.1(@nuxt/kit@3.9.3)(vite@4.5.0): resolution: {integrity: sha512-oPBPVGp6tBd5KdY/qY6lrbLXqrbHRG0hZLvEaJfiZ/GQfDB+szRuLHblQh1oi1Hhh8GeLit/50l4xfs2SA+TCA==} engines: {node: '>=14'} peerDependencies: @@ -7867,7 +7821,7 @@ packages: optional: true dependencies: '@antfu/utils': 0.7.7 - '@nuxt/kit': 3.9.2 + '@nuxt/kit': 3.9.3 '@rollup/pluginutils': 5.1.0 debug: 4.3.4 error-stack-parser-es: 0.1.1 diff --git a/space-plugins/story-starter/pnpm-workspace.yaml b/space-plugins/story-starter/pnpm-workspace.yaml new file mode 100644 index 0000000..5f88330 --- /dev/null +++ b/space-plugins/story-starter/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - 'starters/*' diff --git a/story-starter/starters/nuxt/.eslintrc.cjs b/space-plugins/story-starter/starters/nuxt/.eslintrc.cjs similarity index 100% rename from story-starter/starters/nuxt/.eslintrc.cjs rename to space-plugins/story-starter/starters/nuxt/.eslintrc.cjs diff --git a/story-starter/starters/nuxt/.gitignore b/space-plugins/story-starter/starters/nuxt/.gitignore similarity index 100% rename from story-starter/starters/nuxt/.gitignore rename to space-plugins/story-starter/starters/nuxt/.gitignore diff --git a/story-starter/starters/nuxt/README.md b/space-plugins/story-starter/starters/nuxt/README.md similarity index 100% rename from story-starter/starters/nuxt/README.md rename to space-plugins/story-starter/starters/nuxt/README.md diff --git a/story-starter/starters/nuxt/assets/css/main.css b/space-plugins/story-starter/starters/nuxt/assets/css/main.css similarity index 100% rename from story-starter/starters/nuxt/assets/css/main.css rename to space-plugins/story-starter/starters/nuxt/assets/css/main.css diff --git a/story-starter/starters/nuxt/components/BreadcrumbItem.vue b/space-plugins/story-starter/starters/nuxt/components/BreadcrumbItem.vue similarity index 100% rename from story-starter/starters/nuxt/components/BreadcrumbItem.vue rename to space-plugins/story-starter/starters/nuxt/components/BreadcrumbItem.vue diff --git a/story-starter/starters/nuxt/components/Breadcrumbs.vue b/space-plugins/story-starter/starters/nuxt/components/Breadcrumbs.vue similarity index 100% rename from story-starter/starters/nuxt/components/Breadcrumbs.vue rename to space-plugins/story-starter/starters/nuxt/components/Breadcrumbs.vue diff --git a/story-starter/starters/nuxt/components/Header.vue b/space-plugins/story-starter/starters/nuxt/components/Header.vue similarity index 100% rename from story-starter/starters/nuxt/components/Header.vue rename to space-plugins/story-starter/starters/nuxt/components/Header.vue diff --git a/story-starter/starters/nuxt/components/Loader.vue b/space-plugins/story-starter/starters/nuxt/components/Loader.vue similarity index 100% rename from story-starter/starters/nuxt/components/Loader.vue rename to space-plugins/story-starter/starters/nuxt/components/Loader.vue diff --git a/story-starter/starters/nuxt/components/Pagination.vue b/space-plugins/story-starter/starters/nuxt/components/Pagination.vue similarity index 100% rename from story-starter/starters/nuxt/components/Pagination.vue rename to space-plugins/story-starter/starters/nuxt/components/Pagination.vue diff --git a/story-starter/starters/nuxt/components/SearchBar.vue b/space-plugins/story-starter/starters/nuxt/components/SearchBar.vue similarity index 100% rename from story-starter/starters/nuxt/components/SearchBar.vue rename to space-plugins/story-starter/starters/nuxt/components/SearchBar.vue diff --git a/story-starter/starters/nuxt/components/StoryActionBar.vue b/space-plugins/story-starter/starters/nuxt/components/StoryActionBar.vue similarity index 100% rename from story-starter/starters/nuxt/components/StoryActionBar.vue rename to space-plugins/story-starter/starters/nuxt/components/StoryActionBar.vue diff --git a/story-starter/starters/nuxt/components/StoryList.vue b/space-plugins/story-starter/starters/nuxt/components/StoryList.vue similarity index 100% rename from story-starter/starters/nuxt/components/StoryList.vue rename to space-plugins/story-starter/starters/nuxt/components/StoryList.vue diff --git a/story-starter/starters/nuxt/components/StoryListHeader.vue b/space-plugins/story-starter/starters/nuxt/components/StoryListHeader.vue similarity index 100% rename from story-starter/starters/nuxt/components/StoryListHeader.vue rename to space-plugins/story-starter/starters/nuxt/components/StoryListHeader.vue diff --git a/story-starter/starters/nuxt/components/StoryListItem.vue b/space-plugins/story-starter/starters/nuxt/components/StoryListItem.vue similarity index 100% rename from story-starter/starters/nuxt/components/StoryListItem.vue rename to space-plugins/story-starter/starters/nuxt/components/StoryListItem.vue diff --git a/story-starter/starters/nuxt/composables/useConfig.ts b/space-plugins/story-starter/starters/nuxt/composables/useConfig.ts similarity index 100% rename from story-starter/starters/nuxt/composables/useConfig.ts rename to space-plugins/story-starter/starters/nuxt/composables/useConfig.ts diff --git a/story-starter/starters/nuxt/composables/useLoader.ts b/space-plugins/story-starter/starters/nuxt/composables/useLoader.ts similarity index 100% rename from story-starter/starters/nuxt/composables/useLoader.ts rename to space-plugins/story-starter/starters/nuxt/composables/useLoader.ts diff --git a/story-starter/starters/nuxt/composables/useStories.ts b/space-plugins/story-starter/starters/nuxt/composables/useStories.ts similarity index 100% rename from story-starter/starters/nuxt/composables/useStories.ts rename to space-plugins/story-starter/starters/nuxt/composables/useStories.ts diff --git a/story-starter/starters/nuxt/index.d.ts b/space-plugins/story-starter/starters/nuxt/index.d.ts similarity index 100% rename from story-starter/starters/nuxt/index.d.ts rename to space-plugins/story-starter/starters/nuxt/index.d.ts diff --git a/story-starter/starters/nuxt/nuxt.config.ts b/space-plugins/story-starter/starters/nuxt/nuxt.config.ts similarity index 63% rename from story-starter/starters/nuxt/nuxt.config.ts rename to space-plugins/story-starter/starters/nuxt/nuxt.config.ts index c5929e8..7e828d9 100644 --- a/story-starter/starters/nuxt/nuxt.config.ts +++ b/space-plugins/story-starter/starters/nuxt/nuxt.config.ts @@ -1,7 +1,13 @@ // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ devtools: { enabled: true }, - extends: ['github:storyblok/space-tool-plugins/space-plugin-nuxt-base'], + extends: [ + [ + 'github:storyblok/space-tool-plugins/space-plugins/nuxt-base', + { install: true }, + ], + ], + // extends: [['../../../nuxt-base', { install: true }]], css: ['~/assets/css/main.css'], modules: ['nuxt-lucide-icons', '@nuxtjs/google-fonts', '@nuxtjs/tailwindcss'], googleFonts: { diff --git a/story-starter/starters/nuxt/package.json b/space-plugins/story-starter/starters/nuxt/package.json similarity index 94% rename from story-starter/starters/nuxt/package.json rename to space-plugins/story-starter/starters/nuxt/package.json index 91300b8..78dd8fe 100644 --- a/story-starter/starters/nuxt/package.json +++ b/space-plugins/story-starter/starters/nuxt/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "build": "nuxt build", - "dev": "nuxt dev", + "dev": "nuxt dev --dotenv ../../.env", "lint": "eslint .", "lint:fix": "eslint . --fix", "generate": "nuxt generate", @@ -15,7 +15,6 @@ "dependencies": { "@storyblok/app-extension-auth": "1.0.0-alpha.1", "@types/nprogress": "^0.2.3", - "common": "workspace:*", "nprogress": "^0.2.0", "storyblok-js-client": "^6.2.0", "valibot": "^0.19.0" diff --git a/story-starter/starters/nuxt/pages/index.vue b/space-plugins/story-starter/starters/nuxt/pages/index.vue similarity index 100% rename from story-starter/starters/nuxt/pages/index.vue rename to space-plugins/story-starter/starters/nuxt/pages/index.vue diff --git a/story-starter/starters/nuxt/pnpm-lock.yaml b/space-plugins/story-starter/starters/nuxt/pnpm-lock.yaml similarity index 100% rename from story-starter/starters/nuxt/pnpm-lock.yaml rename to space-plugins/story-starter/starters/nuxt/pnpm-lock.yaml diff --git a/story-starter/starters/nuxt/public/favicon.ico b/space-plugins/story-starter/starters/nuxt/public/favicon.ico similarity index 100% rename from story-starter/starters/nuxt/public/favicon.ico rename to space-plugins/story-starter/starters/nuxt/public/favicon.ico diff --git a/story-starter/starters/nuxt/server/api/stories.ts b/space-plugins/story-starter/starters/nuxt/server/api/stories.ts similarity index 100% rename from story-starter/starters/nuxt/server/api/stories.ts rename to space-plugins/story-starter/starters/nuxt/server/api/stories.ts diff --git a/story-starter/starters/nuxt/server/tsconfig.json b/space-plugins/story-starter/starters/nuxt/server/tsconfig.json similarity index 100% rename from story-starter/starters/nuxt/server/tsconfig.json rename to space-plugins/story-starter/starters/nuxt/server/tsconfig.json diff --git a/story-starter/starters/nuxt/server/utils/parse.ts b/space-plugins/story-starter/starters/nuxt/server/utils/parse.ts similarity index 100% rename from story-starter/starters/nuxt/server/utils/parse.ts rename to space-plugins/story-starter/starters/nuxt/server/utils/parse.ts diff --git a/story-starter/starters/nuxt/shared/auth.ts b/space-plugins/story-starter/starters/nuxt/shared/auth.ts similarity index 100% rename from story-starter/starters/nuxt/shared/auth.ts rename to space-plugins/story-starter/starters/nuxt/shared/auth.ts diff --git a/story-starter/starters/nuxt/shared/defineStoryConfig.ts b/space-plugins/story-starter/starters/nuxt/shared/defineStoryConfig.ts similarity index 100% rename from story-starter/starters/nuxt/shared/defineStoryConfig.ts rename to space-plugins/story-starter/starters/nuxt/shared/defineStoryConfig.ts diff --git a/story-starter/starters/nuxt/stories.config.ts b/space-plugins/story-starter/starters/nuxt/stories.config.ts similarity index 100% rename from story-starter/starters/nuxt/stories.config.ts rename to space-plugins/story-starter/starters/nuxt/stories.config.ts diff --git a/story-starter/starters/nuxt/tailwind.config.js b/space-plugins/story-starter/starters/nuxt/tailwind.config.js similarity index 100% rename from story-starter/starters/nuxt/tailwind.config.js rename to space-plugins/story-starter/starters/nuxt/tailwind.config.js diff --git a/story-starter/starters/nuxt/tsconfig.json b/space-plugins/story-starter/starters/nuxt/tsconfig.json similarity index 100% rename from story-starter/starters/nuxt/tsconfig.json rename to space-plugins/story-starter/starters/nuxt/tsconfig.json diff --git a/story-starter/starters/nuxt/types/config.ts b/space-plugins/story-starter/starters/nuxt/types/config.ts similarity index 100% rename from story-starter/starters/nuxt/types/config.ts rename to space-plugins/story-starter/starters/nuxt/types/config.ts diff --git a/story-starter/starters/nuxt/types/story.ts b/space-plugins/story-starter/starters/nuxt/types/story.ts similarity index 100% rename from story-starter/starters/nuxt/types/story.ts rename to space-plugins/story-starter/starters/nuxt/types/story.ts diff --git a/story-starter/.gitignore b/story-starter/.gitignore deleted file mode 100644 index c657ff7..0000000 --- a/story-starter/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.idea -**/node_modules \ No newline at end of file diff --git a/story-starter/packages/common/package.json b/story-starter/packages/common/package.json deleted file mode 100644 index 241eeb4..0000000 --- a/story-starter/packages/common/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "common", - "version": "0.0.1", - "description": "", - "main": "src/index.ts", - "types": "src/index.ts", - "private": true, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "MIT" -} diff --git a/story-starter/packages/common/src/hello.vue b/story-starter/packages/common/src/hello.vue deleted file mode 100644 index b0b248e..0000000 --- a/story-starter/packages/common/src/hello.vue +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/story-starter/packages/common/src/index.ts b/story-starter/packages/common/src/index.ts deleted file mode 100644 index 014f6d9..0000000 --- a/story-starter/packages/common/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const XPTO = 'xpto2'; -export { default as Hello } from './hello.vue'; diff --git a/story-starter/packages/common/tsconfig.json b/story-starter/packages/common/tsconfig.json deleted file mode 100644 index db28147..0000000 --- a/story-starter/packages/common/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "isolatedModules": true, - "moduleResolution": "node", - "preserveWatchOutput": true, - "skipLibCheck": true, - "noEmit": true, - "strict": true - }, - "exclude": ["node_modules"] -} diff --git a/story-starter/pnpm-workspace.yaml b/story-starter/pnpm-workspace.yaml deleted file mode 100644 index 4f1a424..0000000 --- a/story-starter/pnpm-workspace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -packages: - - 'starters/*' - - 'packages/*' - - space-plugin-nuxt-base diff --git a/tool-nextjs-starter/.env.local.example b/tool-plugins/nextjs-starter/.env.local.example similarity index 100% rename from tool-nextjs-starter/.env.local.example rename to tool-plugins/nextjs-starter/.env.local.example diff --git a/tool-nextjs-starter/.gitignore b/tool-plugins/nextjs-starter/.gitignore similarity index 100% rename from tool-nextjs-starter/.gitignore rename to tool-plugins/nextjs-starter/.gitignore diff --git a/tool-nextjs-starter/.yarn/releases/yarn-3.6.3.cjs b/tool-plugins/nextjs-starter/.yarn/releases/yarn-3.6.3.cjs similarity index 100% rename from tool-nextjs-starter/.yarn/releases/yarn-3.6.3.cjs rename to tool-plugins/nextjs-starter/.yarn/releases/yarn-3.6.3.cjs diff --git a/tool-nextjs-starter/.yarnrc.yml b/tool-plugins/nextjs-starter/.yarnrc.yml similarity index 100% rename from tool-nextjs-starter/.yarnrc.yml rename to tool-plugins/nextjs-starter/.yarnrc.yml diff --git a/tool-nextjs-starter/README.md b/tool-plugins/nextjs-starter/README.md similarity index 100% rename from tool-nextjs-starter/README.md rename to tool-plugins/nextjs-starter/README.md diff --git a/tool-nextjs-starter/next.config.js b/tool-plugins/nextjs-starter/next.config.js similarity index 100% rename from tool-nextjs-starter/next.config.js rename to tool-plugins/nextjs-starter/next.config.js diff --git a/tool-nextjs-starter/package.json b/tool-plugins/nextjs-starter/package.json similarity index 100% rename from tool-nextjs-starter/package.json rename to tool-plugins/nextjs-starter/package.json diff --git a/tool-nextjs-starter/pnpm-lock.yaml b/tool-plugins/nextjs-starter/pnpm-lock.yaml similarity index 100% rename from tool-nextjs-starter/pnpm-lock.yaml rename to tool-plugins/nextjs-starter/pnpm-lock.yaml diff --git a/tool-nextjs-starter/public/tools.svg b/tool-plugins/nextjs-starter/public/tools.svg similarity index 100% rename from tool-nextjs-starter/public/tools.svg rename to tool-plugins/nextjs-starter/public/tools.svg diff --git a/tool-nextjs-starter/src/auth.ts b/tool-plugins/nextjs-starter/src/auth.ts similarity index 100% rename from tool-nextjs-starter/src/auth.ts rename to tool-plugins/nextjs-starter/src/auth.ts diff --git a/tool-nextjs-starter/src/hooks/getContext.ts b/tool-plugins/nextjs-starter/src/hooks/getContext.ts similarity index 100% rename from tool-nextjs-starter/src/hooks/getContext.ts rename to tool-plugins/nextjs-starter/src/hooks/getContext.ts diff --git a/tool-nextjs-starter/src/hooks/index.ts b/tool-plugins/nextjs-starter/src/hooks/index.ts similarity index 100% rename from tool-nextjs-starter/src/hooks/index.ts rename to tool-plugins/nextjs-starter/src/hooks/index.ts diff --git a/tool-nextjs-starter/src/hooks/shared.ts b/tool-plugins/nextjs-starter/src/hooks/shared.ts similarity index 100% rename from tool-nextjs-starter/src/hooks/shared.ts rename to tool-plugins/nextjs-starter/src/hooks/shared.ts diff --git a/tool-nextjs-starter/src/hooks/useAutoHeight.ts b/tool-plugins/nextjs-starter/src/hooks/useAutoHeight.ts similarity index 100% rename from tool-nextjs-starter/src/hooks/useAutoHeight.ts rename to tool-plugins/nextjs-starter/src/hooks/useAutoHeight.ts diff --git a/tool-nextjs-starter/src/pages/401.tsx b/tool-plugins/nextjs-starter/src/pages/401.tsx similarity index 100% rename from tool-nextjs-starter/src/pages/401.tsx rename to tool-plugins/nextjs-starter/src/pages/401.tsx diff --git a/tool-nextjs-starter/src/pages/_app.tsx b/tool-plugins/nextjs-starter/src/pages/_app.tsx similarity index 100% rename from tool-nextjs-starter/src/pages/_app.tsx rename to tool-plugins/nextjs-starter/src/pages/_app.tsx diff --git a/tool-nextjs-starter/src/pages/_document.tsx b/tool-plugins/nextjs-starter/src/pages/_document.tsx similarity index 100% rename from tool-nextjs-starter/src/pages/_document.tsx rename to tool-plugins/nextjs-starter/src/pages/_document.tsx diff --git a/tool-nextjs-starter/src/pages/api/connect/[...slugs].ts b/tool-plugins/nextjs-starter/src/pages/api/connect/[...slugs].ts similarity index 100% rename from tool-nextjs-starter/src/pages/api/connect/[...slugs].ts rename to tool-plugins/nextjs-starter/src/pages/api/connect/[...slugs].ts diff --git a/tool-nextjs-starter/src/pages/index.tsx b/tool-plugins/nextjs-starter/src/pages/index.tsx similarity index 100% rename from tool-nextjs-starter/src/pages/index.tsx rename to tool-plugins/nextjs-starter/src/pages/index.tsx diff --git a/tool-nextjs-starter/src/styles/globals.css b/tool-plugins/nextjs-starter/src/styles/globals.css similarity index 100% rename from tool-nextjs-starter/src/styles/globals.css rename to tool-plugins/nextjs-starter/src/styles/globals.css diff --git a/tool-nextjs-starter/src/utils/index.ts b/tool-plugins/nextjs-starter/src/utils/index.ts similarity index 100% rename from tool-nextjs-starter/src/utils/index.ts rename to tool-plugins/nextjs-starter/src/utils/index.ts diff --git a/tool-nextjs-starter/src/utils/isAdmin.ts b/tool-plugins/nextjs-starter/src/utils/isAdmin.ts similarity index 100% rename from tool-nextjs-starter/src/utils/isAdmin.ts rename to tool-plugins/nextjs-starter/src/utils/isAdmin.ts diff --git a/tool-nextjs-starter/tsconfig.json b/tool-plugins/nextjs-starter/tsconfig.json similarity index 100% rename from tool-nextjs-starter/tsconfig.json rename to tool-plugins/nextjs-starter/tsconfig.json diff --git a/tool-nextjs-starter/yarn.lock b/tool-plugins/nextjs-starter/yarn.lock similarity index 100% rename from tool-nextjs-starter/yarn.lock rename to tool-plugins/nextjs-starter/yarn.lock