Skip to content

Commit

Permalink
feat: add argument support (#3077)
Browse files Browse the repository at this point in the history
  • Loading branch information
omeraplak committed Nov 28, 2022
1 parent 37fac3e commit d603306
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .changeset/breezy-suns-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"create-refine-app": minor
---

Added argument support

before:
```bash
npm create refine-app -- -o refine-antd tutorial
```

after:
```bash
npm create refine-app -o refine-antd tutorial
```
32 changes: 31 additions & 1 deletion packages/create-refine-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,44 @@ const bootstrap = () => {
)
.usage("<command> [options]")
.helpOption("-h, --help", "Output usage information.")
.option(
"-s, --source <source-path>",
"specify a custom source of plugins",
)
.option(
"-b, --branch <source-git-branch>",
"specify a custom branch in source of plugins",
)
.option(
"-o, --preset <preset-name>",
"specify a preset to use for the project",
)
.option(
"-l, --lucky",
"use this option to generate a project with random answers",
)
.allowUnknownOption(true)
.allowExcessArguments(true)
.action((_, command: Command) => {
const superplateExecutable = require.resolve(".bin/superplate");
console.log({ command: command });
try {
execa.sync(
superplateExecutable,
[...command.args, "--project=refine"],
[
...command.args,
"--project=refine",
command.getOptionValue("source")
? "--source=" + command.getOptionValue("source")
: "",
command.getOptionValue("branch")
? "--branch=" + command.getOptionValue("branch")
: "",
command.getOptionValue("preset")
? "--preset=" + command.getOptionValue("preset")
: "",
command.getOptionValue("lucky") ? "--lucky" : "",
],
{
stdio: "inherit",
},
Expand Down

0 comments on commit d603306

Please sign in to comment.