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

Exposing the log flag and integrating with better logging plugin #357

Merged
merged 18 commits into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cli/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const path = require('path');
const spawn = require('cross-spawn');
const selenium = require('selenium-standalone');
const protractorLauncher = require('protractor/built/launcher');
const logger = require('@blackbaud/skyux-logger');

const build = require('./build');
const server = require('./utils/server');
const logger = require('../utils/logger');
const configResolver = require('./utils/config-resolver');

// Disable this to quiet the output
Expand Down
5 changes: 3 additions & 2 deletions cli/pact.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
*/
function pact(command, argv) {
const async = require('async');
const configResolver = require('./utils/config-resolver');
const karma = require('karma');
const Server = karma.Server;
const portfinder = require('portfinder');
const url = require('url');
const logger = require('../utils/logger');
const logger = require('@blackbaud/skyux-logger');

const configResolver = require('./utils/config-resolver');
const tsLinter = require('./utils/ts-linter');
const skyPagesConfigUtil = require('../config/sky-pages/sky-pages.config');
const pactServers = require('../utils/pact-servers');
Expand Down
3 changes: 1 addition & 2 deletions cli/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
'use strict';

const portfinder = require('portfinder');

const logger = require('../utils/logger');
const logger = require('@blackbaud/skyux-logger');
const assetsProcessor = require('../lib/assets-processor');

/**
Expand Down
2 changes: 1 addition & 1 deletion cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @name test
*/
function test(command, argv) {
const logger = require('../utils/logger');
const logger = require('@blackbaud/skyux-logger');
const Server = require('karma').Server;
const tsLinter = require('./utils/ts-linter');
const configResolver = require('./utils/config-resolver');
Expand Down
2 changes: 1 addition & 1 deletion cli/utils/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const util = require('util');
const open = require('open');
const logger = require('winston');
const logger = require('@blackbaud/skyux-logger');
const hostUtils = require('../../utils/host-utils');
const skyPagesConfigUtil = require('../../config/sky-pages/sky-pages.config');

Expand Down
2 changes: 1 addition & 1 deletion cli/utils/config-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const path = require('path');
const glob = require('glob');
const fs = require('fs-extra');
const logger = require('winston');
const logger = require('@blackbaud/skyux-logger');

const skyPagesConfigUtil = require('../../config/sky-pages/sky-pages.config');

Expand Down
8 changes: 2 additions & 6 deletions cli/utils/run-compiler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*jshint node: true*/
'use strict';

const logger = require('../../utils/logger');
const logger = require('@blackbaud/skyux-logger');

const runCompiler = (webpack, config) => {
const compiler = webpack(config);
Expand All @@ -24,11 +24,7 @@ const runCompiler = (webpack, config) => {
logger.warn(jsonStats.warnings);
}

logger.info(stats.toString({
chunks: false,
colors: false
}));

// Normal logging is handled by SimpleProgressWebpackPlugin in common.webpack.config.js
resolve(stats);
});
});
Expand Down
2 changes: 1 addition & 1 deletion cli/utils/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

const fs = require('fs');
const path = require('path');
const logger = require('winston');
const portfinder = require('portfinder');
const express = require('express');
const https = require('https');
const cors = require('cors');
const logger = require('@blackbaud/skyux-logger');

const app = express();

Expand Down
2 changes: 1 addition & 1 deletion cli/utils/ts-linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
'use strict';

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

const flags = [
'--type-check',
Expand Down
2 changes: 1 addition & 1 deletion cli/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const path = require('path');
const logger = require('../utils/logger');
const logger = require('@blackbaud/skyux-logger');

/**
* Returns the version from package.json.
Expand Down
2 changes: 1 addition & 1 deletion config/karma/pact.karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* @param {Object} config
*/
function getConfig(config) {
const logger = require('@blackbaud/skyux-logger');
const minimist = require('minimist');
const argv = minimist(process.argv.slice(2));
require(`./${argv.watch ? 'watch' : 'test'}.karma.conf`)(config);
let skyPagesConfig = require('../sky-pages/sky-pages.config').getSkyPagesConfig(argv._[0]);
let testWebpackConfig = require('../webpack/test.webpack.config');
const logger = require('../../utils/logger');
const path = require('path');
const pactServers = require('../../utils/pact-servers');

Expand Down
2 changes: 1 addition & 1 deletion config/sky-pages/sky-pages.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const fs = require('fs-extra');
const path = require('path');
const merge = require('../../utils/merge');
const logger = require('../../utils/logger');
const logger = require('@blackbaud/skyux-logger');

/**
* Resolves a path given a root path and an array-like arguments object.
Expand Down
105 changes: 64 additions & 41 deletions config/webpack/common.webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*jslint node: true */
'use strict';

const logger = require('@blackbaud/skyux-logger');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
Expand All @@ -20,6 +21,18 @@ function outPath() {
return skyPagesConfigUtil.outPath.apply(skyPagesConfigUtil, arguments);
}

function getLogFormat(skyPagesConfig, argv) {
if (argv.hasOwnProperty('logFormat')) {
return argv.logFormat;
}

if (skyPagesConfig.runtime.command === 'serve' || argv.serve) {
return 'compact';
}

return 'expanded';
}

/**
* Called when loaded via require.
* @name getWebpackConfig
Expand All @@ -36,6 +49,8 @@ function getWebpackConfig(skyPagesConfig, argv = {}) {
let alias = aliasBuilder.buildAliasList(skyPagesConfig);

const outConfigMode = skyPagesConfig && skyPagesConfig.skyux && skyPagesConfig.skyux.mode;
const logFormat = getLogFormat(skyPagesConfig, argv);

let appPath;

switch (outConfigMode) {
Expand All @@ -48,6 +63,53 @@ function getWebpackConfig(skyPagesConfig, argv = {}) {
break;
}

let plugins = [
// Some properties are required on the root object passed to HtmlWebpackPlugin
new HtmlWebpackPlugin({
template: skyPagesConfig.runtime.app.template,
inject: skyPagesConfig.runtime.app.inject,
runtime: skyPagesConfig.runtime,
skyux: skyPagesConfig.skyux
}),

new CommonsChunkPlugin({
name: ['skyux', 'vendor', 'polyfills']
}),

new webpack.DefinePlugin({
'skyPagesConfig': JSON.stringify(skyPagesConfig)
}),

new LoaderOptionsPlugin({
options: {
context: __dirname,
skyPagesConfig: skyPagesConfig
}
}),

new ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)@angular/,
spaPath('src'),
{}
),

// Webpack 2 behavior does not correctly return non-zero exit code.
new ProcessExitCode(),

new OutputKeepAlivePlugin({
enabled: argv['output-keep-alive']
})
];

// Supporting a custom logging type of none
if (logFormat !== 'none') {
plugins.push(new SimpleProgressWebpackPlugin({
format: logFormat,
color: logger.logColor
}));
}

return {
entry: {
polyfills: [outPath('src', 'polyfills.ts')],
Expand Down Expand Up @@ -111,46 +173,7 @@ function getWebpackConfig(skyPagesConfig, argv = {}) {
}
]
},
plugins: [
// Some properties are required on the root object passed to HtmlWebpackPlugin
new HtmlWebpackPlugin({
template: skyPagesConfig.runtime.app.template,
inject: skyPagesConfig.runtime.app.inject,
runtime: skyPagesConfig.runtime,
skyux: skyPagesConfig.skyux
}),

new CommonsChunkPlugin({
name: ['skyux', 'vendor', 'polyfills']
}),

new webpack.DefinePlugin({
'skyPagesConfig': JSON.stringify(skyPagesConfig)
}),

new ProgressBarPlugin(),

new LoaderOptionsPlugin({
options: {
context: __dirname,
skyPagesConfig: skyPagesConfig
}
}),

new ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)@angular/,
spaPath('src'),
{}
),

// Webpack 2 behavior does not correctly return non-zero exit code.
new ProcessExitCode(),

new OutputKeepAlivePlugin({
enabled: argv['output-keep-alive']
})
]
plugins
};
}

Expand Down
9 changes: 4 additions & 5 deletions config/webpack/serve.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlugin');

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

/**
Expand All @@ -28,14 +27,13 @@ function getWebpackConfig(argv, skyPagesConfig) {
let launched = false;
this.plugin('done', (stats) => {
if (!launched) {
logger.info('SKY UX builder is ready.');
launched = true;
browser(argv, skyPagesConfig, stats, this.options.devServer.port);
}
});
}

const common = require('./common.webpack.config').getWebpackConfig(skyPagesConfig);
const common = require('./common.webpack.config').getWebpackConfig(skyPagesConfig, argv);

return webpackMerge(common, {
watch: true,
Expand All @@ -51,7 +49,8 @@ function getWebpackConfig(argv, skyPagesConfig) {
// an aliased file. Webpack will still throw an error when a module
// cannot be resolved via a file path or alias.
ignoreDiagnostics: [2307],
transpileOnly: true
transpileOnly: true,
silent: true
}
},
{
Expand All @@ -65,6 +64,7 @@ function getWebpackConfig(argv, skyPagesConfig) {
devServer: {
compress: true,
inline: true,
stats: false,
hot: argv.hmr,
contentBase: path.join(process.cwd(), 'src', 'app'),
headers: {
Expand All @@ -73,7 +73,6 @@ function getWebpackConfig(argv, skyPagesConfig) {
historyApiFallback: {
index: skyPagesConfigUtil.getAppBase(skyPagesConfig)
},
stats: 'minimal',
https: {
key: fs.readFileSync(path.join(__dirname, '../../ssl/server.key')),
cert: fs.readFileSync(path.join(__dirname, '../../ssl/server.crt'))
Expand Down
5 changes: 3 additions & 2 deletions e2e/shared/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function prepareBuild(config) {

return new Promise((resolve, reject) => {
rimrafPromise(path.join(tmp, 'dist'))
.then(() => exec(`node`, [cliPath, `build`], cwdOpts))
.then(() => exec(`node`, [cliPath, `build`, `--log`, `none`], cwdOpts))
.then(serve)
.then(resolve)
.catch(err => reject(err));
Expand Down Expand Up @@ -209,7 +209,8 @@ function writeConfigServe(port) {
});

writeConfig(skyuxConfigWithPort);
webpackServer = childProcessSpawn(`node`, [cliPath, `serve`, `-l`, `none`], cwdOpts);
const args = [cliPath, `serve`, `-l`, `none`, `--log`, `none`];
webpackServer = childProcessSpawn(`node`, args, cwdOpts);
resetConfig();
resolve();
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/skyux-e2e.e2e-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const common = require('./shared/common');

function validateTestRun(done) {
common.exec(`node`, [common.cliPath, `e2e`], common.cwdOpts)
common.exec(`node`, [common.cliPath, `e2e`, `--log`, `none`], common.cwdOpts)
.then(exit => {
expect(exit).toEqual(0);
done();
Expand Down
2 changes: 1 addition & 1 deletion lib/a11y-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const axeBuilder = require('axe-webdriverjs');
const logger = require('../utils/logger');
const logger = require('@blackbaud/skyux-logger');
const axeConfig = require('../config/axe/axe.config');
const { browser } = require('protractor');

Expand Down
2 changes: 1 addition & 1 deletion loader/sky-processor/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*jshint node: true*/
'use strict';

const logger = require('../../utils/logger');
const logger = require('@blackbaud/skyux-logger');
let plugins;

const getPluginContents = (skyPagesConfig) => {
Expand Down
Loading