mirror of
https://github.com/jackyzha0/quartz
synced 2026-11-27 22:14:40 +01:00
fix(plugins): a disabled dependency is a warning, not a missing plugin that fails the build
This commit is contained in:
3 files changed
+26
-1
No files matched your search
@@ -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/)
|
||||
})
|
||||
})
|
||||
@@ -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}`)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user