Skip to content

Commit

Permalink
Merge pull request #7 from vrockai/license2
Browse files Browse the repository at this point in the history
License checking in services
  • Loading branch information
mtho11 committed Feb 19, 2015
2 parents b884354 + cf65eeb commit 975d2e3
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 52 deletions.
39 changes: 14 additions & 25 deletions dist/hawkular-ui-service.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
/// <reference path="../../lib/hawtio-core-dts/angular.d.ts" />
/// 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 hawkularRest;
(function (hawkularRest) {
hawkularRest._module = angular.module('hawkular.services', ['ngResource']);
})(hawkularRest || (hawkularRest = {}));

/**
* @ngdoc provider
* @name hawkular.rest.HawkularAlert
* @description
* # HawkularAlert
* Provider in the hawkular.rest.
*/
var hawkularRest;
(function (hawkularRest) {
hawkularRest._module.provider('HawkularAlert', function () {
// time (in ms) the notifications are shown
this.host = 'localhost';
this.port = 8080;
this.setHost = function (host) {
Expand Down Expand Up @@ -171,17 +176,9 @@ var hawkularRest;
});
})(hawkularRest || (hawkularRest = {}));

/**
* @ngdoc provider
* @name hawkular.rest.HawkularInventory
* @description
* # HawkularInventory
* Provider in the hawkular.rest.
*/
var hawkularRest;
(function (hawkularRest) {
hawkularRest._module.provider('HawkularInventory', function () {
// time (in ms) the notifications are shown
this.host = 'localhost';
this.port = 8080;
this.setHost = function (host) {
Expand Down Expand Up @@ -213,17 +210,9 @@ var hawkularRest;
});
})(hawkularRest || (hawkularRest = {}));

/**
* @ngdoc provider
* @name hawkular.rest.HawkularMetric
* @description
* # HawkularRest
* Provider in the hawkular.rest.
*/
var hawkularRest;
(function (hawkularRest) {
hawkularRest._module.provider('HawkularMetric', function () {
// time (in ms) the notifications are shown
this.host = 'localhost';
this.port = 8080;
this.setHost = function (host) {
Expand Down
1 change: 1 addition & 0 deletions dist/hawkular-ui-service.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions gulp/scripts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var gulp = require('gulp'),
tslint = require('gulp-tslint');
tslintRules = require('../tslint.json');

var paths = gulp.paths;

Expand All @@ -11,18 +11,29 @@ var $ = require('gulp-load-plugins')({

gulp.task('tslint', function () {
gulp.src([paths.src + '/hawkRest.ts', paths.src + '/hawkRest-*.ts'])
.pipe(tslint())
.pipe(tslint.report('verbose'));
.pipe($.tslint({
rulesDirectory: './tslint-rules/'
}))
.pipe($.tslint.report('verbose'));
});

gulp.task('scripts', function () {

var license = tslintRules.rules['license-header'][1];

return gulp.src([paths.src + '/hawkRest.ts', paths.src + '/hawkRest-*.ts'])
.pipe($.typescript())
.pipe($.typescript({
removeComments: true
}))
.on('error', function handleError(err) {
console.error(err.toString());
this.emit('end');
})
.pipe($.concat('hawkular-ui-service.js'))
.pipe($.header(license))
.pipe(gulp.dest(paths.dist + '/'))
.pipe($.concat('hawkular-ui-service.min.js'))
.pipe($.uglify())
.pipe(gulp.dest(paths.dist + '/'));
});

Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"chalk": "~0.5.1",
"del": "~0.1.3",
"gulp": "~3.8.10",
"gulp-autoprefixer": "~2.0.0",
"gulp-angular-templatecache": "~1.4.2",
"del": "~0.1.3",
"gulp-autoprefixer": "~2.0.0",
"gulp-concat": "2.4.2",
"gulp-load-plugins": "~0.7.1",
"gulp-header": "1.2.2",
"gulp-karma": "~0.0.4",
"gulp-load-plugins": "~0.7.1",
"gulp-tslint": "1.4.3",
"gulp-typescript": "~2.3.0",
"gulp-tslint": "1.4.2",
"wiredep": "~2.2.0",
"gulp-uglify": "1.1.0",
"karma-jasmine": "~0.3.1",
"karma-phantomjs-launcher": "~0.1.4",
"require-dir": "~0.1.0",
"chalk": "~0.5.1"
"wiredep": "~2.2.0"
},
"engines": {
"node": ">=0.10.0"
Expand Down
15 changes: 15 additions & 0 deletions src/rest/hawkRest-alert-provider.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.

/**
* @ngdoc provider
* @name hawkular.rest.HawkularAlert
Expand Down
15 changes: 15 additions & 0 deletions src/rest/hawkRest-inventory-provider.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.

/**
* @ngdoc provider
* @name hawkular.rest.HawkularInventory
Expand Down
15 changes: 15 additions & 0 deletions src/rest/hawkRest-metric-factory.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.

/**
* @ngdoc provider
* @name hawkular.rest.HawkularMetric
Expand Down
15 changes: 15 additions & 0 deletions src/rest/hawkRest.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="../../lib/hawtio-core-dts/angular.d.ts" />

module hawkularRest {
Expand Down
28 changes: 28 additions & 0 deletions 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;
33 changes: 16 additions & 17 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@
"no-arg": true,
"no-bitwise": true,
"no-console": [true,
"debug",
"info",
"time",
"timeEnd",
"trace"
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-debugger": false,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-string-literal": true,
"no-string-literal": false,
"no-switch-case-fall-through": true,
"no-trailing-comma": true,
"_no-trailing-whitespace": true,
Expand All @@ -32,22 +28,25 @@
"no-unreachable": true,
"no-use-before-declare": true,
"one-line": [true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"_quotemark": [true, "double"],
"radix": true,
"semicolon": true,
"triple-equals": [true, "allow-null-check"],
"variable-name": false,
"whitespace": [true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"_check-type"
"whitespace": [false,
"check-branch",
"check-decl",
"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"
]
}
}

0 comments on commit 975d2e3

Please sign in to comment.