Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changes/release-1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### Changed — may break callers

- **Built on cli-core 1.0.0 and cli-base 1.0.0.** A new CLI's generated API files read their types from
`@wirecat/cli-base/codegen/runtime`, the WordPress seed's `spec-model.ts` uses `ModelOverride`, and the GraphQL seed's
test takes `SchemaNode` from `/codegen/runtime`. A CLI from a WordPress config also tests that a sync which would
mark every post deleted stays held, with `--rescan` too, until `--allow-deletions` names the count.
1 change: 1 addition & 0 deletions contracts/help.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Works with:
mail IMAP mail in the same local store: search your mailbox offline, next to your other WireCat data
b24 Bitrix24 CRM: deals, leads and pipelines, searchable with your other WireCat data
amo amoCRM and Kommo: deals, contacts and companies, searchable with your other WireCat data
attio Attio CRM: deals, people and companies, searchable with your other WireCat data
pbx Asterisk PBX calls and recordings, searchable with your other WireCat data
notion Notion pages and databases as local text, searchable with your other WireCat data
ydisk Yandex Disk folders as local text, searchable with your other WireCat data
Expand Down
31 changes: 31 additions & 0 deletions kit/seeds/config/src/content-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,34 @@ it("every option of the content commands runs over a synced copy", async () => {
const refused = await ran(["api", create.command, "--body", "{}", "--dry-run"])
expect(refused.json()).toMatchObject({ error: { code: "permission_error", details: { permission: "posts.create" } } })
})

// The mass-deletion guard is the owner's to lift, by count: a rescan only lists everything again.
it("holds a sync that would mark every post deleted, rescan or not, until --allow-deletions names the count", async () => {
const keyring = memoryKeyring()
const [login, password] = FAKE_API_TOKEN.split(":") as [string, string]
await runCli(["guard", "session", "start", "--site", FAKE_SITE, "--login", login, "--json"], {
keyring,
service: fakeServiceApi(),
stdin: password,
})
const service = contentManifestFake(SOURCE, { api: API.manifest })
const ran = (argv: string[]) => runCli(["guard", ...argv, "--json"], { keyring, service })
const posts = async () =>
((await ran(["posts", "list"])).json() as { items: { external_id: string; type: string }[] }).items.filter(
(one) => one.type === "post",
)
expect((await ran(["sync"])).code).toBe(0)
const ids = service.ids("post")
const listed = (await posts()).length
expect(listed).toBeGreaterThan(0)
for (const id of ids) service.remove("post", id)

const held = await ran(["sync", "--rescan"])
expect(held.code, held.err).toBe(0)
expect(held.out).toContain(`--allow-deletions ${ids.length}`)
expect((await posts()).length).toBe(listed)

const allowed = await ran(["sync", "--rescan", "--allow-deletions", String(ids.length)])
expect(allowed.code, allowed.err).toBe(0)
expect(await posts()).toEqual([])
})
3 changes: 2 additions & 1 deletion kit/seeds/graphql/src/api.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { join } from "node:path"
import { graphqlFake, type SchemaNode, sampleOf } from "@wirecat/cli-base/codegen"
import { graphqlFake, sampleOf } from "@wirecat/cli-base/codegen"
import type { SchemaNode } from "@wirecat/cli-base/codegen/runtime"
import { apiFlagOf, manifestBaseUrl, sendsBytes } from "@wirecat/cli-core/cli"
import { pacePathFor } from "@wirecat/cli-core/sends"
import { afterEach, expect, it } from "vitest"
Expand Down
4 changes: 2 additions & 2 deletions kit/seeds/wp-json/scripts/spec-model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from "node:path"
import { type ApiModel, adaptOpenApi, type Override, readWpJson, wpJsonToOpenApi } from "@wirecat/cli-base/codegen"
import { type ApiModel, adaptOpenApi, type ModelOverride, readWpJson, wpJsonToOpenApi } from "@wirecat/cli-base/codegen"

// SAMPLE: the WordPress namespaces the CLI offers. A plugin's namespace belongs to the sites that run the plugin;
// batch/v1 is never offered, as one batch call runs other routes' writes past their own keys.
Expand All @@ -11,7 +11,7 @@ const NAMESPACES = ["wp/v2"]
*/
export const specModel = async (
root: string,
): Promise<{ model: ApiModel; notes: string[]; overrides: Record<string, Override> }> => {
): Promise<{ model: ApiModel; notes: string[]; overrides: Record<string, ModelOverride> }> => {
const index = readWpJson(join(root, "spec/clidev"))
// An application password's answer is marked secret by the converter, and cli-core offers no api command for it.
const { document, omissions, overrides } = wpJsonToOpenApi(index, {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
"kit:docs": "cspell lint --config cspell.json --no-progress --no-summary kit/*.md SKILL.md && rumdl check --config config/wirecat/rumdl.toml kit/*.md SKILL.md"
},
"dependencies": {
"@wirecat/cli-base": "0.126.1",
"@wirecat/cli-core": "0.722.0",
"@wirecat/cli-base": "1.0.0",
"@wirecat/cli-core": "1.0.0",
"commander": "15.0.0",
"valibot": "1.5.0",
"yaml": "2.9.1"
Expand Down
32 changes: 16 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading