From 01b08d958cdfecb5174fa8baa2272c06ab6b2668 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 1 Dec 2021 15:16:24 +0200 Subject: Remove the now outdated build/svgo.yml (#35447) --- build/svgo.yml | 59 ---------------------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 build/svgo.yml (limited to 'build') diff --git a/build/svgo.yml b/build/svgo.yml deleted file mode 100644 index 67940d393..000000000 --- a/build/svgo.yml +++ /dev/null @@ -1,59 +0,0 @@ -# Usage: -# install svgo globally: `npm i -g svgo` -# svgo --config=build/svgo.yml --input=foo.svg - -# https://github.com/svg/svgo/blob/master/docs/how-it-works/en.md -# replace default config - -multipass: true -#full: true - -# https://github.com/svg/svgo/blob/master/lib/svgo/js2svg.js#L6 for more config options - -js2svg: - pretty: true - indent: 2 - -plugins: -# - addAttributesToSVGElement: -# attributes: -# - focusable: false - - cleanupAttrs: true - - cleanupEnableBackground: true - - cleanupIDs: true - - cleanupListOfValues: true - - cleanupNumericValues: true - - collapseGroups: true - - convertColors: true - - convertPathData: true - - convertShapeToPath: true - - convertStyleToAttrs: true - - convertTransform: true - - inlineStyles: true - - mergePaths: true - - minifyStyles: true - - moveElemsAttrsToGroup: true - - moveGroupAttrsToElems: true - - removeAttrs: - attrs: - - "data-name" - - removeComments: true - - removeDesc: true - - removeDoctype: true - - removeEditorsNSData: true - - removeEmptyAttrs: true - - removeEmptyContainers: true - - removeEmptyText: true - - removeHiddenElems: true - - removeMetadata: true - - removeNonInheritableGroupAttrs: true - - removeTitle: false - - removeUnknownsAndDefaults: - keepRoleAttr: true - - removeUnusedNS: true - - removeUselessDefs: true - - removeUselessStrokeAndFill: true - - removeViewBox: false - - removeXMLNS: false - - removeXMLProcInst: true - - sortAttrs: true -- cgit v1.2.3 From a22694da130e0c4e3e9488769d6b3a120e859f83 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 15 Dec 2021 10:52:49 +0200 Subject: build/postcss.config.js: minor tweaks (#35506) --- build/postcss.config.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'build') diff --git a/build/postcss.config.js b/build/postcss.config.js index b179a0e77..7f8186d10 100644 --- a/build/postcss.config.js +++ b/build/postcss.config.js @@ -1,19 +1,19 @@ 'use strict' -module.exports = ctx => { +const mapConfig = { + inline: false, + annotation: true, + sourcesContent: true +} + +module.exports = context => { return { - map: ctx.file.dirname.includes('examples') ? - false : - { - inline: false, - annotation: true, - sourcesContent: true - }, + map: context.file.dirname.includes('examples') ? false : mapConfig, plugins: { autoprefixer: { cascade: false }, - rtlcss: ctx.env === 'RTL' ? {} : false + rtlcss: context.env === 'RTL' } } } -- cgit v1.2.3 From 9680e1745672f35f6a63c6670b1668e46d5c575d Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 3 Jan 2022 15:03:42 +0200 Subject: Bump copyright year to 2022 (#35639) --- build/build-plugins.js | 4 ++-- build/change-version.js | 4 ++-- build/generate-sri.js | 4 ++-- build/vnu-jar.js | 4 ++-- build/zip-examples.js | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'build') diff --git a/build/build-plugins.js b/build/build-plugins.js index 044344743..64ad6d234 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -2,8 +2,8 @@ /*! * Script to build our plugins to use them separately. - * Copyright 2020-2021 The Bootstrap Authors - * Copyright 2020-2021 Twitter, Inc. + * Copyright 2020-2022 The Bootstrap Authors + * Copyright 2020-2022 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/change-version.js b/build/change-version.js index 22a169db9..6d85441a9 100644 --- a/build/change-version.js +++ b/build/change-version.js @@ -2,8 +2,8 @@ /*! * Script to update version number references in the project. - * Copyright 2017-2021 The Bootstrap Authors - * Copyright 2017-2021 Twitter, Inc. + * Copyright 2017-2022 The Bootstrap Authors + * Copyright 2017-2022 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/generate-sri.js b/build/generate-sri.js index 47d02c4c3..18de4f484 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -5,8 +5,8 @@ * Remember to use the same vendor files as the CDN ones, * otherwise the hashes won't match! * - * Copyright 2017-2021 The Bootstrap Authors - * Copyright 2017-2021 Twitter, Inc. + * Copyright 2017-2022 The Bootstrap Authors + * Copyright 2017-2022 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/vnu-jar.js b/build/vnu-jar.js index 2d5cc8b55..df4192e24 100644 --- a/build/vnu-jar.js +++ b/build/vnu-jar.js @@ -2,8 +2,8 @@ /*! * Script to run vnu-jar if Java is available. - * Copyright 2017-2021 The Bootstrap Authors - * Copyright 2017-2021 Twitter, Inc. + * Copyright 2017-2022 The Bootstrap Authors + * Copyright 2017-2022 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/zip-examples.js b/build/zip-examples.js index 6c8ae527a..759dd817d 100644 --- a/build/zip-examples.js +++ b/build/zip-examples.js @@ -3,7 +3,7 @@ /*! * Script to create the built examples zip archive; * requires the `zip` command to be present! - * Copyright 2020-2021 The Bootstrap Authors + * Copyright 2020-2022 The Bootstrap Authors * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ -- cgit v1.2.3 From c99fa6ca266fd781294a1fe5ffd307478c42c510 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 13 Jan 2022 13:12:10 +0200 Subject: build-plugins.js: use globby package (#35586) We already use it in the change-version.js file --- build/build-plugins.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'build') diff --git a/build/build-plugins.js b/build/build-plugins.js index 64ad6d234..401c67601 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -11,12 +11,12 @@ const path = require('path') const rollup = require('rollup') -const glob = require('glob') +const globby = require('globby') const { babel } = require('@rollup/plugin-babel') const banner = require('./banner.js') -const srcPath = path.resolve(__dirname, '../js/src/') -const jsFiles = glob.sync(srcPath + '/**/*.js') +const srcPath = path.resolve(__dirname, '../js/src/').replace(/\\/g, '/') +const jsFiles = globby.sync(srcPath + '/**/*.js') // Array which holds the resolved plugins const resolvedPlugins = [] -- cgit v1.2.3 From 62d86c07f81dfae632742dbf62633e767bac8edd Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 29 Oct 2021 10:38:35 +0300 Subject: Rename variables --- build/build-plugins.js | 6 +++--- build/generate-sri.js | 6 +++--- build/rollup.config.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'build') diff --git a/build/build-plugins.js b/build/build-plugins.js index 401c67601..8fa0e0b1f 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -15,8 +15,8 @@ const globby = require('globby') const { babel } = require('@rollup/plugin-babel') const banner = require('./banner.js') -const srcPath = path.resolve(__dirname, '../js/src/').replace(/\\/g, '/') -const jsFiles = globby.sync(srcPath + '/**/*.js') +const sourcePath = path.resolve(__dirname, '../js/src/').replace(/\\/g, '/') +const jsFiles = globby.sync(sourcePath + '/**/*.js') // Array which holds the resolved plugins const resolvedPlugins = [] @@ -31,7 +31,7 @@ for (const file of jsFiles) { dist: file.replace('src', 'dist'), fileName: path.basename(file), className: filenameToEntity(path.basename(file)) - // safeClassName: filenameToEntity(path.relative(srcPath, file)) + // safeClassName: filenameToEntity(path.relative(sourcePath, file)) }) } diff --git a/build/generate-sri.js b/build/generate-sri.js index 18de4f484..cde818e09 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -48,9 +48,9 @@ const files = [ ] for (const file of files) { - fs.readFile(file.file, 'utf8', (err, data) => { - if (err) { - throw err + fs.readFile(file.file, 'utf8', (error, data) => { + if (error) { + throw error } const algo = 'sha384' diff --git a/build/rollup.config.js b/build/rollup.config.js index c00438de2..2d2920fd5 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -9,7 +9,7 @@ const banner = require('./banner.js') const BUNDLE = process.env.BUNDLE === 'true' const ESM = process.env.ESM === 'true' -let fileDest = `bootstrap${ESM ? '.esm' : ''}` +let fileDestination = `bootstrap${ESM ? '.esm' : ''}` const external = ['@popperjs/core'] const plugins = [ babel({ @@ -24,7 +24,7 @@ const globals = { } if (BUNDLE) { - fileDest += '.bundle' + fileDestination += '.bundle' // Remove last entry in external array to bundle Popper external.pop() delete globals['@popperjs/core'] @@ -41,7 +41,7 @@ const rollupConfig = { input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`), output: { banner, - file: path.resolve(__dirname, `../dist/js/${fileDest}.js`), + file: path.resolve(__dirname, `../dist/js/${fileDestination}.js`), format: ESM ? 'esm' : 'umd', globals, generatedCode: 'es2015' -- cgit v1.2.3 From 42da2b95566fe0377543120698e242f4756f648e Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 15 Feb 2022 08:50:37 +0200 Subject: Update devDependencies (#35841) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update devDependencies * @babel/core ^7.17.0 → ^7.17.2 * @rollup/plugin-replace ^3.0.1 → ^3.1.0 * eslint ^8.8.0 → ^8.9.0 * eslint-config-xo ^0.39.0 → ^0.40.0 * hugo-bin ^0.80.1 → ^0.80.2 * karma ^6.3.15 → ^6.3.16 * rollup ^2.67.1 → ^2.67.2 * Fix new ESLint errors --- build/build-plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build') diff --git a/build/build-plugins.js b/build/build-plugins.js index 8fa0e0b1f..4c68edcd1 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -48,7 +48,7 @@ const build = async plugin => { babelHelpers: 'bundled' }) ], - external: source => { + external(source) { // Pattern to identify local files const pattern = /^(\.{1,2})\// -- cgit v1.2.3 From d0117a17d807df05dfd6f6ce72a0d63f081ca529 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 20 Sep 2022 08:09:14 +0300 Subject: Update devDependencies (#37177) --- build/.eslintrc.json | 3 ++- build/build-plugins.js | 2 +- build/change-version.js | 4 ++-- build/generate-sri.js | 6 +++--- build/rollup.config.js | 2 +- build/vnu-jar.js | 2 +- build/zip-examples.js | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) (limited to 'build') diff --git a/build/.eslintrc.json b/build/.eslintrc.json index 679bd26f7..dec6323d0 100644 --- a/build/.eslintrc.json +++ b/build/.eslintrc.json @@ -9,6 +9,7 @@ "extends": "../.eslintrc.json", "rules": { "no-console": "off", - "strict": "error" + "strict": "error", + "unicorn/prefer-top-level-await": "off" } } diff --git a/build/build-plugins.js b/build/build-plugins.js index 4c68edcd1..a160209b0 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -9,7 +9,7 @@ 'use strict' -const path = require('path') +const path = require('node:path') const rollup = require('rollup') const globby = require('globby') const { babel } = require('@rollup/plugin-babel') diff --git a/build/change-version.js b/build/change-version.js index 6d85441a9..57c5fdec8 100644 --- a/build/change-version.js +++ b/build/change-version.js @@ -9,8 +9,8 @@ 'use strict' -const fs = require('fs').promises -const path = require('path') +const fs = require('node:fs').promises +const path = require('node:path') const globby = require('globby') const VERBOSE = process.argv.includes('--verbose') diff --git a/build/generate-sri.js b/build/generate-sri.js index cde818e09..ef1b39f97 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -12,9 +12,9 @@ 'use strict' -const crypto = require('crypto') -const fs = require('fs') -const path = require('path') +const crypto = require('node:crypto') +const fs = require('node:fs') +const path = require('node:path') const sh = require('shelljs') sh.config.fatal = true diff --git a/build/rollup.config.js b/build/rollup.config.js index 2d2920fd5..27f12ac03 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -1,6 +1,6 @@ 'use strict' -const path = require('path') +const path = require('node:path') const { babel } = require('@rollup/plugin-babel') const { nodeResolve } = require('@rollup/plugin-node-resolve') const replace = require('@rollup/plugin-replace') diff --git a/build/vnu-jar.js b/build/vnu-jar.js index df4192e24..f29eeb722 100644 --- a/build/vnu-jar.js +++ b/build/vnu-jar.js @@ -9,7 +9,7 @@ 'use strict' -const { execFile, spawn } = require('child_process') +const { execFile, spawn } = require('node:child_process') const vnu = require('vnu-jar') execFile('java', ['-version'], (error, stdout, stderr) => { diff --git a/build/zip-examples.js b/build/zip-examples.js index 759dd817d..077901e47 100644 --- a/build/zip-examples.js +++ b/build/zip-examples.js @@ -9,7 +9,7 @@ 'use strict' -const path = require('path') +const path = require('node:path') const sh = require('shelljs') const pkg = require('../package.json') -- cgit v1.2.3 From aa9d32dd153ed16943ad8be5e8795afaad24d0cf Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 26 Oct 2022 08:26:51 +0300 Subject: Use explicit imports in our javascript source files (#36854) --- build/build-plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build') diff --git a/build/build-plugins.js b/build/build-plugins.js index a160209b0..89fbe1d72 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -27,7 +27,7 @@ const filenameToEntity = filename => filename.replace('.js', '') for (const file of jsFiles) { resolvedPlugins.push({ - src: file.replace('.js', ''), + src: file, dist: file.replace('src', 'dist'), fileName: path.basename(file), className: filenameToEntity(path.basename(file)) -- cgit v1.2.3 From 634e449b9aea2e78cc889684da1b88ca76d1f19c Mon Sep 17 00:00:00 2001 From: George Sotiropoulos Date: Wed, 9 Nov 2022 11:36:12 +0200 Subject: explicitly use `banner` function, avoiding passing arguments --- build/rollup.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build') diff --git a/build/rollup.config.js b/build/rollup.config.js index 27f12ac03..f01918ebf 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -40,7 +40,7 @@ if (BUNDLE) { const rollupConfig = { input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`), output: { - banner, + banner: banner(), file: path.resolve(__dirname, `../dist/js/${fileDestination}.js`), format: ESM ? 'esm' : 'umd', globals, -- cgit v1.2.3 From 5208dd10c4f43b304ebeb75dcf508e016515a248 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 12 Nov 2022 10:09:36 +0200 Subject: ESLint: enable prefer-template rule (#37484) --- build/build-plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build') diff --git a/build/build-plugins.js b/build/build-plugins.js index 89fbe1d72..b6ce58df8 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -16,7 +16,7 @@ const { babel } = require('@rollup/plugin-babel') const banner = require('./banner.js') const sourcePath = path.resolve(__dirname, '../js/src/').replace(/\\/g, '/') -const jsFiles = globby.sync(sourcePath + '/**/*.js') +const jsFiles = globby.sync(`${sourcePath}/**/*.js`) // Array which holds the resolved plugins const resolvedPlugins = [] -- cgit v1.2.3 From cf3c1535e63affb87cb905c33979e814fa484778 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Mon, 21 Nov 2022 09:11:01 -0800 Subject: Update docs and package information to clarify license --- build/build-plugins.js | 1 - build/change-version.js | 1 - build/generate-sri.js | 1 - build/vnu-jar.js | 1 - 4 files changed, 4 deletions(-) (limited to 'build') diff --git a/build/build-plugins.js b/build/build-plugins.js index b6ce58df8..a29e83d83 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -3,7 +3,6 @@ /*! * Script to build our plugins to use them separately. * Copyright 2020-2022 The Bootstrap Authors - * Copyright 2020-2022 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/change-version.js b/build/change-version.js index 57c5fdec8..0de927d77 100644 --- a/build/change-version.js +++ b/build/change-version.js @@ -3,7 +3,6 @@ /*! * Script to update version number references in the project. * Copyright 2017-2022 The Bootstrap Authors - * Copyright 2017-2022 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/generate-sri.js b/build/generate-sri.js index ef1b39f97..652955721 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -6,7 +6,6 @@ * otherwise the hashes won't match! * * Copyright 2017-2022 The Bootstrap Authors - * Copyright 2017-2022 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/vnu-jar.js b/build/vnu-jar.js index f29eeb722..4da9b53c8 100644 --- a/build/vnu-jar.js +++ b/build/vnu-jar.js @@ -3,7 +3,6 @@ /*! * Script to run vnu-jar if Java is available. * Copyright 2017-2022 The Bootstrap Authors - * Copyright 2017-2022 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ -- cgit v1.2.3 From 2cc580e2d1e70d942965d54365db24fe6728ad00 Mon Sep 17 00:00:00 2001 From: "Patrick H. Lauke" Date: Mon, 2 Jan 2023 00:30:53 +0000 Subject: Docs: remove remnants of Twitter / bump dates (#37779) --- build/build-plugins.js | 2 +- build/change-version.js | 2 +- build/generate-sri.js | 2 +- build/vnu-jar.js | 2 +- build/zip-examples.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'build') diff --git a/build/build-plugins.js b/build/build-plugins.js index a29e83d83..b2833a3fb 100644 --- a/build/build-plugins.js +++ b/build/build-plugins.js @@ -2,7 +2,7 @@ /*! * Script to build our plugins to use them separately. - * Copyright 2020-2022 The Bootstrap Authors + * Copyright 2020-2023 The Bootstrap Authors * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/change-version.js b/build/change-version.js index 0de927d77..cda0ea12d 100644 --- a/build/change-version.js +++ b/build/change-version.js @@ -2,7 +2,7 @@ /*! * Script to update version number references in the project. - * Copyright 2017-2022 The Bootstrap Authors + * Copyright 2017-2023 The Bootstrap Authors * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/generate-sri.js b/build/generate-sri.js index 652955721..1c8050f6e 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -5,7 +5,7 @@ * Remember to use the same vendor files as the CDN ones, * otherwise the hashes won't match! * - * Copyright 2017-2022 The Bootstrap Authors + * Copyright 2017-2023 The Bootstrap Authors * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/vnu-jar.js b/build/vnu-jar.js index 4da9b53c8..77f9ed848 100644 --- a/build/vnu-jar.js +++ b/build/vnu-jar.js @@ -2,7 +2,7 @@ /*! * Script to run vnu-jar if Java is available. - * Copyright 2017-2022 The Bootstrap Authors + * Copyright 2017-2023 The Bootstrap Authors * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ diff --git a/build/zip-examples.js b/build/zip-examples.js index 077901e47..d3dc01278 100644 --- a/build/zip-examples.js +++ b/build/zip-examples.js @@ -3,7 +3,7 @@ /*! * Script to create the built examples zip archive; * requires the `zip` command to be present! - * Copyright 2020-2022 The Bootstrap Authors + * Copyright 2020-2023 The Bootstrap Authors * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ -- cgit v1.2.3 From e8730484b8f0ad0458da7ff52ab5ebf55d60b693 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 24 Mar 2023 11:32:43 +0200 Subject: vnu-jar.js: add more logging (#38314) --- build/vnu-jar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'build') diff --git a/build/vnu-jar.js b/build/vnu-jar.js index 77f9ed848..22956cb7e 100644 --- a/build/vnu-jar.js +++ b/build/vnu-jar.js @@ -13,10 +13,13 @@ const vnu = require('vnu-jar') execFile('java', ['-version'], (error, stdout, stderr) => { if (error) { - console.error('Skipping vnu-jar test; Java is missing.') + 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 `|`. @@ -48,6 +51,8 @@ execFile('java', ['-version'], (error, stdout, stderr) => { args.splice(0, 0, '-Xss512k') } + console.log(`command used: java ${args.join(' ')}`) + return spawn('java', args, { shell: true, stdio: 'inherit' -- cgit v1.2.3 From 1fe9067604c65ad61bd5685ad52965f6401e15fe Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 28 Mar 2023 19:56:17 +0300 Subject: zip scripts: remove previous zip files and add quiet flag (#38358) --- build/zip-examples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build') diff --git a/build/zip-examples.js b/build/zip-examples.js index d3dc01278..613376a97 100644 --- a/build/zip-examples.js +++ b/build/zip-examples.js @@ -84,7 +84,7 @@ for (const file of sh.find(`${distFolder}/**/*.html`)) { } // create the zip file -sh.exec(`zip -r9 "${distFolder}.zip" "${distFolder}"`) +sh.exec(`zip -qr9 "${distFolder}.zip" "${distFolder}"`) // remove the folder we created sh.rm('-rf', distFolder) -- cgit v1.2.3 From ae43f0c48bf7acede8a325b24197001fe2b2f416 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 29 Mar 2023 20:49:30 +0300 Subject: Tweak and re-organize ESLint config (#38369) * Tweak and re-organize ESLint config * merge individual configs to the root config * enable more eslint-plugin-import rules * lint markdown files * Lint --- build/.eslintrc.json | 15 --------------- build/banner.js | 1 + 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 build/.eslintrc.json (limited to 'build') diff --git a/build/.eslintrc.json b/build/.eslintrc.json deleted file mode 100644 index dec6323d0..000000000 --- a/build/.eslintrc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "env": { - "browser": false, - "node": true - }, - "parserOptions": { - "sourceType": "script" - }, - "extends": "../.eslintrc.json", - "rules": { - "no-console": "off", - "strict": "error", - "unicorn/prefer-top-level-await": "off" - } -} diff --git a/build/banner.js b/build/banner.js index df82ff32e..a022f1c48 100644 --- a/build/banner.js +++ b/build/banner.js @@ -1,6 +1,7 @@ 'use strict' const pkg = require('../package.json') + const year = new Date().getFullYear() function getBanner(pluginFilename) { -- cgit v1.2.3 From 3d84e60d690b9755d29f2a8bb9ca807f484768bd Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 9 Apr 2023 20:13:08 +0300 Subject: generate-sri.js: use destructuring (#38413) --- build/generate-sri.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'build') diff --git a/build/generate-sri.js b/build/generate-sri.js index 1c8050f6e..1674247a8 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -46,8 +46,8 @@ const files = [ } ] -for (const file of files) { - fs.readFile(file.file, 'utf8', (error, data) => { +for (const { file, configPropertyName } of files) { + fs.readFile(file, 'utf8', (error, data) => { if (error) { throw error } @@ -56,8 +56,8 @@ for (const file of files) { const hash = crypto.createHash(algo).update(data, 'utf8').digest('base64') const integrity = `${algo}-${hash}` - console.log(`${file.configPropertyName}: ${integrity}`) + console.log(`${configPropertyName}: ${integrity}`) - sh.sed('-i', new RegExp(`^(\\s+${file.configPropertyName}:\\s+["'])\\S*(["'])`), `$1${integrity}$2`, configFile) + sh.sed('-i', new RegExp(`^(\\s+${configPropertyName}:\\s+["'])\\S*(["'])`), `$1${integrity}$2`, configFile) }) } -- cgit v1.2.3 From b4befee506260d2b62705f3faec5142054feac6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20D=C3=A9ramond?= Date: Wed, 12 Apr 2023 21:56:22 +0200 Subject: change-version.js: handle rubygems specific version number (#38452) * Handle Ruby specific version in `change-version.js` * Guard against the same version --------- Co-authored-by: XhmikosR --- build/change-version.js | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'build') diff --git a/build/change-version.js b/build/change-version.js index cda0ea12d..9685df589 100644 --- a/build/change-version.js +++ b/build/change-version.js @@ -35,9 +35,17 @@ function regExpQuoteReplacement(string) { async function replaceRecursively(file, oldVersion, newVersion) { const originalString = await fs.readFile(file, 'utf8') - const newString = originalString.replace( - new RegExp(regExpQuote(oldVersion), 'g'), regExpQuoteReplacement(newVersion) - ) + 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) { @@ -55,22 +63,35 @@ async function replaceRecursively(file, oldVersion, newVersion) { 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) { - console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]') - console.error('Got arguments:', args) - process.exit(1) + showUsage(args) } - // Strip any leading `v` from arguments because otherwise we will end up with duplicate `v`s - [oldVersion, newVersion] = [oldVersion, newVersion].map(arg => arg.startsWith('v') ? arg.slice(1) : arg) + // 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))) + await Promise.all( + files.map(file => replaceRecursively(file, oldVersion, newVersion)) + ) } catch (error) { console.error(error) process.exit(1) -- cgit v1.2.3 From 07a08c2335bf2e32579edcb110821c561bd0da67 Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Wed, 17 May 2023 13:18:01 +0900 Subject: Rename config.yml to hugo.yml (#38582) hugo.yml is now recommended (over the generic sounding config.yml) as the default config based filename REF: https://gohugo.io/getting-started/configuration/#hugotoml-vs-configtoml Changing this may make it easier for code editors and build tools to identify this as a Hugo configuration file and project. --- build/generate-sri.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'build') diff --git a/build/generate-sri.js b/build/generate-sri.js index 1674247a8..2e2292475 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -18,11 +18,11 @@ const sh = require('shelljs') sh.config.fatal = true -const configFile = path.join(__dirname, '../config.yml') +const configFile = path.join(__dirname, '../hugo.yml') // Array of objects which holds the files to generate SRI hashes for. // `file` is the path from the root folder -// `configPropertyName` is the config.yml variable's name of the file +// `configPropertyName` is the hugo.yml variable's name of the file const files = [ { file: 'dist/css/bootstrap.min.css', -- cgit v1.2.3 From 5036f70e1c80cebb270aca8c1b422f8d4d4bd47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20D=C3=A9ramond?= Date: Sun, 18 Jun 2023 16:52:31 +0200 Subject: Add `color-modes.js` to `bootstrap-x.y.z-examples.zip` (#38747) --- build/zip-examples.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'build') diff --git a/build/zip-examples.js b/build/zip-examples.js index 613376a97..7378c33c1 100644 --- a/build/zip-examples.js +++ b/build/zip-examples.js @@ -34,6 +34,9 @@ const imgFiles = [ 'bootstrap-logo.svg', 'bootstrap-logo-white.svg' ] +const staticJsFiles = [ + 'color-modes.js' +] sh.config.fatal = true @@ -52,7 +55,8 @@ sh.mkdir('-p', [ distFolder, `${distFolder}/assets/brand/`, `${distFolder}/assets/dist/css/`, - `${distFolder}/assets/dist/js/` + `${distFolder}/assets/dist/js/`, + `${distFolder}/assets/js/` ]) sh.cp('-Rf', `${docsDir}/examples/*`, distFolder) @@ -69,6 +73,10 @@ for (const file of imgFiles) { sh.cp('-f', `${docsDir}/assets/brand/${file}`, `${distFolder}/assets/brand/`) } +for (const file of staticJsFiles) { + sh.cp('-f', `${docsDir}/assets/js/${file}`, `${distFolder}/assets/js/`) +} + sh.rm(`${distFolder}/index.html`) // get all examples' HTML files -- cgit v1.2.3 From 56664e0caa09fe49c6a17ffd9c21909b2380a8a8 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 6 Aug 2023 07:37:24 +0300 Subject: Convert build scripts to ESM (#38984) --- build/banner.js | 15 ------- build/banner.mjs | 20 +++++++++ build/build-plugins.js | 103 ---------------------------------------------- build/build-plugins.mjs | 105 +++++++++++++++++++++++++++++++++++++++++++++++ build/change-version.js | 101 --------------------------------------------- build/change-version.mjs | 102 +++++++++++++++++++++++++++++++++++++++++++++ build/generate-sri.js | 63 ---------------------------- build/generate-sri.mjs | 64 +++++++++++++++++++++++++++++ build/postcss.config.js | 19 --------- build/postcss.config.mjs | 17 ++++++++ build/rollup.config.js | 57 ------------------------- build/rollup.config.mjs | 59 ++++++++++++++++++++++++++ build/vnu-jar.js | 61 --------------------------- build/vnu-jar.mjs | 59 ++++++++++++++++++++++++++ build/zip-examples.js | 98 ------------------------------------------- build/zip-examples.mjs | 101 +++++++++++++++++++++++++++++++++++++++++++++ 16 files changed, 527 insertions(+), 517 deletions(-) delete mode 100644 build/banner.js create mode 100644 build/banner.mjs delete mode 100644 build/build-plugins.js create mode 100644 build/build-plugins.mjs delete mode 100644 build/change-version.js create mode 100644 build/change-version.mjs delete mode 100644 build/generate-sri.js create mode 100644 build/generate-sri.mjs delete mode 100644 build/postcss.config.js create mode 100644 build/postcss.config.mjs delete mode 100644 build/rollup.config.js create mode 100644 build/rollup.config.mjs delete mode 100644 build/vnu-jar.js create mode 100644 build/vnu-jar.mjs delete mode 100644 build/zip-examples.js create mode 100644 build/zip-examples.mjs (limited to 'build') diff --git a/build/banner.js b/build/banner.js deleted file mode 100644 index a022f1c48..000000000 --- a/build/banner.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict' - -const pkg = require('../package.json') - -const year = new Date().getFullYear() - -function getBanner(pluginFilename) { - return `/*! - * Bootstrap${pluginFilename ? ` ${pluginFilename}` : ''} v${pkg.version} (${pkg.homepage}) - * Copyright 2011-${year} ${pkg.author} - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - */` -} - -module.exports = getBanner diff --git a/build/banner.mjs b/build/banner.mjs new file mode 100644 index 000000000..3fea93c8f --- /dev/null +++ b/build/banner.mjs @@ -0,0 +1,20 @@ +import fs from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +const pkgJson = path.join(__dirname, '../package.json') +const pkg = JSON.parse(await fs.readFile(pkgJson, 'utf8')) + +const year = new Date().getFullYear() + +function getBanner(pluginFilename) { + return `/*! + * Bootstrap${pluginFilename ? ` ${pluginFilename}` : ''} v${pkg.version} (${pkg.homepage}) + * Copyright 2011-${year} ${pkg.author} + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */` +} + +export default getBanner diff --git a/build/build-plugins.js b/build/build-plugins.js deleted file mode 100644 index b2833a3fb..000000000 --- a/build/build-plugins.js +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env node - -/*! - * Script to build our plugins to use them separately. - * Copyright 2020-2023 The Bootstrap Authors - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - */ - -'use strict' - -const path = require('node:path') -const rollup = require('rollup') -const globby = require('globby') -const { babel } = require('@rollup/plugin-babel') -const banner = require('./banner.js') - -const sourcePath = path.resolve(__dirname, '../js/src/').replace(/\\/g, '/') -const jsFiles = globby.sync(`${sourcePath}/**/*.js`) - -// Array which holds the resolved plugins -const resolvedPlugins = [] - -// Trims the "js" extension and uppercases => first letter, hyphens, backslashes & slashes -const filenameToEntity = filename => filename.replace('.js', '') - .replace(/(?:^|-|\/|\\)[a-z]/g, str => str.slice(-1).toUpperCase()) - -for (const file of jsFiles) { - resolvedPlugins.push({ - src: file, - dist: file.replace('src', 'dist'), - fileName: path.basename(file), - className: filenameToEntity(path.basename(file)) - // safeClassName: filenameToEntity(path.relative(sourcePath, file)) - }) -} - -const build = async plugin => { - const globals = {} - - const bundle = await rollup.rollup({ - input: plugin.src, - plugins: [ - babel({ - // Only transpile our source code - exclude: 'node_modules/**', - // Include the helpers in each file, at most one copy of each - babelHelpers: 'bundled' - }) - ], - external(source) { - // Pattern to identify local files - const pattern = /^(\.{1,2})\// - - // It's not a local file, e.g a Node.js package - if (!pattern.test(source)) { - globals[source] = source - return true - } - - const usedPlugin = resolvedPlugins.find(plugin => { - return plugin.src.includes(source.replace(pattern, '')) - }) - - if (!usedPlugin) { - throw new Error(`Source ${source} is not mapped!`) - } - - // We can change `Index` with `UtilIndex` etc if we use - // `safeClassName` instead of `className` everywhere - globals[path.normalize(usedPlugin.src)] = usedPlugin.className - return true - } - }) - - await bundle.write({ - banner: banner(plugin.fileName), - format: 'umd', - name: plugin.className, - sourcemap: true, - globals, - generatedCode: 'es2015', - file: plugin.dist - }) - - console.log(`Built ${plugin.className}`) -} - -(async () => { - try { - const basename = path.basename(__filename) - const timeLabel = `[${basename}] finished` - - console.log('Building individual plugins...') - console.time(timeLabel) - - await Promise.all(Object.values(resolvedPlugins).map(plugin => build(plugin))) - - console.timeEnd(timeLabel) - } catch (error) { - console.error(error) - process.exit(1) - } -})() diff --git a/build/build-plugins.mjs b/build/build-plugins.mjs new file mode 100644 index 000000000..77e63070c --- /dev/null +++ b/build/build-plugins.mjs @@ -0,0 +1,105 @@ +#!/usr/bin/env node + +/*! + * Script to build our plugins to use them separately. + * Copyright 2020-2023 The Bootstrap Authors + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ + +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { babel } from '@rollup/plugin-babel' +import globby from 'globby' +import { rollup } from 'rollup' +import banner from './banner.mjs' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +const sourcePath = path.resolve(__dirname, '../js/src/').replace(/\\/g, '/') +const jsFiles = globby.sync(`${sourcePath}/**/*.js`) + +// Array which holds the resolved plugins +const resolvedPlugins = [] + +// Trims the "js" extension and uppercases => first letter, hyphens, backslashes & slashes +const filenameToEntity = filename => filename.replace('.js', '') + .replace(/(?:^|-|\/|\\)[a-z]/g, str => str.slice(-1).toUpperCase()) + +for (const file of jsFiles) { + resolvedPlugins.push({ + src: file, + dist: file.replace('src', 'dist'), + fileName: path.basename(file), + className: filenameToEntity(path.basename(file)) + // safeClassName: filenameToEntity(path.relative(sourcePath, file)) + }) +} + +const build = async plugin => { + const globals = {} + + const bundle = await rollup({ + input: plugin.src, + plugins: [ + babel({ + // Only transpile our source code + exclude: 'node_modules/**', + // Include the helpers in each file, at most one copy of each + babelHelpers: 'bundled' + }) + ], + external(source) { + // Pattern to identify local files + const pattern = /^(\.{1,2})\// + + // It's not a local file, e.g a Node.js package + if (!pattern.test(source)) { + globals[source] = source + return true + } + + const usedPlugin = resolvedPlugins.find(plugin => { + return plugin.src.includes(source.replace(pattern, '')) + }) + + if (!usedPlugin) { + throw new Error(`Source ${source} is not mapped!`) + } + + // We can change `Index` with `UtilIndex` etc if we use + // `safeClassName` instead of `className` everywhere + globals[path.normalize(usedPlugin.src)] = usedPlugin.className + return true + } + }) + + await bundle.write({ + banner: banner(plugin.fileName), + format: 'umd', + name: plugin.className, + sourcemap: true, + globals, + generatedCode: 'es2015', + file: plugin.dist + }) + + console.log(`Built ${plugin.className}`) +} + +(async () => { + try { + const basename = path.basename(__filename) + const timeLabel = `[${basename}] finished` + + console.log('Building individual plugins...') + console.time(timeLabel) + + await Promise.all(Object.values(resolvedPlugins).map(plugin => build(plugin))) + + console.timeEnd(timeLabel) + } catch (error) { + console.error(error) + process.exit(1) + } +})() diff --git a/build/change-version.js b/build/change-version.js deleted file mode 100644 index 9685df589..000000000 --- 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)) diff --git a/build/change-version.mjs b/build/change-version.mjs new file mode 100644 index 000000000..2a16f2f21 --- /dev/null +++ b/build/change-version.mjs @@ -0,0 +1,102 @@ +#!/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) + */ + +import fs from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import globby from 'globby' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +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)) diff --git a/build/generate-sri.js b/build/generate-sri.js deleted file mode 100644 index 2e2292475..000000000 --- a/build/generate-sri.js +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env node - -/*! - * Script to generate SRI hashes for use in our docs. - * Remember to use the same vendor files as the CDN ones, - * otherwise the hashes won't match! - * - * Copyright 2017-2023 The Bootstrap Authors - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - */ - -'use strict' - -const crypto = require('node:crypto') -const fs = require('node:fs') -const path = require('node:path') -const sh = require('shelljs') - -sh.config.fatal = true - -const configFile = path.join(__dirname, '../hugo.yml') - -// Array of objects which holds the files to generate SRI hashes for. -// `file` is the path from the root folder -// `configPropertyName` is the hugo.yml variable's name of the file -const files = [ - { - file: 'dist/css/bootstrap.min.css', - configPropertyName: 'css_hash' - }, - { - file: 'dist/css/bootstrap.rtl.min.css', - configPropertyName: 'css_rtl_hash' - }, - { - file: 'dist/js/bootstrap.min.js', - configPropertyName: 'js_hash' - }, - { - file: 'dist/js/bootstrap.bundle.min.js', - configPropertyName: 'js_bundle_hash' - }, - { - file: 'node_modules/@popperjs/core/dist/umd/popper.min.js', - configPropertyName: 'popper_hash' - } -] - -for (const { file, configPropertyName } of files) { - fs.readFile(file, 'utf8', (error, data) => { - if (error) { - throw error - } - - const algo = 'sha384' - const hash = crypto.createHash(algo).update(data, 'utf8').digest('base64') - const integrity = `${algo}-${hash}` - - console.log(`${configPropertyName}: ${integrity}`) - - sh.sed('-i', new RegExp(`^(\\s+${configPropertyName}:\\s+["'])\\S*(["'])`), `$1${integrity}$2`, configFile) - }) -} diff --git a/build/generate-sri.mjs b/build/generate-sri.mjs new file mode 100644 index 000000000..e2b1554f1 --- /dev/null +++ b/build/generate-sri.mjs @@ -0,0 +1,64 @@ +#!/usr/bin/env node + +/*! + * Script to generate SRI hashes for use in our docs. + * Remember to use the same vendor files as the CDN ones, + * otherwise the hashes won't match! + * + * Copyright 2017-2023 The Bootstrap Authors + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ + +import crypto from 'node:crypto' +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import sh from 'shelljs' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +sh.config.fatal = true + +const configFile = path.join(__dirname, '../hugo.yml') + +// Array of objects which holds the files to generate SRI hashes for. +// `file` is the path from the root folder +// `configPropertyName` is the hugo.yml variable's name of the file +const files = [ + { + file: 'dist/css/bootstrap.min.css', + configPropertyName: 'css_hash' + }, + { + file: 'dist/css/bootstrap.rtl.min.css', + configPropertyName: 'css_rtl_hash' + }, + { + file: 'dist/js/bootstrap.min.js', + configPropertyName: 'js_hash' + }, + { + file: 'dist/js/bootstrap.bundle.min.js', + configPropertyName: 'js_bundle_hash' + }, + { + file: 'node_modules/@popperjs/core/dist/umd/popper.min.js', + configPropertyName: 'popper_hash' + } +] + +for (const { file, configPropertyName } of files) { + fs.readFile(file, 'utf8', (error, data) => { + if (error) { + throw error + } + + const algorithm = 'sha384' + const hash = crypto.createHash(algorithm).update(data, 'utf8').digest('base64') + const integrity = `${algorithm}-${hash}` + + console.log(`${configPropertyName}: ${integrity}`) + + sh.sed('-i', new RegExp(`^(\\s+${configPropertyName}:\\s+["'])\\S*(["'])`), `$1${integrity}$2`, configFile) + }) +} diff --git a/build/postcss.config.js b/build/postcss.config.js deleted file mode 100644 index 7f8186d10..000000000 --- a/build/postcss.config.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict' - -const mapConfig = { - inline: false, - annotation: true, - sourcesContent: true -} - -module.exports = context => { - return { - map: context.file.dirname.includes('examples') ? false : mapConfig, - plugins: { - autoprefixer: { - cascade: false - }, - rtlcss: context.env === 'RTL' - } - } -} diff --git a/build/postcss.config.mjs b/build/postcss.config.mjs new file mode 100644 index 000000000..7717cfc3f --- /dev/null +++ b/build/postcss.config.mjs @@ -0,0 +1,17 @@ +const mapConfig = { + inline: false, + annotation: true, + sourcesContent: true +} + +export default context => { + return { + map: context.file.dirname.includes('examples') ? false : mapConfig, + plugins: { + autoprefixer: { + cascade: false + }, + rtlcss: context.env === 'RTL' + } + } +} diff --git a/build/rollup.config.js b/build/rollup.config.js deleted file mode 100644 index f01918ebf..000000000 --- a/build/rollup.config.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict' - -const path = require('node:path') -const { babel } = require('@rollup/plugin-babel') -const { nodeResolve } = require('@rollup/plugin-node-resolve') -const replace = require('@rollup/plugin-replace') -const banner = require('./banner.js') - -const BUNDLE = process.env.BUNDLE === 'true' -const ESM = process.env.ESM === 'true' - -let fileDestination = `bootstrap${ESM ? '.esm' : ''}` -const external = ['@popperjs/core'] -const plugins = [ - babel({ - // Only transpile our source code - exclude: 'node_modules/**', - // Include the helpers in the bundle, at most one copy of each - babelHelpers: 'bundled' - }) -] -const globals = { - '@popperjs/core': 'Popper' -} - -if (BUNDLE) { - fileDestination += '.bundle' - // Remove last entry in external array to bundle Popper - external.pop() - delete globals['@popperjs/core'] - plugins.push( - replace({ - 'process.env.NODE_ENV': '"production"', - preventAssignment: true - }), - nodeResolve() - ) -} - -const rollupConfig = { - input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`), - output: { - banner: banner(), - file: path.resolve(__dirname, `../dist/js/${fileDestination}.js`), - format: ESM ? 'esm' : 'umd', - globals, - generatedCode: 'es2015' - }, - external, - plugins -} - -if (!ESM) { - rollupConfig.output.name = 'bootstrap' -} - -module.exports = rollupConfig diff --git a/build/rollup.config.mjs b/build/rollup.config.mjs new file mode 100644 index 000000000..dd6c7d13e --- /dev/null +++ b/build/rollup.config.mjs @@ -0,0 +1,59 @@ +import path from 'node:path' +import process from 'node:process' +import { fileURLToPath } from 'node:url' +import { babel } from '@rollup/plugin-babel' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import replace from '@rollup/plugin-replace' +import banner from './banner.mjs' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +const BUNDLE = process.env.BUNDLE === 'true' +const ESM = process.env.ESM === 'true' + +let destinationFile = `bootstrap${ESM ? '.esm' : ''}` +const external = ['@popperjs/core'] +const plugins = [ + babel({ + // Only transpile our source code + exclude: 'node_modules/**', + // Include the helpers in the bundle, at most one copy of each + babelHelpers: 'bundled' + }) +] +const globals = { + '@popperjs/core': 'Popper' +} + +if (BUNDLE) { + destinationFile += '.bundle' + // Remove last entry in external array to bundle Popper + external.pop() + delete globals['@popperjs/core'] + plugins.push( + replace({ + 'process.env.NODE_ENV': '"production"', + preventAssignment: true + }), + nodeResolve() + ) +} + +const rollupConfig = { + input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`), + output: { + banner: banner(), + file: path.resolve(__dirname, `../dist/js/${destinationFile}.js`), + format: ESM ? 'esm' : 'umd', + globals, + generatedCode: 'es2015' + }, + external, + plugins +} + +if (!ESM) { + rollupConfig.output.name = 'bootstrap' +} + +export default rollupConfig diff --git a/build/vnu-jar.js b/build/vnu-jar.js deleted file mode 100644 index 22956cb7e..000000000 --- a/build/vnu-jar.js +++ /dev/null @@ -1,61 +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 = [ - // "autocomplete" is included in