mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-17 19:06:40 +02:00
Build system overhaul.
This commit is contained in:
110
build/change-version.js
Executable file
110
build/change-version.js
Executable file
@@ -0,0 +1,110 @@
|
||||
#!/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)
|
||||
*/
|
||||
|
||||
/* global Set */
|
||||
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var sh = require('shelljs')
|
||||
sh.config.fatal = true
|
||||
var sed = sh.sed
|
||||
|
||||
// Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37
|
||||
RegExp.quote = function (string) {
|
||||
return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&')
|
||||
}
|
||||
RegExp.quoteReplacement = function (string) {
|
||||
return string.replace(/[$]/g, '$$')
|
||||
}
|
||||
|
||||
var DRY_RUN = false
|
||||
|
||||
function walkAsync(directory, excludedDirectories, fileCallback, errback) {
|
||||
if (excludedDirectories.has(path.parse(directory).base)) {
|
||||
return
|
||||
}
|
||||
fs.readdir(directory, function (err, names) {
|
||||
if (err) {
|
||||
errback(err)
|
||||
return
|
||||
}
|
||||
names.forEach(function (name) {
|
||||
var filepath = path.join(directory, name)
|
||||
fs.lstat(filepath, function (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)
|
||||
var updateFile = !DRY_RUN ? function (filepath) {
|
||||
if (allowedExtensions.has(path.parse(filepath).ext)) {
|
||||
sed('-i', original, replacement, filepath)
|
||||
}
|
||||
} : function (filepath) {
|
||||
if (allowedExtensions.has(path.parse(filepath).ext)) {
|
||||
console.log('FILE: ' + filepath)
|
||||
}
|
||||
else {
|
||||
console.log('EXCLUDED:' + filepath)
|
||||
}
|
||||
}
|
||||
walkAsync(directory, excludedDirectories, updateFile, function (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)
|
||||
}
|
||||
var oldVersion = args[0]
|
||||
var newVersion = args[1]
|
||||
var EXCLUDED_DIRS = new Set([
|
||||
'.git',
|
||||
'node_modules',
|
||||
'vendor'
|
||||
])
|
||||
var 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))
|
BIN
build/gcp-key.json.enc
Normal file
BIN
build/gcp-key.json.enc
Normal file
Binary file not shown.
4116
build/npm-shrinkwrap.json
generated
Normal file
4116
build/npm-shrinkwrap.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
41
build/postcss.config.js
Normal file
41
build/postcss.config.js
Normal file
@@ -0,0 +1,41 @@
|
||||
module.exports = (ctx) => ({
|
||||
map: ctx.file.dirname.startsWith('docs') ? false : {
|
||||
inline: false,
|
||||
annotation: true,
|
||||
sourcesContent: true
|
||||
},
|
||||
plugins: {
|
||||
autoprefixer: {
|
||||
browsers: [
|
||||
//
|
||||
// Official browser support policy:
|
||||
// https://v4-alpha.getbootstrap.com/getting-started/browsers-devices/#supported-browsers
|
||||
//
|
||||
'Chrome >= 35', // Exact version number here is kinda arbitrary
|
||||
// Rather than using Autoprefixer's native "Firefox ESR" version specifier string,
|
||||
// we deliberately hardcode the number. This is to avoid unwittingly severely breaking the previous ESR in the event that:
|
||||
// (a) we happen to ship a new Bootstrap release soon after the release of a new ESR,
|
||||
// such that folks haven't yet had a reasonable amount of time to upgrade; and
|
||||
// (b) the new ESR has unprefixed CSS properties/values whose absence would severely break webpages
|
||||
// (e.g. `box-sizing`, as opposed to `background: linear-gradient(...)`).
|
||||
// Since they've been unprefixed, Autoprefixer will stop prefixing them,
|
||||
// thus causing them to not work in the previous ESR (where the prefixes were required).
|
||||
'Firefox >= 38', // Current Firefox Extended Support Release (ESR); https://www.mozilla.org/en-US/firefox/organizations/faq/
|
||||
// Note: Edge versions in Autoprefixer & Can I Use refer to the EdgeHTML rendering engine version,
|
||||
// NOT the Edge app version shown in Edge's "About" screen.
|
||||
// For example, at the time of writing, Edge 20 on an up-to-date system uses EdgeHTML 12.
|
||||
// See also https://github.com/Fyrd/caniuse/issues/1928
|
||||
'Edge >= 12',
|
||||
'Explorer >= 10',
|
||||
// Out of leniency, we prefix these 1 version further back than the official policy.
|
||||
'iOS >= 8',
|
||||
'Safari >= 8',
|
||||
// The following remain NOT officially supported, but we're lenient and include their prefixes to avoid severely breaking in them.
|
||||
'Android 2.3',
|
||||
'Android >= 4',
|
||||
'Opera >= 12'
|
||||
]
|
||||
},
|
||||
'postcss-flexbugs-fixes': {}
|
||||
}
|
||||
})
|
79
build/sauce_browsers.yml
Normal file
79
build/sauce_browsers.yml
Normal file
@@ -0,0 +1,79 @@
|
||||
[
|
||||
# Docs: https://wiki.saucelabs.com/display/DOCS/Platform+Configurator
|
||||
|
||||
{
|
||||
browserName: "safari",
|
||||
platform: "OS X 10.11"
|
||||
},
|
||||
{
|
||||
browserName: "chrome",
|
||||
platform: "OS X 10.11",
|
||||
version: "latest"
|
||||
},
|
||||
{
|
||||
browserName: "firefox",
|
||||
platform: "OS X 10.11",
|
||||
version: "latest"
|
||||
},
|
||||
|
||||
# Mac Opera not currently supported by Sauce Labs
|
||||
|
||||
{
|
||||
browserName: "MicrosoftEdge",
|
||||
platform: "Windows 10",
|
||||
version: "latest"
|
||||
},
|
||||
{
|
||||
browserName: "internet explorer",
|
||||
version: "11",
|
||||
platform: "Windows 8.1"
|
||||
},
|
||||
{
|
||||
browserName: "internet explorer",
|
||||
version: "10",
|
||||
platform: "Windows 8"
|
||||
},
|
||||
|
||||
{
|
||||
browserName: "chrome",
|
||||
platform: "Windows 10",
|
||||
version: "latest"
|
||||
},
|
||||
{
|
||||
browserName: "firefox",
|
||||
platform: "Windows 10",
|
||||
version: "latest"
|
||||
},
|
||||
|
||||
# Win Opera 15+ not currently supported by Sauce Labs
|
||||
|
||||
{
|
||||
browserName: "iphone",
|
||||
deviceName: "iPhone Simulator",
|
||||
platformName: "OS X 10.11",
|
||||
version: "9.3"
|
||||
},
|
||||
|
||||
# iOS Chrome not currently supported by Sauce Labs
|
||||
|
||||
# Linux (unofficial)
|
||||
{
|
||||
browserName: "chrome",
|
||||
platform: "Linux",
|
||||
version: "latest"
|
||||
},
|
||||
{
|
||||
browserName: "firefox",
|
||||
platform: "Linux",
|
||||
version: "latest"
|
||||
},
|
||||
|
||||
# Android
|
||||
{
|
||||
platform: "Linux",
|
||||
browserName: "android",
|
||||
deviceName: "Android Emulator",
|
||||
version: "latest",
|
||||
deviceType: "phone"
|
||||
}
|
||||
]
|
40
build/stamp.js
Normal file
40
build/stamp.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const fs = require('fs')
|
||||
|
||||
fs.readFile('package.json', (err, data) => {
|
||||
if (err) throw err
|
||||
|
||||
const pkg = JSON.parse(data)
|
||||
const year = new Date().getFullYear()
|
||||
|
||||
const stampTop =
|
||||
`/*!
|
||||
* Bootstrap v${pkg.version} (${pkg.homepage})
|
||||
* Copyright 2011-${year} ${pkg.author}
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
*/
|
||||
|
||||
if (typeof jQuery === 'undefined') {
|
||||
throw new Error('Bootstrap\\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\\'s JavaScript.')
|
||||
}
|
||||
|
||||
(function ($) {
|
||||
var version = $.fn.jquery.split(' ')[0].split('.')
|
||||
if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] >= 4)) {
|
||||
throw new Error('Bootstrap\\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0')
|
||||
}
|
||||
})(jQuery);
|
||||
|
||||
(function () {
|
||||
`
|
||||
const stampEnd = `
|
||||
})()`
|
||||
|
||||
process.stdout.write(stampTop)
|
||||
|
||||
process.stdin.on('end', () => {
|
||||
process.stdout.write(stampEnd);
|
||||
});
|
||||
|
||||
process.stdin.pipe(process.stdout)
|
||||
})
|
||||
|
13
build/upload-preview.sh
Executable file
13
build/upload-preview.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
# Upload built docs to preview.twbsapps.com
|
||||
|
||||
# Add build metadata to version
|
||||
sed -i "/^current_version:/ s/\$/+pr.${TRAVIS_COMMIT}/" _config.yml
|
||||
bundle exec jekyll build --destination "$TRAVIS_COMMIT" --baseurl "/c/${TRAVIS_COMMIT}"
|
||||
|
||||
openssl aes-256-cbc -K $encrypted_2b749c8e6327_key -iv $encrypted_2b749c8e6327_iv -in build/gcp-key.json.enc -out build/gcp-key.json -d
|
||||
gcloud auth activate-service-account "$GCP_SERVICE_ACCOUNT" --key-file build/gcp-key.json &> /dev/null || (echo 'GCP login failed!'; exit 1)
|
||||
|
||||
echo "Uploading to http://preview.twbsapps.com/c/${TRAVIS_COMMIT} ..."
|
||||
time gsutil -q -m cp -z html,css,js,svg -r "./${TRAVIS_COMMIT}" gs://preview.twbsapps.com/c/
|
||||
echo 'Done.'
|
Reference in New Issue
Block a user