From 9aeff034f5cdf4e22090904bf9dfecf439b34658 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 3 May 2023 11:10:03 +0200 Subject: Merging upstream version 1.10.5+dfsg. Signed-off-by: Daniel Baumann --- build/build-pages.js | 62 ------------------------------ build/build-pages.mjs | 64 +++++++++++++++++++++++++++++++ build/build-svgs.js | 55 --------------------------- build/build-svgs.mjs | 57 ++++++++++++++++++++++++++++ build/bump-version.mjs | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ build/check-icons.js | 59 ----------------------------- build/check-icons.mjs | 61 ++++++++++++++++++++++++++++++ build/font/css.hbs | 4 +- build/font/scss.hbs | 4 +- build/vnu-jar.js | 52 ------------------------- build/vnu-jar.mjs | 50 +++++++++++++++++++++++++ 11 files changed, 336 insertions(+), 232 deletions(-) delete mode 100644 build/build-pages.js create mode 100644 build/build-pages.mjs delete mode 100644 build/build-svgs.js create mode 100644 build/build-svgs.mjs create mode 100644 build/bump-version.mjs delete mode 100755 build/check-icons.js create mode 100644 build/check-icons.mjs delete mode 100644 build/vnu-jar.js create mode 100644 build/vnu-jar.mjs (limited to 'build') diff --git a/build/build-pages.js b/build/build-pages.js deleted file mode 100644 index 6825be4..0000000 --- a/build/build-pages.js +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env node - -'use strict' - -const fs = require('node:fs').promises -const path = require('node:path') -const picocolors = require('picocolors') - -const iconsDir = path.join(__dirname, '../icons/') -const pagesDir = path.join(__dirname, '../docs/content/icons/') - -const VERBOSE = process.argv.includes('--verbose') - -function capitalizeFirstLetter(string) { - return (string.charAt(0).toUpperCase() + string.slice(1)).split('-').join(' ') -} - -async function main(file) { - const iconBasename = path.basename(file, path.extname(file)) - const iconTitle = capitalizeFirstLetter(iconBasename) - const pageName = path.join(pagesDir, `${iconBasename}.md`) - - const pageTemplate = `--- -title: ${iconTitle} -categories: -tags: ---- -` - - try { - await fs.access(pageName, fs.F_OK) - - if (VERBOSE) { - console.log(`${picocolors.cyan(iconBasename)}: Page already exists; skipping`) - } - } catch { - await fs.writeFile(pageName, pageTemplate) - console.log(picocolors.green(`${iconBasename}: Page created`)) - } -} - -(async () => { - try { - const basename = path.basename(__filename) - const timeLabel = picocolors.cyan(`[${basename}] finished`) - - console.log(picocolors.cyan(`[${basename}] started`)) - console.time(timeLabel) - - const files = await fs.readdir(iconsDir) - - await Promise.all(files.map(file => main(file))) - - const filesLength = files.length - - console.log(picocolors.green('\nSuccess, %s page%s prepared!'), filesLength, filesLength === 1 ? '' : 's') - console.timeEnd(timeLabel) - } catch (error) { - console.error(error) - process.exit(1) - } -})() diff --git a/build/build-pages.mjs b/build/build-pages.mjs new file mode 100644 index 0000000..d410555 --- /dev/null +++ b/build/build-pages.mjs @@ -0,0 +1,64 @@ +#!/usr/bin/env node + +import fs from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import picocolors from 'picocolors' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +const iconsDir = path.join(__dirname, '../icons/') +const pagesDir = path.join(__dirname, '../docs/content/icons/') + +const VERBOSE = process.argv.includes('--verbose') + +function capitalizeFirstLetter(string) { + return (string.charAt(0).toUpperCase() + string.slice(1)).split('-').join(' ') +} + +async function main(file) { + const iconBasename = path.basename(file, path.extname(file)) + const iconTitle = capitalizeFirstLetter(iconBasename) + const pageName = path.join(pagesDir, `${iconBasename}.md`) + + const pageTemplate = `--- +title: ${iconTitle} +categories: +tags: +--- +` + + try { + await fs.access(pageName, fs.F_OK) + + if (VERBOSE) { + console.log(`${picocolors.cyan(iconBasename)}: Page already exists; skipping`) + } + } catch { + await fs.writeFile(pageName, pageTemplate) + console.log(picocolors.green(`${iconBasename}: Page created`)) + } +} + +(async () => { + try { + const basename = path.basename(__filename) + const timeLabel = picocolors.cyan(`[${basename}] finished`) + + console.log(picocolors.cyan(`[${basename}] started`)) + console.time(timeLabel) + + const files = await fs.readdir(iconsDir) + + await Promise.all(files.map(file => main(file))) + + const filesLength = files.length + + console.log(picocolors.green('\nSuccess, %s page%s prepared!'), filesLength, filesLength === 1 ? '' : 's') + console.timeEnd(timeLabel) + } catch (error) { + console.error(error) + process.exit(1) + } +})() diff --git a/build/build-svgs.js b/build/build-svgs.js deleted file mode 100644 index ed868e6..0000000 --- a/build/build-svgs.js +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env node - -'use strict' - -const fs = require('node:fs').promises -const path = require('node:path') -const process = require('node:process') -const picocolors = require('picocolors') -const { loadConfig, optimize } = require('svgo') - -const iconsDir = path.join(__dirname, '../icons/') - -const VERBOSE = process.argv.includes('--verbose') - -async function processFile(file, config) { - const filepath = path.join(iconsDir, file) - const basename = path.basename(file, '.svg') - - const originalSvg = await fs.readFile(filepath, 'utf8') - const { data: optimizedSvg } = await optimize(originalSvg, { path: filepath, ...config }) - - // svgo will always add a final newline when in pretty mode - const resultSvg = optimizedSvg.trim() - - if (resultSvg !== originalSvg) { - await fs.writeFile(filepath, resultSvg, 'utf8') - } - - if (VERBOSE) { - console.log(`- ${basename}`) - } -} - -(async () => { - try { - const basename = path.basename(__filename) - const timeLabel = picocolors.cyan(`[${basename}] finished`) - - console.log(picocolors.cyan(`[${basename}] started`)) - console.time(timeLabel) - - const files = await fs.readdir(iconsDir) - const config = await loadConfig(path.join(__dirname, '../svgo.config.js')) - - await Promise.all(files.map(file => processFile(file, config))) - - const filesLength = files.length - - console.log(picocolors.green('\nSuccess, prepared %s icon%s!'), filesLength, filesLength === 1 ? '' : 's') - console.timeEnd(timeLabel) - } catch (error) { - console.error(error) - process.exit(1) - } -})() diff --git a/build/build-svgs.mjs b/build/build-svgs.mjs new file mode 100644 index 0000000..2927156 --- /dev/null +++ b/build/build-svgs.mjs @@ -0,0 +1,57 @@ +#!/usr/bin/env node + +import fs from 'node:fs/promises' +import path from 'node:path' +import process from 'node:process' +import { fileURLToPath } from 'node:url' +import picocolors from 'picocolors' +import { loadConfig, optimize } from 'svgo' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +const iconsDir = path.join(__dirname, '../icons/') + +const VERBOSE = process.argv.includes('--verbose') + +async function processFile(file, config) { + const filepath = path.join(iconsDir, file) + const basename = path.basename(file, '.svg') + + const originalSvg = await fs.readFile(filepath, 'utf8') + const { data: optimizedSvg } = await optimize(originalSvg, { path: filepath, ...config }) + + // svgo will always add a final newline when in pretty mode + const resultSvg = optimizedSvg.trim() + + if (resultSvg !== originalSvg) { + await fs.writeFile(filepath, resultSvg, 'utf8') + } + + if (VERBOSE) { + console.log(`- ${basename}`) + } +} + +(async () => { + try { + const basename = path.basename(__filename) + const timeLabel = picocolors.cyan(`[${basename}] finished`) + + console.log(picocolors.cyan(`[${basename}] started`)) + console.time(timeLabel) + + const files = await fs.readdir(iconsDir) + const config = await loadConfig(path.join(__dirname, '../svgo.config.mjs')) + + await Promise.all(files.map(file => processFile(file, config))) + + const filesLength = files.length + + console.log(picocolors.green('\nSuccess, prepared %s icon%s!'), filesLength, filesLength === 1 ? '' : 's') + console.timeEnd(timeLabel) + } catch (error) { + console.error(error) + process.exit(1) + } +})() diff --git a/build/bump-version.mjs b/build/bump-version.mjs new file mode 100644 index 0000000..d08d0a9 --- /dev/null +++ b/build/bump-version.mjs @@ -0,0 +1,100 @@ +#!/usr/bin/env node + +/*! + * Script to update version number references in the project. + * Copyright 2023 The Bootstrap Authors + * Licensed under MIT (https://github.com/twbs/icons/blob/main/LICENSE) + */ + +const { execFile } = require('node:child_process') +const fs = require('node:fs').promises + +const VERBOSE = process.argv.includes('--verbose') +const DRY_RUN = process.argv.includes('--dry') || process.argv.includes('--dry-run') + +// These are the files we only care about replacing the version +const FILES = [ + 'build/font/css.hbs', + 'build/font/scss.hbs', + 'config.yml' +] + +// Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37 +function regExpQuote(string) { + return string.replace(/[$()*+-.?[\\\]^{|}]/g, '\\$&') +} + +function regExpQuoteReplacement(string) { + return string.replace(/\$/g, '$$') +} + +async function replaceRecursively(file, oldVersion, newVersion) { + const originalString = await fs.readFile(file, 'utf8') + const newString = originalString.replace( + new RegExp(regExpQuote(oldVersion), 'g'), + regExpQuoteReplacement(newVersion) + ) + + // No need to move any further if the strings are identical + if (originalString === newString) { + return + } + + if (VERBOSE) { + console.log(`Found ${oldVersion} in ${file}`) + } + + if (DRY_RUN) { + return + } + + await fs.writeFile(file, newString, 'utf8') +} + +function bumpNpmVersion(newVersion) { + if (DRY_RUN) { + return + } + + execFile('npm', ['version', newVersion, '--no-git-tag'], { shell: true }, (error) => { + if (error) { + console.error(error) + process.exit(1) + } + }) +} + +function showUsage(args) { + console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]') + console.error('Got arguments:', args) + process.exit(1) +} + +async function main(args) { + let [oldVersion, newVersion] = args + + if (!oldVersion || !newVersion) { + showUsage(args) + } + + // Strip any leading `v` from arguments because + // otherwise we will end up with duplicate `v`s + [oldVersion, newVersion] = [oldVersion, newVersion].map(arg => { + return arg.startsWith('v') ? arg.slice(1) : arg + }) + + if (oldVersion === newVersion) { + showUsage(args) + } + + bumpNpmVersion(newVersion) + + try { + await Promise.all(FILES.map(file => replaceRecursively(file, oldVersion, newVersion))) + } catch (error) { + console.error(error) + process.exit(1) + } +} + +main(process.argv.slice(2)) diff --git a/build/check-icons.js b/build/check-icons.js deleted file mode 100755 index 73f1a5b..0000000 --- a/build/check-icons.js +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env node - -'use strict' - -const fs = require('node:fs').promises -const path = require('node:path') -const process = require('node:process') -const picocolors = require('picocolors') - -const fontJsonPath = path.join(__dirname, '../font/bootstrap-icons.json') -const iconsDir = path.join(__dirname, '../icons/') - -;(async () => { - try { - const basename = path.basename(__filename) - const timeLabel = picocolors.cyan(`[${basename}] finished`) - - console.log(picocolors.cyan(`[${basename}] started`)) - console.time(timeLabel) - - const fontJsonString = await fs.readFile(fontJsonPath, 'utf8') - const fontJson = JSON.parse(fontJsonString) - const svgFiles = await fs.readdir(iconsDir) - - const jsonIconList = Object.keys(fontJson) - const svgIconList = svgFiles.map(svg => path.basename(svg, path.extname(svg))) - - const onlyInJson = jsonIconList.filter(icon => !svgIconList.includes(icon)) - const onlyInSvg = svgIconList.filter(icon => !jsonIconList.includes(icon)) - - if (onlyInJson.length === 0 || onlyInSvg === 0) { - console.log(picocolors.green('Success, found no differences!')) - console.timeEnd(timeLabel) - - return - } - - if (onlyInJson.length > 0) { - console.error(picocolors.red(`Found additional icons in ${fontJsonPath}:`)) - - for (const icon of onlyInJson) { - console.log(` - ${picocolors.red(icon)}`) - } - } - - if (onlyInSvg.length > 0) { - console.error(picocolors.red('Found additional icons in SVG files:')) - - for (const icon of onlyInSvg) { - console.log(` - ${picocolors.red(icon)}`) - } - } - - process.exit(1) - } catch (error) { - console.error(error) - process.exit(1) - } -})() diff --git a/build/check-icons.mjs b/build/check-icons.mjs new file mode 100644 index 0000000..70f3dfe --- /dev/null +++ b/build/check-icons.mjs @@ -0,0 +1,61 @@ +#!/usr/bin/env node + +import fs from 'node:fs/promises' +import path from 'node:path' +import process from 'node:process' +import { fileURLToPath } from 'node:url' +import picocolors from 'picocolors' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +const fontJsonPath = path.join(__dirname, '../font/bootstrap-icons.json') +const iconsDir = path.join(__dirname, '../icons/') + +;(async () => { + try { + const basename = path.basename(__filename) + const timeLabel = picocolors.cyan(`[${basename}] finished`) + + console.log(picocolors.cyan(`[${basename}] started`)) + console.time(timeLabel) + + const fontJsonString = await fs.readFile(fontJsonPath, 'utf8') + const fontJson = JSON.parse(fontJsonString) + const svgFiles = await fs.readdir(iconsDir) + + const jsonIconList = Object.keys(fontJson) + const svgIconList = svgFiles.map(svg => path.basename(svg, '.svg')) + + const onlyInJson = jsonIconList.filter(icon => !svgIconList.includes(icon)) + const onlyInSvg = svgIconList.filter(icon => !jsonIconList.includes(icon)) + + if (onlyInJson.length === 0 || onlyInSvg === 0) { + console.log(picocolors.green('Success, found no differences!')) + console.timeEnd(timeLabel) + + return + } + + if (onlyInJson.length > 0) { + console.error(picocolors.red(`Found additional icons in ${fontJsonPath}:`)) + + for (const icon of onlyInJson) { + console.log(` - ${picocolors.red(icon)}`) + } + } + + if (onlyInSvg.length > 0) { + console.error(picocolors.red('Found additional icons in SVG files:')) + + for (const icon of onlyInSvg) { + console.log(` - ${picocolors.red(icon)}`) + } + } + + process.exit(1) + } catch (error) { + console.error(error) + process.exit(1) + } +})() diff --git a/build/font/css.hbs b/build/font/css.hbs index 6f2aa30..76f27ce 100644 --- a/build/font/css.hbs +++ b/build/font/css.hbs @@ -1,7 +1,7 @@ /*! - * Bootstrap Icons (https://icons.getbootstrap.com/) + * Bootstrap Icons v1.10.5 (https://icons.getbootstrap.com/) * Copyright 2019-2023 The Bootstrap Authors - * Licensed under MIT (https://github.com/twbs/icons/blob/main/LICENSE.md) + * Licensed under MIT (https://github.com/twbs/icons/blob/main/LICENSE) */ @font-face { diff --git a/build/font/scss.hbs b/build/font/scss.hbs index 710b45c..e3bfaf0 100644 --- a/build/font/scss.hbs +++ b/build/font/scss.hbs @@ -1,7 +1,7 @@ /*! - * Bootstrap Icons (https://icons.getbootstrap.com/) + * Bootstrap Icons v1.10.5 (https://icons.getbootstrap.com/) * Copyright 2019-2023 The Bootstrap Authors - * Licensed under MIT (https://github.com/twbs/icons/blob/main/LICENSE.md) + * Licensed under MIT (https://github.com/twbs/icons/blob/main/LICENSE) */ ${{ name }}-font: "{{ name }}" !default; diff --git a/build/vnu-jar.js b/build/vnu-jar.js deleted file mode 100644 index c87d518..0000000 --- a/build/vnu-jar.js +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env node - -/*! - * Script to run vnu-jar if Java is available. - * Copyright 2017-2023 The Bootstrap Authors - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - */ - -'use strict' - -const { execFile, spawn } = require('node:child_process') -const vnu = require('vnu-jar') - -execFile('java', ['-version'], (error, stdout, stderr) => { - if (error) { - console.error('Skipping vnu-jar test; Java is probably missing.') - console.error(error) - return - } - - console.log('Running vnu-jar validation...') - - const is32bitJava = !/64-Bit/.test(stderr) - - // vnu-jar accepts multiple ignores joined with a `|`. - // Also note that the ignores are string regular expressions. - const ignores = [ - ].join('|') - - const args = [ - '-jar', - `"${vnu}"`, - '--asciiquotes', - '--skip-non-html', - '--Werror', - `--filterpattern "${ignores}"`, - '_site/' - ] - - // For the 32-bit Java we need to pass `-Xss512k` - if (is32bitJava) { - args.splice(0, 0, '-Xss512k') - } - - console.log(`command used: java ${args.join(' ')}`) - - return spawn('java', args, { - shell: true, - stdio: 'inherit' - }) - .on('exit', process.exit) -}) diff --git a/build/vnu-jar.mjs b/build/vnu-jar.mjs new file mode 100644 index 0000000..bb8b348 --- /dev/null +++ b/build/vnu-jar.mjs @@ -0,0 +1,50 @@ +#!/usr/bin/env node + +/*! + * Script to run vnu-jar if Java is available. + * Copyright 2017-2023 The Bootstrap Authors + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ + +import { execFile, spawn } from 'node:child_process' +import vnu from 'vnu-jar' + +execFile('java', ['-version'], (error, stdout, stderr) => { + if (error) { + console.error('Skipping vnu-jar test; Java is probably missing.') + console.error(error) + return + } + + console.log('Running vnu-jar validation...') + + const is32bitJava = !/64-Bit/.test(stderr) + + // vnu-jar accepts multiple ignores joined with a `|`. + // Also note that the ignores are string regular expressions. + const ignores = [ + ].join('|') + + const args = [ + '-jar', + `"${vnu}"`, + '--asciiquotes', + '--skip-non-html', + '--Werror', + `--filterpattern "${ignores}"`, + '_site/' + ] + + // For the 32-bit Java we need to pass `-Xss512k` + if (is32bitJava) { + args.splice(0, 0, '-Xss512k') + } + + console.log(`command used: java ${args.join(' ')}`) + + return spawn('java', args, { + shell: true, + stdio: 'inherit' + }) + .on('exit', process.exit) +}) -- cgit v1.2.3