diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 81e6483..94c43ea 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -4,6 +4,7 @@ module.exports = { 'plugin:prettier/recommended', 'plugin:import/recommended', 'plugin:markdown/recommended', + 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', ], plugins: ['@typescript-eslint', 'prettier', 'import', 'html', 'markdown'], @@ -17,11 +18,18 @@ module.exports = { ecmaVersion: 'latest', sourceType: 'module', }, - ignorePatterns: ['output', 'outputTest', '**/*d.ts'], + ignorePatterns: ['output', 'outputTest', 'dist'], rules: { '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }], indent: ['error', 'tab', { SwitchCase: 1 }], }, + settings: { + 'import/resolver': { + node: { + extensions: ['.js', '.jsx', '.ts', '.tsx'], + }, + }, + }, overrides: [ { files: ['**/*.cjs'], diff --git a/README.md b/README.md index 8c27724..b89eb77 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ npm i @sngular/openapi-nodejs-cli --global ### 🧑🏻‍💻 Usage ```bash -npx openapi-nodejs-cli input/schema.yaml +npx openapi-nodejs-cli -i input/schema.yaml ``` You can retrieve an option list with this command: diff --git a/package.json b/package.json index 5c284ae..d61a86e 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,10 @@ ], "license": "Mozilla Public License 2.0", "type": "commonjs", - "main": "src/index.js", - "bin": "src/index.js", + "main": "dist/index.js", + "bin": "dist/index.js", "files": [ - "src/**/*.{d.ts,d.ts.map,js,js.map}", + "dist", "LICENSE", "README.md", "CHANGELOG.md", @@ -24,10 +24,12 @@ "scripts": { "test": "jest", "coverage": "jest --coverage", - "clean": "rm -rf output", + "clean": "rm -rf output outputTest dist", "build": "tsc", + "postbuild": "cp -r ./src/templates ./dist", "postprepare": "npm run build", - "start": "node ./index.js", + "prestart": "npm run build", + "start": "node .", "lint": "npm run lint:prettier && npm run lint:eslint", "lint:eslint": "eslint --ext .ts .", "lint:prettier": "prettier --list-different \"**/*.ts\" || (echo '↑↑ these files are not prettier formatted ↑↑' && exit 1)", diff --git a/src/tests/helpers/capitalize.spec.ts b/src/tests/helpers/capitalize.spec.ts index 00ee0f2..11180d2 100644 --- a/src/tests/helpers/capitalize.spec.ts +++ b/src/tests/helpers/capitalize.spec.ts @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { capitalize } from '../../helpers/capitalize.js'; +import { capitalize } from '../../helpers/capitalize'; describe('capitalize()', () => { describe('passing "name"', () => { diff --git a/src/tests/helpers/divideIntoDocumentsByTag.spec.ts b/src/tests/helpers/divideIntoDocumentsByTag.spec.ts index d7aa1a7..43fa37c 100644 --- a/src/tests/helpers/divideIntoDocumentsByTag.spec.ts +++ b/src/tests/helpers/divideIntoDocumentsByTag.spec.ts @@ -3,10 +3,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { DataObjectWith2Tags } from '../mocks/DataObjectWith2Tags.js'; -import { DataObjectWithoutTags } from '../mocks/DataObjectWithoutTags.js'; +import { DataObjectWith2Tags } from '../mocks/DataObjectWith2Tags'; +import { DataObjectWithoutTags } from '../mocks/DataObjectWithoutTags'; -import { divideIntoDocumentsByTag } from '../../helpers/divideIntoDocumentsByTag.js'; +import { divideIntoDocumentsByTag } from '../../helpers/divideIntoDocumentsByTag'; describe('divideIntoDocumentsByTag()', () => { describe('passing sample DataObject with 2 different tags', () => { diff --git a/src/tests/helpers/getComponentPath.spec.ts b/src/tests/helpers/getComponentPath.spec.ts index 72edfcb..5c1384f 100644 --- a/src/tests/helpers/getComponentPath.spec.ts +++ b/src/tests/helpers/getComponentPath.spec.ts @@ -4,7 +4,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { getComponentPath } from '../../helpers/getComponentPath.js'; +import { getComponentPath } from '../../helpers/getComponentPath'; describe('getComponentPath()', () => { describe('when $ref has no schema', () => { diff --git a/src/tests/helpers/getComponentsFiles.spec.ts b/src/tests/helpers/getComponentsFiles.spec.ts index d34d16a..74024b0 100644 --- a/src/tests/helpers/getComponentsFiles.spec.ts +++ b/src/tests/helpers/getComponentsFiles.spec.ts @@ -5,7 +5,7 @@ */ import axios, { AxiosRequestConfig } from 'axios'; import fs, { PathOrFileDescriptor } from 'node:fs'; -import { getComponentsFiles } from '../../helpers/getComponentsFiles.js'; +import { getComponentsFiles } from '../../helpers/getComponentsFiles'; describe('getComponentsFiles()', () => { describe('passing an URL', () => { diff --git a/src/tests/helpers/hasRepeatedOperationIdErrors.spec.ts b/src/tests/helpers/hasRepeatedOperationIdErrors.spec.ts index c84aa82..b9dde42 100644 --- a/src/tests/helpers/hasRepeatedOperationIdErrors.spec.ts +++ b/src/tests/helpers/hasRepeatedOperationIdErrors.spec.ts @@ -3,9 +3,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { DocumentListWithNoRepeatedOperationIds } from '../mocks/DocumentListWithNoRepeatedOperationIds.js'; -import { DocumentListWithRepeatedOperationIds } from '../mocks/DocumentListWithRepeatedOperationIds.js'; -import { hasRepeatedOperationIdErrors } from '../../helpers/hasRepeatedOperationIdErrors.js'; +import { DocumentListWithNoRepeatedOperationIds } from '../mocks/DocumentListWithNoRepeatedOperationIds'; +import { DocumentListWithRepeatedOperationIds } from '../mocks/DocumentListWithRepeatedOperationIds'; +import { hasRepeatedOperationIdErrors } from '../../helpers/hasRepeatedOperationIdErrors'; describe('checkRepeatedOperationIdErrors()', () => { describe('passing sample DataObject without repeated operationIds', () => { diff --git a/src/tests/helpers/isUrl.spec.ts b/src/tests/helpers/isUrl.spec.ts index 9c32fd0..831c639 100644 --- a/src/tests/helpers/isUrl.spec.ts +++ b/src/tests/helpers/isUrl.spec.ts @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { isUrl } from '../../helpers/isUrl.js'; +import { isUrl } from '../../helpers/isUrl'; describe('isUrl()', () => { describe('passing http url', () => { diff --git a/src/tests/helpers/log.spec.ts b/src/tests/helpers/log.spec.ts index d948e39..3ffbfd5 100644 --- a/src/tests/helpers/log.spec.ts +++ b/src/tests/helpers/log.spec.ts @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { log } from '../../helpers/log.js'; +import { log } from '../../helpers/log'; describe('log()', () => { it('console.log has been called', () => { diff --git a/src/tests/helpers/parseTypes.spec.ts b/src/tests/helpers/parseTypes.spec.ts index 36d4b0e..87af98e 100644 --- a/src/tests/helpers/parseTypes.spec.ts +++ b/src/tests/helpers/parseTypes.spec.ts @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { parseTypes } from '../../helpers/parseTypes.js'; +import { parseTypes } from '../../helpers/parseTypes'; describe('parseTypes()', () => { describe('references to a component', () => { diff --git a/src/tests/helpers/resolveSchemaName.spec.ts b/src/tests/helpers/resolveSchemaName.spec.ts index ed61d8c..df3e51c 100644 --- a/src/tests/helpers/resolveSchemaName.spec.ts +++ b/src/tests/helpers/resolveSchemaName.spec.ts @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { resolveSchemaName } from '../../helpers/resolveSchemaName.js'; +import { resolveSchemaName } from '../../helpers/resolveSchemaName'; describe('resolveSchemaName()', () => { describe('passing a ref', () => { diff --git a/src/tests/helpers/toPascalCase.spec.ts b/src/tests/helpers/toPascalCase.spec.ts index a4ecb30..bebe197 100644 --- a/src/tests/helpers/toPascalCase.spec.ts +++ b/src/tests/helpers/toPascalCase.spec.ts @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { toPascalCase } from '../../helpers/toPascalCase.js'; +import { toPascalCase } from '../../helpers/toPascalCase'; describe('toPascalCase()', () => { describe('passing "name of the variable"', () => { diff --git a/src/tests/helpers/writeOutputFile.spec.ts b/src/tests/helpers/writeOutputFile.spec.ts index d3c9050..dd37239 100644 --- a/src/tests/helpers/writeOutputFile.spec.ts +++ b/src/tests/helpers/writeOutputFile.spec.ts @@ -4,7 +4,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import fs from 'node:fs'; -import { writeOutputFile } from '../../helpers/writeOutputFile.js'; +import { writeOutputFile } from '../../helpers/writeOutputFile'; describe('writeOutputFile()', () => { describe('when output directory does not exists', () => { diff --git a/tsconfig.json b/tsconfig.json index 9e3e36a..f6479bf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -50,7 +50,7 @@ "sourceMap": true /* Create source map files for emitted JavaScript files. */, // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ + "outDir": "dist", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */