monstar-lab-oss / ml-frontend

A monorepo created to provide a starter kit for front-end projects at Monstar Lab, Inc.
https://www.npmjs.com/package/start-frontend
Mozilla Public License 2.0
14 stars 1 forks source link

Improve CLI process #1268

Open jinmayamashita opened 4 months ago

jinmayamashita commented 4 months ago

Discussed in https://github.com/monstar-lab-oss/ml-frontend/discussions/1207

Originally posted by **mvn-tiennguyen-hn** March 7, 2024 I've looked at the code that Jin san wrote [here](https://github.com/jinmayamashita/sandbox-generate-react-app/blob/main/packages/start-frontend/src/index.ts) and it looks great, but I'd like to leave a few comments ## Shell command service We should create a service for shell command for better reuse and encapsulating logic. ```ts function copyFolder(fromPath: string, toPath: string) { // Do stuff } function createFolder(destination: string) { // Do stuff } ``` ## Windows support How about supporting on Windows machine? I think `rsync` and `mkdir` shell command cannot work in PowerShell or Command Prompt as well because WSL (Windows subsystem linux) have not been popular yet. We can use methods from `fs` package (`fs.cpSync`, `fs.mkdir`) to get native supported method on user's machine. ```ts function createFolder(destination: string) { fs.mkdirSync(`${destination}/src/components/api/`); } ``` ## Breakdown CLI into small functions I see all steps from copying core files, copy functions, copy API,... are being done in the same flow. What if users want to add functions or API later, after deciding what they need? I think we should divide CLI into smaller functions, for example: - `/src/packages/cli/init.ts`: Initialize project with basic directory structure - `/src/packages/cli/add.ts`: Add necessary modules, such as authentication or authorization. - `/src/packages/cli/remove.ts`: Remove an unnecessary module From there users can run function they want at any time. By the way, I think authorization functionality should be implemented in 2024. This is also a feature that many people are interested in. I look forward to receiving comments from everyone. Thank you.

Issues: