Compare commits

...
Author SHA1 Message Date
saberzero1 57b3b5d0af fix(cli): a disabled plugin that can't be updated warns instead of failing the update 2026-11-27 23:20:59 +01:00
Emile Bangma c317915450 Merge pull request #2718 from jackyzha0/dev-mode/utils-1.3.4
chore(deps): utils 1.3.4 (tag links under a base path)
2026-11-27 23:12:02 +01:00
3 changed files with 86 additions and 0 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
`npx quartz plugin install --latest` (and `plugin update`) no longer fails because a disabled plugin can't be updated, for example an old `quartz-themes` entry whose repository moved its plugin. The build doesn't load disabled plugins, so this is now a warning that says how to remove the entry. A failing enabled plugin still fails the command.
+17
View File
@@ -1160,6 +1160,13 @@ export async function handlePluginInstallUnified({
const pluginsToUpdate = nameFilter ? Array.from(nameFilter) : Object.keys(lockfile.plugins)
const updatedPlugins = []
let lockfileChanged = false
// Disabled in the config: the build never loads them, so failing to update one is a warning,
// not a failed update (an old entry whose repository changed layout failed every update).
const disabledNames = new Set(
(pluginsJson?.plugins ?? [])
.filter((entry) => entry.enabled === false)
.map((entry) => extractPluginName(entry.source)),
)
// Phase 1: Validate and categorize plugins (fast, sequential)
const validPlugins = []
@@ -1244,6 +1251,16 @@ export async function handlePluginInstallUnified({
}
}
} catch (error) {
if (disabledNames.has(name)) {
console.log(
styleText(
"yellow",
`⚠ Could not update ${name} (disabled, so the build does not load it): ${describeCommandError(error)}\n` +
` Remove it with \`npx quartz plugin remove ${name}\` or fix its source.`,
),
)
return
}
console.log(
styleText("red", `✗ Failed to update ${name}: ${describeCommandError(error)}`),
)
+64
View File
@@ -294,3 +294,67 @@ describe("plugin commands with an extending config", () => {
assert.doesNotMatch(read(dir), /comments/)
})
})
describe("plugin install --latest with a plugin that can't be updated", () => {
const cli = path.resolve(import.meta.dirname, "..", "bootstrap-cli.mjs")
// A Git plugin whose repository no longer has the configured subdirectory (an old
// quartz-themes entry: the repository moved its plugin out of `plugin/`).
const site = (enabled) => {
const repo = path.join(root, "repo")
fs.mkdirSync(repo, { recursive: true })
fs.writeFileSync(path.join(repo, "README.md"), "no plugin/ here\n")
const git = (args) => execSync(`git ${args}`, { cwd: repo, stdio: "ignore", timeout: 30_000 })
git("init -q -b main")
git("-c user.name=t -c user.email=t@t add .")
git("-c user.name=t -c user.email=t@t commit -q -m init")
const url = pathToFileURL(repo).href
const dir = path.join(root, "site")
fs.mkdirSync(path.join(dir, ".quartz", "plugins", "old-theme"), { recursive: true })
fs.writeFileSync(path.join(dir, "package.json"), `{ "name": "site", "version": "5.3.1" }`)
fs.writeFileSync(
path.join(dir, "quartz.config.yaml"),
YAML.stringify({
configuration: { pageTitle: "t" },
plugins: [{ source: { name: "old-theme", repo: url, subdir: "plugin" }, enabled }],
}),
)
fs.writeFileSync(
path.join(dir, "quartz.lock.json"),
JSON.stringify({
version: "1.0.0",
plugins: {
"old-theme": {
source: url,
resolved: url,
subdir: "plugin",
commit: "0000000000000000000000000000000000000000",
installedAt: "2026-01-01T00:00:00.000Z",
},
},
}),
)
return dir
}
const run = (dir) => {
const result = spawnSync(process.execPath, [cli, "plugin", "install", "--latest"], {
cwd: dir,
encoding: "utf-8",
timeout: 60_000,
env: { ...process.env, QUARTZ_CONFIG_PATH: "" },
})
return { output: result.stdout + result.stderr, status: result.status }
}
test("a disabled plugin only warns: the build doesn't load it", () => {
const { output, status } = run(site(false))
assert.match(output, /Could not update old-theme \(disabled/)
assert.match(output, /npx quartz plugin remove old-theme/)
assert.strictEqual(status, 0)
})
test("an enabled plugin fails the update", () => {
const { output, status } = run(site(true))
assert.match(output, /Failed to update old-theme/)
assert.strictEqual(status, 1)
})
})