summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/build-pages.mjs (renamed from build/build-pages.js)10
-rw-r--r--build/build-svgs.mjs (renamed from build/build-svgs.js)16
-rw-r--r--build/bump-version.mjs100
-rw-r--r--[-rwxr-xr-x]build/check-icons.mjs (renamed from build/check-icons.js)14
-rw-r--r--build/font/css.hbs4
-rw-r--r--build/font/scss.hbs4
-rw-r--r--build/vnu-jar.mjs (renamed from build/vnu-jar.js)6
7 files changed, 129 insertions, 25 deletions
diff --git a/build/build-pages.js b/build/build-pages.mjs
index 6825be4..d410555 100644
--- a/build/build-pages.js
+++ b/build/build-pages.mjs
@@ -1,10 +1,12 @@
#!/usr/bin/env node
-'use strict'
+import fs from 'node:fs/promises'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+import picocolors from 'picocolors'
-const fs = require('node:fs').promises
-const path = require('node:path')
-const picocolors = require('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/')
diff --git a/build/build-svgs.js b/build/build-svgs.mjs
index ed868e6..2927156 100644
--- a/build/build-svgs.js
+++ b/build/build-svgs.mjs
@@ -1,12 +1,14 @@
#!/usr/bin/env node
-'use strict'
+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 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 __filename = fileURLToPath(import.meta.url)
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
const iconsDir = path.join(__dirname, '../icons/')
@@ -40,7 +42,7 @@ async function processFile(file, config) {
console.time(timeLabel)
const files = await fs.readdir(iconsDir)
- const config = await loadConfig(path.join(__dirname, '../svgo.config.js'))
+ const config = await loadConfig(path.join(__dirname, '../svgo.config.mjs'))
await Promise.all(files.map(file => processFile(file, config)))
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.mjs
index 73f1a5b..70f3dfe 100755..100644
--- a/build/check-icons.js
+++ b/build/check-icons.mjs
@@ -1,11 +1,13 @@
#!/usr/bin/env node
-'use strict'
+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 fs = require('node:fs').promises
-const path = require('node:path')
-const process = require('node:process')
-const picocolors = require('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/')
@@ -23,7 +25,7 @@ const iconsDir = path.join(__dirname, '../icons/')
const svgFiles = await fs.readdir(iconsDir)
const jsonIconList = Object.keys(fontJson)
- const svgIconList = svgFiles.map(svg => path.basename(svg, path.extname(svg)))
+ 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))
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.mjs
index c87d518..bb8b348 100644
--- a/build/vnu-jar.js
+++ b/build/vnu-jar.mjs
@@ -6,10 +6,8 @@
* 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')
+import { execFile, spawn } from 'node:child_process'
+import vnu from 'vnu-jar'
execFile('java', ['-version'], (error, stdout, stderr) => {
if (error) {