12
const path = require('path')
13
const sh = require('shelljs')
15
const pkg = require('../package.json')
17
const versionShort = pkg.config.version_short
18
const distFolder = `bootstrap-${pkg.version}-examples`
19
const rootDocsDir = '_site'
20
const docsDir = `${rootDocsDir}/docs/${versionShort}/`
25
'bootstrap.min.css.map'
28
'bootstrap.bundle.min.js',
29
'bootstrap.bundle.min.js.map'
32
'bootstrap-outline.svg',
38
if (!sh.test('-d', rootDocsDir)) {
39
throw new Error(`The "${rootDocsDir}" folder does not exist, did you forget building the docs?`)
43
sh.cd(path.join(__dirname, '..'))
46
sh.rm('-rf', [distFolder, `${distFolder}.zip`])
51
`${distFolder}/assets/brand/`,
52
`${distFolder}/assets/dist/css/`,
53
`${distFolder}/assets/dist/js/`
56
sh.cp('-Rf', `${docsDir}/examples/*`, distFolder)
58
cssFiles.forEach(file => {
59
sh.cp('-f', `${docsDir}/dist/css/${file}`, `${distFolder}/assets/dist/css/`)
62
jsFiles.forEach(file => {
63
sh.cp('-f', `${docsDir}/dist/js/${file}`, `${distFolder}/assets/dist/js/`)
66
imgFiles.forEach(file => {
67
sh.cp('-f', `${docsDir}/assets/brand/${file}`, `${distFolder}/assets/brand/`)
70
sh.rm(`${distFolder}/index.html`)
73
sh.find(`${distFolder}/**/*.html`).forEach(file => {
74
const fileContents = sh.cat(file)
76
.replace(new RegExp(`"/docs/${versionShort}/`, 'g'), '"../')
77
.replace(/"..\/dist\//g, '"../assets/dist/')
78
.replace(/(<link href="\.\.\/.*) integrity=".*>/g, '$1>')
79
.replace(/(<script src="\.\.\/.*) integrity=".*>/g, '$1></script>')
80
.replace(/( +)<!-- favicons(.|\n)+<style>/i, ' <style>')
81
new sh.ShellString(fileContents).to(file)
85
sh.exec(`zip -r9 "${distFolder}.zip" "${distFolder}"`)
88
sh.rm('-rf', distFolder)