Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #138 from launchdarkly/eb/ch36754/readme-release
Browse files Browse the repository at this point in the history
doc updates + build improvements
  • Loading branch information
eli-darkly authored Apr 26, 2019
2 parents 360d71e + a66c770 commit 4e9c689
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 96 deletions.
8 changes: 0 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ workflows:
jobs:
- oldest-long-term-support-release
- current-release
- audit-dependencies

node-template: &node-template
steps:
Expand Down Expand Up @@ -35,10 +34,3 @@ jobs:
docker:
- image: circleci/node:latest
- image: redis

audit-dependencies:
docker:
- image: circleci/node:latest
steps:
- checkout
- run: npm audit
44 changes: 41 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
Contributing to the LaunchDarkly SDK for Node.js
================================================
# Contributing to the LaunchDarkly Server-Side SDK for Node.js

We encourage pull-requests and other contributions from the community. We've also published an [SDK contributor's guide](http://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work.
LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this SDK.

## Submitting bug reports and feature requests

The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/node-server-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.

## Submitting pull requests

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.

## Build instructions

### Prerequisites

The project uses `npm`, which is bundled in all supported versions of Node.

### Building

To build, from the project root directory:

```
npm install
npm run build
```

### Testing

To run all unit tests:

```
npm test
```

By default, the full unit test suite includes live tests of the Redis integration. Those tests expect you to have a Redis instance running locally. To skip them, set the environment variable `LD_SKIP_DATABASE_TESTS=1` before running the tests.

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):

```
npm run check-typescript
```
101 changes: 22 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,103 +1,46 @@
LaunchDarkly SDK for Node.js
===========================
# LaunchDarkly Server-Side SDK for Node.js

[![Circle CI](https://circleci.com/gh/launchdarkly/node-client/tree/master.svg?style=svg)](https://circleci.com/gh/launchdarkly/node-client/tree/master)
[![Circle CI](https://circleci.com/gh/launchdarkly/node-server-sdk/tree/master.svg?style=svg)](https://circleci.com/gh/launchdarkly/node-server-sdk/tree/master)

Supported Node versions
-----------------------
## LaunchDarkly overview

This version of the LaunchDarkly SDK has been tested with Node versions 6.14 and up.

Quick setup
-----------

0. Install the Node.js SDK with `npm`

npm install ldclient-node --save

1. Require the LaunchDarkly client:

var LaunchDarkly = require('ldclient-node');


2. Create a new LDClient with your SDK key:

var ld_client = LaunchDarkly.init("YOUR SDK KEY")
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/docs/getting-started) using LaunchDarkly today!

[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)

HTTPS proxy
------------
## Supported Node versions

Node provides built-in support for the use of an HTTPS proxy. You can use NPM to configure Node to proxy all network requests through the URL provided.
```
npm config set https-proxy https://web-proxy.domain.com:8080
```


If your proxy requires authentication then you can prefix the URN with your login information:
```
npm config set https-proxy http://user:pass@web-proxy.domain.com:8080
```


Your first feature flag
-----------------------

1. Create a new feature flag on your [dashboard](https://app.launchdarkly.com)
2. In your application code, use the feature's key to check whether the flag is on for each user:

ld_client.once('ready', function() {
ld_client.variation("your.flag.key", {"key" : "user@test.com"}, false, function(err, show_feature) {
if (show_feature) {
# application code to show the feature
} else {
# the code to run if the feature is off
}
});
});
This version of the LaunchDarkly SDK has been tested with Node versions 6.14 and up.

Using flag data from a file
---------------------------
## Getting started

For testing purposes, the SDK can be made to read feature flag state from a file or files instead of connecting to LaunchDarkly. See `FileDataSource` in the [TypeScript API documentation](https://github.com/launchdarkly/node-client/blob/master/index.d.ts) for more details.
Refer to the [SDK reference guide](https://docs.launchdarkly.com/docs/node-sdk-reference) for instructions on getting started with using the SDK.

Learn more
-----------
## Learn more

Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](http://docs.launchdarkly.com/docs/node-sdk-reference).

Testing
-------
The authoritative description of all properties and methods is in the [TypeScript documentation](https://launchdarkly.github.io/node-server-sdk/).

## Testing

We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.

Contributing
------------
## Contributing

We encourage pull-requests and other contributions from the community. We've also published an [SDK contributor's guide](http://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work.
We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK.

About LaunchDarkly
-----------
## About LaunchDarkly

* 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:
* 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.
* 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?).
* 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.
* 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.
* LaunchDarkly provides feature flag SDKs for
* [Java](http://docs.launchdarkly.com/docs/java-sdk-reference "Java SDK")
* [JavaScript](http://docs.launchdarkly.com/docs/js-sdk-reference "LaunchDarkly JavaScript SDK")
* [PHP](http://docs.launchdarkly.com/docs/php-sdk-reference "LaunchDarkly PHP SDK")
* [Python](http://docs.launchdarkly.com/docs/python-sdk-reference "LaunchDarkly Python SDK")
* [Go](http://docs.launchdarkly.com/docs/go-sdk-reference "LaunchDarkly Go SDK")
* [Node.JS](http://docs.launchdarkly.com/docs/node-sdk-reference "LaunchDarkly Node SDK")
* [Electron](http://docs.launchdarkly.com/docs/electron-sdk-reference "LaunchDarkly Electron SDK")
* [.NET](http://docs.launchdarkly.com/docs/dotnet-sdk-reference "LaunchDarkly .Net SDK")
* [Ruby](http://docs.launchdarkly.com/docs/ruby-sdk-reference "LaunchDarkly Ruby SDK")
* [iOS](http://docs.launchdarkly.com/docs/ios-sdk-reference "LaunchDarkly iOS SDK")
* [Android](http://docs.launchdarkly.com/docs/android-sdk-reference "LaunchDarkly Android SDK")
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list.
* Explore LaunchDarkly
* [launchdarkly.com](http://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
* [docs.launchdarkly.com](http://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDKs
* [apidocs.launchdarkly.com](http://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
* [blog.launchdarkly.com](http://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
* [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies
8 changes: 7 additions & 1 deletion docs/typedoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
// the properties are equivalent to the command-line options described here:
// https://typedoc.org/api/

let version = process.env.VERSION;
if (!version) {
const package = require('../package.json');
version = package.version;
}

module.exports = {
out: './docs/build/html',
exclude: [
'**/node_modules/**',
'test-types.ts'
],
name: 'LaunchDarkly Node SDK',
name: 'LaunchDarkly Server-Side Node SDK (' + version + ')',
readme: 'none', // don't add a home page with a copy of README.md
mode: 'file', // don't treat "index.d.ts" itself as a parent module
includeDeclarations: true, // allows it to process a .d.ts file instead of actual TS code
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Type definitions for ldclient-node

/**
* This is the API reference for the LaunchDarkly SDK for Node.js.
* This is the API reference for the LaunchDarkly Server-Side SDK for Node.js.
*
* In typical usage, you will call [[init]] once at startup time to obtain an instance of
* [[LDClient]], which provides access to all of the SDK's functionality.
Expand Down
41 changes: 41 additions & 0 deletions scripts/release-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# This script generates HTML documentation for the current release and publishes it to the
# "gh-pages" branch of the current repository. The current repository should be the public one,
# and it must already have a "gh-pages" branch.

# It takes exactly one argument: the new version.
# It should be run from the root of this git repo like this:
# ./scripts/release.sh 4.0.9

# The "docs" directory must contain a Makefile that will generate docs into "docs/build/html".
# It will receive the version string in the environment variable $VERSION (in case it is not
# easy for the documentation script to read the version directly from the project).

set -uxe
echo "Building and releasing documentation."

export VERSION=$1

PROJECT_DIR=$(pwd)
GIT_URL=$(git remote get-url origin)

TEMP_DIR=$(mktemp -d /tmp/sdk-docs.XXXXXXX)
DOCS_CHECKOUT_DIR=$TEMP_DIR/checkout

git clone -b gh-pages $GIT_URL $DOCS_CHECKOUT_DIR

cd $PROJECT_DIR/docs
make

cd $DOCS_CHECKOUT_DIR

git rm -r * || true
touch .nojekyll # this turns off unneeded preprocessing by GH Pages which can break our docs
git add .nojekyll
cp -r $PROJECT_DIR/docs/build/html/* .
git add *
git commit -m "Updating documentation to version $VERSION"
git push origin gh-pages

cd $PROJECT_DIR
rm -rf $TEMP_DIR
16 changes: 12 additions & 4 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This script publishes a new version of the ldclient-node SDK to NPM. It also updates the version in package.json.
# This script publishes a new version of the SDK to NPM. It also updates the version in package.json.

# It takes exactly one argument: the new version.
# It should be run from the root of this git repo like this:
Expand All @@ -8,7 +8,7 @@
# When done you should commit and push the changes made.

set -uxe
echo "Starting node-client release."
echo "Starting node-server-sdk release."

VERSION=$1
npm --version
Expand All @@ -17,10 +17,18 @@ npm --version
# We're intentionally not running 'npm version' because it does a git commit, which interferes
# with other parts of this automated release process.

# Update version in setup.py
PACKAGE_JSON_TEMP=./package.json.tmp
sed "s/\"version\".*/\"version\": \"${VERSION}\",/g" package.json > ${PACKAGE_JSON_TEMP}
mv ${PACKAGE_JSON_TEMP} package.json

npm install

npm publish

echo "Done with node-client release"
if [[ $VERSION =~ '-' ]]; then
echo "Not publishing documentation because this is not a production release"
else
./scripts/release-docs.sh $VERSION
fi

echo "Done with node-server-sdk release"

0 comments on commit 4e9c689

Please sign in to comment.