Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
nbottarini committed Apr 24, 2024
1 parent 8a7d177 commit 0ca8ea4
Show file tree
Hide file tree
Showing 19 changed files with 12,875 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
root: true,
extends: ['@react-native-community', 'plugin:json/recommended'],
ignorePatterns: [
'.bundle/',
'dist/',
'android/',
'ios/',
'node_modules/',
'**/node_modules/',
'/**/node_modules/*',
],
overrides: [
{
files: ['*.json','*.ts','*.tsx','*.js','*.jsx'],
},
],
rules: {
'semi': ['error', 'never'],
'curly': ['error', 'multi-line'],
'object-curly-spacing': [ 'error', 'always' ],
'dot-notation': 'off',
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'error',
'react/no-unstable-nested-components': 'off',
'react-native/no-inline-styles': 'off',
'no-new': 'off',
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/semi': ['error', 'never'],
'@typescript-eslint/no-unused-vars': [
'warn', {
'vars': 'all',
'args': 'none',
'ignoreRestSiblings': false,
}],
'prettier/prettier': 'off',
},
}
40 changes: 40 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build & Publish

on: [push]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Install modules
run: yarn install --immutable
- name: Run Lint
run: yarn lint

publish:
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/release-')
steps:
- uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Install modules
run: yarn install --immutable
- name: Build
run: yarn run build
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
86 changes: 86 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# OSX
.DS_Store
Thumbs.db

# VSCode
.vscode/
jsconfig.json

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local
project.xcworkspace

# Android/IntelliJ
build/
android/.idea
.project
.settings
.gradle/
local.properties
*.hprof
android/app/libs
.cxx/
*.keystore
!debug.keystore

# BUCK
buck-out/
\.buckd/

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

# IDEs and editors
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# Expo
.expo/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Typescript
tsconfig.tsbuildinfo

# generated by bob
dist/
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/expo-firebase-app-distribution.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.1.1.cjs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
compressionLevel: mixed
enableGlobalCache: true
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.1.1.cjs
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
[![npm](https://img.shields.io/npm/v/expo-firebase-app-distribution.svg)](https://www.npmjs.com/package/expo-firebase-app-distribution)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI Status](https://github.com/nbottarini/expo-firebase-app-distribution/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/nbottarini/expo-firebase-app-distribution/actions)

# expo-firebase-app-distribution
Expo plugin for firebase app distribution

## Installation

Npm:
```
$ npm install --save expo-firebase-app-distribution @react-native-firebase/app @react-native-firebase/app @react-native-firebase/app-distribution
```

Yarn:
```
$ yarn add expo-firebase-app-distribution @react-native-firebase/app @react-native-firebase/app @react-native-firebase/app-distribution
```

Add plugins to your app.json:
```json
{
"expo": {
"android": {
"googleServicesFile": "./google-services.json",
"package": "com.mycorp.myapp"
},
"ios": {
"googleServicesFile": "./GoogleService-Info.plist",
"bundleIdentifier": "com.mycorp.myapp"
},
"plugins": [
"@react-native-firebase/app",
"expo-firebase-app-distribution"
]
}
}
```

## Usage

Please refer to React Native Firebase App Distribution [docs](https://rnfirebase.io/app-distribution/usage).
1 change: 1 addition & 0 deletions app.plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist')
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
}
53 changes: 53 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "expo-firebase-app-distribution",
"version": "0.1.0",
"description": "Expo Config plugin for react-native-firebase-app-distribution",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Nicolás Bottarini <nicolasbottarini@gmail.com>",
"license": "MIT",
"homepage": "https://github.com/nbottarini/expo-firebase-app-distribution#readme",
"repository": {
"type": "git",
"url": "https://github.com/nbottarini/expo-firebase-app-distribution.git"
},
"keywords": [
"expo",
"firebase",
"app-distribution"
],
"files": [
"dist",
"app.plugin.js"
],
"scripts": {
"build": "yarn run tsc --build",
"lint": "yarn run eslint . && yarn run tsc --noEmit"
},
"dependencies": {
"expo-build-properties": "~0.11.1"
},
"packageManager": "yarn@4.1.1",
"peerDependencies": {
"@react-native-firebase/app": "^19.0.0",
"@react-native-firebase/app-distribution": "^19.0.0",
"expo": "^50"
},
"engines": {
"node": ">= 18.0.0"
},
"devDependencies": {
"@react-native-community/eslint-config": "~3.2.0",
"@react-native-firebase/app-distribution": "~19.0.0",
"@types/node": "~20.12.7",
"@types/react": "~18.2.39",
"@types/react-native": "~0.73.0",
"eslint": "~8.57.0",
"eslint-plugin-json": "~3.1.0",
"expo": "~50.0.14",
"metro-react-native-babel-preset": "~0.77.0",
"react": "~18.2.0",
"react-native": "~0.73.6",
"typescript": "~5.4.4"
}
}
26 changes: 26 additions & 0 deletions src/android/applyPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ConfigPlugin } from '@expo/config-plugins'
import { WarningAggregator, withAppBuildGradle } from 'expo/config-plugins'

export const appDistributionPlugin = 'com.google.firebase.appdistribution'

export const withApplyDistPlugin: ConfigPlugin = config => {
return withAppBuildGradle(config, config => {
if (config.modResults.language === 'groovy') {
config.modResults.contents = applyPlugin(config.modResults.contents)
} else {
WarningAggregator.addWarningAndroid(
'expo-firebase-app-distribution',
`Cannot automatically configure app build.gradle if it's not groovy`,
)
}
return config
})
}

export function applyPlugin(appBuildGradle: string) {
const perfPattern = new RegExp(`apply\\s+plugin:\\s+['"]${appDistributionPlugin}['"]`)
if (!appBuildGradle.match(perfPattern)) {
appBuildGradle += `\napply plugin: '${appDistributionPlugin}'`
}
return appBuildGradle
}
34 changes: 34 additions & 0 deletions src/android/buildscriptDependency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ConfigPlugin, WarningAggregator, withProjectBuildGradle } from '@expo/config-plugins'

const appDistributionClassPath = 'com.google.firebase:firebase-appdistribution-gradle'
const appDistributionVersion = '4.0.1'

/**
* Update `<project>/build.gradle` by adding google-services dependency to buildscript
*/
export const withBuildscriptDependency: ConfigPlugin = config => {
return withProjectBuildGradle(config, config => {
if (config.modResults.language === 'groovy') {
config.modResults.contents = setBuildscriptDependency(config.modResults.contents)
} else {
WarningAggregator.addWarningAndroid(
'expo-firebase-app-distribution',
`Cannot automatically configure project build.gradle if it's not groovy`,
)
}
return config
})
}

export function setBuildscriptDependency(buildGradle: string) {
// TODO: Find a more stable solution for this
if (!buildGradle.includes(appDistributionClassPath)) {
return buildGradle.replace(
/dependencies\s?{/,
`dependencies {
classpath '${appDistributionClassPath}:${appDistributionVersion}'`,
)
}

return buildGradle
}
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ConfigPlugin, createRunOncePlugin, withPlugins } from '@expo/config-plugins'
import { withApplyDistPlugin } from './android/applyPlugin'
import { withBuildscriptDependency } from './android/buildscriptDependency'

const withRnFirebaseAppDistribution: ConfigPlugin = config => {
return withPlugins(config, [withBuildscriptDependency, withApplyDistPlugin])
}

const pak = require('@react-native-firebase/app-distribution/package.json')
export default createRunOncePlugin(withRnFirebaseAppDistribution, pak.name, pak.version)
Loading

0 comments on commit 0ca8ea4

Please sign in to comment.