Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
firefoxic committed Oct 8, 2024
1 parent b59e593 commit f46cf0b
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 177 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
engine-strict=true
manage-package-manager-versions=true
shell-emulator=true
18 changes: 9 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and 
- The verbose and useless `images` command execution messages have been replaced by a compact and clear progressbar.
- Source file extensions can now be in uppercase.

## [2.1.0] — 2024–08–13
## [2.1.0] — 2024–08–13

### Added

- The `--addMetaData` (`-m`) flag is now also available for the `icons` command. Enabling it will create an `index.css` file in the output directory, which contains registrations of custom properties with paths to icons.
- The `--originDensity` (`-d`) option now takes the value `0`. This works like the `1` value, but without adding the density suffix to the filename.

## [2.0.0] — 2024–06–13
## [2.0.0] — 2024–06–13

### Changed

Expand All @@ -36,26 +36,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and 
- New CLI option `-p` (`--publicDirectory`) for the favicons command, allowing you to specify a directory (`public` by default) with static assets where the source SVG files for generating favicons are expected.
- New CLI flag `-m` (`--addMetaData`), enabling which when processing raster images additionally generates metadata files in JSON and JS formats.

## [1.0.3] — 2024–05–24
## [1.0.3] — 2024–05–24

### Fixed

- The path to `icon-180.png` (Apple touch icon) is now correctly generated in `Links.md`.

## [1.0.2] — 2024–05–06
## [1.0.2] — 2024–05–06

### Fixed

- Paths in the `webmanifest` are now generated correctly on Windows.

## [1.0.1] — 2024–05–06
## [1.0.1] — 2024–05–06

### Fixed

- The `conjure favicons` command now works fine on Windows.
- The `webmanifest` is now generated with a final newline.

## [1.0.0] — 2024–04–19
## [1.0.0] — 2024–04–19

### Changed

Expand All @@ -66,19 +66,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and 

- Gereration of `Links.md` file with advice on the code of links for generated files, moving files, and fixing paths to files.

## [0.1.2] — 2024–04–17
## [0.1.2] — 2024–04–17

### Fixed

- No longer requires `pnpm` for package users.

## [0.1.1] — 2024–04–10
## [0.1.1] — 2024–04–10

### Fixed

- Paths to icons in the generated webmanifest.

## [0.1.0] — 2024–04–05
## [0.1.0] — 2024–04–05

### Added

Expand Down
6 changes: 3 additions & 3 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import meow from "meow"

import { conjureAll, conjureFavicons, conjureIcons, conjureImages } from "../lib/index.js"

const cli = meow(`
let cli = meow(`
Usage
$ conjure <command> [options]
Expand Down Expand Up @@ -118,9 +118,9 @@ Examples
},
})

const [command] = cli.input
let [command] = cli.input

const options = { command, ...cli.flags }
let options = { command, ...cli.flags }

if (!(`inputDirectory` in cli.flags)) {
options.inputDirectory = `src/shared${command === `all` ? `` : `/${command}`}`
Expand Down
6 changes: 3 additions & 3 deletions lib/convertSvgToIco.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import sharp from "sharp"
*/
export async function convertSvgToIco ({ publicDirectory, ico32, ico16 }) {
try {
const pngBuffer = [await sharp(ico32).resize(32, 32).png().toBuffer()]
let pngBuffer = [await sharp(ico32).resize(32, 32).png().toBuffer()]

if (ico16) pngBuffer.push(await sharp(ico16).resize(16, 16).png().toBuffer())

const destPath = resolve(publicDirectory, `favicon.ico`)
const destData = icoEndec.encode(pngBuffer)
let destPath = resolve(publicDirectory, `favicon.ico`)
let destData = icoEndec.encode(pngBuffer)

await writeFile(destPath, destData)
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion lib/createLinksFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { writeFile } from "node:fs/promises"
* @returns {Promise<void>} - A promise that resolves when the links file is created.
*/
export async function createLinksFile ({ publicDirectory }) {
const content = `# Favicon links
let content = `# Favicon links
Paste the following links to the \`<head>\` of your HTML document layout:
Expand Down
18 changes: 9 additions & 9 deletions lib/createRasterFavicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import sharp from "sharp"
* @param {string} options.touchIcon - Path to vector touch icon files.
*/
export async function createRasterFavicons ({ publicDirectory, touchIcon }) {
const fileNamePrefix = `icon-`
let fileNamePrefix = `icon-`

const sizes = [180, 192, 512]
const formats = [`png`, `webp`]
let sizes = [180, 192, 512]
let formats = [`png`, `webp`]
let icons = []
let iconDirectory = `${publicDirectory}/favicons`

Expand All @@ -26,16 +26,16 @@ export async function createRasterFavicons ({ publicDirectory, touchIcon }) {
await mkdir(iconDirectory, { recursive: true })
}

for (const format of formats) {
for (const size of sizes) {
for (let format of formats) {
for (let size of sizes) {
if (format === `webp` && size === 180) continue

try {
const image = sharp(touchIcon)
let image = sharp(touchIcon)
.resize(size)
.toFormat(format, { lossless: true })

const outputPath = resolve(iconDirectory, `${fileNamePrefix}${size}.${format}`)
let outputPath = resolve(iconDirectory, `${fileNamePrefix}${size}.${format}`)

await image.toFile(outputPath)
} catch (err) {
Expand All @@ -60,13 +60,13 @@ export async function createRasterFavicons ({ publicDirectory, touchIcon }) {
error(`Error reading package.json:`, err)
}

const webmanifest = {
let webmanifest = {
...(packageInfo.name && { name: packageInfo.name }),
...(packageInfo.description && { description: packageInfo.description }),
icons,
}

const webmanifestPath = resolve(publicDirectory, `manifest.webmanifest`)
let webmanifestPath = resolve(publicDirectory, `manifest.webmanifest`)

try {
await writeFile(webmanifestPath, `${JSON.stringify(webmanifest, null, `\t`)}\n`)
Expand Down
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export async function conjureFavicons (options) {
* @returns {Promise<void>} - A promise that resolves when all the assets are optimized.
*/
export async function conjureAll (options) {
const iconsOptions = prepareOptionsForCommand(`icons`)
const imagesOptions = prepareOptionsForCommand(`images`)
const faviconsOptions = prepareOptionsForCommand(`favicons`)
let iconsOptions = prepareOptionsForCommand(`icons`)
let imagesOptions = prepareOptionsForCommand(`images`)
let faviconsOptions = prepareOptionsForCommand(`favicons`)

await conjureIcons(iconsOptions)
await conjureImages(imagesOptions)
Expand Down
16 changes: 8 additions & 8 deletions lib/optimizeVector.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises"

import { loadConfig, optimize } from "svgo"

const svgoConfig = await loadConfig() ?? await import(`./svgoConfig.js`).then((m) => m.default || m.svgoConfig)
let svgoConfig = await loadConfig() ?? await import(`./svgoConfig.js`).then((m) => m.default || m.svgoConfig)

/**
* Optimizes a set of vector files.
Expand All @@ -17,7 +17,7 @@ const svgoConfig = await loadConfig() ?? await import(`./svgoConfig.js`).then((m
* @throws {Error} If there is an error during optimization.
*/
export async function optimizeVector ({ vectorPaths, inputDirectory, outputDirectory, publicDirectory }) {
for (const filePath of vectorPaths) {
for (let filePath of vectorPaths) {
await optimizeFile(filePath)
}

Expand All @@ -28,8 +28,8 @@ export async function optimizeVector ({ vectorPaths, inputDirectory, outputDirec
*/
async function optimizeFile (filePath) {
try {
const data = await readFile(filePath, `utf8`)
const result = optimize(data, { ...svgoConfig, path: filePath })
let data = await readFile(filePath, `utf8`)
let result = optimize(data, { ...svgoConfig, path: filePath })

if (result.error) throw new Error(`Error optimizing: ${filePath}: ${result.error}`)

Expand All @@ -39,13 +39,13 @@ export async function optimizeVector ({ vectorPaths, inputDirectory, outputDirec
return
}

const subfolder = dirname(filePath.substring(inputDirectory.length))
const destSubfolder = join(outputDirectory, subfolder)
let subfolder = dirname(filePath.substring(inputDirectory.length))
let destSubfolder = join(outputDirectory, subfolder)

await mkdir(destSubfolder, { recursive: true })

const fileName = basename(filePath, extname(filePath))
const destPath = resolve(destSubfolder, `${fileName}.svg`)
let fileName = basename(filePath, extname(filePath))
let destPath = resolve(destSubfolder, `${fileName}.svg`)

await writeFile(destPath, result.data)
} catch (err) {
Expand Down
22 changes: 11 additions & 11 deletions lib/prepareSourceFaviconFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ import { globby } from "globby"
* @returns {Promise<void>} - A promise that resolves when the source files are prepared.
*/
export async function prepareSourceFaviconFiles (options) {
const { publicDirectory } = options
let { publicDirectory } = options

const pathTo32 = normalize(`${publicDirectory}/32.svg`)
const pathTo16 = normalize(`${publicDirectory}/16.svg`)
const pathToTouch = normalize(`${publicDirectory}/touch.svg`)
const pathToIcon = normalize(`${publicDirectory}/favicons/icon.svg`)
let pathTo32 = normalize(`${publicDirectory}/32.svg`)
let pathTo16 = normalize(`${publicDirectory}/16.svg`)
let pathToTouch = normalize(`${publicDirectory}/touch.svg`)
let pathToIcon = normalize(`${publicDirectory}/favicons/icon.svg`)

let paths = await globby([pathTo32, pathTo16, pathToTouch, pathToIcon])

const normalizedVectorPaths = paths.map((path) => normalize(path))
let normalizedVectorPaths = paths.map((path) => normalize(path))

const isIconTouchExists = normalizedVectorPaths.includes(pathToTouch)
const isIcon32Exists = normalizedVectorPaths.includes(pathTo32)
const isIcon16Exists = normalizedVectorPaths.includes(pathTo16)
const isIconExists = normalizedVectorPaths.includes(pathToIcon)
let isIconTouchExists = normalizedVectorPaths.includes(pathToTouch)
let isIcon32Exists = normalizedVectorPaths.includes(pathTo32)
let isIcon16Exists = normalizedVectorPaths.includes(pathTo16)
let isIconExists = normalizedVectorPaths.includes(pathToIcon)

options.isSourceFaviconNotExists = !isIconTouchExists && !isIcon32Exists && !isIcon16Exists
if (options.isSourceFaviconNotExists) return
Expand All @@ -40,7 +40,7 @@ export async function prepareSourceFaviconFiles (options) {

if (isIconExists) await unlink(pathToIcon)

const faviconsDirectory = normalize(`${publicDirectory}/favicons`)
let faviconsDirectory = normalize(`${publicDirectory}/favicons`)

await access(faviconsDirectory).catch(() => mkdir(faviconsDirectory))
await link(options.ico32, pathToIcon)
Expand Down
14 changes: 7 additions & 7 deletions lib/processRaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { createProgressBar } from "./createProgressBar.js"
* @param {boolean} options.addMetaData - Whether to create JSON and JS files with metadata of the images.
*/
export async function processRaster (options) {
const {
let {
rasterPaths,
inputDirectory,
outputDirectory,
Expand All @@ -41,11 +41,11 @@ export async function processRaster (options) {
let messageEnd = `✨ Complete!`
let progressBar = createProgressBar(numberOutputFiles, { messageStart, messageEnd })

for (const filePath of rasterPaths) {
const fileName = basename(filePath, extname(filePath))
const baseName = basename(fileName, extname(fileName))
const subfolder = dirname(filePath.substring(inputDirectory.length))
const destSubfolder = join(outputDirectory, subfolder)
for (let filePath of rasterPaths) {
let fileName = basename(filePath, extname(filePath))
let baseName = basename(fileName, extname(fileName))
let subfolder = dirname(filePath.substring(inputDirectory.length))
let destSubfolder = join(outputDirectory, subfolder)

try {
await mkdir(destSubfolder, { recursive: true })
Expand Down Expand Up @@ -146,7 +146,7 @@ async function fileExists (filePath) {
* @return {Object} The parsed JSON object from the file.
*/
async function readJsonFile (path) {
const file = await readFile(path)
let file = await readFile(path)

return JSON.parse(file)
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
"./lib/"
],
"engines": {
"pnpm": "^9.12.1",
"node": "^18.12 || >=20.9"
},
"packageManager": "pnpm@9.7.0",
"packageManager": "pnpm@9.12.1",
"dependencies": {
"globby": "^14.0.2",
"ico-endec": "^0.1.6",
"meow": "^13.2.0",
"sharp": "^0.33.4",
"sharp": "^0.33.5",
"svgo": "^3.3.2"
},
"scripts": {
Expand All @@ -47,9 +48,9 @@
"postpublish": "git push --follow-tags"
},
"devDependencies": {
"@firefoxic/update-changelog": "^0.2.0",
"@firefoxic/eslint-config": "^2.0.0",
"eslint": "^9.9.0"
"@firefoxic/update-changelog": "^0.2.1",
"@firefoxic/eslint-config": "^3.0.1",
"eslint": "^9.12.0"
},
"keywords": [
"conjure",
Expand Down
Loading

0 comments on commit f46cf0b

Please sign in to comment.