@graphitation/cli
Advanced tools
Comparing version 1.12.1 to 1.13.0
# Change Log - @graphitation/cli | ||
<!-- This log was last generated on Thu, 24 Oct 2024 13:14:46 GMT and should not be manually modified. --> | ||
<!-- This log was last generated on Wed, 30 Oct 2024 09:40:54 GMT and should not be manually modified. --> | ||
<!-- Start content --> | ||
## 1.13.0 | ||
Wed, 30 Oct 2024 09:40:54 GMT | ||
### Patches | ||
- Bump @graphitation/ts-codegen to v2.13.0-alpha.1 | ||
### Changes | ||
- metadata written to a file and tests fixed (77059398+vejrj@users.noreply.github.com) | ||
## 1.12.1 | ||
Thu, 24 Oct 2024 13:14:46 GMT | ||
Thu, 24 Oct 2024 13:15:11 GMT | ||
@@ -11,0 +23,0 @@ ### Patches |
@@ -80,12 +80,9 @@ "use strict"; | ||
"from where to import context" | ||
).option( | ||
"-cm, --context-mapping-file [contextMappingFile]", | ||
"context mapping file" | ||
).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( | ||
"--use-string-unions-instead-of-enums", | ||
"When this flag is set, then enums are replaced by string unions." | ||
).option("--generate-only-enums", "Generate only enum file").option("--scope [scope]", "generate models only for scope").option( | ||
"--enum-migration-json-file [enumMigrationJsonFile]", | ||
"File containing array of enum names, which should be migrated to string unions" | ||
).option( | ||
"--enum-migration-exceptions-json-file [enumMigrationExceptionsJsonFile]", | ||
"File containing array of enum names, which should remain typescript enums" | ||
).description("generate interfaces and models").action( | ||
).option("--generate-only-enums", "Generate only enum file").option("--scope [scope]", "generate models only for scope").description("generate interfaces and models").action( | ||
(inputs, options) => __async(this, null, function* () { | ||
@@ -135,33 +132,19 @@ yield generateInterfaces(getFiles(inputs), options); | ||
); | ||
let enumNamesToMigrate; | ||
let enumNamesToKeep; | ||
if (options.enumMigrationJsonFile) { | ||
const content2 = JSON.parse( | ||
yield import_promises.default.readFile( | ||
import_path.default.join(process.cwd(), options.enumMigrationJsonFile), | ||
{ | ||
encoding: "utf-8" | ||
} | ||
) | ||
); | ||
if (!Array.isArray(content2)) { | ||
throw new Error("enumMigrationJsonFile doesn't contain an array"); | ||
const { contextMappingFile } = options; | ||
let contextMappingContent = null; | ||
let fullContextMappingFilePath; | ||
if (contextMappingFile) { | ||
if (import_path.default.isAbsolute(contextMappingFile)) { | ||
fullContextMappingFilePath = contextMappingFile; | ||
} else { | ||
fullContextMappingFilePath = import_path.default.join( | ||
process.cwd(), | ||
contextMappingFile | ||
); | ||
} | ||
enumNamesToMigrate = content2; | ||
} | ||
if (options.enumMigrationExceptionsJsonFile) { | ||
const content2 = JSON.parse( | ||
yield import_promises.default.readFile( | ||
import_path.default.join(process.cwd(), options.enumMigrationExceptionsJsonFile), | ||
{ | ||
encoding: "utf-8" | ||
} | ||
) | ||
); | ||
if (!Array.isArray(content2)) { | ||
throw new Error( | ||
"enumMigrationExceptionsJsonFile doesn't contain an array" | ||
if (import_fs.default.existsSync(fullContextMappingFilePath)) { | ||
contextMappingContent = JSON.parse( | ||
yield import_promises.default.readFile(fullContextMappingFilePath, { encoding: "utf-8" }) | ||
); | ||
} | ||
enumNamesToKeep = content2; | ||
} | ||
@@ -178,5 +161,4 @@ const result = (0, import_ts_codegen.generateTS)(document, { | ||
generateOnlyEnums: !!options.generateOnlyEnums, | ||
enumNamesToMigrate, | ||
enumNamesToKeep, | ||
modelScope: options.scope || null | ||
modelScope: options.scope || null, | ||
contextMappingContent | ||
}); | ||
@@ -192,2 +174,11 @@ yield import_promises.default.mkdir(outputPath, { recursive: true }); | ||
); | ||
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 +185,0 @@ } |
{ | ||
"name": "@graphitation/cli", | ||
"license": "MIT", | ||
"version": "1.12.1", | ||
"version": "1.13.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-alpha.1", | ||
"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
46401
407