一个React Native项目的持续集成管道需要添加哪些文件到版本控制?

4
我正在将我的react-native项目添加到版本控制中。 我的目的是使用Microsoft的AppCenter配置持续集成流水线。
当我尝试将项目推送到GitHub时,有一些文件太大了。 其中一个是iOS / Pods目录中的文件,另一个是android目录中的.hprof文件。
我很难找到一个高质量的解释,关于哪些文件需要包含在这些ci / cd管道的版本控制中。
目前我的.gitignore文件(从https://www.gitignore.io/api/reactnative中取得)看起来像:
### ReactNative ###
# React Native Stack Base
### ReactNative.Xcode Stack ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Pods
ios/Pods/ <- can this be ignored and still have successful CI builds?

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

### ReactNative.Node Stack ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


### ReactNative.Buck Stack ###
buck-out/
.buckconfig.local
.buckd/
.buckversion
.fakebuckversion

### ReactNative.macOS Stack ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### ReactNative.Gradle Stack ###
.gradle
**/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties

### ReactNative.Android Stack ###
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Freeline
freeline.py
freeline/
freeline_project_description.json

### ReactNative.Linux Stack ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# End of https://www.gitignore.io/api/reactnative

我不确定哪些文件可以忽略,以及哪些需要存在于版本控制中,以便AppCenter可以构建项目。例如,iOS/Pods是否可以从VC中排除?为什么/为什么不行等等。对于初始提交,我的未跟踪的文件如下:

.buckconfig
 .eslintrc.js
 .firebaserc
 .flowconfig
 .gitignore
 .idea/
 .prettierrc.js
 .watchmanconfig
 App.js
 __tests__/
 android/
 app.json
 babel.config.js
 firebase.json
 functions/
 index.android.js
 index.js
 ios/
 metro.config.js
 package-lock.json
 package.json
 src/

在最初的提交中,哪些需要添加到版本控制器中,哪些不需要?


你有找到这个问题的答案吗?我也在尝试弄清楚同样的事情。 - Ryker
1
我相信你可以排除.idea/...在那个列表中的所有其他内容都需要保留。 - Jim
2个回答

0

对于未来查看此问题的用户,您可以很容易地进行第一次提交,并让.gitignore(使用react-native init自动处理)处理第一次提交。然后在下一次提交中添加未跟踪的配置文件。如果您没有.gitignore,可以从React Native git repo或此处获取:

# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/

在我进行初始提交后,我的未跟踪文件看起来像这样:

.buckconfig
.cvsignore.txt
.editorconfig
.eslintrc.js
.flowconfig
.gitattributes
.gitignore
.prettierrc.js
.watchmanconfig
babel.config.js
metro.config.js
tsconfig.json

最终我按照OP的建议将它们全部包含。像.vscode和.idea这样的IDE特定文件夹也可以被排除(源)。一些其他大的应该被忽略的是Podsnode_modules文件夹,因为它们在运行pod installyarn/npm install时会自动生成。


0
我很难找到一个质量上乘的解释,说明这些ci/cd流水线需要在版本控制中包含哪些文件。
规则很简单:添加和提交文件。
然后尝试本地克隆您的存储库,并查看是否可以构建而不需要任何其他文件。 换句话说,这些已添加的文件是否足以让项目能够构建和运行?

1
我理解添加和提交文件。你的方法基本上就像在黑暗中进行目标练习。我正在寻找更加规范的理解。 - Jim

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接