From 91796341e7a64c7e227b09af90e85665aca977fa Mon Sep 17 00:00:00 2001 From: Rodrigo Cesar Date: Fri, 29 Jul 2022 14:06:59 -0300 Subject: [PATCH 1/2] Create config property "omitFilePathComment" Some people want to avoid polluting the code with unnecessary comments. --- README.md | 1 + converter.js | 8 ++++++-- index.js | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 92371d3..4d90798 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ $ npm install --save csharp-models-to-typescript "locale": "en-US" }, "numericEnums": false, + "omitFilePathComment": false, "stringLiteralTypesInsteadOfEnums": false, "customTypeTranslations": { "ProductName": "string", diff --git a/converter.js b/converter.js index ca44af0..126af06 100644 --- a/converter.js +++ b/converter.js @@ -67,7 +67,9 @@ const createConverter = config => { const members = [...(model.Fields || []), ...(model.Properties || [])]; const baseClasses = model.BaseClasses && model.BaseClasses.length ? ` extends ${model.BaseClasses.join(', ')}` : ''; - rows.push(`// ${filename}`); + if (!config.omitFilePathComment) { + rows.push(`// ${filename}`); + } rows.push(`export interface ${model.ModelName}${baseClasses} {`); if (model.IndexSignature) { @@ -85,7 +87,9 @@ const createConverter = config => { const convertEnum = (enum_, filename) => { const rows = []; - rows.push(`// ${filename}`); + if (!config.omitFilePathComment) { + rows.push(`// ${filename}`); + } const entries = Object.entries(enum_.Values); diff --git a/index.js b/index.js index 934ed05..13fc549 100755 --- a/index.js +++ b/index.js @@ -37,6 +37,7 @@ const converter = createConverter({ camelCaseOptions: config.camelCaseOptions || {}, camelCaseEnums: config.camelCaseEnums || false, numericEnums: config.numericEnums || false, + omitFilePathComment: config.omitFilePathComment || false, stringLiteralTypesInsteadOfEnums: config.stringLiteralTypesInsteadOfEnums || false }); From cda53a001e65f8d5daac620d069b62d5daa9e5f0 Mon Sep 17 00:00:00 2001 From: Jonathan Svenheden Date: Wed, 17 Aug 2022 10:40:47 +0200 Subject: [PATCH 2/2] Bump the minor version --- package-lock.json | 31 +++++++++++++++++++++++++++++-- package.json | 2 +- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e748d8c..a8844ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,35 @@ { "name": "csharp-models-to-typescript", - "version": "0.21.1", - "lockfileVersion": 1, + "version": "0.22.0", + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "csharp-models-to-typescript", + "version": "0.22.0", + "license": "MIT", + "dependencies": { + "camelcase": "^6.0.0" + }, + "bin": { + "csharp-models-to-typescript": "index.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/camelcase": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.0.0.tgz", + "integrity": "sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + }, "dependencies": { "camelcase": { "version": "6.0.0", diff --git a/package.json b/package.json index e0fd394..12a03cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "csharp-models-to-typescript", - "version": "0.21.1", + "version": "0.22.0", "title": "C# models to TypeScript", "author": "Jonathan Svenheden ", "license": "MIT",