initial commit
This commit is contained in:
19
assets/bootstrap-4.5.2/build/.eslintrc.json
Normal file
19
assets/bootstrap-4.5.2/build/.eslintrc.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": false,
|
||||
"node": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"sourceType": "script"
|
||||
},
|
||||
"extends": "../.eslintrc.json",
|
||||
"rules": {
|
||||
"consistent-return": "off",
|
||||
"func-style": "off",
|
||||
"no-console": "off",
|
||||
"no-magic-numbers": "off",
|
||||
"no-process-exit": "off",
|
||||
"no-sync": "off",
|
||||
"spaced-comment": "off"
|
||||
}
|
||||
}
|
14
assets/bootstrap-4.5.2/build/banner.js
vendored
Normal file
14
assets/bootstrap-4.5.2/build/banner.js
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
'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
|
92
assets/bootstrap-4.5.2/build/build-plugins.js
vendored
Normal file
92
assets/bootstrap-4.5.2/build/build-plugins.js
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*!
|
||||
* Script to build our plugins to use them separately.
|
||||
* Copyright 2020 The Bootstrap Authors
|
||||
* Copyright 2020 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const rollup = require('rollup')
|
||||
const { babel } = require('@rollup/plugin-babel')
|
||||
const banner = require('./banner.js')
|
||||
|
||||
const TEST = process.env.NODE_ENV === 'test'
|
||||
const plugins = [
|
||||
babel({
|
||||
// Only transpile our source code
|
||||
exclude: 'node_modules/**',
|
||||
// Inline the required helpers in each file
|
||||
babelHelpers: 'inline'
|
||||
})
|
||||
]
|
||||
const bsPlugins = {
|
||||
Alert: path.resolve(__dirname, '../js/src/alert.js'),
|
||||
Button: path.resolve(__dirname, '../js/src/button.js'),
|
||||
Carousel: path.resolve(__dirname, '../js/src/carousel.js'),
|
||||
Collapse: path.resolve(__dirname, '../js/src/collapse.js'),
|
||||
Dropdown: path.resolve(__dirname, '../js/src/dropdown.js'),
|
||||
Modal: path.resolve(__dirname, '../js/src/modal.js'),
|
||||
Popover: path.resolve(__dirname, '../js/src/popover.js'),
|
||||
ScrollSpy: path.resolve(__dirname, '../js/src/scrollspy.js'),
|
||||
Tab: path.resolve(__dirname, '../js/src/tab.js'),
|
||||
Toast: path.resolve(__dirname, '../js/src/toast.js'),
|
||||
Tooltip: path.resolve(__dirname, '../js/src/tooltip.js'),
|
||||
Util: path.resolve(__dirname, '../js/src/util.js')
|
||||
}
|
||||
const rootPath = TEST ? '../js/coverage/dist/' : '../js/dist/'
|
||||
|
||||
const build = async (plugin) => {
|
||||
console.log(`Building ${plugin} plugin...`)
|
||||
|
||||
const external = ['jquery', 'popper.js']
|
||||
const globals = {
|
||||
jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode
|
||||
'popper.js': 'Popper'
|
||||
}
|
||||
|
||||
// Do not bundle Util in plugins
|
||||
if (plugin !== 'Util') {
|
||||
external.push(bsPlugins.Util)
|
||||
globals[bsPlugins.Util] = 'Util'
|
||||
}
|
||||
|
||||
// Do not bundle Tooltip in Popover
|
||||
if (plugin === 'Popover') {
|
||||
external.push(bsPlugins.Tooltip)
|
||||
globals[bsPlugins.Tooltip] = 'Tooltip'
|
||||
}
|
||||
|
||||
const pluginFilename = `${plugin.toLowerCase()}.js`
|
||||
const bundle = await rollup.rollup({
|
||||
input: bsPlugins[plugin],
|
||||
plugins,
|
||||
external
|
||||
})
|
||||
|
||||
await bundle.write({
|
||||
banner: banner(pluginFilename),
|
||||
format: 'umd',
|
||||
name: plugin,
|
||||
sourcemap: true,
|
||||
globals,
|
||||
file: path.resolve(__dirname, `${rootPath}${pluginFilename}`)
|
||||
})
|
||||
|
||||
console.log(`Building ${plugin} plugin... Done!`)
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
try {
|
||||
await Promise.all(Object.keys(bsPlugins).map((plugin) => build(plugin)))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
105
assets/bootstrap-4.5.2/build/change-version.js
vendored
Normal file
105
assets/bootstrap-4.5.2/build/change-version.js
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*!
|
||||
* Script to update version number references in the project.
|
||||
* Copyright 2017-2020 The Bootstrap Authors
|
||||
* Copyright 2017-2020 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const sh = require('shelljs')
|
||||
|
||||
sh.config.fatal = 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, '$$')
|
||||
}
|
||||
|
||||
const DRY_RUN = false
|
||||
|
||||
function walkAsync(directory, excludedDirectories, fileCallback, errback) {
|
||||
if (excludedDirectories.has(path.parse(directory).base)) {
|
||||
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.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(regExpQuote(original), 'g')
|
||||
replacement = regExpQuoteReplacement(replacement)
|
||||
const updateFile = DRY_RUN ? (filepath) => {
|
||||
if (allowedExtensions.has(path.parse(filepath).ext)) {
|
||||
console.log(`FILE: ${filepath}`)
|
||||
} else {
|
||||
console.log(`EXCLUDED:${filepath}`)
|
||||
}
|
||||
} : (filepath) => {
|
||||
if (allowedExtensions.has(path.parse(filepath).ext)) {
|
||||
sh.sed('-i', original, replacement, filepath)
|
||||
}
|
||||
}
|
||||
walkAsync(directory, excludedDirectories, updateFile, (err) => {
|
||||
console.error('ERROR while traversing directory!:')
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
function main(args) {
|
||||
if (args.length !== 2) {
|
||||
console.error('USAGE: change-version old_version new_version')
|
||||
console.error('Got arguments:', args)
|
||||
process.exit(1)
|
||||
}
|
||||
const oldVersion = args[0]
|
||||
const newVersion = args[1]
|
||||
const EXCLUDED_DIRS = new Set([
|
||||
'.git',
|
||||
'_gh_pages',
|
||||
'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)
|
||||
}
|
||||
|
||||
main(process.argv.slice(2))
|
66
assets/bootstrap-4.5.2/build/generate-sri.js
vendored
Normal file
66
assets/bootstrap-4.5.2/build/generate-sri.js
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
#!/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-2020 The Bootstrap Authors
|
||||
* Copyright 2017-2020 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const crypto = require('crypto')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const sh = require('shelljs')
|
||||
|
||||
const pkg = require('../package.json')
|
||||
|
||||
sh.config.fatal = true
|
||||
|
||||
const configFile = path.join(__dirname, '../_config.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
|
||||
const files = [
|
||||
{
|
||||
file: 'dist/css/bootstrap.min.css',
|
||||
configPropertyName: 'css_hash'
|
||||
},
|
||||
{
|
||||
file: 'dist/js/bootstrap.min.js',
|
||||
configPropertyName: 'js_hash'
|
||||
},
|
||||
{
|
||||
file: 'dist/js/bootstrap.bundle.min.js',
|
||||
configPropertyName: 'js_bundle_hash'
|
||||
},
|
||||
{
|
||||
file: `site/docs/${pkg.version_short}/assets/js/vendor/jquery.slim.min.js`,
|
||||
configPropertyName: 'jquery_hash'
|
||||
},
|
||||
{
|
||||
file: 'node_modules/popper.js/dist/umd/popper.min.js',
|
||||
configPropertyName: 'popper_hash'
|
||||
}
|
||||
]
|
||||
|
||||
files.forEach((file) => {
|
||||
fs.readFile(file.file, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
|
||||
const algo = 'sha384'
|
||||
const hash = crypto.createHash(algo).update(data, 'utf8').digest('base64')
|
||||
const integrity = `${algo}-${hash}`
|
||||
|
||||
console.log(`${file.configPropertyName}: ${integrity}`)
|
||||
|
||||
sh.sed('-i', new RegExp(`(\\s${file.configPropertyName}:\\s+"|')(\\S+)("|')`), `$1${integrity}$3`, configFile)
|
||||
})
|
||||
})
|
14
assets/bootstrap-4.5.2/build/postcss.config.js
vendored
Normal file
14
assets/bootstrap-4.5.2/build/postcss.config.js
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = (ctx) => ({
|
||||
map: ctx.file.dirname.includes('examples') ? false : {
|
||||
inline: false,
|
||||
annotation: true,
|
||||
sourcesContent: true
|
||||
},
|
||||
plugins: {
|
||||
autoprefixer: {
|
||||
cascade: false
|
||||
}
|
||||
}
|
||||
})
|
44
assets/bootstrap-4.5.2/build/rollup.config.js
vendored
Normal file
44
assets/bootstrap-4.5.2/build/rollup.config.js
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const { babel } = require('@rollup/plugin-babel')
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
||||
const banner = require('./banner.js')
|
||||
|
||||
const BUNDLE = process.env.BUNDLE === 'true'
|
||||
|
||||
let fileDest = 'bootstrap.js'
|
||||
const external = ['jquery', 'popper.js']
|
||||
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 = {
|
||||
jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode
|
||||
'popper.js': 'Popper'
|
||||
}
|
||||
|
||||
if (BUNDLE) {
|
||||
fileDest = 'bootstrap.bundle.js'
|
||||
// Remove last entry in external array to bundle Popper
|
||||
external.pop()
|
||||
delete globals['popper.js']
|
||||
plugins.push(nodeResolve())
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
input: path.resolve(__dirname, '../js/src/index.js'),
|
||||
output: {
|
||||
banner,
|
||||
file: path.resolve(__dirname, `../dist/js/${fileDest}`),
|
||||
format: 'umd',
|
||||
globals,
|
||||
name: 'bootstrap'
|
||||
},
|
||||
external,
|
||||
plugins
|
||||
}
|
55
assets/bootstrap-4.5.2/build/ship.sh
Normal file
55
assets/bootstrap-4.5.2/build/ship.sh
Normal file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
#
|
||||
# Usage
|
||||
# ---------------
|
||||
# 1. Clone second version of Bootstrap in sibling directory named `bs-docs`.
|
||||
# 2. Within `bs-docs` copy, switch to `gh-pages` branch.
|
||||
# 3. Pull latest, re-bundle, re-npm.
|
||||
# 4. Run script.
|
||||
|
||||
red=$'\e[1;31m'
|
||||
green=$'\e[1;32m'
|
||||
#blue=$'\e[1;34m'
|
||||
magenta=$'\e[1;35m'
|
||||
#cyan=$'\e[1;36m'
|
||||
end=$'\e[0m'
|
||||
|
||||
# Get current version from package.json
|
||||
current_version=$(node -p "require('./package.json').version")
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
printf "\n%s⚠️ Shipping aborted. You must specify a version.\n%s" "$red" "$end"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Pulling latest changes, just to be sure
|
||||
printf "\n%s=======================================================%s" "$magenta" "$end"
|
||||
printf "\n%sPulling latest changes...%s" "$magenta" "$end"
|
||||
printf "\n%s=======================================================\n\n%s" "$magenta" "$end"
|
||||
git pull origin v4-dev
|
||||
|
||||
# Update version number
|
||||
printf "\n%s=======================================================%s" "$magenta" "$end"
|
||||
printf "\n%sUpdating version number...%s" "$magenta" "$end"
|
||||
printf "\n%s=======================================================\n%s" "$magenta" "$end"
|
||||
npm run release-version "$current_version" "$1"
|
||||
|
||||
# Build release
|
||||
printf "\n%s=======================================================%s" "$magenta" "$end"
|
||||
printf "\n%sBuilding release...%s" "$magenta" "$end"
|
||||
printf "\n%s=======================================================\n%s" "$magenta" "$end"
|
||||
npm run release
|
||||
|
||||
# Copy the contents of the built docs site over to `bs-docs` repo
|
||||
printf "\n%s=======================================================%s" "$magenta" "$end"
|
||||
printf "\n%sCopy it over...%s" "$magenta" "$end"
|
||||
printf "\n%s=======================================================\n%s" "$magenta" "$end"
|
||||
cp -rf _gh_pages/. ../bs-docs/
|
||||
printf "\nDone!\n"
|
||||
|
||||
printf "\n%s=======================================================%s" "$green" "$end"
|
||||
printf "\n%sSuccess, $1 is ready to review and publish.%s" "$green" "$end"
|
||||
printf "\n%s=======================================================\n\n%s" "$green" "$end"
|
60
assets/bootstrap-4.5.2/build/svgo.yml
Normal file
60
assets/bootstrap-4.5.2/build/svgo.yml
Normal file
@ -0,0 +1,60 @@
|
||||
# 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:
|
||||
# remove this with IE 11 is no longer supported
|
||||
- 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
|
65
assets/bootstrap-4.5.2/build/vnu-jar.js
vendored
Normal file
65
assets/bootstrap-4.5.2/build/vnu-jar.js
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*!
|
||||
* Script to run vnu-jar if Java is available.
|
||||
* Copyright 2017-2020 The Bootstrap Authors
|
||||
* Copyright 2017-2020 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const childProcess = require('child_process')
|
||||
const vnu = require('vnu-jar')
|
||||
|
||||
childProcess.exec('java -version', (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error('Skipping vnu-jar test; Java is missing.')
|
||||
return
|
||||
}
|
||||
|
||||
const is32bitJava = !/64-Bit/.test(stderr)
|
||||
|
||||
// vnu-jar accepts multiple ignores joined with a `|`.
|
||||
// Also note that the ignores are regular expressions.
|
||||
const ignores = [
|
||||
// "autocomplete" is included in <button> and checkboxes and radio <input>s due to
|
||||
// Firefox's non-standard autocomplete behavior - see https://bugzilla.mozilla.org/show_bug.cgi?id=654072
|
||||
'Attribute “autocomplete” is only allowed when the input type is.*',
|
||||
'Attribute “autocomplete” not allowed on element “button” at this point.',
|
||||
// Markup used in Components → Forms → Layout → Form grid → Horizontal form is currently invalid,
|
||||
// but used this way due to lack of support for flexbox layout on <fieldset> element in most browsers
|
||||
'Element “legend” not allowed as child of element “div” in this context.*',
|
||||
// Content → Reboot uses various date/time inputs as a visual example.
|
||||
// Documentation does not rely on them being usable.
|
||||
'The “date” input type is not supported in all browsers.*',
|
||||
'The “time” input type is not supported in all browsers.*',
|
||||
// IE11 doesn't recognise <main> / give the element an implicit "main" landmark.
|
||||
// Explicit role="main" is redundant for other modern browsers, but still valid.
|
||||
'The “main” role is unnecessary for element “main”.'
|
||||
].join('|')
|
||||
|
||||
const args = [
|
||||
'-jar',
|
||||
vnu,
|
||||
'--asciiquotes',
|
||||
'--skip-non-html',
|
||||
// Ignore the language code warnings
|
||||
'--no-langdetect',
|
||||
'--Werror',
|
||||
`--filterpattern "${ignores}"`,
|
||||
'_gh_pages/',
|
||||
'js/tests/'
|
||||
]
|
||||
|
||||
// For the 32-bit Java we need to pass `-Xss512k`
|
||||
if (is32bitJava) {
|
||||
args.splice(0, 0, '-Xss512k')
|
||||
}
|
||||
|
||||
return childProcess.spawn('java', args, {
|
||||
shell: true,
|
||||
stdio: 'inherit'
|
||||
})
|
||||
.on('exit', process.exit)
|
||||
})
|
63
assets/bootstrap-4.5.2/build/zip-examples.js
vendored
Normal file
63
assets/bootstrap-4.5.2/build/zip-examples.js
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*!
|
||||
* Script to create the built examples zip archive;
|
||||
* requires the `zip` command to be present!
|
||||
* Copyright 2020 The Bootstrap Authors
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const sh = require('shelljs')
|
||||
|
||||
const {
|
||||
version, version_short: versionShort
|
||||
} = require('../package.json')
|
||||
|
||||
const folderName = `bootstrap-${version}-examples`
|
||||
|
||||
sh.config.fatal = true
|
||||
|
||||
if (!sh.test('-d', '_gh_pages')) {
|
||||
throw new Error('The "_gh_pages" folder does not exist, did you forget building the docs?')
|
||||
}
|
||||
|
||||
// switch to the root dir
|
||||
sh.cd(path.join(__dirname, '..'))
|
||||
|
||||
// remove any previously created folder with the same name
|
||||
sh.rm('-rf', folderName)
|
||||
// create any folders so that `cp` works
|
||||
sh.mkdir('-p', folderName)
|
||||
sh.mkdir('-p', `${folderName}/assets/brand/`)
|
||||
|
||||
sh.cp('-Rf', `_gh_pages/docs/${versionShort}/examples/*`, folderName)
|
||||
sh.cp('-Rf', `_gh_pages/docs/${versionShort}/dist/`, `${folderName}/assets/`)
|
||||
// also copy the two brand images we use in the examples
|
||||
sh.cp('-f', [
|
||||
`_gh_pages/docs/${versionShort}/assets/brand/bootstrap-outline.svg`,
|
||||
`_gh_pages/docs/${versionShort}/assets/brand/bootstrap-solid.svg`
|
||||
], `${folderName}/assets/brand/`)
|
||||
sh.rm(`${folderName}/index.html`)
|
||||
|
||||
// get all examples' HTML files
|
||||
sh.find(`${folderName}/**/*.html`).forEach((file) => {
|
||||
const fileContents = sh.cat(file)
|
||||
.toString()
|
||||
.replace(new RegExp(`"/docs/${versionShort}/`, 'g'), '"../')
|
||||
.replace(/"..\/dist\//g, '"../assets/dist/')
|
||||
.replace(/(<link href="\.\.\/.*) integrity=".*>/g, '$1>')
|
||||
.replace(/(<script src="\.\.\/.*) integrity=".*>/g, '$1></script>')
|
||||
.replace(/( +)<!-- favicons(.|\n)+<style>/i, ' <style>')
|
||||
new sh.ShellString(fileContents).to(file)
|
||||
})
|
||||
|
||||
// create the zip file
|
||||
sh.exec(`zip -r9 "${folderName}.zip" "${folderName}"`, {
|
||||
fatal: true
|
||||
})
|
||||
|
||||
// remove the folder we created
|
||||
sh.rm('-rf', folderName)
|
Reference in New Issue
Block a user