English | 中文
A CLI tool to sync local Markdown files to GitHub issues.
这款命令行工具可以把本地的 Markdown 文件同步到 GitHub issue。
- Bloggers who publish with GitHub issues and want to edit drafts locally, then publish new posts or update existing ones at any time.
- Open-source authors who publish documentation through GitHub issues and want to sync docs from the repository to specific issues.
- Anyone else who needs to update GitHub issues frequently.
Install it globally so you can call it from the command line at any time:
npm install -g kup-cli(When a new version of Kup is released, run the same command again to upgrade.)
kup ./path/to/file.md --repo foo/barKup will publish the content of file.md as a new issue in the foo/bar repository, and report the new issue number after it succeeds.
kup ./path/to/file.md --repo foo/bar --id 123Kup will update issue 123 in the foo/bar repository with the content of file.md.
Updating GitHub issues requires authentication, so you need to provide a GitHub token for Kup to call the GitHub API.
-
Create a new token on GitHub's "Personal access tokens" page, and make sure the
reposcope is selected. (See this document for details.) -
Put the token into an environment variable:
export GITHUB_TOKEN=ghp_**********
If Kup cannot read a token from the environment, it will prompt you for one in the terminal.
| Option | Short | Value Type | Description | Notes |
|---|---|---|---|---|
--repo |
-r |
string | Specify the GitHub repository | |
--id |
-i |
integer | Specify the issue number |
|
--version |
-v |
- | Show the version number | |
--help |
-h |
- | Show help information |
Kup can determine the repo option in the following order of priority:
- The
--repooption passed on the command line. - The
repofield in the Markdown file's metadata. - The
kup.repofield in the current project'spackage.json. Kup starts from the Markdown file's directory and searches upward for apackage.jsonfile. - If
kup.repois not present inpackage.json, Kup will try to infer the repository name from therepositoryfield and ask for confirmation before using it. - If that still fails, Kup will continue searching for
.git/configin the current or parent directories, then try to infer the repository name from theurlfield ofremote "origin"and ask for confirmation before using it.
If the entire project syncs to the same repository, it is usually best to configure kup.repo in package.json.
Kup can determine the id option in the following order of priority:
- The
--idoption passed on the command line. - The
idfield in the Markdown file's metadata.
After a file is successfully published as an issue, Kup immediately writes the id back into its metadata.
Kup determines the issue title using the following hints, in descending priority:
- The
titlefield in the Markdown file's metadata. - If the first Markdown block is an H1 heading (in
# Titleform), Kup uses its text as the title. In this case, that H1 heading is excluded from the synced content.
What happens if Kup still cannot determine the issue title?
- When publishing a new issue, Kup generates a title automatically.
- When updating an existing issue, Kup ignores the title, which means the existing title will not be changed.
Whether you are blogging or publishing regular issues, labels are often useful, so Kup supports them as well.
Add a tags field to the Markdown file's metadata and specify one or more labels. These labels do not need to exist in the GitHub repository beforehand. If a label does not already exist, it will be created automatically when the issue is published.
What happens if there is no tags field in the metadata?
- When publishing a new issue, Kup will not assign any labels.
- When updating an existing issue, Kup ignores labels, which means the existing labels will not be changed.
When updating an existing issue, if the labels specified in the metadata differ from the issue's current labels, the new set completely replaces the old one.
- See the issue list for this project for current plans.
- Feature requests and RFC discussions are welcome.
- Kup comes from the English word "pickup", suggesting lightweight transport.
- Kup is also a character in Transformers.
- The logo was created by Fasil and provided for free via freeicons.io.
Any code contributed to this project is considered authorized for commercial use by the project authors and their affiliated companies and distributed under this project's license.
任何贡献到本项目的代码,均视为授权本项目作者及其关联公司用于商业用途,并可按本项目协议进行分发。
MIT
