1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-08 01:15:49 +02:00

Merge pull request #138 from finn-no/lerna

Move to use lerna to have multiple packages inside same repo
This commit is contained in:
Sveinung Røsaker 2016-06-18 11:51:46 +02:00 committed by GitHub
commit c92c168081
117 changed files with 337 additions and 129 deletions

2
.gitignore vendored
View File

@ -1,4 +1,6 @@
node_modules node_modules
lerna-debug
npm-debug
.DS_Store .DS_Store
# Logs # Logs

View File

@ -1,16 +1,14 @@
sudo: false sudo: false
language: node_js language: node_js
node_js: node_js:
- "5.8" - "6"
env: TEST_DATABASE_URL=postgres://postgres@localhost:5432/unleash_test env:
- DATABASE_URL=postgres://postgres@localhost:5432/unleash_test TEST_DATABASE_URL=postgres://postgres@localhost:5432/unleash_test
before_script: before_script:
- echo '--timeout 10000' > test/mocha.opts
- psql -c 'create database unleash_test;' -U postgres - psql -c 'create database unleash_test;' -U postgres
- 'DATABASE_URL=$TEST_DATABASE_URL ./node_modules/.bin/db-migrate up'
script: script:
- npm install - npm install
- npm test - npm run test:ci
- npm run coverage-report || true
notifications: notifications:
hipchat: hipchat:
rooms: rooms:

View File

@ -1,5 +1,7 @@
# unleash # unleash
__Warning: We are in the process of splitting up unleash into multiple packages in this repository, if you want to test the previous package see [previous tag](https://github.com/finn-no/unleash/tree/v1.0.0-alpha.1) __
[![Build Status](https://travis-ci.org/finn-no/unleash.svg?branch=master)](https://travis-ci.org/finn-no/unleash) [![Code Climate](https://codeclimate.com/github/finn-no/unleash/badges/gpa.svg)](https://codeclimate.com/github/finn-no/unleash) [![Coverage Status](https://coveralls.io/repos/finn-no/unleash/badge.png?branch=master)](https://coveralls.io/r/finn-no/unleash?branch=master) [![Dependency Status](https://david-dm.org/finn-no/unleash.png)](https://david-dm.org/finn-no/unleash) [![devDependency Status](https://david-dm.org/finn-no/unleash/dev-status.png)](https://david-dm.org/finn-no/unleash#info=devD) [![Build Status](https://travis-ci.org/finn-no/unleash.svg?branch=master)](https://travis-ci.org/finn-no/unleash) [![Code Climate](https://codeclimate.com/github/finn-no/unleash/badges/gpa.svg)](https://codeclimate.com/github/finn-no/unleash) [![Coverage Status](https://coveralls.io/repos/finn-no/unleash/badge.png?branch=master)](https://coveralls.io/r/finn-no/unleash?branch=master) [![Dependency Status](https://david-dm.org/finn-no/unleash.png)](https://david-dm.org/finn-no/unleash) [![devDependency Status](https://david-dm.org/finn-no/unleash/dev-status.png)](https://david-dm.org/finn-no/unleash#info=devD)
![Admin UI](https://cloud.githubusercontent.com/assets/572/5873775/3ddc1a66-a2fa-11e4-923c-0a9569605dad.png) ![Admin UI](https://cloud.githubusercontent.com/assets/572/5873775/3ddc1a66-a2fa-11e4-923c-0a9569605dad.png)
@ -49,12 +51,12 @@ export TEST_DATABASE_URL=postgres://unleash_user:passord@localhost:5432/unleash_
// Install dependencies // Install dependencies
npm install npm install
// Run migrations in your local DBs // Run migrations in your local DBs (via unleash-api)
./node_modules/.bin/db-migrate up npm run db-migrate
DATABASE_URL=$TEST_DATABASE_URL ./node_modules/.bin/db-migrate up DATABASE_URL=$TEST_DATABASE_URL npm run db-migrate
// Start server in dev-mode: // Start server
npm run dev npm start
// Admin dashboard // Admin dashboard
http://localhost:4242 http://localhost:4242
@ -62,11 +64,8 @@ http://localhost:4242
// Feature API: // Feature API:
http://localhost:4242/features http://localhost:4242/features
// Execute tests: // Execute tests in all packages:
npm test npm test
// Run tests with postgres running in docker:
npm run docker-test
``` ```
### Making a schema change ### Making a schema change
@ -76,3 +75,13 @@ npm run docker-test
3. Run `db-migrate create your-migration-name` and edit the generated file to have this line: `module.exports = require('../scripts/migration-runner').create('NNN-your-migration-name');` 3. Run `db-migrate create your-migration-name` and edit the generated file to have this line: `module.exports = require('../scripts/migration-runner').create('NNN-your-migration-name');`
4. Run `db-migrate up`. 4. Run `db-migrate up`.
5. Generate LB artifact using `scripts/generate-liquibase-artifact` (TODO: make this internal) 5. Generate LB artifact using `scripts/generate-liquibase-artifact` (TODO: make this internal)
### Publishing / Releasing new packages
Please run `npm run nsp` nad `npm run lint` checks before publishing.
Run `npm run publish` to start the publishing process.
Lerna is setup with independent versioning so you will be prompted with version per package, and lerna will update all the versions across packages.
`npm run publish:dry`

4
lerna.json Normal file
View File

@ -0,0 +1,4 @@
{
"lerna": "2.0.0-beta.20",
"version": "independent"
}

View File

@ -1,5 +1,5 @@
{ {
"name": "unleash-server", "name": "unleash-project",
"description": "unleash your features", "description": "unleash your features",
"version": "1.0.0-alpha.2", "version": "1.0.0-alpha.2",
"keywords": [ "keywords": [
@ -8,17 +8,6 @@
"feature", "feature",
"toggle" "toggle"
], ],
"files": [
"lib",
"migrations",
"scripts",
"public",
"app.js",
"server.js",
"server-impl.js",
"README.md",
"LICENSE"
],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "ssh://git@github.com:finn-no/unleash.git" "url": "ssh://git@github.com:finn-no/unleash.git"
@ -27,90 +16,31 @@
"url": "https://github.com/finn-no/unleash/issues" "url": "https://github.com/finn-no/unleash/issues"
}, },
"engines": { "engines": {
"node": ">=4.4.3" "node": "6"
}, },
"main": "./server-impl.js",
"scripts": { "scripts": {
"db-migrate-and-start": "npm run db-migrate && npm run start", "bootstrap": "lerna bootstrap",
"start": "npm run build && NODE_ENV=production node server.js", "prepublish": "npm run bootstrap",
"build": "./node_modules/.bin/webpack -p", "lint": "lerna exec eslint .",
"dev": "NODE_ENV=development supervisor --ignore ./node_modules/,./public/js server-dev.js", "pre-commit": "echo 'no lint check' && exit 0;",
"start-pg": "pg_virtualenv npm run start-pg-chain", "test": "lerna --concurrency=1 exec npm run test",
"start-pg-chain": "export DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@localhost:$PGPORT/postgres ; db-migrate up && npm run dev", "test:ci": "lerna --concurrency=1 exec npm run test:ci",
"test": "export PORT=4243 ; jest && npm run lint && mocha test test/*.js && npm run coverage", "nsp": "lerna exec nsp check",
"docker-test": "export PORT=4243 ; ./scripts/docker-postgres.sh", "start": "lerna --scope=unleash-server exec npm start",
"pg-virtualenv-test": "pg_virtualenv npm run pg-virtualenv-chain", "publish": "lerna publish",
"pg-virtualenv-chain": "export TEST_DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@localhost:$PGPORT/postgres ; npm run db-migrate-testdb && npm test", "publish:dry": "lerna publish --skip-git --skip-npm",
"db-migrate": "node_modules/.bin/db-migrate up", "db-migrate": "lerna --scope=unleash-api exec npm run db-migrate"
"db-migrate-testdb": "DATABASE_URL=$TEST_DATABASE_URL ./node_modules/.bin/db-migrate up",
"tdd": "mocha --watch test test/*",
"test-bamboo-ci": "mocha test test/*",
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec",
"coverage-report": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"jest": "jest",
"lint": "eslint . --ignore-path .gitignore",
"release:patch": "npm version patch && npm run push-package-publish",
"release:minor": "npm version minor && npm run push-package-publish",
"release:major": "npm version major && npm run push-package-publish",
"push-package-publish": "git push --follow-tags && npm publish"
},
"dependencies": {
"bluebird": "2.9.14",
"body-parser": "1.15.0",
"cookie-parser": "^1.4.1",
"db-migrate": "0.9.23",
"deep-diff": "^0.3.3",
"errorhandler": "1.3.5",
"express": "4.13.4",
"express-validator": "2.20.3",
"install": "^0.6.1",
"jsx-loader": "0.12.2",
"jsxhint": "0.13.2",
"knex": "^0.10.0",
"lodash": "^3.5.0",
"log4js": "0.6.35",
"moment": "^2.13.0",
"npm": "^3.8.8",
"pg": "^4.5.5",
"react": "^0.13.1",
"react-router": "^0.13.2",
"reflux": "^0.2.10",
"reqwest": "^2.0.5",
"serve-favicon": "^2.3.0",
"webpack": "^1.13.0",
"webpack-dev-middleware": "^1.6.1"
}, },
"dependencies": {},
"devDependencies": { "devDependencies": {
"chai": "3.5.0", "eslint": "^2.0.0",
"coveralls": "^2.11.9", "eslint-config-finn": "^1.0.0-alpha.3",
"eslint": "^2.9.0",
"eslint-config-spt": "^2.0.0",
"eslint-plugin-react": "^4.3.0", "eslint-plugin-react": "^4.3.0",
"istanbul": "^0.4.3", "lerna": "2.0.0-beta.20",
"jest-cli": "0.5.8",
"mocha": "^2.4.5",
"mocha-lcov-reporter": "1.2.0",
"nsp": "^2.3.2", "nsp": "^2.3.2",
"pre-commit": "^1.0.2", "pre-commit": "^1.0.2"
"react-tools": "^0.13.1",
"supertest": "^1.2.0",
"supervisor": "^0.10.0"
},
"jest": {
"scriptPreprocessor": "<rootDir>/scripts/jest-preprocessor.js",
"modulePathIgnorePatterns": [
"<rootDir>/node_modules/npm"
],
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/react",
"<rootDir>/node_modules/reflux"
],
"moduleFileExtensions": [
"jsx",
"js"
]
}, },
"pre-commit": [ "pre-commit": [
"lint" "pre-commit"
] ]
} }

View File

@ -6,20 +6,28 @@ var validator = require('express-validator');
var log4js = require('log4js'); var log4js = require('log4js');
var logger = require('./lib/logger'); var logger = require('./lib/logger');
var routes = require('./lib/routes'); var routes = require('./lib/routes');
var path = require('path');
module.exports = function(config) { module.exports = function(config) {
var app = express(); var app = express();
var router = express.Router(); // eslint-disable-line var router = express.Router();
var baseUriPath = config.baseUriPath || ''; var baseUriPath = config.baseUriPath || '';
var publicFolder = config.publicFolder;
app.set('trust proxy'); app.set('trust proxy');
app.set('port', config.port); app.set('port', config.port);
app.locals.baseUriPath = baseUriPath; app.locals.baseUriPath = baseUriPath;
app.use(cookieParser()); app.use(cookieParser());
app.use(favicon(__dirname + '/public/favicon.ico')); if (publicFolder) {
app.use(favicon(path.join(publicFolder, 'favicon.ico')));
}
app.use(validator([])); app.use(validator([]));
app.use(baseUriPath, express.static(__dirname + '/public')); if (publicFolder) {
app.use(baseUriPath, express.static(publicFolder));
}
app.use(bodyParser.json({ strict: false })); app.use(bodyParser.json({ strict: false }));
app.use(log4js.connectLogger(logger, { app.use(log4js.connectLogger(logger, {
format: ':remote-addr :status :method :url :response-timems', format: ':remote-addr :status :method :url :response-timems',
@ -30,5 +38,9 @@ module.exports = function(config) {
routes.create(router, config); routes.create(router, config);
app.use(baseUriPath, router); app.use(baseUriPath, router);
if (process.env.NODE_ENV !== 'production') {
app.use(require('errorhandler')());
}
return app; return app;
}; };

View File

@ -0,0 +1,71 @@
{
"name": "unleash-api",
"description": "unleash your features",
"version": "1.0.0-alpha.1",
"keywords": [
"unleash",
"feature toggle",
"feature",
"toggle"
],
"files": [
"lib",
"migrations",
"public",
"app.js",
"server.js",
"server-impl.js",
"README.md",
"LICENSE"
],
"repository": {
"type": "git",
"url": "ssh://git@github.com:finn-no/unleash.git"
},
"bugs": {
"url": "https://github.com/finn-no/unleash/issues"
},
"engines": {
"node": "6"
},
"main": "./server-impl.js",
"scripts": {
"db-migrate-and-start": "npm run db-migrate && npm run start",
"start": "node server.js",
"start:dev": "NODE_ENV=development supervisor --ignore ./node_modules/ server.js",
"start:dev:pg": "pg_virtualenv npm run start:dev:pg-chain",
"start:dev:pg-chain": "export DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@localhost:$PGPORT/postgres ; db-migrate up && npm run start:dev",
"db-migrate": "db-migrate up",
"test": "export PORT=4243 ; mocha test test/*.js && npm run test:coverage",
"test:ci": "npm run db-migrate && npm run test",
"test:watch": "mocha --watch test test/*",
"test:pg-virtualenv": "pg_virtualenv npm run test:pg-virtualenv-chai",
"test:pg-virtualenv-chain": "export TEST_DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@localhost:$PGPORT/postgres ; npm run db-migrate-testdb && npm test",
"test:coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec",
"test:coverage-report": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
},
"dependencies": {
"bluebird": "2.9.14",
"body-parser": "1.15.0",
"cookie-parser": "^1.4.1",
"db-migrate": "0.9.23",
"deep-diff": "^0.3.3",
"errorhandler": "1.3.5",
"express": "4.13.4",
"express-validator": "2.20.3",
"install": "^0.6.1",
"knex": "^0.10.0",
"log4js": "0.6.35",
"pg": "^4.5.5",
"serve-favicon": "^2.3.0"
},
"devDependencies": {
"chai": "3.5.0",
"coveralls": "^2.11.9",
"istanbul": "^0.4.3",
"mocha": "^2.4.5",
"mocha-lcov-reporter": "1.2.0",
"supertest": "^1.2.0",
"supervisor": "^0.10.0"
}
}

View File

@ -19,7 +19,8 @@ function start(options) {
eventDb: eventDb, eventDb: eventDb,
eventStore: eventStore, eventStore: eventStore,
featureDb: featureDb, featureDb: featureDb,
strategyDb: strategyDb strategyDb: strategyDb,
publicFolder: options.publicFolder
}; };
var app = require('./app')(config); var app = require('./app')(config);

View File

@ -0,0 +1,6 @@
{
"extends": [
"finn",
"finn/node"
]
}

View File

@ -0,0 +1 @@
# TODO

View File

@ -0,0 +1,6 @@
# unleash-docker
```bash
$ docker-compose build
$ docker-compose up
```

View File

@ -6,7 +6,8 @@
"scripts": { "scripts": {
"start": "NODE_ENV=production node index.js", "start": "NODE_ENV=production node index.js",
"migrate-and-start": "npm run db-migrate && npm run start", "migrate-and-start": "npm run db-migrate && npm run start",
"db-migrate": "db-migrate up" "db-migrate": "db-migrate up",
"test:ci": "echo 'no tests for unleash-docker';"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",

View File

@ -0,0 +1,6 @@
'use strict';
const path = require('path');
module.exports = {
publicFolder: path.join(__dirname, '..', 'public')
};

View File

@ -0,0 +1,16 @@
'use strict';
const server = require('unleash-server');
const unleash = server.start({});
const app = unleash.app;
const config = unleash.config;
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackConfig = require('./webpack.config');
const compiler = webpack(webpackConfig);
app.use(config.baseUriPath, webpackDevMiddleware(compiler, {
publicPath: '/js',
noInfo: true
}));

View File

@ -0,0 +1,74 @@
{
"name": "unleash-frontend",
"description": "unleash your features",
"version": "1.0.0-alpha.1",
"keywords": [
"unleash",
"feature toggle",
"feature",
"toggle"
],
"files": [
"public",
"README.md",
"LICENSE"
],
"repository": {
"type": "git",
"url": "ssh://git@github.com:finn-no/unleash.git"
},
"bugs": {
"url": "https://github.com/finn-no/unleash/issues"
},
"engines": {
"node": "6"
},
"scripts": {
"build": "webpack -p",
"start": "NODE_ENV=development supervisor --ignore ./node_modules/,./public/js lib/server-dev.js",
"test": "jest",
"test:ci": "npm run test"
},
"main": "./lib/index.js",
"dependencies": {
"jsx-loader": "0.12.2",
"lodash": "^3.5.0",
"moment": "^2.13.0",
"react": "^0.13.1",
"react-router": "^0.13.2",
"reflux": "^0.2.10",
"reqwest": "^2.0.5",
"webpack": "^1.13.0",
"webpack-dev-middleware": "^1.6.1"
},
"devDependencies": {
"chai": "3.5.0",
"coveralls": "^2.11.9",
"istanbul": "^0.4.3",
"jest-cli": "0.5.8",
"mocha": "^2.4.5",
"mocha-lcov-reporter": "1.2.0",
"nsp": "^2.3.2",
"react-tools": "^0.13.1",
"supertest": "^1.2.0",
"supervisor": "^0.10.0",
"unleash-api": "1.0.0-alpha.1"
},
"jest": {
"scriptPreprocessor": "<rootDir>/jest-preprocessor.js",
"modulePathIgnorePatterns": [
"<rootDir>/node_modules/npm"
],
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/react",
"<rootDir>/node_modules/reflux"
],
"moduleFileExtensions": [
"jsx",
"js"
]
},
"pre-commit": [
"lint"
]
}

View File

@ -0,0 +1,6 @@
{
"extends": [
"finn",
"finn/react"
]
}

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More