Skip to content

Commit

Permalink
Include resolvers in src in blitz console (#3933)
Browse files Browse the repository at this point in the history
* optimse only-db flag and add src directory to find resolvers in console

* default parameter
  • Loading branch information
siddhsuresh authored Nov 4, 2022
1 parent 55a43ce commit 4545912
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-parents-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"blitz": patch
---

Include resolvers in `src` directory in blitz console
40 changes: 19 additions & 21 deletions packages/blitz/src/cli/utils/next-console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4545912

Please sign in to comment.