From fdd855167135c4a2ad68aa658bf8bd396b5692b6 Mon Sep 17 00:00:00 2001 From: solufa Date: Sun, 30 Jul 2023 05:50:43 +0900 Subject: [PATCH] feat: enable semi in prettier config and format --- __tests__/index.spec.ts | 54 ++++----- jest.config.ts | 6 +- package.json | 2 +- projects/build.ts | 6 +- projects/nextjs-appdir/lib/$path.ts | 30 ++--- projects/nextjs-appdir/out/lib/basic/$path.ts | 26 ++--- .../nextjs-appdir/out/lib/ignore/$path.ts | 30 ++--- .../nextjs-appdir/out/lib/static/$path.ts | 30 ++--- .../nextjs-basepath/out/lib/basic/$path.ts | 10 +- .../nextjs-basepath/out/lib/ignore/$path.ts | 14 +-- .../nextjs-basepath/out/lib/static/$path.ts | 14 +-- projects/nextjs-basepath/utils/$path.ts | 14 +-- projects/nextjs-custom-ext/lib/$path.ts | 8 +- .../nextjs-custom-ext/out/lib/basic/$path.ts | 4 +- .../nextjs-custom-ext/out/lib/ignore/$path.ts | 8 +- .../nextjs-custom-ext/out/lib/static/$path.ts | 8 +- .../src/out/lib/basic/$path.ts | 22 ++-- .../src/out/lib/ignore/$path.ts | 26 ++--- .../src/out/lib/static/$path.ts | 26 ++--- projects/nextjs-src-appdir/src/utils/$path.ts | 26 ++--- .../nextjs-src/src/out/lib/basic/$path.ts | 10 +- .../nextjs-src/src/out/lib/ignore/$path.ts | 14 +-- .../nextjs-src/src/out/lib/static/$path.ts | 14 +-- projects/nextjs-src/src/utils/$path.ts | 14 +-- projects/nextjs-stable-appdir/lib/$path.ts | 30 ++--- .../out/lib/basic/$path.ts | 26 ++--- .../out/lib/ignore/$path.ts | 30 ++--- .../out/lib/static/$path.ts | 30 ++--- projects/nextjs/lib/$path.ts | 14 +-- projects/nextjs/out/lib/basic/$path.ts | 10 +- projects/nextjs/out/lib/ignore/$path.ts | 14 +-- projects/nextjs/out/lib/static/$path.ts | 14 +-- projects/nuxtjs-basepath/plugins/$path.ts | 30 ++--- .../plugins/util/basic/$path.ts | 24 ++-- .../plugins/util/ignore/$path.ts | 30 ++--- .../plugins/util/static/$path.ts | 30 ++--- projects/nuxtjs-no-slash/plugins/$path.ts | 30 ++--- .../plugins/util/basic/$path.ts | 24 ++-- .../plugins/util/ignore/$path.ts | 30 ++--- .../plugins/util/static/$path.ts | 30 ++--- projects/nuxtjs-src/client/plugins/$path.ts | 30 ++--- .../client/plugins/util/basic/$path.ts | 24 ++-- .../client/plugins/util/ignore/$path.ts | 30 ++--- .../client/plugins/util/static/$path.ts | 30 ++--- projects/nuxtjs/plugins/$path.ts | 30 ++--- projects/nuxtjs/plugins/util/basic/$path.ts | 24 ++-- projects/nuxtjs/plugins/util/ignore/$path.ts | 30 ++--- projects/nuxtjs/plugins/util/static/$path.ts | 30 ++--- projects/projects.ts | 12 +- src/buildTemplate.ts | 58 +++++----- src/cli.ts | 28 ++--- src/createNuxtTemplate.ts | 108 +++++++++--------- src/createStaticTemplate.ts | 44 +++---- src/getConfig.ts | 64 +++++------ src/isIgnored.ts | 10 +- src/nextjs/createNextTemplate.ts | 36 +++--- src/nextjs/parseAppDir.ts | 88 +++++++------- src/nextjs/parsePagesDir.ts | 98 ++++++++-------- src/parseQueryFromTS.ts | 18 +-- src/replaceWithUnderscore.ts | 2 +- src/watchInputDir.ts | 6 +- src/writeRouteFile.ts | 10 +- 62 files changed, 813 insertions(+), 809 deletions(-) diff --git a/__tests__/index.spec.ts b/__tests__/index.spec.ts index 6f0badc..1bb0d9c 100644 --- a/__tests__/index.spec.ts +++ b/__tests__/index.spec.ts @@ -1,44 +1,44 @@ -import fs from 'fs' -import path from 'path' -import { version } from '../package.json' -import { projects } from '../projects/projects' -import build, { resetCache } from '../src/buildTemplate' -import { run } from '../src/cli' -import getConfig from '../src/getConfig' +import fs from 'fs'; +import path from 'path'; +import { version } from '../package.json'; +import { projects } from '../projects/projects'; +import build, { resetCache } from '../src/buildTemplate'; +import { run } from '../src/cli'; +import getConfig from '../src/getConfig'; -jest.setTimeout(30000) +jest.setTimeout(30000); -const nodeVer = +process.versions.node.split('.')[0] +const nodeVer = +process.versions.node.split('.')[0]; describe('cli test', () => { test('version command', async () => { - const spyLog = jest.spyOn(console, 'log').mockImplementation(x => x) - const args = ['--version'] + const spyLog = jest.spyOn(console, 'log').mockImplementation(x => x); + const args = ['--version']; - await run(args) - expect(console.log).toHaveBeenCalledWith(`v${version}`) + await run(args); + expect(console.log).toHaveBeenCalledWith(`v${version}`); - spyLog.mockReset() - spyLog.mockRestore() - }) + spyLog.mockReset(); + spyLog.mockRestore(); + }); test('main', async () => { for (const project of projects) { - if (nodeVer < project.nodeVer) continue + if (nodeVer < project.nodeVer) continue; - resetCache() + resetCache(); - const workingDir = path.join(process.cwd(), 'projects', project.dir) + const workingDir = path.join(process.cwd(), 'projects', project.dir); const { type, input, staticDir, output, ignorePath, trailingSlash, pageExtensions, appDir } = await getConfig( project.enableStatic, project.output && path.join(workingDir, project.output), project.ignorePath, workingDir - ) + ); - const result = fs.readFileSync(`${output}/$path.ts`, 'utf8') - const basepath = /-basepath$/.test(project.dir) ? '/foo/bar' : undefined + const result = fs.readFileSync(`${output}/$path.ts`, 'utf8'); + const basepath = /-basepath$/.test(project.dir) ? '/foo/bar' : undefined; const { filePath, text } = build( type === 'nextjs' ? { @@ -62,9 +62,9 @@ describe('cli test', () => { trailingSlash, basepath } - ) + ); - expect(filePath).toBe(`${output}/$path.ts`) + expect(filePath).toBe(`${output}/$path.ts`); expect( text.replace( new RegExp( @@ -75,7 +75,7 @@ describe('cli test', () => { ), '' ) - ).toBe(result.replace(/\r/g, '')) + ).toBe(result.replace(/\r/g, '')); } - }) -}) + }); +}); diff --git a/jest.config.ts b/jest.config.ts index 39104cd..753a4de 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,9 +1,9 @@ -import type { Config } from '@jest/types' +import type { Config } from '@jest/types'; const config: Config.InitialOptions = { preset: 'ts-jest', testEnvironment: 'node', testPathIgnorePatterns: ['pages'] -} +}; -export default config +export default config; diff --git a/package.json b/package.json index 02ecb5c..7224b59 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ }, "prettier": { "printWidth": 100, - "semi": false, + "semi": true, "arrowParens": "avoid", "singleQuote": true, "trailingComma": "none", diff --git a/projects/build.ts b/projects/build.ts index 61bd384..29bc403 100644 --- a/projects/build.ts +++ b/projects/build.ts @@ -1,5 +1,5 @@ -import { exec } from 'child_process' -import { projects } from './projects' +import { exec } from 'child_process'; +import { projects } from './projects'; projects.forEach(({ dir, output, enableStatic, ignorePath }) => exec( @@ -8,4 +8,4 @@ projects.forEach(({ dir, output, enableStatic, ignorePath }) => }${ignorePath ? ` --ignorePath ${ignorePath}` : ''}`, (_err, stdout, stderr) => console.log(stdout, stderr) ) -) +); diff --git a/projects/nextjs-appdir/lib/$path.ts b/projects/nextjs-appdir/lib/$path.ts index 5bebcbf..1ba841a 100644 --- a/projects/nextjs-appdir/lib/$path.ts +++ b/projects/nextjs-appdir/lib/$path.ts @@ -1,16 +1,16 @@ -import type { Query as Query0 } from '../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../app/(group1)/blog/[...slug]/page' -import type { OptionalQuery as OptionalQuery3 } from '../pages/children/[pid]' -import type { Query as Query4 } from '../pages/children/blog/[...slug]' +import type { Query as Query0 } from '../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../app/(group1)/blog/[...slug]/page'; +import type { OptionalQuery as OptionalQuery3 } from '../pages/children/[pid]'; +import type { Query as Query4 } from '../pages/children/blog/[...slug]'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -109,9 +109,9 @@ export const pagesPath = { }) } } -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -124,6 +124,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-appdir/out/lib/basic/$path.ts b/projects/nextjs-appdir/out/lib/basic/$path.ts index 3ce9711..d8a686e 100644 --- a/projects/nextjs-appdir/out/lib/basic/$path.ts +++ b/projects/nextjs-appdir/out/lib/basic/$path.ts @@ -1,16 +1,16 @@ -import type { Query as Query0 } from '../../../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page' -import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]' -import type { Query as Query4 } from '../../../pages/children/blog/[...slug]' +import type { Query as Query0 } from '../../../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page'; +import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]'; +import type { Query as Query4 } from '../../../pages/children/blog/[...slug]'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -103,6 +103,6 @@ export const pagesPath = { }) } } -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; diff --git a/projects/nextjs-appdir/out/lib/ignore/$path.ts b/projects/nextjs-appdir/out/lib/ignore/$path.ts index 577321e..32532c6 100644 --- a/projects/nextjs-appdir/out/lib/ignore/$path.ts +++ b/projects/nextjs-appdir/out/lib/ignore/$path.ts @@ -1,16 +1,16 @@ -import type { Query as Query0 } from '../../../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page' -import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]' -import type { Query as Query4 } from '../../../pages/children/blog/[...slug]' +import type { Query as Query0 } from '../../../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page'; +import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]'; +import type { Query as Query4 } from '../../../pages/children/blog/[...slug]'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -103,9 +103,9 @@ export const pagesPath = { }) } } -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -117,6 +117,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-appdir/out/lib/static/$path.ts b/projects/nextjs-appdir/out/lib/static/$path.ts index c58dfc3..15bc807 100644 --- a/projects/nextjs-appdir/out/lib/static/$path.ts +++ b/projects/nextjs-appdir/out/lib/static/$path.ts @@ -1,16 +1,16 @@ -import type { Query as Query0 } from '../../../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page' -import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]' -import type { Query as Query4 } from '../../../pages/children/blog/[...slug]' +import type { Query as Query0 } from '../../../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page'; +import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]'; +import type { Query as Query4 } from '../../../pages/children/blog/[...slug]'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -109,9 +109,9 @@ export const pagesPath = { }) } } -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -124,6 +124,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-basepath/out/lib/basic/$path.ts b/projects/nextjs-basepath/out/lib/basic/$path.ts index 9b2bebe..a3f3101 100644 --- a/projects/nextjs-basepath/out/lib/basic/$path.ts +++ b/projects/nextjs-basepath/out/lib/basic/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]' -import type { Query as Query2 } from '../../../pages/blog/[...slug]' +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]'; +import type { Query as Query2 } from '../../../pages/blog/[...slug]'; export const pagesPath = { _a: (a: string | number) => ({ @@ -36,6 +36,6 @@ export const pagesPath = { } }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; diff --git a/projects/nextjs-basepath/out/lib/ignore/$path.ts b/projects/nextjs-basepath/out/lib/ignore/$path.ts index b93d073..76d935b 100644 --- a/projects/nextjs-basepath/out/lib/ignore/$path.ts +++ b/projects/nextjs-basepath/out/lib/ignore/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]' -import type { Query as Query2 } from '../../../pages/blog/[...slug]' +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]'; +import type { Query as Query2 } from '../../../pages/blog/[...slug]'; export const pagesPath = { _a: (a: string | number) => ({ @@ -36,9 +36,9 @@ export const pagesPath = { } }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/foo/bar/aa.json', @@ -50,6 +50,6 @@ export const staticPath = { }, duplicate_json_1: '/foo/bar/duplicate.json', duplicate_json_2: '/foo/bar/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-basepath/out/lib/static/$path.ts b/projects/nextjs-basepath/out/lib/static/$path.ts index 358ce88..ca35394 100644 --- a/projects/nextjs-basepath/out/lib/static/$path.ts +++ b/projects/nextjs-basepath/out/lib/static/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]' -import type { Query as Query2 } from '../../../pages/blog/[...slug]' +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]'; +import type { Query as Query2 } from '../../../pages/blog/[...slug]'; export const pagesPath = { "_ignore": { @@ -39,9 +39,9 @@ export const pagesPath = { } }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/foo/bar/aa.json', @@ -54,6 +54,6 @@ export const staticPath = { }, duplicate_json_1: '/foo/bar/duplicate.json', duplicate_json_2: '/foo/bar/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-basepath/utils/$path.ts b/projects/nextjs-basepath/utils/$path.ts index 5d13b4b..94ae592 100644 --- a/projects/nextjs-basepath/utils/$path.ts +++ b/projects/nextjs-basepath/utils/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../pages' -import type { OptionalQuery as OptionalQuery1 } from '../pages/[pid]' -import type { Query as Query2 } from '../pages/blog/[...slug]' +import type { Query as Query0 } from '../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../pages/[pid]'; +import type { Query as Query2 } from '../pages/blog/[...slug]'; export const pagesPath = { "_ignore": { @@ -39,9 +39,9 @@ export const pagesPath = { } }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/foo/bar/aa.json', @@ -54,6 +54,6 @@ export const staticPath = { }, duplicate_json_1: '/foo/bar/duplicate.json', duplicate_json_2: '/foo/bar/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-custom-ext/lib/$path.ts b/projects/nextjs-custom-ext/lib/$path.ts index 18a38ab..61e97f5 100644 --- a/projects/nextjs-custom-ext/lib/$path.ts +++ b/projects/nextjs-custom-ext/lib/$path.ts @@ -12,9 +12,9 @@ export const pagesPath = { }) } }, -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -27,6 +27,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-custom-ext/out/lib/basic/$path.ts b/projects/nextjs-custom-ext/out/lib/basic/$path.ts index b0467df..d11813f 100644 --- a/projects/nextjs-custom-ext/out/lib/basic/$path.ts +++ b/projects/nextjs-custom-ext/out/lib/basic/$path.ts @@ -9,6 +9,6 @@ export const pagesPath = { }) } }, -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; diff --git a/projects/nextjs-custom-ext/out/lib/ignore/$path.ts b/projects/nextjs-custom-ext/out/lib/ignore/$path.ts index 6f12b87..055a884 100644 --- a/projects/nextjs-custom-ext/out/lib/ignore/$path.ts +++ b/projects/nextjs-custom-ext/out/lib/ignore/$path.ts @@ -9,9 +9,9 @@ export const pagesPath = { }) } }, -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -23,6 +23,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-custom-ext/out/lib/static/$path.ts b/projects/nextjs-custom-ext/out/lib/static/$path.ts index 18a38ab..61e97f5 100644 --- a/projects/nextjs-custom-ext/out/lib/static/$path.ts +++ b/projects/nextjs-custom-ext/out/lib/static/$path.ts @@ -12,9 +12,9 @@ export const pagesPath = { }) } }, -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -27,6 +27,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-src-appdir/src/out/lib/basic/$path.ts b/projects/nextjs-src-appdir/src/out/lib/basic/$path.ts index 4f7b731..af41a0e 100644 --- a/projects/nextjs-src-appdir/src/out/lib/basic/$path.ts +++ b/projects/nextjs-src-appdir/src/out/lib/basic/$path.ts @@ -1,14 +1,14 @@ -import type { Query as Query0 } from '../../../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page' +import type { Query as Query0 } from '../../../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -51,6 +51,6 @@ export const pagesPath = { } }), $url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash, path: `/${buildSuffix(url)}` }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; diff --git a/projects/nextjs-src-appdir/src/out/lib/ignore/$path.ts b/projects/nextjs-src-appdir/src/out/lib/ignore/$path.ts index b7f8799..98e992b 100644 --- a/projects/nextjs-src-appdir/src/out/lib/ignore/$path.ts +++ b/projects/nextjs-src-appdir/src/out/lib/ignore/$path.ts @@ -1,14 +1,14 @@ -import type { Query as Query0 } from '../../../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page' +import type { Query as Query0 } from '../../../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -51,9 +51,9 @@ export const pagesPath = { } }), $url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash, path: `/${buildSuffix(url)}` }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -65,6 +65,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-src-appdir/src/out/lib/static/$path.ts b/projects/nextjs-src-appdir/src/out/lib/static/$path.ts index 6d9989d..9e347d8 100644 --- a/projects/nextjs-src-appdir/src/out/lib/static/$path.ts +++ b/projects/nextjs-src-appdir/src/out/lib/static/$path.ts @@ -1,14 +1,14 @@ -import type { Query as Query0 } from '../../../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page' +import type { Query as Query0 } from '../../../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -54,9 +54,9 @@ export const pagesPath = { } }), $url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash, path: `/${buildSuffix(url)}` }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -69,6 +69,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-src-appdir/src/utils/$path.ts b/projects/nextjs-src-appdir/src/utils/$path.ts index bfe393a..672f3e7 100644 --- a/projects/nextjs-src-appdir/src/utils/$path.ts +++ b/projects/nextjs-src-appdir/src/utils/$path.ts @@ -1,14 +1,14 @@ -import type { Query as Query0 } from '../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../app/(group1)/blog/[...slug]/page' +import type { Query as Query0 } from '../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../app/(group1)/blog/[...slug]/page'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -54,9 +54,9 @@ export const pagesPath = { } }), $url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash, path: `/${buildSuffix(url)}` }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -69,6 +69,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-src/src/out/lib/basic/$path.ts b/projects/nextjs-src/src/out/lib/basic/$path.ts index 9b2bebe..a3f3101 100644 --- a/projects/nextjs-src/src/out/lib/basic/$path.ts +++ b/projects/nextjs-src/src/out/lib/basic/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]' -import type { Query as Query2 } from '../../../pages/blog/[...slug]' +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]'; +import type { Query as Query2 } from '../../../pages/blog/[...slug]'; export const pagesPath = { _a: (a: string | number) => ({ @@ -36,6 +36,6 @@ export const pagesPath = { } }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; diff --git a/projects/nextjs-src/src/out/lib/ignore/$path.ts b/projects/nextjs-src/src/out/lib/ignore/$path.ts index 89848c5..03c3753 100644 --- a/projects/nextjs-src/src/out/lib/ignore/$path.ts +++ b/projects/nextjs-src/src/out/lib/ignore/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]' -import type { Query as Query2 } from '../../../pages/blog/[...slug]' +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]'; +import type { Query as Query2 } from '../../../pages/blog/[...slug]'; export const pagesPath = { _a: (a: string | number) => ({ @@ -36,9 +36,9 @@ export const pagesPath = { } }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -50,6 +50,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-src/src/out/lib/static/$path.ts b/projects/nextjs-src/src/out/lib/static/$path.ts index 279ee8f..02ac552 100644 --- a/projects/nextjs-src/src/out/lib/static/$path.ts +++ b/projects/nextjs-src/src/out/lib/static/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]' -import type { Query as Query2 } from '../../../pages/blog/[...slug]' +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]'; +import type { Query as Query2 } from '../../../pages/blog/[...slug]'; export const pagesPath = { "_ignore": { @@ -39,9 +39,9 @@ export const pagesPath = { } }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -54,6 +54,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-src/src/utils/$path.ts b/projects/nextjs-src/src/utils/$path.ts index 58f5d8b..05dc7f4 100644 --- a/projects/nextjs-src/src/utils/$path.ts +++ b/projects/nextjs-src/src/utils/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../pages' -import type { OptionalQuery as OptionalQuery1 } from '../pages/[pid]' -import type { Query as Query2 } from '../pages/blog/[...slug]' +import type { Query as Query0 } from '../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../pages/[pid]'; +import type { Query as Query2 } from '../pages/blog/[...slug]'; export const pagesPath = { "_ignore": { @@ -39,9 +39,9 @@ export const pagesPath = { } }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -54,6 +54,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-stable-appdir/lib/$path.ts b/projects/nextjs-stable-appdir/lib/$path.ts index 5bebcbf..1ba841a 100644 --- a/projects/nextjs-stable-appdir/lib/$path.ts +++ b/projects/nextjs-stable-appdir/lib/$path.ts @@ -1,16 +1,16 @@ -import type { Query as Query0 } from '../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../app/(group1)/blog/[...slug]/page' -import type { OptionalQuery as OptionalQuery3 } from '../pages/children/[pid]' -import type { Query as Query4 } from '../pages/children/blog/[...slug]' +import type { Query as Query0 } from '../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../app/(group1)/blog/[...slug]/page'; +import type { OptionalQuery as OptionalQuery3 } from '../pages/children/[pid]'; +import type { Query as Query4 } from '../pages/children/blog/[...slug]'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -109,9 +109,9 @@ export const pagesPath = { }) } } -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -124,6 +124,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-stable-appdir/out/lib/basic/$path.ts b/projects/nextjs-stable-appdir/out/lib/basic/$path.ts index 3ce9711..d8a686e 100644 --- a/projects/nextjs-stable-appdir/out/lib/basic/$path.ts +++ b/projects/nextjs-stable-appdir/out/lib/basic/$path.ts @@ -1,16 +1,16 @@ -import type { Query as Query0 } from '../../../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page' -import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]' -import type { Query as Query4 } from '../../../pages/children/blog/[...slug]' +import type { Query as Query0 } from '../../../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page'; +import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]'; +import type { Query as Query4 } from '../../../pages/children/blog/[...slug]'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -103,6 +103,6 @@ export const pagesPath = { }) } } -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; diff --git a/projects/nextjs-stable-appdir/out/lib/ignore/$path.ts b/projects/nextjs-stable-appdir/out/lib/ignore/$path.ts index 577321e..32532c6 100644 --- a/projects/nextjs-stable-appdir/out/lib/ignore/$path.ts +++ b/projects/nextjs-stable-appdir/out/lib/ignore/$path.ts @@ -1,16 +1,16 @@ -import type { Query as Query0 } from '../../../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page' -import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]' -import type { Query as Query4 } from '../../../pages/children/blog/[...slug]' +import type { Query as Query0 } from '../../../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page'; +import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]'; +import type { Query as Query4 } from '../../../pages/children/blog/[...slug]'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -103,9 +103,9 @@ export const pagesPath = { }) } } -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -117,6 +117,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs-stable-appdir/out/lib/static/$path.ts b/projects/nextjs-stable-appdir/out/lib/static/$path.ts index c58dfc3..15bc807 100644 --- a/projects/nextjs-stable-appdir/out/lib/static/$path.ts +++ b/projects/nextjs-stable-appdir/out/lib/static/$path.ts @@ -1,16 +1,16 @@ -import type { Query as Query0 } from '../../../app/page' -import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page' -import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page' -import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]' -import type { Query as Query4 } from '../../../pages/children/blog/[...slug]' +import type { Query as Query0 } from '../../../app/page'; +import type { OptionalQuery as OptionalQuery1 } from '../../../app/(group1)/[pid]/page'; +import type { Query as Query2 } from '../../../app/(group1)/blog/[...slug]/page'; +import type { OptionalQuery as OptionalQuery3 } from '../../../pages/children/[pid]'; +import type { Query as Query4 } from '../../../pages/children/blog/[...slug]'; const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? `?${new URLSearchParams(query)}` : '' - return `${search}${hash ? `#${hash}` : ''}` -} + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? `?${new URLSearchParams(query)}` : ''; + return `${search}${hash ? `#${hash}` : ''}`; +}; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -109,9 +109,9 @@ export const pagesPath = { }) } } -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -124,6 +124,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs/lib/$path.ts b/projects/nextjs/lib/$path.ts index 8c3b0b3..ac844dd 100644 --- a/projects/nextjs/lib/$path.ts +++ b/projects/nextjs/lib/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../pages' -import type { OptionalQuery as OptionalQuery1 } from '../pages/[pid]' -import type { Query as Query2 } from '../pages/blog/[...slug]' +import type { Query as Query0 } from '../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../pages/[pid]'; +import type { Query as Query2 } from '../pages/blog/[...slug]'; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -51,9 +51,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -66,6 +66,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs/out/lib/basic/$path.ts b/projects/nextjs/out/lib/basic/$path.ts index e02ec75..d420af3 100644 --- a/projects/nextjs/out/lib/basic/$path.ts +++ b/projects/nextjs/out/lib/basic/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]' -import type { Query as Query2 } from '../../../pages/blog/[...slug]' +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]'; +import type { Query as Query2 } from '../../../pages/blog/[...slug]'; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -48,6 +48,6 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; diff --git a/projects/nextjs/out/lib/ignore/$path.ts b/projects/nextjs/out/lib/ignore/$path.ts index 5e860ec..c9af3bc 100644 --- a/projects/nextjs/out/lib/ignore/$path.ts +++ b/projects/nextjs/out/lib/ignore/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]' -import type { Query as Query2 } from '../../../pages/blog/[...slug]' +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]'; +import type { Query as Query2 } from '../../../pages/blog/[...slug]'; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -48,9 +48,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -62,6 +62,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nextjs/out/lib/static/$path.ts b/projects/nextjs/out/lib/static/$path.ts index ef4a481..9b27da1 100644 --- a/projects/nextjs/out/lib/static/$path.ts +++ b/projects/nextjs/out/lib/static/$path.ts @@ -1,6 +1,6 @@ -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]' -import type { Query as Query2 } from '../../../pages/blog/[...slug]' +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/[pid]'; +import type { Query as Query2 } from '../../../pages/blog/[...slug]'; export const pagesPath = { "%E6%97%A5%E6%9C%AC%E8%AA%9E": { @@ -51,9 +51,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -66,6 +66,6 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; diff --git a/projects/nuxtjs-basepath/plugins/$path.ts b/projects/nuxtjs-basepath/plugins/$path.ts index e582764..7ed3a24 100644 --- a/projects/nuxtjs-basepath/plugins/$path.ts +++ b/projects/nuxtjs-basepath/plugins/$path.ts @@ -1,8 +1,8 @@ -import type { Plugin } from '@nuxt/types' +import type { Plugin } from '@nuxt/types'; -type Query0 = { hoge: string } +type Query0 = { hoge: string }; -type OptionalQuery1 = { hoge: string } +type OptionalQuery1 = { hoge: string }; type Query2 = { hoge: string @@ -10,7 +10,7 @@ type Query2 = { a: number b: { c: string }[] } -} +}; export const pagesPath = { _ignore: { @@ -40,9 +40,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/foo/bar/aa.json', @@ -55,16 +55,16 @@ export const staticPath = { }, duplicate_json_1: '/foo/bar/duplicate.json', duplicate_json_2: '/foo/bar/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -76,18 +76,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-basepath/plugins/util/basic/$path.ts b/projects/nuxtjs-basepath/plugins/util/basic/$path.ts index 566c527..013c0e7 100644 --- a/projects/nuxtjs-basepath/plugins/util/basic/$path.ts +++ b/projects/nuxtjs-basepath/plugins/util/basic/$path.ts @@ -1,8 +1,8 @@ -import type { Plugin } from '@nuxt/types' +import type { Plugin } from '@nuxt/types'; -type Query0 = { hoge: string } +type Query0 = { hoge: string }; -type OptionalQuery1 = { hoge: string } +type OptionalQuery1 = { hoge: string }; type Query2 = { hoge: string @@ -10,7 +10,7 @@ type Query2 = { a: number b: { c: string }[] } -} +}; export const pagesPath = { _a: (a: string | number) => ({ @@ -37,15 +37,15 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -55,16 +55,16 @@ declare module '@nuxt/types' { interface Context { $pagesPath: PagesPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) -} + inject('pagesPath', pagesPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-basepath/plugins/util/ignore/$path.ts b/projects/nuxtjs-basepath/plugins/util/ignore/$path.ts index 2c9bfce..d72d4f0 100644 --- a/projects/nuxtjs-basepath/plugins/util/ignore/$path.ts +++ b/projects/nuxtjs-basepath/plugins/util/ignore/$path.ts @@ -1,8 +1,8 @@ -import type { Plugin } from '@nuxt/types' +import type { Plugin } from '@nuxt/types'; -type Query0 = { hoge: string } +type Query0 = { hoge: string }; -type OptionalQuery1 = { hoge: string } +type OptionalQuery1 = { hoge: string }; type Query2 = { hoge: string @@ -10,7 +10,7 @@ type Query2 = { a: number b: { c: string }[] } -} +}; export const pagesPath = { _a: (a: string | number) => ({ @@ -37,9 +37,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/foo/bar/aa.json', @@ -51,16 +51,16 @@ export const staticPath = { }, duplicate_json_1: '/foo/bar/duplicate.json', duplicate_json_2: '/foo/bar/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -72,18 +72,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-basepath/plugins/util/static/$path.ts b/projects/nuxtjs-basepath/plugins/util/static/$path.ts index e582764..7ed3a24 100644 --- a/projects/nuxtjs-basepath/plugins/util/static/$path.ts +++ b/projects/nuxtjs-basepath/plugins/util/static/$path.ts @@ -1,8 +1,8 @@ -import type { Plugin } from '@nuxt/types' +import type { Plugin } from '@nuxt/types'; -type Query0 = { hoge: string } +type Query0 = { hoge: string }; -type OptionalQuery1 = { hoge: string } +type OptionalQuery1 = { hoge: string }; type Query2 = { hoge: string @@ -10,7 +10,7 @@ type Query2 = { a: number b: { c: string }[] } -} +}; export const pagesPath = { _ignore: { @@ -40,9 +40,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/foo/bar/aa.json', @@ -55,16 +55,16 @@ export const staticPath = { }, duplicate_json_1: '/foo/bar/duplicate.json', duplicate_json_2: '/foo/bar/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -76,18 +76,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-no-slash/plugins/$path.ts b/projects/nuxtjs-no-slash/plugins/$path.ts index 7003069..2dda2a4 100644 --- a/projects/nuxtjs-no-slash/plugins/$path.ts +++ b/projects/nuxtjs-no-slash/plugins/$path.ts @@ -1,7 +1,7 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../pages' -import type { OptionalQuery as OptionalQuery1 } from '../pages/_pid' -import type { Query as Query2 } from '../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../pages/_pid'; +import type { Query as Query2 } from '../pages/blog/_slug'; export const pagesPath = { _ignore: { @@ -31,9 +31,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -46,16 +46,16 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -67,18 +67,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-no-slash/plugins/util/basic/$path.ts b/projects/nuxtjs-no-slash/plugins/util/basic/$path.ts index ed91851..f1a23b8 100644 --- a/projects/nuxtjs-no-slash/plugins/util/basic/$path.ts +++ b/projects/nuxtjs-no-slash/plugins/util/basic/$path.ts @@ -1,7 +1,7 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid' -import type { Query as Query2 } from '../../../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid'; +import type { Query as Query2 } from '../../../pages/blog/_slug'; export const pagesPath = { _a: (a: string | number) => ({ @@ -28,15 +28,15 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -46,16 +46,16 @@ declare module '@nuxt/types' { interface Context { $pagesPath: PagesPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) -} + inject('pagesPath', pagesPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-no-slash/plugins/util/ignore/$path.ts b/projects/nuxtjs-no-slash/plugins/util/ignore/$path.ts index 452ad6b..0bebd2a 100644 --- a/projects/nuxtjs-no-slash/plugins/util/ignore/$path.ts +++ b/projects/nuxtjs-no-slash/plugins/util/ignore/$path.ts @@ -1,7 +1,7 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid' -import type { Query as Query2 } from '../../../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid'; +import type { Query as Query2 } from '../../../pages/blog/_slug'; export const pagesPath = { _a: (a: string | number) => ({ @@ -28,9 +28,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -42,16 +42,16 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -63,18 +63,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-no-slash/plugins/util/static/$path.ts b/projects/nuxtjs-no-slash/plugins/util/static/$path.ts index 55ffd4c..3b2a524 100644 --- a/projects/nuxtjs-no-slash/plugins/util/static/$path.ts +++ b/projects/nuxtjs-no-slash/plugins/util/static/$path.ts @@ -1,7 +1,7 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid' -import type { Query as Query2 } from '../../../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid'; +import type { Query as Query2 } from '../../../pages/blog/_slug'; export const pagesPath = { _ignore: { @@ -31,9 +31,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -46,16 +46,16 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -67,18 +67,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-src/client/plugins/$path.ts b/projects/nuxtjs-src/client/plugins/$path.ts index 634c8db..061653c 100644 --- a/projects/nuxtjs-src/client/plugins/$path.ts +++ b/projects/nuxtjs-src/client/plugins/$path.ts @@ -1,7 +1,7 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../pages' -import type { OptionalQuery as OptionalQuery1 } from '../pages/_pid' -import type { Query as Query2 } from '../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../pages/_pid'; +import type { Query as Query2 } from '../pages/blog/_slug'; export const pagesPath = { _ignore: { @@ -31,9 +31,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -46,16 +46,16 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -67,18 +67,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-src/client/plugins/util/basic/$path.ts b/projects/nuxtjs-src/client/plugins/util/basic/$path.ts index f227e3d..41b7b6d 100644 --- a/projects/nuxtjs-src/client/plugins/util/basic/$path.ts +++ b/projects/nuxtjs-src/client/plugins/util/basic/$path.ts @@ -1,7 +1,7 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid' -import type { Query as Query2 } from '../../../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid'; +import type { Query as Query2 } from '../../../pages/blog/_slug'; export const pagesPath = { _a: (a: string | number) => ({ @@ -28,15 +28,15 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -46,16 +46,16 @@ declare module '@nuxt/types' { interface Context { $pagesPath: PagesPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) -} + inject('pagesPath', pagesPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-src/client/plugins/util/ignore/$path.ts b/projects/nuxtjs-src/client/plugins/util/ignore/$path.ts index 2cdcbdd..166ec4d 100644 --- a/projects/nuxtjs-src/client/plugins/util/ignore/$path.ts +++ b/projects/nuxtjs-src/client/plugins/util/ignore/$path.ts @@ -1,7 +1,7 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid' -import type { Query as Query2 } from '../../../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid'; +import type { Query as Query2 } from '../../../pages/blog/_slug'; export const pagesPath = { _a: (a: string | number) => ({ @@ -28,9 +28,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -42,16 +42,16 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -63,18 +63,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs-src/client/plugins/util/static/$path.ts b/projects/nuxtjs-src/client/plugins/util/static/$path.ts index 64b1428..d8dfcdc 100644 --- a/projects/nuxtjs-src/client/plugins/util/static/$path.ts +++ b/projects/nuxtjs-src/client/plugins/util/static/$path.ts @@ -1,7 +1,7 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../../../pages' -import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid' -import type { Query as Query2 } from '../../../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../../../pages'; +import type { OptionalQuery as OptionalQuery1 } from '../../../pages/_pid'; +import type { Query as Query2 } from '../../../pages/blog/_slug'; export const pagesPath = { _ignore: { @@ -31,9 +31,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -46,16 +46,16 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -67,18 +67,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs/plugins/$path.ts b/projects/nuxtjs/plugins/$path.ts index 91437cc..ea6652c 100644 --- a/projects/nuxtjs/plugins/$path.ts +++ b/projects/nuxtjs/plugins/$path.ts @@ -1,8 +1,8 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../pages' -import type { Query as Query2 } from '../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../pages'; +import type { Query as Query2 } from '../pages/blog/_slug'; -type OptionalQuery1 = { hoge: string } +type OptionalQuery1 = { hoge: string }; export const pagesPath = { _ignore: { @@ -32,9 +32,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -47,16 +47,16 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -68,18 +68,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs/plugins/util/basic/$path.ts b/projects/nuxtjs/plugins/util/basic/$path.ts index a31bbd4..543ae20 100644 --- a/projects/nuxtjs/plugins/util/basic/$path.ts +++ b/projects/nuxtjs/plugins/util/basic/$path.ts @@ -1,8 +1,8 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../../../pages' -import type { Query as Query2 } from '../../../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../../../pages'; +import type { Query as Query2 } from '../../../pages/blog/_slug'; -type OptionalQuery1 = { hoge: string } +type OptionalQuery1 = { hoge: string }; export const pagesPath = { _a: (a: string | number) => ({ @@ -29,15 +29,15 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -47,16 +47,16 @@ declare module '@nuxt/types' { interface Context { $pagesPath: PagesPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) -} + inject('pagesPath', pagesPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs/plugins/util/ignore/$path.ts b/projects/nuxtjs/plugins/util/ignore/$path.ts index 6b7f1ed..0b9a872 100644 --- a/projects/nuxtjs/plugins/util/ignore/$path.ts +++ b/projects/nuxtjs/plugins/util/ignore/$path.ts @@ -1,8 +1,8 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../../../pages' -import type { Query as Query2 } from '../../../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../../../pages'; +import type { Query as Query2 } from '../../../pages/blog/_slug'; -type OptionalQuery1 = { hoge: string } +type OptionalQuery1 = { hoge: string }; export const pagesPath = { _a: (a: string | number) => ({ @@ -29,9 +29,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -43,16 +43,16 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -64,18 +64,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/nuxtjs/plugins/util/static/$path.ts b/projects/nuxtjs/plugins/util/static/$path.ts index ae8c010..35c0202 100644 --- a/projects/nuxtjs/plugins/util/static/$path.ts +++ b/projects/nuxtjs/plugins/util/static/$path.ts @@ -1,8 +1,8 @@ -import type { Plugin } from '@nuxt/types' -import type { Query as Query0 } from '../../../pages' -import type { Query as Query2 } from '../../../pages/blog/_slug' +import type { Plugin } from '@nuxt/types'; +import type { Query as Query0 } from '../../../pages'; +import type { Query as Query2 } from '../../../pages/blog/_slug'; -type OptionalQuery1 = { hoge: string } +type OptionalQuery1 = { hoge: string }; export const pagesPath = { _ignore: { @@ -32,9 +32,9 @@ export const pagesPath = { }) }, $url: (url: { query: Query0, hash?: string | undefined }) => ({ path: '/', query: url.query as any, hash: url.hash }) -} +}; -export type PagesPath = typeof pagesPath +export type PagesPath = typeof pagesPath; export const staticPath = { aa_json: '/aa.json', @@ -47,16 +47,16 @@ export const staticPath = { }, duplicate_json_1: '/duplicate.json', duplicate_json_2: '/duplicate_json' -} as const +} as const; -export type StaticPath = typeof staticPath +export type StaticPath = typeof staticPath; declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -68,18 +68,18 @@ declare module '@nuxt/types' { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath $staticPath: StaticPath } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath) - inject('staticPath', staticPath) -} + inject('pagesPath', pagesPath); + inject('staticPath', staticPath); +}; -export default pathPlugin +export default pathPlugin; diff --git a/projects/projects.ts b/projects/projects.ts index 8d46cb4..3330780 100644 --- a/projects/projects.ts +++ b/projects/projects.ts @@ -14,11 +14,11 @@ export const projects = [ ( project ): { - dir: string - output: string | undefined - enableStatic: boolean - ignorePath: string | undefined - nodeVer: number + dir: string; + output: string | undefined; + enableStatic: boolean; + ignorePath: string | undefined; + nodeVer: number; }[] => [ { ...project, output: undefined, enableStatic: true, ignorePath: undefined }, { @@ -40,4 +40,4 @@ export const projects = [ ignorePath: '.pathpidaignore' } ] -) +); diff --git a/src/buildTemplate.ts b/src/buildTemplate.ts index b09d13c..9a8760d 100644 --- a/src/buildTemplate.ts +++ b/src/buildTemplate.ts @@ -1,16 +1,16 @@ -import path from 'path' -import { createNuxtTemplate } from './createNuxtTemplate' -import { createStaticTemplate } from './createStaticTemplate' -import type { Config } from './getConfig' -import { createNextTemplate } from './nextjs/createNextTemplate' +import path from 'path'; +import { createNuxtTemplate } from './createNuxtTemplate'; +import { createStaticTemplate } from './createStaticTemplate'; +import type { Config } from './getConfig'; +import { createNextTemplate } from './nextjs/createNextTemplate'; -let prevPagesText = '' -let prevStaticText = '' +let prevPagesText = ''; +let prevStaticText = ''; export const resetCache = () => { - prevPagesText = '' - prevStaticText = '' -} + prevPagesText = ''; + prevStaticText = ''; +}; export default ( { @@ -26,35 +26,35 @@ export default ( }: Config, mode?: 'pages' | 'static' ) => { - const emptyPathRegExp = /\n.+{\n+ +}.*/ + const emptyPathRegExp = /\n.+{\n+ +}.*/; if (mode !== 'static') { - let text = '' + let text = ''; switch (type) { case 'nextjs': - text = createNextTemplate(input, output, ignorePath, appDir, pageExtensions) - break + text = createNextTemplate(input, output, ignorePath, appDir, pageExtensions); + break; case 'nuxtjs': - text = createNuxtTemplate(input, output, ignorePath, trailingSlash) - break + text = createNuxtTemplate(input, output, ignorePath, trailingSlash); + break; } while (emptyPathRegExp.test(text)) { - text = text.replace(emptyPathRegExp, '') + text = text.replace(emptyPathRegExp, ''); } - prevPagesText = text + prevPagesText = text; } if (staticDir && mode !== 'pages') { - let text = createStaticTemplate(staticDir, basepath, ignorePath) + let text = createStaticTemplate(staticDir, basepath, ignorePath); while (emptyPathRegExp.test(text)) { - text = text.replace(emptyPathRegExp, '') + text = text.replace(emptyPathRegExp, ''); } - prevStaticText = text + prevStaticText = text; } return { @@ -65,7 +65,7 @@ declare module 'vue/types/vue' { interface Vue { $pagesPath: PagesPath${prevStaticText ? '\n $staticPath: StaticPath' : ''} } -} +}; declare module '@nuxt/types' { interface NuxtAppOptions { @@ -75,22 +75,22 @@ declare module '@nuxt/types' { interface Context { $pagesPath: PagesPath${prevStaticText ? '\n $staticPath: StaticPath' : ''} } -} +}; declare module 'vuex/types/index' { interface Store { $pagesPath: PagesPath${prevStaticText ? '\n $staticPath: StaticPath' : ''} } -} +}; const pathPlugin: Plugin = (_, inject) => { - inject('pagesPath', pagesPath)${prevStaticText ? "\n inject('staticPath', staticPath)" : ''} -} + inject('pagesPath', pagesPath);${prevStaticText ? "\n inject('staticPath', staticPath);" : ''} +}; -export default pathPlugin +export default pathPlugin; ` : '' }`, filePath: path.posix.join(output, '$path.ts') - } -} + }; +}; diff --git a/src/cli.ts b/src/cli.ts index 9047ac6..2b6dfff 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,14 +1,14 @@ -import minimist from 'minimist' -import build from './buildTemplate' -import getConfig from './getConfig' -import watch from './watchInputDir' -import write from './writeRouteFile' +import minimist from 'minimist'; +import build from './buildTemplate'; +import getConfig from './getConfig'; +import watch from './watchInputDir'; +import write from './writeRouteFile'; export const run = async (args: string[]) => { const argv = minimist(args, { string: ['version', 'watch', 'enableStatic', 'output', 'ignorePath'], alias: { v: 'version', w: 'watch', s: 'enableStatic', o: 'output', p: 'ignorePath' } - }) + }); argv.version !== undefined ? console.log(`v${require('../package.json').version}`) @@ -18,17 +18,17 @@ export const run = async (args: string[]) => { argv.enableStatic !== undefined, argv.output, argv.ignorePath - ) - write(build(config)) + ); + write(build(config)); if (config.type === 'nextjs') { - config.input && watch(config.input, () => write(build(config, 'pages'))) - config.appDir && watch(config.appDir.input, () => write(build(config, 'pages'))) + config.input && watch(config.input, () => write(build(config, 'pages'))); + config.appDir && watch(config.appDir.input, () => write(build(config, 'pages'))); } else { - watch(config.input, () => write(build(config, 'pages'))) + watch(config.input, () => write(build(config, 'pages'))); } - config.staticDir && watch(config.staticDir, () => write(build(config, 'static'))) + config.staticDir && watch(config.staticDir, () => write(build(config, 'static'))); })() - : write(build(await getConfig(argv.enableStatic !== undefined, argv.output, argv.ignorePath))) -} + : write(build(await getConfig(argv.enableStatic !== undefined, argv.output, argv.ignorePath))); +}; diff --git a/src/createNuxtTemplate.ts b/src/createNuxtTemplate.ts index 932f4df..67ae597 100644 --- a/src/createNuxtTemplate.ts +++ b/src/createNuxtTemplate.ts @@ -1,8 +1,8 @@ -import fs from 'fs' -import path from 'path' -import { createIg, isIgnored } from './isIgnored' -import { parseQueryFromTS } from './parseQueryFromTS' -import { replaceWithUnderscore } from './replaceWithUnderscore' +import fs from 'fs'; +import path from 'path'; +import { createIg, isIgnored } from './isIgnored'; +import { parseQueryFromTS } from './parseQueryFromTS'; +import { replaceWithUnderscore } from './replaceWithUnderscore'; const createMethods = ( indent: string, @@ -19,41 +19,41 @@ const createMethods = ( trailingSlash || pathname === '' ? '/' : '' }${/\${/.test(pathname) ? '`' : "'"}${ importName ? `, query: url${importName.startsWith('Query') ? '' : '?'}.query as any` : '' - }, hash: url${importName?.startsWith('Query') ? '' : '?'}.hash })` + }, hash: url${importName?.startsWith('Query') ? '' : '?'}.hash })`; const parseQueryFromVue = (file: string, suffix: number) => { - const fileData = fs.readFileSync(file, 'utf8') + const fileData = fs.readFileSync(file, 'utf8'); const typeName = ['Query', 'OptionalQuery'].find(type => new RegExp(`export (interface ${type} ?{|type ${type} ?= ?{)`).test(fileData) - ) + ); - if (!typeName) return + if (!typeName) return; - const queryRegExp = new RegExp(`export (interface ${typeName} ?{|type ${typeName} ?= ?{)`) - const [, typeText, targetText] = fileData.split(queryRegExp) - const { length } = targetText - let cursor = 0 - let depth = 1 + const queryRegExp = new RegExp(`export (interface ${typeName} ?{|type ${typeName} ?= ?{)`); + const [, typeText, targetText] = fileData.split(queryRegExp); + const { length } = targetText; + let cursor = 0; + let depth = 1; while (depth && cursor <= length) { if (targetText[cursor] === '}') { - depth -= 1 + depth -= 1; } else if (targetText[cursor] === '{') { - depth += 1 + depth += 1; } - cursor += 1 + cursor += 1; } - const importName = `${typeName}${suffix}` + const importName = `${typeName}${suffix}`; return { importName, importString: `${typeText.replace(typeName, importName)}${targetText .slice(0, cursor) - .replace(/\r/g, '')}\n` - } -} + .replace(/\r/g, '')};\n` + }; +}; export const createNuxtTemplate = ( input: string, @@ -61,18 +61,18 @@ export const createNuxtTemplate = ( ignorePath: string | undefined, trailingSlash = false ) => { - const ig = createIg(ignorePath) - const imports: string[] = [] + const ig = createIg(ignorePath); + const imports: string[] = []; const getImportName = (file: string) => { const result = path.extname(file).startsWith('.ts') ? parseQueryFromTS(output, file, imports.length) - : parseQueryFromVue(file, imports.length) + : parseQueryFromVue(file, imports.length); if (result) { - imports.push(result.importString) - return result.importName + imports.push(result.importString); + return result.importName; } - } + }; const createPathObjString = ( targetDir: string, @@ -82,7 +82,7 @@ export const createNuxtTemplate = ( text: string, methodsOfIndexTsFile?: string ) => { - indent += ' ' + indent += ' '; const props: string[] = fs .readdirSync(targetDir) @@ -96,32 +96,32 @@ export const createNuxtTemplate = ( ) .sort() .map((file, _, arr) => { - const basename = path.basename(file, path.extname(file)) - let valFn = `${indent}${replaceWithUnderscore(basename)}: {\n<% next %>\n${indent}}` - let newUrl = `${url}/${basename}` + const basename = path.basename(file, path.extname(file)); + let valFn = `${indent}${replaceWithUnderscore(basename)}: {\n<% next %>\n${indent}}`; + let newUrl = `${url}/${basename}`; if (basename.startsWith('_')) { - const slug = basename.slice(1) - const isPassValNullable = basename !== file + const slug = basename.slice(1); + const isPassValNullable = basename !== file; valFn = `${indent}_${slug}: (${slug}${isPassValNullable ? '?' : ''}: string | number${ isPassValNullable ? ' | undefined' : '' - }) => ({\n<% next %>\n${indent}})` + }) => ({\n<% next %>\n${indent}})`; newUrl = `${url}${ isPassValNullable ? `\${${slug} !== undefined ? \`/\${${slug}}\` : ''}` : `/\${${slug}}` - }` + }`; } - const target = path.posix.join(targetDir, file) + const target = path.posix.join(targetDir, file); if (fs.statSync(target).isFile() && basename !== 'index' && !arr.includes(basename)) { return valFn.replace( '<% next %>', createMethods(indent, getImportName(target), newUrl, trailingSlash) - ) + ); } else if (fs.statSync(target).isDirectory()) { const indexFile = fs .readdirSync(target) - .find(name => path.basename(name, path.extname(name)) === 'index') + .find(name => path.basename(name, path.extname(name)) === 'index'); return createPathObjString( target, @@ -136,26 +136,26 @@ export const createNuxtTemplate = ( newUrl, trailingSlash ) - ) + ); } - return '' + return ''; }) - .filter(Boolean) + .filter(Boolean); return text.replace( '<% props %>', `${props.join(',\n')}${ methodsOfIndexTsFile ? `${props.length ? ',\n' : ''}${methodsOfIndexTsFile}` : '' }` - ) - } + ); + }; const rootIndexFile = fs .readdirSync(input) - .find(name => path.basename(name, path.extname(name)) === 'index') - const rootIndent = '' - let rootMethods + .find(name => path.basename(name, path.extname(name)) === 'index'); + const rootIndent = ''; + let rootMethods; if (rootIndexFile) { rootMethods = createMethods( @@ -163,17 +163,17 @@ export const createNuxtTemplate = ( getImportName(path.posix.join(input, rootIndexFile)), '', trailingSlash - ) + ); } - const text = createPathObjString(input, '.', rootIndent, '', '{\n<% props %>\n}', rootMethods) - const importsText = imports.filter(i => i.startsWith('import')).join('\n') - const queriesText = imports.filter(i => !i.startsWith('import')).join('\n') + const text = createPathObjString(input, '.', rootIndent, '', '{\n<% props %>\n}', rootMethods); + const importsText = imports.filter(i => i.startsWith('import')).join('\n'); + const queriesText = imports.filter(i => !i.startsWith('import')).join('\n'); - return `import type { Plugin } from '@nuxt/types' + return `import type { Plugin } from '@nuxt/types'; ${importsText}${importsText && queriesText ? '\n' : ''} ${queriesText}${ imports.length ? '\n' : '' - }export const pagesPath = ${text}\n\nexport type PagesPath = typeof pagesPath -` -} + }export const pagesPath = ${text};\n\nexport type PagesPath = typeof pagesPath; +`; +}; diff --git a/src/createStaticTemplate.ts b/src/createStaticTemplate.ts index f589f93..113d85c 100644 --- a/src/createStaticTemplate.ts +++ b/src/createStaticTemplate.ts @@ -1,36 +1,36 @@ -import fs from 'fs' -import path from 'path' -import { createIg, isIgnored } from './isIgnored' -import { replaceWithUnderscore } from './replaceWithUnderscore' +import fs from 'fs'; +import path from 'path'; +import { createIg, isIgnored } from './isIgnored'; +import { replaceWithUnderscore } from './replaceWithUnderscore'; export const createStaticTemplate = ( input: string, basepath: string | undefined, ignorePath: string | undefined ) => { - const ig = createIg(ignorePath) + const ig = createIg(ignorePath); const createPublicString = (targetDir: string, indent: string, url: string, text: string) => { - indent += ' ' + indent += ' '; - const files = fs.readdirSync(targetDir).sort() - const replacedFiles = files.map(replaceWithUnderscore) + const files = fs.readdirSync(targetDir).sort(); + const replacedFiles = files.map(replaceWithUnderscore); const duplicatedInfo = replacedFiles.reduce>( (a, b, i) => ({ ...a, [b]: [...(a[b] ?? []), i] }), {} - ) + ); const props: string[] = files .map((file, i) => { - const newUrl = `${url}/${file}` - const target = path.posix.join(targetDir, file) + const newUrl = `${url}/${file}`; + const target = path.posix.join(targetDir, file); - if (isIgnored(ig, ignorePath, targetDir, file)) return '' + if (isIgnored(ig, ignorePath, targetDir, file)) return ''; - const replacedFile = replacedFiles[i] + const replacedFile = replacedFiles[i]; const valFn = `${indent}${ duplicatedInfo[replacedFile].length > 1 ? `${replacedFile}_${duplicatedInfo[replacedFile].indexOf(i)}` : replacedFile - }: <% next %>` + }: <% next %>`; return fs.statSync(target).isFile() ? valFn.replace('<% next %>', `'${newUrl}'`) @@ -41,19 +41,19 @@ export const createStaticTemplate = ( newUrl, valFn.replace('<% next %>', `{\n<% props %>\n${indent}}`) ) - : '' + : ''; }) - .filter(Boolean) + .filter(Boolean); - return text.replace('<% props %>', props.join(',\n')) - } + return text.replace('<% props %>', props.join(',\n')); + }; const text = createPublicString( input, '', typeof basepath === 'string' ? basepath.replace(/\/+$/, '') : '', - '{\n<% props %>\n} as const' - ) + '{\n<% props %>\n} as const;' + ); - return `\nexport const staticPath = ${text}\n\nexport type StaticPath = typeof staticPath\n` -} + return `\nexport const staticPath = ${text}\n\nexport type StaticPath = typeof staticPath;\n`; +}; diff --git a/src/getConfig.ts b/src/getConfig.ts index 4f8d0a5..27f4697 100644 --- a/src/getConfig.ts +++ b/src/getConfig.ts @@ -1,25 +1,25 @@ -import fs from 'fs' +import fs from 'fs'; // import type { NextConfig } from 'next/dist/server/config' -import path from 'path' +import path from 'path'; export type Config = ( | { type: 'nextjs'; input: string | undefined; appDir: { input: string } | undefined } | { type: 'nuxtjs'; input: string; appDir?: undefined } ) & { - staticDir: string | undefined - output: string - ignorePath: string | undefined - trailingSlash?: boolean | undefined - basepath?: string | undefined - pageExtensions?: string[] | undefined -} + staticDir: string | undefined; + output: string; + ignorePath: string | undefined; + trailingSlash?: boolean | undefined; + basepath?: string | undefined; + pageExtensions?: string[] | undefined; +}; const getFrameworkType = (dir: string) => { - const packageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')) - const deps = Object.assign(packageJson.devDependencies ?? {}, packageJson.dependencies ?? {}) + const packageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')); + const deps = Object.assign(packageJson.devDependencies ?? {}, packageJson.dependencies ?? {}); - return deps.nuxt ? 'nuxtjs' : 'nextjs' -} + return deps.nuxt ? 'nuxtjs' : 'nextjs'; +}; export default async ( enableStatic: boolean, @@ -27,42 +27,42 @@ export default async ( igPath: string | undefined, dir = process.cwd() ): Promise => { - const type = getFrameworkType(dir) - const ignorePath = igPath && path.join(dir, igPath) + const type = getFrameworkType(dir); + const ignorePath = igPath && path.join(dir, igPath); if (type === 'nextjs') { - let config /*: NextConfig */ + let config; /*: NextConfig */ try { // >= v11.1.0 config = await require('next/dist/server/config').default( require('next/constants').PHASE_PRODUCTION_BUILD, dir - ) + ); } catch (e) { // < v11.1.0 config = await require('next/dist/next-server/server/config').default( require('next/constants').PHASE_PRODUCTION_BUILD, dir - ) + ); } const srcDir = fs.existsSync(path.posix.join(dir, 'src/pages')) || fs.existsSync(path.posix.join(dir, 'src/app')) ? path.posix.join(dir, 'src') - : dir + : dir; - const isAppDirUsed = fs.existsSync(path.posix.join(srcDir, 'app')) + const isAppDirUsed = fs.existsSync(path.posix.join(srcDir, 'app')); if (!output) { - const utilsPath = path.join(srcDir, 'utils') - output = fs.existsSync(utilsPath) ? utilsPath : path.join(srcDir, 'lib') + const utilsPath = path.join(srcDir, 'utils'); + output = fs.existsSync(utilsPath) ? utilsPath : path.join(srcDir, 'lib'); } - if (!fs.existsSync(output)) fs.mkdirSync(output) + if (!fs.existsSync(output)) fs.mkdirSync(output); - const inputDir = path.posix.join(srcDir, 'pages') + const inputDir = path.posix.join(srcDir, 'pages'); return { type, @@ -73,18 +73,18 @@ export default async ( appDir: isAppDirUsed ? { input: path.posix.join(srcDir, 'app') } : undefined, pageExtensions: config.pageExtensions, basepath: config.basePath - } + }; } else { - const nuxttsPath = path.join(dir, 'nuxt.config.ts') + const nuxttsPath = path.join(dir, 'nuxt.config.ts'); const config = await require('@nuxt/config').loadNuxtConfig({ rootDir: dir, configFile: fs.existsSync(nuxttsPath) ? nuxttsPath : undefined - }) - const srcDir = path.posix.join(dir, config.srcDir ?? '') + }); + const srcDir = path.posix.join(dir, config.srcDir ?? ''); - output = output ?? path.posix.join(srcDir, 'plugins') + output = output ?? path.posix.join(srcDir, 'plugins'); - if (!fs.existsSync(output)) fs.mkdirSync(output) + if (!fs.existsSync(output)) fs.mkdirSync(output); return { type, @@ -94,6 +94,6 @@ export default async ( ignorePath, trailingSlash: config.router?.trailingSlash, basepath: config.router?.base - } + }; } -} +}; diff --git a/src/isIgnored.ts b/src/isIgnored.ts index 7bbe203..1e12a7c 100644 --- a/src/isIgnored.ts +++ b/src/isIgnored.ts @@ -1,9 +1,9 @@ -import fs from 'fs' -import ignore, { Ignore } from 'ignore' -import path from 'path' +import fs from 'fs'; +import ignore, { Ignore } from 'ignore'; +import path from 'path'; export const createIg = (ignorePath: string | undefined) => - ignorePath === undefined ? undefined : ignore().add(fs.readFileSync(ignorePath).toString()) + ignorePath === undefined ? undefined : ignore().add(fs.readFileSync(ignorePath).toString()); export const isIgnored = ( ig: Ignore | undefined, @@ -16,4 +16,4 @@ export const isIgnored = ( (ignorePath ?? '').replace(path.basename(ignorePath ?? ''), ''), path.posix.join(targetDir, file) ) - ) + ); diff --git a/src/nextjs/createNextTemplate.ts b/src/nextjs/createNextTemplate.ts index bdf73cd..07c7f1b 100644 --- a/src/nextjs/createNextTemplate.ts +++ b/src/nextjs/createNextTemplate.ts @@ -1,5 +1,5 @@ -import { parseAppDir } from './parseAppDir' -import { parsePagesDir } from './parsePagesDir' +import { parseAppDir } from './parseAppDir'; +import { parsePagesDir } from './parsePagesDir'; export const createNextTemplate = ( input: string | undefined, @@ -10,24 +10,28 @@ export const createNextTemplate = ( ): string => { const appDirData = appDir ? parseAppDir(appDir.input, output, ignorePath) - : { imports: [], text: '' } + : { imports: [], text: '' }; const pagesDir = input ? parsePagesDir(input, output, ignorePath, pageExtensions, appDirData.imports.length) - : { imports: [], text: '' } - const imports = [...appDirData.imports, ...pagesDir.imports] + : { imports: [], text: '' }; + const imports = [...appDirData.imports, ...pagesDir.imports]; return `${imports.join('\n')}${imports.length ? '\n\n' : ''}${ appDir ? `const buildSuffix = (url?: {query?: Record, hash?: string}) => { - const query = url?.query - const hash = url?.hash - if (!query && !hash) return '' - const search = query ? \`?\${new URLSearchParams(query)}\` : '' - return \`\${search}\${hash ? \`#\${hash}\` : ''}\` -}\n\n` - : '' - }export const pagesPath = {\n${appDirData.text}${appDirData.text && pagesDir.text ? ',\n' : ''}${ - pagesDir.text - }\n}\n\nexport type PagesPath = typeof pagesPath + const query = url?.query; + const hash = url?.hash; + if (!query && !hash) return ''; + const search = query ? \`?\${new URLSearchParams(query)}\` : ''; + return \`\${search}\${hash ? \`#\${hash}\` : ''}\`; +}; + ` -} + : '' + }export const pagesPath = { +${appDirData.text}${appDirData.text && pagesDir.text ? ',\n' : ''}${pagesDir.text} +}; + +export type PagesPath = typeof pagesPath; +`; +}; diff --git a/src/nextjs/parseAppDir.ts b/src/nextjs/parseAppDir.ts index 34088e7..9d8a891 100644 --- a/src/nextjs/parseAppDir.ts +++ b/src/nextjs/parseAppDir.ts @@ -1,9 +1,9 @@ -import fs from 'fs' -import path from 'path' -import { createIg, isIgnored } from '../isIgnored' -import { parseQueryFromTS } from '../parseQueryFromTS' -import { replaceWithUnderscore } from '../replaceWithUnderscore' -import { Slugs } from './parsePagesDir' +import fs from 'fs'; +import path from 'path'; +import { createIg, isIgnored } from '../isIgnored'; +import { parseQueryFromTS } from '../parseQueryFromTS'; +import { replaceWithUnderscore } from '../replaceWithUnderscore'; +import { Slugs } from './parsePagesDir'; export const createMethods = ( indent: string, @@ -23,24 +23,24 @@ export const createMethods = ( : '' }, hash: url${importName?.startsWith('Query') ? '' : '?'}.hash, path: \`${pathname .replace(/\[\[?\.\.\.(.*?)\]\]?/g, `\${$1?.join('/')}`) - .replace(/\[(.*?)\]/g, `\${$1}`)}\${buildSuffix(url)}\` })` + .replace(/\[(.*?)\]/g, `\${$1}`)}\${buildSuffix(url)}\` })`; export const parseAppDir = ( input: string, output: string, ignorePath: string | undefined ): { imports: string[]; text: string } => { - const ig = createIg(ignorePath) - const pageFileNames = ['page.tsx', 'page.jsx', 'page.js'] - const imports: string[] = [] + const ig = createIg(ignorePath); + const pageFileNames = ['page.tsx', 'page.jsx', 'page.js']; + const imports: string[] = []; const getImportName = (file: string) => { - const result = parseQueryFromTS(output, file, imports.length) + const result = parseQueryFromTS(output, file, imports.length); if (result) { - imports.push(result.importString) - return result.importName + imports.push(result.importString); + return result.importName; } - } + }; const createPathObjString = ( targetDir: string, @@ -50,7 +50,7 @@ export const parseAppDir = ( text: string, methodsOfIndexTsFile?: string ) => { - indent += ' ' + indent += ' '; const props: string[] = fs .readdirSync(targetDir) @@ -62,26 +62,26 @@ export const parseAppDir = ( ) .sort() .map(file => { - const newSlugs = [...slugs] - const target = path.posix.join(targetDir, file) + const newSlugs = [...slugs]; + const target = path.posix.join(targetDir, file); if (file.startsWith('(') && file.endsWith(')')) { - return createPathObjString(target, indent.slice(2), url, newSlugs, '<% props %>') + return createPathObjString(target, indent.slice(2), url, newSlugs, '<% props %>'); } - const newUrl = `${url}/${file}` + const newUrl = `${url}/${file}`; let valFn = `${indent}${JSON.stringify( replaceWithUnderscore(file) - )}: {\n<% next %>\n${indent}}` + )}: {\n<% next %>\n${indent}}`; if (file.startsWith('[') && file.endsWith(']')) { - const slug = file.replace(/[.[\]]/g, '') + const slug = file.replace(/[.[\]]/g, ''); valFn = `${indent}${`_${slug}`}: (${slug}${file.startsWith('[[') ? '?' : ''}: ${ /\[\./.test(file) ? 'string[]' : 'string | number' - }) => ({\n<% next %>\n${indent}})` - newSlugs.push(slug) + }) => ({\n<% next %>\n${indent}})`; + newSlugs.push(slug); } - const indexFile = fs.readdirSync(target).find(name => pageFileNames.includes(name)) + const indexFile = fs.readdirSync(target).find(name => pageFileNames.includes(name)); return createPathObjString( target, @@ -96,41 +96,41 @@ export const parseAppDir = ( newSlugs, newUrl ) - ) + ); }) - .filter(Boolean) + .filter(Boolean); const joinedProps = props .reduce((accumulator, current) => { - const last = accumulator[accumulator.length - 1] + const last = accumulator[accumulator.length - 1]; if (last !== undefined) { - const [a, ...b] = last.split('\n') - const [x, ...y] = current.split('\n') + const [a, ...b] = last.split('\n'); + const [x, ...y] = current.split('\n'); if (a === x) { - y.pop() - const z = y.pop() - const merged = [a, ...y, `${z},`, ...b].join('\n') - return [...accumulator.slice(0, -1), merged] + y.pop(); + const z = y.pop(); + const merged = [a, ...y, `${z},`, ...b].join('\n'); + return [...accumulator.slice(0, -1), merged]; } } - return [...accumulator, current] + return [...accumulator, current]; }, []) - .join(',\n') + .join(',\n'); return text.replace( '<% props %>', `${joinedProps}${ methodsOfIndexTsFile ? `${props.length ? ',\n' : ''}${methodsOfIndexTsFile}` : '' }` - ) - } + ); + }; - const rootIndexFile = fs.readdirSync(input).find(name => pageFileNames.includes(name)) - const rootIndent = '' - let rootMethods + const rootIndexFile = fs.readdirSync(input).find(name => pageFileNames.includes(name)); + const rootIndent = ''; + let rootMethods; if (rootIndexFile) { rootMethods = createMethods( @@ -138,10 +138,10 @@ export const parseAppDir = ( getImportName(path.posix.join(input, rootIndexFile)), [], '/' - ) + ); } - const text = createPathObjString(input, rootIndent, '', [], '<% props %>', rootMethods) + const text = createPathObjString(input, rootIndent, '', [], '<% props %>', rootMethods); // console.log({ input, rootIndent, rootMethods, text }) - return { imports, text } -} + return { imports, text }; +}; diff --git a/src/nextjs/parsePagesDir.ts b/src/nextjs/parsePagesDir.ts index b6a7cdc..5afa193 100644 --- a/src/nextjs/parsePagesDir.ts +++ b/src/nextjs/parsePagesDir.ts @@ -1,10 +1,10 @@ -import fs from 'fs' -import path from 'path' -import { createIg, isIgnored } from '../isIgnored' -import { parseQueryFromTS } from '../parseQueryFromTS' -import { replaceWithUnderscore } from '../replaceWithUnderscore' +import fs from 'fs'; +import path from 'path'; +import { createIg, isIgnored } from '../isIgnored'; +import { parseQueryFromTS } from '../parseQueryFromTS'; +import { replaceWithUnderscore } from '../replaceWithUnderscore'; -export type Slugs = string[] +export type Slugs = string[]; export const createMethods = ( indent: string, @@ -25,7 +25,7 @@ export const createMethods = ( : importName ? `, query: url${importName.startsWith('Query') ? '' : '?'}.query` : '' - }, hash: url${importName?.startsWith('Query') ? '' : '?'}.hash })` + }, hash: url${importName?.startsWith('Query') ? '' : '?'}.hash })`; export const parsePagesDir = ( input: string, @@ -34,19 +34,19 @@ export const parsePagesDir = ( pageExtensions = ['tsx', 'ts', 'jsx', 'js'], appDirQueryLength: number ): { imports: string[]; text: string } => { - const ig = createIg(ignorePath) - const regExpChunk = `\\.(${pageExtensions.join('|').replace(/\./g, '\\.')})$` - const indexPageRegExp = new RegExp(`^index${regExpChunk}`) - const pageExtRegExp = new RegExp(regExpChunk) - const imports: string[] = [] + const ig = createIg(ignorePath); + const regExpChunk = `\\.(${pageExtensions.join('|').replace(/\./g, '\\.')})$`; + const indexPageRegExp = new RegExp(`^index${regExpChunk}`); + const pageExtRegExp = new RegExp(regExpChunk); + const imports: string[] = []; const getImportName = (file: string) => { - const result = parseQueryFromTS(output, file, appDirQueryLength + imports.length) + const result = parseQueryFromTS(output, file, appDirQueryLength + imports.length); if (result) { - imports.push(result.importString) - return result.importName + imports.push(result.importString); + return result.importName; } - } + }; const createPathObjString = ( targetDir: string, @@ -56,7 +56,7 @@ export const parsePagesDir = ( text: string, methodsOfIndexTsFile?: string ) => { - indent += ' ' + indent += ' '; const props: string[] = fs .readdirSync(targetDir) @@ -71,33 +71,33 @@ export const parsePagesDir = ( ) .sort() .map(file => { - const newSlugs = [...slugs] - const basename = file.replace(pageExtRegExp, '') - const newUrl = `${url}/${basename}` + const newSlugs = [...slugs]; + const basename = file.replace(pageExtRegExp, ''); + const newUrl = `${url}/${basename}`; let valFn = `${indent}${JSON.stringify( replaceWithUnderscore(basename) - )}: {\n<% next %>\n${indent}}` + )}: {\n<% next %>\n${indent}}`; if (basename.startsWith('[') && basename.endsWith(']')) { - const slug = basename.replace(/[.[\]]/g, '') - const opt = basename.startsWith('[[') + const slug = basename.replace(/[.[\]]/g, ''); + const opt = basename.startsWith('[['); valFn = `${indent}${`_${slug}`}: (${slug}${opt ? '?' : ''}: ${ /\[\./.test(basename) ? `string[]${opt ? ' | undefined' : ''}` : `string | number${opt ? ' | undefined' : ''}` - }) => ({\n<% next %>\n${indent}})` - newSlugs.push(slug) + }) => ({\n<% next %>\n${indent}})`; + newSlugs.push(slug); } - const target = path.posix.join(targetDir, file) + const target = path.posix.join(targetDir, file); if (fs.statSync(target).isFile() && basename !== 'index') { return valFn.replace( '<% next %>', createMethods(indent, getImportName(target), newSlugs, newUrl) - ) + ); } else if (fs.statSync(target).isDirectory()) { - const indexFile = fs.readdirSync(target).find(name => indexPageRegExp.test(name)) + const indexFile = fs.readdirSync(target).find(name => indexPageRegExp.test(name)); return createPathObjString( target, @@ -112,44 +112,44 @@ export const parsePagesDir = ( newSlugs, newUrl ) - ) + ); } - return '' + return ''; }) - .filter(Boolean) + .filter(Boolean); const joinedProps = props .reduce((accumulator, current) => { - const last = accumulator[accumulator.length - 1] + const last = accumulator[accumulator.length - 1]; if (last !== undefined) { - const [a, ...b] = last.split('\n') - const [x, ...y] = current.split('\n') + const [a, ...b] = last.split('\n'); + const [x, ...y] = current.split('\n'); if (a === x) { - y.pop() - const z = y.pop() - const merged = [a, ...y, `${z},`, ...b].join('\n') - return [...accumulator.slice(0, -1), merged] + y.pop(); + const z = y.pop(); + const merged = [a, ...y, `${z},`, ...b].join('\n'); + return [...accumulator.slice(0, -1), merged]; } } - return [...accumulator, current] + return [...accumulator, current]; }, []) - .join(',\n') + .join(',\n'); return text.replace( '<% props %>', `${joinedProps}${ methodsOfIndexTsFile ? `${props.length ? ',\n' : ''}${methodsOfIndexTsFile}` : '' }` - ) - } + ); + }; - const rootIndexFile = fs.readdirSync(input).find(name => indexPageRegExp.test(name)) - const rootIndent = '' - let rootMethods + const rootIndexFile = fs.readdirSync(input).find(name => indexPageRegExp.test(name)); + const rootIndent = ''; + let rootMethods; if (rootIndexFile) { rootMethods = createMethods( @@ -157,10 +157,10 @@ export const parsePagesDir = ( getImportName(path.posix.join(input, rootIndexFile)), [], '/' - ) + ); } - const text = createPathObjString(input, rootIndent, '', [], '<% props %>', rootMethods) + const text = createPathObjString(input, rootIndent, '', [], '<% props %>', rootMethods); - return { imports, text } -} + return { imports, text }; +}; diff --git a/src/parseQueryFromTS.ts b/src/parseQueryFromTS.ts index 87be970..9aca3c5 100644 --- a/src/parseQueryFromTS.ts +++ b/src/parseQueryFromTS.ts @@ -1,21 +1,21 @@ -import fs from 'fs' -import path from 'path' +import fs from 'fs'; +import path from 'path'; export const parseQueryFromTS = (output: string, file: string, suffix: number) => { - const fileData = fs.readFileSync(file, 'utf8') + const fileData = fs.readFileSync(file, 'utf8'); const typeName = ['Query', 'OptionalQuery'].find(type => new RegExp(`export (interface ${type} ?{|type ${type} ?=)`).test(fileData) - ) + ); - if (!typeName) return + if (!typeName) return; - const importName = `${typeName}${suffix}` + const importName = `${typeName}${suffix}`; return { importName, importString: `import type { ${typeName} as ${importName} } from '${path .relative(output, file) .replace(/\\/g, '/') - .replace(/(\/index)?\.tsx?$/, '')}'` - } -} + .replace(/(\/index)?\.tsx?$/, '')}';` + }; +}; diff --git a/src/replaceWithUnderscore.ts b/src/replaceWithUnderscore.ts index b14b310..8089acf 100644 --- a/src/replaceWithUnderscore.ts +++ b/src/replaceWithUnderscore.ts @@ -1,2 +1,2 @@ export const replaceWithUnderscore = (name: string) => - name.replace(/(-|\.|!| |'|\*|\(|\))/g, '_').replace(/^(\d)/, '$$$1') + name.replace(/(-|\.|!| |'|\*|\(|\))/g, '_').replace(/^(\d)/, '$$$1'); diff --git a/src/watchInputDir.ts b/src/watchInputDir.ts index 1df7580..19f2ec5 100644 --- a/src/watchInputDir.ts +++ b/src/watchInputDir.ts @@ -1,5 +1,5 @@ -import chokidar from 'chokidar' +import chokidar from 'chokidar'; export default (input: string, callback: (...args: any) => void) => { - chokidar.watch(input, { ignoreInitial: true, ignored: /\/\$[^/]+\.ts$/ }).on('all', callback) -} + chokidar.watch(input, { ignoreInitial: true, ignored: /\/\$[^/]+\.ts$/ }).on('all', callback); +}; diff --git a/src/writeRouteFile.ts b/src/writeRouteFile.ts index 32bcbcc..5653402 100644 --- a/src/writeRouteFile.ts +++ b/src/writeRouteFile.ts @@ -1,8 +1,8 @@ -import fs from 'fs' +import fs from 'fs'; export default ({ filePath, text }: { text: string; filePath: string }) => { - if (fs.existsSync(filePath) && fs.readFileSync(filePath, 'utf8') === text) return + if (fs.existsSync(filePath) && fs.readFileSync(filePath, 'utf8') === text) return; - fs.writeFileSync(filePath, text, 'utf8') - console.log(`${filePath} was built successfully.`) -} + fs.writeFileSync(filePath, text, 'utf8'); + console.log(`${filePath} was built successfully.`); +};