为wordpress主题和插件创建令人满意的作曲家私人存储库

Phi*_*ook 7 php git wordpress composer-php satis

我的目标是将一个composer.json文件提交到我们的项目存储库,该文件指定应该为该项目使用哪些主题或插件,当开发人员下载回购时,他们需要做的就是运行composer install.我们希望将插件保留在项目仓库之外,以阻止项目仓库的膨胀,并且拉动和推动变得缓慢.

对于标准的wordpress插件,例如"Jetpack by WordPress.com",这很好,因为我们将使用https://wpackagist.org/.但是,对于支付插件和内部定制的Premium而无法开源的我们希望将它们托管在Private Composer Repository中.

因为我们将有这些插件的多个版本,我希望所有版本都能显示,如1.1,1.2,1.3,因此开发人员可以在composer.json中指定哪个版本是必需的,例如,如果未来的版本破坏了某些东西,我们需要回滚到以前的版本.

我已经阅读了设置Satis私有存储库的基础知识,我已经这样做但是我不能让它循环遍历版本的git标签,并指定它是一个Wordpress插件并将其安装在正确的位置.

这是我第一次获得所有git标记版本的尝试:

{
    "name": "Private Repository",
    "homepage": "http://packages.privaterepo.com",
    "repositories": [
        {
            "type": "vcs",
            "url": "git@bitbucket.org:companyname/project.git"
        }
    ],
    "require-all": true
}
Run Code Online (Sandbox Code Playgroud)

这是我必须指定版本,但让它安装在正确的Wordpress插件位置:

{
    "name": "Private Repository",
    "homepage": "http://packages.privaterepo.com",
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "company/project",
                "description": "WordPress Plugin",
                "version": "1.0",
                "source": {
                    "type": "git",
                    "url": "git@bitbucket.org:company/project.git",
                    "reference": "origin/master"
                },
                "type": "wordpress-plugin",
                "require": {
                    "php": ">=5.3.2",
                    "composer/installers": "*"
                }
            }
        }
    ],
    "require-all": true,
    "require-dependencies": true,
    "extra": {
        "installer-paths": {
            "wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议我如何让这两种情况一起工作?

Sve*_*ven 0

我想我有类似的设置:在本地 Satis 存储库中,我们既有来自私有 Git 服务器的内部包,也有来自 Github 的所有外部包。

诀窍是执行两个步骤:第一步仅提取所有外部包的元数据,这就是您的版本范围发挥作用的地方,以避免提取所有内容。

第二步将扫描所有本地 Git 存储库并检测所有版本,此外还将添加在步骤 1 中创建的 Composer 存储库。

实际上,您将处理两个 Satis 配置,这将创建两个结果,并且外部包的第一个作业的结果将仅获取所有元数据,在第二步中,它会像本地 Git 存储库一样导入和使用,并进行配置第二步扫描“所有”版本并可能从中创建 ZIP 文件,这将为您可能需要的每个包创建一个很好的本地备份副本。

或者换句话说:

satis-external.json

{
    "repositories": [
        {
            "type":"composer",
            "url":"https://packagist.org"
        }
    ],
    "require": {
        "any/package":">=2.0"
    }
    "output-html": false,
    "require-dependencies": true
}
Run Code Online (Sandbox Code Playgroud)

运行:

php -dmemory_limit=2G satis/bin/satis build satis-external.json external/
Run Code Online (Sandbox Code Playgroud)

satis-internal.json

{
    "repositories": [
        {
            "type": "composer",
            "url": "http://url/from/external/above"
        },
        {
            "type": "vcs",
            "url": "ssh://internal/gitrepo.git"
        }
    ],
    "require-all": true,
    "archive": {
        "directory": "dist",
        "format": "zip",
        "prefix-url": "https://whatever/youneed",
        "skip-dev": true
    }
}
Run Code Online (Sandbox Code Playgroud)

运行这个

php  -dmemory_limit=2G satis/bin/satis build satis-internal.json internal/
Run Code Online (Sandbox Code Playgroud)

在 Satis 中添加“type=composer”存储库将使其行为与任何其他存储库一样 - 特别是如果您“require-all=true”,它将下载其中提到的所有软件包,因此请注意不要直接添加 Packagist 或任何其他存储库。

另请注意,“需要依赖项”对于外部包来说是正确的,因为您可能不想经历添加要使用的包的每个依赖项的麻烦。

如果您的某些付费软件包提供远程存储库访问,您可以在外部配置中添加此存储库以及访问凭据 - 它应该可以工作。