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

Commit

Permalink
make it fail on publish error and add required modules for verdaccio (#…
Browse files Browse the repository at this point in the history
…3552)

Signed-off-by: Nick Lincoln <[email protected]>
  • Loading branch information
nklincoln authored and Simon Stone committed Mar 13, 2018
1 parent 28f1b14 commit fa78928
Show file tree
Hide file tree
Showing 52 changed files with 793 additions and 283 deletions.
2 changes: 1 addition & 1 deletion packages/composer-playground/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage
dist
node_modules
e2e/data/files
e2e/data
3 changes: 3 additions & 0 deletions packages/composer-playground/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ npm-debug.log

# Usabilla code template
usabilla.html.template

#pm2 files
*.pm2
2 changes: 1 addition & 1 deletion packages/composer-playground/e2e/component/add-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ExpectedConditions } from 'protractor';

import { OperationsHelper } from '../utils/operations-helper';
import { dragDropFile } from '../utils/fileUtils';
import { Constants } from '../utils/constants';
import { Constants } from '../constants';

export class AddFile {

Expand Down
2 changes: 1 addition & 1 deletion packages/composer-playground/e2e/component/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { Constants } from '../utils/constants';
import { Constants } from '../constants';

export class BusyAlert {

Expand Down
9 changes: 3 additions & 6 deletions packages/composer-playground/e2e/component/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ExpectedConditions } from 'protractor';

import { OperationsHelper } from '../utils/operations-helper';
import { dragDropFile } from '../utils/fileUtils';
import { Constants } from '../utils/constants';
import { Constants } from '../constants';

let baseTiles = ['basic-sample-network', 'empty-business-network', 'drag-drop'];

Expand All @@ -33,10 +33,7 @@ export class Deploy {

// Wait for disappear
static waitToDisappear(fabric?) {
let wait = Constants.shortWait;
if (fabric) {
wait = null;
}
let wait = fabric ? Constants.vlongwait : Constants.shortWait;
return browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.choose-network'))), wait);
}

Expand Down Expand Up @@ -86,7 +83,7 @@ export class Deploy {
})
.then(() => {
return userSecret.sendKeys(secret);
})
});
};

static retrieveBaseTileOptions() {
Expand Down
2 changes: 1 addition & 1 deletion packages/composer-playground/e2e/component/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { OperationsHelper } from '../utils/operations-helper';
import { Constants } from '../utils/constants';
import { Constants } from '../constants';
import { EditorFile } from './editor-file';

let scrollMe = (target) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/composer-playground/e2e/component/error-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ExpectedConditions } from 'protractor';

import { OperationsHelper } from '../utils/operations-helper';
import { dragDropFile } from '../utils/fileUtils';
import { Constants } from '../utils/constants';
import { Constants } from '../constants';

export class ErrorAlert {

Expand Down
2 changes: 1 addition & 1 deletion packages/composer-playground/e2e/component/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { dragDropFile } from '../utils/fileUtils';
import { OperationsHelper } from '../utils/operations-helper';
import { Constants } from '../utils/constants';
import { Constants } from '../constants';

// Initialise known tile orderings
let baseTiles = ['basic-sample-network', 'empty-business-network', 'drag-drop'];
Expand Down
4 changes: 2 additions & 2 deletions packages/composer-playground/e2e/component/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { browser, element, by, ElementFinder, WebElement } from 'protractor';
import { dragDropFile } from '../utils/fileUtils';
import { ExpectedConditions } from 'protractor';

import { Constants } from '../utils/constants';
import { Constants } from '../constants';
import { OperationsHelper } from '../utils/operations-helper';
import { BusyAlert } from './alert';
import * as fs from 'fs';
Expand Down Expand Up @@ -48,7 +48,7 @@ export class Login {
});
}

// Connect to Playground via named ID Card under named connectino profile
// Connect to Playground via named ID Card under named connection profile
static connectViaIdCard(profile: string, networkName: string) {
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.connection-profile'))), Constants.longWait)
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/composer-playground/e2e/component/replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { OperationsHelper } from '../utils/operations-helper';
import { Constants } from '../utils/constants';
import { Constants } from '../constants';

export class Replace {

Expand Down
2 changes: 1 addition & 1 deletion packages/composer-playground/e2e/component/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { OperationsHelper } from '../utils/operations-helper';
import { Constants } from '../utils/constants';
import { Constants } from '../constants';

let scrollMe = (target) => {
target.scrollIntoView(true);
Expand Down
40 changes: 40 additions & 0 deletions packages/composer-playground/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.
*/

import path = require('path');

export class Constants {

static readonly shortWait = 5000;

static readonly longWait = 10000;

static readonly mlongwait = 30000;

static readonly vlongwait = 240000;

static readonly webPlaygroundPort = 3001;
static readonly fabricPlaygroundPort = 3002;

static readonly sampleNetworks = ['basic-sample-network', 'import-network'];

static readonly downloadLocation = path.join(__dirname, 'downloads');
static readonly sampleNetworkDir = path.join(__dirname, 'data/sample-networks');
static readonly tempDir = path.join(__dirname, 'tmp');
static readonly scriptsDir = path.join(__dirname, 'scripts');

static readonly fabricBaseDir = path.join(__dirname, 'fabric');
static readonly fabricConfigDir = path.join(Constants.fabricBaseDir, 'hlfv1');
static readonly peerAdminCardName = 'TestPeerAdmin.card';
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Welcome to Hyperledger Composer!

This is the "Hello World" of Hyperledger Composer samples.

This sample defines a business network composed of a single asset type (`SampleAsset`), a single participant type (`SampleParticipant`), a single transaction type (`SampleTransaction`), and a single event type (`SampleEvent`).

`SampleAssets` are owned by a `SampleParticipant`, and the value property on a `SampleAsset` can be modified by submitting a `SampleTransaction`. The `SampleTransaction` emits a `SampleEvent` that notifies applications of the old and new values for each modified `SampleAsset`.

To get started inside Hyperledger Composer you can click the Test tab and create instances of `SampleAsset` and `SampleParticipant`. Make sure that the owner property on the `SampleAsset` refers to a `SampleParticipant` that you have created.

You can then submit a `SampleTransaction`, making sure that the asset property refers to an asset that you created earlier. After the transaction has been processed you should see that the value property on the asset has been modified, and that a `SampleEvent` has been emitted.

The logic for updating the asset when a `SampleTransaction` is processed is written in `sample.js`.

Don't forget that you can import more advanced samples into Hyperledger Composer using the Import/Replace button.

Have fun learning Hyperledger Composer!
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.
*/

/**
* Sample transaction processor function.
* @param {org.acme.sample.SampleTransaction} tx The sample transaction instance.
* @transaction
*/
function sampleTransaction(tx) {

// Save the old value of the asset.
var oldValue = tx.asset.value;

// Update the asset with the new value.
tx.asset.value = tx.newValue;

// Get the asset registry for the asset.
return getAssetRegistry('org.acme.sample.SampleAsset')
.then(function (assetRegistry) {

// Update the asset in the asset registry.
return assetRegistry.update(tx.asset);

})
.then(function () {

// Emit an event for the modified asset.
var event = getFactory().newEvent('org.acme.sample', 'SampleEvent');
event.asset = tx.asset;
event.oldValue = oldValue;
event.newValue = tx.newValue;
emit(event);

});

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Sample business network definition.
*/
namespace org.acme.sample

asset SampleAsset identified by assetId {
o String assetId
--> SampleParticipant owner
o String value
}

asset SampleComplexAsset identified by assetId {
o String assetId
o Boolean booleanField
o DateTime dateTimeField
o Double doubleField
o Integer integerField
o Long longField
o String[] arrayField optional
}

participant SampleParticipant identified by participantId {
o String participantId
o String firstName
o String lastName
}

transaction SampleTransaction {
--> SampleAsset asset
o String newValue
}

event SampleEvent {
o String oldValue
o String newValue
--> SampleAsset asset
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"basic-sample-network","version":"0.1.0","description":"The Hello World of Hyperledger Composer samples","scripts":{"prepublish":"mkdirp ./dist && composer archive create --sourceType dir --sourceName . -a ./dist/basic-sample-network.bna","pretest":"npm run lint","lint":"eslint .","postlint":"npm run licchk","licchk":"license-check","postlicchk":"npm run doc","doc":"jsdoc --pedantic --recurse -c jsdoc.conf","test-inner":"mocha --recursive && cucumber-js","test-cover":"nyc npm run test-inner","test":"npm run test-inner"},"repository":{"type":"git","url":"https://github.com/hyperledger/composer-sample-networks.git"},"keywords":["sample","network"],"author":"Hyperledger Composer","license":"Apache-2.0","devDependencies":{"browserfs":"^1.2.0","chai":"^3.5.0","chai-as-promised":"^6.0.0","composer-admin":"latest","composer-cli":"latest","composer-client":"latest","composer-connector-embedded":"latest","composer-cucumber-steps":"latest","cucumber":"^2.2.0","eslint":"^3.6.1","istanbul":"^0.4.5","jsdoc":"^3.4.1","license-check":"^1.1.5","mkdirp":"^0.5.1","mocha":"^3.2.0","moment":"^2.17.1","nyc":"^11.0.2"},"license-check-config":{"src":["**/*.js","!./coverage/**/*","!./node_modules/**/*","!./out/**/*","!./scripts/**/*"],"path":"header.txt","blocking":true,"logInfo":false,"logError":true},"nyc":{"exclude":["coverage/**","features/**","out/**","test/**"],"reporter":["text-summary","html"],"all":true,"check-coverage":true,"statements":100,"branches":100,"functions":100,"lines":100}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Sample access control list.
*/
rule AllAccess {
description: "AllAccess - grant everything to everybody"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}

rule EverybodyCanReadEverything {
description: "Allow all participants read access to all resources"
participant: "org.acme.sample.SampleParticipant"
operation: READ
resource: "org.acme.sample.*"
action: ALLOW
}

rule EverybodyCanSubmitTransactions {
description: "Allow all participants to submit transactions"
participant: "org.acme.sample.SampleParticipant"
operation: CREATE
resource: "org.acme.sample.SampleTransaction"
action: ALLOW
}

rule OwnerHasFullAccessToTheirAssets {
description: "Allow all participants full access to their assets"
participant(p): "org.acme.sample.SampleParticipant"
operation: ALL
resource(r): "org.acme.sample.SampleAsset"
condition: (r.owner.getIdentifier() === p.getIdentifier())
action: ALLOW
}

rule NetworkAdminUser {
description: "Grant business network administrators full access to user resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "**"
action: ALLOW
}

rule NetworkAdminSystem {
description: "Grant business network administrators full access to system resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Welcome to Hyperledger Composer!

This is the "Hello World" of Hyperledger Composer samples.

This sample defines a business network composed of a single asset type (`SampleAsset`), a single participant type (`SampleParticipant`), a single transaction type (`SampleTransaction`), and a single event type (`SampleEvent`).

`SampleAssets` are owned by a `SampleParticipant`, and the value property on a `SampleAsset` can be modified by submitting a `SampleTransaction`. The `SampleTransaction` emits a `SampleEvent` that notifies applications of the old and new values for each modified `SampleAsset`.

To get started inside Hyperledger Composer you can click the Test tab and create instances of `SampleAsset` and `SampleParticipant`. Make sure that the owner property on the `SampleAsset` refers to a `SampleParticipant` that you have created.

You can then submit a `SampleTransaction`, making sure that the asset property refers to an asset that you created earlier. After the transaction has been processed you should see that the value property on the asset has been modified, and that a `SampleEvent` has been emitted.

The logic for updating the asset when a `SampleTransaction` is processed is written in `sample.js`.

Don't forget that you can import more advanced samples into Hyperledger Composer using the Import/Replace button.

Have fun learning Hyperledger Composer!
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.
*/

/**
* Sample transaction processor function.
* @param {org.acme.sample.SampleTransaction} tx The sample transaction instance.
* @transaction
*/
function sampleTransaction(tx) {

// Save the old value of the asset.
var oldValue = tx.asset.value;

// Update the asset with the new value.
tx.asset.value = tx.newValue;

// Get the asset registry for the asset.
return getAssetRegistry('org.acme.sample.SampleAsset')
.then(function (assetRegistry) {

// Update the asset in the asset registry.
return assetRegistry.update(tx.asset);

})
.then(function () {

// Emit an event for the modified asset.
var event = getFactory().newEvent('org.acme.sample', 'SampleEvent');
event.asset = tx.asset;
event.oldValue = oldValue;
event.newValue = tx.newValue;
emit(event);

});

}
Loading

0 comments on commit fa78928

Please sign in to comment.