Skip to content

refactor(cli): split config.ts into config/ modules - #575

Merged
brunomenezes merged 5 commits into
prerelease/v2-alphafrom
refactor/cli-config-modules
Nov 3, 2026
Merged

brunomenezes merged 5 commits into
prerelease/v2-alphafrom
refactor/cli-config-modules

Conversation

@brunomenezes

Copy link
Copy Markdown
Member

Summary

config.ts had grown to 1200+ lines mixing three things: the parsed Config the rest of the CLI uses, the cartesi.toml parsers, and a couple of helpers only one builder needs. This splits it along those lines, with no behaviour change: every moved function is identical to the original apart from export, config.ts keeps exporting every name it exported before, and importers outside config/ don't change except for the two nvram helpers below.

Moving config.ts to config/index.ts was considered and left out. It would touch the import path in 31 files this PR otherwise doesn't change, so it's a separate follow-up if wanted.

config.ts                    parse, CONFIG_KEYS, re-exports
config/
  types.ts                   Config and every drive, nvram, machine and withdrawal type
  constants.ts, errors.ts    unchanged
  defaults.ts                defaultConfig, defaultRootDriveConfig, defaultMachineConfig
  size.ts                    splitSize, formatSize
  accounts.ts                accounts drive: getAccountsDrive, assertAccountsDrive*, LOG2_LEAF_SIZE
  toml/
    tables.ts                TomlTable helpers: isTomlTable, mergeTomlTables, assertKnownKeys
    values.ts                scalar parsers: parseString, parseSize, parseBytes, ...
    drives.ts, nvrams.ts, machine.ts, accounts.ts   one parser per table

Imports only go downward: config.ts → config/toml/* → the parsed side (accounts, defaults, size, types, constants, errors). toml/ holds parsing only. The defaults live on the parsed side, and toml/drives.ts and toml/machine.ts import them. Nothing under config/ imports config.ts.

parse reads as before: merge the files → check the top-level keys → parseDrives, parseNvrams → duplicate labels → [withdrawal], [machine], sdk → assertAccountsDrive.

No changeset added as nothing is user visible.

Changes:

  • builder/nvram.ts: gains nvramImageFilename and nvramHasImage, which describe the image this builder writes; machine.ts and commands/shell.ts import them from there.
  • config/toml/accounts.ts: the accounts_drive/accounts_drive_size marker shared by drives and nvrams, and the [withdrawal] table, which only applies to an application with an accounts drive.
  • getDriveFormat stays a parser helper in config/toml/drives.ts, exported through config.ts for builder/none.ts.
  • mergeTomlValues is dropped as nothing used it.
  • TomlPrimitive, deprecated by smol-toml 1.9 in favour of TomlValue, is replaced, and the local TomlTable by smol-toml's own, which is the same type.
  • Tests are untouched. They import from src/config.js.

@changeset-bot

changeset-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 549cf26

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@brunomenezes brunomenezes moved this to 👁 In Review in Rollups Tooling Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 91.2% (🎯 0%) 12399 / 13596
🔵 Statements 91.2% 12399 / 13596
🔵 Functions 81.87% 280 / 342
🔵 Branches 0% 0 / 0
📁 File Coverage (20 files)
File Lines Statements Functions Branches Uncovered Lines
apps/cli/src/base.ts 🔴 38.01% 🔴 38.01% 🟡 64.71% 🔴 0% 62, 70-74, 79, 93, 101-174,...
apps/cli/src/builder/directory.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/docker.ts 🟢 87.12% 🟢 87.12% 🟡 66.67% 🔴 0% 77-79, 81, 114-116, 174-183
apps/cli/src/builder/empty.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/none.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/nvram.ts 🟢 97.14% 🟢 97.14% 🟢 100% 🔴 0% 38
apps/cli/src/builder/tar.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/commands/foreclose.ts 🔴 49.09% 🔴 49.09% 🔴 50% 🔴 0% 69, 91-145
apps/cli/src/commands/refund.ts 🔴 38.2% 🔴 38.2% 🟡 66.67% 🔴 0% 55-109
apps/cli/src/commands/withdraw.ts 🔴 46.58% 🔴 46.58% 🟡 73.33% 🔴 0% 95-123, 277-278, 301-356, 3...
apps/cli/src/compose/anvil.ts 🟡 79.25% 🟡 79.25% 🟢 100% 🔴 0% 19-29
apps/cli/src/compose/builder.ts 🟢 99.79% 🟢 99.79% 🟢 100% 🔴 0% 228
apps/cli/src/compose/bundler.ts 🔴 4.82% 🔴 4.82% 🔴 0% 🔴 0% 8-40, 44-75, 79-92
apps/cli/src/compose/common.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/database.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/explorer.ts 🔴 6.67% 🔴 6.67% 🔴 0% 🔴 0% 10-38, 43-55, 59-72
apps/cli/src/compose/node.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/passkey.ts 🔴 8.33% 🔴 8.33% 🔴 0% 🔴 0% 9-18, 23-42, 46-59
apps/cli/src/compose/paymaster.ts 🔴 7.69% 🔴 7.69% 🔴 0% 🔴 0% 8-21, 25-44, 48-61
apps/cli/src/compose/proxy.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -

@github-project-automation github-project-automation Bot moved this from 👁 In Review to 👍 Waiting Merge in Rollups Tooling Nov 3, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Waiting Merge in Rollups SDK Nov 3, 2026
@brunomenezes
brunomenezes merged commit 0911b6c into prerelease/v2-alpha Nov 3, 2026
5 of 6 checks passed
@brunomenezes
brunomenezes deleted the refactor/cli-config-modules branch November 3, 2026 15:37
@github-project-automation github-project-automation Bot moved this from 👍 Waiting Merge to 📦 Done in Rollups Tooling Nov 3, 2026
@github-project-automation github-project-automation Bot moved this from Waiting Merge to Done in Rollups SDK Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done
Status: 📦 Done

Development

Successfully merging this pull request may close these issues.

2 participants