Skip to content

Commit

Permalink
Merge pull request #11 from vrockai/master
Browse files Browse the repository at this point in the history
Added license checker + travis build fix
  • Loading branch information
mtho11 committed Feb 19, 2015
2 parents 1acb0ab + bcbe0b4 commit ea74189
Show file tree
Hide file tree
Showing 29 changed files with 381 additions and 58 deletions.
15 changes: 12 additions & 3 deletions .travis.build.plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

pushd $@
npm install && bower instal && gulp build
popd
status=0;

for plugin in $(find plugins/ -maxdepth 1 -mindepth 1);
do
pushd $plugin
(npm install && bower install && gulp build) || status=1;
popd
done;

if [ "$status" != 0 ]; then
exit 1;
fi
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ before_install:
- 'npm install -g bower gulp typescript'

script:
- 'for plugin in $(find plugins/ -maxdepth 1 -mindepth 1); do ./.travis.build.plugin.sh $plugin; done;'
- './.travis.build.plugin.sh'

# use this line in case of building only a sub-set of plugins
# - 'for plugin in alerts inventory metrics; do ./.travis.build.plugin.sh $plugin; done;'
23 changes: 14 additions & 9 deletions plugins/alerts/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var gulp = require('gulp'),
fs = require('fs'),
path = require('path'),
s = require('underscore.string'),
tslint = require('gulp-tslint');
tslint = require('gulp-tslint'),
tslintRules = require('./tslint.json');

var plugins = gulpLoadPlugins({});
var pkg = require('./package.json');
Expand All @@ -40,8 +41,12 @@ var config = {
target: 'ES5',
module: 'commonjs',
declarationFiles: true,
noExternalResolve: false
})
noExternalResolve: false,
removeComments: true
}),
tsLintOptions: {
rulesDirectory: './tslint-rules/'
}
};

gulp.task('bower', function() {
Expand Down Expand Up @@ -94,13 +99,13 @@ gulp.task('tsc', ['clean-defs'], function() {

gulp.task('tslint', function(){
gulp.src(config.ts)
.pipe(tslint())
.pipe(tslint(config.tsLintOptions))
.pipe(tslint.report('verbose'));
});

gulp.task('tslint-watch', function(){
gulp.src(config.ts)
.pipe(tslint())
.pipe(tslint(config.tsLintOptions))
.pipe(tslint.report('prose', {
emitError: false
}));
Expand All @@ -119,8 +124,11 @@ gulp.task('template', ['tsc'], function() {
});

gulp.task('concat', ['template'], function() {
var license = tslintRules.rules['license-header'][1];

return gulp.src(['compiled.js', 'templates.js'])
.pipe(plugins.concat(config.js))
.pipe(plugins.header(license))
.pipe(gulp.dest(config.dist))
.pipe(gulp.dest(config.rootDist));
});
Expand Down Expand Up @@ -155,7 +163,4 @@ gulp.task('reload', function() {

gulp.task('build', ['bower', 'path-adjust', 'tslint', 'tsc', 'template', 'concat', 'clean']);

gulp.task('default', ['connect']);



gulp.task('default', ['connect']);
5 changes: 3 additions & 2 deletions plugins/alerts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
"devDependencies": {
"bower": "1.3.12",
"event-stream": "3.1.7",
"gulp": "3.8.10",
"gulp": "3.8.11",
"gulp-angular-templatecache": "1.5.0",
"gulp-clean": "0.3.1",
"gulp-concat": "2.4.2",
"gulp-connect": "2.2.0",
"gulp-header": "1.2.2",
"gulp-load-plugins": "0.8.0",
"gulp-notify": "2.1.0",
"gulp-typescript": "2.4.2",
"gulp-tslint": "1.4.2",
"gulp-tslint": "1.4.3",
"gulp-watch": "3.0.0",
"through2": "0.6.3",
"underscore.string": "2.4.0",
Expand Down
15 changes: 15 additions & 0 deletions plugins/alerts/plugins/alerts/ts/alerts.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/// Copyright 2014-2015 Red Hat, Inc. and/or its affiliates
/// and other contributors as indicated by the @author tags.
///
/// 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.

/// <reference path="alertsPlugin.ts"/>
module HawkularAlerts {

Expand Down
15 changes: 15 additions & 0 deletions plugins/alerts/plugins/alerts/ts/alertsGlobals.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/// Copyright 2014-2015 Red Hat, Inc. and/or its affiliates
/// and other contributors as indicated by the @author tags.
///
/// 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.

/// <reference path="../../includes.ts"/>
module HawkularAlerts {

Expand Down
15 changes: 15 additions & 0 deletions plugins/alerts/plugins/alerts/ts/alertsPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/// Copyright 2014-2015 Red Hat, Inc. and/or its affiliates
/// and other contributors as indicated by the @author tags.
///
/// 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.

/// <reference path="../../includes.ts"/>
/// <reference path="alertsGlobals.ts"/>
module HawkularAlerts {
Expand Down
15 changes: 15 additions & 0 deletions plugins/alerts/plugins/includes.ts
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
/// Copyright 2014-2015 Red Hat, Inc. and/or its affiliates
/// and other contributors as indicated by the @author tags.
///
/// 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.

/// <reference path="../libs/hawtio-utilities/defs.d.ts"/>
28 changes: 28 additions & 0 deletions plugins/alerts/tslint-rules/licenseHeaderRule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function Rule() {
Lint.Rules.AbstractRule.apply(this, arguments);
}

Rule.prototype = Object.create(Lint.Rules.AbstractRule.prototype);
Rule.prototype.apply = function(sourceFile) {
return this.applyWithWalker(new LicenseHeaderWalker(sourceFile, this.getOptions()));
};

function LicenseHeaderWalker() {
Lint.RuleWalker.apply(this, arguments);
}

LicenseHeaderWalker.prototype = Object.create(Lint.RuleWalker.prototype);
LicenseHeaderWalker.prototype.visitSourceFile = function (node) {
// create a failure at the current position
var sourceText = this.getSourceFile().text;

var licenceHeader = this.getOptions()[0];

if ( sourceText.indexOf(licenceHeader) !== 0 ){
this.addFailure(this.createFailure(0, 0, "Missing or incorrect project license header."));
}

Lint.RuleWalker.prototype.visitSourceFile.call(this, node);
};

exports.Rule = Rule;
3 changes: 3 additions & 0 deletions plugins/alerts/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"check-operator",
"check-separator",
"_check-type"
],
"license-header": [ true,
"/// Copyright 2014-2015 Red Hat, Inc. and/or its affiliates\n/// and other contributors as indicated by the @author tags.\n///\n/// Licensed under the Apache License, Version 2.0 (the \"License\");\n/// you may not use this file except in compliance with the License.\n/// You may obtain a copy of the License at\n///\n/// http://www.apache.org/licenses/LICENSE-2.0\n///\n/// Unless required by applicable law or agreed to in writing, software\n/// distributed under the License is distributed on an \"AS IS\" BASIS,\n/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n/// See the License for the specific language governing permissions and\n/// limitations under the License.\n"
]
}
}
55 changes: 46 additions & 9 deletions plugins/inventory/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
/*
* Copyright 2014-2015 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* 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.
*/

var gulp = require('gulp'),
wiredep = require('wiredep').stream,
eventStream = require('event-stream'),
gulpLoadPlugins = require('gulp-load-plugins'),
map = require('vinyl-map'),
fs = require('fs'),
path = require('path'),
s = require('underscore.string');
s = require('underscore.string'),
tslint = require('gulp-tslint'),
tslintRules = require('./tslint.json');

var plugins = gulpLoadPlugins({});
var pkg = require('./package.json');
Expand All @@ -22,8 +41,12 @@ var config = {
target: 'ES5',
module: 'commonjs',
declarationFiles: true,
noExternalResolve: false
})
noExternalResolve: false,
removeComments: true
}),
tsLintOptions: {
rulesDirectory: './tslint-rules/'
}
};

gulp.task('bower', function () {
Expand Down Expand Up @@ -74,6 +97,20 @@ gulp.task('tsc', ['clean-defs'], function () {
}));
});

gulp.task('tslint', function () {
gulp.src(config.ts)
.pipe(tslint(config.tsLintOptions))
.pipe(tslint.report('verbose'));
});

gulp.task('tslint-watch', function () {
gulp.src(config.ts)
.pipe(tslint(config.tsLintOptions))
.pipe(tslint.report('prose', {
emitError: false
}));
});

gulp.task('template', ['tsc'], function () {
return gulp.src(config.templates)
.pipe(plugins.angularTemplatecache({
Expand All @@ -87,8 +124,11 @@ gulp.task('template', ['tsc'], function () {
});

gulp.task('concat', ['template'], function () {
var license = tslintRules.rules['license-header'][1];

return gulp.src(['compiled.js', 'templates.js'])
.pipe(plugins.concat(config.js))
.pipe(plugins.header(license))
.pipe(gulp.dest(config.dist))
.pipe(gulp.dest(config.rootDist));
});
Expand All @@ -103,7 +143,7 @@ gulp.task('watch', ['build'], function () {
gulp.start('reload');
});
plugins.watch(['libs/**/*.d.ts', config.ts, config.templates], function () {
gulp.start(['tsc', 'template', 'concat', 'clean']);
gulp.start(['tslint-watch', 'tsc', 'template', 'concat', 'clean']);
});
});

Expand All @@ -121,9 +161,6 @@ gulp.task('reload', function () {
.pipe(plugins.connect.reload());
});

gulp.task('build', ['bower', 'path-adjust', 'tsc', 'template', 'concat', 'clean']);

gulp.task('default', ['connect']);

gulp.task('build', ['bower', 'path-adjust', 'tslint', 'tsc', 'template', 'concat', 'clean']);

gulp.task('default', ['connect']);
5 changes: 4 additions & 1 deletion plugins/inventory/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"name": "hawkular-inventory",
"version": "0.1.0",
"private": true,
"devDependencies": {
"bower": "^1.3.12",
"event-stream": "^3.1.7",
"gulp": "^3.8.10",
"gulp": "3.8.11",
"gulp-angular-templatecache": "^1.5.0",
"gulp-clean": "^0.3.1",
"gulp-concat": "^2.4.2",
"gulp-connect": "^2.2.0",
"gulp-header": "1.2.2",
"gulp-load-plugins": "^0.8.0",
"gulp-notify": "^2.1.0",
"gulp-typescript": "^2.3.0",
"gulp-tslint": "1.4.3",
"gulp-watch": "^3.0.0",
"through2": "^0.6.3",
"underscore.string": "^2.4.0",
Expand Down
15 changes: 15 additions & 0 deletions plugins/inventory/plugins/includes.ts
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
/// Copyright 2014-2015 Red Hat, Inc. and/or its affiliates
/// and other contributors as indicated by the @author tags.
///
/// 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.

/// <reference path="../libs/hawtio-utilities/defs.d.ts"/>

0 comments on commit ea74189

Please sign in to comment.