From 140ed2d00fee47f149d00ab624d6dd0c3647c066 Mon Sep 17 00:00:00 2001 From: Kamil Listopad Date: Wed, 22 Apr 2026 18:05:07 +0200 Subject: [PATCH 1/2] Allow [moc], [canisters], [build], [lint] in mops publish These sections are documented in mops.toml reference and used for local development workflows (check/build/test/lint). They were incorrectly rejected by `mops publish` with "Unknown config section", forcing publishers to strip them before each publish. Fixes #512 Made-with: Cursor --- cli/CHANGELOG.md | 1 + cli/commands/publish.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 968ef137..e877c3a1 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -1,6 +1,7 @@ # Mops CLI Changelog ## Next +- Fix `mops publish` rejecting `[moc]`, `[canisters]`, `[build]`, and `[lint]` sections in `mops.toml` (#512) ## 2.12.2 - Fix `mops install` (and any `--lock check` flow) failing with "Mismatched number of resolved packages" when a project's resolved dependencies include multiple aliases (e.g. `base`, `base@0`, `base@0.16`) that pin to the same `name@version` diff --git a/cli/commands/publish.ts b/cli/commands/publish.ts index 79814c71..e23a5d6e 100644 --- a/cli/commands/publish.ts +++ b/cli/commands/publish.ts @@ -56,6 +56,10 @@ export async function publish( "dev-dependencies", "toolchain", "requirements", + "moc", + "canisters", + "build", + "lint", ].includes(key) ) { console.log(chalk.red("Error: ") + `Unknown config section [${key}]`); From c6052a71b91374c30aee6a678e4cd5169344b16e Mon Sep 17 00:00:00 2001 From: Kamil Listopad Date: Wed, 22 Apr 2026 18:19:23 +0200 Subject: [PATCH 2/2] Drop unknown-section/key/requirement guards from mops publish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These three publish-only allowlists drifted from the docs/types and were the only place in the CLI that complained about unknown keys. Backend validateConfig.mo still enforces the real schema (unknown requirements, length caps, dependency rules, "not supported yet" fields), so removing the CLI guards loses no real protection. The [requirements] guard was also already broken — it used `return` inside a forEach, which neither stops iteration nor exits the process, so it only printed a red message and continued. Made-with: Cursor --- cli/CHANGELOG.md | 2 +- cli/commands/publish.ts | 52 ----------------------------------------- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index e877c3a1..55a072d9 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -1,7 +1,7 @@ # Mops CLI Changelog ## Next -- Fix `mops publish` rejecting `[moc]`, `[canisters]`, `[build]`, and `[lint]` sections in `mops.toml` (#512) +- `mops publish` no longer rejects unknown `mops.toml` sections, `package.*` keys, or `requirements.*` entries — these typo guards were the only place in the CLI that complained about unknown keys, drifted from the docs/types, and blocked publish on harmless local-only config like `[moc]`, `[canisters]`, `[build]`, and `[lint]` (#512) ## 2.12.2 - Fix `mops install` (and any `--lock check` flow) failing with "Mismatched number of resolved packages" when a project's resolved dependencies include multiple aliases (e.g. `base`, `base@0`, `base@0.16`) that pin to the same `name@version` diff --git a/cli/commands/publish.ts b/cli/commands/publish.ts index e23a5d6e..40e6651d 100644 --- a/cli/commands/publish.ts +++ b/cli/commands/publish.ts @@ -47,26 +47,6 @@ export async function publish( console.log(`Publishing ${config.package?.name}@${config.package?.version}`); - // validate - for (let key of Object.keys(config)) { - if ( - ![ - "package", - "dependencies", - "dev-dependencies", - "toolchain", - "requirements", - "moc", - "canisters", - "build", - "lint", - ].includes(key) - ) { - console.log(chalk.red("Error: ") + `Unknown config section [${key}]`); - process.exit(1); - } - } - // required fields if (!config.package) { console.log( @@ -101,29 +81,6 @@ export async function publish( } } - let packageKeys = [ - "name", - "version", - "keywords", - "description", - "repository", - "documentation", - "homepage", - "baseDir", - "readme", - "license", - "files", - "dfx", - "moc", - "donation", - ]; - for (let key of Object.keys(config.package)) { - if (!packageKeys.includes(key)) { - console.log(chalk.red("Error: ") + `Unknown config key 'package.${key}'`); - process.exit(1); - } - } - // disabled fields for (let key of ["dfx", "moc", "homepage", "documentation", "donation"]) { if ((config.package as any)[key]) { @@ -226,15 +183,6 @@ export async function publish( } } - if (config.requirements) { - Object.keys(config.requirements).forEach((name) => { - if (name !== "moc") { - console.log(chalk.red("Error: ") + `Unknown requirement "${name}"`); - return; - } - }); - } - let toBackendDep = (dep: Dependency): DependencyV2 => { return { ...dep,