npm 脚本可以使用 Github API 将包发布到 Github 吗?

Can an npm script publish a package to Github using the Github API?

我正在尝试使用此脚本进行首次提交并将包公开发布到 Github。 { "scripts": { "first": "git add -A && git commit -m \"First commit\" && A='{\"name\":\"'$npm_package_name'\",\"description\":\"'$npm_package_description'\",\"license_template\":\"'$npm_package_license'\"}' && echo \"${A}\" && curl -u $npm_package_author_name 'https://api.github.com/'$npm_package_author_name'/'$npm_package_name -d \"$A\" && git remote add origin 'https://github.com/'$npm_package_author_name'/'$npm_package_name'.git' && git push -u origin master" } } 我不断收到此错误。我已经搜索了文档,但无法弄清楚原因。这不可能吗?请帮忙! { "message": "Not Found", "documentation_url": "https://developer.github.com/v3" }

编辑: 这是工作脚本!我必须进行一些更改才能与 Github 的 origin/master 添加许可证文件的原始提交合并。 github api create repository doc for reference

"first": "O='{\"name\":\"'$npm_package_name'\",\"description\":\"'$npm_package_description'\",\"license_template\":\"'$npm_package_license'\"}' && echo \"${O}\" && curl -u $npm_package_author_name https://api.github.com/user/repos -d \"${A}\" && git add -A && git commit -m \"initial\" && git remote add origin 'https://github.com/'$npm_package_author_name'/'$npm_package_name'.git' && git merge origin/master --allow-unrelated-histories -m $npm_package_version && git push --set-upstream origin master && git push && git push --tags"

尝试从您的脚本中删除命令,直到它正常工作,以确定是哪个部分触发了该消息。

https://api.github.com/'$npm_package_author_name'/'$npm_package_name URL 看起来很奇怪,因为 GitHub API usually has a generic name after https://api.github.com/, like https://api.github.com/user (User API)

您还可以考虑更成熟的 npm 包,例如 release-it