Neos Flow 项目的正确 .gitignore 文件?
Proper .gitignore file for a Neos Flow project?
我最近使用 composer create-project --keep-vcs neos/flow-base-distribution ProjectName
创建了一个新项目,我对它生成的 .gitignore 文件有点困惑:
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
它基本上丢弃了 VCS 中的几乎所有文件,包括整个 Packages/Application 文件夹,我 假设 我的大部分代码都会放在那里。那么给出了什么?为什么 .gitignore 文件如此广泛?
我以前没有 neos-flow 的经验,但我在 composer 的帮助下用 Ubuntu OS 在两台不同的计算机上安装了它。
我的 .gitignore 文件输出与你两次的输出相同。
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
我项目的原始结构是
. .. .editorconfig .git .github .gitignore Build Configuration Data Packages Readme.rst Web bin composer.json composer.lock flow flow.bat
当我删除 .gitignore 中声明的所有文件夹和文件时,我的项目结构是这样的
. .. .editorconfig .git .github .gitignore composer.json composer.lock
如您所知,.gitignore 文件的目的是允许您忽略您永远不想提交到存储库中的文件,例如编辑器备份文件、构建产品或本地配置覆盖。
我认为 neos-flow 只需要应用 .gitignore 后剩余的那些文件。
那些是 composer.json 和 composer.lock
composer.json 的目的是显示有关项目的详细信息,如名称、描述、许可证信息。
composer.lock 显示项目的所有包和依赖项、它们的名称、详细信息和 url 用于下载包。
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"
}
}
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"
}]}
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"
],
所以简而言之,你的 .gitignore 是绝对准确的。我也在我的两台 ubuntu 电脑上都安装了它,而且都是一样的。
.gitignore
在他们的存储库下有两个模型:
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
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
因为我是一个狂热的 Flow 用户,我可以解释为什么 Packages/
目录被排除在外:
如您在 composer.json
中所见,有此部分:
"repositories": {
"distributionPackages": {
"type": "path",
"url": "./DistributionPackages/*"
}
},
这告诉作曲家在 DistributionPackages/
目录中查找您自己的包。这比在 Packages/
目录中混合自己的包和依赖项要干净得多,并且还有助于依赖项管理本身(因为只有包目录中的 composer.json
需要包含包依赖项 - 即不需要在根 composer.json
中复制它们)。
有关详细信息,请参阅 https://docs.neos.io/cms/manual/dependency-management#the-path-repository-setup and https://www.neos.io/blog/project-repository-best-practice.html(这不仅适用于 Neos 站点包,还适用于每个项目特定的包)。
至于其他排除的文件:由于这些文件是由 composer install
创建的,因此不需要由 git 跟踪。
例外:您经常想要包含 Web/
目录(但排除非特定内容,如 Web/_Resources/
或 Web/index.php
),即用于网络根目录。
我最近使用 composer create-project --keep-vcs neos/flow-base-distribution ProjectName
创建了一个新项目,我对它生成的 .gitignore 文件有点困惑:
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
它基本上丢弃了 VCS 中的几乎所有文件,包括整个 Packages/Application 文件夹,我 假设 我的大部分代码都会放在那里。那么给出了什么?为什么 .gitignore 文件如此广泛?
我以前没有 neos-flow 的经验,但我在 composer 的帮助下用 Ubuntu OS 在两台不同的计算机上安装了它。 我的 .gitignore 文件输出与你两次的输出相同。
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
我项目的原始结构是
. .. .editorconfig .git .github .gitignore Build Configuration Data Packages Readme.rst Web bin composer.json composer.lock flow flow.bat
当我删除 .gitignore 中声明的所有文件夹和文件时,我的项目结构是这样的
. .. .editorconfig .git .github .gitignore composer.json composer.lock
如您所知,.gitignore 文件的目的是允许您忽略您永远不想提交到存储库中的文件,例如编辑器备份文件、构建产品或本地配置覆盖。
我认为 neos-flow 只需要应用 .gitignore 后剩余的那些文件。
那些是 composer.json 和 composer.lock
composer.json 的目的是显示有关项目的详细信息,如名称、描述、许可证信息。
composer.lock 显示项目的所有包和依赖项、它们的名称、详细信息和 url 用于下载包。
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"
}
}
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"
}]}
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"
],
所以简而言之,你的 .gitignore 是绝对准确的。我也在我的两台 ubuntu 电脑上都安装了它,而且都是一样的。
.gitignore
在他们的存储库下有两个模型:
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
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
因为我是一个狂热的 Flow 用户,我可以解释为什么 Packages/
目录被排除在外:
如您在 composer.json
中所见,有此部分:
"repositories": {
"distributionPackages": {
"type": "path",
"url": "./DistributionPackages/*"
}
},
这告诉作曲家在 DistributionPackages/
目录中查找您自己的包。这比在 Packages/
目录中混合自己的包和依赖项要干净得多,并且还有助于依赖项管理本身(因为只有包目录中的 composer.json
需要包含包依赖项 - 即不需要在根 composer.json
中复制它们)。
有关详细信息,请参阅 https://docs.neos.io/cms/manual/dependency-management#the-path-repository-setup and https://www.neos.io/blog/project-repository-best-practice.html(这不仅适用于 Neos 站点包,还适用于每个项目特定的包)。
至于其他排除的文件:由于这些文件是由 composer install
创建的,因此不需要由 git 跟踪。
例外:您经常想要包含 Web/
目录(但排除非特定内容,如 Web/_Resources/
或 Web/index.php
),即用于网络根目录。