I received a task to see how to customize the folder structure for new apps, more precisely, nest apps. I'd a search and found that is possible to create a lib folder under the tools folder, and following patterns, I could populate a pre-created structure of files using generateFiles
from @nrwl/devkit
. The example below shows a simple structure that is used with a lib, where will change the variable names and populate the files with "__ __" in the name:
my-lib/
├── files/
├── mysql/
| ├── __originalName__.mwb
| └── schema.json
├── src/
├── index.ts__tmpl__
└── models.ts__tmpl__
Well, first of all, I would like to know if it is possible to change a new app structure while still on memory and only after that, write on the disk.
So using Nest as an example, a new nest app will look like this:
├── src/
├── app.controller.spec.ts
├── app.controller.ts
├── app.module.ts
├── app.service.ts
├── main.ts
But, let's imagine, I need to change the app.controller.ts
and app.controller.spec.ts
to a new folder and create a few other files to every new nest app. I don't have experience with nest yet.
├── src/
├── controllers/
├── app.controller.ts
├── app.controller.spec.ts
├── new.controller.ts
├── new.controller.spec.ts
├── app.module.ts
├── app.service.ts
├── main.ts
If yes for the first question, how can I achieve that? Right now I'm trying to work with generators. I run npx nx generate @nrwl/workspace:workspace-generator app-nest
which gives me a start point, but I have no idea how can I change the files.
My reference: https://nx.dev/latest/angular/generators/workspace-generators/