mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 17:12:43 +00:00
feat: improve cross-uni app workflow
This commit is contained in:
25
frontend/app/.iconsrc.json
Normal file
25
frontend/app/.iconsrc.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"inputPath": "node_modules/material-symbols/material-symbols-rounded.woff2",
|
||||
"outputPath": "src/assets/icons.min.woff2",
|
||||
"htmlGlob": "src/**/*.html",
|
||||
"scriptGlob": "src/**/*.ts",
|
||||
"additionalIcons": {
|
||||
"about": ["copyright", "campaign", "policy", "description", "text_snippet"],
|
||||
"navigation": [
|
||||
"home",
|
||||
"newspaper",
|
||||
"search",
|
||||
"calendar_month",
|
||||
"local_cafe",
|
||||
"local_library",
|
||||
"inventory_2",
|
||||
"map",
|
||||
"grade",
|
||||
"account_circle",
|
||||
"settings",
|
||||
"info",
|
||||
"rate_review",
|
||||
"work"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,32 @@ android {
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions 'uni'
|
||||
productFlavors {
|
||||
file('../../config').eachDir {
|
||||
def config = new groovy.json.JsonSlurper().parseText(file("$it/default.json").text)
|
||||
"${it.name}" {
|
||||
dimension 'uni'
|
||||
applicationId config.android.packageName
|
||||
versionName config.appMarketingVersion
|
||||
resValue 'string', 'app_name', config.appName
|
||||
resValue 'string', 'title_activity_main', config.appName
|
||||
resValue 'string', 'package_name', config.android.packageName
|
||||
resValue 'string', 'custom_url_scheme', config.appUrlScheme
|
||||
resValue 'string', 'app_host', config.appLinkHost
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"schematics": {},
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"builder": "@openstapps/angular-builder:application",
|
||||
"options": {
|
||||
"outputPath": "www",
|
||||
"index": "src/index.html",
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import {CapacitorConfig} from '@capacitor/cli';
|
||||
|
||||
const variant = process.env.APP_VARIANT ?? 'default';
|
||||
// eslint-disable-next-line unicorn/prefer-module, @typescript-eslint/no-var-requires
|
||||
const uniConfig = require(`./config/${variant}/default.json`);
|
||||
|
||||
const config: CapacitorConfig = {
|
||||
appId: 'de.anyschool.app',
|
||||
appName: 'StApps',
|
||||
appId: uniConfig.android.packageName, // TODO: iOS bundle ID
|
||||
appName: uniConfig.appName,
|
||||
webDir: 'www',
|
||||
android: {
|
||||
flavor: variant,
|
||||
},
|
||||
// TODO: iOS scheme
|
||||
cordova: {
|
||||
preferences: {
|
||||
'AndroidXEnabled': 'true',
|
||||
|
||||
67
frontend/app/config/config.schema.json
Normal file
67
frontend/app/config/config.schema.json
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "App Config",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"appName": {
|
||||
"type": "string",
|
||||
"description": "Full app name",
|
||||
"examples": ["Open StApps"]
|
||||
},
|
||||
"appDisplayName": {
|
||||
"type": "string",
|
||||
"description": "App name on mobile device homescreen (Not much space)",
|
||||
"examples": ["StApps"]
|
||||
},
|
||||
"backendUrl": {
|
||||
"type": "string",
|
||||
"description": "Publicly available backend url",
|
||||
"examples": ["https://your.backend.server.tld"]
|
||||
},
|
||||
"backendVersion": {
|
||||
"type": "string",
|
||||
"description": "Minimum backend version the app will request",
|
||||
"examples": ["3.0.0"]
|
||||
},
|
||||
"appLinkHost": {
|
||||
"type": "string",
|
||||
"description": "Your host used for universal (deep) links",
|
||||
"examples": ["your.deep.link.host.tdl"]
|
||||
},
|
||||
"appUrlScheme": {
|
||||
"type": "string",
|
||||
"description": "Custom url scheme for native app versions",
|
||||
"examples": ["de.anyschool.app"]
|
||||
},
|
||||
"appMarketingVersion": {
|
||||
"type": "string",
|
||||
"description": "App marketing version used in Stores (preferably SemVer or CalVer)",
|
||||
"examples": ["1.0.0"]
|
||||
},
|
||||
"android": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"packageName": {
|
||||
"type": "string",
|
||||
"description": "Android package name",
|
||||
"examples": ["de.anyschool.app"]
|
||||
}
|
||||
},
|
||||
"required": ["packageName"]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"$schema",
|
||||
"appName",
|
||||
"appDisplayName",
|
||||
"backendUrl",
|
||||
"backendVersion",
|
||||
"appLinkHost",
|
||||
"appUrlScheme",
|
||||
"appMarketingVersion",
|
||||
"android"
|
||||
]
|
||||
}
|
||||
13
frontend/app/config/default.json
Normal file
13
frontend/app/config/default.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "./config.schema.json",
|
||||
"appName": "Open StApps",
|
||||
"appDisplayName": "StApps",
|
||||
"backendUrl": "http://localhost:3000",
|
||||
"backendVersion": "3.0.0",
|
||||
"appLinkHost": "localhost:3000",
|
||||
"appUrlScheme": "de.anyschool.app",
|
||||
"appMarketingVersion": "1.0.0",
|
||||
"android": {
|
||||
"packageName": "de.anyschool.app"
|
||||
}
|
||||
}
|
||||
13
frontend/app/config/f-u/default.json
Normal file
13
frontend/app/config/f-u/default.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "../config.schema.json",
|
||||
"appName": "Uni Frankfurt",
|
||||
"appDisplayName": "Uni Frankfurt",
|
||||
"backendUrl": "https://mobile.server.uni-frankfurt.de",
|
||||
"backendVersion": "3.1.0",
|
||||
"appLinkHost": "mobile.app.uni-frankfurt.de",
|
||||
"appUrlScheme": "de.unifrankfurt.app",
|
||||
"appMarketingVersion": "2.3.0",
|
||||
"android": {
|
||||
"packageName": "de.unifrankfurt.app"
|
||||
}
|
||||
}
|
||||
BIN
frontend/app/config/f-u/favicon.png
Normal file
BIN
frontend/app/config/f-u/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
BIN
frontend/app/config/f-u/logo.png
Normal file
BIN
frontend/app/config/f-u/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.3 KiB |
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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 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/>.
|
||||
*/
|
||||
|
||||
/** @type {import('./scripts/icon-config').IconConfig} */
|
||||
const config = {
|
||||
inputPath: 'node_modules/material-symbols/material-symbols-rounded.woff2',
|
||||
outputPath: 'src/assets/icons.min.woff2',
|
||||
htmlGlob: 'src/**/*.html',
|
||||
scriptGlob: 'src/**/*.ts',
|
||||
additionalIcons: {
|
||||
about: ['copyright', 'campaign', 'policy', 'description', 'text_snippet'],
|
||||
navigation: [
|
||||
'home',
|
||||
'newspaper',
|
||||
'search',
|
||||
'calendar_month',
|
||||
'local_cafe',
|
||||
'local_library',
|
||||
'inventory_2',
|
||||
'map',
|
||||
'grade',
|
||||
'account_circle',
|
||||
'settings',
|
||||
'info',
|
||||
'rate_review',
|
||||
'work',
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -14,14 +14,10 @@
|
||||
"Thea Schöbl <dev@theaninova.de>"
|
||||
],
|
||||
"scripts": {
|
||||
"analyze": "webpack-bundle-analyzer www/stats.json",
|
||||
"build": "pnpm check-icons && ng build --configuration=production --stats-json && webpack-bundle-analyzer www/stats.json --mode static --report www/bundle-info.html --no-open",
|
||||
"build:analyze": "npm run build:stats && npm run analyze",
|
||||
"build": "ng build --configuration=production",
|
||||
"build:android": "ionic capacitor build android --no-open && cd android && ./gradlew clean assemble && cd ..",
|
||||
"build:prod": "ng build --configuration=production",
|
||||
"build:stats": "ng build --configuration=production --stats-json",
|
||||
"changelog": "conventional-changelog -p angular -i src/assets/about/CHANGELOG.md -s -r 0",
|
||||
"check-icons": "node scripts/check-icon-correctness.mjs",
|
||||
"chromium:no-cors": "chromium --disable-web-security --user-data-dir=\".browser-data/chromium\"",
|
||||
"chromium:virtual-host": "chromium --host-resolver-rules=\"MAP mobile.app.uni-frankfurt.de:* localhost:8100\" --ignore-certificate-errors",
|
||||
"cypress:open": "cypress open",
|
||||
@@ -139,6 +135,7 @@
|
||||
"@ionic/cli": "7.2.0",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@openstapps/angular-builder": "workspace:*",
|
||||
"@types/fontkit": "2.0.7",
|
||||
"@types/geojson": "1.0.6",
|
||||
"@types/glob": "8.1.0",
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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 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/>.
|
||||
*/
|
||||
import {readFileSync, writeFileSync} from 'fs';
|
||||
import {omit, pickBy} from '@openstapps/collection-utils';
|
||||
|
||||
/**
|
||||
* accumulate and transform licenses based on two license files
|
||||
* @param {string} path
|
||||
* @param {string} additionalLicensesPath
|
||||
*/
|
||||
function accumulateFile(path, additionalLicensesPath) {
|
||||
const packageJson = JSON.parse(readFileSync('./package.json').toString());
|
||||
const dependencies = packageJson.dependencies;
|
||||
|
||||
console.log(`Accumulating licenses from ${path}`);
|
||||
|
||||
writeFileSync(
|
||||
path,
|
||||
JSON.stringify(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
Object.entries({
|
||||
...pickBy(JSON.parse(readFileSync(path).toString()), (_, key) => {
|
||||
const parts = /** @type {string} */ (key).split('@');
|
||||
|
||||
return dependencies[parts.slice(0, -1).join('@')] === parts[parts.length - 1];
|
||||
}),
|
||||
...JSON.parse(readFileSync(additionalLicensesPath).toString()),
|
||||
})
|
||||
.map(([key, value]) => ({
|
||||
licenseText: value.licenseFile && readFileSync(value.licenseFile, 'utf8'),
|
||||
name: key,
|
||||
...omit(value, 'licenseFile', 'path'),
|
||||
}))
|
||||
.sort((a, b) => a.name.localeCompare(b.name)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
accumulateFile('./src/assets/about/licenses.json', './additional-licenses.json');
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* 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 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/>.
|
||||
*/
|
||||
import {openSync} from 'fontkit';
|
||||
import config from '../icons.config.mjs';
|
||||
import {existsSync} from 'fs';
|
||||
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons.mjs';
|
||||
import {fetchCodePointMap} from './get-code-points.mjs';
|
||||
|
||||
const commandName = '"npm run minify-icons"';
|
||||
if (!existsSync(config.outputPath)) {
|
||||
console.error(`Minified font not found. Run ${commandName} first.`);
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
/** @type {import('fontkit').Font} */
|
||||
const modifiedFont = openSync(config.outputPath);
|
||||
|
||||
let success = true;
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||
checkAll().then(() => {
|
||||
console.log();
|
||||
if (success) {
|
||||
console.log('All icons are present in both fonts.');
|
||||
} else {
|
||||
console.error('Errors occurred.');
|
||||
process.exit(-1);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async function checkAll() {
|
||||
check(config.additionalIcons || {});
|
||||
check(await getUsedIconsTS(config.scriptGlob));
|
||||
check(await getUsedIconsHtml(config.htmlGlob));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, string[]>} icons
|
||||
*/
|
||||
async function check(icons) {
|
||||
const codePoints = await fetchCodePointMap();
|
||||
|
||||
for (const icon of Object.values(icons).flat()) {
|
||||
const codePoint = codePoints.get(icon);
|
||||
if (!codePoint) throw new Error(`"${icon}" is not a valid icon`);
|
||||
if (!modifiedFont.getGlyph(Number.parseInt(codePoint, 16))) {
|
||||
throw new Error(`"${icon}" (code point ${codePoint}) is missing`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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 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/>.
|
||||
*/
|
||||
import {glob} from 'glob';
|
||||
import {readFileSync} from 'fs';
|
||||
import {
|
||||
matchPropertyAccess,
|
||||
matchPropertyContent,
|
||||
matchTagProperties,
|
||||
} from '../src/app/util/ion-icon/icon-match.mjs';
|
||||
|
||||
/**
|
||||
* @returns {Promise<Record<string, string[]>>}
|
||||
*/
|
||||
export async function getUsedIconsHtml(pattern = 'src/**/*.html') {
|
||||
return Object.fromEntries(
|
||||
(await glob(pattern))
|
||||
.map(file => [
|
||||
file,
|
||||
readFileSync(file, 'utf8')
|
||||
.match(matchTagProperties('ion-icon'))
|
||||
?.flatMap(match => {
|
||||
return match.match(matchPropertyContent(['name', 'md', 'ios']));
|
||||
})
|
||||
.filter(it => !!it) || [],
|
||||
])
|
||||
.filter(([, values]) => values && values.length > 0),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<Record<string, string[]>>}
|
||||
*/
|
||||
export async function getUsedIconsTS(pattern = 'src/**/*.ts') {
|
||||
const regex = matchPropertyAccess('SCIcon');
|
||||
return Object.fromEntries(
|
||||
(await glob(pattern))
|
||||
.map(file => [file, readFileSync(file, 'utf8').match(regex) || []])
|
||||
.filter(([, values]) => values && values.length > 0),
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
const url =
|
||||
'https://raw.githubusercontent.com/google/material-design-icons/master/' +
|
||||
'variablefont/MaterialSymbolsRounded%5BFILL%2CGRAD%2Copsz%2Cwght%5D.codepoints';
|
||||
|
||||
export async function fetchCodePointMap() {
|
||||
const icons = await fetch(url)
|
||||
.then(it => it.text())
|
||||
.then(it => new Map(it.split('\n').map(it => /** @type {[string, string]} */ (it.split(' ')))));
|
||||
if (icons.size < 100) throw new Error(`Code point map is very small, is the URL incorrect? ${url}`);
|
||||
return icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} icons
|
||||
*/
|
||||
export async function getCodePoints(icons) {
|
||||
const codePoints = await fetchCodePointMap();
|
||||
return icons.map(icon => {
|
||||
const code = codePoints.get(icon);
|
||||
if (!code) throw new Error(`Code point for icon ${icon} not found`);
|
||||
return code;
|
||||
});
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import {networkInterfaces} from 'os';
|
||||
|
||||
console.log(
|
||||
Object.entries(networkInterfaces())
|
||||
.map(([, info]) => info)
|
||||
.flat()
|
||||
.find(info => info && !info.internal && info.family === 'IPv4')?.address,
|
||||
);
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* 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 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/>.
|
||||
*/
|
||||
|
||||
export interface IconConfig {
|
||||
scriptGlob?: string;
|
||||
htmlGlob?: string;
|
||||
inputPath: string;
|
||||
outputPath: string;
|
||||
additionalIcons?: {[purpose: string]: string[]};
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* 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 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/>.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import {exec} from 'child_process';
|
||||
import config from '../icons.config.mjs';
|
||||
import {statSync} from 'fs';
|
||||
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons.mjs';
|
||||
import {getCodePoints} from './get-code-points.mjs';
|
||||
|
||||
/**
|
||||
* @param {string[] | string} command
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function run(command) {
|
||||
const fullCommand = Array.isArray(command) ? command.join(' ') : command;
|
||||
console.log(`>> ${fullCommand}`);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(fullCommand, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else if (stderr) {
|
||||
reject(stderr);
|
||||
} else {
|
||||
resolve(stdout.trim());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async function minifyIconFont() {
|
||||
/** @type {Set<string>} */
|
||||
const icons = new Set();
|
||||
|
||||
for (const iconSet of [
|
||||
...Object.values(config.additionalIcons || []),
|
||||
...Object.values(await getUsedIconsTS(config.scriptGlob)),
|
||||
...Object.values(await getUsedIconsHtml(config.htmlGlob)),
|
||||
]) {
|
||||
for (const icon of iconSet) {
|
||||
icons.add(icon);
|
||||
}
|
||||
}
|
||||
|
||||
const glyphs = ['5f-7a', '30-39', ...(await getCodePoints([...icons]))].sort();
|
||||
|
||||
console.log(
|
||||
await run([
|
||||
'pyftsubset',
|
||||
`"${config.inputPath}"`,
|
||||
`--unicodes=${glyphs.join(',')}`,
|
||||
'--no-layout-closure',
|
||||
`--output-file="${config.outputPath}"`,
|
||||
'--flavor=woff2',
|
||||
]),
|
||||
);
|
||||
|
||||
console.log(`${glyphs.length} Used Icons Total`);
|
||||
console.log(`Minified font saved to ${config.outputPath}`);
|
||||
const result = statSync(config.outputPath).size;
|
||||
const before = statSync(config.inputPath).size;
|
||||
|
||||
console.log(
|
||||
`${toByteUnit(before)} > ${toByteUnit(result)} (${(((before - result) / before) * 100).toFixed(
|
||||
2,
|
||||
)}% Reduction)`,
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||
minifyIconFont();
|
||||
|
||||
/**
|
||||
* Bytes to respective units
|
||||
* @param {number} value
|
||||
* @returns {string}
|
||||
*/
|
||||
function toByteUnit(value) {
|
||||
if (value < 1024) {
|
||||
return `${value}B`;
|
||||
} else if (value < 1024 * 1024) {
|
||||
return `${(value / 1024).toFixed(2)}KB`;
|
||||
} else {
|
||||
return `${(value / 1024 / 1024).toFixed(2)}MB`;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": "@openstapps/tsconfig",
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "Node"
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import {ActivatedRoute} from '@angular/router';
|
||||
import {SCAboutPage, SCAppConfiguration} from '@openstapps/core';
|
||||
import {ConfigProvider} from '../../config/config.provider';
|
||||
import packageJson from '../../../../../package.json';
|
||||
import config from 'capacitor.config';
|
||||
import config from '../../../../../config/default.json';
|
||||
import {App} from '@capacitor/app';
|
||||
import {Capacitor} from '@capacitor/core';
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ import {
|
||||
SCTranslations,
|
||||
} from '@openstapps/core';
|
||||
import {NavigationService} from './navigation.service';
|
||||
import config from 'capacitor.config';
|
||||
import {SettingsProvider} from '../../settings/settings.provider';
|
||||
import {BreakpointObserver} from '@angular/cdk/layout';
|
||||
import config from '../../../../../config/default.json';
|
||||
|
||||
/**
|
||||
* Generated class for the MenuPage page.
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export function matchTagProperties(tag: string): RegExp;
|
||||
|
||||
export function matchPropertyContent(properties: string[]): RegExp;
|
||||
|
||||
export function matchPropertyAccess(objectName: string): RegExp;
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {string} tag
|
||||
*/
|
||||
export function matchTagProperties(tag) {
|
||||
return new RegExp(`(?<=<${tag})[\\s\\S]*?(?=>\\s*<\\/${tag}\\s*>)`, 'g');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} properties
|
||||
*/
|
||||
export function matchPropertyContent(properties) {
|
||||
const names = properties.join('|');
|
||||
|
||||
return new RegExp(`((?<=(${names})=")[\\w-]+(?="))|((?<=\\[(${names})]="')[\\w-]+(?='"))`, 'g');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} objectName
|
||||
*/
|
||||
export function matchPropertyAccess(objectName) {
|
||||
return new RegExp(`(?<=${objectName}\\s*\\.\\s*)\\w+`, 'g');
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* 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 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/>.
|
||||
*/
|
||||
/* eslint-disable unicorn/no-null */
|
||||
import {matchPropertyAccess, matchPropertyContent, matchTagProperties} from './icon-match.mjs';
|
||||
|
||||
describe('matchTagProperties', function () {
|
||||
const regex = matchTagProperties('test');
|
||||
|
||||
it('should match html tag content', function () {
|
||||
expect('<test content></test>'.match(regex)).toEqual([' content']);
|
||||
});
|
||||
|
||||
it('should match all tags', function () {
|
||||
expect('<test content1></test> <test content2></test>'.match(regex)).toEqual([' content1', ' content2']);
|
||||
});
|
||||
|
||||
it('should not match wrong tags', function () {
|
||||
expect('<no content></no>'.match(regex)).toEqual(null);
|
||||
});
|
||||
|
||||
it('should accept valid html whitespaces', function () {
|
||||
expect(
|
||||
`
|
||||
<test
|
||||
content
|
||||
>
|
||||
</test
|
||||
>
|
||||
`.match(regex),
|
||||
).toEqual(['\n content\n ']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('matchPropertyContent', function () {
|
||||
const regex = matchPropertyContent(['test1', 'test2']);
|
||||
|
||||
it('should match bare literals', function () {
|
||||
expect(`test1="content" test2="content1"`.match(regex)).toEqual(['content', 'content1']);
|
||||
});
|
||||
|
||||
it('should match angular literals', function () {
|
||||
expect(`[test1]="'content'" [test2]="'content1'"`.match(regex)).toEqual(['content', 'content1']);
|
||||
});
|
||||
|
||||
it('should not match wrong literals', function () {
|
||||
expect(`no="content" [no]="'content'"`.match(regex)).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('matchPropertyAccess', function () {
|
||||
const property = '0_20a_boninAo0_';
|
||||
const object = 'test';
|
||||
const regex = matchPropertyAccess(object);
|
||||
|
||||
it('should match property access', function () {
|
||||
expect(`${object}.${property}`.match(regex)).toEqual([property]);
|
||||
});
|
||||
|
||||
it('should respect whitespace', function () {
|
||||
expect(`${object}. ${property}`.match(regex)).toEqual([property]);
|
||||
expect(`${object} .${property}`.match(regex)).toEqual([property]);
|
||||
expect(`${object} . ${property}`.match(regex)).toEqual([property]);
|
||||
expect(`${object} \n . \n ${property}`.match(regex)).toEqual([property]);
|
||||
});
|
||||
|
||||
it('should not include invalid trailing stuff', function () {
|
||||
expect(`${object}.${property}!`.match(regex)).toEqual([property]);
|
||||
expect(`${object}.${property}.`.match(regex)).toEqual([property]);
|
||||
expect(`${object}.${property}-`.match(regex)).toEqual([property]);
|
||||
expect(`${object}.${property}]`.match(regex)).toEqual([property]);
|
||||
expect(`${object}.${property}}`.match(regex)).toEqual([property]);
|
||||
expect(`${object}.${property};`.match(regex)).toEqual([property]);
|
||||
expect(`${object}.${property}:`.match(regex)).toEqual([property]);
|
||||
});
|
||||
});
|
||||
BIN
frontend/app/src/assets/icon/favicon.png
Normal file
BIN
frontend/app/src/assets/icon/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -16,12 +16,13 @@
|
||||
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
|
||||
// `ng build --env=prod` then `environment.production.ts` will be used instead.
|
||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
import config from '../../config/default.json';
|
||||
|
||||
export const environment = {
|
||||
backend_url: 'https://mobile.server.uni-frankfurt.de',
|
||||
app_host: 'mobile.app.uni-frankfurt.de',
|
||||
custom_url_scheme: 'de.anyschool.app',
|
||||
backend_version: '999.0.0',
|
||||
backend_url: config.backendUrl,
|
||||
app_host: config.appLinkHost,
|
||||
custom_url_scheme: config.appUrlScheme,
|
||||
backend_version: config.backendVersion,
|
||||
production: true,
|
||||
};
|
||||
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
|
||||
// `ng build --env=prod` then `environment.production.ts` will be used instead.
|
||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
import config from '../../config/default.json';
|
||||
|
||||
export const environment = {
|
||||
backend_url: 'https://mobile.server.uni-frankfurt.de',
|
||||
app_host: 'mobile.app.uni-frankfurt.de',
|
||||
custom_url_scheme: 'de.anyschool.app',
|
||||
backend_version: '999.0.0',
|
||||
backend_url: config.backendUrl,
|
||||
app_host: config.appLinkHost,
|
||||
custom_url_scheme: config.appUrlScheme,
|
||||
backend_version: config.backendVersion,
|
||||
production: false,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user