Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Added skyux lint command (#205)
Browse files Browse the repository at this point in the history
* Update angular (#189)

* Updated dependencies

* Updated skyux2 version

* Updated dependencies

* Using template branch for testing

* Reverted protractor config

* Pointing to dev branch for local testing

* Updated package json

* Using explicit types

* Updated version of skyux

* Updated dependencies

* Fixed linting errors

* Added fontfaceobserver to types

* Fixed tslint errors

* Fixed tslint errors

* Ensure that the files are not directories

* Update tests for file processor

* Update plugin-file-processor.js

* Update plugin-file-processor.spec.js

* Updated version of skyux

* Updated config

* Added specific version of firefox

* Updated tsconfig

* Updating travis version

* Updated version of firefox

* Updated directconnect

* Updated protractor

* Added firfox launcher

* Removed directConnect

* Reverting back to directConnect

* Removed firefox

* Re-added firefox

* Accepting insecure certs

* Enabled directconnect

* use chrome with chromOptions in protractor-dev.conf.js

* add sources to travis.yml

* add dist: trusty

* Removed tsconfig paths

* Update typescript-loader

* Simpler method for avoiding directories

* As ts-node option and fix e2e test

* updates for rc.0 release (#190)

* Omnibar config (#193)

* Using omnibarConfigMap for envid/svcid

* Fixing implicit any

* Fixed codelyzer path (#192)

* Fixed codelyzer path

* Added node_modules to excludes

* Readded node_modules

* Ignore public directory when generating components (#187)

* Added ignore pattern to component generator

* Component generator should ignore public folder

* Updated ignore pattern

* Plugin File Processor should not check directories (#186)

* Do not check directories

* Added nodir option

* Updated CHANGELOG.md and package.json for 1.0.0-rc.1 (#194)

* Updated template branch, bug fix for component pattern (#195)

* Updated branch to master

* Fixed bug with ignore components pattern

* Updated unit tests

* Release 1.0.0 rc.2 (#196)

* Update CHANGELOG.md

* Update package.json

* Remove extra s. (#197)

* Fixed type error, updated SKY UX (#199)

* Fixed type error

* Updated skyux

* Updated skyux

* Release 1.0.0 rc.3 (#200)

* Fixed type error

* Updated skyux

* Updated skyux

* Update package.json

* Update CHANGELOG.md

* Param functionality (#201)

* Fixed typo in OmnibarConfigMap.  Allowing querystring params to be case insensitive

* Test cleanup

* Removed unnecessary mapping functionality

* Added lint command

* Fixed `skyux test/watch` performance (#202)

* Removed tslint-loader
* Created custom sky-tslint loader

* Release 1.0.0-rc.4 (#207)

* Updated changelog, version

* Update CHANGELOG.md

* Update CHANGELOG.md

* Added to skyux builder (#204)

* Updated package dependencies (#208)

* Updated package dependencies

* Update skyux version

* use appropriate template branch

* Add hash routing option for easy mode. (#206)

* Updates rc5 (#209)

* Updates for rc.5

* Capitalize Angular. (#211)

* Wrote failing test.  Then made config property public for template (#212)

* Added skyux lint files

* Update CHANGELOG.md

* Updated unit tests

* Updated unit tests

* Fixed e2e test

* Fixed e2e tests

* Update build.js

* Added colors to logger

* Updated linter result

* Added error log after karma reporter

* Update test.js

* Added errors to linter result
  • Loading branch information
Blackbaud-SteveBrush authored and Blackbaud-PaulCrowder committed Jul 26, 2017
1 parent 8a49f46 commit 1cbbf40
Show file tree
Hide file tree
Showing 28 changed files with 480 additions and 375 deletions.
9 changes: 9 additions & 0 deletions cli/build-public-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ const preparePackage = require('./utils/prepare-library-package');
const webpackConfig = require('../config/webpack/build-public-library.webpack.config.js');
const skyPagesConfigUtil = require('../config/sky-pages/sky-pages.config');
const runCompiler = require('./utils/run-compiler');
const tsLinter = require('./utils/ts-linter');

function runLinter() {
const lintResult = tsLinter.lintSync();
if (lintResult.exitCode > 0) {
process.exit(lintResult.exitCode);
}
}

function cleanTemp() {
rimraf.sync(skyPagesConfigUtil.spaPathTemp());
Expand Down Expand Up @@ -61,6 +69,7 @@ function transpile(skyPagesConfig, webpack) {
}

module.exports = (skyPagesConfig, webpack) => {
runLinter();
cleanAll();
stageTypeScriptFiles();
writeTSConfig();
Expand Down
7 changes: 7 additions & 0 deletions cli/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const generator = require('../lib/sky-pages-module-generator');
const assetsProcessor = require('../lib/assets-processor');
const pluginFileProcessor = require('../lib/plugin-file-processor');
const runCompiler = require('./utils/run-compiler');
const tsLinter = require('./utils/ts-linter');

function writeTSConfig() {
var config = {
Expand Down Expand Up @@ -127,6 +128,12 @@ function build(argv, skyPagesConfig, webpack) {
const assetsBaseUrl = argv.assets || '';
const assetsRel = argv.assetsrel;

const lintResult = tsLinter.lintSync();
if (lintResult.exitCode > 0) {
process.exit(lintResult.exitCode);
return;
}

if (compileModeIsAoT) {
stageAot(skyPagesConfig, assetsBaseUrl, assetsRel);
buildConfig = require('../config/webpack/build-aot.webpack.config');
Expand Down
11 changes: 11 additions & 0 deletions cli/lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*jslint node: true */
'use strict';

function lint() {
const tsLinter = require('./utils/ts-linter');
const result = tsLinter.lintSync();

process.exit(result.exitCode);
}

module.exports = lint;
71 changes: 41 additions & 30 deletions cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,52 @@
'use strict';

/**
* Spawns the karam start command.
* Spawns the karma test command.
* @name test
*/
function test(command, argv) {
const path = require('path');
const spawn = require('cross-spawn');

const karmaConfigPath = path.resolve(
__dirname,
'..',
'config/karma/' + command + '.karma.conf.js'
);

const flags = [
'--max-old-space-size=4096',
'node_modules/karma/bin/karma',
'start',
karmaConfigPath,
'--command',
command
];

if (argv && argv.coverage === false) {
flags.push('--no-coverage');
} else {
flags.push('--coverage');
}

const options = {
stdio: 'inherit'
const logger = require('../utils/logger');
const Server = require('karma').Server;
const tsLinter = require('./utils/ts-linter');
const skyPagesConfigUtil = require('../config/sky-pages/sky-pages.config');

argv = argv || process.argv;
argv.command = command;

const karmaConfigUtil = require('karma').config;
const karmaConfigPath = skyPagesConfigUtil.outPath(`config/karma/${command}.karma.conf.js`);
const karmaConfig = karmaConfigUtil.parseConfig(karmaConfigPath);

let lintResult;

const onRunStart = () => {
lintResult = tsLinter.lintSync();
};

const onRunComplete = () => {
if (lintResult.exitCode > 0) {
// Pull the logger out of the execution stream to let it print
// after karma's coverage reporter.
setTimeout(() => {
logger.error('Process failed due to linting errors:');
lintResult.errors.forEach(error => logger.error(error));
}, 10);
}
};

const onExit = (exitCode) => {
if (exitCode === 0) {
exitCode = lintResult.exitCode;
}

logger.info(`Karma has exited with ${exitCode}.`);
process.exit(exitCode);
};

// Pass our exitCode up
const test = spawn('node', flags, options);
test.on('exit', exitCode => process.exit(exitCode));
const server = new Server(karmaConfig, onExit);
server.on('run_start', onRunStart);
server.on('run_complete', onRunComplete);
server.start();
}

module.exports = test;
41 changes: 41 additions & 0 deletions cli/utils/ts-linter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*jslint node: true */
'use strict';

const spawn = require('cross-spawn');
const skyPagesConfigUtil = require('../../config/sky-pages/sky-pages.config');
const logger = require('../../utils/logger');

const flags = [
'--max-old-space-size=4096',
'--type-check',
'--project',
skyPagesConfigUtil.spaPath('tsconfig.json'),
'--config',
skyPagesConfigUtil.spaPath('tslint.json')
];

function lintSync() {
logger.info('Starting TSLint...');

const spawnResult = spawn.sync('./node_modules/.bin/tslint', flags);
const errorString = spawnResult.stderr.toString().trim();

let errors = [];
if (errorString) {
errors = errorString.split(/\r?\n/);
}

// Print linting results to console.
errors.forEach(error => logger.error(error));
const plural = (errors.length === 1) ? '' : 's';
logger.info(`TSLint finished with ${errors.length} error${plural}.`);

return {
exitCode: spawnResult.status,
errors: errors
};
}

module.exports = {
lintSync
};
10 changes: 0 additions & 10 deletions config/webpack/test.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const DefinePlugin = require('webpack/lib/DefinePlugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
const ProcessExitCode = require('../../plugin/process-exit-code');
const SkyTsLintCheckerPlugin = require('../../loader/sky-tslint/checker-plugin');
const skyPagesConfigUtil = require('../sky-pages/sky-pages.config');
const aliasBuilder = require('./alias-builder');

Expand Down Expand Up @@ -77,12 +76,6 @@ function getWebpackConfig(skyPagesConfig, argv) {
loader: outPath('loader', 'sky-processor', 'preload'),
exclude: excludes
},
{
enforce: 'pre',
test: /\.ts$/,
loader: outPath('loader', 'sky-tslint'),
exclude: excludes
},
{
test: /\.ts$/,
use: [
Expand Down Expand Up @@ -142,9 +135,6 @@ function getWebpackConfig(skyPagesConfig, argv) {
{}
),

// Handles watch-mode maintenance for TSLint.
new SkyTsLintCheckerPlugin(),

// Webpack 2 behavior does not correctly return non-zero exit code.
new ProcessExitCode()
]
Expand Down
4 changes: 2 additions & 2 deletions e2e/skyux-build-aot.e2e-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { Injectable } from '@angular/core';
@Injectable()
export class AboutGuard {
canActivate(next: any, state: any) {
public canActivate(next: any, state: any): boolean {
return false;
}
}
Expand Down Expand Up @@ -62,7 +62,7 @@ import { Injectable } from '@angular/core';
@Injectable()
export class RootGuard {
canActivateChild(next: any, state: any) {
public canActivateChild(next: any, state: any): boolean {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/skyux-build-jit.e2e-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { Injectable } from '@angular/core';
@Injectable()
export class AboutGuard {
canActivate(next: any, state: any) {
public canActivate(next: any, state: any): boolean {
return false;
}
}
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module.exports = {
case 'serve':
require('./cli/serve')(argv, skyPagesConfig, webpack, WebpackDevServer);
break;
case 'lint':
require('./cli/lint')();
break;
case 'test':
case 'watch':
require('./cli/test')(command, argv);
Expand Down
14 changes: 0 additions & 14 deletions loader/sky-tslint/checker-plugin.js

This file was deleted.

32 changes: 0 additions & 32 deletions loader/sky-tslint/index.js

This file was deleted.

25 changes: 0 additions & 25 deletions loader/sky-tslint/program.js

This file was deleted.

2 changes: 1 addition & 1 deletion runtime/i18n/resources.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Resources pipe', () => {

return Observable.of(value);
}
};
} as SkyAppResourcesService;
});

it('should return the expected string', () => {
Expand Down
5 changes: 5 additions & 0 deletions runtime/i18n/resources.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import {
import { Http } from '@angular/http';

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/publishReplay';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/of';

import { SkyAppAssetsService } from '@blackbaud/skyux-builder/runtime/assets.service';
import { SkyAppLocaleProvider } from '@blackbaud/skyux-builder/runtime/i18n/locale-provider';
Expand Down
2 changes: 1 addition & 1 deletion src/app/sky-pages.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File dynamically generated via webpack.
// Matching definition makes IDE's happy.
export let SkyPagesModule: any;
export class SkyPagesModule {}

// The following comment is used to track timestamps in `skyux serve`
// TS (1492006796510 END
Loading

0 comments on commit 1cbbf40

Please sign in to comment.