cssmagic / kup Goto Github PK
View Code? Open in Web Editor NEWA CLI tool to sync local Markdown files to GitHub issues.
License: MIT License
A CLI tool to sync local Markdown files to GitHub issues.
License: MIT License
$HOME/.cmcm/kup/config.json
{
"tokens":{
"github":"___access__token___"
}
}
{
"tokens":{
"github":{
"username1":"___access__token___",
"username2":"___access__token___"
}
}
}
🤔 默认用户如何指定?每次询问还是自动取第一个?
{
"tokens":{
"github":{
"username1":"___access__token___",
"username2":"___access__token___"
},
"gitlab":"___access__token___"
}
}
这是迟早要做的。
这个功能具体怎么设计,还需要好好想想。是支持多个文件,还是支持 glob,还是支持自动获取近期变更的……
增加 -d
--dump
布尔值选项,如果有,则进行反向操作(不是发布,而是采集)。
获取 repo 和 id 参数的逻辑不变。
此时如果不指定文件,则自动在当前目录生成一个文件,命名为 {repo-owner}--{repo-name}--{id}.md
。采集成功后写入 YAML 元数据。
这是目前的已知问题。
但具体怎么处理,需要想一想。因为后续会支持批处理多文件,需要综合考虑。
用户可能会通过环境变量指定代理:
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890
需要识别这个代理配置并通过此代理发送请求。
需要在 Markdown 文件内添加一些元数据,以便 Kup 正确投递。
考虑到在 Markdown 顶部添加 YAML 格式的元数据已是较为普遍的做法:
因此,Kup 也打算采用这种方式。
---
title: The title of this issue
repo: cssmagic/kup
id: 168
tags:
- JS
- RFC
---
Markdown 正文
Markdown 正文
Markdown 正文
kup <file> [--repo aaa/bbb] [--id 123]
准备工作:需要测试一下,最小化的权限范围是哪些。
目前是拿 RFC #1 凑数,回头还是要写一篇正式的文档。
允许用户在 package.json
中一次性指定目标 repo。
操作 GitHub issue 是需要权限认证的,因此你需要向 Kup 提供 GitHub token,以便 Kup 调用 GitHub API。
进入 “Personal access tokens” 页面可以查看已经生成的 token。点击右上角的 “Generate new token” 按钮开始生成一个新的 token。
在生成新 token 之前,GitHub 通常会要求你输入登录密码来验证身份。毕竟是涉及身份和权限的敏感操作,安全第一。
验证通过,进入生成 token 的表单,填写必要的信息:
点击页面底部的 “Generate token” 按钮即可生成新 token。
随后我们回到第 1 步的 token 列表页,可以看到新 token 的明文,我们需要立即把它复制下来并妥善保管。因为刷新页面之后,GitHub 将不再展示 token 内容。如果遗忘了这个 token,我们只能把它删除后重新生成。
拥有 token 的人可以在不知道你的密码的情况下以你的名义调用 GitHub API,它在一定程度上就相当于你的账号密码,因此不要把 token 告诉其他人。
如果你把 token 写入代码并提交到 GitHub 上的公开仓库,或者把它发布到公开仓库的 issue 或评论内,相当于这个 token 已经泄漏,那么 GitHub 出于安全考虑会立即删掉这个 token。
由于 Kup 目前还没有保存 token 的功能,你需要在使用 Kup 之前通过环境变量把 token 传递给 Kup:
export GITHUB_TOKEN=ghp_**********
为了避免每次使用 Kup 之前都要重复这个动作,你可以把这行命令写入 ~/.zshrc
或 ~/.bash_profile
这样的终端初始化文件。
如果 repo 参数是猜测出来的,在进行下一步操作之前,需要向用户确认。
定位 Git 仓库的根目录:
git rev-parse --show-toplevel
获取 origin 的地址:
git remote get-url origin
Node.js 调用 Git 命令:
https://github.com/typicode/husky/blob/main/src/index.ts#L9-L10
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.