Skip to content

Commit b295744

Browse files
committed
feat(cli): deprecate deploy and deploy build commands
1 parent ea13b95 commit b295744

File tree

6 files changed

+25
-164
lines changed

6 files changed

+25
-164
lines changed

.changeset/eighty-clowns-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cartesi/cli": major
3+
---
4+
5+
DEPRECATED: cartesi deploy build

.changeset/upset-news-ask.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cartesi/cli": major
3+
---
4+
5+
DEPRECATED: cartesi deploy

apps/cli/src/commands/deploy.ts

Lines changed: 9 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,19 @@
1-
import { Command, Option } from "@commander-js/extra-typings";
2-
import confirm from "@inquirer/confirm";
3-
import select from "@inquirer/select";
1+
import { Command } from "@commander-js/extra-typings";
42
import chalk from "chalk";
5-
import open, { apps } from "open";
6-
import { getMachineHash, logPrompt } from "../base.js";
73
import { createBuildCommand } from "./deploy/build.js";
84

95
export const createDeployCommand = () => {
106
const command = new Command("deploy")
117
.description(
12-
"Package and deploy the application to a supported live network.",
8+
"DEPRECATED: Package and deploy the application to a supported live network.",
139
)
14-
.addOption(
15-
new Option("--hosting <hosting>", "hosting type").choices([
16-
"self-hosted",
17-
"third-party",
18-
]),
19-
)
20-
.addOption(
21-
new Option(
22-
"--webapp <webapp>",
23-
"webapp address",
24-
).makeOptionMandatory(),
25-
)
26-
.action(async (options, command) => {
27-
// print machine hash
28-
const templateHash = getMachineHash();
29-
if (!templateHash) {
30-
command.error(
31-
`Cartesi machine snapshot not found, run 'build'`,
32-
);
33-
return;
34-
}
35-
logPrompt({
36-
title: "Cartesi machine templateHash",
37-
value: templateHash,
38-
});
39-
40-
// ask for deployment type
41-
const hosting =
42-
options.hosting ||
43-
(await select<"self-hosted" | "third-party">({
44-
message: "Select hosting type",
45-
choices: [
46-
{
47-
name: "Self-hosting",
48-
description: `Select this option if you want to run the node for your application.
49-
You will need the following infrastructure:
50-
51-
- a cloud server for the application node
52-
- a postgres database
53-
- a web3 node provider
54-
- a funded wallet
55-
`,
56-
value: "self-hosted",
57-
},
58-
{
59-
name: "Use third-party provider",
60-
description:
61-
"Select this option to use a third-party service provider to run a node for your application.",
62-
value: "third-party",
63-
disabled: "(coming soon)",
64-
},
65-
],
66-
}));
67-
68-
let queryString = "";
69-
switch (hosting) {
70-
case "self-hosted": {
71-
// build docker image
72-
// Execute the build subcommand
73-
command.commands
74-
.find((cmd) => cmd.name() === "build")
75-
?.parseAsync(command.args);
76-
77-
queryString = `?templateHash=${templateHash}`;
78-
break;
79-
}
80-
case "third-party": {
81-
command.error(
82-
"Third-party provider deployment not supported yet",
83-
);
84-
}
85-
}
86-
87-
// prompt user to open webapp for onchain deployment
88-
const deployUrl = `${options.webapp}${queryString}`;
89-
if (await confirm({ message: `Open ${chalk.cyan(deployUrl)}?` })) {
90-
open(deployUrl, { app: { name: apps.chrome } });
91-
}
92-
93-
return;
10+
.action(async () => {
11+
console.warn(
12+
chalk.yellow(
13+
"deploy command is deprecated, use 'rollups deploy' instead",
14+
),
15+
);
9416
});
95-
command.addCommand(createBuildCommand());
17+
command.addCommand(createBuildCommand(), { hidden: true });
9618
return command;
9719
};
Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,12 @@
1-
import { Command, Option } from "@commander-js/extra-typings";
2-
import { execa } from "execa";
3-
import fs from "fs-extra";
4-
import path from "path";
5-
import { tmpNameSync } from "tmp";
6-
import { getContextPath, getMachineHash, logPrompt } from "../../base.js";
7-
8-
const buildRollupsImage = async (platform?: string) => {
9-
const buildResult = tmpNameSync();
10-
const imagePath = getContextPath("image");
11-
const binPath = path.join(
12-
path.dirname(new URL(import.meta.url).pathname),
13-
"..",
14-
"..",
15-
);
16-
const dockerfile = path.join(
17-
binPath,
18-
"compose",
19-
"rollups",
20-
"DockerfileDeploy.txt",
21-
);
22-
const args = [
23-
"buildx",
24-
"build",
25-
"-f",
26-
dockerfile,
27-
"--load",
28-
"--iidfile",
29-
buildResult,
30-
imagePath,
31-
];
32-
33-
// optional platform, default to not defining, which will build for the host platform
34-
if (platform) {
35-
args.push("--platform", platform);
36-
}
37-
38-
await execa("docker", args, { stdio: "inherit" });
39-
return fs.readFileSync(buildResult, "utf8");
40-
};
1+
import { Command } from "@commander-js/extra-typings";
2+
import chalk from "chalk";
413

424
export const createBuildCommand = () => {
435
return new Command("build")
446
.description(
45-
"Package the application in a Docker image ready to be deployed.",
7+
"DEPRECATED: Package the application in a Docker image ready to be deployed.",
468
)
47-
.addOption(
48-
new Option(
49-
"--platform <platform>",
50-
"Docker image target platform",
51-
).choices(["linux/amd64", "linux/arm64"]),
52-
)
53-
.option("--json", "Format output as json.")
54-
.action(async ({ platform, json }, command) => {
55-
// print machine hash
56-
const templateHash = getMachineHash();
57-
if (!templateHash) {
58-
command.error(
59-
`Cartesi machine snapshot not found, run 'build'`,
60-
);
61-
return;
62-
}
63-
logPrompt({
64-
title: "Cartesi machine templateHash",
65-
value: templateHash,
66-
});
67-
console.log("Building application node Docker image...");
68-
69-
const image = await buildRollupsImage(platform);
70-
logPrompt({
71-
title: "Application node Docker image",
72-
value: image,
73-
});
74-
75-
if (json) {
76-
process.stdout.write(JSON.stringify({ image }));
77-
}
9+
.action(async () => {
10+
console.warn(chalk.yellow("deploy build command is deprecated"));
7811
});
7912
};

apps/cli/src/compose/rollups/DockerfileDeploy.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

apps/cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const program = new Command()
3636
.addCommand(createBuildCommand())
3737
.addCommand(createCleanCommand())
3838
.addCommand(createCreateCommand())
39-
.addCommand(createDeployCommand())
39+
.addCommand(createDeployCommand(), { hidden: true })
4040
.addCommand(createDoctorCommand())
4141
.addCommand(createHashCommand())
4242
.addCommand(createRollupsCommand())

0 commit comments

Comments
 (0)