From 8add48c355301538aa2b8ebdaa7ba9279f4794c1 Mon Sep 17 00:00:00 2001 From: timsu92 <33785401+timsu92@users.noreply.github.com> Date: Wed, 21 Jun 2023 15:28:09 +0800 Subject: [PATCH 1/5] feat: support nuxt3 --- src/blank-configurations/nuxt3.ts | 3 +++ src/set-pages-config.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/blank-configurations/nuxt3.ts diff --git a/src/blank-configurations/nuxt3.ts b/src/blank-configurations/nuxt3.ts new file mode 100644 index 0000000..a1162b1 --- /dev/null +++ b/src/blank-configurations/nuxt3.ts @@ -0,0 +1,3 @@ +// Default Pages configuration for Nuxt3 +// https://nuxt.com/docs/api/configuration/nuxt-config +export default defineNuxtConfig({}) diff --git a/src/set-pages-config.js b/src/set-pages-config.js index 2ec86a8..19c16b0 100644 --- a/src/set-pages-config.js +++ b/src/set-pages-config.js @@ -23,6 +23,18 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, sit target: 'static' } } + case 'nuxt3': + return { + configurationFile: generatorConfigFile || './nuxt.config.ts', + blankConfigurationFile: `${__dirname}/blank-configurations/nuxt3.ts`, + properties: { + // Configure a base path of the app + 'app.baseURL': path, + + // Set the target to static too + ssr: false + } + } case 'next': // Next does not want a trailing slash path = removeTrailingSlash(path) From 69440930f7e2e2f38a31b27ab071a9fffee822ea Mon Sep 17 00:00:00 2001 From: timsu92 <33785401+timsu92@users.noreply.github.com> Date: Wed, 21 Jun 2023 16:23:12 +0800 Subject: [PATCH 2/5] test(nuxt3): tries to create testing for nuxt3 Files mainly copied from nuxt2 version --- src/fixtures/nuxt3/async.expected.ts | 16 ++++++++++++++++ src/fixtures/nuxt3/async.ts | 12 ++++++++++++ src/fixtures/nuxt3/default.expected.ts | 25 +++++++++++++++++++++++++ src/fixtures/nuxt3/default.ts | 23 +++++++++++++++++++++++ src/set-pages-config.test.js | 4 ++-- 5 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 src/fixtures/nuxt3/async.expected.ts create mode 100644 src/fixtures/nuxt3/async.ts create mode 100644 src/fixtures/nuxt3/default.expected.ts create mode 100644 src/fixtures/nuxt3/default.ts diff --git a/src/fixtures/nuxt3/async.expected.ts b/src/fixtures/nuxt3/async.expected.ts new file mode 100644 index 0000000..7a7490e --- /dev/null +++ b/src/fixtures/nuxt3/async.expected.ts @@ -0,0 +1,16 @@ +const getAllDynamicRoute = async function () { + const routes = await (async () => { + return ['/posts/hello-world', '/posts/hello-again'] + })() + return routes +} + +export default defineNuxtConfig({ + app: { + baseURL: '/docs/' + }, + generate: { + routes: await getAllDynamicRoute() + }, + ssr: false +}) diff --git a/src/fixtures/nuxt3/async.ts b/src/fixtures/nuxt3/async.ts new file mode 100644 index 0000000..894a472 --- /dev/null +++ b/src/fixtures/nuxt3/async.ts @@ -0,0 +1,12 @@ +const getAllDynamicRoute = async function () { + const routes = await (async () => { + return ['/posts/hello-world', '/posts/hello-again'] + })() + return routes +} + +export default defineNuxtConfig({ + generate: { + routes: await getAllDynamicRoute() + } +}) diff --git a/src/fixtures/nuxt3/default.expected.ts b/src/fixtures/nuxt3/default.expected.ts new file mode 100644 index 0000000..a423e5f --- /dev/null +++ b/src/fixtures/nuxt3/default.expected.ts @@ -0,0 +1,25 @@ +// https://nuxt.com/docs/api/configuration/nuxt-config +export default defineNuxtConfig({ + app: { + baseURL: '/docs/' , + head: { + title: 'nuxt', + htmlAttrs: { + lang: 'en' + }, + meta: [ + { charset: 'utf-8' }, + { name: 'viewport', content: 'width=device-width, initial-scale=1' }, + { key: 'description', name: 'description', content: '' }, + { name: 'format-detection', content: 'telephone=no' } + ], + link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }] + } + }, + ssr: false, + css: [], + plugins: [], + components: true, + modules: [], + build: {} +}) diff --git a/src/fixtures/nuxt3/default.ts b/src/fixtures/nuxt3/default.ts new file mode 100644 index 0000000..896b5ed --- /dev/null +++ b/src/fixtures/nuxt3/default.ts @@ -0,0 +1,23 @@ +// https://nuxt.com/docs/api/configuration/nuxt-config +export default defineNuxtConfig({ + app: { + head: { + title: 'nuxt', + htmlAttrs: { + lang: 'en' + }, + meta: [ + { charset: 'utf-8' }, + { name: 'viewport', content: 'width=device-width, initial-scale=1' }, + { key: 'description', name: 'description', content: '' }, + { name: 'format-detection', content: 'telephone=no' } + ], + link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }] + } + }, + css: [], + plugins: [], + components: true, + modules: [], + build: {} +}) diff --git a/src/set-pages-config.test.js b/src/set-pages-config.test.js index dc3215e..383b40d 100644 --- a/src/set-pages-config.test.js +++ b/src/set-pages-config.test.js @@ -8,8 +8,8 @@ const { getTempFolder, compareFiles } = require('./test-helpers') // Get the temp folder const tempFolder = getTempFolder() -const SUPPORTED_GENERATORS = ['next', 'nuxt', 'gatsby', 'sveltekit'] -const SUPPORTED_FILE_EXTENSIONS = ['.js', '.cjs', '.mjs'] +const SUPPORTED_GENERATORS = ['next', 'nuxt', 'nuxt3', 'gatsby', 'sveltekit'] +const SUPPORTED_FILE_EXTENSIONS = ['.js', '.cjs', '.mjs', '.ts'] const IS_BLANK_CONFIG_FILE_REGEX = new RegExp( '^blank\\.(' + SUPPORTED_FILE_EXTENSIONS.map(ext => ext.slice(1)).join('|') + ')$' ) From bec7cf6e61b96c25028401188cf4d1edb41cc18f Mon Sep 17 00:00:00 2001 From: timsu92 <33785401+timsu92@users.noreply.github.com> Date: Wed, 21 Jun 2023 20:29:39 +0800 Subject: [PATCH 3/5] test(nuxt3): allow wrapping call to match Nuxt3's config --- src/set-pages-config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/set-pages-config.js b/src/set-pages-config.js index 19c16b0..2e0f1bf 100644 --- a/src/set-pages-config.js +++ b/src/set-pages-config.js @@ -27,6 +27,7 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, sit return { configurationFile: generatorConfigFile || './nuxt.config.ts', blankConfigurationFile: `${__dirname}/blank-configurations/nuxt3.ts`, + allowWrappingCall: true, properties: { // Configure a base path of the app 'app.baseURL': path, From 1b6de598b3326e6560597f921292723bf2e39ea9 Mon Sep 17 00:00:00 2001 From: timsu92 <33785401+timsu92@users.noreply.github.com> Date: Wed, 21 Jun 2023 20:35:06 +0800 Subject: [PATCH 4/5] test(nuxt3): move lines to match generated config's sequence --- src/fixtures/nuxt3/async.expected.ts | 7 +++---- src/fixtures/nuxt3/async.ts | 1 + src/fixtures/nuxt3/default.expected.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fixtures/nuxt3/async.expected.ts b/src/fixtures/nuxt3/async.expected.ts index 7a7490e..c71491c 100644 --- a/src/fixtures/nuxt3/async.expected.ts +++ b/src/fixtures/nuxt3/async.expected.ts @@ -1,3 +1,4 @@ +// https://nuxt.com/docs/api/configuration/nuxt-config const getAllDynamicRoute = async function () { const routes = await (async () => { return ['/posts/hello-world', '/posts/hello-again'] @@ -6,11 +7,9 @@ const getAllDynamicRoute = async function () { } export default defineNuxtConfig({ - app: { - baseURL: '/docs/' - }, + ssr: false, + app: { baseURL: '/docs/' }, generate: { routes: await getAllDynamicRoute() }, - ssr: false }) diff --git a/src/fixtures/nuxt3/async.ts b/src/fixtures/nuxt3/async.ts index 894a472..3faade7 100644 --- a/src/fixtures/nuxt3/async.ts +++ b/src/fixtures/nuxt3/async.ts @@ -1,3 +1,4 @@ +// https://nuxt.com/docs/api/configuration/nuxt-config const getAllDynamicRoute = async function () { const routes = await (async () => { return ['/posts/hello-world', '/posts/hello-again'] diff --git a/src/fixtures/nuxt3/default.expected.ts b/src/fixtures/nuxt3/default.expected.ts index a423e5f..af26c3b 100644 --- a/src/fixtures/nuxt3/default.expected.ts +++ b/src/fixtures/nuxt3/default.expected.ts @@ -1,5 +1,6 @@ // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ + ssr: false, app: { baseURL: '/docs/' , head: { @@ -16,7 +17,6 @@ export default defineNuxtConfig({ link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }] } }, - ssr: false, css: [], plugins: [], components: true, From 21bcdd1a8fb52b4b9e340654eeaebc45a14c5ebf Mon Sep 17 00:00:00 2001 From: timsu92 <33785401+timsu92@users.noreply.github.com> Date: Wed, 21 Jun 2023 20:41:02 +0800 Subject: [PATCH 5/5] feat: add nuxt3 to be one of static_site_generator input --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e894dd3..1dc55cc 100644 --- a/action.yml +++ b/action.yml @@ -6,7 +6,7 @@ runs: main: 'dist/index.js' inputs: static_site_generator: - description: 'Optional static site generator to attempt to configure: "nuxt", "next", "gatsby", or "sveltekit"' + description: 'Optional static site generator to attempt to configure: "nuxt", "nuxt3", "next", "gatsby", or "sveltekit"' required: false generator_config_file: description: 'Optional file path to static site generator configuration file'