Skip to content

feat: add doc update --publish to publish drafts - #156

Merged
scottlovegrove merged 2 commits into
Doist:mainfrom
andriykohut:feat/doc-update-publish
Oct 23, 2026
Merged

scottlovegrove merged 2 commits into
Doist:mainfrom
andriykohut:feat/doc-update-publish

Conversation

@andriykohut

@andriykohut andriykohut commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

ol doc create makes a draft unless --publish is passed, but there was no way to publish that draft later without the web UI. ol doc update now takes --publish, which sets publish: true on documents.update, the same way doc create does. It works on its own (ol doc update <id> --publish), leaving the title and text untouched, and the output says Published: instead of Updated:.

Drafts created in the web UI can have no collection, and Outline won't publish those without a collectionId. For them, --collection <ref> names the collection to publish into, resolved like the other collection options. Outline ignores collectionId on update unless publishing, so --collection without --publish stops with an error instead of doing nothing. The README and the skill list both forms.

Tested: npm test (236 passing, with tests that --publish sends only { id, publish: true }, that --collection sends the resolved collectionId, and that --collection alone errors before any API call), type-check, lint, format and the skill sync check. Against self-hosted Outline 1.11.0: doc update <draft> --publish publishes a CLI-created draft with its title and text unchanged, and a plain doc update leaves a draft unpublished. A draft created without a collection fails with collectionId is required to publish a draft without collection on --publish alone, and --publish --collection <ref> publishes it into that collection.

`doc create` makes a draft unless `--publish` is passed, and there was
no way to publish that draft later without the web UI. `doc update`
now takes `--publish`, which sets `publish: true` on `documents.update`.
It works on its own, leaving the title and text untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@scottlovegrove scottlovegrove left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this works as described for drafts created through the CLI. A couple of comments inline, the first being the more important one.

Comment thread src/commands/document.ts
.option('--title <title>', 'New title')
.option('--text <text>', 'New body (markdown)')
.option('--file <path>', 'Read markdown from file')
.option('--publish', 'Publish a draft')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work for drafts that don't belong to a collection, which you can create from the web UI. For those, Outline's authorizeDocumentPublish requires a collectionId in the request and rejects with collectionId is required to publish a draft without collection (source), and there's currently no way to pass one from the CLI. Drafts made with ol doc create always have a collection because it requires --collection or --parent, which is why it works in your testing.

Could you add a --collection <ref> option to doc update that resolves via resolveCollectionId and sends collectionId alongside publish: true? documents.update already accepts collectionId for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks.

Added in fa1c940:

doc update now takes --collection <ref>, resolved via resolveCollectionId, and sends it as collectionId alongside publish: true. Outline only uses collectionId on update when publishing, so --collection without --publish now errors (pointing to doc move) instead of silently doing nothing. Checked against Outline 1.11.0 with a draft created without a collection: --publish alone gets collectionId is required to publish a draft without collection, and --publish --collection <ref> publishes it into that collection.

Comment thread src/commands/document.ts
if (rawText) body.text = rawText
if (opts.title) body.title = opts.title
}
if (opts.publish) body.publish = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: with --publish the output further down still prints Updated: <title>. Printing Published: <title> in that case would make it clearer the publish happened.

…-collection`

Drafts created in the web UI can have no collection, and Outline
rejects publishing them unless `collectionId` is sent. `doc update`
now takes `--collection <ref>`, resolved like the other collection
options. Outline ignores `collectionId` on update unless publishing,
so `--collection` without `--publish` is rejected instead of being a
silent no-op. With `--publish`, the output says `Published:`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scottlovegrove
scottlovegrove merged commit e155c92 into Doist:main Oct 23, 2026
5 checks passed
doist-release-bot Bot added a commit that referenced this pull request Oct 23, 2026
## [2.2.0](v2.1.12...v2.2.0) (2026-10-23)

### Features

* add `doc update --publish` to publish drafts ([#156](#156)) ([e155c92](e155c92))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@andriykohut
andriykohut deleted the feat/doc-update-publish branch October 23, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants