Skip to content

Commit

Permalink
feat: React-native support for auto-env attributes. (#357)
Browse files Browse the repository at this point in the history
This PR adds auto env support for the react-native sdk.
  • Loading branch information
yusinto authored Feb 1, 2024
1 parent cd75210 commit deea99c
Show file tree
Hide file tree
Showing 48 changed files with 2,371 additions and 131 deletions.
25 changes: 22 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
module.exports = {
env: {
node: true,
'jest/globals': true,
},
extends: ['airbnb-base', 'airbnb-typescript/base', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.eslint.json',
},
plugins: ['@typescript-eslint', 'prettier'],
ignorePatterns: ['**/dist/**', '**/vercel/examples/**'],
plugins: ['@typescript-eslint', 'prettier', 'jest'],
ignorePatterns: [
'**/dist/**',
'**/vercel/examples/**',
'**/react-native/example/**',
'**/fromExternal/**',
],
rules: {
'@typescript-eslint/lines-between-class-members': 'off',
'@typescript-eslint/no-unused-vars': [
Expand All @@ -20,7 +26,12 @@ module.exports = {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/jest*.ts', '**/*.test.ts', '**/rollup.config.ts'],
devDependencies: [
'**/jest*.ts',
'**/*.test.ts',
'**/rollup.config.ts',
'**/*{.,_}{test,spec}.{ts,tsx}',
],
},
],
'import/default': 'error',
Expand All @@ -30,5 +41,13 @@ module.exports = {
'import/no-cycle': 'error',
'import/no-useless-path-segments': 'error',
'import/no-duplicates': 'error',
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
// 'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
},
globals: {
BigInt: 'readonly',
},
};
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"eslint": "^8.45.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.0",
"typedoc": "0.25.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/akamai-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/crypto-js": "^4.1.1",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.45.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"launchdarkly-js-test-helpers": "^2.2.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/akamai-edgekv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/crypto-js": "^4.1.1",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.45.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"launchdarkly-js-test-helpers": "^2.2.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@
"@types/crypto-js": "^4.1.1",
"@types/jest": "^29.5.0",
"@types/rollup-plugin-generate-package-json": "^3.2.3",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.45.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"launchdarkly-js-test-helpers": "^2.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/react-native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ and re-run pod install for [auto-linking to work](https://github.com/react-nativ
// App.tsx
import { LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';

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

const App = () => (
Expand Down Expand Up @@ -100,7 +100,7 @@ yarn && yarn ios-go

## Verifying SDK build provenance with the SLSA framework

LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).
LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).

## About LaunchDarkly

Expand Down
3 changes: 3 additions & 0 deletions packages/sdk/react-native/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'],
};
8 changes: 6 additions & 2 deletions packages/sdk/react-native/example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { MOBILE_KEY } from '@env';

import { LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';
import {
AutoEnvAttributes,
LDProvider,
ReactNativeLDClient,
} from '@launchdarkly/react-native-client-sdk';

import Welcome from './src/welcome';

const featureClient = new ReactNativeLDClient(MOBILE_KEY);
const featureClient = new ReactNativeLDClient(MOBILE_KEY, AutoEnvAttributes.Enabled);

const App = () => {
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/react-native/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"expo-splash-screen": "~0.20.5",
"expo-status-bar": "~1.7.1",
"react": "18.2.0",
"react-native": "0.72.6"
"react-native": "0.72.6",
"react-native-dotenv": "^3.4.9"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand All @@ -37,7 +38,7 @@
"@types/react": "~18.2.14",
"@types/react-native-dotenv": "^0.2.1",
"detox": "^20.14.7",
"react-native-dotenv": "^3.4.9",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
}
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/react-native/example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"jsx": "react",
"strict": true,
"typeRoots": ["./types"]
"typeRoots": ["./types"],
},
"exclude": ["e2e"]
"exclude": ["e2e"],
}
Loading

0 comments on commit deea99c

Please sign in to comment.