@graphitation/cli
Advanced tools
Comparing version 1.13.1 to 1.14.0
# Change Log - @graphitation/cli | ||
<!-- This log was last generated on Wed, 30 Oct 2024 12:58:08 GMT and should not be manually modified. --> | ||
<!-- This log was last generated on Fri, 22 Nov 2024 09:11:08 GMT and should not be manually modified. --> | ||
<!-- Start content --> | ||
## 1.14.0 | ||
Fri, 22 Nov 2024 09:11:08 GMT | ||
### Minor changes | ||
- Context type generation re-worked (77059398+vejrj@users.noreply.github.com) | ||
- Bump @graphitation/ts-codegen to v2.13.0 | ||
## 1.13.1 | ||
Wed, 30 Oct 2024 12:58:08 GMT | ||
Wed, 30 Oct 2024 12:58:29 GMT | ||
@@ -11,0 +20,0 @@ ### Patches |
@@ -78,5 +78,17 @@ "use strict"; | ||
).option( | ||
"-ci, --context-import [contextImport]", | ||
"-ci, --context-type-path [contextTypePath]", | ||
"from where to import context" | ||
).option("-cn, --context-name [contextName]", "Context name").option("-ei, --enums-import [enumsImport]", "from where to import enums").option("-l, --legacy", "generate legacy types").option("--legacy-models", "do not use models for object types").option( | ||
).option("-cn, --context-type-name [contextTypeName]", "Context type name").option( | ||
"-dcp, --default-context-sub-type-path [defaultContextSubTypePath]", | ||
"From where the default context type will be exported" | ||
).option( | ||
"-dcn, --default-context-sub-type-name [defaultContextSubTypeName]", | ||
"Default context type which will extend context sub type" | ||
).option( | ||
"-cnt, --context-sub-type-name-template [contextSubTypeNameTemplate]", | ||
"context resource name template. You need to specify ${resourceName} in the parameter eg. `${resourceName}Context`" | ||
).option( | ||
"-cpt, --context-sub-type-path-template [contextSubTypePathTemplate]", | ||
"context resource path template. You need to specify ${resourceName} in the parameter eg. `@package/preffix-${resourceName}-suffix`" | ||
).option("-ei, --enums-import [enumsImport]", "from where to import enums").option("-l, --legacy", "generate legacy types").option("--legacy-models", "do not use models for object types").option( | ||
"--use-string-unions-instead-of-enums", | ||
@@ -106,10 +118,10 @@ "When this flag is set, then enums are replaced by string unions." | ||
} | ||
function getContextPath(outputDir, contextImport) { | ||
if (!contextImport) { | ||
function getContextPath(outputDir, contextTypePath) { | ||
if (!contextTypePath) { | ||
return; | ||
} | ||
if (!contextImport.startsWith(".")) { | ||
return contextImport; | ||
if (!contextTypePath.startsWith(".")) { | ||
return contextTypePath; | ||
} | ||
const contextDir = import_path.default.join(process.cwd(), contextImport); | ||
const contextDir = import_path.default.join(process.cwd(), contextTypePath); | ||
return import_path.default.relative(outputDir, contextDir).split(import_path.default.sep).join(import_path.default.posix.sep); | ||
@@ -171,4 +183,11 @@ } | ||
documentPath: fullPath, | ||
contextImport: getContextPath(outputPath, options.contextImport) || null, | ||
contextName: options.contextName, | ||
contextTypePath: getContextPath(outputPath, options.contextTypePath) || null, | ||
contextTypeName: options.contextTypeName, | ||
contextSubTypeNameTemplate: options.contextSubTypeNameTemplate, | ||
contextSubTypePathTemplate: options.contextSubTypePathTemplate, | ||
defaultContextSubTypePath: getContextPath( | ||
outputPath, | ||
options.defaultContextSubTypePath | ||
), | ||
defaultContextSubTypeName: options.defaultContextSubTypeName, | ||
enumsImport: getContextPath(outputPath, options.enumsImport) || null, | ||
@@ -192,2 +211,11 @@ legacyCompat: !!options.legacy, | ||
); | ||
if (result.contextMappingOutput) { | ||
outputs.push( | ||
import_promises.default.writeFile( | ||
import_path.default.join(outputPath, "schema-context-mapping-metadata.json"), | ||
JSON.stringify(result.contextMappingOutput, null, 2), | ||
{ encoding: "utf-8" } | ||
) | ||
); | ||
} | ||
yield Promise.all(outputs); | ||
@@ -194,0 +222,0 @@ } |
{ | ||
"name": "@graphitation/cli", | ||
"license": "MIT", | ||
"version": "1.13.1", | ||
"version": "1.14.0", | ||
"bin": { | ||
@@ -27,3 +27,3 @@ "supermassive": "./bin/supermassive.js" | ||
"@graphitation/supermassive-extractors": "^2.2.5", | ||
"@graphitation/ts-codegen": "^2.12.1", | ||
"@graphitation/ts-codegen": "^2.13.0", | ||
"commander": "^8.3.0", | ||
@@ -30,0 +30,0 @@ "fast-glob": "^3.2.12", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
54768
481