Skip to content

Commit

Permalink
Merge pull request #1621 from brecke/update-npm
Browse files Browse the repository at this point in the history
Update npm
  • Loading branch information
brecke authored Nov 9, 2018
2 parents 13989cf + 6b66d37 commit 3c0ac8b
Show file tree
Hide file tree
Showing 644 changed files with 13,956 additions and 315 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ jobs:
docker-compose up -d oae-etherpad
- run:
name: Install Hilary dependencies
command: |
command: |
docker cp /root/Hilary oae-hilary:/usr/src
docker-compose run oae-hilary 'npm install'
- run:
name: Run tests
command: docker-compose run oae-hilary "TWITTER_KEY=$TWITTER_KEY TWITTER_SECRET=$TWITTER_SECRET FACEBOOK_APP_ID=$FACEBOOK_APP_ID FACEBOOK_APP_SECRET=$FACEBOOK_APP_SECRET GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET grunt test"
command: docker-compose run oae-hilary "TWITTER_KEY=$TWITTER_KEY TWITTER_SECRET=$TWITTER_SECRET FACEBOOK_APP_ID=$FACEBOOK_APP_ID FACEBOOK_APP_SECRET=$FACEBOOK_APP_SECRET GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET npm test"
workflows:
version: 2
test-all:
Expand Down
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
/dump.rdb
/target/
*.log
doc_data.txt

/node_modules/*
!/node_modules/oae-*

# This line is needed to work around a bug with Atom IDE TreeView
# https://github.com/atom/tree-view/issues/196
!/node_modules/oae-*/
.DS_Store

/node_modules/oae-release-tools
12 changes: 6 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "node_modules/oae-rest"]
path = node_modules/oae-rest
url = https://github.com/oaeproject/oae-rest
[submodule "3akai-ux"]
path = 3akai-ux
url = https://github.com/oaeproject/3akai-ux
[submodule "node_modules/restjsdoc"]
path = node_modules/restjsdoc
url = https://github.com/oaeproject/restjsdoc.git
[submodule "packages/oae-rest"]
path = packages/oae-rest
url = https://github.com/oaeproject/oae-rest
[submodule "packages/restjsdoc"]
path = packages/restjsdoc
url = https://github.com/oaeproject/restjsdoc
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@
# $ docker run -it --name=hilary --net=host oae-hilary:latest
#

FROM oaeproject/oae-hilary-deps-docker:v0.1
FROM oaeproject/oae-hilary-deps-docker:v0.2
LABEL Name=OAE-Hilary
LABEL Author=ApereoFoundation
LABEL [email protected]

# Install global dependencies
RUN npm install --silent --global [email protected]
RUN npm install --silent --global nodemon bunyan grunt grunt-cli

# Create the temp directory
RUN mkdir -p /tmp/oae

Expand Down
240 changes: 0 additions & 240 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,249 +17,12 @@
/* eslint-disable no-use-before-define, camelcase, unicorn/filename-case, no-unused-vars, no-use-extend-native/no-use-extend-native */

module.exports = grunt => {
const _ = require('underscore');
const shell = require('shelljs');
const util = require('util');
const mocha_grep = process.env.MOCHA_GREP;

// Timeout used to determine when a test has failed
const MOCHA_TIMEOUT = 60000;

let regexErrors = false;

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jslint: {
files: [
'Gruntfile.js',
'etc/**/*.js',
'node_modules/oae-*/lib/**/*.js',
'node_modules/oae-*/tests/**/*.js',
'node_modules/oae-*/config/**/*.js'
]
},
jshint: {
options: {
node: true,
sub: true,
indent: 4,
trailing: true,
quotmark: 'single',
curly: true,
white: false,
strict: false,
globals: {
it: true,
describe: true,
before: true,
beforeEach: true,
after: true,
afterEach: true
}
},
files: '<%= jslint.files %>'
},
'mocha-hack': {
all: {
src: ['node_modules/oae-tests/runner/beforeTests.js', 'node_modules/oae-*/tests/**/*.js'],
options: {
timeout: MOCHA_TIMEOUT,
ignoreLeaks: false,
fullStackTrace: true,
reporter: 'spec',
// eslint-disable-next-line camelcase
grep: mocha_grep,
bail: false,
slow: 500,
globals: ['oaeTests']
}
}
},
clean: ['target/'],
replace: {
'check-style': {
src: ['node_modules/oae-*/**/*.js', '!node_modules/oae-*/node_modules/**/*.js'],
overwrite: true,
replacements: [
{
from: /@param (\S|\s\s)/,
to: (matchedWord, index, fullText, regexMatches) => {
const msg = '@param should be followed by 2 spaces';
// eslint-disable-next-line no-use-before-define
return logMatch(msg, matchedWord, index, fullText, regexMatches);
}
},
{
from: /@return \s/,
to: (matchedWord, index, fullText, regexMatches) => {
const msg = '@return should be followed by 1 space';
return logMatch(msg, matchedWord, index, fullText, regexMatches);
}
},
{
from: /@returns/,
to: (matchedWord, index, fullText, regexMatches) => {
const msg = 'Use @return instead of @returns';
return logMatch(msg, matchedWord, index, fullText, regexMatches);
}
},
{
from: /@throws \s/,
to: (matchedWord, index, fullText, regexMatches) => {
const msg = '@throws should be followed by 1 space';
return logMatch(msg, matchedWord, index, fullText, regexMatches);
}
},
{
from: /(tenant|globalAdmin)Server\.(get|post|put|head|del)\((.*)/,
to: (matchedWord, index, fullText, regexMatches) => {
const msg =
'Do not use the tenantServer or globalAdminServer to bind routes. Use the Router object like this:\n\n ' +
regexMatches[0] +
"Router.on('" +
regexMatches[1] +
"', " +
regexMatches[2];
return logMatch(msg, matchedWord, index, fullText, regexMatches);
}
}
]
}
}
});

// Utility function for logging regex matches
const logMatch = (msg, matchedWord, index, fullText, regexMatches) => {
const lineNum = fullText.substring(0, index).match(/\n/g).length + 1;
const line = fullText.split('\n')[lineNum - 1];
grunt.log.writeln(msg.red + ': ' + lineNum + ': ' + line);
regexErrors = true;
return matchedWord;
};

// Task to run the regex task and fail if it matches anything
grunt.registerTask('check-style', ['replace', 'jshint', 'checkRegexErrors']);
grunt.registerTask('checkRegexErrors', () => {
grunt.task.requires('replace');
if (regexErrors) {
grunt.warn('Style rule validation failed');
}
});

// Override default test task to use mocha-hack
grunt.registerTask('test', ['mocha-hack']);

// Make a task for running tests on a single module
grunt.registerTask('test-module', 'Test a single module', module => {
const config = {
src: [
'node_modules/oae-tests/runner/beforeTests.js',
'node_modules/' + module + '/tests/**/*.js'
],
options: grunt.config.get('mocha-hack.all.options')
};
grunt.config.set('mocha-hack.' + module, config);
grunt.task.run('mocha-hack:' + module);
});

// Runs the unit tests and dumps some coverage data
grunt.registerTask('test-instrumented', report => {
// If no report format was provided, we default to `lcov` which generates lcov and html
report = report || 'lcov';

// Get the modules that should be excluded
const excludeDirectories = grunt.file.expand(
{ filter: 'isDirectory' },
'node_modules/*',
'!node_modules/oae-*',
'node_modules/oae-tests',
'node_modules/oae-*/node_modules'
);
const excludeDirectoriesParameters = _.map(excludeDirectories, module => {
return util.format('-x %s/\\*\\*', module);
});

// Exclude the tests from the coverage reports
const oaeModules = grunt.file.expand({ filter: 'isDirectory' }, 'node_modules/oae-*');
const testDirectories = _.map(oaeModules, directory => {
return util.format('-x %s/tests/\\*\\*', directory);
});
const testUtilDirectories = _.map(oaeModules, directory => {
return util.format('-x %s/lib/test/\\*\\*', directory);
});

// Exclude the config directories
const configDirectories = _.map(oaeModules, module => {
return util.format('-x %s/config/\\*\\*', module);
});

// Build up one big set of exlusion filters
const excludeFilters = _.union(
excludeDirectoriesParameters,
testDirectories,
testUtilDirectories,
configDirectories
);
excludeFilters.push('-x Gruntfile.js');

const cmd = util.format(
'node_modules/.bin/istanbul cover --verbose --dir target --no-default-excludes %s --report %s ./node_modules/grunt-cli/bin/grunt',
excludeFilters.join(' '),
report
);
const { code } = shell.exec(cmd);
if (code !== 0) {
process.exit(code);
}
});

// Sends a coverage report to coveralls.io
grunt.registerTask('coveralls', () => {
// This assumes we're executing within the context of Travis CI
// If not, you'll have to add a .converalls.yml file with `repo_token: ...` in it
shell.exec('cat ./target/lcov.info | ./node_modules/coveralls/bin/coveralls.js');
});

// Run test coverage and open the report
grunt.registerTask('test-coverage', [
'clean',
'test-instrumented',
'showFile:target/lcov-report/index.html'
]);

// Run test coverage
grunt.registerTask('test-coverage-coveralls', [
'clean',
'test-instrumented:lcovonly',
'coveralls'
]);

// Make a task to open the browser
// eslint-disable-next-line complexity
grunt.registerTask('showFile', 'Open a file with the OS default viewer', file => {
let browser = shell.env.BROWSER;
if (!browser) {
if (process.platform === 'linux') {
browser = 'xdg-open';
} else if (process.platform === 'darwin') {
browser = 'open';
} else if (process.platform === 'win32') {
browser = 'explorer.exe';
}
}
if (browser) {
shell.exec(browser + ' ' + (file || 'target/coverage.html'));
}
});

// Bring in tasks from npm
// Temporary work around till https://github.com/yaymukund/grunt-simple-mocha/issues/16 lands.
grunt.loadNpmTasks('grunt-mocha-hack');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-text-replace');

// Copies the files that need to go in the release.
// We remove the test files and the Grunt file as it could be potentially
// devestating to run the tests in a production environment.
Expand All @@ -273,7 +36,4 @@ module.exports = grunt => {

shell.exec('bin/package -so ' + outputDir);
});

// Default task.
grunt.registerTask('default', ['check-style', 'test']);
};
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ To create a new user, use either the Sign Up link at the top left, or the Sign I

We're looking forward to seeing your contributions to the OAE project!

### Running tests

To run tests just make sure you have installed all dependencies (`npm i`) and run `npm test`. To run tests on a specific module, just append its name as follows: `npm run test-module -- oae-principals`.

### Troubleshooting

#### Booting takes too much time
Expand Down
Loading

0 comments on commit 3c0ac8b

Please sign in to comment.