Skip to content

Commit

Permalink
release: v4.0.0-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mrholek committed May 5, 2021
1 parent 13c08d0 commit 66d199c
Show file tree
Hide file tree
Showing 64 changed files with 6,542 additions and 3,830 deletions.
142 changes: 60 additions & 82 deletions build/change-version.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,106 +1,84 @@
#!/usr/bin/env node

'use strict'

/*!
* Script to update version number references in the project.
* Copyright 2017 The Bootstrap Authors
* Copyright 2017 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Copyright 2017-2021 The Bootstrap Authors
* Copyright 2017-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/

/* global Set */
'use strict'

const fs = require('fs')
const fs = require('fs').promises
const path = require('path')
const sh = require('shelljs')
sh.config.fatal = true
const sed = sh.sed
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
}
const EXCLUDED_FILES = [
'CHANGELOG.md'
]

// Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37
RegExp.quote = (string) => string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&')
RegExp.quoteReplacement = (string) => string.replace(/[$]/g, '$$')
function regExpQuote(string) {
return string.replace(/[$()*+-.?[\\\]^{|}]/g, '\\$&')
}

function regExpQuoteReplacement(string) {
return string.replace(/\$/g, '$$')
}

const DRY_RUN = false
async function replaceRecursively(file, oldVersion, newVersion) {
const originalString = await fs.readFile(file, 'utf8')
const newString = originalString.replace(
new RegExp(regExpQuote(oldVersion), 'g'), regExpQuoteReplacement(newVersion)
)

function walkAsync(directory, excludedDirectories, fileCallback, errback) {
if (excludedDirectories.has(path.parse(directory).base)) {
// No need to move any further if the strings are identical
if (originalString === newString) {
return
}
fs.readdir(directory, (err, names) => {
if (err) {
errback(err)
return
}
names.forEach((name) => {
const filepath = path.join(directory, name)
fs.lstat(filepath, (err, stats) => {
if (err) {
process.nextTick(errback, err)
return
}
if (stats.isSymbolicLink()) {
return
}
else if (stats.isDirectory()) {
process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback)
}
else if (stats.isFile()) {
process.nextTick(fileCallback, filepath)
}
})
})
})
}

function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) {
original = new RegExp(RegExp.quote(original), 'g')
replacement = RegExp.quoteReplacement(replacement)
const updateFile = !DRY_RUN ? (filepath) => {
if (allowedExtensions.has(path.parse(filepath).ext)) {
sed('-i', original, replacement, filepath)
}
} : (filepath) => {
if (allowedExtensions.has(path.parse(filepath).ext)) {
console.log(`FILE: ${filepath}`)
}
else {
console.log(`EXCLUDED:${filepath}`)
}
if (VERBOSE) {
console.log(`FILE: ${file}`)
}
walkAsync(directory, excludedDirectories, updateFile, (err) => {
console.error('ERROR while traversing directory!:')
console.error(err)
process.exit(1)
})

if (DRY_RUN) {
return
}

await fs.writeFile(file, newString, 'utf8')
}

function main(args) {
if (args.length !== 2) {
console.error('USAGE: change-version old_version new_version')
async function main(args) {
const [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)
}
const oldVersion = args[0]
const newVersion = args[1]
const EXCLUDED_DIRS = new Set([
'.git',
'node_modules',
'vendor'
])
const INCLUDED_EXTENSIONS = new Set([
// This extension whitelist is how we avoid modifying binary files
'',
'.css',
'.html',
'.js',
'.json',
'.md',
'.scss',
'.txt',
'.yml'
])
replaceRecursively('.', EXCLUDED_DIRS, INCLUDED_EXTENSIONS, oldVersion, newVersion)

// Strip any leading `v` from arguments because otherwise we will end up with duplicate `v`s
[oldVersion, newVersion].map(arg => arg.startsWith('v') ? arg.slice(1) : arg)

try {
const files = await globby(GLOB, GLOBBY_OPTIONS, EXCLUDED_FILES)

await Promise.all(files.map(file => replaceRecursively(file, oldVersion, newVersion)))
} catch (error) {
console.error(error)
process.exit(1)
}
}

main(process.argv.slice(2))
Binary file not shown.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coreui/coreui-free-bootstrap-admin-template",
"version": "4.0.0-alpha.2",
"version": "4.0.0-beta.0",
"description": "Free Bootstrap Admin Template",
"keywords": [
"admin",
Expand Down
2 changes: 1 addition & 1 deletion src/js/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/**
* --------------------------------------------------------------------------
* CoreUI Boostrap Admin Template (v4.0.0-alpha.2): main.js
* CoreUI Boostrap Admin Template (v4.0.0-beta.0): main.js
* Licensed under MIT (https://coreui.io/license)
* --------------------------------------------------------------------------
*/
Expand Down
2 changes: 1 addition & 1 deletion src/js/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* --------------------------------------------------------------------------
* CoreUI Boostrap Admin Template (v4.0.0-alpha.2): colors.js
* CoreUI Boostrap Admin Template (v4.0.0-beta.0): colors.js
* Licensed under MIT (https://coreui.io/license)
* --------------------------------------------------------------------------
*/
Expand Down
2 changes: 1 addition & 1 deletion src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/**
* --------------------------------------------------------------------------
* CoreUI Boostrap Admin Template (v4.0.0-alpha.2): main.js
* CoreUI Boostrap Admin Template (v4.0.0-beta.0): main.js
* Licensed under MIT (https://coreui.io/license)
* --------------------------------------------------------------------------
*/
Expand Down
2 changes: 1 addition & 1 deletion src/js/popovers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* --------------------------------------------------------------------------
* CoreUI Free Boostrap Admin Template (v4.0.0-alpha.2): popovers.js
* CoreUI Free Boostrap Admin Template (v4.0.0-beta.0): popovers.js
* Licensed under MIT (https://coreui.io/license)
* --------------------------------------------------------------------------
*/
Expand Down
2 changes: 1 addition & 1 deletion src/js/toasts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* --------------------------------------------------------------------------
* CoreUI Free Boostrap Admin Template (v4.0.0-alpha.2): popovers.js
* CoreUI Free Boostrap Admin Template (v4.0.0-beta.0): popovers.js
* Licensed under MIT (https://coreui.io/license)
* --------------------------------------------------------------------------
*/
Expand Down
2 changes: 1 addition & 1 deletion src/js/tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* --------------------------------------------------------------------------
* CoreUI Free Boostrap Admin Template (v4.0.0-alpha.2): tooltips.js
* CoreUI Free Boostrap Admin Template (v4.0.0-beta.0): tooltips.js
* Licensed under MIT (https://coreui.io/license)
* --------------------------------------------------------------------------
*/
Expand Down
2 changes: 1 addition & 1 deletion src/js/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* --------------------------------------------------------------------------
* CoreUI Boostrap Admin Template (v4.0.0-alpha.2): main.js
* CoreUI Boostrap Admin Template (v4.0.0-beta.0): main.js
* Licensed under MIT (https://coreui.io/license)
* --------------------------------------------------------------------------
*/
Expand Down
42 changes: 42 additions & 0 deletions src/pug/views/docs/contents.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
extends ../../_layout/default.pug

block view
.card
.card-header
strong Contents
span.small.ms-1 What’s included
.card-body
p Within the download you’ll find the following directories and files, logically grouping common assets and providing both compiled and minified variations. You’ll see something like this:
pre.hljs
code
| free-bootstrap-admin-template/
| ├── build/
| ├── src/
| │ ├── assets/
| │ │ ├── brand/
| │ │ ├── favicon/
| │ │ ├── icons/
| │ │ ├── img/
| │ ├── js/
| │ ├── pug/
| │ │ ├── _layout/
| │ │ ├── _partial/
| │ │ ├── base/
| │ │ ├── buttons/
| │ │ ├── icons/
| │ │ ├── notifications/
| │ │ ├── ...
| │ │ ├── index.pug
| │ │ └── ...
| │ ├── scss/
| │ ├── vendors/
| │ └── views/
| │ ├── base/
| │ ├── buttons/
| │ ├── css/
| │ ├── icons/
| │ ├── notifications/
| │ ├── ...
| │ ├── index.html
| │ └── ...
| └── package.json
29 changes: 29 additions & 0 deletions src/pug/views/docs/installation.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
extends ../../_layout/default.pug

block view
.card
.card-header
strong Installation
.card-body
h2 Installation
h3 Clone repo
pre.hljs.language-bash
code
| # clone the repo
| $ git clone https://github.com/coreui/coreui-free-bootstrap-admin-template.git my-project
|
| # go into app's directory
| $ cd my-project
|
| # install app's dependencies
| $ npm install

h2 Usage
pre.hljs.language-bash
code
| # serve with hot reload at localhost:3000.
| $ npm run serve
|
| # build for production with minification
| $ npm run build

Loading

0 comments on commit 66d199c

Please sign in to comment.