Skip to content

Improve CLI process #1268

@jinmayamashita

Description

@jinmayamashita

Discussed in #1207

Originally posted by mvn-tiennguyen-hn March 7, 2024
I've looked at the code that Jin san wrote here 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.

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.

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:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions