简体   繁体   English

适合 Neos Flow 项目的 .gitignore 文件?

[英]Proper .gitignore file for a Neos Flow project?

I recently created a new project using composer create-project --keep-vcs neos/flow-base-distribution ProjectName and I'm a bit confused by the .gitignore file it produces:我最近使用composer create-project --keep-vcs neos/flow-base-distribution ProjectName创建了一个新项目,我对它生成的 .gitignore 文件有点困惑:

/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat

It basically throws out almost every file from the VCS, including the entirety of the Packages/Application folder, where I assumed most of my code would go.它基本上从 VCS 中丢弃了几乎所有文件,包括整个 Packages/Application 文件夹,我认为我的大部分代码都会放在那里。 So what gives?那么什么给呢? Why is the .gitignore file so broad?为什么 .gitignore 文件如此广泛?

I don't have previous experience in neos-flow but I installed it with the help of composer on two different computers with Ubuntu OS.我以前没有使用 neos-flow 的经验,但我在 Composer 的帮助下将它安装在两台不同的 Ubuntu 计算机上。 My .gitignore file output is same like your output both time.我的 .gitignore 文件输出两次都与您的输出相同。

/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat

The Original structure of my project is我的项目的原始结构是

.  ..  .editorconfig  .git  .github  .gitignore  Build  Configuration  Data  Packages  Readme.rst  Web  bin  composer.json  composer.lock  flow  flow.bat

When i remove all folders and files as declared in .gitignore then my project structure is like this当我删除 .gitignore 中声明的所有文件夹和文件时,我的项目结构是这样的

.  ..  .editorconfig  .git  .github  .gitignore   composer.json  composer.lock

As you know, The purpose of the .gitignore file is to allow you to ignore files, such as editor backup files, build products or local configuration overrides that you never want to commit into a repository.如您所知,.gitignore 文件的目的是允许您忽略您永远不想提交到存储库中的文件,例如编辑器备份文件、构建产品或本地配置覆盖。
I think that neos-flow just need those files that are remaining after applying .gitignore.我认为 Neos-flow 只需要应用 .gitignore 后剩余的那些文件。 Those are composer.json and composer.lock那些是composer.json 和 composer.lock
The purpose of composer.json is that it shows the details about the project like name, description, license information. composer.json的目的是显示有关项目的详细信息,如名称、描述、许可证信息。
And composer.lock shows all packages, and dependencies for the project, their name, detail and url for downloading the package. composer.lock显示所有包和项目的依赖项、它们的名称、详细信息和下载包的 url。

The content of composer.json composer.json的内容

{
    "name": "neos/flow-base-distribution",
    "description": "Flow Base Distribution",
    "license": "MIT",
    "support": {
        "email": "hello@neos.io",
        "slack": "http://slack.neos.io/",
        "forum": "https://discuss.neos.io/",
        "wiki": "https://discuss.neos.io/c/the-neos-project/project-documentation",
        "issues": "https://github.com/neos/flow-development-collection/issues",
        "docs": "https://flowframework.readthedocs.io/",
        "source": "https://github.com/neos/flow-base-distribution"
    },
    "config": {
        "vendor-dir": "Packages/Libraries",
        "bin-dir": "bin"
    },
    "require": {
        "neos/flow": "~6.0.0",
        "neos/welcome": "~6.0.0"
    },
    "require-dev": {
        "neos/kickstarter": "~6.0.0",
        "neos/buildessentials": "~6.0.0",
        "neos/behat": "dev-master",
        "phpunit/phpunit": "~8.1",
        "mikey179/vfsstream": "~1.6"
    },
    "repositories": {
        "distributionPackages": {
            "type": "path",
            "url": "./DistributionPackages/*"
        }
    },
    "replace": {
        "typo3/flow-base-distribution": "self.version"
    },
    "suggest": {
        "ext-pdo_sqlite": "For running functional tests out-of-the-box this is required"
    },
    "scripts": {
        "post-update-cmd": "Neos\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
        "post-install-cmd": "Neos\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
        "post-package-update": "Neos\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall",
        "post-package-install": "Neos\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall"
    }
}

First 70 lines of composer.lock composer.lock 的前 70 行

{
    "_readme": [
        "This file locks the dependencies of your project to a known state",
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
        "This file is @generated automatically"
    ],
    "content-hash": "06d49a77babbafa5a03d726865e61dc3",
    "packages": [
        {
            "name": "composer/ca-bundle",
            "version": "1.2.4",
            "source": {
                "type": "git",
                "url": "https://github.com/composer/ca-bundle.git",
                "reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/composer/ca-bundle/zipball/10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
                "reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
                "shasum": ""
            },
            "require": {
                "ext-openssl": "*",
                "ext-pcre": "*",
                "php": "^5.3.2 || ^7.0 || ^8.0"
            },
            "require-dev": {
                "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8",
                "psr/log": "^1.0",
                "symfony/process": "^2.5 || ^3.0 || ^4.0"
            },
            "type": "library",
            "extra": {
                "branch-alias": {
                    "dev-master": "1.x-dev"
                }
            },
            "autoload": {
                "psr-4": {
                    "Composer\\CaBundle\\": "src"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Jordi Boggiano",
                    "email": "j.boggiano@seld.be",
                    "homepage": "http://seld.be"
                }
            ],
            "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.",
            "keywords": [
                "cabundle",
                "cacert",
                "certificate",
                "ssl",
                "tls"
            ],
            "time": "2019-08-30T08:44:50+00:00"
        }]}

The _readme key in composer.lock json shows the purpose of composer.lock composer.lock json 中的 _readme 键显示了 composer.lock 的用途

"_readme": [
        "This file locks the dependencies of your project to a known state",
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
        "This file is @generated automatically"
    ],

So in short your .gitignore is absolutely fine and accurate.因此,简而言之,您的 .gitignore 绝对正确且准确。 I also install it on both my ubuntu computers and both are same.我也在我的两台 ubuntu 电脑上安装了它,两者都是一样的。

There are two models of .gitignore under their repository: .gitignore在其存储库下有两种模型:


https://github.com/neos/flow/blob/master/Resources/Private/Installer/Distribution/Defaults/.gitignore https://github.com/neos/flow/blob/master/Resources/Private/Installer/Distribution/Defaults/.gitignore

/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat

https://github.com/neos/flow-development-distribution/blob/master/.gitignore https://github.com/neos/flow-development-distribution/blob/master/.gitignore

/Build/Behat/*
/Build/BuildEssentials
/Build/Reports
/Build/Resources
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.txt
/Upgrading.txt
/Readme.rst
/Upgrading.rst
/flow
/flow.bat

As I am an avid Flow user, I can explain why the Packages/ directory is excluded:因为我是一个狂热的 Flow 用户,所以我可以解释为什么Packages/目录被排除在外:

As you can see in the composer.json , there is this section:正如你在composer.json看到的,有这个部分:

    "repositories": {
        "distributionPackages": {
            "type": "path",
            "url": "./DistributionPackages/*"
        }
    },

This tells composer to look for your own packages in the DistributionPackages/ directory.这告诉作曲家在DistributionPackages/目录中查找您自己的包。 This is much cleaner than mixing own packages and dependencies in the Packages/ directory and also helps a bit with dependency management itself (since only the composer.json in your package directory needs to contain the package dependencies - ie no need to duplicate them in the root composer.json ).这比在Packages/目录中混合自己的包和依赖项要干净得多,而且还有助于依赖项管理本身(因为只有包目录中的composer.json需要包含包依赖项 - 即不需要在根composer.json )。 See https://docs.neos.io/cms/manual/dependency-management#the-path-repository-setup and https://www.neos.io/blog/project-repository-best-practice.html for more info about that (this not only applies to Neos site packages, but every project specific package).有关更多信息,请参阅https://docs.neos.io/cms/manual/dependency-management#the-path-repository-setuphttps://www.neos.io/blog/project-repository-best-practice.html相关信息(这不仅适用于 Neos 站点包,还适用于每个项目特定的包)。

As for the other excluded files: Since those get created by composer install , those don't need to be tracked by git.至于其他排除的文件:由于这些文件是由composer install创建的,因此不需要由 git 跟踪。

Exception: You often want to include the Web/ directory (but exclude non-specific contents like Web/_Resources/ or Web/index.php ) ie for the favicons or other static files needed in the web root.例外:您通常希望包含Web/目录(但排除非特定内容,如Web/_Resources/Web/index.php ),即网站根目录中所需的网站图标或其他静态文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM