From 31433a3db09b914e50716537c8f5a385691e0917 Mon Sep 17 00:00:00 2001 From: John Carmichael Date: Mon, 16 Jun 2025 11:24:22 +0100 Subject: [PATCH] fix: default ignore paths for copy and render now explicitly match the build & dist folder only, avoiding accidental matches with similarly named files (e.g., tsconfig.build.json). --- .idea/codeStyles/Project.xml | 66 ------------------- .idea/codeStyles/codeStyleConfig.xml | 5 -- .idea/inspectionProfiles/Project_Default.xml | 7 -- .idea/jsLibraryMappings.xml | 6 -- .idea/misc.xml | 9 --- .idea/modules.xml | 8 --- .idea/openapi-nodegen.iml | 8 --- .idea/php.xml | 12 ---- .idea/vcs.xml | 9 --- CHANGELOG.md | 3 + README.md | 2 +- package-lock.json | 4 +- package.json | 2 +- src/__tests__/openapiNodegen_full.ts | 2 + .../__tests__/shouldCopyOrRenderFile.ts | 46 +++++++++++++ src/lib/helpers/shouldCopyOrRenderFile.ts | 4 +- .../tsconfig.build.json | 12 ++++ 17 files changed, 69 insertions(+), 136 deletions(-) delete mode 100644 .idea/codeStyles/Project.xml delete mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/jsLibraryMappings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/openapi-nodegen.iml delete mode 100644 .idea/php.xml delete mode 100644 .idea/vcs.xml create mode 100644 test_server/.openapi-nodegen/git/httpsGithubComAcrontumOpenapiNodegenTypescriptServerGit/tsconfig.build.json diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 88d6af9d..00000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index 79ee123c..00000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 5fe51e8d..00000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml deleted file mode 100644 index d23208fb..00000000 --- a/.idea/jsLibraryMappings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 0ecb5c32..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 148cb7c1..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/openapi-nodegen.iml b/.idea/openapi-nodegen.iml deleted file mode 100644 index c956989b..00000000 --- a/.idea/openapi-nodegen.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index f5f27444..00000000 --- a/.idea/php.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index fc7a4af7..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f3cd1ff..e1da8446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 5.62.4 16/06/2025 +fix: default ignore paths for copy and render now explicitly match the build & dist folder only, avoiding accidental matches with similarly named files (e.g., tsconfig.build.json). + ### 5.62.3 04/03/2025 fix: template fetch fail message referred toa URL even when local path provided diff --git a/README.md b/README.md index 472fbac9..960a1634 100755 --- a/README.md +++ b/README.md @@ -28,4 +28,4 @@ The templates should be hosted on a publicly available https url, eg: [generate- It is strongly recommended to use the OpenApi DSL package [boats](https://www.npmjs.com/package/boats) to standardize OpenAPI/AsyncAPI file architecture and operation IDs and more. ___ -Generate-It is an opensource project from [acrontum](https://www.acrontum.de/) and [Liffery](https://www.liffery.com/) written in TypeScript and is tested on NodeJS 14 LTS. +Generate-It is an opensource project from [acrontum](https://www.acrontum.de/) and [Liffery](https://www.liffery.com/) written in TypeScript and is tested on NodeJS LTS. diff --git a/package-lock.json b/package-lock.json index ccccd28b..68f59d2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "generate-it", - "version": "5.62.3", + "version": "5.62.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "generate-it", - "version": "5.62.3", + "version": "5.62.4", "license": "MIT", "dependencies": { "@apidevtools/json-schema-ref-parser": "^11.7.2", diff --git a/package.json b/package.json index ec60570a..50091485 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "generate-it", - "version": "5.62.3", + "version": "5.62.4", "description": "Generate-it, will generate servers, clients, web-socket and anything else you can template with nunjucks from yml files (openapi/asyncapi)", "author": "Acrontum GmbH & Liffery Ltd", "license": "MIT", diff --git a/src/__tests__/openapiNodegen_full.ts b/src/__tests__/openapiNodegen_full.ts index 30fa423d..0ec3459f 100644 --- a/src/__tests__/openapiNodegen_full.ts +++ b/src/__tests__/openapiNodegen_full.ts @@ -82,6 +82,8 @@ it('Should have the correct file hashes', async () => { // The app ts should be modified - the hash should match: // test_server/.openapi-nodegen/git/httpsGithubComAcrontumOpenapiNodegenTypescriptInjectServerGit/src/app.ts ['test_server/src/app.ts', 'c8b383752c315a02043acdd40df63caf'], + // It should copy over build files like tsconfig.build.json + ['test_server/tsconfig.build.json', 'a085d43ab78199c39acaaddd70696776'], ]; const mismatched: string[] = []; diff --git a/src/lib/helpers/__tests__/shouldCopyOrRenderFile.ts b/src/lib/helpers/__tests__/shouldCopyOrRenderFile.ts index 3cbafad2..6da5a9a6 100644 --- a/src/lib/helpers/__tests__/shouldCopyOrRenderFile.ts +++ b/src/lib/helpers/__tests__/shouldCopyOrRenderFile.ts @@ -2,6 +2,52 @@ import shouldCopyOrRenderFile from '@/lib/helpers/shouldCopyOrRenderFile'; import { NodegenRc } from '@/interfaces'; describe('File Ignore Functionality', () => { + + it('should skip files in a build or dist folder but not if the file contains build or dist', () => { + expect(shouldCopyOrRenderFile({ + ignoreForWhichAction: 'copy', + directoryPathContainingFilename: 'build/something.ts', + filenameBeingProcessed: 'config' + })).toBe(false); + expect(shouldCopyOrRenderFile({ + ignoreForWhichAction: 'render', + directoryPathContainingFilename: 'build/something.ts', + filenameBeingProcessed: 'config' + })).toBe(false); + expect(shouldCopyOrRenderFile({ + ignoreForWhichAction: 'copy', + directoryPathContainingFilename: 'dist/something.ts', + filenameBeingProcessed: 'config' + })).toBe(false); + expect(shouldCopyOrRenderFile({ + ignoreForWhichAction: 'render', + directoryPathContainingFilename: 'dist/something.ts', + filenameBeingProcessed: 'config' + })).toBe(false); + + expect(shouldCopyOrRenderFile({ + ignoreForWhichAction: 'copy', + directoryPathContainingFilename: 'dist.something.ts', + filenameBeingProcessed: 'config' + })).toBe(true); + expect(shouldCopyOrRenderFile({ + ignoreForWhichAction: 'render', + directoryPathContainingFilename: 'dist.something.ts', + filenameBeingProcessed: 'config' + })).toBe(true); + + expect(shouldCopyOrRenderFile({ + ignoreForWhichAction: 'copy', + directoryPathContainingFilename: 'tsconfig.build.json', + filenameBeingProcessed: 'config' + })).toBe(true); + expect(shouldCopyOrRenderFile({ + ignoreForWhichAction: 'render', + directoryPathContainingFilename: 'tsconfig.build.json', + filenameBeingProcessed: 'config' + })).toBe(true); + }); + it('should skip .git, node_modules, and editor files', () => { expect(shouldCopyOrRenderFile({ ignoreForWhichAction: 'copy', diff --git a/src/lib/helpers/shouldCopyOrRenderFile.ts b/src/lib/helpers/shouldCopyOrRenderFile.ts index be58c129..feedfa13 100644 --- a/src/lib/helpers/shouldCopyOrRenderFile.ts +++ b/src/lib/helpers/shouldCopyOrRenderFile.ts @@ -1,8 +1,8 @@ import { NodegenRc } from '@/interfaces'; import path from 'path'; -const defaultCopyIgnoreList = [`(\\.idea|\\.git|\\.vscode|node_modules|build|dist|_tpl_testing_)\\b`]; -const defaultRenderIgnoreList = [`(\\.idea|\\.git|\\.vscode|node_modules|build|dist)\\b`]; +const defaultCopyIgnoreList = [`(\\.idea|\\.git|\\.vscode|node_modules|build\/|dist\/|_tpl_testing_)\\b`]; +const defaultRenderIgnoreList = [`(\\.idea|\\.git|\\.vscode|node_modules|build\/|dist\/)\\b`]; let ignoreList: string; let fullRegex: RegExp; diff --git a/test_server/.openapi-nodegen/git/httpsGithubComAcrontumOpenapiNodegenTypescriptServerGit/tsconfig.build.json b/test_server/.openapi-nodegen/git/httpsGithubComAcrontumOpenapiNodegenTypescriptServerGit/tsconfig.build.json new file mode 100644 index 00000000..d341d0fc --- /dev/null +++ b/test_server/.openapi-nodegen/git/httpsGithubComAcrontumOpenapiNodegenTypescriptServerGit/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "dist", + "types": ["node"], + "sourceMap": false, + "composite": true, + "incremental": true + }, + "exclude": ["**/*.test.ts", "**/*.spec.ts"], + "include": ["src/**/*.ts", "migrations", "src/router.int.spec.ts", "package.json"] +}