From e0cd8dc4c22898677b76b29706d0a8ca00c3d115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20C=C3=A9sar=20Abalde=20Reyes?= Date: Tue, 21 Jun 2022 14:59:33 +0200 Subject: [PATCH 01/13] #35 Updates CONTRIBUTING.md to help developers lo launch the project in local machines --- CONTRIBUTING.md | 43 +++++++++++++++++++++++++++++++++++++++++++ README.md | 7 ++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37fde9a..83823fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,7 @@

Best practices · +Quickstart · Pull request process · Code of conduct

@@ -29,6 +30,48 @@ project. We encourage you to follow them and help us create a better product! - Create commit messages that briefly describe the change applied, preferably in English. +## Quickstart + +### Dependencies + +To install dependencies, after cloning the repository, run: + +```bash +npm install +``` + +### Clean +To clean output & build path run: + +```bash +npm run clean +``` + +### Build + +To build the application, run: + +```bash +npm run build +``` + + +### Usage +To execute the application run: + +```bash +npm start -- -i input/file.yaml +``` + +You can find all the options in our [README](./README.md) file + +### Putting all together +When you are developing a new feature you must clean output & build path, rebuild the app and execute it. So this is a good command to _remember_: + +```bash +npm run clean && npm run build && npm start -- -i input/file.yaml +``` + ## Pull request process 1. Ensure any install or build dependencies are solved before doing a build. diff --git a/README.md b/README.md index da6288c..47c7191 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@

Summary · Getting started · +Contributing · Support · License

@@ -55,13 +56,17 @@ Options: -h, --help shows this help ``` +## 🤝 Contributing + +If you want to collaborate with the project, please read our [CONTRIBUTING.md](./CONTRIBUTING.md) where you can find our guidelines + ## 🧰 Support We’ll be glad to talk and discuss how `openapi-nodejs-cli` can help you 😊 Reach us through [GitHub issues](https://github.com/corunet/openapi-nodejs-cli/issues), [email](mailto:info@corunet.com) or [Twitter](https://twitter.com/corunet). -## License +## 🔐 License This Source Code Form is subject to the terms of the Mozilla Public 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/](https://mozilla.org/MPL/2.0/). [![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://github.com/corunet/openapi-nodejs-cli/blob/main/LICENSE) From 9c33e09d1c7694d321f4ef4f55e8f1212c11762e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20C=C3=A9sar=20Abalde=20Reyes?= Date: Tue, 21 Jun 2022 15:04:00 +0200 Subject: [PATCH 02/13] #35 Fix usage sample in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47c7191..c383a5a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ npm i @corunet/openapi-nodejs-cli --global ### 🧑🏻‍💻 Usage ```bash -openapi-nodejs-cli input/schema.yaml +openapi-nodejs-cli -i input/schema.yaml ``` You can retrieve an option list with this command: From d47189741a356f240310d13ca3bce3b15b19958e Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Tue, 12 Sep 2023 13:52:09 +0200 Subject: [PATCH 03/13] fix: missing templates and start script --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5c284ae..a2213d1 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "main": "src/index.js", "bin": "src/index.js", "files": [ - "src/**/*.{d.ts,d.ts.map,js,js.map}", + "src/**/*.{d.ts,d.ts.map,js,js.map,hbs}", "LICENSE", "README.md", "CHANGELOG.md", @@ -27,7 +27,8 @@ "clean": "rm -rf output", "build": "tsc", "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)", From 89bc06ec2770120a380165b91e741a60dad33ef4 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Tue, 12 Sep 2023 13:54:12 +0200 Subject: [PATCH 04/13] fix: readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From f405e04427b4a388fde24dc29a73c0016dc16b76 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Tue, 12 Sep 2023 17:20:54 +0200 Subject: [PATCH 05/13] refactor: move build files to dist --- package.json | 7 ++++--- tsconfig.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a2213d1..351b735 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,hbs}", + "dist", "LICENSE", "README.md", "CHANGELOG.md", @@ -26,6 +26,7 @@ "coverage": "jest --coverage", "clean": "rm -rf output", "build": "tsc", + "postbuild": "cp -r ./src/templates ./dist", "postprepare": "npm run build", "prestart": "npm run build", "start": "node .", 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. */ From 5e733c9ca02b57fa189488d3fe54b055e6b3f342 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Tue, 12 Sep 2023 17:32:43 +0200 Subject: [PATCH 06/13] feat: add folders to clean script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 351b735..d61a86e 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "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", From f351e68522e590046b5a21de9fecfa07c43d6284 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Tue, 12 Sep 2023 18:22:47 +0200 Subject: [PATCH 07/13] refactor: test ts instead js --- .eslintrc.cjs | 10 +++++++++- src/tests/helpers/capitalize.spec.ts | 2 +- src/tests/helpers/divideIntoDocumentsByTag.spec.ts | 6 +++--- src/tests/helpers/getComponentPath.spec.ts | 2 +- src/tests/helpers/getComponentsFiles.spec.ts | 2 +- src/tests/helpers/hasRepeatedOperationIdErrors.spec.ts | 6 +++--- src/tests/helpers/isUrl.spec.ts | 2 +- src/tests/helpers/log.spec.ts | 2 +- src/tests/helpers/parseTypes.spec.ts | 2 +- src/tests/helpers/resolveSchemaName.spec.ts | 2 +- src/tests/helpers/toPascalCase.spec.ts | 2 +- src/tests/helpers/writeOutputFile.spec.ts | 2 +- 12 files changed, 24 insertions(+), 16 deletions(-) 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/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', () => { From fc54104b83368a74ffbca985d3e55dfc1aa59f50 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Wed, 13 Sep 2023 14:47:40 +0200 Subject: [PATCH 08/13] refactor: readme and contributing --- CONTRIBUTING.md | 20 ++++++++++---------- README.md | 14 +++++++++++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1ad57ac..1aa8410 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,15 +36,7 @@ project. We encourage you to follow them and help us create a better product! To install dependencies, after cloning the repository, run: ```bash -npm install -``` - -### Clean - -To clean output & build path run: - -```bash -npm run clean +npm ci ``` ### Build @@ -63,6 +55,14 @@ To execute the application run: npm start -- -i input/file.yaml ``` +### Clean + +To clean output & build path run: + +```bash +npm run clean +``` + You can find all the options in our [README](./README.md) file ### Putting all together @@ -70,7 +70,7 @@ You can find all the options in our [README](./README.md) file When you are developing a new feature you must clean output & build path, rebuild the app and execute it. So this is a good command to _remember_: ```bash -npm run clean && npm run build && npm start -- -i input/file.yaml +npm run clean && npm start -- -i input/file.yaml ``` ## Pull request process diff --git a/README.md b/README.md index 89b3953..ba6bf07 100644 --- a/README.md +++ b/README.md @@ -24,22 +24,30 @@ This generator requires the Node version >=17.7.1 to run properly -### How to install +### 🧑🏻‍💻 Usage + +You can install it: ```bash npm i @sngular/openapi-nodejs-cli --global ``` -### 🧑🏻‍💻 Usage +and use as: ```bash openapi-nodejs-cli -i input/schema.yaml ``` +or use directly: + +```bash +npx i @sngular/openapi-nodejs-cli -i input/schema.yaml +``` + You can retrieve an option list with this command: ```bash -npx openapi-nodejs-cli --help +openapi-nodejs-cli --help ``` ```bash From 986bc2c3db173bb73b11053a5be4d9c624684171 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Wed, 13 Sep 2023 14:56:45 +0200 Subject: [PATCH 09/13] feat: add example schema to start dev --- CONTRIBUTING.md | 2 +- example.yaml | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 example.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1aa8410..6029c7c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,7 +52,7 @@ npm run build To execute the application run: ```bash -npm start -- -i input/file.yaml +npm start -- -i example.yaml ``` ### Clean diff --git a/example.yaml b/example.yaml new file mode 100644 index 0000000..dd88679 --- /dev/null +++ b/example.yaml @@ -0,0 +1,24 @@ +openapi: 3.1.0 +info: + title: Sample API + description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML. + version: 0.1.9 +servers: + - url: http://api.example.com/v1 + description: Optional server description, e.g. Main (production) server + - url: http://staging-api.example.com + description: Optional server description, e.g. Internal staging server for testing +paths: + /users: + get: + summary: Returns a list of users. + description: Optional extended description in CommonMark or HTML. + responses: + '200': # status code + description: A JSON array of user names + content: + application/json: + schema: + type: array + items: + type: string From ee54b29b46edb05287567f1fc104b6576a8e01b2 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Thu, 14 Sep 2023 17:52:31 +0200 Subject: [PATCH 10/13] Revert "refactor: move build files to dist" This reverts commit f405e04427b4a388fde24dc29a73c0016dc16b76. --- package.json | 7 +++---- tsconfig.json | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d61a86e..1f911cb 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,10 @@ ], "license": "Mozilla Public License 2.0", "type": "commonjs", - "main": "dist/index.js", - "bin": "dist/index.js", + "main": "src/index.js", + "bin": "src/index.js", "files": [ - "dist", + "src/**/*.{d.ts,d.ts.map,js,js.map,hbs}", "LICENSE", "README.md", "CHANGELOG.md", @@ -26,7 +26,6 @@ "coverage": "jest --coverage", "clean": "rm -rf output outputTest dist", "build": "tsc", - "postbuild": "cp -r ./src/templates ./dist", "postprepare": "npm run build", "prestart": "npm run build", "start": "node .", diff --git a/tsconfig.json b/tsconfig.json index f6479bf..9e3e36a 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": "dist", /* Specify an output folder for all emitted files. */ + // "outDir": "./", /* 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. */ From a954d21657495d8ec6bd99229db24a1ee943b259 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Thu, 14 Sep 2023 17:52:43 +0200 Subject: [PATCH 11/13] Revert "feat: add folders to clean script" This reverts commit 5e733c9ca02b57fa189488d3fe54b055e6b3f342. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f911cb..a2213d1 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "scripts": { "test": "jest", "coverage": "jest --coverage", - "clean": "rm -rf output outputTest dist", + "clean": "rm -rf output", "build": "tsc", "postprepare": "npm run build", "prestart": "npm run build", From 12bb34d64a5f9d1408ab06149e2aa48a67df7fd6 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Thu, 14 Sep 2023 17:53:12 +0200 Subject: [PATCH 12/13] Revert "refactor: test ts instead js" This reverts commit f351e68522e590046b5a21de9fecfa07c43d6284. --- .eslintrc.cjs | 10 +--------- src/tests/helpers/capitalize.spec.ts | 2 +- src/tests/helpers/divideIntoDocumentsByTag.spec.ts | 6 +++--- src/tests/helpers/getComponentPath.spec.ts | 2 +- src/tests/helpers/getComponentsFiles.spec.ts | 2 +- src/tests/helpers/hasRepeatedOperationIdErrors.spec.ts | 6 +++--- src/tests/helpers/isUrl.spec.ts | 2 +- src/tests/helpers/log.spec.ts | 2 +- src/tests/helpers/parseTypes.spec.ts | 2 +- src/tests/helpers/resolveSchemaName.spec.ts | 2 +- src/tests/helpers/toPascalCase.spec.ts | 2 +- src/tests/helpers/writeOutputFile.spec.ts | 2 +- 12 files changed, 16 insertions(+), 24 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 94c43ea..81e6483 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -4,7 +4,6 @@ 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'], @@ -18,18 +17,11 @@ module.exports = { ecmaVersion: 'latest', sourceType: 'module', }, - ignorePatterns: ['output', 'outputTest', 'dist'], + ignorePatterns: ['output', 'outputTest', '**/*d.ts'], 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/src/tests/helpers/capitalize.spec.ts b/src/tests/helpers/capitalize.spec.ts index 11180d2..00ee0f2 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'; +import { capitalize } from '../../helpers/capitalize.js'; describe('capitalize()', () => { describe('passing "name"', () => { diff --git a/src/tests/helpers/divideIntoDocumentsByTag.spec.ts b/src/tests/helpers/divideIntoDocumentsByTag.spec.ts index 43fa37c..d7aa1a7 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'; -import { DataObjectWithoutTags } from '../mocks/DataObjectWithoutTags'; +import { DataObjectWith2Tags } from '../mocks/DataObjectWith2Tags.js'; +import { DataObjectWithoutTags } from '../mocks/DataObjectWithoutTags.js'; -import { divideIntoDocumentsByTag } from '../../helpers/divideIntoDocumentsByTag'; +import { divideIntoDocumentsByTag } from '../../helpers/divideIntoDocumentsByTag.js'; 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 5c1384f..72edfcb 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'; +import { getComponentPath } from '../../helpers/getComponentPath.js'; 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 74024b0..d34d16a 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'; +import { getComponentsFiles } from '../../helpers/getComponentsFiles.js'; describe('getComponentsFiles()', () => { describe('passing an URL', () => { diff --git a/src/tests/helpers/hasRepeatedOperationIdErrors.spec.ts b/src/tests/helpers/hasRepeatedOperationIdErrors.spec.ts index b9dde42..c84aa82 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'; -import { DocumentListWithRepeatedOperationIds } from '../mocks/DocumentListWithRepeatedOperationIds'; -import { hasRepeatedOperationIdErrors } from '../../helpers/hasRepeatedOperationIdErrors'; +import { DocumentListWithNoRepeatedOperationIds } from '../mocks/DocumentListWithNoRepeatedOperationIds.js'; +import { DocumentListWithRepeatedOperationIds } from '../mocks/DocumentListWithRepeatedOperationIds.js'; +import { hasRepeatedOperationIdErrors } from '../../helpers/hasRepeatedOperationIdErrors.js'; 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 831c639..9c32fd0 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'; +import { isUrl } from '../../helpers/isUrl.js'; describe('isUrl()', () => { describe('passing http url', () => { diff --git a/src/tests/helpers/log.spec.ts b/src/tests/helpers/log.spec.ts index 3ffbfd5..d948e39 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'; +import { log } from '../../helpers/log.js'; 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 87af98e..36d4b0e 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'; +import { parseTypes } from '../../helpers/parseTypes.js'; describe('parseTypes()', () => { describe('references to a component', () => { diff --git a/src/tests/helpers/resolveSchemaName.spec.ts b/src/tests/helpers/resolveSchemaName.spec.ts index df3e51c..ed61d8c 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'; +import { resolveSchemaName } from '../../helpers/resolveSchemaName.js'; describe('resolveSchemaName()', () => { describe('passing a ref', () => { diff --git a/src/tests/helpers/toPascalCase.spec.ts b/src/tests/helpers/toPascalCase.spec.ts index bebe197..a4ecb30 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'; +import { toPascalCase } from '../../helpers/toPascalCase.js'; 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 dd37239..d3c9050 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'; +import { writeOutputFile } from '../../helpers/writeOutputFile.js'; describe('writeOutputFile()', () => { describe('when output directory does not exists', () => { From 6934a1641ee4d5d1185fb19b00c7337b48ea5687 Mon Sep 17 00:00:00 2001 From: Adan Toscano Date: Fri, 15 Sep 2023 16:38:20 +0200 Subject: [PATCH 13/13] feat: add clean build script --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d15c842..a3c5cbe 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "scripts": { "test": "jest", "coverage": "jest --coverage", - "clean": "rm -rf output", "build": "tsc", + "build:clean": "tsc --build --clean", "postprepare": "npm run build", "prestart": "npm run build", "start": "node .", @@ -36,7 +36,8 @@ "format:eslint": "npm run lint:eslint -- --fix", "format:prettier": "prettier --write .", "prepare": "husky install", - "release": "npx semantic-release" + "release": "npx semantic-release", + "clean": "rm -rf output outputTest && npm run build:clean" }, "repository": { "type": "git",