Skip to content

Commit 8beedc7

Browse files
authored
chore: add react-native workspace (#305)
1 parent 31c1901 commit 8beedc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+638
-20
lines changed

.github/workflows/react-native.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: sdk/react-native
2+
3+
on:
4+
push:
5+
branches: [main, 'feat/**']
6+
paths-ignore:
7+
- '**.md' #Do not need to run CI for markdown changes.
8+
pull_request:
9+
branches: [main, 'feat/**']
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
build-test-react-native:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
19+
- id: shared
20+
name: Shared CI Steps
21+
uses: ./actions/ci
22+
with:
23+
workspace_name: '@launchdarkly/react-native-client-sdk'
24+
workspace_path: packages/sdk/react-native

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"packages/sdk/server-node",
1111
"packages/sdk/cloudflare",
1212
"packages/sdk/cloudflare/example",
13+
"packages/sdk/react-native",
1314
"packages/sdk/vercel",
1415
"packages/sdk/akamai-base",
1516
"packages/sdk/akamai-base/example",

packages/sdk/cloudflare/example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "example",
2+
"name": "cloudflare-example",
33
"version": "0.0.0",
44
"type": "module",
55
"module": "./dist/index.mjs",
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{
22
"compilerOptions": {
3-
// Uses "." so it can load package.json.
4-
"rootDir": ".",
5-
"outDir": "dist",
6-
"target": "ES2017",
3+
"allowSyntheticDefaultImports": true,
4+
"declaration": true,
5+
"declarationMap": true,
76
"lib": ["es6"],
87
"module": "ES6",
9-
"strict": true,
8+
"moduleResolution": "node",
109
"noImplicitOverride": true,
11-
"allowSyntheticDefaultImports": true,
12-
"sourceMap": true,
13-
"declaration": true,
14-
"declarationMap": true, // enables importers to jump to source
10+
"outDir": "dist",
1511
"resolveJsonModule": true,
12+
// Uses "." so it can load package.json.
13+
"rootDir": ".",
14+
"skipLibCheck": true,
15+
// enables importers to jump to source
16+
"sourceMap": true,
17+
"strict": true,
1618
"stripInternal": true,
17-
"moduleResolution": "node",
18-
"types": ["@cloudflare/workers-types", "jest", "node"],
19-
"skipLibCheck": true
19+
"target": "ES2017",
20+
"types": ["@cloudflare/workers-types", "jest", "node"]
2021
},
2122
"exclude": ["**/*.test.ts", "dist", "node_modules", "__tests__", "example"]
2223
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
All notable changes to the LaunchDarkly SDK for React Native will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org).

packages/sdk/react-native/LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2023 Catamorphic, Co.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# LaunchDarkly React Native SDK
2+
3+
:warning: UNSUPPORTED This SDK is in pre-release development and is not supported.
4+
5+
[![NPM][sdk-react-native-npm-badge]][sdk-react-native-npm-link]
6+
[![Actions Status][sdk-react-native-ci-badge]][sdk-react-native-ci]
7+
[![Documentation][sdk-react-native-ghp-badge]][sdk-react-native-ghp-link]
8+
[![NPM][sdk-react-native-dm-badge]][sdk-react-native-npm-link]
9+
[![NPM][sdk-react-native-dt-badge]][sdk-react-native-npm-link]
10+
11+
The LaunchDarkly React Native SDK is designed primarily for use in mobile environments. It follows the client-side LaunchDarkly model for multi-user contexts.
12+
13+
This SDK is a replacement of [launchdarkly-react-native-client-sdk](https://github.com/launchdarkly/react-native-client-sdk). Please consider updating your application to use this package instead.
14+
15+
For more information, see the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/client-side/react-native).
16+
17+
## Install
18+
19+
```shell
20+
yarn add @launchdarkly/react-native-client-sdk
21+
```
22+
23+
## Quickstart
24+
25+
TODO
26+
27+
```typescript
28+
import { init } from '@launchdarkly/react-native-client-sdk';
29+
30+
// TODO
31+
```
32+
33+
See the full [example app](https://github.com/launchdarkly/js-core/tree/main/packages/sdk/react-native/example).
34+
35+
## Developing this SDK
36+
37+
:information_source: You will need to setup your sdk key in the example dir. See the example [README](https://github.com/launchdarkly/js-core/blob/main/packages/sdk/react-native/example/README.md#L1).
38+
39+
```shell
40+
# at js-core repo root
41+
yarn && yarn build
42+
43+
# at sdk/react-native repo
44+
yarn android | ios
45+
```
46+
47+
## About LaunchDarkly
48+
49+
- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
50+
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
51+
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
52+
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
53+
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
54+
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
55+
- Explore LaunchDarkly
56+
- [launchdarkly.com](https://www.launchdarkly.com/ 'LaunchDarkly Main Website') for more information
57+
- [docs.launchdarkly.com](https://docs.launchdarkly.com/ 'LaunchDarkly Documentation') for our documentation and SDK reference guides
58+
- [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ 'LaunchDarkly API Documentation') for our API documentation
59+
- [blog.launchdarkly.com](https://blog.launchdarkly.com/ 'LaunchDarkly Blog Documentation') for the latest product updates
60+
61+
[sdk-react-native-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/react-native.yml/badge.svg
62+
[sdk-react-native-ci]: https://github.com/launchdarkly/js-core/actions/workflows/react-native.yml
63+
[sdk-react-native-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/react-native-client-sdk.svg?style=flat-square
64+
[sdk-react-native-npm-link]: https://www.npmjs.com/package/@launchdarkly/react-native-client-sdk
65+
[sdk-react-native-ghp-badge]: https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8
66+
[sdk-react-native-ghp-link]: https://launchdarkly.github.io/js-core/packages/sdk/react-native/docs/
67+
[sdk-react-native-dm-badge]: https://img.shields.io/npm/dm/@launchdarkly/react-native-client-sdk.svg?style=flat-square
68+
[sdk-react-native-dt-badge]: https://img.shields.io/npm/dt/@launchdarkly/react-native-client-sdk.svg?style=flat-square
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
.env
3+
4+
# dependencies
5+
node_modules/
6+
7+
# Expo
8+
.expo/
9+
dist/
10+
web-build/
11+
12+
# Native
13+
*.orig.*
14+
*.jks
15+
*.p8
16+
*.p12
17+
*.key
18+
*.mobileprovision
19+
20+
# Metro
21+
.metro-health-check*
22+
23+
# debug
24+
npm-debug.*
25+
yarn-debug.*
26+
yarn-error.*
27+
28+
# macOS
29+
.DS_Store
30+
*.pem
31+
32+
# local env files
33+
.env*.local
34+
35+
# typescript
36+
*.tsbuildinfo
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { CLIENT_SIDE_SDK_KEY } from '@env';
2+
import React, { useEffect, useState } from 'react';
3+
import { StyleSheet, Text, View } from 'react-native';
4+
5+
import { init, type LDClientImpl } from '@launchdarkly/react-native-client-sdk';
6+
7+
const context = { kind: 'user', key: 'test-user-1' };
8+
9+
export default function App() {
10+
const [ldc, setLdc] = useState<LDClientImpl>();
11+
const [flag, setFlag] = useState<boolean>(false);
12+
13+
useEffect(() => {
14+
init(CLIENT_SIDE_SDK_KEY, context)
15+
.then((c) => {
16+
setLdc(c);
17+
})
18+
.catch((e) => console.log(e));
19+
}, []);
20+
21+
useEffect(() => {
22+
const f = ldc?.boolVariation('dev-test-flag', false);
23+
setFlag(f ?? false);
24+
}, [ldc]);
25+
26+
return (
27+
<View style={styles.container}>
28+
<Text>{flag ? <>devTestFlag: {`${flag}`}</> : <>loading...</>}</Text>
29+
</View>
30+
);
31+
}
32+
33+
const styles = StyleSheet.create({
34+
container: {
35+
flex: 1,
36+
alignItems: 'center',
37+
justifyContent: 'center',
38+
},
39+
box: {
40+
width: 60,
41+
height: 60,
42+
marginVertical: 20,
43+
},
44+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## LaunchDarkly React Native SDK example app
2+
3+
To run the example app:
4+
5+
1. Create a `.env` file at the same level as this README
6+
2. Add your client-side sdk key to that `.env` file:
7+
8+
```shell
9+
CLIENT_SIDE_SDK_KEY=abcdef12456
10+
```
11+
12+
3. Finally
13+
14+
```shell
15+
# android
16+
yarn && yarn android
17+
18+
# ios
19+
yarn && yarn ios
20+
```

0 commit comments

Comments
 (0)