Replaced stream queue

This commit is contained in:
alexjanousekGSA
2024-08-08 14:01:05 -06:00
parent cc310d8a23
commit 25f75a98ec
2 changed files with 10 additions and 27 deletions

View File

@@ -5,17 +5,12 @@
// 1. LIBRARIES // 1. LIBRARIES
// - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - -
const { src, pipe, dest, series, parallel, watch } = require('gulp'); const { src, dest, series, parallel, watch } = require('gulp');
const rollupPluginCommonjs = require('rollup-plugin-commonjs'); const rollupPluginCommonjs = require('rollup-plugin-commonjs');
const rollupPluginNodeResolve = require('rollup-plugin-node-resolve'); const rollupPluginNodeResolve = require('rollup-plugin-node-resolve');
const streamqueue = require('streamqueue'); const gulpMerge = require('gulp-merge');
const stylish = require('jshint-stylish'); const stylish = require('jshint-stylish');
const uswds = require("@uswds/compile"); const uswds = require("@uswds/compile");
const log = require('console-log-level')({
level: 'info'
});
log.info('Testing logging during gulp task.');
const plugins = {}; const plugins = {};
plugins.addSrc = require('gulp-add-src'); plugins.addSrc = require('gulp-add-src');
@@ -24,7 +19,7 @@ plugins.cleanCSS = require('gulp-clean-css');
plugins.concat = require('gulp-concat'); plugins.concat = require('gulp-concat');
plugins.jshint = require('gulp-jshint'); plugins.jshint = require('gulp-jshint');
plugins.prettyerror = require('gulp-prettyerror'); plugins.prettyerror = require('gulp-prettyerror');
plugins.rollup = require('gulp-better-rollup') plugins.rollup = require('gulp-better-rollup');
plugins.uglify = require('gulp-uglify'); plugins.uglify = require('gulp-uglify');
// 2. CONFIGURATION // 2. CONFIGURATION
@@ -37,13 +32,11 @@ const paths = {
govuk_frontend: 'node_modules/govuk-frontend/' govuk_frontend: 'node_modules/govuk-frontend/'
}; };
// Rewrite /static prefix for URLs in CSS files // Rewrite /static prefix for URLs in CSS files
let staticPathMatcher = new RegExp('^\/static\/'); let staticPathMatcher = new RegExp('^\/static\/')
if (process.env.NOTIFY_ENVIRONMENT == 'development') { // pass through if on development if (process.env.NOTIFY_ENVIRONMENT == 'development') { // pass through if on development
staticPathMatcher = url => url; staticPathMatcher = url => url;
} }
// 3. TASKS // 3. TASKS
// - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - -
@@ -64,9 +57,6 @@ const copy = {
} }
}; };
const javascripts = () => { const javascripts = () => {
// JS from third-party sources // JS from third-party sources
// We assume none of it will need to pass through Babel // We assume none of it will need to pass through Babel
@@ -103,7 +93,7 @@ const javascripts = () => {
paths.npm + 'textarea-caret/index.js', paths.npm + 'textarea-caret/index.js',
paths.npm + 'cbor-js/cbor.js', paths.npm + 'cbor-js/cbor.js',
paths.npm + 'socket.io-client/dist/socket.io.min.js', paths.npm + 'socket.io-client/dist/socket.io.min.js',
paths.npm + 'd3/dist/d3.min.js' paths.npm + 'chart.js/dist/chart.umd.js'
])); ]));
// JS local to this application // JS local to this application
@@ -131,9 +121,8 @@ const javascripts = () => {
paths.src + 'javascripts/timeoutPopup.js', paths.src + 'javascripts/timeoutPopup.js',
paths.src + 'javascripts/date.js', paths.src + 'javascripts/date.js',
paths.src + 'javascripts/loginAlert.js', paths.src + 'javascripts/loginAlert.js',
paths.src + 'javascripts/totalMessagesChart.js',
paths.src + 'javascripts/activityChart.js',
paths.src + 'javascripts/main.js', paths.src + 'javascripts/main.js',
paths.src + 'javascripts/sampleChartDashboard.js',
]) ])
.pipe(plugins.prettyerror()) .pipe(plugins.prettyerror())
.pipe(plugins.babel({ .pipe(plugins.babel({
@@ -142,13 +131,12 @@ const javascripts = () => {
// return single stream of all vinyl objects piped from the end of the vendored stream, then // return single stream of all vinyl objects piped from the end of the vendored stream, then
// those from the end of the local stream // those from the end of the local stream
return streamqueue({ objectMode: true }, vendored, local) return gulpMerge(vendored, local)
.pipe(plugins.uglify()) .pipe(plugins.uglify())
.pipe(plugins.concat('all.js')) .pipe(plugins.concat('all.js'))
.pipe(dest(paths.dist + 'javascripts/')) .pipe(dest(paths.dist + 'javascripts/'))
}; };
// Copy images // Copy images
const images = () => { const images = () => {
@@ -161,7 +149,6 @@ const images = () => {
.pipe(dest(paths.dist + 'images/')) .pipe(dest(paths.dist + 'images/'))
}; };
const watchFiles = { const watchFiles = {
javascripts: (cb) => { javascripts: (cb) => {
watch([paths.src + 'javascripts/**/*'], javascripts); watch([paths.src + 'javascripts/**/*'], javascripts);
@@ -181,7 +168,6 @@ const watchFiles = {
} }
}; };
const lint = { const lint = {
'js': (cb) => { 'js': (cb) => {
return src( return src(
@@ -193,7 +179,6 @@ const lint = {
} }
}; };
// Default: compile everything // Default: compile everything
const defaultTask = parallel( const defaultTask = parallel(
parallel( parallel(
@@ -211,7 +196,6 @@ const defaultTask = parallel(
) )
); );
// Watch for changes and re-run tasks // Watch for changes and re-run tasks
const watchForChanges = parallel( const watchForChanges = parallel(
watchFiles.javascripts, watchFiles.javascripts,
@@ -219,7 +203,6 @@ const watchForChanges = parallel(
watchFiles.self watchFiles.self
); );
exports.default = defaultTask; exports.default = defaultTask;
exports.lint = series(lint.js); exports.lint = series(lint.js);
@@ -254,5 +237,5 @@ uswds.paths.dist.theme = './app/assets/sass/uswds';
exports.init = uswds.init; exports.init = uswds.init;
exports.compile = uswds.compile; exports.compile = uswds.compile;
exports.copyAll = uswds.copyAll; exports.copyAll = uswds.copyAll;
exports.watch = uswds.watch;
exports.copyAssets = uswds.copyAssets; exports.copyAssets = uswds.copyAssets;
exports.watch = uswds.watch;

View File

@@ -30,6 +30,7 @@
"chart.js": "^4.4.3", "chart.js": "^4.4.3",
"govuk_frontend_toolkit": "^9.0.1", "govuk_frontend_toolkit": "^9.0.1",
"govuk-frontend": "2.13.0", "govuk-frontend": "2.13.0",
"gulp-merge": "^0.1.1",
"hogan": "1.0.2", "hogan": "1.0.2",
"jquery": "3.7.1", "jquery": "3.7.1",
"morphdom": "^2.7.4", "morphdom": "^2.7.4",
@@ -37,7 +38,6 @@
"query-command-supported": "1.0.0", "query-command-supported": "1.0.0",
"sass-embedded": "^1.77.8", "sass-embedded": "^1.77.8",
"socket.io-client": "^4.2.0", "socket.io-client": "^4.2.0",
"streamqueue": "^1.1.2",
"textarea-caret": "3.1.0", "textarea-caret": "3.1.0",
"timeago": "1.6.7" "timeago": "1.6.7"
}, },
@@ -51,7 +51,7 @@
"gulp-babel": "8.0.0", "gulp-babel": "8.0.0",
"gulp-better-rollup": "4.0.1", "gulp-better-rollup": "4.0.1",
"gulp-clean-css": "4.3.0", "gulp-clean-css": "4.3.0",
"gulp-concat": "2.6.1", "gulp-concat": "^2.6.1",
"gulp-include": "2.4.1", "gulp-include": "2.4.1",
"gulp-jshint": "2.1.0", "gulp-jshint": "2.1.0",
"gulp-prettyerror": "2.0.0", "gulp-prettyerror": "2.0.0",