【问题标题】:What files need to be added to version control for a react-native project's continuous integration pipeline?react-native 项目的持续集成管道需要将哪些文件添加到版本控制中?
【发布时间】:2020-11-01 00:59:03
【问题描述】:

我正在将我的 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/

对于初始提交,哪些需要添加,哪些不需要添加到VC?

【问题讨论】:

  • 你找到答案了吗?我试图找出同样的事情
  • 我相信您可以排除 .idea/...该列表中您想要保留的所有其他内容
  • 感谢您的澄清!

标签: react-native version-control gitignore visual-studio-app-center


【解决方案1】:

我很难找到关于哪些文件需要包含在这些 ci/cd 管道的版本控制中的质量解释。

规则很简单:添加和提交文件。

然后尝试在本地克隆您的存储库,看看它可以在不需要任何其他文件的情况下构建。
换句话说,添加的文件是否足以让项目构建和运行?

【讨论】:

  • 我了解添加和提交文件。你的方法基本上就像在黑暗中练习目标。我正在寻找更规范的理解
【解决方案2】:

对于这个问题的未来观众,您可以很好地进行第一次提交,然后让.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 的建议将所有这些都包括在内。 IDE 特定文件夹(如 .vscode 和 .idea 文件夹)也可以排除在 (Source) 之外。其他一些应该忽略的大文件夹是 Pods 和 node_modules 文件夹,因为它们是在您分别运行 pod install 和 yarn/npm install 时自动生成的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-11
    • 2017-08-02
    • 2020-06-12
    • 2012-05-01
    • 1970-01-01
    • 2017-04-20
    • 2011-03-12
    • 1970-01-01
    相关资源
    最近更新 更多