Skip to content

Commit 84ff14e

Browse files
committed
Merge branch 'main' of https://github.com/coreui/coreui
2 parents be77818 + 693efd2 commit 84ff14e

File tree

77 files changed

+743
-669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+743
-669
lines changed

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"node": true
109109
},
110110
"parserOptions": {
111-
"sourceType": "script"
111+
"sourceType": "module"
112112
},
113113
"rules": {
114114
"no-console": "off",

build/banner.js

-15
This file was deleted.

build/banner.mjs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import fs from 'node:fs/promises'
2+
import path from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
6+
7+
const pkgJson = path.join(__dirname, '../package.json')
8+
const pkg = JSON.parse(await fs.readFile(pkgJson, 'utf8'))
9+
10+
const year = new Date().getFullYear()
11+
12+
function getBanner(pluginFilename) {
13+
return `/*!
14+
* CoreUI${pluginFilename ? ` ${pluginFilename}` : ''} v${pkg.version} (${pkg.homepage})
15+
* Copyright ${year} ${pkg.author}
16+
* Licensed under MIT (https://github.com/coreui/coreui/blob/main/LICENSE)
17+
*/`
18+
}
19+
20+
export default getBanner

build/build-plugins.js renamed to build/build-plugins.mjs

+9-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
77
*/
88

9-
'use strict'
9+
import path from 'node:path'
10+
import { fileURLToPath } from 'node:url'
11+
import { babel } from '@rollup/plugin-babel'
12+
import globby from 'globby'
13+
import { rollup } from 'rollup'
14+
import banner from './banner.mjs'
1015

11-
const path = require('node:path')
12-
const rollup = require('rollup')
13-
const globby = require('globby')
14-
const { babel } = require('@rollup/plugin-babel')
15-
const banner = require('./banner.js')
16+
const __filename = fileURLToPath(import.meta.url)
17+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1618

1719
const sourcePath = path.resolve(__dirname, '../js/src/').replace(/\\/g, '/')
1820
const jsFiles = globby.sync(`${sourcePath}/**/*.js`)
@@ -37,7 +39,7 @@ for (const file of jsFiles) {
3739
const build = async plugin => {
3840
const globals = {}
3941

40-
const bundle = await rollup.rollup({
42+
const bundle = await rollup({
4143
input: plugin.src,
4244
plugins: [
4345
babel({

build/change-version.js renamed to build/change-version.mjs

+27-16
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,21 @@
66
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
77
*/
88

9-
'use strict'
10-
11-
const fs = require('node:fs').promises
12-
const path = require('node:path')
13-
const globby = require('globby')
9+
import { execFile } from 'node:child_process'
10+
import fs from 'node:fs/promises'
11+
import process from 'node:process'
1412

1513
const VERBOSE = process.argv.includes('--verbose')
1614
const DRY_RUN = process.argv.includes('--dry') || process.argv.includes('--dry-run')
1715

18-
// These are the filetypes we only care about replacing the version
19-
const GLOB = [
20-
'**/*.{css,html,js,json,md,scss,txt,yml}'
16+
// These are the files we only care about replacing the version
17+
const FILES = [
18+
'README.md',
19+
'hugo.yml',
20+
'js/src/base-component.js',
21+
'package.js',
22+
'scss/mixins/_banner.scss'
2123
]
22-
const GLOBBY_OPTIONS = {
23-
cwd: path.join(__dirname, '..'),
24-
gitignore: true
25-
}
2624

2725
// Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37
2826
function regExpQuote(string) {
@@ -53,7 +51,7 @@ async function replaceRecursively(file, oldVersion, newVersion) {
5351
}
5452

5553
if (VERBOSE) {
56-
console.log(`FILE: ${file}`)
54+
console.log(`Found ${oldVersion} in ${file}`)
5755
}
5856

5957
if (DRY_RUN) {
@@ -63,6 +61,19 @@ async function replaceRecursively(file, oldVersion, newVersion) {
6361
await fs.writeFile(file, newString, 'utf8')
6462
}
6563

64+
function bumpNpmVersion(newVersion) {
65+
if (DRY_RUN) {
66+
return
67+
}
68+
69+
execFile('npm', ['version', newVersion, '--no-git-tag'], { shell: true }, error => {
70+
if (error) {
71+
console.error(error)
72+
process.exit(1)
73+
}
74+
})
75+
}
76+
6677
function showUsage(args) {
6778
console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]')
6879
console.error('Got arguments:', args)
@@ -86,11 +97,11 @@ async function main(args) {
8697
showUsage(args)
8798
}
8899

89-
try {
90-
const files = await globby(GLOB, GLOBBY_OPTIONS)
100+
bumpNpmVersion(newVersion)
91101

102+
try {
92103
await Promise.all(
93-
files.map(file => replaceRecursively(file, oldVersion, newVersion))
104+
FILES.map(file => replaceRecursively(file, oldVersion, newVersion))
94105
)
95106
} catch (error) {
96107
console.error(error)

build/generate-sri.js renamed to build/generate-sri.mjs

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
1010
*/
1111

12-
'use strict'
12+
import crypto from 'node:crypto'
13+
import fs from 'node:fs'
14+
import path from 'node:path'
15+
import { fileURLToPath } from 'node:url'
16+
import sh from 'shelljs'
1317

14-
const crypto = require('node:crypto')
15-
const fs = require('node:fs')
16-
const path = require('node:path')
17-
const sh = require('shelljs')
18+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1819

1920
sh.config.fatal = true
2021

@@ -52,9 +53,9 @@ for (const { file, configPropertyName } of files) {
5253
throw error
5354
}
5455

55-
const algo = 'sha384'
56-
const hash = crypto.createHash(algo).update(data, 'utf8').digest('base64')
57-
const integrity = `${algo}-${hash}`
56+
const algorithm = 'sha384'
57+
const hash = crypto.createHash(algorithm).update(data, 'utf8').digest('base64')
58+
const integrity = `${algorithm}-${hash}`
5859

5960
console.log(`${configPropertyName}: ${integrity}`)
6061

build/postcss.config.js renamed to build/postcss.config.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
'use strict'
2-
31
const mapConfig = {
42
inline: false,
53
annotation: true,
64
sourcesContent: true
75
}
86

9-
module.exports = context => {
7+
export default context => {
108
return {
119
map: context.file.dirname.includes('examples') ? false : mapConfig,
1210
plugins: {

build/rollup.config.js renamed to build/rollup.config.mjs

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
'use strict'
1+
import path from 'node:path'
2+
import process from 'node:process'
3+
import { fileURLToPath } from 'node:url'
4+
import { babel } from '@rollup/plugin-babel'
5+
import { nodeResolve } from '@rollup/plugin-node-resolve'
6+
import replace from '@rollup/plugin-replace'
7+
import banner from './banner.mjs'
28

3-
const path = require('node:path')
4-
const { babel } = require('@rollup/plugin-babel')
5-
const { nodeResolve } = require('@rollup/plugin-node-resolve')
6-
const replace = require('@rollup/plugin-replace')
7-
const banner = require('./banner.js')
9+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
810

911
const BUNDLE = process.env.BUNDLE === 'true'
1012
const ESM = process.env.ESM === 'true'
1113

12-
let fileDestination = `coreui${ESM ? '.esm' : ''}`
13-
const external = ['@popperjs/core', 'date-fns']
14+
let destinationFile = `coreui${ESM ? '.esm' : ''}`
15+
const external = ['@popperjs/core']
1416
const plugins = [
1517
babel({
1618
// Only transpile our source code
@@ -25,7 +27,7 @@ const globals = {
2527
}
2628

2729
if (BUNDLE) {
28-
fileDestination += '.bundle'
30+
destinationFile += '.bundle'
2931
// Remove last entry in external array to bundle Popper
3032
external.pop()
3133
delete globals['@popperjs/core']
@@ -45,7 +47,7 @@ const rollupConfig = {
4547
input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`),
4648
output: {
4749
banner: banner(),
48-
file: path.resolve(__dirname, `../dist/js/${fileDestination}.js`),
50+
file: path.resolve(__dirname, `../dist/js/${destinationFile}.js`),
4951
format: ESM ? 'esm' : 'umd',
5052
globals,
5153
generatedCode: 'es2015'
@@ -58,4 +60,4 @@ if (!ESM) {
5860
rollupConfig.output.name = 'coreui'
5961
}
6062

61-
module.exports = rollupConfig
63+
export default rollupConfig

build/vnu-jar.js renamed to build/vnu-jar.mjs

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
77
*/
88

9-
'use strict'
10-
11-
const { execFile, spawn } = require('node:child_process')
12-
const vnu = require('vnu-jar')
9+
import { execFile, spawn } from 'node:child_process'
10+
import vnu from 'vnu-jar'
1311

1412
execFile('java', ['-version'], (error, stdout, stderr) => {
1513
if (error) {
@@ -58,4 +56,4 @@ execFile('java', ['-version'], (error, stdout, stderr) => {
5856
stdio: 'inherit'
5957
})
6058
.on('exit', process.exit)
61-
})
59+
})

dist/css/coreui-grid.css

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/css/coreui-grid.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/css/coreui-grid.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/css/coreui-grid.min.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)