Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/all-goats-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/cli": patch
---

migrate compose from YAML to TS
7 changes: 3 additions & 4 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"semver": "^7.7.2",
"smol-toml": "^1.4.2",
"tmp": "^0.2.5",
"viem": "^2.37.6"
"viem": "^2.37.6",
"yaml": "^2.8.2"
},
"devDependencies": {
"@biomejs/biome": "catalog:",
Expand All @@ -56,7 +57,6 @@
"@types/tmp": "^0.2.6",
"@vitest/coverage-istanbul": "^3.2.4",
"@wagmi/cli": "^2.5.1",
"copyfiles": "^2.4.1",
"npm-run-all": "^4.1.5",
"rimraf": "^6.0.1",
"ts-node": "^10.9.2",
Expand All @@ -66,13 +66,12 @@
"vitest": "^3.2.4"
},
"scripts": {
"build": "run-s clean codegen compile copy-files",
"build": "run-s clean codegen compile",
"clean": "rimraf dist",
"codegen": "run-p codegen:wagmi",
"codegen:wagmi": "wagmi generate",
"compile": "tsc -p tsconfig.build.json",
"postcompile": "chmod +x dist/index.js",
"copy-files": "copyfiles -u 1 \"src/**/*.yaml\" \"src/**/*.env\" \"src/**/*.txt\" dist",
"lint": "biome lint",
"posttest": "pnpm lint",
"test": "vitest"
Expand Down
4 changes: 2 additions & 2 deletions apps/cli/src/commands/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export const createLogsCommand = () => {

const serviceInfo = await getServiceInfo({
projectName,
service: "rollups-node",
service: "rollups_node",
});
if (!serviceInfo) {
throw new Error(`service rollups-node not found`);
throw new Error(`service rollups_node not found`);
}

await execa(
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/commands/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const createStatusCommand = () => {

const status = await getServiceState({
projectName,
service: "rollups-node",
service: "rollups_node",
});
const deployments = await getDeployments({
projectName,
Expand Down
63 changes: 63 additions & 0 deletions apps/cli/src/compose/anvil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import type { ComposeFile, Config, Service } from "../types/compose.js";
import { DEFAULT_HEALTHCHECK } from "./common.js";

type ServiceOptions = {
imageTag?: string;
blockTime?: number;
};

// Anvil service
const service = (options?: ServiceOptions): Service => {
const blockTime = options?.blockTime ?? 2;
const imageTag = options?.imageTag ?? "latest";

return {
image: `cartesi/sdk:${imageTag}`,
command: ["devnet", "--block-time", blockTime.toString()],
healthcheck: {
...DEFAULT_HEALTHCHECK,
test: ["CMD", "eth_isready"],
},
environment: {
ANVIL_IP_ADDR: "0.0.0.0",
},
};
};

const proxy = (): Config => ({
name: "anvil-proxy",
content: `http:
routers:
anvil:
rule: "PathPrefix(\`/anvil\`)"
middlewares:
- "remove-anvil-prefix"
service: anvil
middlewares:
remove-anvil-prefix:
replacePathRegex:
regex: "^/anvil(.*)"
replacement: "$1"
services:
anvil:
loadBalancer:
servers:
- url: "http://anvil:8545"`,
});

export default (options?: ServiceOptions): ComposeFile => ({
configs: {
anvil_proxy: proxy(),
},
services: {
anvil: service(options),
proxy: {
configs: [
{
source: "anvil_proxy",
target: "/etc/traefik/conf.d/anvil.yaml",
},
],
},
},
});
Loading
Loading