Skip to content

Move to multi-package repo using lerna. #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
npm-debug.log
dist
node_modules
lerna-debug.log

coverage/

Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ node_js:
branches:
only:
- master
- 2.0-consolidation
env:
global:
# BROWSER_STACK_USERNAME
Expand Down
75 changes: 14 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,24 @@
# Optimizely JavaScript SDK
<h3 align="center">
Optimizely JavaScript SDK
</h3>

This repository houses the JavaScript SDK for Optimizely X Full Stack.
<p align="center">
This repository houses the JavaScript SDK for use with Optimizely X Full Stack
</p>

## Getting Started
## Packages

### Installing the SDK
This repository is a monorepo that we manage using [Lerna](https://github.com/lerna/lerna). That means that we actually publish [several packages](/packages) to npm from the same codebase, including:

The SDK is available through [npm](https://npmjs.com/package/optimizely-sdk-core). To install:
| Package | Version | Docs | Description |
| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| [`optimizely-sdk-core`](/packages/optimizely-sdk-core) | [![npm](https://img.shields.io/npm/v/optimizely-sdk-core.svg?style=flat-square)](https://npmjs.com/package/@optimizely/optimizely-sdk-core) | [![](https://img.shields.io/badge/API%20Docs-site-green.svg?style=flat-square)](https://developers.optimizely.com/x/solutions/sdks/reference/?language=javascript) | The core of Optimizely SDK |

```
npm install @optimizely/optimizely-sdk-core --save
```
## About

Or to use in a non CommonJS fashion:
`optimizely-sdk` is developed and maintained by [Optimizely](https://optimizely.com) and many [contributors](https://github.com/optimizely/javascript-sdk/graphs/contributors). If you're interested in learning more about what Optimizely X FullStack can do for your company, please [get in touch](mailto:eng@optimizely.com)!

1. Run `npm run build`
2. Pull in `dist/optimizely.browser.umd.min.js` as a `<script>`
3. Use as global variable `window.optimizelyClient`

### Migrating from 1.x.x

This version represents a major version change and, as such, introduces some breaking changes:

- We have changed the package name to more accurately reflect the implementation of the SDK. Instead of using `optimizely-sdk`, we have migrated it to `optimizely-sdk-core` as this contains the core functionality of the SDK and leaves out things like datafile management. Instead the new `optimizely-sdk` package will be a wrapper around `optimizely-sdk-core` that will include more advanced functionality such as datafile management and event dispatch retries and can be used straight out of the box with minimal config. More on this later!

- The Node SDK is now combined with the JavaScript SDK so that we have one `optimizely-sdk-core` package that works across both server + browser environments.

- You will no longer be able to pass in `revenue` value as a stand-alone argument to the `track` call. Instead you will need to pass it as an entry in the [`eventTags`](https://developers.optimizely.com/x/solutions/sdks/reference/index.html?language=javascript#event-tags).

### Using the SDK
See the Optimizely X Full Stack testing [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first JavaScript project and use the SDK.

## Development

### Installing dependencies

```npm install```

### Unit tests

You can run all unit tests with:
```
npm test
```

### Build distribution packages

```
npm run build
```

This command will build several distribution bundles under the `dist` directory:
1. optimizely.browser.cjs.js - This is the main entry point for browser/client-side bundles
2. optimizely.browser.umd.js - This is used when not packaging the optimizely-sdk with your own JS bundles. Instead you would load this script as a `<script>` tag and reference it via the global var `optimizelyClient`
3. optimizely.node.js - This is the main entry point for Node apps

The browser bundles also come with a minified / production-ready version.

### Environment Variables

The .yml of this project contains environment vairables for ```BROWSER_STACK_USERNAME``` and ```BROWSER_STACK_ACCESS_KEY```.

These variables, created in BrowserStack, are encrypted by the TravisCI public key. This is done directly with the TravisCI command line tools; for additional information see travis encrypt-file.

### Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md).



Please see [CONTRIBUTING](CONTRIBUTING.md).
28 changes: 0 additions & 28 deletions Scripts/ci_unit_tests.sh

This file was deleted.

7 changes: 7 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lerna": "2.9.0",
"version": "independent",
"packages": [
"packages/*"
]
}
79 changes: 11 additions & 68 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,16 @@
{
"name": "@optimizely/optimizely-sdk-core",
"version": "2.0.0-beta",
"description": "JavaScript core SDK package for Optimizely X Full Stack",
"main": "dist/optimizely.node.js",
"browser": "dist/optimizely.browser.cjs.js",
"private": true,
"version": "1.0.0",
"name": "optimizely-sdk-packages",
"scripts": {
"test": "mocha ./lib/*.tests.js ./lib/**/*.tests.js ./lib/**/**/*tests.js --recursive",
"test-travis": "npm run test && grunt",
"build": "npm run build-node && npm run build-browser",
"build-node": "npm run build-node-dev",
"build-browser": "npm run build-dev-cjs && npm run build-dev-umd && npm run build-prod-cjs && npm run build-prod-umd",
"build-node-dev": "webpack lib/index.node.js dist/optimizely.node.js --target=node --output-library-target=commonjs2",
"build-node-prod": "webpack -p lib/index.node.js dist/optimizely.node.min.js --target=node --output-library-target=commonjs2",
"build-dev-cjs": "webpack lib/index.browser.js dist/optimizely.browser.cjs.js --output-library-target=commonjs",
"build-dev-umd": "webpack lib/index.browser.js dist/optimizely.browser.umd.js --output-library=optimizelyClient --output-library-target=umd",
"build-prod-cjs": "webpack -p lib/index.browser.js dist/optimizely.browser.cjs.min.js --output-library-target=commonjs",
"build-prod-umd": "webpack -p lib/index.browser.js dist/optimizely.browser.umd.min.js --output-library=optimizelyClient --output-library-target=umd",
"lint": "eslint lib/**",
"cover": "istanbul cover _mocha ./lib/*.tests.js ./lib/**/*.tests.js ./lib/**/**/*tests.js",
"coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"
},
"repository": {
"type": "git",
"url": "git+https://github.com/optimizely/javascript-sdk.git"
},
"keywords": [
"optimizely"
],
"bugs": {
"url": "https://github.com/optimizely/javascript-sdk/issues"
},
"homepage": "https://github.com/optimizely/javascript-sdk#readme",
"dependencies": {
"json-schema": "^0.2.3",
"lodash": "^4.13.1",
"murmurhash": "0.0.2",
"request": "~2.83.0",
"sprintf": "^0.1.5",
"uuid": "~3.0.1"
"postinstall": "lerna bootstrap && lerna run build",
"build": "lerna run build",
"clean": "lerna run clean",
"publish": "npm run build && lerna publish",
"test": "lerna run test --stream",
"test-travis": "lerna run test-travis --stream"
},
"devDependencies": {
"bluebird": "^3.4.6",
"chai": "^3.5.0",
"coveralls": "^2.13.1",
"eslint": "^2.9.0",
"grunt": "^1.0.1",
"grunt-karma": "^2.0.0",
"istanbul": "^0.4.5",
"json-loader": "^0.5.4",
"karma": "^2.0.0",
"karma-browserstack-launcher": "^1.2.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.1.1",
"karma-mocha": "^1.3.0",
"karma-sinon": "^1.0.5",
"karma-webpack": "^2.0.3",
"load-grunt-tasks": "^0.6.0",
"mathjs": "^3.3.0",
"mocha": "^2.5.3",
"mocha-lcov-reporter": "^1.3.0",
"nock": "^7.7.2",
"sinon": "^2.3.1",
"webpack": "^2.6.0"
},
"files": [
"dist/",
"lib/",
"LICENSE",
"CHANGELOG",
"README.md"
]
"lerna": "^2.9.0"
}
}
File renamed without changes.
File renamed without changes.
66 changes: 66 additions & 0 deletions packages/optimizely-sdk-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Optimizely JavaScript SDK Core

This repository houses the JavaScript SDK Core for Optimizely X Full Stack.

## Getting Started

### Installing the SDK

The SDK is available through [npm](https://npmjs.com/package/optimizely-sdk-core). To install:

```
npm install @optimizely/optimizely-sdk-core --save
```

Or to use in a non CommonJS fashion:

1. Run `npm run build`
2. Pull in `dist/optimizely.browser.umd.min.js` as a `<script>`
3. Use as global variable `window.optimizelyClient`

### Migrating from 1.x.x

This version represents a major version change and, as such, introduces some breaking changes:

- We have changed the package name to more accurately reflect the implementation of the SDK. Instead of using `optimizely-sdk`, we have migrated it to `optimizely-sdk-core` as this contains the core functionality of the SDK and leaves out things like datafile management. Instead the new `optimizely-sdk` package will be a wrapper around `optimizely-sdk-core` that will include more advanced functionality such as datafile management and event dispatch retries and can be used straight out of the box with minimal config. More on this later!

- The Node SDK is now combined with the JavaScript SDK so that we have one `optimizely-sdk-core` package that works across both server + browser environments.

- We no longer support legacy Node versions (under 4.0).

- You will no longer be able to pass in `revenue` value as a stand-alone argument to the `track` call. Instead you will need to pass it as an entry in the [`eventTags`](https://developers.optimizely.com/x/solutions/sdks/reference/index.html?language=javascript#event-tags).

### Using the SDK
See the Optimizely X Full Stack testing [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first JavaScript project and use the SDK.

## Development

### Installing dependencies

```npm install```

### Unit tests

You can run all unit tests with:
```
npm test
```

### Build distribution packages

```
npm run build
```

This command will build several distribution bundles under the `dist` directory:
1. optimizely.browser.cjs.js - This is the main entry point for browser/client-side bundles
2. optimizely.browser.umd.js - This is used when not packaging the optimizely-sdk with your own JS bundles. Instead you would load this script as a `<script>` tag and reference it via the global var `optimizelyClient`
3. optimizely.node.js - This is the main entry point for Node apps

The browser bundles also come with a minified / production-ready version.

### Environment Variables

The .yml of this project contains environment vairables for ```BROWSER_STACK_USERNAME``` and ```BROWSER_STACK_ACCESS_KEY```.

These variables, created in BrowserStack, are encrypted by the TravisCI public key. This is done directly with the TravisCI command line tools; for additional information see travis encrypt-file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ exports.RESERVED_EVENT_KEYWORDS = {
exports.JAVASCRIPT_CLIENT_ENGINE = 'javascript-sdk';
exports.NEW_OPTIMIZELY_VERSION = '2';
exports.NODE_CLIENT_ENGINE = 'node-sdk';
exports.NODE_CLIENT_VERSION = '2.0.0-beta';
exports.NODE_CLIENT_VERSION = '2.0.0-beta1';

/*
* Notification types for use with NotificationCenter
Expand Down
File renamed without changes.
76 changes: 76 additions & 0 deletions packages/optimizely-sdk-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"name": "@optimizely/optimizely-sdk-core",
"version": "2.0.0-beta1",
"description": "JavaScript core SDK package for Optimizely X Full Stack",
"main": "dist/optimizely.node.js",
"browser": "dist/optimizely.browser.cjs.js",
"scripts": {
"test": "mocha ./lib/*.tests.js ./lib/**/*.tests.js ./lib/**/**/*tests.js --recursive",
"test-travis": "npm run test && grunt",
"build": "npm run build-node && npm run build-browser",
"build-node": "npm run build-node-dev",
"build-browser": "npm run build-dev-cjs && npm run build-dev-umd && npm run build-prod-cjs && npm run build-prod-umd",
"build-node-dev": "webpack lib/index.node.js dist/optimizely.node.js --target=node --output-library-target=commonjs2",
"build-node-prod": "webpack -p lib/index.node.js dist/optimizely.node.min.js --target=node --output-library-target=commonjs2",
"build-dev-cjs": "webpack lib/index.browser.js dist/optimizely.browser.cjs.js --output-library-target=commonjs",
"build-dev-umd": "webpack lib/index.browser.js dist/optimizely.browser.umd.js --output-library=optimizelyClient --output-library-target=umd",
"build-prod-cjs": "webpack -p lib/index.browser.js dist/optimizely.browser.cjs.min.js --output-library-target=commonjs",
"build-prod-umd": "webpack -p lib/index.browser.js dist/optimizely.browser.umd.min.js --output-library=optimizelyClient --output-library-target=umd",
"lint": "eslint lib/**",
"cover": "istanbul cover _mocha ./lib/*.tests.js ./lib/**/*.tests.js ./lib/**/**/*tests.js",
"coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"
},
"repository": {
"type": "git",
"url": "git+https://github.com/optimizely/javascript-sdk.git"
},
"keywords": [
"optimizely"
],
"bugs": {
"url": "https://github.com/optimizely/javascript-sdk/issues"
},
"homepage": "https://github.com/optimizely/javascript-sdk#readme",
"dependencies": {
"json-schema": "^0.2.3",
"lodash": "^4.13.1",
"murmurhash": "0.0.2",
"request": "~2.83.0",
"sprintf": "^0.1.5",
"uuid": "~3.0.1"
},
"devDependencies": {
"bluebird": "^3.4.6",
"chai": "^3.5.0",
"coveralls": "^2.13.1",
"eslint": "^2.9.0",
"grunt": "^1.0.1",
"grunt-karma": "^2.0.0",
"istanbul": "^0.4.5",
"json-loader": "^0.5.4",
"karma": "^2.0.0",
"karma-browserstack-launcher": "^1.2.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.1.1",
"karma-mocha": "^1.3.0",
"karma-sinon": "^1.0.5",
"karma-webpack": "^2.0.3",
"load-grunt-tasks": "^0.6.0",
"mathjs": "^3.3.0",
"mocha": "^2.5.3",
"mocha-lcov-reporter": "^1.3.0",
"nock": "^7.7.2",
"sinon": "^2.3.1",
"webpack": "^2.6.0"
},
"publishConfig": {
"access": "public"
},
"files": [
"dist/",
"lib/",
"LICENSE",
"CHANGELOG",
"README.md"
]
}