Skip to content

Commit c58458f

Browse files
authored
fix: Drop unknown-section/key/requirement guards from mops publish (#513)
Fixes #512. `mops publish` rejected `[moc]`, `[canisters]`, `[build]`, and `[lint]` sections in `mops.toml` even though all four are documented and used by other mops commands. The check was one of three publish-only typo guards (top-level sections, `[package].*` keys, `[requirements].*` keys) — all dropped, because: - They drifted from the docs/types every time a new section shipped (#512 was the result). - No other command complains about unknown keys, so typos silently work everywhere except publish. - The `[requirements]` guard was already broken — `return` inside `forEach` only printed a red message and continued. Backend `validateConfig.mo` still enforces the real schema (unknown requirements, length caps, "not supported yet" fields, dependency rules), so no real protection is lost. All other publish validations are untouched. ## Test plan - [ ] `mops publish` succeeds with `[moc]`, `[canisters]`, `[build]`, `[lint]` sections - [ ] Backend still rejects unknown `[requirements]` entries - [ ] Other publish validations (local/GitHub deps, disabled `package.*` fields) still fire
1 parent caa48ce commit c58458f

2 files changed

Lines changed: 1 addition & 48 deletions

File tree

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Mops CLI Changelog
22

33
## Next
4+
- `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)
45

56
## 2.12.2
67
- 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`

cli/commands/publish.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,6 @@ export async function publish(
4747

4848
console.log(`Publishing ${config.package?.name}@${config.package?.version}`);
4949

50-
// validate
51-
for (let key of Object.keys(config)) {
52-
if (
53-
![
54-
"package",
55-
"dependencies",
56-
"dev-dependencies",
57-
"toolchain",
58-
"requirements",
59-
].includes(key)
60-
) {
61-
console.log(chalk.red("Error: ") + `Unknown config section [${key}]`);
62-
process.exit(1);
63-
}
64-
}
65-
6650
// required fields
6751
if (!config.package) {
6852
console.log(
@@ -97,29 +81,6 @@ export async function publish(
9781
}
9882
}
9983

100-
let packageKeys = [
101-
"name",
102-
"version",
103-
"keywords",
104-
"description",
105-
"repository",
106-
"documentation",
107-
"homepage",
108-
"baseDir",
109-
"readme",
110-
"license",
111-
"files",
112-
"dfx",
113-
"moc",
114-
"donation",
115-
];
116-
for (let key of Object.keys(config.package)) {
117-
if (!packageKeys.includes(key)) {
118-
console.log(chalk.red("Error: ") + `Unknown config key 'package.${key}'`);
119-
process.exit(1);
120-
}
121-
}
122-
12384
// disabled fields
12485
for (let key of ["dfx", "moc", "homepage", "documentation", "donation"]) {
12586
if ((config.package as any)[key]) {
@@ -222,15 +183,6 @@ export async function publish(
222183
}
223184
}
224185

225-
if (config.requirements) {
226-
Object.keys(config.requirements).forEach((name) => {
227-
if (name !== "moc") {
228-
console.log(chalk.red("Error: ") + `Unknown requirement "${name}"`);
229-
return;
230-
}
231-
});
232-
}
233-
234186
let toBackendDep = (dep: Dependency): DependencyV2 => {
235187
return {
236188
...dep,

0 commit comments

Comments
 (0)