Skip to content

Commit

Permalink
🔥 REMOVE: logs (#559)
Browse files Browse the repository at this point in the history
* 🔥 REMOVE: logs

* Update dependency @sveltejs/kit to v1.30.1

* tmp wo eslint

* 🎉 NEW: detect export function (not only export const) in +server.ts files (#560)

* tests should stick in the same project

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
jycouet and renovate[bot] authored Dec 13, 2023
1 parent 33cbdb6 commit c162424
Show file tree
Hide file tree
Showing 36 changed files with 152 additions and 90 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-queens-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vite-plugin-kit-routes': patch
---

detect export function (not only export const) in +server.ts files
5 changes: 5 additions & 0 deletions .changeset/thin-otters-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vite-plugin-striper': patch
---

rmv some leftover logs :/
4 changes: 3 additions & 1 deletion packages/eslint-config/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'@theguild',
'@theguild/eslint-config/react',
'@theguild/eslint-config/mdx',
'@theguild/eslint-config/json',
'@theguild/eslint-config/yml',
Expand Down Expand Up @@ -42,9 +41,12 @@ module.exports = {
},
},
],
ignorePatterns: ['tsconfig.json', 'tsconfig.eslint.json', '.npmrc', 'README.md'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
project: 'tsconfig.eslint.json',
extraFileExtensions: ['.json'],
},
env: {
browser: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/handles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"devDependencies": {
"@kitql/eslint-config": "workspace:*",
"@sveltejs/adapter-node": "1.3.1",
"@sveltejs/kit": "1.29.0",
"@sveltejs/kit": "1.30.1",
"@sveltejs/package": "2.2.2",
"publint": "0.2.4",
"svelte": "4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"devDependencies": {
"@sveltejs/adapter-auto": "2.1.0",
"@sveltejs/kit": "1.29.0",
"@sveltejs/kit": "1.30.1",
"@sveltejs/package": "2.2.2",
"@kitql/eslint-config": "workspace:*",
"publint": "0.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"devDependencies": {
"@sveltejs/adapter-auto": "2.1.0",
"@sveltejs/kit": "1.29.0",
"@sveltejs/kit": "1.30.1",
"@sveltejs/package": "2.2.2",
"@kitql/eslint-config": "workspace:*",
"publint": "0.2.4",
Expand Down
34 changes: 2 additions & 32 deletions packages/internals/src/lib/fs/fs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,11 @@ import { getFilesUnder, read, write, relative } from './fs.js'

describe('fs', () => {
it('getFilesUnder', async () => {
const location = relative(`${process.cwd()}`, '../vite-plugin-kit-routes/src/routes/')
const location = relative(`${process.cwd()}`, 'src/routes/')
expect(getFilesUnder(location)).toMatchInlineSnapshot(`
[
"(rootGroup)/+page.svelte",
"(rootGroup)/subGroup/(anotherSub)/user/+page.svelte",
"(rootGroup)/subGroup/+page.svelte",
"(rootGroup)/subGroup2/+page.svelte",
"+layout.svelte",
"[[lang]]/contract/+page.svelte",
"[[lang]]/contract/+server.ts",
"[[lang]]/contract/[id]/+page.server.ts",
"[[lang]]/contract/[id]/+page.svelte",
"[[lang]]/gp/(logged)/one/+page.svelte",
"[[lang]]/gp/(public)/two/+page.svelte",
"[[lang]]/main/+page.svelte",
"[[lang]]/match/[id=ab]/+page.svelte",
"[[lang]]/match/[id=int]/+page.svelte",
"[[lang]]/site/+page.server.ts",
"[[lang]]/site/+page.svelte",
"[[lang]]/site/+server.ts",
"[[lang]]/site/[id]/+page.server.ts",
"[[lang]]/site/[id]/+page.svelte",
"[[lang]]/site_contract/+page.server.ts",
"[[lang]]/site_contract/[siteId]-[contractId]/+page.server.ts",
"[[lang]]/site_contract/[siteId]-[contractId]/+page.svelte",
"a/[...rest]/z/+page.svelte",
"api/graphql/+server.ts",
"data/errors/[locale].json/+server.ts",
"lay/(layVerySpecial)/+layout.svelte",
"lay/(layVerySpecial)/normal/+page.svelte",
"lay/(layVerySpecial)/root-layout/+page@.svelte",
"lay/(layVerySpecial)/skip/+page@lay.svelte",
"lay/+layout.svelte",
"page_server_woAction/+page.server.ts",
"sp/+page.svelte",
"+page.svelte",
]
`)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-kit-routes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"devDependencies": {
"@kitql/eslint-config": "workspace:*",
"@sveltejs/adapter-auto": "2.1.0",
"@sveltejs/kit": "1.29.0",
"@sveltejs/kit": "1.30.1",
"@sveltejs/package": "2.2.2",
"publint": "0.2.4",
"svelte": "4.2.1",
Expand Down
4 changes: 4 additions & 0 deletions packages/vite-plugin-kit-routes/src/lib/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ const PAGES = {
* SERVERS
*/
const SERVERS = {
'GET /server_func_get': `/server_func_get`,
'POST /server_func_post': `/server_func_post`,
'GET /contract': (params?: { lang?: 'fr' | 'en' | 'hu' | 'at' | string }) => {
return `${params?.lang ? `/${params?.lang}` : ''}/contract`
},
Expand Down Expand Up @@ -275,6 +277,8 @@ export type KIT_ROUTES = {
'/sp': never
}
SERVERS: {
'GET /server_func_get': never
'POST /server_func_post': never
'GET /contract': 'lang'
'POST /contract': 'lang'
'GET /site': 'lang'
Expand Down
26 changes: 19 additions & 7 deletions packages/vite-plugin-kit-routes/src/lib/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,34 @@ export const getMethodsOfServerFiles = (pathFile: string) => {
let exportedNames: string[] = []
visit(codeParsed, {
visitExportNamedDeclaration(path) {
// @ts-ignore
const declarations = path.node.declaration?.declarations
if (declarations) {
declarations.forEach((declaration: any) => {
if (declaration.id.name) {
const declaration = path.node.declaration

// Check for variable declarations
if (declaration?.type === 'VariableDeclaration') {
declaration.declarations.forEach(declaration => {
if (
declaration.type === 'VariableDeclarator' &&
declaration.id.type === 'Identifier' &&
declaration.id.name
) {
exportedNames.push(declaration.id.name)
}
})
}

// Check for function declarations
if (declaration?.type === 'FunctionDeclaration') {
if (declaration.id && declaration.id.name) {
exportedNames.push(String(declaration.id.name))
}
}

// Check for export specifiers (for aliased exports)
const specifiers = path.node.specifiers
if (specifiers) {
specifiers.forEach((specifier: any) => {
specifiers.forEach(specifier => {
if (specifier.exported.name) {
exportedNames.push(specifier.exported.name)
exportedNames.push(String(specifier.exported.name))
}
})
}
Expand Down
8 changes: 8 additions & 0 deletions packages/vite-plugin-kit-routes/src/lib/plugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ describe('rmv Helper', () => {
"(rootGroup)/subGroup/(anotherSub)/user/+page.svelte",
"(rootGroup)/subGroup/+page.svelte",
"(rootGroup)/subGroup2/+page.svelte",
"(servers)/server_func_get/+server.ts",
"(servers)/server_func_post/+server.ts",
"+layout.svelte",
"/contract/+page.svelte",
"/contract/+server.ts",
Expand Down Expand Up @@ -840,6 +842,8 @@ describe('rmv Helper', () => {
"(rootGroup)/subGroup/(anotherSub)/user/+page.svelte",
"(rootGroup)/subGroup/+page.svelte",
"(rootGroup)/subGroup2/+page.svelte",
"(servers)/server_func_get/+server.ts",
"(servers)/server_func_post/+server.ts",
"+layout.svelte",
"[[lang]]/contract/+page.svelte",
"[[lang]]/contract/+server.ts",
Expand Down Expand Up @@ -877,6 +881,8 @@ describe('rmv Helper', () => {
"/subGroup/user/+page.svelte",
"/subGroup/+page.svelte",
"/subGroup2/+page.svelte",
"/server_func_get/+server.ts",
"/server_func_post/+server.ts",
"+layout.svelte",
"[[lang]]/contract/+page.svelte",
"[[lang]]/contract/+server.ts",
Expand Down Expand Up @@ -917,6 +923,8 @@ describe('rmv Helper', () => {
"/subGroup/user/+page.svelte",
"/subGroup/+page.svelte",
"/subGroup2/+page.svelte",
"/server_func_get/+server.ts",
"/server_func_post/+server.ts",
"+layout.svelte",
"/contract/+page.svelte",
"/contract/+server.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function GET() {
return new Response()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function POST() {
return new Response()
}
4 changes: 3 additions & 1 deletion packages/vite-plugin-kit-routes/src/test/ROUTES_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const PAGES = {
* SERVERS
*/
const SERVERS = {
"GET /server_func_get": `${base}/server_func_get`,
"POST /server_func_post": `${base}/server_func_post`,
"GET /contract": (params?: { lang?: (string | number) }) => {
return `${base}${params?.lang ? `/${params?.lang}`: ''}/contract`
},
Expand Down Expand Up @@ -181,7 +183,7 @@ export function route<T extends keyof AllTypes>(key: T, ...params: any[]): strin
*/
export type KIT_ROUTES = {
PAGES: { '/': never, '/subGroup': never, '/subGroup/user': never, '/subGroup2': never, '/contract': 'lang', '/contract/[id]': 'id' | 'lang', '/gp/one': 'lang', '/gp/two': 'lang', '/main': 'lang', '/match/[id=ab]': 'id' | 'lang', '/match/[id=int]': 'id' | 'lang', '/site': 'lang', '/site/[id]': 'id' | 'lang', '/site_contract/[siteId]-[contractId]': 'siteId' | 'contractId' | 'lang', '/a/[...rest]/z': 'rest', '/lay/normal': never, '/lay/root-layout': never, '/lay/skip': never, '/sp': never }
SERVERS: { 'GET /contract': 'lang', 'POST /contract': 'lang', 'GET /site': 'lang', 'GET /api/graphql': never, 'POST /api/graphql': never, 'GET /data/errors/[locale].json': 'locale' }
SERVERS: { 'GET /server_func_get': never, 'POST /server_func_post': never, 'GET /contract': 'lang', 'POST /contract': 'lang', 'GET /site': 'lang', 'GET /api/graphql': never, 'POST /api/graphql': never, 'GET /data/errors/[locale].json': 'locale' }
ACTIONS: { 'default /contract/[id]': 'id' | 'lang', 'create /site': 'lang', 'update /site/[id]': 'id' | 'lang', 'delete /site/[id]': 'id' | 'lang', 'noSatisfies /site_contract': 'lang', 'send /site_contract/[siteId]-[contractId]': 'siteId' | 'contractId' | 'lang' }
LINKS: Record<string, never>
Params: { lang: never, id: never, siteId: never, contractId: never, rest: never, locale: never }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export const PAGES = {
* SERVERS
*/
export const SERVERS = {
"GET /server_func_get": `/server_func_get`,
"POST /server_func_post": `/server_func_post`,
"GET /contract": (params?: { lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => {
return `${params?.lang ? `/${params?.lang}`: ''}/contract`
},
Expand Down Expand Up @@ -167,7 +169,7 @@ export const currentSp = () => {
*/
export type KIT_ROUTES = {
PAGES: { '/': never, '/subGroup': never, '/subGroup/user': never, '/subGroup2': never, '/contract': 'lang', '/contract/[id]': 'id' | 'lang', '/gp/one': 'lang', '/gp/two': 'lang', '/main': 'lang', '/match/[id=ab]': 'id' | 'lang', '/match/[id=int]': 'id' | 'lang', '/site': 'lang', '/site/[id]': 'lang' | 'id', '/site_contract/[siteId]-[contractId]': 'siteId' | 'contractId' | 'lang', '/a/[...rest]/z': 'rest', '/lay/normal': never, '/lay/root-layout': never, '/lay/skip': never, '/sp': never }
SERVERS: { 'GET /contract': 'lang', 'POST /contract': 'lang', 'GET /site': 'lang', 'GET /api/graphql': never, 'POST /api/graphql': never, 'GET /data/errors/[locale].json': 'locale' }
SERVERS: { 'GET /server_func_get': never, 'POST /server_func_post': never, 'GET /contract': 'lang', 'POST /contract': 'lang', 'GET /site': 'lang', 'GET /api/graphql': never, 'POST /api/graphql': never, 'GET /data/errors/[locale].json': 'locale' }
ACTIONS: { 'default /contract/[id]': 'id' | 'lang', 'create /site': 'lang', 'update /site/[id]': 'id' | 'lang', 'delete /site/[id]': 'id' | 'lang', 'noSatisfies /site_contract': 'lang', 'send /site_contract/[siteId]-[contractId]': 'siteId' | 'contractId' | 'lang' }
LINKS: { 'twitter': never, 'twitter_post': 'name' | 'id', 'gravatar': 'str' }
Params: { first: never, lang: never, id: never, limit: never, demo: never, siteId: never, contractId: never, rest: never, locale: never, extra: never, name: never, str: never, s: never, d: never }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export const PAGES = {
* SERVERS
*/
export const SERVERS = {
"GET /server_func_get": `/server_func_get`,
"POST /server_func_post": `/server_func_post`,
"GET /contract": (params?: { lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => {
return `${params?.lang ? `/${params?.lang}`: ''}/contract`
},
Expand Down Expand Up @@ -168,7 +170,7 @@ export const currentSp = () => {
*/
export type KIT_ROUTES = {
PAGES: { '/': never, '/subGroup': never, '/subGroup/user': never, '/subGroup2': never, '/contract': 'lang', '/contract/[id]': 'lang' | 'id', '/gp/one': 'lang', '/gp/two': 'lang', '/main': 'lang', '/match/[id=ab]': 'lang' | 'id', '/match/[id=int]': 'lang' | 'id', '/site': 'lang', '/site/[id]': 'lang' | 'id', '/site_contract/[siteId]-[contractId]': 'siteId' | 'contractId' | 'lang', '/a/[...rest]/z': 'rest', '/lay/normal': never, '/lay/root-layout': never, '/lay/skip': never, '/sp': never }
SERVERS: { 'GET /contract': 'lang', 'POST /contract': 'lang', 'GET /site': 'lang', 'GET /api/graphql': never, 'POST /api/graphql': never, 'GET /data/errors/[locale].json': 'locale' }
SERVERS: { 'GET /server_func_get': never, 'POST /server_func_post': never, 'GET /contract': 'lang', 'POST /contract': 'lang', 'GET /site': 'lang', 'GET /api/graphql': never, 'POST /api/graphql': never, 'GET /data/errors/[locale].json': 'locale' }
ACTIONS: { 'default /contract/[id]': 'lang' | 'id', 'create /site': 'lang', 'update /site/[id]': 'lang' | 'id', 'delete /site/[id]': 'lang' | 'id', 'noSatisfies /site_contract': 'lang', 'send /site_contract/[siteId]-[contractId]': 'siteId' | 'contractId' | 'lang' }
LINKS: { 'twitter': never, 'twitter_post': 'name' | 'id', 'gravatar': 'str' }
Params: { first: never, lang: never, id: never, limit: never, demo: never, siteId: never, contractId: never, rest: never, locale: never, extra: never, name: never, str: never, s: never, d: never }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export const PAGES = {
* SERVERS
*/
export const SERVERS = {
"GET_server_func_get": `/server_func_get`,
"POST_server_func_post": `/server_func_post`,
"GET_contract": (params?: { lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => {
return `${params?.lang ? `/${params?.lang}`: ''}/contract`
},
Expand Down Expand Up @@ -167,7 +169,7 @@ export const currentSp = () => {
*/
export type KIT_ROUTES = {
PAGES: { '_ROOT': never, 'subGroup': never, 'subGroup_user': never, 'subGroup2': never, 'contract': 'lang', 'contract_id': 'id' | 'lang', 'gp_one': 'lang', 'gp_two': 'lang', 'main': 'lang', 'match_id_ab': 'id' | 'lang', 'match_id_int': 'id' | 'lang', 'site': 'lang', 'site_id': 'lang' | 'id', 'site_contract_siteId_contractId': 'siteId' | 'contractId' | 'lang', 'a_rest_z': 'rest', 'lay_normal': never, 'lay_root_layout': never, 'lay_skip': never, 'sp': never }
SERVERS: { 'GET_contract': 'lang', 'POST_contract': 'lang', 'GET_site': 'lang', 'GET_api_graphql': never, 'POST_api_graphql': never, 'GET_data_errors_locale_json': 'locale' }
SERVERS: { 'GET_server_func_get': never, 'POST_server_func_post': never, 'GET_contract': 'lang', 'POST_contract': 'lang', 'GET_site': 'lang', 'GET_api_graphql': never, 'POST_api_graphql': never, 'GET_data_errors_locale_json': 'locale' }
ACTIONS: { 'default_contract_id': 'id' | 'lang', 'create_site': 'lang', 'update_site_id': 'id' | 'lang', 'delete_site_id': 'id' | 'lang', 'noSatisfies_site_contract': 'lang', 'send_site_contract_siteId_contractId': 'siteId' | 'contractId' | 'lang' }
LINKS: { 'twitter': never, 'twitter_post': 'name' | 'id', 'gravatar': 'str' }
Params: { first: never, lang: never, id: never, limit: never, demo: never, siteId: never, contractId: never, rest: never, locale: never, extra: never, name: never, str: never, s: never, d: never }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export const PAGES = {
* SERVERS
*/
export const SERVERS = {
"GET_server_func_get": `/server_func_get`,
"POST_server_func_post": `/server_func_post`,
"GET_contract": (params?: { lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => {
return `${params?.lang ? `/${params?.lang}`: ''}/contract`
},
Expand Down Expand Up @@ -168,7 +170,7 @@ export const currentSp = () => {
*/
export type KIT_ROUTES = {
PAGES: { '_ROOT': never, 'subGroup': never, 'subGroup_user': never, 'subGroup2': never, 'contract': 'lang', 'contract_id': 'lang' | 'id', 'gp_one': 'lang', 'gp_two': 'lang', 'main': 'lang', 'match_id_ab': 'lang' | 'id', 'match_id_int': 'lang' | 'id', 'site': 'lang', 'site_id': 'lang' | 'id', 'site_contract_siteId_contractId': 'siteId' | 'contractId' | 'lang', 'a_rest_z': 'rest', 'lay_normal': never, 'lay_root_layout': never, 'lay_skip': never, 'sp': never }
SERVERS: { 'GET_contract': 'lang', 'POST_contract': 'lang', 'GET_site': 'lang', 'GET_api_graphql': never, 'POST_api_graphql': never, 'GET_data_errors_locale_json': 'locale' }
SERVERS: { 'GET_server_func_get': never, 'POST_server_func_post': never, 'GET_contract': 'lang', 'POST_contract': 'lang', 'GET_site': 'lang', 'GET_api_graphql': never, 'POST_api_graphql': never, 'GET_data_errors_locale_json': 'locale' }
ACTIONS: { 'default_contract_id': 'lang' | 'id', 'create_site': 'lang', 'update_site_id': 'lang' | 'id', 'delete_site_id': 'lang' | 'id', 'noSatisfies_site_contract': 'lang', 'send_site_contract_siteId_contractId': 'siteId' | 'contractId' | 'lang' }
LINKS: { 'twitter': never, 'twitter_post': 'name' | 'id', 'gravatar': 'str' }
Params: { first: never, lang: never, id: never, limit: never, demo: never, siteId: never, contractId: never, rest: never, locale: never, extra: never, name: never, str: never, s: never, d: never }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export const PAGES = {
* SERVERS
*/
export const SERVERS = {
"GET /server_func_get": `/server_func_get`,
"POST /server_func_post": `/server_func_post`,
"GET /contract": (params?: { lang?: ('fr' | 'en' | 'hu' | 'at' | string) }) => {
return `${params?.lang ? `/${params?.lang}`: ''}/contract`
},
Expand Down Expand Up @@ -194,7 +196,7 @@ export function route<T extends keyof AllTypes>(key: T, ...params: any[]): strin
*/
export type KIT_ROUTES = {
PAGES: { '/': never, '/subGroup': never, '/subGroup/user': never, '/subGroup2': never, '/contract': 'lang', '/contract/[id]': 'id' | 'lang', '/gp/one': 'lang', '/gp/two': 'lang', '/main': 'lang', '/match/[id=ab]': 'id' | 'lang', '/match/[id=int]': 'id' | 'lang', '/site': 'lang', '/site/[id]': 'lang' | 'id', '/site_contract/[siteId]-[contractId]': 'siteId' | 'contractId' | 'lang', '/a/[...rest]/z': 'rest', '/lay/normal': never, '/lay/root-layout': never, '/lay/skip': never, '/sp': never }
SERVERS: { 'GET /contract': 'lang', 'POST /contract': 'lang', 'GET /site': 'lang', 'GET /api/graphql': never, 'POST /api/graphql': never, 'GET /data/errors/[locale].json': 'locale' }
SERVERS: { 'GET /server_func_get': never, 'POST /server_func_post': never, 'GET /contract': 'lang', 'POST /contract': 'lang', 'GET /site': 'lang', 'GET /api/graphql': never, 'POST /api/graphql': never, 'GET /data/errors/[locale].json': 'locale' }
ACTIONS: { 'default /contract/[id]': 'id' | 'lang', 'create /site': 'lang', 'update /site/[id]': 'id' | 'lang', 'delete /site/[id]': 'id' | 'lang', 'noSatisfies /site_contract': 'lang', 'send /site_contract/[siteId]-[contractId]': 'siteId' | 'contractId' | 'lang' }
LINKS: { 'twitter': never, 'twitter_post': 'name' | 'id', 'gravatar': 'str' }
Params: { first: never, lang: never, id: never, limit: never, demo: never, siteId: never, contractId: never, rest: never, locale: never, extra: never, name: never, str: never, s: never, d: never }
Expand Down
Loading

0 comments on commit c162424

Please sign in to comment.