<commit_before>#! /usr/bin/env nix-shell
#! nix-shell --pure -i bash -p nix bash
set -eu
source ./nix-shell-init.sh

app=$(basename $PWD)

reactNativeVersion=$(cat files/package.json | grep '"react-native"' | cut -d '"' -f4)
reactNativeMacosVersion=$(cat files/package.json | grep '"react-native-macos"' | cut -d '"' -f4)
buildToolsVersion=$(nix-store --query --references $(nix-instantiate '<nixpkgs>' -A androidsdk) | grep 'android-build-tools' | sed 's/.*build-tools-r\(.*\).drv/\1/')

# install react-native-cli and react-native-macos-cli
mkdir $app
cp files/package.json $app/
test -f files/npm-shrinkwrap && cp files/npm-shrinkwrap.json $app/
nix-shell -p nodejs --run "cd $app && npm install react-native-cli && npm install react-native-macos-cli"

# add correct react-native-macos version for the cli-tool to install.
sed -i "s/npm install --save react-native-macos/npm install --save react-native-macos@$reactNativeMacosVersion/g" $app/node_modules/react-native-macos-cli/index.js

# init ios/android/macos project
nix-shell -p nodejs python2 --run "\
     (echo yes | node ./$app/node_modules/react-native-macos-cli/index.js init $app --version=$reactNativeMacosVersion && rm $app/.gitignore)\
  && (echo yes | node ./$app/node_modules/react-native-cli/index.js init $app --version=$reactNativeVersion)\
  && (cd $app; node ./node_modules/react-native-cli/index.js android)"

# Android package signing
echo "MYAPP_RELEASE_STORE_FILE=my-release-key.keystore" >> $app/android/gradle.properties
echo "MYAPP_RELEASE_KEY_ALIAS=my-key-alias" >> $app/android/gradle.properties
echo "MYAPP_RELEASE_STORE_PASSWORD=<PASSWORD>" >> $app/android/gradle.properties
echo "MYAPP_RELEASE_KEY_PASSWORD=<PASSWORD>" >> $app/android/gradle.properties
sed -i "s/defaultConfig {/signingConfigs {release {storeFile file(MYAPP_RELEASE_STORE_FILE); storePassword MYAPP_RELEASE_STORE_PASSWORD;keyAlias MYAPP_RELEASE_KEY_ALIAS;keyPassword MYAPP_RELEASE_KEY_PASSWORD}}; buildTypes { release { signingConfig signingConfigs.release }}; defaultConfig {/g" $app/android/app/build.gradle
sed -i "s/minifyEnabled/signingConfig signingConfigs.release; minifyEnabled/g" $app/android/app/build.gradle

sed -i "s/^android [{]/android { adbOptions.timeOutInMs = 8*60*1000; com.android.ddmlib.DdmPreferences.setTimeOut(8*60*1000)/" $app/android/app/build.gradle

# change project buildTools to that available from nixpkgs
sed -i "s/buildToolsVersion \"[^\"]*\"/buildToolsVersion \"$buildToolsVersion\"/" $app/android/app/build.gradle

# install all needed npm-stuff
cp -fR files/* $app/
rm $app/index.windows.js<commit_msg>this seems to work now<commit_after>#! /usr/bin/env nix-shell
#! nix-shell --pure -i bash -p nix bash
set -eu
source ./nix-shell-init.sh

app=$(basename $PWD)

reactNativeVersion=$(cat files/package.json | grep '"react-native"' | cut -d '"' -f4)
reactNativeMacosVersion=$(cat files/package.json | grep '"react-native-macos"' | cut -d '"' -f4)
buildToolsVersion=$(nix-store --query --references $(nix-instantiate '<nixpkgs>' -A androidsdk) | grep 'android-build-tools' | sed 's/.*build-tools-r\(.*\).drv/\1/')

# install react-native-cli and react-native-macos-cli
mkdir $app
cp files/package.json $app/
test -f files/npm-shrinkwrap && cp files/npm-shrinkwrap.json $app/
nix-shell -p nodejs --run "cd $app && npm install react-native-cli && npm install react-native-macos-cli"

# init ios/android/macos project
nix-shell -p nodejs python2 --run "\
     (echo yes | node ./$app/node_modules/react-native-macos-cli/index.js init $app --version=$reactNativeMacosVersion && rm $app/.gitignore)\
  && (echo yes | node ./$app/node_modules/react-native-cli/index.js init $app --version=$reactNativeVersion)\
  && (cd $app; node ./node_modules/react-native-cli/index.js android)"

# Android package signing
echo "MYAPP_RELEASE_STORE_FILE=my-release-key.keystore" >> $app/android/gradle.properties
echo "MYAPP_RELEASE_KEY_ALIAS=my-key-alias" >> $app/android/gradle.properties
echo "MYAPP_RELEASE_STORE_PASSWORD=<PASSWORD>" >> $app/android/gradle.properties
echo "MYAPP_RELEASE_KEY_PASSWORD=<PASSWORD>" >> $app/android/gradle.properties
sed -i "s/defaultConfig {/signingConfigs {release {storeFile file(MYAPP_RELEASE_STORE_FILE); storePassword MYAPP_RELEASE_STORE_PASSWORD;keyAlias MYAPP_RELEASE_KEY_ALIAS;keyPassword MYAPP_RELEASE_KEY_PASSWORD}}; buildTypes { release { signingConfig signingConfigs.release }}; defaultConfig {/g" $app/android/app/build.gradle
sed -i "s/minifyEnabled/signingConfig signingConfigs.release; minifyEnabled/g" $app/android/app/build.gradle

sed -i "s/^android [{]/android { adbOptions.timeOutInMs = 8*60*1000; com.android.ddmlib.DdmPreferences.setTimeOut(8*60*1000)/" $app/android/app/build.gradle

# change project buildTools to that available from nixpkgs
sed -i "s/buildToolsVersion \"[^\"]*\"/buildToolsVersion \"$buildToolsVersion\"/" $app/android/app/build.gradle

# install all needed npm-stuff
cp -fR files/* $app/
rm $app/index.windows.js
{'fraction_non_alphanumeric': 0.1526825332795482, 'fraction_numerical': 0.007260992335619202, 'mean_word_length': 4.938922155688623, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7066407', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1686, 'n_words': 358}