Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump gulp-filter from 7.0.0 to 9.0.1 in /csunplugged #2322

Merged
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
88 changes: 47 additions & 41 deletions csunplugged/gulpfile.js → csunplugged/gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,55 @@
////////////////////////////////

// Gulp and package
const { src, dest, parallel, series, watch, lastRun } = require('gulp')
const pjson = require('./package.json')
import gulp from "gulp";
const { src, dest, parallel, series, watch, lastRun } = gulp;

// Package
import { readFile } from "node:fs/promises";
const pjson = JSON.parse(await readFile('./package.json'))

// Plugins
const autoprefixer = require('autoprefixer')
const browserify = require('browserify')
const browserSync = require('browser-sync').create()
const buffer = require('vinyl-buffer');
const c = require('ansi-colors')
const concat = require('gulp-concat')
const cssnano = require('cssnano')
const dependents = require('gulp-dependents')
const errorHandler = require('gulp-error-handle')
const filter = require('gulp-filter')
const gulpif = require('gulp-if');
const { hideBin } = require('yargs/helpers')
const imagemin = require('gulp-imagemin')
const log = require('fancy-log')
const pixrem = require('pixrem')
const postcss = require('gulp-postcss')
const postcssFlexbugFixes = require('postcss-flexbugs-fixes')
const reload = browserSync.reload
const sass = require('gulp-sass')(require('sass'));
const sourcemaps = require('gulp-sourcemaps')
const spawn = require('child_process').spawn
const tap = require('gulp-tap')
const terser = require('gulp-terser')
const yargs = require('yargs/yargs')
import autoprefixer from 'autoprefixer'
import browserify from 'browserify'
import browserSync from 'browser-sync'
import buffer from 'vinyl-buffer'
import c from 'ansi-colors'
const { bgRed, red } = c;
import concat from 'gulp-concat'
import cssnano from 'cssnano'
import dependents from 'gulp-dependents'
import errorHandler from 'gulp-error-handle'
import filter from 'gulp-filter'
import gulpif from 'gulp-if'
import { hideBin } from 'yargs/helpers'
import imagemin from 'gulp-imagemin'
import { error as _error } from 'fancy-log'
import pixrem from 'pixrem'
import postcss from 'gulp-postcss'
import postcssFlexbugFixes from 'postcss-flexbugs-fixes'
const { reload } = browserSync.create();
import * as dartSass from 'sass';
import gulpSass from 'gulp-sass';
const sass = gulpSass(dartSass);
import sourcemaps from 'gulp-sourcemaps'
const { init, write } = sourcemaps
import { spawn } from 'child_process'
import tap from 'gulp-tap'
import terser from 'gulp-terser'
import yargs from 'yargs/yargs'

// Arguments
const argv = yargs(hideBin(process.argv)).argv
const PRODUCTION = !!argv.production;

// Relative paths function
function pathsConfig(appName) {
this.app = `./${pjson.name}`
const vendorsRoot = 'node_modules'
const staticSourceRoot = 'static'
const staticOutputRoot = 'build'

return {
app: this.app,
app: `./${pjson.name}`,
// Source files
bootstrap_source: `${vendorsRoot}/bootstrap/scss`,
css_source: `${staticSourceRoot}/css`,
Expand Down Expand Up @@ -73,9 +80,9 @@ function pathsConfig(appName) {
var paths = pathsConfig()

function catchError(error) {
log.error(
c.bgRed('Error:'),
c.red(error)
_error(
bgRed('Error:'),
red(error)
);
this.emit('end');
}
Expand Down Expand Up @@ -114,9 +121,9 @@ const js_files_skip_optimisation = [
function css() {
return src(`${paths.css_source}/**/*.css`)
.pipe(errorHandler(catchError))
.pipe(sourcemaps.init())
.pipe(init())
.pipe(postcss(processCss))
.pipe(sourcemaps.write())
.pipe(write())
.pipe(gulpif(PRODUCTION, postcss(minifyCss))) // Minifies the result
.pipe(dest(paths.css_output))
}
Expand All @@ -132,7 +139,7 @@ function scss() {
return src(`${paths.scss_source}/**/*.scss`, { since: lastRun(scss) })
.pipe(errorHandler(catchError))
.pipe(dependents())
.pipe(sourcemaps.init())
.pipe(init())
.pipe(sass({
includePaths: [
paths.bootstrap_source,
Expand All @@ -141,7 +148,7 @@ function scss() {
sourceComments: !PRODUCTION,
}).on('error', sass.logError))
.pipe(postcss(postcss_callback))
.pipe(sourcemaps.write())
.pipe(write())
.pipe(gulpif(PRODUCTION, postcss(minifyCss))) // Minifies the result
.pipe(dest(paths.css_output))
}
Expand All @@ -154,15 +161,15 @@ function js() {
`!${paths.js_source}/modules/**/*.js`
], { since: lastRun(js) })
.pipe(errorHandler(catchError))
.pipe(sourcemaps.init())
.pipe(init())
.pipe(js_filter)
.pipe(tap(function (file) {
file.contents = browserify(file.path, { debug: true }).bundle().on('error', catchError);
}))
.pipe(buffer())
.pipe(gulpif(PRODUCTION, terser({ keep_fnames: true })))
.pipe(js_filter.restore)
.pipe(sourcemaps.write())
.pipe(write())
.pipe(dest(paths.js_output))
}

Expand Down Expand Up @@ -224,7 +231,7 @@ function watchPaths() {
}

// Generate all assets
const generateAssets = parallel(
export const generateAssets = parallel(
css,
scss,
js,
Expand All @@ -233,13 +240,12 @@ const generateAssets = parallel(
files,
fonts
)
generateAssets.displayName = "generate-assets";

// Set up dev environment
const dev = parallel(
// initBrowserSync,
watchPaths
)
// TODO: Look at cleaning build folder
exports["generate-assets"] = generateAssets
exports["dev"] = dev
exports.default = series(generateAssets, dev)
export default series(generateAssets, dev);
2 changes: 1 addition & 1 deletion csunplugged/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"gulp-concat": "2.6.1",
"gulp-dependents": "1.2.5",
"gulp-error-handle": "1.0.1",
"gulp-filter": "7.0.0",
"gulp-filter": "9.0.1",
"gulp-if": "3.0.0",
"gulp-imagemin": "7.1.0",
"gulp-postcss": "9.0.1",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
volumes:
# https://burnedikt.com/dockerized-node-development-and-mounting-node-volumes/#exclude-node_modules-from-the-mount
- ./csunplugged/package.json:/app/package.json:z
- ./csunplugged/gulpfile.js:/app/gulpfile.js:z
- ./csunplugged/gulpfile.mjs:/app/gulpfile.mjs:z
- ./csunplugged/static:/app/static:z
- ./csunplugged/build:/app/build:z
command: npm run dev
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/local/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.17.0-buster
FROM node:20-buster

ARG DOCKER_UID=1000
RUN usermod -u $DOCKER_UID node
Expand Down