Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dselman committed Feb 3, 2017
2 parents f1e7b5b + c514c08 commit bf3c99b
Show file tree
Hide file tree
Showing 62 changed files with 10,638 additions and 959 deletions.
13 changes: 10 additions & 3 deletions .travis/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ else

fi


# Set the GitHub deploy key we will use to publish.
set-up-ssh --key "$encrypted_f19708b15817_key" \
--iv "$encrypted_f19708b15817_iv" \
--path-encrypted-key " ${DIR}/.travis/github_deploy_docs_key.enc"

# push the html documents
# Configure the Git repository and clean any untracked and unignored build files.
git config user.name "Travis CI"
Expand All @@ -86,12 +92,13 @@ git config push.default simple

echo ${DIR}
cd ${DIR}/site/out
rm -rf gh-pages

export REPO="staging-fabric-composer-web"
export REPO="fabric-composer.github.io"

git clone [email protected]:fabric-composer/${REPO}.git
cd ${REPO}
git remote set-url origin ${REPO}.git

cd ${DIR}/site/out${REPO}

rm -rf ${DIR}/site/out/${REPO}/*
cp -rf ${DIR}/site/out/jekylldocs/_site/* .
Expand Down
Binary file added .travis/github_deploy_docs_key.enc
Binary file not shown.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# Fabric Composer
Fabric Composer is a blockchain Solution Framework for Hyperledger Fabric: a library of assets/functions for quickly creating blockchain-based applications.

You must run the following commands in order to pull the chaincode dependencies down from
their repositories:
Fabric Composer is an application development framework which simplifies and expedites the creation of [Hyperledger fabric](https://hyperledger-fabric.readthedocs.io/en/latest/) blockchain applications. If you're new to Blockchain, Hyperledger fabric or Fabric Composer, we recommend that you start at the [Fabric composer website](https://fabric-composer.github.io). This site will help you get up and running by developing a sample blockchain application to buy and sell houses and apartments in a digital property business network.

# Using this repository

Clone this repository.

You must run the following commands in order to pull the Hyperledger fabric chaincode dependencies from their repositories:

$ git submodule init
$ git submodule update

You should see messages indicating that the required git repositories have been cloned into the correct
vendor subdirectory.
You should see messages indicating that the required git repositories have been cloned into the correct vendor subdirectory.

You must install [Lerna](https://lernajs.io) to build this multi-package repository.
You must install [Lerna](https://lernajs.io) to build this multi-package repository:

$ npm install -g lerna

Once Lerna is installed, and this repository is cloned, then you must bootstrap the
repository so that all of the dependencies are installed and all of the packages are
linked together:
You must bootstrap the repository so that all of the dependencies are installed and all of the packages are linked together:

$ lerna bootstrap

Expand All @@ -27,3 +28,5 @@ Alternatively, you can execute npm commands across all of the packages at once u
Lerna:

$ lerna run test

You're now ready to start with the Fabric Composer project.
87 changes: 14 additions & 73 deletions contrib-notes/atom-setup.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,27 @@
# Using Atom for Concerto development
(Atom)[https://atom.io/] is the favoured development environment by many (possibly all) of the contributors on Concerto and related projects. Atom is at it's most productive would used with a number of plugins. The ones that we have found to be most useful are below and would suggest that you install these when with developing Concerto itself or applications using the Concerto API.
# Using Atom for Fabric Composer development

Quik
[Atom](https://atom.io/) is the preferred code editor for contributors the fabric composer project. Many developers find Atom especially productive due to the wide range of plugins availability to assist with code development activities. These include syntax highlighting for node.js code, JavaScript and the Composer modelling language, or *linting* to help eliminate potential bugs and ensure a consistent coding style. Developers can also develop their own plugins. Here's a list of Atom plugins for you consider as you develop within the fabric composer project.

## Code editing
## Javascipt and node.js linting

### Concerto File Highlighting
The very first plugin you should install is a syntax highlighter for the Concerto model files. If you only install one thing, make it this one.
Use the [linter-eslint plugin](https://atom.io/packages/linter-eslint) to help with linting node.js and JavaScript code. For an example of the eslinter config file see [here](../packages/composer-admin/.eslintrc.yml).

[https://github.ibm.com/Blockchain-WW-Labs/Concerto-Atom]
## Composer modelling language

### esLint
JavaScript dosn't come with a compiler that can pick up silly mistakes, but a linter is an essential tool to help. The one we have used is eslint.
Use the [composer-atom plugin](https://github.com/fabric-composer/tools) for syntax highlighting of the composer modelling language. It is located in the *packages/composer-atom* directory of the [tools repository](https://github.com/fabric-composer/tools) in the fabric composer project. Follow the instructions in the README to install the plugin.

[https://atom.io/packages/linter-eslint]
## Find unfinished work items

This is the config file that we have used with eslint
```
env:
es6: true
node: true
mocha: true
extends: 'eslint:recommended'
parserOptions:
sourceType:
- script
rules:
indent:
- error
- 4
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
no-unused-vars:
- error
- args: none
no-console: off
curly: error
eqeqeq: error
no-throw-literal: error
strict: error
no-var: error
dot-notation: error
no-tabs: error
no-trailing-spaces: error
# no-use-before-define: error
no-useless-call: error
no-with: error
operator-linebreak: error
require-jsdoc:
- error
- require:
ClassDeclaration: true
MethodDefinition: true
FunctionDeclaration: true
valid-jsdoc:
- error
- requireReturn: false
yoda: error
```
Use the [todo-show](https://atom.io/packages/todo-show) plugin to find indicators that code might not be complete by finding instances of indicative text, such as *TODO*, *FUTURE*, *BUG* etc.

### TODO-Show
This can show easily all the TODO: FUTURE: etc that in the codebase
[https://atom.io/packages/todo-show]
## Match selected keywords

### Highlight selected
Click on a keyword or variable and this will show up the matching instances in the file.
[https://atom.io/packages/highlight-selected]
Use the [highlight-selected plugin](https://atom.io/packages/highlight-selected) to find all matches of a keyword in the current file.

### DocBlockr
Helps to create skeltion doc comments for Functions
[https://atom.io/packages/docblockr]
## Documentation assistance

## General
Use the [docblockr plugin](https://atom.io/packages/docblockr) to create pretty comments, function prototypes and other helpful code decorations.

### FileIcons
Useful UI enhancement to show different icons for different file Types
## File type visualization

[https://atom.io/packages/file-icons]
Use the [file-icons plugin](https://atom.io/packages/file-icons) to assign visual representations to file extension to help locate files of a given type.
2 changes: 1 addition & 1 deletion packages/generator-composer/generators/angular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module.exports = yeoman.Base.extend({
type: 'input',
name: 'connectionProfileName',
message: 'What is the Connection Profile to use?',
default: 'hyperledger',
default: 'newProfile',
store: false,
validate: function(input) {
if(input !== null && input !== undefined && input !== '') {
Expand Down
31 changes: 20 additions & 11 deletions packages/generator-composer/generators/angular/templates/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* IBM Confidential
* OCO Source Materials
* IBM Mozart - 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.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';
Expand All @@ -14,10 +18,15 @@
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const config = require('config').get('<%= appName %>');

//const username = require('username');
let connectionProfileName = config.get('connectionProfileName');
let networkIdentifier = config.get('networkIdentifier');
let enrollmentId = config.get('enrollmentId');
let enrollmentSecret = config.get('enrollmentSecret');

const createConcertoRouter = require('./router');

const createcomposerRouter = require('./router');

// configure Express
const app = express();
Expand All @@ -37,11 +46,11 @@ app.use(express.static(path.join(__dirname, 'src')));
app.use('/node_modules', express.static(__dirname + '/node_modules'));


const BusinessNetworkConnection = require('@ibm/concerto-client').BusinessNetworkConnection;
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
let businessNetworkConnection = new BusinessNetworkConnection();

try{
return createConcertoRouter('<%= connectionProfileName %>', '<%= networkIdentifier %>', '<%= enrollmentId %>', '<%= enrollmentSecret %>')
return createcomposerRouter(connectionProfileName, networkIdentifier, enrollmentId, enrollmentSecret)
.then((router) => {
// attach the Router to Express
app.use('/api/v1/', router );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{

"<%= appName %>" : {
"connectionProfileName":"<%= connectionProfileName %>",
"networkIdentifier":"<%= networkIdentifier %>",
"enrollmentId":"<%= enrollmentId %>",
"enrollmentSecret":"<%= enrollmentSecret %>"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"postinstall": "typings install",
"ng": "ng",
"app": "node app.js",
"start": "concurrently \"ng serve\" \"node app.js\" \"sleep 5 && opener http://localhost:8080\"",
"start": "concurrently \"ng serve\" \"node app.js\" \"sleep 5 && opener http://localhost:4200\"",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
Expand All @@ -27,6 +27,7 @@
"bootstrap": "^3.3.7",
"bower": "^1.8.0",
"concurrently": "^3.1.0",
"config": "^1.21.0",
"core-js": "^2.4.1",
"jquery": "^3.1.1",
"opener": "^1.4.2",
Expand Down
60 changes: 25 additions & 35 deletions packages/generator-composer/generators/angular/templates/router.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
/*
* IBM Confidential
* OCO Source Materials
* IBM Concerto Express Router - 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.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/




/*
This file came from the old Concerto-Express-Router.
Quite a lot of code which needs to either be removed or edited to work with the newest version of Concerto.
Going to edit this and remove code when needed as the Strongloop connector will be replacing this.
*/



'use strict';

const express = require('express');
const BusinessNetworkConnection = require('@ibm/concerto-client').BusinessNetworkConnection;
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
/**
* Returns an Express Router for the Concerto assets and transactions
* Returns an Express Router for the composer assets and transactions
*
* @param {Concerto} concerto - the Concerto instance
* @param {SecurityContext} securityContext - the Security Context to access Concerto methods
* @param {composer} composer - the composer instance
* @param {SecurityContext} securityContext - the Security Context to access composer methods
* @param {Object} options - the options
* @return {Promise} a Promise to the Express Router
* @public
Expand Down Expand Up @@ -107,11 +97,11 @@ function createRouter(profile,network,user,pass) {
}

/**
* Creates the Express App routes for an Asset or Participant Concerto type
* Creates the Express App routes for an Asset or Participant composer type
* @param {Router} router - the Express router
* @param {Concerto} concerto - the Concerto instance
* @param {SecurityContext} securityContext - the Security Context to access Concerto methods
* @param {ClassDeclaration} classDeclaration - the Concerto type
* @param {composer} composer - the composer instance
* @param {SecurityContext} securityContext - the Security Context to access composer methods
* @param {ClassDeclaration} classDeclaration - the composer type
* @param {Object} options - the options
* @return {Promise} a promise to the asset registry
*/
Expand Down Expand Up @@ -184,8 +174,8 @@ function createAssetRoutes(router, businessNetworkConnection, businessNetworkDef
/**
* Creates the Express App route for querying and submitting transactions
* @param {Router} router - the Express router
* @param {Concerto} concerto - the Concerto instance
* @param {SecurityContext} securityContext - the Security Context to access Concerto methods
* @param {composer} composer - the composer instance
* @param {SecurityContext} securityContext - the Security Context to access composer methods
* @param {Object} options - the options
* @return {Promise} a Promise to the transaction registry lookup
*/
Expand Down Expand Up @@ -255,14 +245,14 @@ function createTransactionRoutes(router, businessNetworkConnection, businessNetw
/**
* Creates the Express App route for refreshing the model manager
* @param {Router} router - the Express router
* @param {Concerto} concerto - the Concerto instance
* @param {SecurityContext} securityContext - the Security Context to access Concerto methods
* @param {composer} composer - the composer instance
* @param {SecurityContext} securityContext - the Security Context to access composer methods
* @param {Object} options - the options
*/
function createModelManagerRoute(router, businessNetworkDefinition) {
console.log('Registering model manager route.');
router.get('/modelmanager/loadModels', (req, res, next) => {
concerto.loadModels(securityContext).then(() => {
composer.loadModels(securityContext).then(() => {
res.type('application/json');
res.send('{"status" : "ok"}');
})
Expand Down Expand Up @@ -303,7 +293,7 @@ function getFunctionName(req) {

/**
* Returns a JS Object suitable for transmission on the wire
* @param {Serializer} serializer Concerto Serializer to use for Resources
* @param {Serializer} serializer composer Serializer to use for Resources
* @param {string} functionName the registry function that was called to get the obj
* @param {Object} obj - the object returned by calling functionName on the registry
* @return {Object} a JS Object that can be serialized to JSON for return to the caller
Expand Down
Loading

0 comments on commit bf3c99b

Please sign in to comment.