summaryrefslogtreecommitdiffstats
path: root/build/change-version.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-15 11:37:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-15 11:37:25 +0000
commitb58ba798972661b7f3191cc818c3855aa53893ad (patch)
treef2853fde120265064f7bf1bb18e35509edc48979 /build/change-version.js
parentReleasing debian version 5.3.1+dfsg-1. (diff)
downloadbootstrap-html-b58ba798972661b7f3191cc818c3855aa53893ad.tar.xz
bootstrap-html-b58ba798972661b7f3191cc818c3855aa53893ad.zip
Merging upstream version 5.3.2+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'build/change-version.js')
-rw-r--r--build/change-version.js101
1 files changed, 0 insertions, 101 deletions
diff --git a/build/change-version.js b/build/change-version.js
deleted file mode 100644
index 9685df5..0000000
--- a/build/change-version.js
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env node
-
-/*!
- * Script to update version number references in the project.
- * Copyright 2017-2023 The Bootstrap Authors
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
- */
-
-'use strict'
-
-const fs = require('node:fs').promises
-const path = require('node:path')
-const globby = require('globby')
-
-const VERBOSE = process.argv.includes('--verbose')
-const DRY_RUN = process.argv.includes('--dry') || process.argv.includes('--dry-run')
-
-// These are the filetypes we only care about replacing the version
-const GLOB = [
- '**/*.{css,html,js,json,md,scss,txt,yml}'
-]
-const GLOBBY_OPTIONS = {
- cwd: path.join(__dirname, '..'),
- gitignore: true
-}
-
-// 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)
- )
- // Also replace the version used by the rubygem,
- // which is using periods (`.`) instead of hyphens (`-`)
- .replace(
- new RegExp(regExpQuote(oldVersion.replace(/-/g, '.')), 'g'),
- regExpQuoteReplacement(newVersion.replace(/-/g, '.'))
- )
-
- // No need to move any further if the strings are identical
- if (originalString === newString) {
- return
- }
-
- if (VERBOSE) {
- console.log(`FILE: ${file}`)
- }
-
- if (DRY_RUN) {
- return
- }
-
- await fs.writeFile(file, newString, 'utf8')
-}
-
-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)
- }
-
- try {
- const files = await globby(GLOB, GLOBBY_OPTIONS)
-
- await Promise.all(
- files.map(file => replaceRecursively(file, oldVersion, newVersion))
- )
- } catch (error) {
- console.error(error)
- process.exit(1)
- }
-}
-
-main(process.argv.slice(2))