Skip to content

Commit

Permalink
Merge branch 'main' into yus/sc-227636/rn-should-import-asyncstorage-…
Browse files Browse the repository at this point in the history
…conditionally
  • Loading branch information
yusinto committed Dec 22, 2023
2 parents 8e9a0c1 + 37ff40e commit 262d9f3
Show file tree
Hide file tree
Showing 16 changed files with 653 additions and 619 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- name: 'Setup Redis'
if: ${{ inputs.workspace_path == 'packages/store/node-server-sdk-redis' }}
run: |
Expand Down Expand Up @@ -80,5 +83,6 @@ jobs:
uses: ./actions/publish
with:
workspace_name: ${{ env.WORKSPACE_NAME }}
workspace_path: ${{ inputs.workspace_path }}
prerelease: ${{ inputs.prerelease }}
dry_run: ${{ inputs.dry_run }}
33 changes: 33 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- id: release-common
name: Full release of packages/shared/common
uses: ./actions/full-release
Expand All @@ -60,6 +63,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- id: release-common
name: Full release of packages/shared/sdk-server
uses: ./actions/full-release
Expand All @@ -80,6 +86,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- id: release-common
name: Full release of packages/shared/sdk-server-edge
uses: ./actions/full-release
Expand All @@ -100,6 +109,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- id: release-common
name: Full release of packages/shared/akamai-edgeworker-sdk
uses: ./actions/full-release
Expand All @@ -120,6 +132,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- id: release-common
name: Full release of packages/sdk/cloudflare
uses: ./actions/full-release
Expand All @@ -140,6 +155,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- id: release-common
name: Full release of packages/sdk/server-node
uses: ./actions/full-release
Expand All @@ -160,6 +178,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- id: release-common
name: Full release of packages/sdk/vercel
uses: ./actions/full-release
Expand All @@ -180,6 +201,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- id: release-common
name: Full release of packages/sdk/akamai-base
uses: ./actions/full-release
Expand All @@ -200,6 +224,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- id: release-common
name: Full release of packages/sdk/akamai-edgekv
uses: ./actions/full-release
Expand All @@ -220,6 +247,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- run: |
sudo apt-get update
sudo apt-get install redis-server
Expand All @@ -244,6 +274,9 @@ jobs:
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- uses: ./actions/install-npm-version
with:
npm_version: 9.5.0
- run: |
sudo docker run -d -p 8000:8000 amazon/dynamodb-local
- id: release-common
Expand Down
1 change: 1 addition & 0 deletions actions/full-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ runs:
- uses: ./actions/publish
with:
workspace_name: ${{ env.WORKSPACE_NAME }}
workspace_path: ${{ inputs.workspace_path }}
prerelease: false
dry_run: false
- uses: ./actions/publish-docs
Expand Down
16 changes: 16 additions & 0 deletions actions/install-npm-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Install npm version
# Used to specify a version of npm that supports --provenance (for node installs < 18.X)
description: Install the latest version of the npm CLI utility.
inputs:
npm_version:
description: 'The version of npm to install'
required: false
default: latest

runs:
using: composite
steps:
- name: 'Install specified npm version'
shell: bash
run: |
npm install -g npm@${{ inputs.npm_version }}
4 changes: 4 additions & 0 deletions actions/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ inputs:
workspace_name:
description: 'The workspace to publish'
required: true
workspace_path:
description: 'Path to the workspace (for npm publish)'
required: true
prerelease:
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
required: true
Expand All @@ -21,5 +24,6 @@ runs:
./scripts/publish.sh
env:
WORKSPACE: ${{ inputs.workspace_name }}
WORKSPACE_PATH: ${{ inputs.workspace_path }}
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }}
72 changes: 64 additions & 8 deletions packages/sdk/react-native/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# LaunchDarkly React Native SDK

:warning: UNSUPPORTED This SDK is in pre-release development and is not supported.
> [!WARNING]
> UNSUPPORTED This SDK is in pre-release development and is not supported.
[![NPM][sdk-react-native-npm-badge]][sdk-react-native-npm-link]
[![Actions Status][sdk-react-native-ci-badge]][sdk-react-native-ci]
Expand All @@ -20,24 +21,79 @@ For more information, see the [complete reference guide for this SDK](https://do
yarn add @launchdarkly/react-native-client-sdk
```

Additionally, the LaunchDarkly React-Native SDK uses
[@react-native-async-storage/async-storage](https://github.com/react-native-async-storage/async-storage)
for bootstrapping. This is a native dependency.

If you are using expo, then installing this package from npm like above and re-running pod install should suffice.

If you are not using expo, you will need to explicitly add
@react-native-async-storage/async-storage as a dependency to your project
and re-run pod install for [auto-linking to work](https://github.com/react-native-community/cli/issues/1347).

## Quickstart

TODO
1. Wrap your application with `LDProvider` passing it an LDClient and
an LDContext:

```jsx
// App.tsx
import { LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';

const featureClient = new ReactNativeLDClient('mobile-key');
const userContext = { kind: 'user', key: 'test-user-1' };

```typescript
// TODO
const App = () => (
<LDProvider client={featureClient} context={userContext}>
<Welcome />
</LDProvider>
);

export default App;
```

2. Then in a child component, evaluate flags with `useBoolVariation`:

```jsx
import { useBoolVariation } from '@launchdarkly/react-native-client-sdk';

export default function Welcome() {
const flagValue = useBoolVariation('flag-key', false);

return (
<View style={styles.container}>
<Text>Welcome to LaunchDarkly</Text>
<Text>Flag value is {`${flagValue}`}</Text>
</View>
);
}
```

See the full [example app](https://github.com/launchdarkly/js-core/tree/main/packages/sdk/react-native/example).

## Developing this SDK

1. Build all the code in the `js-core` repo:

```shell
# ios
yarn ios
# at js-core repo root
yarn && yarn build
```

# android
yarn android
2. The example app uses [react-native-dotenv](https://github.com/goatandsheep/react-native-dotenv)
to manage environment variables. Under `packages/sdk/react-native/example`
create an `.env` file and add your mobile key:

```shell
echo "MOBILE_KEY=mob-abc" >> packages/sdk/react-native/example/.env
```

3. Run the example app. This will link the local react-native sdk code to the
example app for development:

```shell
# in react-native/example
yarn && yarn ios-go
```

## About LaunchDarkly
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/react-native/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ MOBILE_KEY=abcdef12456

```shell
# Note for android, there's an issue with Flipper interfering with streaming connections
# so please run the release build. There's no such issue with ios.

# android
yarn && yarn android-release
# so please run the release build. There's no such issues with ios.

# ios
yarn && yarn ios-go

# android
yarn && yarn android-release
```
19 changes: 10 additions & 9 deletions packages/sdk/react-native/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
"scripts": {
"start": "expo start",
"expo-clean": "expo prebuild --clean",
"android": "expo run:android",
"android-release": "expo run:android --variant release",
"android-go": "expo start --android --clear",
"android": "yarn link-dev && expo run:android",
"android-release": "yarn link-dev && expo run:android --variant release",
"android-go": "yarn link-dev && expo start --android --clear",
"android-log": "react-native log-android",
"ios": "expo run:ios",
"ios-release": "expo run:ios --configuration Release",
"ios-go": "yarn dev && expo start --ios --clear",
"ios": "yarn link-dev && expo run:ios",
"ios-release": "yarn link-dev && expo run:ios --configuration Release",
"ios-go": "yarn link-dev && expo start --ios --clear",
"ios-log": "react-native log-ios",
"web": "expo start --web --clear",
"web": "yarn link-dev && expo start --web --clear",
"clean": "expo prebuild --clean && yarn cache clean && rm -rf node_modules && rm -rf .expo",
"dev": "(cd .. && yarn clean && yarn build)"
"link-dev": "(cd .. && yarn build)",
"postinstall": "yarn link-dev"
},
"dependencies": {
"expo": "~49.0.16",
"expo-splash-screen": "~0.20.5",
"expo-status-bar": "~1.7.1",
"react": "18.2.0",
"react-native": "^0.73.1"
"react-native": "0.72.6"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
Loading

0 comments on commit 262d9f3

Please sign in to comment.