From 45459129367f5774af4534e667f56bb4099c33e9 Mon Sep 17 00:00:00 2001 From: Siddharth Suresh Date: Fri, 4 Nov 2022 22:02:45 +0530 Subject: [PATCH] Include resolvers in `src` in blitz console (#3933) * optimse only-db flag and add src directory to find resolvers in console * default parameter --- .changeset/stale-parents-yawn.md | 5 +++ packages/blitz/src/cli/utils/next-console.ts | 40 ++++++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 .changeset/stale-parents-yawn.md diff --git a/.changeset/stale-parents-yawn.md b/.changeset/stale-parents-yawn.md new file mode 100644 index 0000000000..ae92a8d334 --- /dev/null +++ b/.changeset/stale-parents-yawn.md @@ -0,0 +1,5 @@ +--- +"blitz": patch +--- + +Include resolvers in `src` directory in blitz console diff --git a/packages/blitz/src/cli/utils/next-console.ts b/packages/blitz/src/cli/utils/next-console.ts index 5d6842e2c5..613ec8738f 100644 --- a/packages/blitz/src/cli/utils/next-console.ts +++ b/packages/blitz/src/cli/utils/next-console.ts @@ -71,32 +71,30 @@ export const forceRequire = (modulePath: string) => { } } -export async function getBlitzModulePaths() { +export async function getBlitzModulePaths(onlyDb = false) { const projectRoot = getProjectRootSync() - const {globby} = await import("globby") - const paths = await globby( - [ - "app/**/{queries,mutations}/**/*.{js,ts,tsx}", - "utils/*.{js,ts,tsx}", - "jobs/**/*.{js,ts,tsx}", - "integrations/**/*.{js,ts,tsx}", - "!**/*.test.*", - "!**/*.spec.*", - ], - {cwd: projectRoot, gitignore: true}, - ) - paths.push(getDbFolder()) - debug("Paths", paths) - + const paths = [getDbFolder()] + if (!onlyDb) { + const {globby} = await import("globby") + paths.push( + ...(await globby( + [ + "{app,src}/**/{queries,mutations}/**/*.{js,ts,tsx}", + "utils/*.{js,ts,tsx}", + "jobs/**/*.{js,ts,tsx}", + "integrations/**/*.{js,ts,tsx}", + "!**/*.test.*", + "!**/*.spec.*", + ], + {cwd: projectRoot, gitignore: true}, + )), + ) + } return [...paths.map((p: string) => path.join(projectRoot, p))] } export const loadBlitz = async (onlyDb: boolean, module = "") => { - let paths = await getBlitzModulePaths() - - if (onlyDb) { - paths = paths.filter((p) => p.includes(getDbFolder())) - } + let paths = await getBlitzModulePaths(onlyDb) if (module) { paths = paths.filter((p) => module.includes(p) || p.includes(module))