line / create-liff-app

Start developing LIFF application with a simple CLI command.
https://developers.line.biz/en/docs/liff/
Apache License 2.0
63 stars 8 forks source link

Add flags to the CLI #19

Closed so99ynoodles closed 2 years ago

so99ynoodles commented 2 years ago

🙋 Feature Request

Add flags to the CLI

🤔 Expected Behavior

Users can set their information as flags so they can skip the process of pressing enters several times.

😯 Current Behavior

There is no way to create-liff-app without pressing enters.

💁 Possible Solution

There can be flags or args of all parameters. This is just an example ↓

npx @line/create-liff-app <app_name> 

1st argument: app_name
-t or --template: template_name
--js: use JavaScript
--ts: use TypeScript
-l or --liffid: liff_id
--yarn: use yarn
--npm: use npm
-h or --help: tooltips for the create-liff-app
-v or --version: version of create-liff-app

We may use libraries like commander or yargs to implement this.

💻 Examples

You can check the create-next-app implementation. https://github.com/vercel/next.js/blob/canary/packages/create-next-app/index.ts

BWsix commented 2 years ago

Hi, is anyone working on this issue now? If not, I am willing to give it a try and make a PR

so99ynoodles commented 2 years ago

@BWsix Awesome! It would be great if you give it a try! (Sorry that the specs are not organized enough)

BWsix commented 2 years ago

Sure! I'll submit a PR with the changes in a day or two.

@so99ynoodles I am thinking of the following implementations, which one looks better to you or we do this in another way?:

  1. Make every flag optional (maybe even the first argument app name), and ask questions for missing informations. This is easier and don't require a lot of changes to the create-liff-app.ts since we can do this using commander in index.ts and pass the provided flags to create-liff-app.ts.
  2. Make first argument app name and flag template, liffid required and set default values for other flags. This will be done by replacing inquirer with commander and requires more changes to the create-liff-app.ts.

Btw, now that we're adding flags to reduce the time answering questions, what do you think we infer package manager automatically and let users change package manager by adding flags (--use-npm, --use-yarn) like create-next-app does? This can be easily done by borrowing their code.

Also, there's a page (link) on Line Developer which talks about the create-liff-app that hasn't been updated and still uses the previous version of cla. Maybe someone would need to update that page (after the flag feature?)

BWsix commented 2 years ago

Also, is the main field in root level package.json required or it can be removed? It causes path error after build to JavaScript when I import and use package.json in ts file.

so99ynoodles commented 2 years ago

I am thinking of the following implementations, which one looks better to you or we do this in another way?:

I think option.1 is a better choice since it won't change users' experience! (or command to start with)

Btw, now that we're adding flags to reduce the time answering questions, what do you think we infer package manager automatically and let users change package manager by adding flags (--use-npm, --use-yarn) like create-next-app does?

I think it can be a better experience for some users, but I'm little concerned about setting their default package manager manually since we cannot use yarn create to start create-liff-app since it has @line prefix, so yarn users will be frustrated if they don't know about --use-yarn flag.

Also, there's a page (link) on Line Developer which talks about the create-liff-app that hasn't been updated and still uses the previous version of cla. Maybe someone would need to update that page (after the flag feature?)

We are gonna make a contact with the LINE document team. Thank you for notifying it 🙏

Also, is the main field in root level package.json required or it can be removed? It causes path error after build to JavaScript when I import and use package.json in ts file.

Yes, it can be deleted.

BWsix commented 2 years ago

Thank you for the informative reply!

we cannot use yarn create to start create-liff-app since it has @line prefix

I didn't know that! I'll not make changes to the package manager part.