cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

Option `removeStaleFiles` does not delete files in output directory #123

Closed spitfjre closed 3 years ago

spitfjre commented 4 years ago

With given configuration the output directory does not get "cleaned" and to be more precise, no files get updated. Only after manually clearing the directory and running generate again the output files are generated. So not sure if this is the combination of the configuration options or some problem with node version or OS (Ubuntu 20.04).

"ng-openapi-gen": "^0.12.1"
Angular CLI: 10.0.5
Node: 13.14.0
OS: linux x64

Angular: 10.0.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.5
@angular-devkit/build-angular     0.1000.5
@angular-devkit/build-optimizer   0.1000.5
@angular-devkit/build-webpack     0.1000.5
@angular-devkit/core              10.0.5
@angular-devkit/schematics        10.0.8
@angular/cdk                      10.0.2
@angular/cli                      10.0.5
@angular/material                 10.0.2
@ngtools/webpack                  10.0.5
@schematics/angular               10.0.5
@schematics/update                0.1000.5
rxjs                              6.6.2
typescript                        3.9.7
webpack                           4.43.0
{
    "$schema": "../node_modules/ng-openapi-gen/ng-openapi-gen-schema.json",
    "enumStyle": "upper",
    "ignoreUnusedModels": false,
    "indexFile": false,
    "input": "../microservices/toll-box/openapi.json",
    "modelIndex": false,
    "module": "TollBoxModule",
    "output": "libs/toll-box-api/src/lib",
    "removeStaleFiles": true,
    "serviceIndex": false
}
remkoboschker commented 4 years ago

I have te same on windows. Was working fine and suddenly if I run ng-openapi-gen I get a new folder with a $ suffix. If I remove the folder by hand beforehand, generation works fine.

luisfpg commented 3 years ago

I cannot reproduce this issue. If I generate to some folder, then create a bogus file in that folder and generate again, the file is removed. @remkoboschker The $ suffix works as follows:

  1. A temporary folder with the $ suffix is created in the same parent directory as the output folder
  2. All files are generated on that folder
  3. A synchronization is done between the real output folder and that temporary folder: new / modified files are copied and files that don't exist in the corresponding temporary folder but exist in the real output folder are removed
  4. The entire temporary folder is removed, even if the generation fails for some reason

I would need some help to track down exactly what happens, because it works fine here on Linux (using Manjaro, but teammates use Ubuntu as well). I don't use Windows / Mac, so it is a bit hard for me to find issues on these platforms.

remkoboschker commented 3 years ago

I have not seen this issue for some time on windows. You can close the issue as far as I'm concerned. Thank you.