aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/build/zip-examples.js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-06-13 10:00:50 +0000
committerMario <mario@mariovavti.com>2020-06-13 10:00:50 +0000
commitdc3b09c8f38872ef8b792a4b551671a6105754cc (patch)
tree554f130cc2d5a00088cad6c9a75ae0a8f2d558f8 /vendor/twbs/bootstrap/build/zip-examples.js
parentc8c4513af98a9dd2a6d9331ba4b3ab3af0e95a5f (diff)
downloadvolse-hubzilla-dc3b09c8f38872ef8b792a4b551671a6105754cc.tar.gz
volse-hubzilla-dc3b09c8f38872ef8b792a4b551671a6105754cc.tar.bz2
volse-hubzilla-dc3b09c8f38872ef8b792a4b551671a6105754cc.zip
composer update bootstrap
Diffstat (limited to 'vendor/twbs/bootstrap/build/zip-examples.js')
-rw-r--r--vendor/twbs/bootstrap/build/zip-examples.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/vendor/twbs/bootstrap/build/zip-examples.js b/vendor/twbs/bootstrap/build/zip-examples.js
new file mode 100644
index 000000000..3f7fb9abb
--- /dev/null
+++ b/vendor/twbs/bootstrap/build/zip-examples.js
@@ -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/master/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)