mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-28 11:52:13 +00:00
feat: separate prettier from eslint
This commit is contained in:
committed by
Thea Schöbl
parent
939fb6ef0f
commit
a88d000ccd
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import fs from 'fs';
|
||||
import {omit} from '../src/app/_helpers/collections/omit';
|
||||
@@ -30,22 +30,15 @@ function accumulateFile(path: string, additionalLicensesPath: string) {
|
||||
JSON.stringify(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
Object.entries<any>({
|
||||
...pickBy(
|
||||
JSON.parse(fs.readFileSync(path).toString()),
|
||||
(_, key: string) => {
|
||||
const parts = key.split('@');
|
||||
...pickBy(JSON.parse(fs.readFileSync(path).toString()), (_, key: string) => {
|
||||
const parts = key.split('@');
|
||||
|
||||
return (
|
||||
dependencies[parts.slice(0, -1).join('@')] ===
|
||||
parts[parts.length - 1]
|
||||
);
|
||||
},
|
||||
),
|
||||
return dependencies[parts.slice(0, -1).join('@')] === parts[parts.length - 1];
|
||||
}),
|
||||
...JSON.parse(fs.readFileSync(additionalLicensesPath).toString()),
|
||||
})
|
||||
.map(([key, value]) => ({
|
||||
licenseText:
|
||||
value.licenseFile && fs.readFileSync(value.licenseFile, 'utf8'),
|
||||
licenseText: value.licenseFile && fs.readFileSync(value.licenseFile, 'utf8'),
|
||||
name: key,
|
||||
...omit(value, 'licenseFile', 'path'),
|
||||
}))
|
||||
@@ -54,7 +47,4 @@ function accumulateFile(path: string, additionalLicensesPath: string) {
|
||||
);
|
||||
}
|
||||
|
||||
accumulateFile(
|
||||
'./src/assets/about/licenses.json',
|
||||
'./additional-licenses.json',
|
||||
);
|
||||
accumulateFile('./src/assets/about/licenses.json', './additional-licenses.json');
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import fontkit, {Font} from 'fontkit';
|
||||
import config from '../icons.config';
|
||||
@@ -57,9 +57,7 @@ function check(icons: Record<string, string[]>) {
|
||||
console.error(`${purpose}: ${icon} does not exist. Typo?`);
|
||||
} else if (!hasIcon(modifiedFont, icon)) {
|
||||
success = false;
|
||||
console.error(
|
||||
`${purpose}: ${icon} not found in minified font. Run ${commandName} to regenerate it.`,
|
||||
);
|
||||
console.error(`${purpose}: ${icon} not found in minified font. Run ${commandName} to regenerate it.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import glob from 'glob';
|
||||
import {readFileSync} from 'fs';
|
||||
import {
|
||||
matchPropertyContent,
|
||||
matchTagProperties,
|
||||
} from '../src/app/util/ion-icon/icon-match';
|
||||
import {matchPropertyContent, matchTagProperties} from '../src/app/util/ion-icon/icon-match';
|
||||
|
||||
const globPromise = (pattern: string) =>
|
||||
new Promise<string[]>((resolve, reject) =>
|
||||
@@ -27,9 +24,7 @@ const globPromise = (pattern: string) =>
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export async function getUsedIconsHtml(
|
||||
glob = 'src/**/*.html',
|
||||
): Promise<Record<string, string[]>> {
|
||||
export async function getUsedIconsHtml(glob = 'src/**/*.html'): Promise<Record<string, string[]>> {
|
||||
return Object.fromEntries(
|
||||
(await globPromise(glob))
|
||||
.map(file => [
|
||||
@@ -48,15 +43,10 @@ export async function getUsedIconsHtml(
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export async function getUsedIconsTS(
|
||||
glob = 'src/**/*.ts',
|
||||
): Promise<Record<string, string[]>> {
|
||||
export async function getUsedIconsTS(glob = 'src/**/*.ts'): Promise<Record<string, string[]>> {
|
||||
return Object.fromEntries(
|
||||
(await globPromise(glob))
|
||||
.map(file => [
|
||||
file,
|
||||
readFileSync(file, 'utf8').match(/(?<=Icon`)[\w-]+(?=`)/g) || [],
|
||||
])
|
||||
.map(file => [file, readFileSync(file, 'utf8').match(/(?<=Icon`)[\w-]+(?=`)/g) || []])
|
||||
.filter(([, values]) => values.length > 0),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,9 +77,7 @@ async function minifyIconFont() {
|
||||
glyphs.push(config.codePoints[icon]);
|
||||
} else {
|
||||
console.log();
|
||||
console.error(
|
||||
`${icon} code point could not be determined. Add it to config.codePoints.`,
|
||||
);
|
||||
console.error(`${icon} code point could not be determined. Add it to config.codePoints.`);
|
||||
process.exit(-1);
|
||||
}
|
||||
}
|
||||
@@ -91,15 +89,7 @@ async function minifyIconFont() {
|
||||
const pythonPath = `"${await run('npm config get python')}"`;
|
||||
console.log(`Using python from npm config ${pythonPath}`);
|
||||
console.log(await run(`${pythonPath} --version`));
|
||||
console.log(
|
||||
await run([
|
||||
pythonPath,
|
||||
'-m',
|
||||
'pip',
|
||||
'install',
|
||||
'fonttools[ufo,lxml,unicode,woff]',
|
||||
]),
|
||||
);
|
||||
console.log(await run([pythonPath, '-m', 'pip', 'install', 'fonttools[ufo,lxml,unicode,woff]']));
|
||||
|
||||
console.log(
|
||||
await run([
|
||||
@@ -119,10 +109,9 @@ async function minifyIconFont() {
|
||||
const before = statSync(config.inputPath).size;
|
||||
|
||||
console.log(
|
||||
`${toByteUnit(before)} > ${toByteUnit(result)} (${(
|
||||
((before - result) / before) *
|
||||
100
|
||||
).toFixed(2)}% Reduction)`,
|
||||
`${toByteUnit(before)} > ${toByteUnit(result)} (${(((before - result) / before) * 100).toFixed(
|
||||
2,
|
||||
)}% Reduction)`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user