Skip to content

Commit

Permalink
Update JS dependencies (#15033)
Browse files Browse the repository at this point in the history
* Update JS dependencies

- Update all JS dependencies
- For octicons, rename trashcan to trash
- For svgo, migrate to v2 api, output seems to have slightly changed but icons look the same
- For stylelint, update config, fix custom property duplicates
- For monaco, drop legacy Edge support
- For eslint, enable new rules, fix new issues
- For less-loader, remove deprecated import syntax

* update svgo usage in generate-images and rebuild logo.svg with it
  • Loading branch information
silverwind authored Mar 22, 2021
1 parent a587a28 commit 1a03fa7
Show file tree
Hide file tree
Showing 273 changed files with 1,861 additions and 1,659 deletions.
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ rules:
unicode-bom: [2, never]
unicorn/better-regex: [0]
unicorn/catch-error-name: [0]
unicorn/consistent-destructuring: [2]
unicorn/consistent-function-scoping: [2]
unicorn/custom-error-definition: [0]
unicorn/empty-brace-spaces: [2]
Expand All @@ -356,19 +357,24 @@ rules:
unicorn/import-style: [0]
unicorn/new-for-builtins: [2]
unicorn/no-abusive-eslint-disable: [0]
unicorn/no-array-for-each: [0]
unicorn/no-array-instanceof: [0]
unicorn/no-array-push-push: [2]
unicorn/no-console-spaces: [0]
unicorn/no-fn-reference-in-iterator: [0]
unicorn/no-for-loop: [0]
unicorn/no-hex-escape: [0]
unicorn/no-keyword-prefix: [0]
unicorn/no-lonely-if: [2]
unicorn/no-nested-ternary: [0]
unicorn/no-new-array: [0]
unicorn/no-new-buffer: [0]
unicorn/no-null: [0]
unicorn/no-object-as-default-parameter: [2]
unicorn/no-process-exit: [0]
unicorn/no-reduce: [2]
unicorn/no-static-only-class: [2]
unicorn/no-this-assignment: [2]
unicorn/no-unreadable-array-destructuring: [0]
unicorn/no-unsafe-regex: [0]
unicorn/no-unused-properties: [2]
Expand All @@ -378,8 +384,12 @@ rules:
unicorn/numeric-separators-style: [0]
unicorn/prefer-add-event-listener: [2]
unicorn/prefer-array-find: [2]
unicorn/prefer-array-flat: [2]
unicorn/prefer-array-index-of: [2]
unicorn/prefer-array-some: [2]
unicorn/prefer-dataset: [2]
unicorn/prefer-date-now: [2]
unicorn/prefer-default-parameters: [0]
unicorn/prefer-event-key: [2]
unicorn/prefer-includes: [2]
unicorn/prefer-math-trunc: [2]
Expand All @@ -391,6 +401,7 @@ rules:
unicorn/prefer-optional-catch-binding: [2]
unicorn/prefer-query-selector: [0]
unicorn/prefer-reflect-apply: [0]
unicorn/prefer-regexp-test: [2]
unicorn/prefer-replace-all: [0]
unicorn/prefer-set-has: [0]
unicorn/prefer-spread: [0]
Expand Down
17 changes: 9 additions & 8 deletions build/generate-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const imageminZopfli = require('imagemin-zopfli');
const Svgo = require('svgo');
const {optimize, extendDefaultPlugins} = require('svgo');
const {fabric} = require('fabric');
const {readFile, writeFile} = require('fs').promises;
const {resolve} = require('path');
Expand All @@ -24,14 +24,15 @@ function loadSvg(svg) {

async function generate(svg, outputFile, {size, bg}) {
if (outputFile.endsWith('.svg')) {
const svgo = new Svgo({
plugins: [
{removeDimensions: true},
{addAttributesToSVGElement: {attributes: [{width: size}, {height: size}]}},
],
const {data} = optimize(svg, {
plugins: extendDefaultPlugins([
'removeDimensions',
{
name: 'addAttributesToSVGElement',
params: {attributes: [{width: size}, {height: size}]}
},
]),
});

const {data} = await svgo.optimize(svg);
await writeFile(outputFile, data);
return;
}
Expand Down
31 changes: 10 additions & 21 deletions build/generate-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const fastGlob = require('fast-glob');
const Svgo = require('svgo');
const {optimize, extendDefaultPlugins} = require('svgo');
const {resolve, parse} = require('path');
const {readFile, writeFile, mkdir} = require('fs').promises;

Expand All @@ -25,31 +25,20 @@ async function processFile(file, {prefix, fullName} = {}) {
if (prefix === 'octicon') name = name.replace(/-[0-9]+$/, ''); // chop of '-16' on octicons
}

const svgo = new Svgo({
plugins: [
{removeXMLNS: true},
{removeDimensions: true},
const {data} = optimize(await readFile(file, 'utf8'), {
plugins: extendDefaultPlugins([
'removeXMLNS',
'removeDimensions',
{
addClassesToSVGElement: {
classNames: [
'svg',
name,
],
},
name: 'addClassesToSVGElement',
params: {classNames: ['svg', name]},
},
{
addAttributesToSVGElement: {
attributes: [
{'width': '16'},
{'height': '16'},
{'aria-hidden': 'true'},
],
},
name: 'addAttributesToSVGElement',
params: {attributes: [{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'}]},
},
],
]),
});

const {data} = await svgo.optimize(await readFile(file, 'utf8'));
await writeFile(resolve(outputDir, `${name}.svg`), data);
}

Expand Down
2 changes: 1 addition & 1 deletion docs/content/page/index.de-de.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Gitea ist ein [Gogs](http://gogs.io)-Fork.

## Browser Unterstützung

- Letzten 2 Versions von Chrome, Firefox, Safari, Edge (EdgeHTML) and Edge (Chromium)
- Letzten 2 Versions von Chrome, Firefox, Safari und Edge
- Firefox ESR
2 changes: 1 addition & 1 deletion docs/content/page/index.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Windows, on architectures like amd64, i386, ARM, PowerPC, and others.

## Browser Support

- Last 2 versions of Chrome, Firefox, Safari, Edge (EdgeHTML) and Edge (Chromium)
- Last 2 versions of Chrome, Firefox, Safari and Edge
- Firefox ESR

## Components
Expand Down
2 changes: 1 addition & 1 deletion docs/content/page/index.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Gitea 是從 [Gogs](http://gogs.io) Fork 出來的,請閱讀部落格文章 [G

## 瀏覽器支援

- 最近 2 個版本的 Chrome, Firefox, Safari, Edge (EdgeHTML), Edge (Chromium)
- 最近 2 個版本的 Chrome, Firefox, Safari, Edge
- Firefox ESR

## 元件
Expand Down
Loading

0 comments on commit 1a03fa7

Please sign in to comment.