You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+12-19
Original file line number
Diff line number
Diff line change
@@ -6,41 +6,34 @@ LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkl
6
6
7
7
The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/js-client-sdk/issues) in the SDK repository. Bug reports and feature requests specific to this SDK should be filed in this issue tracker. The SDK team will respond to all newly filed issues within two business days.
8
8
9
-
Submitting pull requests
10
-
------------------
9
+
## Submitting pull requests
11
10
12
11
We encourage pull requests and other contributions from the community. Before submitting pull requests, ensure that all temporary or unintended code is removed. Don't worry about adding reviewers to the pull request; the LaunchDarkly SDK team will add themselves. The SDK team will acknowledge all pull requests within two business days.
13
12
14
-
Build instructions
15
-
------------------
13
+
## Build instructions
16
14
17
-
Before building the code, it would be helpful to know a bit about the structure of the code in this repository. This repository is a monorepo containing two projects, each of which is published to npm as a package with the same name:
18
-
19
-
-`launchdarkly-js-client-sdk`: This is the main SDK package that applications will import. Any logic that specifically relies on being in a browser environment should go here (see `browserPlatform.js`). This automatically imports `launchdarkly-js-sdk-common`.
20
-
-`launchdarkly-js-sdk-common`: Internal implementation code that is not browser-specific.
15
+
### Prerequisites
21
16
22
-
The reason `launchdarkly-js-sdk-common`exists is that the [Electron SDK](https://github.com/launchdarkly/electron-client) has very similar functionality to the browser SDK. Therefore, all of the code that is used by both has been factored out into the common package.
17
+
Note that much of the basic SDK logic, which is common to all of the LaunchDarkly client-side JavaScript-based SDKs, is in the `launchdarkly-js-sdk-common`package in the [js-sdk-common](https://github.com/launchdarkly/js-sdk-common) repository. This is pulled in automatically by `npm` when you build the SDK, but if you are planning to make changes that affect the common code, you will need to check out that repository as well.
23
18
24
-
### Prerequisites
19
+
### Setup
25
20
26
-
Before building the SDK, you need to install [Lerna](https://www.npmjs.com/package/lerna).
21
+
To install project dependencies, from the project root directory:
27
22
28
23
```
29
-
npm install lerna
24
+
npm install
30
25
```
31
26
32
-
### Building
27
+
### Testing
33
28
34
-
You can build all three packages by running the following command from the root directory:
29
+
To run all unit tests:
35
30
36
31
```
37
-
npm run build
32
+
npm test
38
33
```
39
34
40
-
### Testing
41
-
42
-
You can run all tests by running the following command from the root directory:
35
+
To verify that the TypeScript declarations compile correctly (this involves compiling the file `test-types.ts`, so if you have changed any types or interfaces, you will want to update that code):
This is a simple front-end-only JavaScript application that exercises much of the functionality of the LaunchDarkly SDK for browser JavaScript. It is not meant to be an example of how to write a LaunchDarkly application, since most of its logic is devoted to implementing a testing UI that a real application would not have. Instead, it is meant to show the SDK in action and to verify that feature flags work as expected in a given environment.
4
+
5
+
For a more realistic example of a LaunchDarkly-enabled application with both a front end and a back end, see [`hello-bootstrap`](https://github.com/launchdarkly/hello-bootstrap).
6
+
7
+
## Running the demo
8
+
9
+
Most of the demo can be used without a real HTTP server; just start your browser and tell it to open the `index.html` file in this directory. The only thing that will not work in that mode is the "Set URL" feature under Navigation/Events.
10
+
11
+
To access the demo via a basic HTTP server, there are several ways but the simplest-- if you have Python-- is to run `python -m SimpleHTTPServer 8000` from a command line at the SDK root directory, and then browse to this location.
12
+
13
+
Note that by default, the demo uses the latest release of the JS SDK script that is hosted on `app.launchdarkly.com`. However, if it detects that you have built the SDK locally, it will use the local SDK code instead. Therefore, it can be used for testing changes to the SDK. To build from the SDK root directory, run `npm run build`.
14
+
15
+
## Selecting an environment
16
+
17
+
By default, the demo uses a simple environment that LaunchDarkly has created for this purpose, containing a few feature flags as follows-- two that do not change, and two that change in response to a user property:
18
+
19
+
*`client-side-flag-1-always-true`: Always returns the boolean value `true`.
20
+
*`client-side-flag-2-always-green`: Always returns the string value `"green"`.
21
+
*`client-side-flag-3-does-name-start-with-b`: Returns `true` if the user's `name` property starts with the letter B, otherwise `false`.
22
+
*`client-side-flag-4-has-valid-email`: Returns `true` if the user's `email` property matches a simple regex for validating emails, otherwise `false`.
23
+
24
+
You can instead use your own environment, by copying the environment ID from [your dashboard](https://app.launchdarkly.com/settings/projects) into the Environment ID field and clicking "Update Configuration, Reconnect". You should now see all feature flags from your environment that have the "Make this flag available to client-side SDKs" option checked. If you also clicked the "Live updates (streaming)" box, you should also see any changes you make to your flags reflected on the page in real time.
0 commit comments