我在 github 上建立了一个satis存储库,用于跨项目共享一些公司内部包。
现在,当我尝试“依赖”新存储库时,我尝试了以下操作:
"repositories": [ {
"type": "composer",
"url": "https://raw.githubusercontent.com/[organisation]/satis/master/web/packages.json?token=[token-copied-from-url]"
} ]
Run Code Online (Sandbox Code Playgroud)
它工作得足够好,composer 找到了 package.json,但是,它失败了:
[Composer\Downloader\TransportException]
The "https://raw.githubusercontent.com/[organization]/satis/master/web/packages.json?token=[token-copied-from-url]/include/all$[some-json-file].json" file could not be downloaded (HTTP/1.1 404 Not Found)
Run Code Online (Sandbox Code Playgroud)
这并不奇怪,因为 ?token 部分似乎生成了无效的 URL。
我可以通过手动将包含文件的内容直接移动到packages.json 中来解决这个问题,但这不太理想,特别是当 satis 决定生成多个文件时。
我认为这会导致的另一个问题是我不太了解令牌的有效性。也许它的寿命不长,然后需要定期重新生成。
有没有办法可以将我的 satis 存储库托管为“只是”github 存储库?
初步测试表明这是可以做到的。
我认为您需要从存储库 URL 中删除packages.json,并且我怀疑 ?token 参数。理论上,您可以通过标头传递令牌:
https://developer.github.com/v3/#authentication
不过我还没有测试过。
您可以在此处查看无需身份验证的工作测试:
尝试一下:
git clone git@github.com:markchalloner/satishostcomposer.git
cd satishostcomposer
composer install
Run Code Online (Sandbox Code Playgroud)
应该安装供应商/markchalloner/satishostdemo
示例 satis.json:
{
"name": "Satis Host",
"homepage": "https://raw.githubusercontent.com/markchalloner/satishost/master/web/",
"archive": {
"directory": "dist",
"format": "tar",
"prefix-url": "https://raw.githubusercontent.com/markchalloner/satishost/master/web/",
"skip-dev": true
},
"repositories": [
{
"_comment": "Demo packages",
"type": "package",
"package": {
"name": "markchalloner/satishostdemo",
"version": "0.1.0",
"dist": {
"type": "zip",
"url": "dist/demo.zip"
}
}
}
],
"require-all": true
}
Run Code Online (Sandbox Code Playgroud)
示例composer.json(在您的项目中):
{
"repositories": [
{
"type": "composer",
"url": "https://raw.githubusercontent.com/markchalloner/satishost/master/web",
"options": {
"http": {
"header": [
"API-TOKEN: YOUR-API-TOKEN"
]
}
}
}
],
"require": {
"markchalloner/satishostdemo": "0.1.0"
},
"minimum-stability": "dev"
}
Run Code Online (Sandbox Code Playgroud)
谢谢
| 归档时间: |
|
| 查看次数: |
1030 次 |
| 最近记录: |