Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from SSTONE1/master
Browse files Browse the repository at this point in the history
Add initial Lerna and Travis files
  • Loading branch information
Simon Stone authored and GitHub Enterprise committed Jan 5, 2017
2 parents 017c5f8 + 133a6db commit de0e223
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: node_js
node_js:
- '4'
- '6'
dist: trusty
before_install: |
set -ev
npm install -g npm
npm config set @ibm:registry https://npm-registry.whitewater.ibm.com
npm config set //npm-registry.whitewater.ibm.com/:_authToken ${NPM_TOKEN}
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
install: |
set -ev
npm install 2>&1 | tee
script: |
set -ev
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
npm test 2>&1 | tee
deploy:
provider: script
script: npm run deploy 2>&1 | tee
skip_cleanup: true
on:
all_branches: true
7 changes: 7 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lerna": "2.0.0-beta.32",
"packages": [
"packages/@ibm/*"
],
"version": "independent"
}
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"devDependencies": {
"lerna": "2.0.0-beta.32",
"moment": "^2.17.1"
},
"name": "@ibm/concerto",
"description": "You must install [Lerna](https://lernajs.io) to build this multi-package repository.",
"version": "0.2.0",
"main": "index.js",
"scripts": {
"postinstall": "npm run bootstrap",
"bootstrap": "lerna bootstrap",
"test": "lerna run test",
"deploy": "./scripts/deploy.sh"
},
"repository": {
"type": "git",
"url": "[email protected]:Blockchain-WW-Labs/Concerto.git"
},
"keywords": [
"blockchain",
"hyperledger",
"solutions"
],
"author": "IBM",
"license": "ISC"
}
39 changes: 39 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Exit on first error, print all commands.
set -ev

# Grab the Concerto directory.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"

# Check that this is the right node.js version.
if [ "${TRAVIS_NODE_VERSION}" != "" -a "${TRAVIS_NODE_VERSION}" != "4" ]; then
echo Not executing as not running primary node.js version.
exit 0
fi

# Check that this is the main repository.
if [[ "${TRAVIS_REPO_SLUG}" != Blockchain-WW-Labs* ]]; then
echo "Skipping deploy; wrong repository slug."
exit 0
fi

# If this is not for a tagged (release) build, set the prerelease version.
if [ -z "${TRAVIS_TAG}" ]; then
lerna exec -- ${DIR}/scripts/timestamp.js package.json
fi

# Push the code to npm.
if [ "${TRAVIS_BRANCH}" = "develop" ]; then

# Publish with unstable tag. These are development builds.
echo "Pushing with tag unstable"
lerna exec -- npm publish --scope=@ibm --tag=unstable

else

# Publish with latest tag (default). These are release builds.
echo "Pushing with tag develop"
lerna exec -- npm publish --scope=@ibm

fi
32 changes: 32 additions & 0 deletions scripts/timestamp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node
/*
* IBM Confidential
* OCO Source Materials
* IBM Concerto - Blockchain Solution Framework
* Copyright IBM Corp. 2016
* The source code for this program is not published or otherwise
* divested of its trade secrets, irrespective of what has
* been deposited with the U.S. Copyright Office.
*/

'use strict';

const fs = require('fs');
const moment = require('moment');

if (process.argv.length !== 3) {
console.error('Usage: timestamp.js <package.json>');
process.exit(1);
}

let fileName = process.argv[2];
let fileContents = fs.readFileSync(fileName, 'utf8');
let file = JSON.parse(fileContents);

let timestamp = moment().format('YYYYMMDDHHmmss');

file.version = file.version.replace(/-.*/, '');
file.version += '-' + timestamp;

fileContents = JSON.stringify(file, null, 2);
fs.writeFileSync(fileName, fileContents, 'utf8');

0 comments on commit de0e223

Please sign in to comment.