Skip to content

Commit

Permalink
Added script to pull latest icons
Browse files Browse the repository at this point in the history
  • Loading branch information
akopachov committed Aug 30, 2023
1 parent 8b51721 commit bb7edb8
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 113 deletions.
2 changes: 2 additions & 0 deletions .github/release-body.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
* USDT: `0xa12163eD56e35d3B38F7087B573384E40b2785e1`
* DOGE: `DAa3nu1RCWwxZdAnGVga77bgxDFP1nhahj`
* TON: `EQCSBzoTb1B7RhXnka5RegmdjHR3gQwRVgZHNPPqzjjvlW9T`

## Antivirus scanner results
11 changes: 0 additions & 11 deletions convert-aegis-icons.js

This file was deleted.

182 changes: 93 additions & 89 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,89 +1,93 @@
{
"name": "flipper-authenticator-companion",
"version": "1.1.0",
"private": true,
"description": "Flipper Authenticator Companion App",
"main": "src/electron.cjs",
"type": "module",
"author": "Alexander Kopachov (@akopachov)",
"scripts": {
"dev": "cross-env NODE_ENV=dev pnpm run dev:all",
"dev:all": "concurrently -n=svelte,electron -c='#ff3e00',blue \"pnpm run dev:svelte\" \"pnpm run dev:electron\"",
"dev:svelte": "vite dev",
"dev:electron": "electron src/electron.cjs",
"build": "cross-env NODE_ENV=production pnpm run build:svelte && pnpm build:electron",
"build:svelte": "vite build",
"build:electron": "electron-builder --config build.config.json",
"lint": "eslint src/",
"lint:fix": "eslint src/ --fix"
},
"browserslist": [
"Chrome 89"
],
"engines": {
"node": ">=18",
"pnpm": ">=8",
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm"
},
"devDependencies": {
"@floating-ui/dom": "^1.5.1",
"@skeletonlabs/skeleton": "^2.0.0",
"@skeletonlabs/tw-plugin": "^0.1.0",
"@sveltejs/adapter-static": "2.0.3",
"@sveltejs/kit": "1.24.0",
"@tailwindcss/forms": "^0.5.6",
"@tailwindcss/typography": "^0.5.9",
"@types/node": "^20.5.7",
"@types/papaparse": "^5.3.8",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"async-sema": "^3.1.1",
"autoprefixer": "^10.4.15",
"concurrently": "^8.2.1",
"cross-env": "^7.0.3",
"delay": "^6.0.0",
"electron": "^26.1.0",
"electron-builder": "^24.6.3",
"electron-connect": "^0.6.3",
"electron-packager": "^17.1.2",
"electron-reloader": "^1.2.3",
"escape-string-regexp": "^5.0.0",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-svelte": "^2.33.0",
"papaparse": "^5.4.1",
"postcss": "^8.4.29",
"postcss-load-config": "^4.0.1",
"prettier": "^3.0.3",
"prettier-plugin-svelte": "^3.0.3",
"qr-scanner": "^1.4.2",
"sass": "^1.66.1",
"smart-buffer": "^4.2.0",
"svelte": "^4.2.0",
"svelte-check": "^3.5.1",
"svelte-dnd-action": "^0.9.26",
"svelte-eslint-parser": "^0.33.0",
"svelte-preprocess": "^5.0.4",
"tailwindcss": "^3.3.3",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"url-otpauth-ng": "^3.1.0",
"utc-offsets": "^1.0.0",
"uuid": "^9.0.0",
"vite": "^4.4.9",
"vite-plugin-electron-renderer": "^0.14.5",
"vite-plugin-tailwind-purgecss": "^0.1.3"
},
"dependencies": {
"electron-log": "^4.4.8",
"electron-serve": "^1.1.0",
"electron-store": "^8.1.0",
"electron-updater": "^6.1.1",
"electron-window-state": "^5.0.3",
"node-screenshots": "^0.1.6",
"serialport": "^12.0.0"
}
}
{
"name": "flipper-authenticator-companion",
"version": "1.1.0",
"private": true,
"description": "Flipper Authenticator Companion App",
"main": "src/electron.cjs",
"type": "module",
"author": "Alexander Kopachov (@akopachov)",
"scripts": {
"dev": "cross-env NODE_ENV=dev pnpm run dev:all",
"dev:all": "concurrently -n=svelte,electron -c='#ff3e00',blue \"pnpm run dev:svelte\" \"pnpm run dev:electron\"",
"dev:svelte": "vite dev",
"dev:electron": "electron src/electron.cjs",
"build": "cross-env NODE_ENV=production pnpm run build:svelte && pnpm build:electron",
"build:svelte": "vite build",
"build:electron": "electron-builder --config build.config.json",
"lint": "eslint src/",
"lint:fix": "eslint src/ --fix",
"update:icons": "node update-aegis-icons.cjs"
},
"browserslist": [
"Chrome 89"
],
"engines": {
"node": ">=18",
"pnpm": ">=8",
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm"
},
"devDependencies": {
"@floating-ui/dom": "^1.5.1",
"@skeletonlabs/skeleton": "^2.0.0",
"@skeletonlabs/tw-plugin": "^0.1.0",
"@sveltejs/adapter-static": "2.0.3",
"@sveltejs/kit": "1.24.0",
"@tailwindcss/forms": "^0.5.6",
"@tailwindcss/typography": "^0.5.9",
"@types/node": "^20.5.7",
"@types/papaparse": "^5.3.8",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"async-sema": "^3.1.1",
"autoprefixer": "^10.4.15",
"concurrently": "^8.2.1",
"cross-env": "^7.0.3",
"delay": "^6.0.0",
"electron": "^26.1.0",
"electron-builder": "^24.6.3",
"electron-connect": "^0.6.3",
"electron-packager": "^17.1.2",
"electron-reloader": "^1.2.3",
"escape-string-regexp": "^5.0.0",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-svelte": "^2.33.0",
"papaparse": "^5.4.1",
"postcss": "^8.4.29",
"postcss-load-config": "^4.0.1",
"prettier": "^3.0.3",
"prettier-plugin-svelte": "^3.0.3",
"qr-scanner": "^1.4.2",
"sass": "^1.66.1",
"smart-buffer": "^4.2.0",
"svelte": "^4.2.0",
"svelte-check": "^3.5.1",
"svelte-dnd-action": "^0.9.26",
"svelte-eslint-parser": "^0.33.0",
"svelte-preprocess": "^5.0.4",
"tailwindcss": "^3.3.3",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"url-otpauth-ng": "^3.1.0",
"utc-offsets": "^1.0.0",
"uuid": "^9.0.0",
"vite": "^4.4.9",
"vite-plugin-electron-renderer": "^0.14.5",
"vite-plugin-tailwind-purgecss": "^0.1.3"
},
"dependencies": {
"electron-log": "^4.4.8",
"electron-serve": "^1.1.0",
"electron-store": "^8.1.0",
"electron-updater": "^6.1.1",
"electron-window-state": "^5.0.3",
"node-screenshots": "^0.1.6",
"serialport": "^12.0.0"
},
"optionalDependencies": {
"adm-zip": "^0.5.10"
}
}
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/lib/totp-icons/catalog.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions static/totp-icons/Key.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 0 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,8 @@
"types": ["vite/client", "node"],
"typeRoots": ["node_modules/@types"],
"lib": ["ESNext"],
/**
svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
to enforce using \`import type\` instead of \`import\` for Types.
*/
"importsNotUsedAsValues": "error",
"isolatedModules": true,
/**
To have warnings/errors of the Svelte compiler at the correct position,
enable source maps by default.
*/
"sourceMap": true,
"esModuleInterop": true,
"skipLibCheck": true,
Expand Down
58 changes: 58 additions & 0 deletions update-aegis-icons.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const AdmZip = require('adm-zip');
const fs = require('node:fs/promises');

const IconsDirectory = './static/totp-icons';
const IconsCatalogPath = './src/lib/totp-icons/catalog.json';

function mapAegisCatalog(data, tag) {
return {
uuid: data.uuid,
name: data.name,
version: data.version,
tag: tag,
icons: data.icons
.filter(i => i.filename.includes('1_Primary'))
.map(m => ({ filename: m.filename.replace('icons/1_Primary/', ''), issuer: m.issuer.map(i => i.toLowerCase()) })),
};
}

async function main() {
const latestReleaseResponse = await fetch('https://github.com/aegis-icons/aegis-icons/releases/latest');
const actualReleaseTag = latestReleaseResponse.url.replace('https://github.com/aegis-icons/aegis-icons/releases/tag/', '');
let existingCatalogTag = 'N/A';
try {
const existingCatalog = require(IconsCatalogPath);
existingCatalogTag = existingCatalog.tag;
} catch {
/* empty */
}
if (existingCatalogTag != actualReleaseTag) {
console.info(`New version of AEGIS icons are available! Existing: ${existingCatalogTag}, New: ${actualReleaseTag}`);
console.info('Downloading ZIP');
const catalogZipResponse = await fetch(
'https://github.com/aegis-icons/aegis-icons/releases/latest/download/aegis-icons.zip',
);

const catalogZipBuffer = Buffer.from(await catalogZipResponse.arrayBuffer());
const catalogZip = new AdmZip(catalogZipBuffer, { readEntries: true });
await fs.rm(IconsDirectory, { recursive: true, force: true });

console.info('Extracting icons');
await fs.mkdir(IconsDirectory, { recursive: true });
for (let entry of catalogZip.getEntries()) {
if (entry.entryName.startsWith('icons/1_Primary') || entry.entryName == 'icons/3_Generic/Key.svg') {
catalogZip.extractEntryTo(entry, IconsDirectory, false, true, false);
}
}

console.info('Building catalog file');
const rawCatalog = JSON.parse(catalogZip.getEntry('pack.json').getData().toString('utf-8'));
const filteredCatalog = mapAegisCatalog(rawCatalog, actualReleaseTag);
await fs.writeFile(IconsCatalogPath, JSON.stringify(filteredCatalog));
console.log('Done!');
} else {
console.info('No new version available');
}
}

main();

0 comments on commit bb7edb8

Please sign in to comment.