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

Added skyux lint command #205

Merged
merged 41 commits into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0bb6c7b
Update angular (#189)
Blackbaud-PatrickOFriel Jun 17, 2017
a7c3277
updates for rc.0 release (#190)
Blackbaud-PatrickOFriel Jun 17, 2017
189eb63
Omnibar config (#193)
Jun 20, 2017
314aefd
Fixed codelyzer path (#192)
Blackbaud-SteveBrush Jun 20, 2017
28830ba
Ignore public directory when generating components (#187)
Blackbaud-SteveBrush Jun 20, 2017
424672f
Plugin File Processor should not check directories (#186)
Blackbaud-SteveBrush Jun 20, 2017
1085d54
Updated CHANGELOG.md and package.json for 1.0.0-rc.1 (#194)
Jun 20, 2017
6de9f1f
Updated template branch, bug fix for component pattern (#195)
Blackbaud-SteveBrush Jun 20, 2017
9e52340
Release 1.0.0 rc.2 (#196)
Blackbaud-SteveBrush Jun 21, 2017
b9f8688
Remove extra s. (#197)
blackbaud-johnly Jun 22, 2017
256d4b8
Fixed type error, updated SKY UX (#199)
Blackbaud-SteveBrush Jun 23, 2017
db62d70
Release 1.0.0 rc.3 (#200)
Blackbaud-SteveBrush Jun 23, 2017
978813f
Param functionality (#201)
Jun 27, 2017
ee0b61f
Added lint command
Blackbaud-SteveBrush Jun 29, 2017
4272474
Fixed `skyux test/watch` performance (#202)
Blackbaud-SteveBrush Jun 29, 2017
3ed462a
Release 1.0.0-rc.4 (#207)
Blackbaud-SteveBrush Jun 29, 2017
7fcfe14
Added to skyux builder (#204)
Blackbaud-SandhyaRajasabeson Jun 30, 2017
5454e9a
Updated package dependencies (#208)
Blackbaud-SteveBrush Jul 1, 2017
9320118
Add hash routing option for easy mode. (#206)
Blackbaud-AdamHickey Jul 3, 2017
3846c64
Updates rc5 (#209)
Blackbaud-PatrickOFriel Jul 3, 2017
7c58a14
Capitalize Angular. (#211)
blackbaud-johnly Jul 3, 2017
f7c24e9
Wrote failing test. Then made config property public for template (#…
Jul 5, 2017
d3b2b5e
Merge branch 'rc-ng4-upgrade' into feature-skyux-lint
Blackbaud-SteveBrush Jul 20, 2017
29ec11d
Merge branch 'master' into feature-skyux-lint
Blackbaud-SteveBrush Jul 20, 2017
6be7ba4
Added skyux lint files
Blackbaud-SteveBrush Jul 20, 2017
69def38
Update CHANGELOG.md
Blackbaud-SteveBrush Jul 20, 2017
7ebf50a
Updated unit tests
Blackbaud-SteveBrush Jul 20, 2017
b31d875
Merge branch 'feature-skyux-lint' of https://github.com/blackbaud/sky…
Blackbaud-SteveBrush Jul 20, 2017
b3d97be
Updated unit tests
Blackbaud-SteveBrush Jul 20, 2017
d918a48
Fixed e2e test
Blackbaud-SteveBrush Jul 20, 2017
931d9ff
Fixed e2e tests
Blackbaud-SteveBrush Jul 21, 2017
b186d13
Update build.js
Blackbaud-SteveBrush Jul 21, 2017
da8467d
Merge branch 'master' into feature-skyux-lint
Blackbaud-SteveBrush Jul 24, 2017
6294917
Merge branch 'master' into feature-skyux-lint
Blackbaud-SteveBrush Jul 25, 2017
da33ec8
Added colors to logger
Blackbaud-SteveBrush Jul 25, 2017
d7eb664
Updated linter result
Blackbaud-SteveBrush Jul 25, 2017
0aa68d8
Merged conflicts
Blackbaud-SteveBrush Jul 25, 2017
3525656
Added error log after karma reporter
Blackbaud-SteveBrush Jul 25, 2017
2d4b2f8
Update test.js
Blackbaud-SteveBrush Jul 25, 2017
68d8193
Merge branch 'master' into feature-skyux-lint
Blackbaud-SteveBrush Jul 25, 2017
67e570c
Added errors to linter result
Blackbaud-SteveBrush Jul 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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