From ab213dd0a1e51699aae492f8b546e4a311fcb97d Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Sun, 15 Aug 2021 08:35:57 +0000 Subject: Initial plumbing and conversion of a simple javascript to typescript (#1790) * initial conversion of a simple script * Moved some of the 'gulp' and related npm modules from being runtime dependencies to development dependencies. --- gulpfile.babel.js | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'gulpfile.babel.js') diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 08cc34b63..1f3c42a3d 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -14,6 +14,7 @@ import sassVariables from 'gulp-sass-variables'; import { removeSync, outputJson } from 'fs-extra'; import kebabCase from 'kebab-case'; import hexRgb from 'hex-rgb'; +import ts from 'gulp-typescript'; import * as buildInfo from 'preval-build-info'; import config from './package.json'; @@ -29,6 +30,8 @@ const isDevBuild = process.env.NODE_ENV === 'development'; const getTargetEnv = isDevBuild ? 'development' : 'production'; +const tsProject = ts.createProject('tsconfig.json'); + const styleConfig = Object.keys(rawStyleConfig).map(key => { const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]); return { @@ -67,7 +70,7 @@ const paths = { src: 'src/styles/vertical.scss', dest: 'build/styles', }, - scripts: { + javascripts: { src: 'src/**/*.js', dest: 'build/', watch: [ @@ -75,6 +78,14 @@ const paths = { 'src/**/*.js', ], }, + typescripts: { + src: 'src/**/*.ts', + dest: 'build/', + watch: [ + // 'packages/**/*.ts', + 'src/**/*.ts', + ], + }, packages: { watch: 'packages/**/*', // dest: 'build/', @@ -121,9 +132,11 @@ export function mvSrc() { [ `${paths.src}/*`, `${paths.src}/*/**`, - `!${paths.scripts.watch[1]}`, + `!${paths.javascripts.watch[1]}`, + `!${paths.typescripts.watch[1]}`, `!${paths.src}/styles/**`, `!${paths.src}/**/*.js`, + `!${paths.src}/**/*.ts`, ], { since: gulp.lastRun(mvSrc) }, ) @@ -226,16 +239,39 @@ export function verticalStyle() { .pipe(connect.reload()); } -export function scripts() { +export function processJavascripts() { return gulp - .src(paths.scripts.src, { since: gulp.lastRun(scripts) }) + .src( + [ + paths.javascripts.src, + ], + { since: gulp.lastRun(processJavascripts) }) + .pipe( + babel({ + comments: false, + }), + ) + .pipe(gulpIf(!isDevBuild, uglify())) // Only uglify in production to speed up dev builds + .pipe(gulp.dest(paths.javascripts.dest)) + .pipe(connect.reload()); +} + +export function processTypescripts() { + return gulp + .src( + [ + paths.typescripts.src, + ], + { since: gulp.lastRun(processTypescripts) }) + .pipe(tsProject()) + .js .pipe( babel({ comments: false, }), ) .pipe(gulpIf(!isDevBuild, uglify())) // Only uglify in production to speed up dev builds - .pipe(gulp.dest(paths.scripts.dest)) + .pipe(gulp.dest(paths.typescripts.dest)) .pipe(connect.reload()); } @@ -244,9 +280,10 @@ export function watch() { gulp.watch(paths.styles.watch, styles); gulp.watch(paths.verticalStyle.src, verticalStyle); - gulp.watch([paths.src, `${paths.scripts.src}`, `${paths.styles.src}`], mvSrc); + gulp.watch([paths.src, `${paths.javascripts.src}`, `${paths.styles.src}`], mvSrc); - gulp.watch(paths.scripts.watch, scripts); + gulp.watch(paths.javascripts.watch, processJavascripts); + gulp.watch(paths.typescripts.watch, processTypescripts); } export function webserver() { @@ -270,7 +307,7 @@ export function recipeInfo() { const build = gulp.series( clean, gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages, exportBuildInfo), - gulp.parallel(html, scripts, styles, verticalStyle, recipes, recipeInfo), + gulp.parallel(html, processJavascripts, processTypescripts, styles, verticalStyle, recipes, recipeInfo), ); export { build }; -- cgit v1.2.3-54-g00ecf From fea2003b490af35b987d35ae97689300982befd8 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sun, 15 Aug 2021 14:38:07 +0530 Subject: chore: npm upgrades --- gulpfile.babel.js | 6 +- package-lock.json | 197 ++++++++++++++++++++++++++++-------------------------- package.json | 18 ++--- 3 files changed, 114 insertions(+), 107 deletions(-) (limited to 'gulpfile.babel.js') diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 1f3c42a3d..c6fe6975a 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -245,7 +245,8 @@ export function processJavascripts() { [ paths.javascripts.src, ], - { since: gulp.lastRun(processJavascripts) }) + { since: gulp.lastRun(processJavascripts) }, + ) .pipe( babel({ comments: false, @@ -262,7 +263,8 @@ export function processTypescripts() { [ paths.typescripts.src, ], - { since: gulp.lastRun(processTypescripts) }) + { since: gulp.lastRun(processTypescripts) }, + ) .pipe(tsProject()) .js .pipe( diff --git a/package-lock.json b/package-lock.json index 41afd1f19..f810e8bc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1685,9 +1685,9 @@ } }, "@babel/register": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.14.5.tgz", - "integrity": "sha512-TjJpGz/aDjFGWsItRBQMOFTrmTI9tr79CHOK+KIvLeCkbxuOAk2M5QHjvruIMGoo9OuccMh5euplPzc5FjAKGg==", + "version": "7.15.3", + "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.15.3.tgz", + "integrity": "sha512-mj4IY1ZJkorClxKTImccn4T81+UKTo4Ux0+OFSV9hME1ooqS9UV+pJ6BjD0qXPK4T3XW/KNa79XByjeEMZz+fw==", "dev": true, "requires": { "clone-deep": "^4.0.1", @@ -6817,13 +6817,13 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.29.0.tgz", - "integrity": "sha512-eiREtqWRZ8aVJcNru7cT/AMVnYd9a2UHsfZT8MR1dW3UUEg6jDv9EQ9Cq4CUPZesyQ58YUpoAADGv71jY8RwgA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.29.1.tgz", + "integrity": "sha512-AHqIU+SqZZgBEiWOrtN94ldR3ZUABV5dUG94j8Nms9rQnHFc8fvDOue/58K4CFz6r8OtDDc35Pw9NQPWo0Ayrw==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.29.0", - "@typescript-eslint/scope-manager": "4.29.0", + "@typescript-eslint/experimental-utils": "4.29.1", + "@typescript-eslint/scope-manager": "4.29.1", "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.1.0", @@ -6832,43 +6832,43 @@ }, "dependencies": { "@typescript-eslint/experimental-utils": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.29.0.tgz", - "integrity": "sha512-FpNVKykfeaIxlArLUP/yQfv/5/3rhl1ov6RWgud4OgbqWLkEq7lqgQU9iiavZRzpzCRQV4XddyFz3wFXdkiX9w==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.29.1.tgz", + "integrity": "sha512-kl6QG6qpzZthfd2bzPNSJB2YcZpNOrP6r9jueXupcZHnL74WiuSjaft7WSu17J9+ae9zTlk0KJMXPUj0daBxMw==", "dev": true, "requires": { "@types/json-schema": "^7.0.7", - "@typescript-eslint/scope-manager": "4.29.0", - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/typescript-estree": "4.29.0", + "@typescript-eslint/scope-manager": "4.29.1", + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/typescript-estree": "4.29.1", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" } }, "@typescript-eslint/scope-manager": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.0.tgz", - "integrity": "sha512-HPq7XAaDMM3DpmuijxLV9Io8/6pQnliiXMQUcAdjpJJSR+fdmbD/zHCd7hMkjJn04UQtCQBtshgxClzg6NIS2w==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.1.tgz", + "integrity": "sha512-Hzv/uZOa9zrD/W5mftZa54Jd5Fed3tL6b4HeaOpwVSabJK8CJ+2MkDasnX/XK4rqP5ZTWngK1ZDeCi6EnxPQ7A==", "dev": true, "requires": { - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/visitor-keys": "4.29.0" + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/visitor-keys": "4.29.1" } }, "@typescript-eslint/types": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.0.tgz", - "integrity": "sha512-2YJM6XfWfi8pgU2HRhTp7WgRw78TCRO3dOmSpAvIQ8MOv4B46JD2chnhpNT7Jq8j0APlIbzO1Bach734xxUl4A==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.1.tgz", + "integrity": "sha512-Jj2yu78IRfw4nlaLtKjVaGaxh/6FhofmQ/j8v3NXmAiKafbIqtAPnKYrf0sbGjKdj0hS316J8WhnGnErbJ4RCA==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.0.tgz", - "integrity": "sha512-8ZpNHDIOyqzzgZrQW9+xQ4k5hM62Xy2R4RPO3DQxMc5Rq5QkCdSpk/drka+DL9w6sXNzV5nrdlBmf8+x495QXQ==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.1.tgz", + "integrity": "sha512-lIkkrR9E4lwZkzPiRDNq0xdC3f2iVCUjw/7WPJ4S2Sl6C3nRWkeE1YXCQ0+KsiaQRbpY16jNaokdWnm9aUIsfw==", "dev": true, "requires": { - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/visitor-keys": "4.29.0", + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/visitor-keys": "4.29.1", "debug": "^4.3.1", "globby": "^11.0.3", "is-glob": "^4.0.1", @@ -6877,12 +6877,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.0.tgz", - "integrity": "sha512-LoaofO1C/jAJYs0uEpYMXfHboGXzOJeV118X4OsZu9f7rG7Pr9B3+4HTU8+err81rADa4xfQmAxnRnPAI2jp+Q==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.1.tgz", + "integrity": "sha512-zLqtjMoXvgdZY/PG6gqA73V8BjqPs4af1v2kiiETBObp+uC6gRYnJLmJHxC0QyUrrHDLJPIWNYxoBV3wbcRlag==", "dev": true, "requires": { - "@typescript-eslint/types": "4.29.0", + "@typescript-eslint/types": "4.29.1", "eslint-visitor-keys": "^2.0.0" } }, @@ -6912,41 +6912,41 @@ } }, "@typescript-eslint/parser": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.0.tgz", - "integrity": "sha512-+92YRNHFdXgq+GhWQPT2bmjX09X7EH36JfgN2/4wmhtwV/HPxozpCNst8jrWcngLtEVd/4zAwA6BKojAlf+YqA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.1.tgz", + "integrity": "sha512-3fL5iN20hzX3Q4OkG7QEPFjZV2qsVGiDhEwwh+EkmE/w7oteiOvUNzmpu5eSwGJX/anCryONltJ3WDmAzAoCMg==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.29.0", - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/typescript-estree": "4.29.0", + "@typescript-eslint/scope-manager": "4.29.1", + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/typescript-estree": "4.29.1", "debug": "^4.3.1" }, "dependencies": { "@typescript-eslint/scope-manager": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.0.tgz", - "integrity": "sha512-HPq7XAaDMM3DpmuijxLV9Io8/6pQnliiXMQUcAdjpJJSR+fdmbD/zHCd7hMkjJn04UQtCQBtshgxClzg6NIS2w==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.1.tgz", + "integrity": "sha512-Hzv/uZOa9zrD/W5mftZa54Jd5Fed3tL6b4HeaOpwVSabJK8CJ+2MkDasnX/XK4rqP5ZTWngK1ZDeCi6EnxPQ7A==", "dev": true, "requires": { - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/visitor-keys": "4.29.0" + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/visitor-keys": "4.29.1" } }, "@typescript-eslint/types": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.0.tgz", - "integrity": "sha512-2YJM6XfWfi8pgU2HRhTp7WgRw78TCRO3dOmSpAvIQ8MOv4B46JD2chnhpNT7Jq8j0APlIbzO1Bach734xxUl4A==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.1.tgz", + "integrity": "sha512-Jj2yu78IRfw4nlaLtKjVaGaxh/6FhofmQ/j8v3NXmAiKafbIqtAPnKYrf0sbGjKdj0hS316J8WhnGnErbJ4RCA==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.0.tgz", - "integrity": "sha512-8ZpNHDIOyqzzgZrQW9+xQ4k5hM62Xy2R4RPO3DQxMc5Rq5QkCdSpk/drka+DL9w6sXNzV5nrdlBmf8+x495QXQ==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.1.tgz", + "integrity": "sha512-lIkkrR9E4lwZkzPiRDNq0xdC3f2iVCUjw/7WPJ4S2Sl6C3nRWkeE1YXCQ0+KsiaQRbpY16jNaokdWnm9aUIsfw==", "dev": true, "requires": { - "@typescript-eslint/types": "4.29.0", - "@typescript-eslint/visitor-keys": "4.29.0", + "@typescript-eslint/types": "4.29.1", + "@typescript-eslint/visitor-keys": "4.29.1", "debug": "^4.3.1", "globby": "^11.0.3", "is-glob": "^4.0.1", @@ -6955,12 +6955,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.0.tgz", - "integrity": "sha512-LoaofO1C/jAJYs0uEpYMXfHboGXzOJeV118X4OsZu9f7rG7Pr9B3+4HTU8+err81rADa4xfQmAxnRnPAI2jp+Q==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.1.tgz", + "integrity": "sha512-zLqtjMoXvgdZY/PG6gqA73V8BjqPs4af1v2kiiETBObp+uC6gRYnJLmJHxC0QyUrrHDLJPIWNYxoBV3wbcRlag==", "dev": true, "requires": { - "@typescript-eslint/types": "4.29.0", + "@typescript-eslint/types": "4.29.1", "eslint-visitor-keys": "^2.0.0" } }, @@ -13901,36 +13901,30 @@ "dev": true }, "eslint-import-resolver-node": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz", - "integrity": "sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.5.tgz", + "integrity": "sha512-XMoPKjSpXbkeJ7ZZ9icLnJMTY5Mc1kZbCakHquaFsXPpyWOwK0TK6CODO+0ca54UoM9LKOxyUNnoVZRl8TeaAg==", "dev": true, "requires": { - "debug": "^2.6.9", - "resolve": "^1.13.1" + "debug": "^3.2.7", + "resolve": "^1.20.0" }, "dependencies": { "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true } } }, "eslint-module-utils": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.1.tgz", - "integrity": "sha512-ZXI9B8cxAJIH4nfkhTwcRTEAnrVfobYqwjWy/QMCZ8rHkZHFjf9yO4BzpiF9kCSfNlMG54eKigISHpX0+AaT4A==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.2.tgz", + "integrity": "sha512-QG8pcgThYOuqxupd06oYTZoNOGaUdTY1PqK+oS6ElF6vs4pBdk/aYxFVQQXzcrAqp9m7cl7lb2ubazX+g16k2Q==", "dev": true, "requires": { "debug": "^3.2.7", @@ -14007,17 +14001,17 @@ } }, "eslint-plugin-import": { - "version": "2.23.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.23.4.tgz", - "integrity": "sha512-6/wP8zZRsnQFiR3iaPFgh5ImVRM1WN5NUWfTIRqwOdeiGJlBcSk82o1FEVq8yXmy4lkIzTo7YhHCIxlU/2HyEQ==", + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.24.0.tgz", + "integrity": "sha512-Kc6xqT9hiYi2cgybOc0I2vC9OgAYga5o/rAFinam/yF/t5uBqxQbauNPMC6fgb640T/89P0gFoO27FOilJ/Cqg==", "dev": true, "requires": { "array-includes": "^3.1.3", "array.prototype.flat": "^1.2.4", "debug": "^2.6.9", "doctrine": "^2.1.0", - "eslint-import-resolver-node": "^0.3.4", - "eslint-module-utils": "^2.6.1", + "eslint-import-resolver-node": "^0.3.5", + "eslint-module-utils": "^2.6.2", "find-up": "^2.0.0", "has": "^1.0.3", "is-core-module": "^2.4.0", @@ -16798,9 +16792,9 @@ "dev": true }, "hex-rgb": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/hex-rgb/-/hex-rgb-3.0.0.tgz", - "integrity": "sha512-iWOUTZu7KQGhErV8JfTQDH5F/M2D0HVd0sexS4Grg4e4RYAiN3c4jfpPqKgfedqeebKcNZBl2z3zlgCtFjpFJQ==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/hex-rgb/-/hex-rgb-4.3.0.tgz", + "integrity": "sha512-Ox1pJVrDCyGHMG9CFg1tmrRUMRPRsAWYc/PinY0XzJU4K7y7vjNoLKIQ7BR5UJMCxNN8EM1MNDmHWA/B3aZUuw==", "dev": true }, "hexy": { @@ -27035,9 +27029,9 @@ } }, "simple-git": { - "version": "2.42.0", - "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.42.0.tgz", - "integrity": "sha512-illpUX0bcrdB3AyvBGLz0ToRVP7lXNJOGVybGVuVk7PpivPNK5YKJx2aagKdKbveaMtt0DCLK4/jfjDb6b2M2g==", + "version": "2.44.0", + "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.44.0.tgz", + "integrity": "sha512-wIjcAmymhzgdaM0Y/a+XxmNGlivvHQTPZDYXVmyHMShVDwdeVqu3+OOyDbYu0DnfVzqLs2EOxRTgMNbC3YquwQ==", "dev": true, "requires": { "@kwsites/file-exists": "^1.1.1", @@ -27477,19 +27471,19 @@ "dev": true }, "sqlite3": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.0.0.tgz", - "integrity": "sha512-rjvqHFUaSGnzxDy2AHCwhHy6Zp6MNJzCPGYju4kD8yi6bze4d1/zMTg6C7JI49b7/EM7jKMTvyfN/4ylBKdwfw==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.0.2.tgz", + "integrity": "sha512-1SdTNo+BVU211Xj1csWa8lV6KM0CtucDwRyA0VHl91wEH1Mgh7RxUpI4rVvG7OhHrzCSGaVyW5g8vKvlrk9DJA==", "requires": { - "node-addon-api": "2.0.0", + "node-addon-api": "^3.0.0", "node-gyp": "3.x", "node-pre-gyp": "^0.11.0" }, "dependencies": { "node-addon-api": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.0.tgz", - "integrity": "sha512-ASCL5U13as7HhOExbT6OlWJJUV/lLzL2voOSP1UVehpRD8FbSrSDjfScK/KwAvVTI5AS6r4VwbOMlIqtvRidnA==" + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", + "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==" } } }, @@ -28297,9 +28291,9 @@ } }, "terser": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.4.0.tgz", - "integrity": "sha512-oDG16n2WKm27JO8h4y/w3iqBGAOSCtq7k8dRmrn4Wf9NouL0b2WpMHGChFGZq4nFAQy1FsNJrVQHfurXOSTmOA==", + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz", + "integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", "dev": true, "requires": { "commander": "^2.20.0", @@ -28402,6 +28396,17 @@ "figgy-pudding": "^3.5.1" } }, + "terser": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz", + "integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.6.1", + "source-map-support": "~0.5.12" + } + }, "yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", @@ -28855,9 +28860,9 @@ } }, "tslib": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", - "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, "tsscmp": { "version": "1.0.6", diff --git a/package.json b/package.json index ce13d3c1e..1778ab0b7 100644 --- a/package.json +++ b/package.json @@ -125,10 +125,10 @@ "route-parser": "0.0.5", "semver": "7.3.5", "smoothscroll-polyfill": "0.4.4", - "sqlite3": "5.0.0", + "sqlite3": "5.0.2", "tar": "4.4.15", "targz": "1.0.1", - "tslib": "2.3.0", + "tslib": "2.3.1", "useragent-generator": "1.1.1-amkt-22079-finish.0", "uuid": "3.3.3", "validator": "11.0.0", @@ -146,7 +146,7 @@ "@babel/plugin-syntax-dynamic-import": "7.8.3", "@babel/preset-env": "7.15.0", "@babel/preset-react": "7.14.5", - "@babel/register": "7.14.5", + "@babel/register": "7.15.3", "@commitlint/cli": "13.1.0", "@commitlint/config-conventional": "13.1.0", "@tsconfig/node14": "1.0.1", @@ -157,8 +157,8 @@ "@types/react": "16.14.6", "@types/react-dom": "16.9.13", "@types/uuid": "3.4.9", - "@typescript-eslint/eslint-plugin": "4.29.0", - "@typescript-eslint/parser": "4.29.0", + "@typescript-eslint/eslint-plugin": "4.29.1", + "@typescript-eslint/parser": "4.29.1", "all-contributors-cli": "6.20.0", "babel-plugin-react-intl": "3.5.1", "commitizen": "4.2.4", @@ -174,7 +174,7 @@ "eslint-config-airbnb": "18.2.1", "eslint-config-airbnb-typescript": "12.3.1", "eslint-config-prettier": "8.3.0", - "eslint-plugin-import": "2.23.4", + "eslint-plugin-import": "2.24.0", "eslint-plugin-jest": "24.4.0", "eslint-plugin-jsx-a11y": "6.4.1", "eslint-plugin-prettier": "3.4.0", @@ -192,7 +192,7 @@ "gulp-sass-variables": "1.2.0", "gulp-typescript": "6.0.0-alpha.1", "gulp-uglify": "3.0.2", - "hex-rgb": "3.0.0", + "hex-rgb": "4.3.0", "html-webpack-plugin": "4.5.2", "husky": "7.0.1", "jest": "27.0.6", @@ -205,8 +205,8 @@ "preval-build-info": "1.0.3", "react-intl-translations-manager": "5.0.3", "sass": "1.37.5", - "simple-git": "2.42.0", - "terser": "4.4.0", + "simple-git": "2.44.0", + "terser": "4.8.0", "ts-loader": "5.4.5", "typescript": "3.9.10", "webpack": "4.46.0", -- cgit v1.2.3-54-g00ecf From 1a91b6a671f6cdb5dfc4788576f9d078267242ad Mon Sep 17 00:00:00 2001 From: mhatvan Date: Sun, 15 Aug 2021 18:34:02 +0200 Subject: build: include animations.css file in build - add animations step in gulp to transpile scss and copy to build --- gulpfile.babel.js | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'gulpfile.babel.js') diff --git a/gulpfile.babel.js b/gulpfile.babel.js index c6fe6975a..02e42e788 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -70,6 +70,10 @@ const paths = { src: 'src/styles/vertical.scss', dest: 'build/styles', }, + animations: { + src: 'src/styles/animations.scss', + dest: 'build/styles', + }, javascripts: { src: 'src/**/*.js', dest: 'build/', @@ -239,6 +243,37 @@ export function verticalStyle() { .pipe(connect.reload()); } +export function animations() { + return gulp + .src(paths.animations.src) + .pipe( + sassVariables( + Object.assign( + { + $env: getTargetEnv, + }, + ...styleConfig, + ), + ), + ) + .pipe( + sass({ + includePaths: ['./node_modules', '../node_modules'], + }).on('error', sass.logError), + ) + .pipe( + gulpIf( + !isDevBuild, + csso({ + // Only minify in production to speed up dev builds + restructure: false, // Don't restructure CSS, otherwise it will break the styles + }), + ), + ) + .pipe(gulp.dest(paths.animations.dest)) + .pipe(connect.reload()); +} + export function processJavascripts() { return gulp .src( @@ -309,7 +344,7 @@ export function recipeInfo() { const build = gulp.series( clean, gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages, exportBuildInfo), - gulp.parallel(html, processJavascripts, processTypescripts, styles, verticalStyle, recipes, recipeInfo), + gulp.parallel(html, processJavascripts, processTypescripts, styles, verticalStyle, animations, recipes, recipeInfo), ); export { build }; -- cgit v1.2.3-54-g00ecf From 889d3802548b2f591312eaf3ced22700e8524160 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sun, 15 Aug 2021 22:51:01 +0530 Subject: refactor: remove duplication of code blocks handling stylesheets in gulp --- gulpfile.babel.js | 91 +++++++------------------------------------------------ 1 file changed, 11 insertions(+), 80 deletions(-) (limited to 'gulpfile.babel.js') diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 02e42e788..7311fc633 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -62,40 +62,36 @@ const paths = { watch: 'src/**/*.html', }, styles: { - src: 'src/styles/main.scss', + src: [ + 'src/styles/main.scss', + 'src/styles/vertical.scss', + 'src/styles/animations.scss', + ], dest: 'build/styles', watch: 'src/styles/**/*.scss', }, - verticalStyle: { - src: 'src/styles/vertical.scss', - dest: 'build/styles', - }, - animations: { - src: 'src/styles/animations.scss', - dest: 'build/styles', - }, javascripts: { src: 'src/**/*.js', dest: 'build/', watch: [ - // 'packages/**/*.js', 'src/**/*.js', + // 'packages/**/*.js', ], }, typescripts: { src: 'src/**/*.ts', dest: 'build/', watch: [ - // 'packages/**/*.ts', 'src/**/*.ts', + // 'packages/**/*.ts', ], }, packages: { watch: 'packages/**/*', // dest: 'build/', // watch: [ - // // 'packages/**/*.js', // 'src/**/*.js', + // // 'packages/**/*.js', // ], }, }; @@ -136,11 +132,9 @@ export function mvSrc() { [ `${paths.src}/*`, `${paths.src}/*/**`, - `!${paths.javascripts.watch[1]}`, - `!${paths.typescripts.watch[1]}`, + `!${paths.javascripts.watch[0]}`, + `!${paths.typescripts.watch[0]}`, `!${paths.src}/styles/**`, - `!${paths.src}/**/*.js`, - `!${paths.src}/**/*.ts`, ], { since: gulp.lastRun(mvSrc) }, ) @@ -212,68 +206,6 @@ export function styles() { .pipe(connect.reload()); } -export function verticalStyle() { - return gulp - .src(paths.verticalStyle.src) - .pipe( - sassVariables( - Object.assign( - { - $env: getTargetEnv, - }, - ...styleConfig, - ), - ), - ) - .pipe( - sass({ - includePaths: ['./node_modules', '../node_modules'], - }).on('error', sass.logError), - ) - .pipe( - gulpIf( - !isDevBuild, - csso({ - // Only minify in production to speed up dev builds - restructure: false, // Don't restructure CSS, otherwise it will break the styles - }), - ), - ) - .pipe(gulp.dest(paths.verticalStyle.dest)) - .pipe(connect.reload()); -} - -export function animations() { - return gulp - .src(paths.animations.src) - .pipe( - sassVariables( - Object.assign( - { - $env: getTargetEnv, - }, - ...styleConfig, - ), - ), - ) - .pipe( - sass({ - includePaths: ['./node_modules', '../node_modules'], - }).on('error', sass.logError), - ) - .pipe( - gulpIf( - !isDevBuild, - csso({ - // Only minify in production to speed up dev builds - restructure: false, // Don't restructure CSS, otherwise it will break the styles - }), - ), - ) - .pipe(gulp.dest(paths.animations.dest)) - .pipe(connect.reload()); -} - export function processJavascripts() { return gulp .src( @@ -315,7 +247,6 @@ export function processTypescripts() { export function watch() { gulp.watch(paths.packages.watch, mvLernaPackages); gulp.watch(paths.styles.watch, styles); - gulp.watch(paths.verticalStyle.src, verticalStyle); gulp.watch([paths.src, `${paths.javascripts.src}`, `${paths.styles.src}`], mvSrc); @@ -344,7 +275,7 @@ export function recipeInfo() { const build = gulp.series( clean, gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages, exportBuildInfo), - gulp.parallel(html, processJavascripts, processTypescripts, styles, verticalStyle, animations, recipes, recipeInfo), + gulp.parallel(html, processJavascripts, processTypescripts, styles, recipes, recipeInfo), ); export { build }; -- cgit v1.2.3-54-g00ecf From a5dd7ed72c689ed558e5a82ef32dfaa3512ba0c9 Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Sun, 15 Aug 2021 18:29:20 +0000 Subject: Minor cleanup of gulp (#1798) --- gulpfile.babel.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gulpfile.babel.js') diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 7311fc633..625d52e19 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -248,7 +248,7 @@ export function watch() { gulp.watch(paths.packages.watch, mvLernaPackages); gulp.watch(paths.styles.watch, styles); - gulp.watch([paths.src, `${paths.javascripts.src}`, `${paths.styles.src}`], mvSrc); + gulp.watch([paths.src], mvSrc); gulp.watch(paths.javascripts.watch, processJavascripts); gulp.watch(paths.typescripts.watch, processTypescripts); @@ -266,6 +266,7 @@ export function recipes() { .src(paths.recipes.src, { since: gulp.lastRun(recipes) }) .pipe(gulp.dest(paths.recipes.dest)); } + export function recipeInfo() { return gulp .src(paths.recipeInfo.src, { since: gulp.lastRun(recipeInfo) }) -- cgit v1.2.3-54-g00ecf From 16d8de38b74c298fda27c22c804850a999183d57 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 21 Aug 2021 09:03:32 +0530 Subject: chore: move build-time js files out of 'src' and into 'scripts' so that they not packaged into final deployable artefact --- gulpfile.babel.js | 2 +- package.json | 4 +- scripts/add-crowdin-contributors.js | 81 +++++++++++++++++++++++++++ scripts/build-theme-info.js | 97 +++++++++++++++++++++++++++++++++ scripts/link-readme.js | 63 +++++++++++++++++++++ scripts/theme/default/legacy.js | 38 +++++++++++++ src/scripts/add-crowdin-contributors.js | 81 --------------------------- src/scripts/build-theme-info.js | 97 --------------------------------- src/scripts/link-readme.js | 63 --------------------- src/theme/default/legacy.js | 38 ------------- 10 files changed, 282 insertions(+), 282 deletions(-) create mode 100644 scripts/add-crowdin-contributors.js create mode 100644 scripts/build-theme-info.js create mode 100644 scripts/link-readme.js create mode 100644 scripts/theme/default/legacy.js delete mode 100644 src/scripts/add-crowdin-contributors.js delete mode 100644 src/scripts/build-theme-info.js delete mode 100644 src/scripts/link-readme.js delete mode 100644 src/theme/default/legacy.js (limited to 'gulpfile.babel.js') diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 625d52e19..f87958a77 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -19,7 +19,7 @@ import ts from 'gulp-typescript'; import * as buildInfo from 'preval-build-info'; import config from './package.json'; -import * as rawStyleConfig from './src/theme/default/legacy'; +import * as rawStyleConfig from './scripts/theme/default/legacy'; dotenv.config(); diff --git a/package.json b/package.json index f49c71492..87e18f1c7 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "apply-branding": "node ./src/i18n/apply-branding.js", "update-submodules": "git submodule update --remote --force", "prepare-code": "npm run lint && npm run reformat-files && npm run manage-translations && npm run apply-branding", - "build-theme-info": "node src/scripts/build-theme-info.js", - "link-readme": "node src/scripts/link-readme.js", + "build-theme-info": "node scripts/build-theme-info.js", + "link-readme": "node scripts/link-readme.js", "minify-images": "./scripts/minify-images.sh", "start:server": "node src/internal-server/test.js" }, diff --git a/scripts/add-crowdin-contributors.js b/scripts/add-crowdin-contributors.js new file mode 100644 index 000000000..05e377a94 --- /dev/null +++ b/scripts/add-crowdin-contributors.js @@ -0,0 +1,81 @@ +/** + * Add CrowdIn Contributors to AllContributors list + * + * This script will add CrowdIn Contributors to the list of all contributors. + * As the CrowdIn API doesn't give good access to the data needed, this script + * requires you to manually execute a script on the members page of CrowdIn + * and paste its output into this script. + * + * Usage: + * 1. Open https://crowdin.com/project/getferdi/settings#members + * 2. Open the console and execute the script below: + +const members = []; +// All elements containing members +const membersEl = [...document.querySelectorAll('.ps-members-name')]; +// Remove the first 4 contributors as they are already in the list +for (let i = 0; i < 4; i += 1) { + membersEl.shift(); +} +membersEl.forEach((el) => { + const text = el.innerText; + let picture = el.querySelector('img').getAttribute('src'); + picture = picture.replace(/\?.+/, ''); + + // Check if the text includes a separate username + if (text.includes('(')) { + const username = /(?<=\()\w*(?=\))/.exec(text)[0]; + const name = /^.*(?= \()/.exec(text)[0]; + + if (username) { + members.push({ + name: name || username, + login: username, + avatar_url: picture, + }); + return; + } + } + members.push({ + name: text, + login: text, + avatar_url: picture, + }); +}); + +// Output data to console +console.clear(); +console.log(JSON.stringify(members)); + + * 3. Paste the output of the script (JSON Array) below to set 'list' to that value + * 4. Execute this script using 'node scripts/add-crowdin-contributors.js' + * 5. Regenerate the README table using the CLI ('all-contributors generate') + * Please check if the generated data is ok and no data is lost. +*/ +const list = []; + +const fs = require('fs-extra'); +const path = require('path'); +const allContributors = require('all-contributors-cli'); + +const infoPath = path.join(__dirname, '..', '..', '.all-contributorsrc'); + +(async () => { + const info = await fs.readJSON(infoPath); + + for (const user of list) { + // eslint-disable-next-line no-await-in-loop + info.contributors = await allContributors.addContributorWithDetails({ + ...user, + contributions: ['translation'], + profile: `https://crowdin.com/profile/${user.login}`, + options: { + contributors: info.contributors, + }, + }); + } + + fs.writeJSON(infoPath, info, { + spaces: 2, + }); +})(); diff --git a/scripts/build-theme-info.js b/scripts/build-theme-info.js new file mode 100644 index 000000000..4058be942 --- /dev/null +++ b/scripts/build-theme-info.js @@ -0,0 +1,97 @@ +/** + * Script to get information on which selectors use the brand color. + * This is needed to provide the accent color feature - the feature will create CSS rules + * to overwrite the color of these selectors. + */ +const css = require('css'); +const fs = require('fs-extra'); +const path = require('path'); +const theme = require('@meetfranz/theme'); + +// Colors that should be replaced with the accent color +const accentColors = [ + theme.DEFAULT_ACCENT_COLOR.toLowerCase(), + '#7367f0', + '#5e50ee', +]; + +const cssFile = path.join(__dirname, '..', '..', 'build', 'styles', 'main.css'); +const outputFile = path.join(__dirname, '..', 'assets', 'themeInfo.json'); + +// Parse and extract the rules from a CSS stylesheet file +async function getRulesFromCssFile(file) { + const cssSrc = (await fs.readFile(file)).toString(); + const cssTree = css.parse(cssSrc); + + return cssTree.stylesheet.rules; +} + +/** + * Get all selectors from a list of parsed CSS rules that set any property to one of the specified + * values. + * + * This function will output an object in this format: + * { + * 'property-name': [ array of selectors ] + * } + * + * e.g. + * { + * 'background-color': [ + * '.background', + * '.input-dark' + * ] + * } + * + * @param {Array} rules Rules as outputted by the `css` module + * @param {Array} values Array of values that should be searched for + */ +function getSelectorsDeclaringValues(rules, values) { + const output = {}; + + rules.forEach((rule) => { + if (rule.declarations) { + rule.declarations.forEach((declaration) => { + if (declaration.type === 'declaration' + && values.includes(declaration.value.toLowerCase())) { + if (!output[declaration.property]) { + output[declaration.property] = []; + } + output[declaration.property] = output[declaration.property].concat(rule.selectors); + } + }); + } + }); + + return output; +} + +async function generateThemeInfo() { + if (!await fs.pathExists(cssFile)) { + console.log('Please make sure to build the project first.'); + return; + } + + // Read and parse css bundle + const rules = await getRulesFromCssFile(cssFile); + + console.log(`Found ${rules.length} rules`); + + // Get rules specifying the brand colors + const brandRules = getSelectorsDeclaringValues(rules, accentColors); + + console.log(`Found ${Object.keys(brandRules).join(', ')} properties that set color to brand color`); + + // Join array of declarations into a single string + Object.keys(brandRules).forEach((rule) => { + brandRules[rule] = brandRules[rule].join(', '); + }); + + // Write object with theme info to file + fs.writeFile( + outputFile, + JSON.stringify(brandRules), + ); +} + +generateThemeInfo(); diff --git a/scripts/link-readme.js b/scripts/link-readme.js new file mode 100644 index 000000000..1e47cddf8 --- /dev/null +++ b/scripts/link-readme.js @@ -0,0 +1,63 @@ +/** + * Script that automatically creates links to issues and users inside README.md + * + * e.g. "#123" => "[#123](https://github.com/getferdi/ferdi/issues/123)" + * and "franz/#123" => "[franz#123](https://github.com/meetfranz/franz/issues/123)" + * and "@abc" => "[@abc](https://github.com/abc)" + */ + +const fs = require('fs-extra'); +const path = require('path'); + +console.log('Linking issues and PRs in README.md'); + +const readmepath = path.join(__dirname, '..', '..', 'README.md'); + +// Read README.md +let readme = fs.readFileSync(readmepath, 'utf-8'); + +let replacements = 0; + +// Replace Franz issues +// Regex matches strings that don't begin with a "[", i.e. are not already linked +// followed by a "franz#" and digits to indicate +// a GitHub issue, and not ending with a "]" +readme = readme.replace(/(? { + const issueNr = match.replace('franz#', ''); + replacements += 1; + return `[franz#${issueNr}](https://github.com/meetfranz/franz/issues/${issueNr})`; +}); + +// Replace external issues +// Regex matches strings that don't begin with a "[", followed a repo name in the format "user/repo" +// followed by a "#" and digits to indicate a GitHub issue, and not ending with a "]" +readme = readme.replace(/(? { + const issueNr = match.replace(/\D/g, ''); + const repo = match.replace(/#\d+/g, ''); + replacements += 1; + return `[${repo}#${issueNr}](https://github.com/${repo}/issues/${issueNr})`; +}); + +// Replace Ferdi issues +// Regex matches strings that don't begin with a "[", i.e. are not already linked and +// don't begin with "franz", i.e. are not Franz issues, followed by a "#" and digits to indicate +// a GitHub issue, and not ending with a "]" +readme = readme.replace(/(? { + const issueNr = match.replace('#', ''); + replacements += 1; + return `[#${issueNr}](https://github.com/getferdi/ferdi/issues/${issueNr})`; +}); + +// Link GitHub users +// Regex matches strings that don't begin with a "[", i.e. are not already linked +// followed by a "@" and at least one word character and not ending with a "]" +readme = readme.replace(/(? { + const username = match.replace('@', ''); + replacements += 1; + return `[@${username}](https://github.com/${username})`; +}); + +// Write to file +fs.writeFileSync(readmepath, readme); + +console.log(`Added ${replacements} strings`); diff --git a/scripts/theme/default/legacy.js b/scripts/theme/default/legacy.js new file mode 100644 index 000000000..015dca756 --- /dev/null +++ b/scripts/theme/default/legacy.js @@ -0,0 +1,38 @@ +/* legacy config, injected into sass at build time */ +export const themeBrandPrimary = '#7266F0'; +export const themeBrandSuccess = '#5cb85c'; +export const themeBrandInfo = '#5bc0de'; +export const themeBrandWarning = '#FF9F00'; +export const themeBrandDanger = '#d9534f'; + +export const themeGrayDark = '#373a3c'; +export const themeGray = '#55595c'; +export const themeGrayLight = '#818a91'; +export const themeGrayLighter = '#eceeef'; +export const themeGrayLightest = '#f7f7f9'; + +export const themeBorderRadius = '6px'; +export const themeBorderRadiusSmall = '3px'; + +export const themeSidebarWidth = '68px'; + +export const themeTextColor = themeGrayDark; + +export const themeTransitionTime = '.5s'; + +export const themeInsetShadow = 'inset 0 2px 5px rgba(0, 0, 0, .03)'; + +export const darkThemeBlack = '#1A1A1A'; + +export const darkThemeGrayDarkest = '#1E1E1E'; +export const darkThemeGrayDarker = '#2D2F31'; +export const darkThemeGrayDark = '#383A3B'; + +export const darkThemeGray = '#47494B'; + +export const darkThemeGrayLight = '#515355'; +export const darkThemeGrayLighter = '#8a8b8b'; +export const darkThemeGrayLightest = '#FFFFFF'; + +export const darkThemeGraySmoke = '#CED0D1'; +export const darkThemeTextColor = '#FFFFFF'; diff --git a/src/scripts/add-crowdin-contributors.js b/src/scripts/add-crowdin-contributors.js deleted file mode 100644 index ed29a0daf..000000000 --- a/src/scripts/add-crowdin-contributors.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Add CrowdIn Contributors to AllContributors list - * - * This script will add CrowdIn Contributors to the list of all contributors. - * As the CrowdIn API doesn't give good access to the data needed, this script - * requires you to manually execute a script on the members page of CrowdIn - * and paste its output into this script. - * - * Usage: - * 1. Open https://crowdin.com/project/getferdi/settings#members - * 2. Open the console and execute the script below: - -const members = []; -// All elements containing members -const membersEl = [...document.querySelectorAll('.ps-members-name')]; -// Remove the first 4 contributors as they are already in the list -for (let i = 0; i < 4; i += 1) { - membersEl.shift(); -} -membersEl.forEach((el) => { - const text = el.innerText; - let picture = el.querySelector('img').getAttribute('src'); - picture = picture.replace(/\?.+/, ''); - - // Check if the text includes a separate username - if (text.includes('(')) { - const username = /(?<=\()\w*(?=\))/.exec(text)[0]; - const name = /^.*(?= \()/.exec(text)[0]; - - if (username) { - members.push({ - name: name || username, - login: username, - avatar_url: picture, - }); - return; - } - } - members.push({ - name: text, - login: text, - avatar_url: picture, - }); -}); - -// Output data to console -console.clear(); -console.log(JSON.stringify(members)); - - * 3. Paste the output of the script (JSON Array) below to set 'list' to that value - * 4. Execute this script using 'node src/scripts/add-crowdin-contributors.js' - * 5. Regenerate the README table using the CLI ('all-contributors generate') - * Please check if the generated data is ok and no data is lost. -*/ -const list = []; - -const fs = require('fs-extra'); -const path = require('path'); -const allContributors = require('all-contributors-cli'); - -const infoPath = path.join(__dirname, '..', '..', '.all-contributorsrc'); - -(async () => { - const info = await fs.readJSON(infoPath); - - for (const user of list) { - // eslint-disable-next-line no-await-in-loop - info.contributors = await allContributors.addContributorWithDetails({ - ...user, - contributions: ['translation'], - profile: `https://crowdin.com/profile/${user.login}`, - options: { - contributors: info.contributors, - }, - }); - } - - fs.writeJSON(infoPath, info, { - spaces: 2, - }); -})(); diff --git a/src/scripts/build-theme-info.js b/src/scripts/build-theme-info.js deleted file mode 100644 index 4058be942..000000000 --- a/src/scripts/build-theme-info.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Script to get information on which selectors use the brand color. - * This is needed to provide the accent color feature - the feature will create CSS rules - * to overwrite the color of these selectors. - */ -const css = require('css'); -const fs = require('fs-extra'); -const path = require('path'); -const theme = require('@meetfranz/theme'); - -// Colors that should be replaced with the accent color -const accentColors = [ - theme.DEFAULT_ACCENT_COLOR.toLowerCase(), - '#7367f0', - '#5e50ee', -]; - -const cssFile = path.join(__dirname, '..', '..', 'build', 'styles', 'main.css'); -const outputFile = path.join(__dirname, '..', 'assets', 'themeInfo.json'); - -// Parse and extract the rules from a CSS stylesheet file -async function getRulesFromCssFile(file) { - const cssSrc = (await fs.readFile(file)).toString(); - const cssTree = css.parse(cssSrc); - - return cssTree.stylesheet.rules; -} - -/** - * Get all selectors from a list of parsed CSS rules that set any property to one of the specified - * values. - * - * This function will output an object in this format: - * { - * 'property-name': [ array of selectors ] - * } - * - * e.g. - * { - * 'background-color': [ - * '.background', - * '.input-dark' - * ] - * } - * - * @param {Array} rules Rules as outputted by the `css` module - * @param {Array} values Array of values that should be searched for - */ -function getSelectorsDeclaringValues(rules, values) { - const output = {}; - - rules.forEach((rule) => { - if (rule.declarations) { - rule.declarations.forEach((declaration) => { - if (declaration.type === 'declaration' - && values.includes(declaration.value.toLowerCase())) { - if (!output[declaration.property]) { - output[declaration.property] = []; - } - output[declaration.property] = output[declaration.property].concat(rule.selectors); - } - }); - } - }); - - return output; -} - -async function generateThemeInfo() { - if (!await fs.pathExists(cssFile)) { - console.log('Please make sure to build the project first.'); - return; - } - - // Read and parse css bundle - const rules = await getRulesFromCssFile(cssFile); - - console.log(`Found ${rules.length} rules`); - - // Get rules specifying the brand colors - const brandRules = getSelectorsDeclaringValues(rules, accentColors); - - console.log(`Found ${Object.keys(brandRules).join(', ')} properties that set color to brand color`); - - // Join array of declarations into a single string - Object.keys(brandRules).forEach((rule) => { - brandRules[rule] = brandRules[rule].join(', '); - }); - - // Write object with theme info to file - fs.writeFile( - outputFile, - JSON.stringify(brandRules), - ); -} - -generateThemeInfo(); diff --git a/src/scripts/link-readme.js b/src/scripts/link-readme.js deleted file mode 100644 index 1e47cddf8..000000000 --- a/src/scripts/link-readme.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Script that automatically creates links to issues and users inside README.md - * - * e.g. "#123" => "[#123](https://github.com/getferdi/ferdi/issues/123)" - * and "franz/#123" => "[franz#123](https://github.com/meetfranz/franz/issues/123)" - * and "@abc" => "[@abc](https://github.com/abc)" - */ - -const fs = require('fs-extra'); -const path = require('path'); - -console.log('Linking issues and PRs in README.md'); - -const readmepath = path.join(__dirname, '..', '..', 'README.md'); - -// Read README.md -let readme = fs.readFileSync(readmepath, 'utf-8'); - -let replacements = 0; - -// Replace Franz issues -// Regex matches strings that don't begin with a "[", i.e. are not already linked -// followed by a "franz#" and digits to indicate -// a GitHub issue, and not ending with a "]" -readme = readme.replace(/(? { - const issueNr = match.replace('franz#', ''); - replacements += 1; - return `[franz#${issueNr}](https://github.com/meetfranz/franz/issues/${issueNr})`; -}); - -// Replace external issues -// Regex matches strings that don't begin with a "[", followed a repo name in the format "user/repo" -// followed by a "#" and digits to indicate a GitHub issue, and not ending with a "]" -readme = readme.replace(/(? { - const issueNr = match.replace(/\D/g, ''); - const repo = match.replace(/#\d+/g, ''); - replacements += 1; - return `[${repo}#${issueNr}](https://github.com/${repo}/issues/${issueNr})`; -}); - -// Replace Ferdi issues -// Regex matches strings that don't begin with a "[", i.e. are not already linked and -// don't begin with "franz", i.e. are not Franz issues, followed by a "#" and digits to indicate -// a GitHub issue, and not ending with a "]" -readme = readme.replace(/(? { - const issueNr = match.replace('#', ''); - replacements += 1; - return `[#${issueNr}](https://github.com/getferdi/ferdi/issues/${issueNr})`; -}); - -// Link GitHub users -// Regex matches strings that don't begin with a "[", i.e. are not already linked -// followed by a "@" and at least one word character and not ending with a "]" -readme = readme.replace(/(? { - const username = match.replace('@', ''); - replacements += 1; - return `[@${username}](https://github.com/${username})`; -}); - -// Write to file -fs.writeFileSync(readmepath, readme); - -console.log(`Added ${replacements} strings`); diff --git a/src/theme/default/legacy.js b/src/theme/default/legacy.js deleted file mode 100644 index 3f4bec5d5..000000000 --- a/src/theme/default/legacy.js +++ /dev/null @@ -1,38 +0,0 @@ -/* legacy config, injected into sass */ -export const themeBrandPrimary = '#7266F0'; -export const themeBrandSuccess = '#5cb85c'; -export const themeBrandInfo = '#5bc0de'; -export const themeBrandWarning = '#FF9F00'; -export const themeBrandDanger = '#d9534f'; - -export const themeGrayDark = '#373a3c'; -export const themeGray = '#55595c'; -export const themeGrayLight = '#818a91'; -export const themeGrayLighter = '#eceeef'; -export const themeGrayLightest = '#f7f7f9'; - -export const themeBorderRadius = '6px'; -export const themeBorderRadiusSmall = '3px'; - -export const themeSidebarWidth = '68px'; - -export const themeTextColor = themeGrayDark; - -export const themeTransitionTime = '.5s'; - -export const themeInsetShadow = 'inset 0 2px 5px rgba(0, 0, 0, .03)'; - -export const darkThemeBlack = '#1A1A1A'; - -export const darkThemeGrayDarkest = '#1E1E1E'; -export const darkThemeGrayDarker = '#2D2F31'; -export const darkThemeGrayDark = '#383A3B'; - -export const darkThemeGray = '#47494B'; - -export const darkThemeGrayLight = '#515355'; -export const darkThemeGrayLighter = '#8a8b8b'; -export const darkThemeGrayLightest = '#FFFFFF'; - -export const darkThemeGraySmoke = '#CED0D1'; -export const darkThemeTextColor = '#FFFFFF'; -- cgit v1.2.3-54-g00ecf