Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.vscode
*.sqlite
.nyc_output
package-lock.json
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ stages:
- name: dev_deploy
if: branch = develop AND type = push
- name: package_build
if: (branch = develop AND type = cron) OR (branch = master and type = push)
if: branch = master and type = push

jobs:
include:
Expand Down Expand Up @@ -48,7 +48,5 @@ jobs:
on:
tags: false
after_deploy:
- if [ "$TRAVIS_BRANCH" == "develop" ]; then sshpass -p $PRE_PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no
$PRE_PROD_MACHINE_USERNAME@$PRE_PROD_MACHINE_IP "iofog-controller stop; npm update -g --unsafe-perm iofogcontroller; iofog-controller start";
else sshpass -p $PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no
$PROD_MACHINE_USERNAME@$PROD_MACHINE_IP "iofog-controller stop; npm update -g --unsafe-perm iofogcontroller; iofog-controller start"; fi
- sshpass -p $PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no
$PROD_MACHINE_USERNAME@$PROD_MACHINE_IP "iofog-controller stop; npm update -g --unsafe-perm iofogcontroller; iofog-controller start"
177 changes: 94 additions & 83 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,85 +1,96 @@
{
"name": "iofogcontroller",
"version": "1.0.24",
"description": "ioFog Controller project for Eclipse IoFog @ iofog.org \\nCopyright (c) 2018 Edgeworx, Inc.",
"main": "./src/main.js",
"author": "Saeid Baghbidi",
"contributors": [
"Kilton Hopkins <kilton@edgeworx.io>",
"Saeid Baghbidi",
"Pavel Kazlou",
"Egor Krylovich",
"Iryna Laryionava",
"Maryna Lipnitskaya",
"Dmitriy Kudasov",
"Dmitry Stolbunov",
"Darya Busel",
"Alexander Shpak",
"Kate Lukashick",
"Eugene Pankov",
"Maksim Chepelev",
"Tetiana Yatsiuk",
"Sergey Valevich"
],
"license": {
"type": "EPL-2.0",
"url": "https://www.eclipse.org/legal/epl-v20.html"
},
"bugs": {
"email": "edgemaster@iofog.org"
},
"homepage": "https://www.iofog.org",
"repository": {
"type": "git",
"url": "https://github.com/ioFog/Controller"
},
"scripts": {
"start": "NODE_ENV=production node ./src/main.js start",
"start-dev": "NODE_ENV=development node ./src/main.js start",
"build": "export NODE_ENV=production && cd src/sequelize && ../../node_modules/.bin/sequelize db:migrate && ../../node_modules/.bin/sequelize db:seed:all",
"preuninstall": "bash scripts/preuninstall.sh",
"postinstall": "bash scripts/postinstall.sh && NODE_ENV=production node ./src/main.js init",
"lint": "./node_modules/.bin/eslint \"**/*.js\"",
"automatic-release": "automatic-release",
"test": ""
},
"preferGlobal": true,
"bin": {
"iofog-controller": "src/main.js"
},
"dependencies": {
"body-parser": "^1.18.3",
"command-line-args": "^5.0.2",
"command-line-usage": "^5.0.5",
"continuation-local-storage": "^3.2.1",
"cookie-parser": "^1.4.3",
"daemonize2": "^0.4.2",
"ejs": "^2.6.1",
"express": "^4.16.3",
"formidable": "^1.2.1",
"fs": "^0.0.1-security",
"ftp": "^0.3.10",
"helmet": "^3.13.0",
"jsonschema": "^1.2.4",
"morgan": "^1.9.1",
"nconf": "^0.10.0",
"nodemailer": "^4.6.8",
"nodemailer-smtp-transport": "^2.7.4",
"path": "^0.12.7",
"portscanner": "^2.2.0",
"retry-as-promised": "^3.1.0",
"sequelize": "^4.39.0",
"sequelize-cli": "^4.1.1",
"sqlite3": "^4.0.2",
"string-format": "^2.0.0",
"umzug": "^2.1.0",
"underscore": "^1.9.1",
"winston": "^3.1.0",
"xss-clean": "^0.1.1",
"qs": "^6.5.2"
},
"devDependencies": {
"automatic-release": "^1.1.1",
"eslint": "^5.6.1"
}
"name": "iofogcontroller",
"version": "1.0.24",
"description": "ioFog Controller project for Eclipse IoFog @ iofog.org \\nCopyright (c) 2018 Edgeworx, Inc.",
"main": "./src/main.js",
"author": "Saeid Baghbidi",
"contributors": [
"Kilton Hopkins <kilton@edgeworx.io>",
"Saeid Baghbidi",
"Pavel Kazlou",
"Egor Krylovich",
"Iryna Laryionava",
"Maryna Lipnitskaya",
"Dmitriy Kudasov",
"Dmitry Stolbunov",
"Darya Busel",
"Alexander Shpak",
"Kate Lukashick",
"Eugene Pankov",
"Maksim Chepelev",
"Tetiana Yatsiuk",
"Sergey Valevich"
],
"license": {
"type": "EPL-2.0",
"url": "https://www.eclipse.org/legal/epl-v20.html"
},
"bugs": {
"email": "edgemaster@iofog.org"
},
"homepage": "https://www.iofog.org",
"repository": {
"type": "git",
"url": "https://github.com/ioFog/Controller"
},
"scripts": {
"start": "node scripts/start.js",
"start-dev": "node scripts/start-dev.js",
"build": "node scripts/init.js",
"preuninstall": "node scripts/preuninstall.js",
"postinstall": "node scripts/postinstall.js",
"lint": "./node_modules/.bin/eslint \"**/*.js\"",
"automatic-release": "automatic-release",
"test": "node scripts/test.js",
"coverage": "node scripts/coverage.js"
},
"preferGlobal": true,
"bin": {
"iofog-controller": "src/main.js"
},
"dependencies": {
"body-parser": "^1.18.3",
"command-line-args": "^5.0.2",
"command-line-usage": "^5.0.5",
"continuation-local-storage": "^3.2.1",
"cookie-parser": "^1.4.3",
"daemonize2": "^0.4.2",
"ejs": "^2.6.1",
"express": "^4.16.3",
"formidable": "^1.2.1",
"fs": "^0.0.1-security",
"ftp": "^0.3.10",
"helmet": "^3.13.0",
"jsonschema": "^1.2.4",
"morgan": "^1.9.1",
"nconf": "^0.10.0",
"nodemailer": "^4.6.8",
"nodemailer-smtp-transport": "^2.7.4",
"path": "^0.12.7",
"portscanner": "^2.2.0",
"retry-as-promised": "^3.1.0",
"sequelize": "^4.39.0",
"sequelize-cli": "^4.1.1",
"sqlite3": "^4.0.2",
"string-format": "^2.0.0",
"umzug": "^2.1.0",
"underscore": "^1.9.1",
"winston": "^3.1.0",
"xss-clean": "^0.1.1",
"qs": "^6.5.2",
"child_process": "^1.0.2",
"os": "^0.1.1"
},
"devDependencies": {
"automatic-release": "^1.1.1",
"bdd-lazy-var": "^2.5.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-http": "^4.2.0",
"eslint": "^5.6.1",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"sinon": "^7.1.1",
"sinon-chai": "^3.2.0"
}
}
24 changes: 24 additions & 0 deletions scripts/coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* *******************************************************************************
* * Copyright (c) 2018 Edgeworx, Inc.
* *
* * This program and the accompanying materials are made available under the
* * terms of the Eclipse Public License v. 2.0 which is available at
* * http://www.eclipse.org/legal/epl-2.0
* *
* * SPDX-License-Identifier: EPL-2.0
* *******************************************************************************
*
*/

const execSync = require('child_process').execSync;

const options = {
env: {
'NODE_ENV': 'test',
"PATH": process.env.PATH
},
stdio: [process.stdin, process.stdout, process.stderr]
};

execSync('nyc mocha', options);
24 changes: 24 additions & 0 deletions scripts/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* *******************************************************************************
* * Copyright (c) 2018 Edgeworx, Inc.
* *
* * This program and the accompanying materials are made available under the
* * terms of the Eclipse Public License v. 2.0 which is available at
* * http://www.eclipse.org/legal/epl-2.0
* *
* * SPDX-License-Identifier: EPL-2.0
* *******************************************************************************
*
*/

const execSync = require('child_process').execSync;

const options = {
env: {
'NODE_ENV': 'production',
"PATH": process.env.PATH
},
stdio: [process.stdin, process.stdout, process.stderr]
};

execSync('node ./src/main.js init', options);
47 changes: 47 additions & 0 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* *******************************************************************************
* * Copyright (c) 2018 Edgeworx, Inc.
* *
* * This program and the accompanying materials are made available under the
* * terms of the Eclipse Public License v. 2.0 which is available at
* * http://www.eclipse.org/legal/epl-2.0
* *
* * SPDX-License-Identifier: EPL-2.0
* *******************************************************************************
*
*/


const os = require('os');
const execSync = require('child_process').execSync;
const fs = require('fs');

const rootDir = `${__dirname}/../`;
let installation_variables_file_name = 'iofogcontroller_install_variables';
let installation_variables_file;
let tempDir;

if (os.type() === 'Linux') {
tempDir = '/tmp/';
} else if (os.type() === 'Darwin') {
tempDir = '/tmp/';
} else if (os.type() === 'Windows_NT') {
tempDir = `${process.env.APPDATA}/`;
} else {
throw new Error("Unsupported OS found: " + os.type());
}

installation_variables_file = tempDir + installation_variables_file_name;


const devDbBackup = `${tempDir}dev_database.sqlite`;
if (fs.existsSync(devDbBackup)) {
fs.renameSync(devDbBackup, `${rootDir}/src/sequelize/dev_database.sqlite`)
}

const prodDbBackup = `${tempDir}prod_database.sqlite`;
if (fs.existsSync(prodDbBackup)) {
fs.renameSync(prodDbBackup, `${rootDir}/src/sequelize/prod_database.sqlite`)
}

//TODO: add version migrations
17 changes: 10 additions & 7 deletions scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

##TODO: remove after js scripts finished

vercomp () {
if [[ $1 == $2 ]]
then
Expand Down Expand Up @@ -37,9 +39,8 @@ vercomp () {

#START
#restore db
IOFOG_CONTROLLER_BIN_DIR=$(whereis iofog-controller | awk -F " " '{print $2}')
IOFOG_CONTROLLER_BIN_DIR=${IOFOG_CONTROLLER_BIN_DIR%"iofog-controller"}
IOFOG_CONTROLLER_SEQUELIZE_DIR=$IOFOG_CONTROLLER_BIN_DIR'../lib/node_modules/iofogcontroller/src/sequelize'
IOFOG_CONTROLLER_NODE_MODULES=$(npm root -g iofog-controller)
IOFOG_CONTROLLER_SEQUELIZE_DIR=$IOFOG_CONTROLLER_NODE_MODULES'/iofogcontroller/src/sequelize'

DEV_DB_FILE=$IOFOG_CONTROLLER_SEQUELIZE_DIR'/dev_database.sqlite'
DEV_DB_FILE_BACKUP='/tmp/dev_database.sqlite'
Expand All @@ -54,16 +55,18 @@ if [ -f $PROD_DB_FILE_BACKUP ]; then
fi

#prev versions migrations
PREV_IOFOG_CONTROLLER_VER=$(grep prev_ver /tmp/iofogcontroller_install_variables | awk '{print $2}')
echo "Prev ver: "${PREV_IOFOG_CONTROLLER_VER}
if [ -f /tmp/iofogcontroller_install_variables ]; then
PREV_IOFOG_CONTROLLER_VER=$(grep prev_ver /tmp/iofogcontroller_install_variables | awk '{print $2}')
fi

if [[ -z "${PREV_IOFOG_CONTROLLER_VER// }" ]]
then
echo "No prev ver"
echo "No previous version"
else
echo "Previous version: "${PREV_IOFOG_CONTROLLER_VER}
if [[ $(vercomp $PREV_IOFOG_CONTROLLER_VER 1.0.0) = '<' ]] || [[ $(vercomp $PREV_IOFOG_CONTROLLER_VER 1.0.0) = '=' ]]
then
echo "Upgrading from ver 1.0.0"
echo "Upgrading from version 1.0.0"
sqlite3 src/sequelize/prod_database.sqlite "insert into SequelizeMeta (name) values ('20180928110125-insert-registry.js');"
sqlite3 src/sequelize/prod_database.sqlite "insert into SequelizeMeta (name) values ('20180928111532-insert-catalog-item.js');"
sqlite3 src/sequelize/prod_database.sqlite "insert into SequelizeMeta (name) values ('20180928112152-insert-iofog-type.js');"
Expand Down
19 changes: 0 additions & 19 deletions scripts/preinstall.sh

This file was deleted.

Loading