Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -0,0 +1,5 @@
{
"rules": {
"strict": [2, "global"]
}
}

View file

@ -0,0 +1,54 @@
/**
* @file
*
* Compile *.es6.js files to ES5.
*
* @internal This file is part of the core javascript build process and is only
* meant to be used in that context.
*/
'use strict';
const fs = require('fs');
const path = require('path');
const babel = require('babel-core');
const glob = require('glob');
// Logging human-readable timestamp.
const log = function (message) {
// eslint-disable-next-line no-console
console.log(`[${new Date().toTimeString().slice(0, 8)}] ${message}`);
};
function addSourceMappingUrl(code, loc) {
return code + '\n\n//# sourceMappingURL=' + path.basename(loc);
}
const changedOrAdded = (filePath) => {
babel.transformFile(filePath, {
sourceMaps: true,
comments: false
}, function (err, result) {
const fileName = filePath.slice(0, -7);
// we've requested for a sourcemap to be written to disk
let mapLoc = `${fileName}.js.map`;
fs.writeFile(mapLoc, JSON.stringify(result.map));
fs.writeFile(`${fileName}.js`, addSourceMappingUrl(result.code, mapLoc));
log(`'${filePath}' is being processed.`);
});
};
const fileMatch = './**/*.es6.js';
const globOptions = {
ignore: 'node_modules/**'
};
const processFiles = (error, filePaths) => {
if (error) {
process.exitCode = 1;
}
filePaths.forEach(changedOrAdded);
};
glob(fileMatch, globOptions, processFiles);
process.exitCode = 0;

View file

@ -0,0 +1,67 @@
/**
* @file
*
* Watch changes to *.es6.js files and compile them to ES5 during development.
*
* @internal This file is part of the core javascript build process and is only
* meant to be used in that context.
*/
'use strict';
const fs = require('fs');
const path = require('path');
const babel = require('babel-core');
const chokidar = require('chokidar');
// Logging human-readable timestamp.
const log = function log(message) {
// eslint-disable-next-line no-console
console.log(`[${new Date().toTimeString().slice(0, 8)}] ${message}`);
};
function addSourceMappingUrl(code, loc) {
return `${code}\n\n//# sourceMappingURL=${path.basename(loc)}`;
}
const fileMatch = './**/*.es6.js';
const watcher = chokidar.watch(fileMatch, {
ignoreInitial: true,
ignored: 'node_modules/**'
});
const changedOrAdded = (filePath) => {
babel.transformFile(filePath, {
sourceMaps: true,
comments: false
}, (err, result) => {
const fileName = filePath.slice(0, -7);
// we've requested for a sourcemap to be written to disk
const mapLoc = `${fileName}.js.map`;
fs.writeFileSync(mapLoc, JSON.stringify(result.map));
fs.writeFileSync(`${fileName}.js`, addSourceMappingUrl(result.code, mapLoc));
log(`'${filePath}' has been changed.`);
});
};
const unlinkHandler = (err) => {
if (err) {
log(err);
}
};
watcher
.on('add', filePath => changedOrAdded(filePath))
.on('change', filePath => changedOrAdded(filePath))
.on('unlink', (filePath) => {
const fileName = filePath.slice(0, -7);
fs.stat(`${fileName}.js`, () => {
fs.unlink(`${fileName}.js`, unlinkHandler);
});
fs.stat(`${fileName}.js.map`, () => {
fs.unlink(`${fileName}.js.map`, unlinkHandler);
});
})
.on('ready', () => log(`Watching '${fileMatch}' for changes.`));

View file

@ -0,0 +1,12 @@
#!/bin/bash
# Rename *.js files in *.es6.js. Only need to be run once.
# Should be removed after *.es6.js files are committed to core.
#
# @internal This file is part of the core javascript build process and is only
# meant to be used in that context.
for js in `find ./{misc,modules,themes} -name '*.js'`;
do
mv ${js} ${js%???}.es6.js;
done