Recently, I was assigned a task to explore customizing the folder structure for new apps, specifically Nest apps. After some research, I discovered that it is possible to create a "lib" folder within the "tools" directory and leverage patterns to automatically generate files using generateFiles
from @nrwl/devkit
. Below is an example of a basic structure typically used with a lib, where variable names are changed and files are populated with "__" in the name:
my-lib/
├── files/
├── mysql/
| ├── __originalName__.mwb
| └── schema.json
├── src/
├── index.ts__tmpl__
└── models.ts__tmpl__
Firstly, I am curious if it is feasible to modify a new app structure in memory before committing the changes to disk.
For instance, assume we have a new nest app structured like this:
├── src/
├── app.controller.spec.ts
├── app.controller.ts
├── app.module.ts
├── app.service.ts
├── main.ts
However, what if I need to move the app.controller.ts
and app.controller.spec.ts
files to a new folder, as well as add additional files to all new nest apps? As someone relatively new to Nest, this poses a challenge for me.
├── 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 changing the file structure in memory is indeed possible, how can I accomplish this? Currently, I am experimenting with generators. I executed
npx nx generate @nrwl/workspace:workspace-generator app-nest
to get started, but I'm unsure of how to proceed with altering the files.
For more information, please visit: