Skip to content

Commit

Permalink
Merge pull request #2707 from apinf/develop
Browse files Browse the repository at this point in the history
0.47.0 release
  • Loading branch information
brylie authored Jul 3, 2017
2 parents c9946d4 + 9b6f081 commit 0886ac0
Show file tree
Hide file tree
Showing 29 changed files with 1,148 additions and 198 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"no-underscore-dangle": [
2,
{
"allow": ["_id", "__", "_initialized", "_config"]
"allow": ["_id", "__", "_initialized", "_config", "_debug"]
}
],
"no-negated-condition": [
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v4.8.3
2 changes: 1 addition & 1 deletion .scripts/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

set -ev

if [ "${TRAVIS_PULL_REQUEST}" = "false" ]
if [ "${TRAVIS_PULL_REQUEST}" = "false" -a "${TRAVIS_REPO_SLUG}" = "apinf/platform" ]
then
docker build -t apinf/platform:$DOCKER_TAG .
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
Expand Down
107 changes: 107 additions & 0 deletions .scripts/run-chimp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* Copyright 2017 Apinf Oy
This file is covered by the EUPL license.
You may obtain a copy of the licence at
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 */

// Inspired by https://goo.gl/Rbd2s2

var path = require('path'),
fs = require('fs'),
extend = require('util')._extend,
exec = require('child_process').exec,
processes = [];

var baseDir = path.resolve(__dirname, '..'),
srcDir = path.resolve(baseDir);

var appOptions = {
env: {
PORT: 3000,
ROOT_URL: 'http://localhost:3000'
}
};

/**
* Start a process on the O.S.
* Optionally start a child process if options.waitForMessage
* is set to an output message emitted by this process.
*
* @param {command, options} opts
* @param {*} callback
*/
function startProcess(opts, callback) {
var proc = exec(
opts.command,
opts.options
);

if (opts.waitForMessage) {
proc.stdout.on('data', function waitForMessage(data) {
if (data.toString().match(opts.waitForMessage)) {
if (callback) {
callback();
}
}
});
}

if (!opts.silent) {
proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
}

if (opts.logFile) {
var logStream = fs.createWriteStream(opts.logFile, {flags: 'a'});
proc.stdout.pipe(logStream);
proc.stderr.pipe(logStream);
}

proc.on('close', function(code) {
console.log(opts.name, 'exited with code ' + code);
for (var i = 0; i < processes.length; i += 1) {
processes[i].kill();
}
process.exit(code);
});
processes.push(proc);
}

/**
* Always run meteor in production-like environment
* since we do not want to reload changing files
*
* @param {*} callback
*/
function startApp(callback) {
startProcess({
name: 'Meteor App',
command: 'meteor --production',
waitForMessage: appOptions.waitForMessage,
options: {
cwd: srcDir,
env: extend(appOptions.env, process.env)
}
}, callback);
}

/**
* Start chimp
*/
function startChimp() {
startProcess({
name: 'Chimp',
command: 'yarn run chimp-test'
});
}

/**
* Run meteor and then chimp after application has started
*/
function chimpNoMirror() {
appOptions.waitForMessage = 'App running at:';
startApp(function() {
startChimp();
});
}

chimpNoMirror();
13 changes: 13 additions & 0 deletions .scripts/start-xvfb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Copyright 2017 Apinf Oy
#This file is covered by the EUPL license.
#You may obtain a copy of the licence at
#https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11

set -ev

if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
sh -e /etc/init.d/xvfb start
sleep 3
fi
41 changes: 36 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
sudo: false
language: node_js
node_js:
- "node"
- '4'

addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://dl.yarnpkg.com/debian/ stable main'
key_url: 'https://dl.yarnpkg.com/debian/pubkey.gpg'
packages:
- g++-4.8
- yarn
chrome: stable

branches:
only:
- develop

before_cache:
- rm -f $HOME/.meteor/log/*.log

cache:
yarn: true

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
directories:
- $HOME/.meteor

services:
- docker

before_install:
# Install meteor locally on CI
- if [ ! -e "$HOME/.meteor/meteor" ]; then curl https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh; fi

before_script:
- yarn
- yarn run lint
# Start X Virtual Frame Buffer for headless testing with real browsers
- ./.scripts/start-xvfb.sh

install:
- export PATH="$HOME/.meteor:$PATH"

script:
# Run meteor and chimp from node.js
- travis_retry yarn test
# Build docker image
- ./.scripts/docker_build.sh

env:
global:
- DISPLAY=:99.0
- TEST_MODE: "true"
- CXX=g++-4.8
2 changes: 1 addition & 1 deletion about/client/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h3>
Apinf
</dt>
<dd>
0.46.0
0.47.0
</dd>
<dt>
API Umbrella
Expand Down
5 changes: 5 additions & 0 deletions apis/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ApiV1.addCollection(Apis, {
tags: [
ApiV1.swagger.tags.api,
],
summary: 'List and search public APIs.',
description: 'List and search public APIs.',
parameters: [
ApiV1.swagger.params.optionalSearch,
Expand Down Expand Up @@ -106,6 +107,7 @@ ApiV1.addCollection(Apis, {
tags: [
ApiV1.swagger.tags.api,
],
summary: 'Fetch API with specified ID',
description: 'Returns one API with specified ID or nothing if there is not match found',
parameters: [
ApiV1.swagger.params.apiId,
Expand All @@ -126,6 +128,7 @@ ApiV1.addCollection(Apis, {
tags: [
ApiV1.swagger.tags.api,
],
summary: 'Add new API to catalog.',
description: 'Adds an API to catalog. On success, returns newly added API object.',
parameters: [
ApiV1.swagger.params.api,
Expand Down Expand Up @@ -155,6 +158,7 @@ ApiV1.addCollection(Apis, {
tags: [
ApiV1.swagger.tags.api,
],
summary: 'Update API',
description: 'Update an API',
parameters: [
ApiV1.swagger.params.apiId,
Expand Down Expand Up @@ -232,6 +236,7 @@ ApiV1.addCollection(Apis, {
tags: [
ApiV1.swagger.tags.api,
],
summary: 'Delete API.',
description: 'Deletes the identified API from the system.',
parameters: [
ApiV1.swagger.params.apiId,
Expand Down
8 changes: 4 additions & 4 deletions branding/client/branding.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ <h3 class="panel-title">
type="update"
collection=brandingCollection
doc=branding }}
{{> afQuickField name='siteTitle' id="site-title" }}
{{> afQuickField name='siteSlogan' id="site-slogan" }}
{{> afQuickField name='siteTitle' id="branding-site-title" }}
{{> afQuickField name='siteSlogan' id="branding-site-slogan" }}
{{> afQuickField name='colors' }}
{{> afQuickField name='siteFooter' id="site-footer" }}
{{> afQuickField name='footerCode' id="footer-code" }}
Expand All @@ -46,7 +46,7 @@ <h3 class="panel-title">
</a>
{{> afQuickField name='homeCustomBlock' }}
<div id="form-buttons">
<button type="submit" class="btn btn-primary" id="submit-branding">
<button id="branding-update-button" type="submit" class="btn btn-primary">
{{_ "branding_update" }}
</button>
</div>
Expand All @@ -62,7 +62,7 @@ <h3 class="panel-title">
{{> afQuickField name='footerCode' }}
{{> afQuickField name='socialMedia' }}
<div id="form-buttons">
<button type="submit" class="btn btn-primary">
<button id="branding-save-button" type="submit" class="btn btn-primary">
{{_ "branding_save" }}
</button>
</div>
Expand Down
36 changes: 36 additions & 0 deletions core/capture_exception/client/error_handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Copyright 2017 Apinf Oy
This file is covered by the EUPL license.
You may obtain a copy of the licence at
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 */

// Meteor packages imports
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

// Npm packages imports
import Raven from 'raven-js';

// Set Global Error Handler
window.addEventListener('error', (e) => {
// Send error message and stack
Raven.captureException(e.message, { extra: { stack: e.error.stack } });
});

// Set Global Error Handler on Promise rejection
window.addEventListener('unhandledrejection', (e) => {
// Send error message and stack
Raven.captureException(e.reason.message, { extra: { stack: e.reason.stack } });
});

// Set Global Handler on Sign in
Accounts.onLogin(() => {
Raven.setUserContext({
email: Meteor.user().emails[0].address,
id: Meteor.userId(),
});
});

// Set Global Handler on Sign Out
Accounts.onLogout(() => {
Raven.setUserContext();
});
27 changes: 27 additions & 0 deletions core/capture_exception/client/start_up.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright 2017 Apinf Oy
This file is covered by the EUPL license.
You may obtain a copy of the licence at
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 */

// Meteor packages imports
import { Meteor } from 'meteor/meteor';

// Npm packages imports
import Raven from 'raven-js';

// APInf imports
import wrapMeteorDebug from './wrap_meteor_debug';

Meteor.startup(() => {
Meteor.call('getClientDsn', (err, result) => {
// The falsy result will turn off the Sentry app
const SENTRY_DSN = result || false;

// Configure Raven capture tracking for Client side
Raven
.config(SENTRY_DSN)
.install();
});

wrapMeteorDebug();
});
27 changes: 27 additions & 0 deletions core/capture_exception/client/wrap_meteor_debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright 2017 Apinf Oy
This file is covered by the EUPL license.
You may obtain a copy of the licence at
https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11 */

// Meteor packages imports
import { Meteor } from 'meteor/meteor';

// Npm packages imports
import Raven from 'raven-js';

export default function wrapMeteorDebug () {
// Expand Meteor._debug function - capture and log exception to Sentry before display error
const originalMeteorDebug = Meteor._debug;

Meteor._debug = function (m, s) {
// Exception message contains two message.
// One of them is Exception Tracker which is not useful for debugging
// Don't send exception to Sentry which is related to Tracker exception
if (m !== 'Exception from Tracker recompute function:') {
// Provide message of error and stack
Raven.captureException(m, { extra: { stack: s } });
}
// eslint-disable-next-line
return originalMeteorDebug.apply(this, arguments);
};
}
Loading

0 comments on commit 0886ac0

Please sign in to comment.