Update gulp*

This commit is contained in:
2026-03-25 21:10:11 +01:00
parent 3eb40a1e26
commit be2f5755b1
10 changed files with 11225 additions and 15398 deletions
+82 -40
View File
@@ -1,34 +1,47 @@
require('source-map-support').install();
import 'source-map-support/register.js';
import fs from 'fs';
import path from 'path';
import gulp from 'gulp';
import _ from 'lodash';
import gulpif from 'gulp-if';
import rev from 'gulp-rev';
import gulpSass from 'gulp-sass';
import dartSass from 'sass';
import shell from 'gulp-shell';
import cssnano from 'gulp-cssnano';
import imagemin from 'gulp-imagemin';
import autoprefixer from 'gulp-autoprefixer';
import liveServer from 'gulp-live-server';
import sizereport from 'gulp-sizereport';
import markdownTree from 'markdown-tree';
import mocha from 'gulp-spawn-mocha';
import remapIstanbul from 'remap-istanbul/lib/gulpRemapIstanbul.js';
import { spawn } from 'child_process';
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';
import { deleteAsync } from 'del';
import config from './config.json' with { type: 'json' };
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const _ = require('lodash');
const gulpif = require('gulp-if');
const rev = require('gulp-rev');
const gulpSass = require('gulp-sass');
const dartSass = require('sass');
const shell = require('gulp-shell');
const cssnano = require('gulp-cssnano');
const imagemin = require('gulp-imagemin');
const autoprefixer = require('gulp-autoprefixer');
const liveServer = require('gulp-live-server');
const sizereport = require('gulp-sizereport');
const markdownTree = require('markdown-tree');
const del = require('del');
const mocha = require('gulp-spawn-mocha');
const remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');
const spawn = require('child_process').spawn;
const argv = require('yargs').argv;
const config = require('./config.json');
let development = true;
const stamp = Math.floor(Math.random() * 0xffffffff);
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-';
const HASH = _.range(0, 10).map(() => chars[Math.floor(Math.random() * chars.length)]).join('');
let development = true;
const sass = gulpSass(dartSass);
const argv = yargs(hideBin(process.argv))
.option('fast', { type: 'boolean', default: false })
.option('noserver', { type: 'boolean', default: false })
.option('adm', { type: 'boolean', default: false })
.option('debug', { type: 'boolean', default: false })
.option('main', { type: 'boolean', default: false })
.option('beta', { type: 'boolean', default: false })
.option('timing', { type: 'boolean', default: false })
.option('coverage', { type: 'boolean', default: false })
.option('tests', { type: 'boolean', default: false })
.option('sprites', { type: 'boolean', default: false })
.parse();
function swallowError(e) {
console.log(e.message);
this.emit('end');
@@ -56,13 +69,13 @@ const npmScript = (name, args = []) => {
return func;
};
const clean = () => del([
const clean = () => deleteAsync([
'build/*',
'temp/*',
'!temp/.gitignore',
]);
const clearnAdmin = () => del([
const clearAdmin = () => deleteAsync([
'build/assets-admin',
]);
@@ -114,17 +127,44 @@ const changelog = cb => {
};
const icons = cb => {
const root1 = path.join('node_modules', '@fortawesome', 'free-solid-svg-icons');
const root2 = path.join('node_modules', '@fortawesome', 'free-brands-svg-icons');
const fontPaths = [
path.join('node_modules', '@fortawesome', 'free-solid-svg-icons'),
path.join('node_modules', '@fortawesome', 'free-brands-svg-icons')
];
const parseIcon = pathString => {
const faCode = fs.readFileSync(pathString, 'utf8');
const exports = {};
const fakeRequire = relative => {
const splitPath = pathString.split(path.sep);
splitPath.pop();
const newPath = `${splitPath.join(path.sep)}${path.sep}${relative}.js`;
return parseIcon(newPath);
};
const fn = new Function('exports', 'require', faCode);
fn(exports, fakeRequire);
return exports;
};
const getIconCode = src => JSON.stringify(require(`./${src}`).definition);
const getIconCode = src => JSON.stringify(parseIcon(`./${src}`).definition);
const iconsTs = readFile('src/ts/client/icons.ts');
const matched = _.uniq(iconsTs.match(/\bfa[A-Z]\S*\b/g));
const icons = matched.map(m => ({
const icons = matched.map(m => {
const iconPath = (e) => path.join(e, `${m}.js`);
const paths = fontPaths.map(e => iconPath(e));
const found = paths.find(e => fs.existsSync(e));
if (!found) {
console.log(paths.join('\n'));
throw new Error(`Unable to find icon ${m}`);
}
const iconCode = getIconCode(found);
return {
name: m,
code: fs.existsSync(path.join(root1, `${m}.js`)) ? getIconCode(path.join(root1, `${m}.js`)) : getIconCode(path.join(root2, `${m}.js`)),
})).sort((a, b) => a.name.localeCompare(b.name));
const code = `/* tslint:disable */\n\n${icons.map(({ name, code }) => `export const ${name} = ${code};`).join('\n')}`;
code: iconCode
};
}).sort((a, b) => a.name.localeCompare(b.name));
const code = `/* eslint-disable */\n\n${icons.map(({ name, code }) => `export const ${name} = ${code};`).join('\n')}`;
fs.writeFile('src/ts/generated/fa-icons.ts', lintCode(code), 'utf8', cb);
};
@@ -161,7 +201,7 @@ const assetsRev = cb => {
fs.writeFile('src/ts/generated/rev.ts', lintCode(code), 'utf8', cb);
};
const assetsCopy = () => gulp.src('assets/**/*')
const assetsCopy = () => gulp.src('assets/**/*', { encoding: false })
.pipe(gulpif(!argv.fast, imagemin()))
.pipe(rev())
.pipe(gulp.dest('build/assets'))
@@ -169,7 +209,7 @@ const assetsCopy = () => gulp.src('assets/**/*')
.pipe(gulp.dest('build'));
function buildSass(name, src, dest) {
const result = () => gulp.src([src], { base: 'src' })
const result = () => gulp.src([src], { base: 'src', encoding: false })
.pipe(sass({
includePaths: ['src/styles/'],
}).on('error', sass.logError))
@@ -181,6 +221,7 @@ function buildSass(name, src, dest) {
return result;
}
const sassMain = buildSass('main', 'src/styles/style.scss', 'build/assets');
const sassInline = buildSass('inline', 'src/styles/style-inline.scss', 'build/assets');
const sassTools = buildSass('tools', 'src/styles/style-tools.scss', 'build/assets');
@@ -330,15 +371,16 @@ const spritesTask = argv.sprites ? sprites : empty;
const buildSprites = gulp.series(tsTools, sprites);
const build = gulp.series(clean, setProd, common, ts, webpackProd, sw, size);
const admin = gulp.series(clearnAdmin, setProd, sassAdmin, ts, webpackAdmin);
const admin = gulp.series(clearAdmin, setProd, sassAdmin, ts, webpackAdmin);
const dev = gulp.series(clean, spritesTask, common, gulp.parallel(serverDev, watch, watchTools));
module.exports = {
export {
music,
admin,
build,
dev,
sprites: buildSprites,
default: dev,
test: watchTests,
sprites,
tests as test
};
// gulp.watch(['build/**/*.css']).on('change', path => server.notify({ path }));
// gulp.watch(['build/**/*.js']).on('change', path => server.notify({ path }));
+11004 -15247
View File
File diff suppressed because it is too large Load Diff
+12 -12
View File
@@ -102,7 +102,7 @@
"@types/ua-parser-js": "^0.7.39",
"@types/uws": "^0.13.7",
"@types/webgl2": "^0.0.12",
"@types/yargs": "^13.0.12",
"@types/yargs": "^17.0.35",
"@typescript-eslint/eslint-plugin": "^8.57.1",
"@typescript-eslint/parser": "^8.57.1",
"ag-psd": "^6.2.0",
@@ -122,7 +122,7 @@
"connect-mongo": "^6.0.0",
"cookie-parser": "^1.4.4",
"core-js": "^3.2.1",
"del": "^5.1.0",
"del": "^8.0.1",
"delta-e": "0.0.7",
"errorhandler": "^1.5.1",
"eslint": "^5.16.0",
@@ -140,19 +140,19 @@
"frameguard": "^3.1.0",
"fs-extra": "^8.1.0",
"gif.js": "^0.2.0",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^7.0.0",
"gulp": "^5.0.1",
"gulp-autoprefixer": "^10.0.0",
"gulp-cssnano": "^2.1.3",
"gulp-if": "^3.0.0",
"gulp-imagemin": "^6.1.0",
"gulp-imagemin": "^9.2.0",
"gulp-live-server": "0.0.31",
"gulp-plumber": "^1.2.1",
"gulp-rev": "^9.0.0",
"gulp-sass": "^5.1.0",
"gulp-shell": "^0.7.1",
"gulp-rev": "^12.0.0",
"gulp-sass": "^6.0.1",
"gulp-shell": "^0.8.0",
"gulp-sizereport": "^1.2.1",
"gulp-sourcemaps": "^2.6.5",
"gulp-spawn-mocha": "^5.0.1",
"gulp-sourcemaps": "^3.0.0",
"gulp-spawn-mocha": "^6.0.0",
"howler": "^2.1.2",
"hsts": "^2.2.0",
"html-loader": "^5.1.0",
@@ -187,7 +187,7 @@
"request-promise": "^4.2.4",
"rollbar": "^2.12.2",
"rxjs": "^7.8.2",
"sass": "^1.58.3",
"sass": "^1.62.1",
"sass-loader": "^13.3.3",
"serve-favicon": "^2.5.0",
"sinon": "^7.4.1",
@@ -210,7 +210,7 @@
"webpack-merge": "^6.0.1",
"workbox-cli": "^4.3.1",
"wrapper-webpack-plugin": "^2.2.2",
"yargs": "^14.0.0",
"yargs": "^18.0.0",
"zone.js": "^0.14.2"
}
}
+35 -35
View File
@@ -1,35 +1,35 @@
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";
// @import "node_modules/bootstrap/scss/root";
// @import "node_modules/bootstrap/scss/print";
@import "node_modules/bootstrap/scss/reboot";
@import "node_modules/bootstrap/scss/type";
@import "node_modules/bootstrap/scss/images";
@import "node_modules/bootstrap/scss/code";
@import "node_modules/bootstrap/scss/grid";
@import "node_modules/bootstrap/scss/tables";
@import "node_modules/bootstrap/scss/forms";
@import "node_modules/bootstrap/scss/buttons";
@import "node_modules/bootstrap/scss/transitions";
@import "node_modules/bootstrap/scss/dropdown";
@import "node_modules/bootstrap/scss/button-group";
@import "node_modules/bootstrap/scss/input-group";
@import "node_modules/bootstrap/scss/custom-forms";
@import "node_modules/bootstrap/scss/nav";
@import "node_modules/bootstrap/scss/navbar";
// @import "node_modules/bootstrap/scss/card";
// @import "node_modules/bootstrap/scss/breadcrumb";
@import "node_modules/bootstrap/scss/pagination";
@import "node_modules/bootstrap/scss/badge";
// @import "node_modules/bootstrap/scss/jumbotron";
@import "node_modules/bootstrap/scss/alert";
@import "node_modules/bootstrap/scss/progress";
// @import "node_modules/bootstrap/scss/media";
@import "node_modules/bootstrap/scss/list-group";
@import "node_modules/bootstrap/scss/close";
@import "node_modules/bootstrap/scss/modal";
@import "node_modules/bootstrap/scss/tooltip";
@import "node_modules/bootstrap/scss/popover";
// @import "node_modules/bootstrap/scss/carousel";
@import "node_modules/bootstrap/scss/utilities";
@import "../../../node_modules/bootstrap/scss/functions";
@import "../../../node_modules/bootstrap/scss/variables";
@import "../../../node_modules/bootstrap/scss/mixins";
// @import "../../../node_modules/bootstrap/scss/root";
// @import "../../../node_modules/bootstrap/scss/print";
@import "../../../node_modules/bootstrap/scss/reboot";
@import "../../../node_modules/bootstrap/scss/type";
@import "../../../node_modules/bootstrap/scss/images";
@import "../../../node_modules/bootstrap/scss/code";
@import "../../../node_modules/bootstrap/scss/grid";
@import "../../../node_modules/bootstrap/scss/tables";
@import "../../../node_modules/bootstrap/scss/forms";
@import "../../../node_modules/bootstrap/scss/buttons";
@import "../../../node_modules/bootstrap/scss/transitions";
@import "../../../node_modules/bootstrap/scss/dropdown";
@import "../../../node_modules/bootstrap/scss/button-group";
@import "../../../node_modules/bootstrap/scss/input-group";
@import "../../../node_modules/bootstrap/scss/custom-forms";
@import "../../../node_modules/bootstrap/scss/nav";
@import "../../../node_modules/bootstrap/scss/navbar";
// @import "../../../node_modules/bootstrap/scss/card";
// @import "../../../node_modules/bootstrap/scss/breadcrumb";
@import "../../../node_modules/bootstrap/scss/pagination";
@import "../../../node_modules/bootstrap/scss/badge";
// @import "../../../node_modules/bootstrap/scss/jumbotron";
@import "../../../node_modules/bootstrap/scss/alert";
@import "../../../node_modules/bootstrap/scss/progress";
// @import "../../../node_modules/bootstrap/scss/media";
@import "../../../node_modules/bootstrap/scss/list-group";
@import "../../../node_modules/bootstrap/scss/close";
@import "../../../node_modules/bootstrap/scss/modal";
@import "../../../node_modules/bootstrap/scss/tooltip";
@import "../../../node_modules/bootstrap/scss/popover";
// @import "../../../node_modules/bootstrap/scss/carousel";
@import "../../../node_modules/bootstrap/scss/utilities";
+35 -35
View File
@@ -1,35 +1,35 @@
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";
// @import "node_modules/bootstrap/scss/root";
// @import "node_modules/bootstrap/scss/print";
@import "node_modules/bootstrap/scss/reboot";
@import "node_modules/bootstrap/scss/type";
@import "node_modules/bootstrap/scss/images";
@import "node_modules/bootstrap/scss/code";
@import "node_modules/bootstrap/scss/grid";
// @import "node_modules/bootstrap/scss/tables";
@import "node_modules/bootstrap/scss/forms";
@import "node_modules/bootstrap/scss/buttons";
@import "node_modules/bootstrap/scss/transitions";
@import "node_modules/bootstrap/scss/dropdown";
@import "node_modules/bootstrap/scss/button-group";
@import "node_modules/bootstrap/scss/input-group";
@import "node_modules/bootstrap/scss/custom-forms";
@import "node_modules/bootstrap/scss/nav";
@import "node_modules/bootstrap/scss/navbar";
// @import "node_modules/bootstrap/scss/card";
// @import "node_modules/bootstrap/scss/breadcrumb";
// @import "node_modules/bootstrap/scss/pagination";
@import "node_modules/bootstrap/scss/badge";
// @import "node_modules/bootstrap/scss/jumbotron";
@import "node_modules/bootstrap/scss/alert";
// @import "node_modules/bootstrap/scss/progress";
// @import "node_modules/bootstrap/scss/media";
@import "node_modules/bootstrap/scss/list-group";
// @import "node_modules/bootstrap/scss/close";
@import "node_modules/bootstrap/scss/modal";
@import "node_modules/bootstrap/scss/tooltip";
@import "node_modules/bootstrap/scss/popover";
// @import "node_modules/bootstrap/scss/carousel";
@import "node_modules/bootstrap/scss/utilities";
@import "../../../node_modules/bootstrap/scss/functions";
@import "../../../node_modules/bootstrap/scss/variables";
@import "../../../node_modules/bootstrap/scss/mixins";
// @import "../../../node_modules/bootstrap/scss/root";
// @import "../../../node_modules/bootstrap/scss/print";
@import "../../../node_modules/bootstrap/scss/reboot";
@import "../../../node_modules/bootstrap/scss/type";
@import "../../../node_modules/bootstrap/scss/images";
@import "../../../node_modules/bootstrap/scss/code";
@import "../../../node_modules/bootstrap/scss/grid";
// @import "../../../node_modules/bootstrap/scss/tables";
@import "../../../node_modules/bootstrap/scss/forms";
@import "../../../node_modules/bootstrap/scss/buttons";
@import "../../../node_modules/bootstrap/scss/transitions";
@import "../../../node_modules/bootstrap/scss/dropdown";
@import "../../../node_modules/bootstrap/scss/button-group";
@import "../../../node_modules/bootstrap/scss/input-group";
@import "../../../node_modules/bootstrap/scss/custom-forms";
@import "../../../node_modules/bootstrap/scss/nav";
@import "../../../node_modules/bootstrap/scss/navbar";
// @import "../../../node_modules/bootstrap/scss/card";
// @import "../../../node_modules/bootstrap/scss/breadcrumb";
// @import "../../../node_modules/bootstrap/scss/pagination";
@import "../../../node_modules/bootstrap/scss/badge";
// @import "../../../node_modules/bootstrap/scss/jumbotron";
@import "../../../node_modules/bootstrap/scss/alert";
// @import "../../../node_modules/bootstrap/scss/progress";
// @import "../../../node_modules/bootstrap/scss/media";
@import "../../../node_modules/bootstrap/scss/list-group";
// @import "../../../node_modules/bootstrap/scss/close";
@import "../../../node_modules/bootstrap/scss/modal";
@import "../../../node_modules/bootstrap/scss/tooltip";
@import "../../../node_modules/bootstrap/scss/popover";
// @import "../../../node_modules/bootstrap/scss/carousel";
@import "../../../node_modules/bootstrap/scss/utilities";
+3 -3
View File
@@ -202,6 +202,6 @@ $flag-black: #3e4347;
$flag-yellow: #ffe62e;
$flag-green: #00aa00;
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";
@import "../../../node_modules/bootstrap/scss/functions";
@import "../../../node_modules/bootstrap/scss/variables";
@import "../../../node_modules/bootstrap/scss/mixins";
+1 -1
View File
@@ -81,7 +81,7 @@ function getLabel(arg: LogArgument | undefined) {
if (typeof arg === 'string') {
return arg;
} else if (arg && 'message' in arg) {
return arg.message + (arg.stack || '');
return (arg as any).message + (arg.stack || '');
} else {
return arg ? arg.toString() : '';
}
+14 -1
View File
@@ -6,7 +6,20 @@ import 'core-js/stable/promise/finally';
import 'reflect-metadata';
import * as Bluebird from 'bluebird';
import * as fs from 'fs';
import { argv } from 'yargs';
import * as yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const argv = (yargs as any)(hideBin(process.argv))
.option('beta', {
type: 'boolean',
default: false
})
.option('tools', {
type: 'boolean',
default: false
})
.parseSync();
(global as any).DEVELOPMENT = process.env.NODE_ENV !== 'production';
(global as any).BETA = !!argv.beta;
+16 -1
View File
@@ -1,5 +1,20 @@
import { argv } from 'yargs';
import { ServerConfig } from '../common/adminInterfaces';
import * as yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const argv = (yargs as any)(hideBin(process.argv))
.option('port', { type: 'string' })
.option('login', { type: 'boolean', default: false })
.option('admin', { type: 'boolean', default: false })
.option('standaloneadmin', { type: 'boolean', default: false })
.option('game', { type: 'string', default: DEVELOPMENT })
.option('superadmin', { type: 'string' })
.option('users', { type: 'boolean', default: false })
.option('tools', { type: 'boolean', default: false })
.option('webpack', { type: 'boolean', default: false })
.option('local', { type: 'boolean', default: false })
.option('nocleanup', { type: 'boolean', default: false })
.parse();
export interface AppConfig {
title: string;
+2 -2
View File
@@ -4,7 +4,7 @@ import '../server/boot';
import * as mongoose from 'mongoose';
import * as fs from 'fs';
import * as path from 'path';
import * as del from 'del';
import { deleteAsync } from 'del';
import { once, mapValues } from 'lodash';
import { spawnSync } from 'child_process';
import { createStubInstance, SinonStubbedInstance, stub } from 'sinon';
@@ -51,7 +51,7 @@ export function generateDiff(expectedPath: string, actualPath: string) {
}
export async function clearCompareResults(group: string) {
await del([pathTo('tools', 'temp', group, '*.png').replace(/\\/g, '/')]);
await deleteAsync([pathTo('tools', 'temp', group, '*.png').replace(/\\/g, '/')]);
}
export function compareCanvases(