Skip to content

Commit

Permalink
[#3838]: Move to yarn instead of npm
Browse files Browse the repository at this point in the history
  • Loading branch information
alwx committed Jul 25, 2018
1 parent c0ca114 commit b5b64ab
Show file tree
Hide file tree
Showing 20 changed files with 5,888 additions and 8,602 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ local.properties
node_modules/
npm-debug.log
.nvmrc
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# BUCK
buck-out/
Expand Down Expand Up @@ -85,6 +90,7 @@ status-dev-cli
#ios
ios/Pods
ios/StatusIm.xcworkspace
ios/prebuild.log
.ruby-version

#python
Expand Down
16 changes: 2 additions & 14 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@ env.LANGUAGE="en_US.UTF-8"
env.LC_ALL="en_US.UTF-8"
env.FASTLANE_DISABLE_COLORS=1

def installJSDeps() {
def attempt = 1
def maxAttempts = 10
def installed = false
while (!installed && attempt <= maxAttempts) {
println "#${attempt} attempt to install npm deps"
sh 'scripts/prepare-for-platform.sh mobile'
sh 'npm install'
installed = fileExists('node_modules/web3/index.js')
attemp = attempt + 1
}
}

timeout(90) {
node ('macos') {
def apkUrl = ''
Expand All @@ -41,7 +28,8 @@ timeout(90) {
sh 'rm -rf node_modules'
sh 'cp .env.jenkins .env'

installJSDeps()
sh 'scripts/prepare-for-platform.sh mobile'
sh 'yarn install'

sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
Expand Down
16 changes: 2 additions & 14 deletions Jenkinsfile.nightly
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ env.LANGUAGE="en_US.UTF-8"
env.LC_ALL="en_US.UTF-8"
env.FASTLANE_DISABLE_COLORS=1

def installJSDeps() {
def attempt = 1
def maxAttempts = 10
def installed = false
while (!installed && attempt <= maxAttempts) {
println "#${attempt} attempt to install npm deps"
sh 'scripts/prepare-for-platform.sh mobile'
sh 'npm install'
installed = fileExists('node_modules/web3/index.js')
attemp = attempt + 1
}
}

timeout(90) {
node ('macos'){
def apkUrl = ''
Expand All @@ -37,7 +24,8 @@ timeout(90) {
sh 'rm -rf node_modules'
sh 'cp .env.jenkins .env'

installJSDeps()
sh 'scripts/prepare-for-platform.sh mobile'
sh 'yarn install'

sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
Expand Down
14 changes: 1 addition & 13 deletions Jenkinsfile.nightly_fastlane
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ env.LANGUAGE="en_US.UTF-8"
env.LC_ALL="en_US.UTF-8"
env.FASTLANE_DISABLE_COLORS=1

def installJSDeps() {
def attempt = 1
def maxAttempts = 10
def installed = false
while (!installed && attempt <= maxAttempts) {
println "#${attempt} attempt to install npm deps"
sh 'npm install'
installed = fileExists('node_modules/web3/index.js')
attemp = attempt + 1
}
}

timeout(90) {
node ('macos'){
def apkUrl = ''
Expand All @@ -41,7 +29,7 @@ timeout(90) {

sh 'scripts/prepare-for-platform.sh mobile'
version = readFile("${env.WORKSPACE}/VERSION").trim()
installJSDeps()
sh 'yarn install'

sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
Expand Down
16 changes: 2 additions & 14 deletions Jenkinsfile.parameters
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@ env.LANGUAGE="en_US.UTF-8"
env.LC_ALL="en_US.UTF-8"
env.FASTLANE_DISABLE_COLORS=1

def installJSDeps() {
def attempt = 1
def maxAttempts = 10
def installed = false
while (!installed && attempt <= maxAttempts) {
println "#${attempt} attempt to install npm deps"
sh 'scripts/prepare-for-platform.sh mobile'
sh 'npm install'
installed = fileExists('node_modules/web3/index.js')
attemp = attempt + 1
}
}

timeout(90) {
node ('macos') {
def apkUrl = ''
Expand Down Expand Up @@ -56,7 +43,8 @@ timeout(90) {
sh 'cat .env'
sh 'echo "**********************************************************************"'

installJSDeps()
sh 'scripts/prepare-for-platform.sh mobile'
sh 'yarn install'

sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
Expand Down
14 changes: 1 addition & 13 deletions Jenkinsfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ env.LANGUAGE="en_US.UTF-8"
env.LC_ALL="en_US.UTF-8"
env.FASTLANE_DISABLE_COLORS=1

def installJSDeps() {
def attempt = 1
def maxAttempts = 10
def installed = false
while (!installed && attempt <= maxAttempts) {
println "#${attempt} attempt to install npm deps"
sh 'npm install'
installed = fileExists('node_modules/web3/index.js')
attemp = attempt + 1
}
}

timeout(90) {
node ('macos'){
def apkUrl = ''
Expand All @@ -42,7 +30,7 @@ timeout(90) {

sh 'scripts/prepare-for-platform.sh mobile'
version = readFile("${env.WORKSPACE}/VERSION").trim()
installJSDeps()
sh 'yarn install'

sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
Expand Down
14 changes: 1 addition & 13 deletions Jenkinsfile.upload_release_android
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ env.LANGUAGE="en_US.UTF-8"
env.LC_ALL="en_US.UTF-8"
env.FASTLANE_DISABLE_COLORS=1

def installJSDeps() {
def attempt = 1
def maxAttempts = 10
def installed = false
while (!installed && attempt <= maxAttempts) {
println "#${attempt} attempt to install npm deps"
sh 'npm install'
installed = fileExists('node_modules/web3/index.js')
attemp = attempt + 1
}
}

timeout(90) {
node ('macos'){
def apkUrl = ''
Expand Down Expand Up @@ -46,7 +34,7 @@ timeout(90) {

sh 'scripts/prepare-for-platform.sh mobile'
version = readFile("${env.WORKSPACE}/VERSION").trim()
installJSDeps()
sh 'yarn install'

sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
Expand Down
14 changes: 1 addition & 13 deletions Jenkinsfile.upload_release_ios
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ env.LANGUAGE="en_US.UTF-8"
env.LC_ALL="en_US.UTF-8"
env.FASTLANE_DISABLE_COLORS=1

def installJSDeps() {
def attempt = 1
def maxAttempts = 10
def installed = false
while (!installed && attempt <= maxAttempts) {
println "#${attempt} attempt to install npm deps"
sh 'npm install'
installed = fileExists('node_modules/web3/index.js')
attemp = attempt + 1
}
}

timeout(90) {
node ('macos'){
def apkUrl = ''
Expand Down Expand Up @@ -45,7 +33,7 @@ timeout(90) {

sh 'scripts/prepare-for-platform.sh mobile'
version = readFile("${env.WORKSPACE}/VERSION").trim()
installJSDeps()
sh 'yarn install'

sh 'mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack'
sh 'cd ios && pod install && cd ..'
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ setup: ##@prepare Install all the requirements for status-react

prepare: ##@prepare Install dependencies and prepare workspace
scripts/prepare-for-platform.sh mobile
npm install

yarn install

prepare-ios: prepare ##@prepare Install iOS specific dependencies
mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ project.ext.react = [
entryFile: "index.android.js"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "react.gradle"

/**
* Set this to true to create two separate APKs instead of one:
Expand Down
66 changes: 48 additions & 18 deletions android/app/react.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import org.apache.tools.ant.taskdefs.condition.Os

def config = project.hasProperty("react") ? project.react : [];

def cliPath = config.cliPath ?: "node_modules/react-native/local-cli/cli.js"
def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
def entryFile = config.entryFile ?: "index.android.js"
def bundleCommand = config.bundleCommand ?: "bundle"

// because elvis operator
def elvisFile(thing) {
Expand All @@ -12,6 +14,7 @@ def elvisFile(thing) {

def reactRoot = elvisFile(config.root) ?: file("../../")
def inputExcludes = config.inputExcludes ?: ["android/**", "ios/**"]
def bundleConfig = config.bundleConfig ? "${reactRoot}/${config.bundleConfig}" : null ;

void runBefore(String dependentTaskName, Task task) {
Task dependentTask = tasks.findByPath(dependentTaskName);
Expand All @@ -30,26 +33,31 @@ gradle.projectsEvaluated {

productFlavors.each { productFlavorName ->
buildTypes.each { buildTypeName ->
// Create variant and source names
def sourceName = "${buildTypeName}"
def targetName = "${sourceName.capitalize()}"
if (productFlavorName) {
sourceName = "${productFlavorName}${targetName}"
}
// Create variant and target names
def flavorNameCapitalized = "${productFlavorName.capitalize()}"
def buildNameCapitalized = "${buildTypeName.capitalize()}"
def targetName = "${flavorNameCapitalized}${buildNameCapitalized}"
def targetPath = productFlavorName ?
"${productFlavorName}/${buildTypeName}" :
"${buildTypeName}"

// React js bundle directories
def jsBundleDirConfigName = "jsBundleDir${targetName}"
def jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ?:
file("$buildDir/intermediates/assets/${sourceName}")
file("$buildDir/intermediates/assets/${targetPath}")

def resourcesDirConfigName = "jsBundleDir${targetName}"
def resourcesDirConfigName = "resourcesDir${targetName}"
def resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?:
file("$buildDir/intermediates/res/merged/${sourceName}")
file("$buildDir/intermediates/res/merged/${targetPath}")
def jsBundleFile = file("$jsBundleDir/$bundleAssetName")

// Bundle task name for variant
def bundleJsAndAssetsTaskName = "bundle${targetName}JsAndAssets"

// Additional node and packager commandline arguments
def nodeExecutableAndArgs = config.nodeExecutableAndArgs ?: ["node"]
def extraPackagerArgs = config.extraPackagerArgs ?: []

def currentBundleTask = tasks.create(
name: bundleJsAndAssetsTaskName,
type: Exec) {
Expand All @@ -71,26 +79,48 @@ gradle.projectsEvaluated {
workingDir reactRoot

// Set up dev mode
def devEnabled = !targetName.toLowerCase().contains("release")
def devEnabled = !(config."devDisabledIn${targetName}"
|| targetName.toLowerCase().contains("release"))

def extraArgs = extraPackagerArgs;

if (bundleConfig) {
extraArgs = extraArgs.clone()
extraArgs.add("--config");
extraArgs.add(bundleConfig);
}

println cliPath
println bundleCommand
println "--platform android --dev false --reset-cache --entry-file"
println entryFile
println "--bundle-output"
println jsBundleFile
println "--assets-dest"
println resourcesDir

if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
commandLine("cmd", "/c", *nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}",
"--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, *extraArgs)
} else {
commandLine "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
commandLine(*nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}",
"--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, *extraArgs)
}

enabled config."bundleIn${targetName}" ?: targetName.toLowerCase().contains("release")
enabled config."bundleIn${targetName}" ||
config."bundleIn${buildTypeName.capitalize()}" ?:
targetName.toLowerCase().contains("release")
}

// Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process
currentBundleTask.dependsOn("merge${targetName}Resources")
currentBundleTask.dependsOn("merge${targetName}Assets")

runBefore("processArmeabi-v7a${targetName}Resources", currentBundleTask)
runBefore("processX86${targetName}Resources", currentBundleTask)
runBefore("process${flavorNameCapitalized}Armeabi-v7a${buildNameCapitalized}Resources", currentBundleTask)
runBefore("process${flavorNameCapitalized}X86${buildNameCapitalized}Resources", currentBundleTask)
runBefore("processUniversal${targetName}Resources", currentBundleTask)
runBefore("process${targetName}Resources", currentBundleTask)
runBefore("dataBindingProcessLayouts${targetName}", currentBundleTask)
}
}
}
}
4 changes: 2 additions & 2 deletions docker-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ RUN mkdir -p $LEIN_INSTALL \
&& mv leiningen-$LEIN_VERSION-standalone.zip /usr/share/java/leiningen-$LEIN_VERSION-standalone.jar

# Install React-Native
RUN npm install -g react-native-cli
RUN yarn global add react-native-cli

# Add files needed for installing dependencies
# Use directory /build for that purpose
Expand All @@ -80,7 +80,7 @@ ADD ./project.clj ./

ADD ./package.json package-lock.json ./

RUN npm install
RUN yarn install

ADD . ./

Expand Down
Loading

0 comments on commit b5b64ab

Please sign in to comment.