From f2596b1ab620ed76014bd7cc5d36ba23ad347616 Mon Sep 17 00:00:00 2001 From: JYC Date: Wed, 19 Oct 2022 20:17:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20FIX:=20context?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :art: UPDATE: format * :children_crossing: FIX: context * :art: UPDATE: changeset --- .changeset/rude-roses-itch.md | 5 + .prettierrc.cjs | 4 +- examples/demo-init/package.json | 7 +- examples/demo-init/pnpm-lock.yaml | 8 +- package.json | 1 + .../all-in/src/lib/graphql/kitQLServer.ts | 12 +- packages/all-in/src/lib/hooks/graphql.ts | 1 + packages/all-in/src/lib/index.ts | 11 +- .../all-in/src/lib/modules/_init/index.ts | 1 + packages/all-in/src/lib/modules/user/index.ts | 1 + .../lib/modules/user/resolvers/_Mutation.ts | 2 +- .../src/lib/modules/user/resolvers/_Query.ts | 7 +- .../all-in/src/lib/vite/actionContexts.ts | 7 +- packages/all-in/src/lib/vite/actionEnum.ts | 7 +- packages/all-in/src/lib/vite/actionModules.ts | 5 +- .../all-in/src/lib/vite/actionResolvers.ts | 5 +- .../all-in/src/lib/vite/actionTypeDefs.ts | 5 +- packages/all-in/src/lib/vite/fileFolder.ts | 1 + .../src/lib/vite/{index.ts => generate.ts} | 19 ++-- packages/all-in/src/lib/vite/plugin.ts | 3 +- packages/all-in/src/lib/vite/prismaHelper.ts | 2 +- packages/all-in/tsconfig.json | 1 + packages/all-in/vite.config.ts | 2 + packages/helper/test/Log.spec.ts | 1 + .../helper/test/queryStringApprend.spec.ts | 1 + packages/helper/test/sleep.spec.ts | 1 + packages/helper/test/stry.spec.ts | 1 + packages/module-codegen/src/actionContexts.ts | 3 +- packages/module-codegen/src/actionEnum.ts | 1 + .../module-codegen/src/actionModuleContext.ts | 1 + packages/module-codegen/src/actionModules.ts | 1 + .../module-codegen/src/actionResolvers.ts | 1 + packages/module-codegen/src/actionTypeDefs.ts | 1 + .../module-codegen/src/defaultConfigFile.ts | 1 + packages/module-codegen/src/fileFolder.ts | 1 + packages/module-codegen/src/index.ts | 1 + packages/template/src/index.ts | 4 +- .../test/plugins.checkConf.spec.ts | 1 + pnpm-lock.yaml | 107 +++++++++++++++++- vite.config.ts | 2 +- website/scripts/algolia-ci.mjs | 2 +- website/src/components/index-page.tsx | 1 + website/src/pages/_app.tsx | 2 +- .../pages/docs/extra/migrating-to-0.7.0.mdx | 1 + website/src/pages/docs/setup/02_server.mdx | 3 +- .../setup/03_vite-plugin-watch-and-run.mdx | 2 +- 46 files changed, 195 insertions(+), 62 deletions(-) create mode 100644 .changeset/rude-roses-itch.md rename packages/all-in/src/lib/vite/{index.ts => generate.ts} (89%) diff --git a/.changeset/rude-roses-itch.md b/.changeset/rude-roses-itch.md new file mode 100644 index 00000000..30930a3d --- /dev/null +++ b/.changeset/rude-roses-itch.md @@ -0,0 +1,5 @@ +--- +'@kitql/all-in': patch +--- + +export all the lib in svelte esm diff --git a/.prettierrc.cjs b/.prettierrc.cjs index d47f2f03..1bc2cd5f 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -3,5 +3,7 @@ const { plugins, ...prettierConfig } = require('@theguild/prettier-config') module.exports = { ...prettierConfig, semi: false, - plugins: [...plugins, 'prettier-plugin-svelte'], + plugins: [...plugins, 'prettier-plugin-svelte', '@trivago/prettier-plugin-sort-imports'], + importOrder: ['', '^[./]'], + importOrderSeparation: true, } diff --git a/examples/demo-init/package.json b/examples/demo-init/package.json index fafd310a..947a5d95 100644 --- a/examples/demo-init/package.json +++ b/examples/demo-init/package.json @@ -8,6 +8,7 @@ "url": "https://github.com/jycouet/kitql", "directory": "examples/demo-init" }, + "type": "module", "scripts": { "dev": "vite dev --port 3777", "build": "npm run build:date && vite build", @@ -38,14 +39,10 @@ "vite": "3.1.7" }, "dependencies": { - "@kitql/all-in": "0.8.0-next.6", + "@kitql/all-in": "0.8.0-next.7", "houdini": "0.16.8", "graphql": "15.5.3" }, - "resolutions": { - "graphql": "15.5.3" - }, - "type": "module", "engines": { "node": ">=16.0.0" }, diff --git a/examples/demo-init/pnpm-lock.yaml b/examples/demo-init/pnpm-lock.yaml index 0f033835..5c58c7ee 100644 --- a/examples/demo-init/pnpm-lock.yaml +++ b/examples/demo-init/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: .: specifiers: - '@kitql/all-in': 0.8.0-next.6 + '@kitql/all-in': 0.8.0-next.7 '@playwright/test': ^1.25.0 '@sveltejs/adapter-auto': 1.0.0-next.80 '@sveltejs/kit': 1.0.0-next.511 @@ -30,7 +30,7 @@ importers: typescript: 4.7.4 vite: 3.1.7 dependencies: - '@kitql/all-in': 0.8.0-next.6_pc72mchvuva65atzv2lure54iq + '@kitql/all-in': 0.8.0-next.7_pc72mchvuva65atzv2lure54iq graphql: 15.5.3 houdini: 0.16.8_graphql@15.5.3 devDependencies: @@ -1400,8 +1400,8 @@ packages: '@jridgewell/sourcemap-codec': 1.4.14 dev: false - /@kitql/all-in/0.8.0-next.6_pc72mchvuva65atzv2lure54iq: - resolution: {integrity: sha512-1QooWfjLes2hAoZKP5OJH+mynYv56jxH+hiegq9aDjFlmfDtpELZ7dZZvwZ4OcMC/sXjzMH51KklgGfNkOcaRw==} + /@kitql/all-in/0.8.0-next.7_pc72mchvuva65atzv2lure54iq: + resolution: {integrity: sha512-ea2DGPjSRIBaFPWsr4RzZAzWVR6JwK8aHR8+81PLu+6RIxS9iWHRYzaA+DjAmDIt2/Wk6WsWbjTRrPFz4n2DJg==} peerDependencies: graphql: ^15.5.0 dependencies: diff --git a/package.json b/package.json index 958c05ec..d61443bd 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@changesets/cli": "2.24.4", "@theguild/eslint-config": "0.0.2", "@theguild/prettier-config": "0.0.3", + "@trivago/prettier-plugin-sort-imports": "^3.3.1", "@vitest/coverage-c8": "^0.24.3", "@vitest/ui": "0.23.2", "bob-the-bundler": "4.0.0", diff --git a/packages/all-in/src/lib/graphql/kitQLServer.ts b/packages/all-in/src/lib/graphql/kitQLServer.ts index 56c54aed..67be8486 100644 --- a/packages/all-in/src/lib/graphql/kitQLServer.ts +++ b/packages/all-in/src/lib/graphql/kitQLServer.ts @@ -1,6 +1,8 @@ +import type { KitQLHandleGraphQL } from '$lib/hooks/graphql' import type { RequestEvent } from '@sveltejs/kit' + import { modules } from './$kitql/_appModules' -import { kitQLModules } from './kitQLModules' +import { kitQLModules } from './kitQLModules.js' const plugins = [] plugins.push(kitQLModules(modules)) @@ -9,8 +11,8 @@ function getContext({ request }: RequestEvent) { // get the cookie or the token... const coolInfo = request.headers.get('Authorization') - // get the user from the coolInfo (redis or db) - const user = { id: 1, name: 'John' } + // get the user from the coolInfo (redis or db or ...) + const user = { id: 7, name: 'JYC' } return { request, @@ -33,7 +35,7 @@ export type IKitQLContext = ReturnType // config: // contextType: $graphql/kitQLServer#IKitQLContext -export const kitqlServer = { +export const kitqlServer: KitQLHandleGraphQL = { plugins, - getContext, + context: getContext, } diff --git a/packages/all-in/src/lib/hooks/graphql.ts b/packages/all-in/src/lib/hooks/graphql.ts index 2dd5f077..fdf9a87b 100644 --- a/packages/all-in/src/lib/hooks/graphql.ts +++ b/packages/all-in/src/lib/hooks/graphql.ts @@ -51,6 +51,7 @@ export function handleGraphql(options?: KitQLHandleGraphQL({ logging: true, + // will be overwritten by modules schema: createSchema({ typeDefs: ` type Query { diff --git a/packages/all-in/src/lib/index.ts b/packages/all-in/src/lib/index.ts index 3e70a1b2..ceea667e 100644 --- a/packages/all-in/src/lib/index.ts +++ b/packages/all-in/src/lib/index.ts @@ -1,15 +1,13 @@ // Svelte Component -// export { default as KitQLInfo } from './KitQLInfo.svelte' +export { default as KitQLInfo } from './KitQLInfo.svelte' // graphql-modules export { createModule } from 'graphql-modules' export { kitQLModules } from './graphql/kitQLModules.js' // SvelteKit hooks -export type { KitQLHandleGraphQL } from './hooks/graphql.js' -export { handleGraphql } from './hooks/graphql.js' -export type { KitQLHandleGraphiQL } from './hooks/graphiql.js' -export { handleGraphiql } from './hooks/graphiql.js' +export { type KitQLHandleGraphQL, handleGraphql } from './hooks/graphql.js' +export { type KitQLHandleGraphiQL, handleGraphiql } from './hooks/graphiql.js' // Prisma // export { getKitQLPrisma } from './prisma/kitQLPrisma' @@ -17,8 +15,7 @@ export { handleGraphiql } from './hooks/graphiql.js' // GraphQL Config export type { CodegenConfig as KitQLCodegenConfig } from '@graphql-codegen/cli' export type { IGraphQLProject as KitQLProject } from 'graphql-config' -export type { KitQLProjects, KitQLConfig, KitQLScalar } from './graphql/graphqlConfig.js' -export { kitQLConfig } from './graphql/graphqlConfig.js' +export { type KitQLProjects, type KitQLConfig, type KitQLScalar, kitQLConfig } from './graphql/graphqlConfig.js' // vite plugin export { kitql } from './vite/plugin.js' diff --git a/packages/all-in/src/lib/modules/_init/index.ts b/packages/all-in/src/lib/modules/_init/index.ts index c4caf533..13038c05 100644 --- a/packages/all-in/src/lib/modules/_init/index.ts +++ b/packages/all-in/src/lib/modules/_init/index.ts @@ -1,4 +1,5 @@ import { createModule } from 'graphql-modules' + import { resolvers } from './$kitql/resolvers' import { typeDefs } from './$kitql/typedefs' diff --git a/packages/all-in/src/lib/modules/user/index.ts b/packages/all-in/src/lib/modules/user/index.ts index 883455b7..a793ac8d 100644 --- a/packages/all-in/src/lib/modules/user/index.ts +++ b/packages/all-in/src/lib/modules/user/index.ts @@ -1,6 +1,7 @@ import { createModule } from 'graphql-modules' import { dirname } from 'path' import { fileURLToPath } from 'url' + import { resolvers } from './$kitql/resolvers' import { typeDefs } from './$kitql/typedefs' diff --git a/packages/all-in/src/lib/modules/user/resolvers/_Mutation.ts b/packages/all-in/src/lib/modules/user/resolvers/_Mutation.ts index f1898b06..37f107c3 100644 --- a/packages/all-in/src/lib/modules/user/resolvers/_Mutation.ts +++ b/packages/all-in/src/lib/modules/user/resolvers/_Mutation.ts @@ -3,7 +3,7 @@ import type { UserModule } from '../$kitql/moduleTypes' export const resolvers: UserModule.Resolvers = { Mutation: { userCreate: async (root, args, ctx) => { - return { id: '7', username: args.fields.username } + return { id: '77', username: args.fields.username } }, }, } diff --git a/packages/all-in/src/lib/modules/user/resolvers/_Query.ts b/packages/all-in/src/lib/modules/user/resolvers/_Query.ts index 918ae0f6..ff860484 100644 --- a/packages/all-in/src/lib/modules/user/resolvers/_Query.ts +++ b/packages/all-in/src/lib/modules/user/resolvers/_Query.ts @@ -1,14 +1,15 @@ -import { topLevelFields } from '$lib/graphql/helper' import type { UserConnection } from '$lib/graphql/$kitql/graphqlTypes' +import { topLevelFields } from '$lib/graphql/helper' import { _InitModule } from '$lib/modules/_init/$kitql/moduleTypes' + import { UserModule } from '../$kitql/moduleTypes' export const resolvers: UserModule.Resolvers = { Query: { user: async (root, args, ctx) => { return { - id: '1', - username: 'JYC', + id: ctx.user.id.toString(), + username: ctx.user.name, } }, diff --git a/packages/all-in/src/lib/vite/actionContexts.ts b/packages/all-in/src/lib/vite/actionContexts.ts index 03a3cdc2..b0bd27a6 100644 --- a/packages/all-in/src/lib/vite/actionContexts.ts +++ b/packages/all-in/src/lib/vite/actionContexts.ts @@ -1,7 +1,8 @@ -import { createFolderIfNotExists } from './fileFolder' -import { toPascalCase } from './formatString' import { join } from 'path' -import { write } from './readWrite' + +import { createFolderIfNotExists } from './fileFolder.js' +import { toPascalCase } from './formatString.js' +import { write } from './readWrite.js' export function actionContext(ctxModules: { ctxName: string; moduleName: string }[], outputFolder: string) { const dataCtxModules = [] diff --git a/packages/all-in/src/lib/vite/actionEnum.ts b/packages/all-in/src/lib/vite/actionEnum.ts index b5902fbc..4bd57018 100644 --- a/packages/all-in/src/lib/vite/actionEnum.ts +++ b/packages/all-in/src/lib/vite/actionEnum.ts @@ -1,8 +1,9 @@ import { existsSync } from 'fs' import { join } from 'path' -import { createFolderIfNotExists } from './fileFolder' -import { toPascalCase } from './formatString' -import { write } from './readWrite' + +import { createFolderIfNotExists } from './fileFolder.js' +import { toPascalCase } from './formatString.js' +import { write } from './readWrite.js' export function actionEnum( enumsModuleFolder: string, diff --git a/packages/all-in/src/lib/vite/actionModules.ts b/packages/all-in/src/lib/vite/actionModules.ts index fc961422..1d26fd23 100644 --- a/packages/all-in/src/lib/vite/actionModules.ts +++ b/packages/all-in/src/lib/vite/actionModules.ts @@ -1,6 +1,7 @@ import { join, posix } from 'path' -import { createFolderIfNotExists } from './fileFolder' -import { write } from './readWrite' + +import { createFolderIfNotExists } from './fileFolder.js' +import { write } from './readWrite.js' export function actionModules(modules: { directory: string; name: string }[], outputFolder: string) { const modulesImports: string[] = [] diff --git a/packages/all-in/src/lib/vite/actionResolvers.ts b/packages/all-in/src/lib/vite/actionResolvers.ts index 7bbcf0cf..5e4ba3aa 100644 --- a/packages/all-in/src/lib/vite/actionResolvers.ts +++ b/packages/all-in/src/lib/vite/actionResolvers.ts @@ -1,6 +1,7 @@ import { join, posix } from 'path' -import { createFolderIfNotExists, getFiles, getFileWODots, getFileWOTS } from './fileFolder' -import { write } from './readWrite' + +import { createFolderIfNotExists, getFiles, getFileWODots, getFileWOTS } from './fileFolder.js' +import { write } from './readWrite.js' export function actionResolvers(moduleFolder: string, moduleOutputFolder: string) { const resolversFolder = 'resolvers' diff --git a/packages/all-in/src/lib/vite/actionTypeDefs.ts b/packages/all-in/src/lib/vite/actionTypeDefs.ts index 7dde51bd..7be96ad5 100644 --- a/packages/all-in/src/lib/vite/actionTypeDefs.ts +++ b/packages/all-in/src/lib/vite/actionTypeDefs.ts @@ -1,6 +1,7 @@ import { join } from 'path' -import { createFolderIfNotExists, getFiles } from './fileFolder' -import { read, write } from './readWrite' + +import { createFolderIfNotExists, getFiles } from './fileFolder.js' +import { read, write } from './readWrite.js' export function actionTypeDefs(moduleFolder: string, moduleOutputFolder: string) { const typedefsFolder = 'typedefs' diff --git a/packages/all-in/src/lib/vite/fileFolder.ts b/packages/all-in/src/lib/vite/fileFolder.ts index ef894a26..3979f1a4 100644 --- a/packages/all-in/src/lib/vite/fileFolder.ts +++ b/packages/all-in/src/lib/vite/fileFolder.ts @@ -1,6 +1,7 @@ import { existsSync, mkdirSync, readdirSync } from 'fs' import glob from 'glob' import { extname, join } from 'path' + const rootPath = process.cwd() export const getDirectories = (source: string) => { diff --git a/packages/all-in/src/lib/vite/index.ts b/packages/all-in/src/lib/vite/generate.ts similarity index 89% rename from packages/all-in/src/lib/vite/index.ts rename to packages/all-in/src/lib/vite/generate.ts index b0e4858d..9b207cb0 100644 --- a/packages/all-in/src/lib/vite/index.ts +++ b/packages/all-in/src/lib/vite/generate.ts @@ -1,14 +1,15 @@ import { Log, logGreen, logRed } from '@kitql/helper' import { basename, extname } from 'path' -import { actionContext } from './actionContexts' -import { actionEnum } from './actionEnum' -import { actionModules } from './actionModules' -import { actionResolvers } from './actionResolvers' -import { actionTypeDefs } from './actionTypeDefs' -import { getDirectories, getFullPath } from './fileFolder' -import { type KitQLVite } from './KitQLVite' -import { getPrismaEnum } from './prismaHelper' -import { readLines } from './readWrite' + +import { type KitQLVite } from './KitQLVite.js' +import { actionContext } from './actionContexts.js' +import { actionEnum } from './actionEnum.js' +import { actionModules } from './actionModules.js' +import { actionResolvers } from './actionResolvers.js' +import { actionTypeDefs } from './actionTypeDefs.js' +import { getDirectories, getFullPath } from './fileFolder.js' +import { getPrismaEnum } from './prismaHelper.js' +import { readLines } from './readWrite.js' export function generate(config?: KitQLVite) { const log = new Log('KitQL') diff --git a/packages/all-in/src/lib/vite/plugin.ts b/packages/all-in/src/lib/vite/plugin.ts index 8836dc76..c0baf142 100644 --- a/packages/all-in/src/lib/vite/plugin.ts +++ b/packages/all-in/src/lib/vite/plugin.ts @@ -1,6 +1,7 @@ import type { Plugin } from 'vite' -import { generate } from '.' + import type { KitQLVite } from './KitQLVite' +import { generate } from './generate.js' export function kitql(config?: KitQLVite): Plugin { return { diff --git a/packages/all-in/src/lib/vite/prismaHelper.ts b/packages/all-in/src/lib/vite/prismaHelper.ts index 482625d0..8655a4c4 100644 --- a/packages/all-in/src/lib/vite/prismaHelper.ts +++ b/packages/all-in/src/lib/vite/prismaHelper.ts @@ -1,4 +1,4 @@ -import { toPascalCase } from './formatString' +import { toPascalCase } from './formatString.js' export function getPrismaEnum(lines: string[]): Record { const enums = {} diff --git a/packages/all-in/tsconfig.json b/packages/all-in/tsconfig.json index 42563d33..8976598c 100644 --- a/packages/all-in/tsconfig.json +++ b/packages/all-in/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "./.svelte-kit/tsconfig.json", "compilerOptions": { + "moduleResolution": "NodeNext", "importsNotUsedAsValues": "preserve", "paths": { "$lib": ["src/lib"], diff --git a/packages/all-in/vite.config.ts b/packages/all-in/vite.config.ts index 0bdc0f4e..6c9b5582 100644 --- a/packages/all-in/vite.config.ts +++ b/packages/all-in/vite.config.ts @@ -1,6 +1,8 @@ import { sveltekit } from '@sveltejs/kit/vite' import { type UserConfig } from 'vite' + import { kitql } from './src/lib/vite/plugin' + // import { kitql } from '@kitql/all-in' const config: UserConfig = { diff --git a/packages/helper/test/Log.spec.ts b/packages/helper/test/Log.spec.ts index b5e61011..fa06e3a7 100644 --- a/packages/helper/test/Log.spec.ts +++ b/packages/helper/test/Log.spec.ts @@ -1,4 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' + import { Log, logCyan, logGreen, logMagneta, logRed, logYellow } from '../src/Log' import { stry } from '../src/stry' diff --git a/packages/helper/test/queryStringApprend.spec.ts b/packages/helper/test/queryStringApprend.spec.ts index 22322294..1f22abe2 100644 --- a/packages/helper/test/queryStringApprend.spec.ts +++ b/packages/helper/test/queryStringApprend.spec.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest' + import { queryStringApprend } from '../src/queryStringApprend' describe('kitql - helper - queryStringApprend', () => { diff --git a/packages/helper/test/sleep.spec.ts b/packages/helper/test/sleep.spec.ts index f855d188..73f31437 100644 --- a/packages/helper/test/sleep.spec.ts +++ b/packages/helper/test/sleep.spec.ts @@ -1,4 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' + import { sleep } from '../src/sleep' describe('kitql - helper - sleep', () => { diff --git a/packages/helper/test/stry.spec.ts b/packages/helper/test/stry.spec.ts index f0c1b51c..c16e9f73 100644 --- a/packages/helper/test/stry.spec.ts +++ b/packages/helper/test/stry.spec.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest' + import { stry } from '../src/stry' describe('kitql - helper - stry', () => { diff --git a/packages/module-codegen/src/actionContexts.ts b/packages/module-codegen/src/actionContexts.ts index 03a3cdc2..d3fec231 100644 --- a/packages/module-codegen/src/actionContexts.ts +++ b/packages/module-codegen/src/actionContexts.ts @@ -1,6 +1,7 @@ +import { join } from 'path' + import { createFolderIfNotExists } from './fileFolder' import { toPascalCase } from './formatString' -import { join } from 'path' import { write } from './readWrite' export function actionContext(ctxModules: { ctxName: string; moduleName: string }[], outputFolder: string) { diff --git a/packages/module-codegen/src/actionEnum.ts b/packages/module-codegen/src/actionEnum.ts index b5902fbc..7b66a3ba 100644 --- a/packages/module-codegen/src/actionEnum.ts +++ b/packages/module-codegen/src/actionEnum.ts @@ -1,5 +1,6 @@ import { existsSync } from 'fs' import { join } from 'path' + import { createFolderIfNotExists } from './fileFolder' import { toPascalCase } from './formatString' import { write } from './readWrite' diff --git a/packages/module-codegen/src/actionModuleContext.ts b/packages/module-codegen/src/actionModuleContext.ts index 75a559b3..d849a945 100644 --- a/packages/module-codegen/src/actionModuleContext.ts +++ b/packages/module-codegen/src/actionModuleContext.ts @@ -1,4 +1,5 @@ import { join, basename, extname } from 'path' + import { createFolderIfNotExists } from './fileFolder' import { toPascalCase } from './formatString' import { write } from './readWrite' diff --git a/packages/module-codegen/src/actionModules.ts b/packages/module-codegen/src/actionModules.ts index fc961422..b4d88a87 100644 --- a/packages/module-codegen/src/actionModules.ts +++ b/packages/module-codegen/src/actionModules.ts @@ -1,4 +1,5 @@ import { join, posix } from 'path' + import { createFolderIfNotExists } from './fileFolder' import { write } from './readWrite' diff --git a/packages/module-codegen/src/actionResolvers.ts b/packages/module-codegen/src/actionResolvers.ts index 7bbcf0cf..619bcb3d 100644 --- a/packages/module-codegen/src/actionResolvers.ts +++ b/packages/module-codegen/src/actionResolvers.ts @@ -1,4 +1,5 @@ import { join, posix } from 'path' + import { createFolderIfNotExists, getFiles, getFileWODots, getFileWOTS } from './fileFolder' import { write } from './readWrite' diff --git a/packages/module-codegen/src/actionTypeDefs.ts b/packages/module-codegen/src/actionTypeDefs.ts index 7dde51bd..71b28a2c 100644 --- a/packages/module-codegen/src/actionTypeDefs.ts +++ b/packages/module-codegen/src/actionTypeDefs.ts @@ -1,4 +1,5 @@ import { join } from 'path' + import { createFolderIfNotExists, getFiles } from './fileFolder' import { read, write } from './readWrite' diff --git a/packages/module-codegen/src/defaultConfigFile.ts b/packages/module-codegen/src/defaultConfigFile.ts index fc898621..1e8d2bfb 100644 --- a/packages/module-codegen/src/defaultConfigFile.ts +++ b/packages/module-codegen/src/defaultConfigFile.ts @@ -1,4 +1,5 @@ import path from 'path' + import { write } from './readWrite' type TEnumsModuleConfig = { diff --git a/packages/module-codegen/src/fileFolder.ts b/packages/module-codegen/src/fileFolder.ts index ef894a26..3979f1a4 100644 --- a/packages/module-codegen/src/fileFolder.ts +++ b/packages/module-codegen/src/fileFolder.ts @@ -1,6 +1,7 @@ import { existsSync, mkdirSync, readdirSync } from 'fs' import glob from 'glob' import { extname, join } from 'path' + const rootPath = process.cwd() export const getDirectories = (source: string) => { diff --git a/packages/module-codegen/src/index.ts b/packages/module-codegen/src/index.ts index 77d57559..6834a513 100644 --- a/packages/module-codegen/src/index.ts +++ b/packages/module-codegen/src/index.ts @@ -2,6 +2,7 @@ import { Log, logCyan, logGreen, logRed } from '@kitql/helper' import fs from 'fs' import { join, basename, extname } from 'path' import YAML from 'yaml' + import { actionContext } from './actionContexts' import { actionEnum } from './actionEnum' import { actionModuleContext } from './actionModuleContext' diff --git a/packages/template/src/index.ts b/packages/template/src/index.ts index 35a949bb..697a6e48 100644 --- a/packages/template/src/index.ts +++ b/packages/template/src/index.ts @@ -1,6 +1,6 @@ -import YAML from 'yaml' -import path from 'path' import fs from 'fs' +import path from 'path' +import YAML from 'yaml' function sar(str: string, sarObj: Record) { for (const key in sarObj) { diff --git a/packages/vite-plugin-watch-and-run/test/plugins.checkConf.spec.ts b/packages/vite-plugin-watch-and-run/test/plugins.checkConf.spec.ts index 3b1dcb24..d18fce64 100644 --- a/packages/vite-plugin-watch-and-run/test/plugins.checkConf.spec.ts +++ b/packages/vite-plugin-watch-and-run/test/plugins.checkConf.spec.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from 'vitest' + import watchAndRun from '../src' describe('vite-plugin-watch-and-run', () => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b468fb9..02205f77 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,7 @@ importers: '@changesets/cli': 2.24.4 '@theguild/eslint-config': 0.0.2 '@theguild/prettier-config': 0.0.3 + '@trivago/prettier-plugin-sort-imports': ^3.3.1 '@vitest/coverage-c8': ^0.24.3 '@vitest/ui': 0.23.2 bob-the-bundler: 4.0.0 @@ -28,6 +29,7 @@ importers: '@changesets/cli': 2.24.4 '@theguild/eslint-config': 0.0.2_irgkl5vooow2ydyo6aokmferha '@theguild/prettier-config': 0.0.3_prettier@2.7.1 + '@trivago/prettier-plugin-sort-imports': 3.3.1_prettier@2.7.1 '@vitest/coverage-c8': 0.24.3_nfqmtj2i2wbshsdqjmmrigkz7a '@vitest/ui': 0.23.2 bob-the-bundler: 4.0.0_typescript@4.8.3 @@ -352,7 +354,6 @@ packages: dependencies: '@jridgewell/gen-mapping': 0.1.1 '@jridgewell/trace-mapping': 0.3.17 - dev: false /@ardatan/relay-compiler/12.0.0_graphql@15.8.0: resolution: {integrity: sha512-9anThAaj1dQr6IGmzBMcfzOQKTa5artjuPmw8NYK/fiGEMjADbSguBY2FMDykt+QhilR3wc9VA/3yVju7JHg7Q==} @@ -401,7 +402,6 @@ packages: /@babel/compat-data/7.19.4: resolution: {integrity: sha512-CHIGpJcUQ5lU9KrPHTjBMhVwQG6CQjxfg36fGXl3qk/Gik1WwWachaXFuo0uCWJT/mStOKtcbFJCaVLihC1CMw==} engines: {node: '>=6.9.0'} - dev: false /@babel/core/7.12.9: resolution: {integrity: sha512-gTXYh3M5wb7FRXQy+FErKFAv90BnlOuNn1QkCK2lREoPAjrQCO49+HVSrFoe5uakFAF5eenS75KbO2vQiLrTMQ==} @@ -428,6 +428,29 @@ packages: dev: true optional: true + /@babel/core/7.17.8: + resolution: {integrity: sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ==} + engines: {node: '>=6.9.0'} + dependencies: + '@ampproject/remapping': 2.2.0 + '@babel/code-frame': 7.18.6 + '@babel/generator': 7.19.5 + '@babel/helper-compilation-targets': 7.19.3_@babel+core@7.17.8 + '@babel/helper-module-transforms': 7.19.0 + '@babel/helpers': 7.19.4 + '@babel/parser': 7.19.4 + '@babel/template': 7.18.10 + '@babel/traverse': 7.19.4 + '@babel/types': 7.19.4 + convert-source-map: 1.9.0 + debug: 4.3.4 + gensync: 1.0.0-beta.2 + json5: 2.2.1 + semver: 6.3.0 + transitivePeerDependencies: + - supports-color + dev: true + /@babel/core/7.19.3: resolution: {integrity: sha512-WneDJxdsjEvyKtXKsaBGbDeiyOjR5vYq4HcShxnIbG0qixpoHjI3MqeZM9NDvsojNCEBItQE4juOo/bU6e72gQ==} engines: {node: '>=6.9.0'} @@ -451,6 +474,15 @@ packages: - supports-color dev: false + /@babel/generator/7.17.7: + resolution: {integrity: sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.19.4 + jsesc: 2.5.2 + source-map: 0.5.7 + dev: true + /@babel/generator/7.19.5: resolution: {integrity: sha512-DxbNz9Lz4aMZ99qPpO1raTbcrI1ZeYh+9NR9qhfkQIbFtVEqotHojEBxHzmxhVONkGt6VyrqVQcgpefMy9pqcg==} engines: {node: '>=6.9.0'} @@ -466,6 +498,19 @@ packages: '@babel/types': 7.19.4 dev: false + /@babel/helper-compilation-targets/7.19.3_@babel+core@7.17.8: + resolution: {integrity: sha512-65ESqLGyGmLvgR0mst5AdW1FkNlj9rQsCKduzEoEPhBCDFGXvz2jW6bXFG6i0/MrV2s7hhXjjb2yAzcPuQlLwg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + dependencies: + '@babel/compat-data': 7.19.4 + '@babel/core': 7.17.8 + '@babel/helper-validator-option': 7.18.6 + browserslist: 4.21.4 + semver: 6.3.0 + dev: true + /@babel/helper-compilation-targets/7.19.3_@babel+core@7.19.3: resolution: {integrity: sha512-65ESqLGyGmLvgR0mst5AdW1FkNlj9rQsCKduzEoEPhBCDFGXvz2jW6bXFG6i0/MrV2s7hhXjjb2yAzcPuQlLwg==} engines: {node: '>=6.9.0'} @@ -601,7 +646,6 @@ packages: /@babel/helper-validator-option/7.18.6: resolution: {integrity: sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==} engines: {node: '>=6.9.0'} - dev: false /@babel/helpers/7.19.4: resolution: {integrity: sha512-G+z3aOx2nfDHwX/kyVii5fJq+bgscg89/dJNWpYeKeBv3v9xX8EIabmx1k6u9LS04H7nROFVRVK+e3k0VHp+sw==} @@ -621,6 +665,14 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 + /@babel/parser/7.18.9: + resolution: {integrity: sha512-9uJveS9eY9DJ0t64YbIBZICtJy8a5QrDEVdiLCG97fVLpDTpGX7t8mMSb6OWw6Lrnjqj4O8zwjELX3dhoMgiBg==} + engines: {node: '>=6.0.0'} + hasBin: true + dependencies: + '@babel/types': 7.19.4 + dev: true + /@babel/parser/7.19.4: resolution: {integrity: sha512-qpVT7gtuOLjWeDTKLkJ6sryqLliBaFpAtGeqw5cs5giLldvh+Ch0plqnUMKoVAUS6ZEueQQiZV+p5pxtPitEsA==} engines: {node: '>=6.0.0'} @@ -985,6 +1037,24 @@ packages: '@babel/parser': 7.19.4 '@babel/types': 7.19.4 + /@babel/traverse/7.17.3: + resolution: {integrity: sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/code-frame': 7.18.6 + '@babel/generator': 7.19.5 + '@babel/helper-environment-visitor': 7.18.9 + '@babel/helper-function-name': 7.19.0 + '@babel/helper-hoist-variables': 7.18.6 + '@babel/helper-split-export-declaration': 7.18.6 + '@babel/parser': 7.19.4 + '@babel/types': 7.19.4 + debug: 4.3.4 + globals: 11.12.0 + transitivePeerDependencies: + - supports-color + dev: true + /@babel/traverse/7.19.4: resolution: {integrity: sha512-w3K1i+V5u2aJUOXBFFC5pveFLmtq1s3qcdDNC2qRI6WPBQIDaKFqXxDEqDO/h1dQ3HjsZoZMyIy6jGLq0xtw+g==} engines: {node: '>=6.9.0'} @@ -1002,6 +1072,14 @@ packages: transitivePeerDependencies: - supports-color + /@babel/types/7.17.0: + resolution: {integrity: sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-validator-identifier': 7.19.1 + to-fast-properties: 2.0.0 + dev: true + /@babel/types/7.19.4: resolution: {integrity: sha512-M5LK7nAeS6+9j7hAq+b3fQs+pNfUtTGq+yFFfHnauFA8zQtLRfmuipmsKDKKLuyG+wC8ABW43A153YNawNTEtw==} engines: {node: '>=6.9.0'} @@ -1981,7 +2059,6 @@ packages: dependencies: '@jridgewell/set-array': 1.1.2 '@jridgewell/sourcemap-codec': 1.4.14 - dev: false /@jridgewell/gen-mapping/0.3.2: resolution: {integrity: sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==} @@ -2900,6 +2977,23 @@ packages: resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} engines: {node: '>= 10'} + /@trivago/prettier-plugin-sort-imports/3.3.1_prettier@2.7.1: + resolution: {integrity: sha512-ITGspeOlFnK1dwJVjqOguGW3Ja8hakxOPFudhpP0YfsDHT0yM0u4TU+62Vl83hCatnhB4+fYhlSZyiifUv4xSg==} + peerDependencies: + prettier: 2.x + dependencies: + '@babel/core': 7.17.8 + '@babel/generator': 7.17.7 + '@babel/parser': 7.18.9 + '@babel/traverse': 7.17.3 + '@babel/types': 7.17.0 + javascript-natural-sort: 0.7.1 + lodash: 4.17.21 + prettier: 2.7.1 + transitivePeerDependencies: + - supports-color + dev: true + /@trysound/sax/0.2.0: resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==} engines: {node: '>=10.13.0'} @@ -7649,6 +7743,10 @@ packages: istanbul-lib-report: 3.0.0 dev: true + /javascript-natural-sort/0.7.1: + resolution: {integrity: sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==} + dev: true + /joycon/3.1.1: resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} engines: {node: '>=10'} @@ -10769,7 +10867,6 @@ packages: resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==} engines: {node: '>=0.10.0'} dev: true - optional: true /source-map/0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} diff --git a/vite.config.ts b/vite.config.ts index 5d4a0d26..83b82c0f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,6 @@ /// -import { defineConfig } from 'vitest/config' import { resolve } from 'path' +import { defineConfig } from 'vitest/config' export default defineConfig({ test: { diff --git a/website/scripts/algolia-ci.mjs b/website/scripts/algolia-ci.mjs index 8e3cdee3..1b7f8019 100644 --- a/website/scripts/algolia-ci.mjs +++ b/website/scripts/algolia-ci.mjs @@ -1,5 +1,5 @@ -import { resolve } from 'node:path' import { indexToAlgolia } from '@theguild/algolia' +import { resolve } from 'node:path' const CWD = process.cwd() diff --git a/website/src/components/index-page.tsx b/website/src/components/index-page.tsx index 03445531..3ca8fd02 100644 --- a/website/src/components/index-page.tsx +++ b/website/src/components/index-page.tsx @@ -1,4 +1,5 @@ import { FeatureList, HeroGradient, NPMBadge } from '@theguild/components' + import houdini_kitql from '../../public/assets/houdini-kitql.png' import graphql from '../../public/assets/logos/graphql.png' import houdini from '../../public/assets/logos/houdini.png' diff --git a/website/src/pages/_app.tsx b/website/src/pages/_app.tsx index 7ed0533e..2499af07 100644 --- a/website/src/pages/_app.tsx +++ b/website/src/pages/_app.tsx @@ -1,5 +1,5 @@ -import { AppProps } from 'next/app' import '@theguild/components/style.css' +import { AppProps } from 'next/app' export default function App({ Component, pageProps }: AppProps) { return diff --git a/website/src/pages/docs/extra/migrating-to-0.7.0.mdx b/website/src/pages/docs/extra/migrating-to-0.7.0.mdx index 15f883fb..0f97d4c9 100644 --- a/website/src/pages/docs/extra/migrating-to-0.7.0.mdx +++ b/website/src/pages/docs/extra/migrating-to-0.7.0.mdx @@ -71,6 +71,7 @@ After: ```ts filename="page.ts" import { load_FirstQuery } from '$houdini' + import type { Load } from './$types' export const load: Load = async event => { diff --git a/website/src/pages/docs/setup/02_server.mdx b/website/src/pages/docs/setup/02_server.mdx index b89bed53..62a43857 100644 --- a/website/src/pages/docs/setup/02_server.mdx +++ b/website/src/pages/docs/setup/02_server.mdx @@ -44,9 +44,10 @@ This is the file where you will create your kitQL Server. To start, it should lo ```ts import type { RequestEvent } from '@sveltejs/kit' -import { kitQLModules } from './kitQLModules' + // This should be fully generated 🥳 import { modules } from './$kitql/_appModules' +import { kitQLModules } from './kitQLModules' const plugins = [] plugins.push(kitQLModules(modules)) diff --git a/website/src/pages/docs/setup/03_vite-plugin-watch-and-run.mdx b/website/src/pages/docs/setup/03_vite-plugin-watch-and-run.mdx index a9490533..a57fed5f 100644 --- a/website/src/pages/docs/setup/03_vite-plugin-watch-and-run.mdx +++ b/website/src/pages/docs/setup/03_vite-plugin-watch-and-run.mdx @@ -18,8 +18,8 @@ Add `watchAndRun` plugin with the following configuration: - `run`: a command to trigger when a file change is detected (You can be very creative 🥳!) ```js filename="vite.config.js" -import watchAndRun from 'vite-plugin-watch-and-run' import path from 'path' +import watchAndRun from 'vite-plugin-watch-and-run' /** @type {import('vite').UserConfig} */ const config = {