diff --git a/.eslintrc.json b/.eslintrc.json index 1e769e6..f16af6b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,12 +3,15 @@ "env": { "jest": true }, - "parser": "@babel/eslint-parser", - "extends": "@react-native-community", - "plugins": ["@babel"], + "parser": "@typescript-eslint/parser", + "extends": [ + "@react-native-community", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["@typescript-eslint"], "settings": { "react": { - "version": "16.8" + "version": "18.2" } } } diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 551f081..284d71a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,19 +1,22 @@ name: Linting -on: [ push, pull_request ] +on: [push, pull_request] jobs: eslint: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 - - name: Use Node 16 - uses: actions/setup-node@v2 + uses: actions/checkout@v4 + + - name: Use Node 20 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 20 cache: yarn + - name: Install dependencies run: yarn + - name: Run linter run: yarn lint diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..5a82226 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,42 @@ +name: Push +concurrency: + group: push +on: + push: + branches: + - master +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write + id-token: write + steps: + - name: Check out repository code + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: yarn + + - name: Install dependencies + run: yarn --frozen-lockfile + + - name: Build + run: yarn build + + - name: Install latest npm + run: npm install -g npm@latest + + - name: Release + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + NPM_TOKEN: ${{secrets.NPM_TOKEN}} + NPM_CONFIG_PROVENANCE: true + run: yarn release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7319992..9b4c998 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,19 +1,22 @@ name: Unit tests -on: [ push, pull_request ] +on: [push, pull_request] jobs: jest: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 - - name: Use Node 16 - uses: actions/setup-node@v2 + uses: actions/checkout@v4 + + - name: Use Node 20 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 20 cache: yarn + - name: Install dependencies run: yarn + - name: Run tests run: yarn test diff --git a/.gitignore b/.gitignore index b580b3f..bb5d396 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,10 @@ node_modules .vscode package-lock.json example/yarn.lock + +# Jest +# +.jest/ + +# ts outDir +lib/ diff --git a/docs/add-app.md b/docs/add-app.md index d51d0cb..d9c2e16 100644 --- a/docs/add-app.md +++ b/docs/add-app.md @@ -7,15 +7,14 @@ URL schemes. This document describes the steps required to add support for a new maps/directions app to the library. - ## General guidelines -* Only submit one new app integration per pull request. - +- Only submit one new app integration per pull request. ## Step by step ### 1. Add constants + Start by updating [`src/constants.js`](../src/constants.js). Start by determining a key that you will use to identify the new app. @@ -28,21 +27,22 @@ title to the `title` variable. The URL scheme you add to the `prefixes` variable will be used to determine if the app exists on the client's device. - ### 2. Add icon + Add a 150x150 pixels icon with that same name to the `src/images` directory, and then add the appropriate reference to that icon to the `icons` object in the `src/constants.js` file. ### 3. Add logic + In [`src/index.js`](../src/index.js) you will find the logic to actually open the app. Add the logic for your new app there, and make sure to test it on Android and iOS. Some apps use different URL formats for each platform. ### 4. Update README + Add the new app to the list at the top of `README.md`. Also make sure to add any iOS-specific new URL schemes to the `LSApplicationQueriesSchemes` information just below it. - Thanks! diff --git a/docs/expo.md b/docs/expo.md index 08513ba..dc83535 100644 --- a/docs/expo.md +++ b/docs/expo.md @@ -2,7 +2,7 @@ These instructions are provided to help you configure your Expo app to work with this library. When using Expo there are two workflows: managed and bare. The instructions for each are slightly different. -# iOS +# IOS ## Bare Workflow diff --git a/docs/popup.md b/docs/popup.md index a430c13..b54f986 100644 --- a/docs/popup.md +++ b/docs/popup.md @@ -14,7 +14,7 @@ import { Popup } from 'react-native-map-link'; onCancelPressed={() => this.setState({ isVisible: false })} onAppPressed={() => this.setState({ isVisible: false })} onBackButtonPressed={() => this.setState({ isVisible: false })} - modalProps={{ // you can put all react-native-modal props inside. + modalProps={{ // you can put all modal props inside. animationIn: 'slideInUp' }} appsWhiteList={[ /* Array of apps (apple-maps, google-maps, etc...) that you want @@ -25,7 +25,7 @@ import { Popup } from 'react-native-map-link'; /> ``` -The Popup component uses react-native-modal. So you can pass all react-native-modal properties inside "modalProps" to modify styling and animations. +The Popup component uses react native modal. So you can pass all react native modal properties inside "modalProps" to modify styling and animations. Also, you can customize the styling of the popup by passing an object like this in the `style` prop of the `Popup` component: diff --git a/example/.gitignore b/example/.gitignore index 4820714..ae59f55 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -1,11 +1,36 @@ -node_modules/**/* -.expo/* -npm-debug.* +# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files + +# dependencies +node_modules/ + +# Expo +.expo/ +dist/ +web-build/ +web-report/ + +# Native +*.orig.* *.jks *.p8 *.p12 *.key *.mobileprovision -*.orig.* -web-build/ -web-report/ + +# Metro +.metro-health-check* + +# debug +npm-debug.* +yarn-debug.* +yarn-error.* + +# macOS +.DS_Store +*.pem + +# local env files +.env*.local + +# typescript +*.tsbuildinfo diff --git a/example/.watchmanconfig b/example/.watchmanconfig deleted file mode 100644 index 0967ef4..0000000 --- a/example/.watchmanconfig +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/example/App.js b/example/App.js deleted file mode 100644 index 9b12640..0000000 --- a/example/App.js +++ /dev/null @@ -1,94 +0,0 @@ -import React, {Component} from 'react'; -import {Button, StyleSheet, View, Image, Text, Pressable} from 'react-native'; - -import {Popup, showLocation, getApps} from 'react-native-map-link'; - -const options = { - latitude: 38.8976763, - longitude: -77.0387185, - title: 'The White House', - dialogTitle: 'This is the dialog Title', - dialogMessage: 'This is the amazing dialog Message', - cancelText: 'This is the cancel button text', -}; - -const onFootOptions = { - ...options, - sourceLatitude: 38.8991792, - sourceLongitude: -77.0452072, - directionsMode: 'walk', -}; - -export default class App extends Component { - constructor(props) { - super(props); - - this.state = { - isVisible: false, - apps:[], - }; - } - - async componentDidMount(){ - const apps = await getApps(options) - this.setState((prevState) => ({...prevState, apps})) - } - - render() { - const {apps} = this.state - return ( - - - - {apps.map(({icon, name, id, open}) => ( - - - {name} - - ))} - - this.setState({isVisible: false})} - onAppPressed={() => this.setState({isVisible: false})} - onBackButtonPressed={() => this.setState({isVisible: false})} - options={options} - /> - - -