graphql-codegen-modules-gen
Advanced tools
Comparing version 1.5.1 to 1.6.1
{ | ||
"name": "graphql-codegen-modules-gen", | ||
"version": "1.5.1", | ||
"version": "1.6.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -69,14 +69,6 @@ # Welcome to graphql-codegen-modules-gen 🔥 | ||
### ▶ (Bonus) Execute it after your usual @graphql-codegen | ||
### ▶ (Bonus) Execute it before your usual @graphql-codegen | ||
At the end of your `codegen.yml` file, add (carefull, like this, you don't see logs.): | ||
with a pre hook. | ||
``` | ||
hooks: | ||
afterAllFileWrite: | ||
- yarn gen-mg | ||
``` | ||
or with a post hook. | ||
## ✨ Result | ||
@@ -155,1 +147,3 @@ | ||
**Merge 3/** Generate global `_appModules.ts` (merge all `index.ts` of each modules) | ||
**Merge 4/** Generate global `_urqlCache.ts` (merge all `_urqlCacheXXX.ts` of each modules) |
@@ -184,2 +184,3 @@ import { | ||
let ctxModules = []; | ||
let urqlCacheModules = []; | ||
const moduleNames = getDirectories(modulePath); | ||
@@ -293,9 +294,17 @@ moduleNames.forEach((moduleName) => { | ||
}); | ||
/******************* */ | ||
/* 5.1/ ctxModules */ | ||
/******************* */ | ||
// Are there files starting by _urqlCache? file to add in the global _urqlCacheModules.ts file? | ||
providersFiles.forEach((providerFile) => { | ||
if (providerFile.startsWith("_urqlCache")) { | ||
const urqlCacheName = providerFile | ||
.replace("_urqlCache", "") | ||
.replace(".ts", ""); | ||
urqlCacheModules.push({ moduleName, urqlCacheName }); | ||
} | ||
}); | ||
}); | ||
// console.log( | ||
// ` ${getGreen("✔")} Merge done`, | ||
// `[${getGreen(moduleNames.length)} modules]` | ||
// ); | ||
/******************* */ | ||
@@ -336,3 +345,3 @@ /* 3.2/ _ctxModules */ | ||
pad(ctxModules.length, 2) | ||
)} contexts in ${getGreen("_gen/_ctxModules.ts")} for`, | ||
)} contexts in ${getGreen("_gen/_ctxModules.ts")} for`, | ||
`[${ctxModules | ||
@@ -370,5 +379,48 @@ .map((c) => getGreen(c.moduleName + "#" + c.ctxName)) | ||
pad(moduleNames.length, 2) | ||
)} modules in ${getGreen("_gen/_appModules.ts")} for`, | ||
)} modules in ${getGreen("_gen/_appModules.ts")} for`, | ||
`[${moduleNames.map((c) => getGreen(c)).join(",")}]` | ||
); | ||
/******************* */ | ||
/* 5.2/ _urqlCacheModules */ | ||
/******************* */ | ||
let dataUrqlCacheModules = []; | ||
urqlCacheModules.forEach((urqlCache) => { | ||
dataUrqlCacheModules.push( | ||
`import { urqlCache${toPascalCase( | ||
urqlCache.urqlCacheName | ||
)} } from '$lib/modules/${ | ||
urqlCache.moduleName | ||
}/providers/_urqlCache${toPascalCase(urqlCache.urqlCacheName)}';` | ||
); | ||
}); | ||
dataUrqlCacheModules.push(``); | ||
dataUrqlCacheModules.push(`export const urqlCacheModules = {`); | ||
urqlCacheModules.forEach((urqlCache) => { | ||
dataUrqlCacheModules.push( | ||
` ...urqlCache${toPascalCase(urqlCache.urqlCacheName)},` | ||
); | ||
}); | ||
dataUrqlCacheModules.push(`}`); | ||
createFolderIfNotExists(join(modulePath, "../graphql", genFolder)); | ||
writeFileSync( | ||
join(modulePath, "../graphql", genFolder, "_urqlCacheModules.ts"), | ||
dataUrqlCacheModules.join("\r\n"), | ||
(err) => { | ||
console.error(err); | ||
} | ||
); | ||
console.log( | ||
` ${getGreen("✔")} Merge 5/ ${getGreen( | ||
pad(urqlCacheModules.length, 2) | ||
)} urqlCache in ${getGreen("_gen/_urqlCacheModules.ts")} for`, | ||
`[${urqlCacheModules | ||
.map((c) => getGreen(c.moduleName + "#" + c.urqlCacheName)) | ||
.join(",")}]` | ||
); | ||
} else { | ||
@@ -375,0 +427,0 @@ console.error(`❌ '${modulePath}' is not a valid folder path`); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30796
788
148