sweetchuck / composer-repo-path
@todo 项目描述
1.x-dev
2023-12-26 16:52 UTC
Requires
- php: >=7.4
- composer-plugin-api: ^2.0
- ext-json: *
Requires (Dev)
- codeception/codeception: ^4.0
- codeception/module-asserts: ^1.1
- codeception/module-cli: ^1.1
- codeception/module-filesystem: ^1.0
- composer/composer: ^2.0
- mikey179/vfsstream: ^1.6
- nuvoleweb/robo-config: ^2.0
- squizlabs/php_codesniffer: ^3.5
- stecman/symfony-console-completion: ^0.11
- sweetchuck/git-hooks: 2.x-dev
- sweetchuck/robo-git: 2.x-dev
- sweetchuck/robo-phpcs: 2.x-dev
- sweetchuck/robo-phpmd: 2.x-dev
- symfony/error-handler: ^5.0 || ^6.0
- symfony/filesystem: ^5.2 || ^6.0
This package is auto-updated.
Last update: 2024-08-26 18:13:24 UTC
README
这是一个 Composer 插件,用于下载在 composer.json#/repositories
中以 "path" 类型引用的包。
问题在于,当存在如下的 composer.json 时,则 ../../foo/bar
目录必须在执行 composer update
或 composer install
命令之前存在。此插件尝试通过订阅 "pre command" 事件在早期阶段下载它们。
{ "repositories": { "foo/bar": { "type": "path", "url": "../../foo/bar-1.x" } }, "require": { "foo/bar": "*" } }
使用 - 全局(推荐)
composer global require sweetchuck/composer-repo-path
cd somewhere/my/project-01
根据以下示例编辑你的composer.json
{ "name": "my/project-01", "minimum-stability": "dev", "prefer-stable": true, "config": { "preferred-install": "dist" }, "repositories": { "foo/bar": { "type": "path", "url": "../../foo/bar-1.x", "options": { "repo-path": { "url": "http://example.com/foo/bar.git", "branch": "1.x" } } } }, "require": { "foo/bar": "*" } }
composer update
ls -la '../../foo/bar-1.x'
应该是一个普通目录。
ls -la 'vendor/foo'
"bar" 应该是一个符号链接。
使用 - 项目
如果没有全局预先安装 sweetchuck/composer-repo-path
插件,事情会稍微复杂一些。
当在干净的项目中第一次运行 composer update
命令时,则 sweetchuck/composer-repo-path
插件不可用,如果 ../../foo/bar-1.x
目录不存在,则 Composer 会抛出错误。
composer-suite 插件有助于解决这个问题。
cd somewhere/my/project-01
- composer.json
{ "name": "my/project-01", "minimum-stability": "dev", "prefer-stable": true, "config": { "preferred-install": "dist" }, "repositories": {}, "require": { "foo/bar": "^1.0" }, "require-dev": { "sweetchuck/composer-repo-path": "1.x-dev", "sweetchuck/composer-suite": "1.x-dev" }, "extra": { "composer-suite": { "local": { "description": "Modifications for local development", "actions": [ { "type": "prepend", "config": { "parents": ["repositories"], "items": { "foo/bar": { "type": "path", "url": "", "options": { "repo-path": { "url": "https://example.com/foo/bar.git", "remote": "upstream", "branch": "1.x" } } } } } }, { "type": "replaceRecursive", "config": { "parents": ["require"], "items": { "foo/bar": "*" } } } ] } } } }
composer update
composer suite:generate
- 可选:
COMPOSER='composer.local.json' composer repo-path:download
COMPOSER='composer.local.json' composer update
@TODO
命令 - composer repo-path:list
列出所有通过符号链接安装的包。
示例:`composer repo-path:list
示例输出:空格分隔的包名。
foo/bar baz/doo tab/fal
--format='json|yaml|csv' 选项将很有用。
与 Sweetchuck/composer-suite 一起
{ "scripts": { "suite:install:local": [ "rm composer.local.json composer.local.lock", "composer suite:generate", "cp composer.lock composer.local.lock", "COMPOSER='composer.local.lock' composer update $(composer repo-path:list)" ], "suite:reset": [ "rm $(COMPOSER='composer.local.lock' composer repo-path:list --format=json | jq 'find install dirs of the symlinked packages')", "composer install" ] } }