Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #64 from reTHINK-project/develop
Browse files Browse the repository at this point in the history
merging for release
  • Loading branch information
pchainho authored Nov 8, 2017
2 parents 50a77f4 + 1268c74 commit 144cd2a
Show file tree
Hide file tree
Showing 185 changed files with 1,868 additions and 13,375 deletions.
120 changes: 120 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
plugins:
- import

extends:
- eslint:recommended
- plugin:import/errors
- plugin:import/warnings

env:
browser: true
commonjs: true
es6: true
node: true
mocha: true
jquery: true

parserOptions:
ecmaVersion: 6
ecmaFeatures:
modules: true
classes: true
sourceType: module

rules:
no-const-assign: warn
no-this-before-super: warn
no-undef: warn
no-unreachable: warn
no-unused-vars: warn
constructor-super: warn
valid-typeof: warn
quotes:
- error
- single
semi:
- warn
- always
consistent-this:
- warn
- _this
space-before-function-paren:
- error
- never
block-spacing: error
brace-style:
- error
- 1tbs
- allowSingleLine: true
no-console: off
no-empty:
- warn
- allowEmptyCatch: true
no-spaced-func: 2
array-bracket-spacing:
- warn
- never
- {}
space-in-parens:
- warn
- never
quote-props:
- warn
- as-needed
key-spacing:
- error
- beforeColon: false
afterColon: true
space-unary-ops:
- error
- words: false
nonwords: false
no-mixed-spaces-and-tabs: error
no-trailing-spaces: error
comma-dangle:
- warn
- never
yoda:
- warn
- never
no-with: error
no-multiple-empty-lines: error
no-multi-str: off
one-var:
- error
- never
comma-spacing:
- error
- before: false
after: true
semi-spacing:
- error
- before: false
after: true
space-before-blocks:
- error
- always
wrap-iife: error
comma-style:
- error
- last
space-infix-ops: error
camelcase:
- error
- properties: never
eol-last: error
dot-notation: error
curly:
- error
- multi-line
keyword-spacing:
- error
- {}
lines-around-comment:
- error
- beforeLineComment: true
allowBlockStart: true
indent:
- error
- 2
- SwitchCase: 1
103 changes: 102 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,108 @@ function hypertyDeployed(hyperty) {
```
**NOTE:** This probably needs to be optimized, suggestion are welcome;

#### **examples** folder
## Install all modules inside each hyperty source code

```shell
# This will execute npm install for each package.json inside each hyperty source code;
npm run install:all
```

## The Repository structure

This repository hosts source code of Hyperties. For more information about Hyperties and reTHINK framework pls read [this](https://github.com/reTHINK-project/dev-hyperty-toolkit/blob/master/README.md).

### **SRC** folder

Hold all Hyperty related source code, like hyperty classes and JSON-Schemas. The hyperty class must have the suffix ".hy.js", on the file.

Each hyperty folder could have it's own `package.json`

```shell
# To create the pacakge.json
npm init
```

To use the all modules from [**Service Framework**](https://github.com/reTHINK-project/dev-service-framework/), like, *Syncher* or *Discovery* do:
```shell
# install dependencies
npm install rethink-project/dev-service-framework#develop --save
```

**Example:** Hello.hy.js

**Why?**
Because all the files in folder, could be a possible hyperty, with this suffix, we can distinguish the main hyperty from others files that complement it;


#### Hyperty Source Code

```javascript

// Service Framework
import IdentityManager from 'service-framework/dist/IdentityManager';
import {Discovery} from 'service-framework/dist/Discovery';
import { Syncher } from 'service-framework/dist/Syncher';

/**
*
*/
class MyHyperty {

constructor(hypertyURL, bus, configuration) {

if (!hypertyURL) throw new Error('The hypertyURL is a needed parameter');
if (!bus) throw new Error('The MiniBus is a needed parameter');
if (!configuration) throw new Error('The configuration is a needed parameter');

let syncher = new Syncher(hypertyURL, bus, configuration);

}

myMethod() {
console.log('hello');
}

}

/**
* Function will activate the hyperty on the runtime
* @param {URL.URL} hypertyURL url which identifies the hyperty
* @param {MiniBus} bus Minibus used to make the communication between hyperty and runtime;
* @param {object} configuration configuration
*/
export default function activate(hypertyURL, bus, configuration) {

return {
name: 'MyHyperty',
instance: new MyHyperty(hypertyURL, bus, configuration)
};

}
```

#### Hyperty Descriptor

```json
{
"language": "javascript",
"signature": "",
"configuration": {},
"hypertyType": [
"chat"
],
"constraints": {
"browser": true
},
"dataObjects": [
"https://catalogue.%domain%/.well-known/dataschema/Communication"
],
"objectName": "HypertyName"
}
```


### **EXAMPLES** folder

In this folder you have, for each hyperty you develop, the Web side testing.
This is customized with HTML using [Handlebars](http://handlebarsjs.com/) and ES5 javascript;
Expand Down
52 changes: 52 additions & 0 deletions bin/preinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
var fs = require('fs')
var path = require('path');
var resolve = require('path').resolve;
var join = require('path').join;
var cp = require('child_process');

// get library path
var lib = resolve(__dirname, '../src/')

// https://gist.github.com/kethinov/6658166
// List all files in a directory in Node.js recursively in a synchronous fashion
const read = (dir, filename) =>
fs.readdirSync(dir)
.reduce((files, file) => {
var fsPath = fs.statSync(path.join(dir, file));
var fileObject = path.parse(path.join(dir, file));
return fsPath.isDirectory() && !fileObject.dir.includes('node_modules') ?
files.concat(read(path.join(dir, file), filename)) :
file === filename ? files.concat(dir) : files
},
[]);

var list = read(lib, 'package.json');

var current = 0;
var limit = list.length;

function queue(list) {
const mod = list[current];
fs.accessSync(join(mod, 'package.json'));

const fileObject = path.parse(join(mod, 'package.json'));

console.log('------------------------------------------------------------------------------');
console.log(fileObject.dir );

// install folder
const sp = cp.spawn('npm', ['i'], { env: process.env, cwd: mod, stdio: 'inherit', shell: true});

sp.on('exit', () => {
current++;
console.log(current, limit);
if (current < limit) {
queue(list);
console.log('------------------------------------------------------------------------------');
} else {
console.log('All done!');
}
})
}

queue(list);
52 changes: 52 additions & 0 deletions bin/update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
var fs = require('fs')
var path = require('path');
var resolve = require('path').resolve;
var join = require('path').join;
var cp = require('child_process');

// get library path
var lib = resolve(__dirname, '../src/')

// https://gist.github.com/kethinov/6658166
// List all files in a directory in Node.js recursively in a synchronous fashion
const read = (dir, filename) =>
fs.readdirSync(dir)
.reduce((files, file) => {
var fsPath = fs.statSync(path.join(dir, file));
var fileObject = path.parse(path.join(dir, file));
return fsPath.isDirectory() && !fileObject.dir.includes('node_modules') ?
files.concat(read(path.join(dir, file), filename)) :
file === filename ? files.concat(dir) : files
},
[]);

var list = read(lib, 'package.json');

var current = 0;
var limit = list.length;

function queue(list) {
const mod = list[current];
fs.accessSync(join(mod, 'package.json'));

const fileObject = path.parse(join(mod, 'package.json'));

console.log('------------------------------------------------------------------------------');
console.log(fileObject.dir );

// install folder
const sp = cp.spawn('npm', ['update'], { env: process.env, cwd: mod, stdio: 'inherit', shell: true});

sp.on('exit', () => {
current++;
console.log(current, limit);
if (current < limit) {
queue(list);
console.log('------------------------------------------------------------------------------');
} else {
console.log('All done!');
}
})
}

queue(list);
Loading

0 comments on commit 144cd2a

Please sign in to comment.