Skip to content

Commit a947d74

Browse files
committed
feat(cli): remove need of rollups subcommand
1 parent f2697a5 commit a947d74

36 files changed

Lines changed: 578 additions & 605 deletions

.changeset/thick-taxis-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cartesi/cli": patch
3+
---
4+
5+
remove need of rollups subcommand

apps/cli/src/commands/create.ts

100644100755
Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
1-
import { Command } from "@commander-js/extra-typings";
1+
import { Command, Option } from "@commander-js/extra-typings";
22
import chalk from "chalk";
3+
import ora from "ora";
4+
import { download } from "../template.js";
5+
6+
export const DEFAULT_TEMPLATES_BRANCH = "prerelease/sdk-12";
7+
8+
const TEMPLATES = [
9+
"cpp",
10+
"cpp-low-level",
11+
"go",
12+
"javascript",
13+
"lua",
14+
"python",
15+
"ruby",
16+
"rust",
17+
"typescript",
18+
] as const;
319

420
export const createCreateCommand = () => {
521
return new Command("create")
6-
.summary("DEPRECATED: use 'rollups create' instead")
7-
.action(async () => {
8-
console.warn(
9-
chalk.yellow(
10-
"create command is deprecated, use 'rollups create' instead",
11-
),
12-
);
22+
.argument("<name>", "application and directory name")
23+
.addOption(
24+
new Option("-t, --template <template>", "template name to use")
25+
.choices(TEMPLATES)
26+
.makeOptionMandatory(),
27+
)
28+
.option(
29+
"-b, --branch <branch>",
30+
"cartesi/application-templates repository branch name to use",
31+
DEFAULT_TEMPLATES_BRANCH,
32+
)
33+
.action(async (name, { branch, template }) => {
34+
const spinner = ora("Creating application...").start();
35+
try {
36+
const { dir } = await download(template, branch, name);
37+
spinner.succeed(`Application created at ${chalk.cyan(dir)}`);
38+
} catch (e: unknown) {
39+
spinner.fail(
40+
e instanceof Error
41+
? `Error creating application: ${chalk.red(e.message)}`
42+
: String(e),
43+
);
44+
}
1345
});
1446
};

0 commit comments

Comments
 (0)