fix(plugins): a disabled dependency is a warning, not a missing plugin that fails the build

This commit is contained in:
saberzero1 committed 2026-11-09 21:59:17 +01:00
1 parent db6e72fad7
commit 85d2b43df0
3 files changed
+26 -1

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
A plugin whose dependency is configured but disabled gets the intended warning ("depends on X which is disabled") instead of failing the build with "requires X. Run: npx quartz plugin add X".
@@ -373,3 +373,19 @@ describe("dependencies on plugins that are built in now", () => {
assert.match(errors[0], /requires "@quartz-community\/explorer"/)
})
})
describe("a dependency that is configured but disabled", () => {
test("is a warning, not a missing plugin", () => {
const dep = "@quartz-community/explorer"
const entries: PluginJsonEntry[] = [
{ source: "github:someone/x", enabled: true, options: {} },
{ source: dep, enabled: false, options: {} },
]
const manifests = new Map<string, PluginManifest>([
["github:someone/x", { dependencies: [dep] } as unknown as PluginManifest],
])
const { errors, warnings } = validateDependencies(entries, manifests, [])
assert.deepStrictEqual(errors, [])
assert.match(warnings[0], /depends on "@quartz-community\/explorer" which is disabled/)
})
})
+5 -1
View File
@@ -215,6 +215,8 @@ export function validateDependencies(
warnings.push(
`Plugin "${pluginName}" depends on "${depName}" which is disabled. "${pluginName}" may not function correctly.`,
)
// it doesn't run, so its order doesn't matter (and its manifest isn't loaded)
continue
}
const depManifest = manifests.get(dep)
@@ -506,7 +508,9 @@ export async function loadQuartzConfig(
)
// Validate dependencies
const validation = validateDependencies(enabledEntries, manifests, builtinPlan.builtins)
// all entries: a dependency that is configured but disabled is a warning, not "missing"
// (validateDependencies skips disabled plugins itself)
const validation = validateDependencies(pluginEntries, manifests, builtinPlan.builtins)
for (const warning of validation.warnings) {
console.warn(styleText("yellow", `⚠`) + ` ${warning}`)
}