Updated
This commit is contained in:
parent
d61b8b7bd8
commit
46783c4f38
57 changed files with 4178 additions and 5992 deletions
13
frontend/@dasig/scripts/functions/encryptRsa.ts
Normal file
13
frontend/@dasig/scripts/functions/encryptRsa.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { JSEncrypt } from "jsencrypt";
|
||||
import { $rsaPublicKey } from "../../../configs/config.security.ts";
|
||||
|
||||
const enc = new JSEncrypt();
|
||||
const PUBLIC_KEY = $rsaPublicKey.get();
|
||||
|
||||
export default (message: string) => {
|
||||
enc.setPublicKey(PUBLIC_KEY);
|
||||
const encrypted = enc.encrypt(message).toString();
|
||||
const fixedEncrypted = encrypted.replace(/\//g, "~");
|
||||
|
||||
return fixedEncrypted;
|
||||
};
|
||||
1
frontend/@dasig/scripts/index.ts
Normal file
1
frontend/@dasig/scripts/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { default as encryptRsa } from "./functions/encryptRsa.ts";
|
||||
23
frontend/@dasig/scripts/node/generateFavicon.js
Normal file
23
frontend/@dasig/scripts/node/generateFavicon.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { consola } from 'consola';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import sharp from 'sharp';
|
||||
|
||||
try {
|
||||
const dirPath = path.resolve('./public')
|
||||
|
||||
if (fs.existsSync(dirPath)) {
|
||||
const inputSrc = './src/images/favicon.png'
|
||||
const favicon = dirPath + '/favicon.png'
|
||||
const faviconBuffer = await sharp(inputSrc).png({ quality: 90 }).resize(48).toBuffer()
|
||||
await sharp(faviconBuffer).toFile(favicon)
|
||||
consola.success('Favicon generated successfully')
|
||||
} else {
|
||||
consola.error('Directory does not exist:', dirPath)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
if (error.message.includes('missing')) {
|
||||
consola.error('Source favicon does not exist')
|
||||
}
|
||||
}
|
||||
41
frontend/@dasig/scripts/node/optimizeImage.js
Normal file
41
frontend/@dasig/scripts/node/optimizeImage.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { consola } from 'consola';
|
||||
import sharp from 'sharp';
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
|
||||
(async () => {
|
||||
const argv = yargs(hideBin(process.argv))
|
||||
.option('name', {
|
||||
alias: 'n',
|
||||
describe: 'Specify the name of the image',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
})
|
||||
.option('size', {
|
||||
alias: 's',
|
||||
describe: 'Specify the size of the image',
|
||||
type: 'number',
|
||||
demandOption: true,
|
||||
})
|
||||
.argv;
|
||||
|
||||
const name = argv.name;
|
||||
const size = argv.size;
|
||||
|
||||
try {
|
||||
const avifOutputPath = `./src/@dasig/images/${name.toString().split('.').slice(0, -1).join('.')}.avif`
|
||||
const webpOutputPath = `./src/@dasig/images/${name.toString().split('.').slice(0, -1).join('.')}.webp`
|
||||
|
||||
const avifBuffer = await sharp(`./src/images/${name}`).avif({ quality: 60 }).resize(size).toBuffer()
|
||||
await sharp(avifBuffer).toFile(avifOutputPath)
|
||||
consola.success(`${name} successfully optimized in Avif`)
|
||||
|
||||
const webpBuffer = await sharp(`./src/images/${name}`).webp({ quality: 75 }).resize(size).toBuffer()
|
||||
await sharp(webpBuffer).toFile(webpOutputPath)
|
||||
consola.success(`${name} successfully optimized in Webp`)
|
||||
} catch (error) {
|
||||
consola.error('Error optimizing image:', error)
|
||||
if (error.message.includes('missing')) consola.error(`${name} could not be found on image folder`)
|
||||
}
|
||||
})()
|
||||
|
||||
33
frontend/@dasig/scripts/node/optimizeLogo.js
Normal file
33
frontend/@dasig/scripts/node/optimizeLogo.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { consola } from 'consola';
|
||||
import sharp from 'sharp';
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
|
||||
(async () => {
|
||||
const argv = yargs(hideBin(process.argv))
|
||||
.option('size', {
|
||||
alias: 's',
|
||||
describe: 'Specify the size of the logo',
|
||||
type: 'number',
|
||||
demandOption: true,
|
||||
})
|
||||
.argv;
|
||||
|
||||
const size = argv.size;
|
||||
|
||||
try {
|
||||
const webpImage = './src/@dasig/images/logo.webp'
|
||||
const avifImage = './src/@dasig/images/logo.avif'
|
||||
const inputSrc = './src/images/logo.png'
|
||||
|
||||
const avifBuffer = await sharp(inputSrc).avif({ quality: 60 }).resize(size).toBuffer()
|
||||
await sharp(avifBuffer).toFile(avifImage)
|
||||
consola.success('Logo successfully optimized in Avif')
|
||||
|
||||
const webpBuffer = await sharp(inputSrc).webp({ quality: 75 }).resize(size).toBuffer()
|
||||
await sharp(webpBuffer).toFile(webpImage)
|
||||
consola.success('Logo successfully optimized in Webp')
|
||||
} catch (error) {
|
||||
consola.error('Error generating favicon:', error)
|
||||
}
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue