upgrades core to 8.4.2
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Compile *.es6.js files to ES5.
|
||||
* Provides the build:js command to compile *.es6.js files to ES5.
|
||||
*
|
||||
* Run build:js with --file to only parse a specific file. Using the --check
|
||||
* flag build:js can be run to check if files are compiled correctly.
|
||||
* @example <caption>Only process misc/drupal.es6.js and misc/drupal.init.es6.js</caption
|
||||
* yarn run build:js -- --file misc/drupal.es6.js --file misc/drupal.init.es6.js
|
||||
* @example <caption>Check if all files have been compiled correctly</caption
|
||||
* yarn run build:js -- --check
|
||||
*
|
||||
* @internal This file is part of the core javascript build process and is only
|
||||
* meant to be used in that context.
|
||||
@@ -9,46 +16,34 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const babel = require('babel-core');
|
||||
const glob = require('glob');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const changeOrAdded = require('./changeOrAdded');
|
||||
const check = require('./check');
|
||||
const log = require('./log');
|
||||
|
||||
// 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.`);
|
||||
});
|
||||
};
|
||||
|
||||
// Match only on .es6.js files.
|
||||
const fileMatch = './**/*.es6.js';
|
||||
// Ignore everything in node_modules
|
||||
const globOptions = {
|
||||
ignore: 'node_modules/**'
|
||||
ignore: './node_modules/**'
|
||||
};
|
||||
const processFiles = (error, filePaths) => {
|
||||
if (error) {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
filePaths.forEach(changedOrAdded);
|
||||
// Process all the found files.
|
||||
let callback = changeOrAdded;
|
||||
if (argv.check) {
|
||||
callback = check;
|
||||
}
|
||||
filePaths.forEach(callback);
|
||||
};
|
||||
glob(fileMatch, globOptions, processFiles);
|
||||
|
||||
if (argv.file) {
|
||||
processFiles(null, [].concat(argv.file));
|
||||
}
|
||||
else {
|
||||
glob(fileMatch, globOptions, processFiles);
|
||||
}
|
||||
process.exitCode = 0;
|
||||
|
||||
@@ -11,50 +11,29 @@
|
||||
|
||||
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 changeOrAdded = require('./changeOrAdded');
|
||||
const log = require('./log');
|
||||
|
||||
// Match only on .es6.js files.
|
||||
const fileMatch = './**/*.es6.js';
|
||||
// Ignore everything in node_modules
|
||||
const watcher = chokidar.watch(fileMatch, {
|
||||
ignoreInitial: true,
|
||||
ignored: 'node_modules/**'
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
// Watch for filesystem changes.
|
||||
watcher
|
||||
.on('add', filePath => changedOrAdded(filePath))
|
||||
.on('change', filePath => changedOrAdded(filePath))
|
||||
.on('add', changeOrAdded)
|
||||
.on('change', changeOrAdded)
|
||||
.on('unlink', (filePath) => {
|
||||
const fileName = filePath.slice(0, -7);
|
||||
fs.stat(`${fileName}.js`, () => {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
const fs = require('fs');
|
||||
const log = require('./log');
|
||||
const compile = require('./compile');
|
||||
|
||||
module.exports = (filePath) => {
|
||||
log(`'${filePath}' is being processed.`);
|
||||
// Transform the file.
|
||||
compile(filePath, function write(code) {
|
||||
const fileName = filePath.slice(0, -7);
|
||||
// Write the result to the filesystem.
|
||||
fs.writeFile(`${fileName}.js`, code, () => {
|
||||
log(`'${filePath}' is finished.`);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
const chalk = require('chalk');
|
||||
const fs = require('fs');
|
||||
const log = require('./log');
|
||||
const compile = require('./compile');
|
||||
|
||||
module.exports = (filePath) => {
|
||||
log(`'${filePath}' is being checked.`);
|
||||
// Transform the file.
|
||||
compile(filePath, function check(code) {
|
||||
const fileName = filePath.slice(0, -7);
|
||||
fs.readFile(`${fileName}.js`, function read(err, data) {
|
||||
if (err) {
|
||||
log(chalk.red(err));
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
if (code !== data.toString()) {
|
||||
log(chalk.red(`'${filePath}' is not updated.`));
|
||||
process.exitCode = 1;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
const chalk = require('chalk');
|
||||
const log = require('./log');
|
||||
const babel = require('babel-core');
|
||||
|
||||
module.exports = (filePath, callback) => {
|
||||
// Transform the file.
|
||||
// Check process.env.NODE_ENV to see if we should create sourcemaps.
|
||||
babel.transformFile(
|
||||
filePath,
|
||||
{
|
||||
sourceMaps: process.env.NODE_ENV === 'development' ? 'inline' : false,
|
||||
comments: false,
|
||||
plugins: [
|
||||
['add-header-comment', {
|
||||
'header': [
|
||||
`DO NOT EDIT THIS FILE.\nSee the following change record for more information,\nhttps://www.drupal.org/node/2815083\n@preserve`
|
||||
]
|
||||
}]
|
||||
]
|
||||
},
|
||||
(err, result) => {
|
||||
if (err) {
|
||||
log(chalk.red(err));
|
||||
process.exitCode = 1;
|
||||
}
|
||||
else {
|
||||
callback(result.code);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = (message) => {
|
||||
// Logging human-readable timestamp.
|
||||
console.log(`[${new Date().toTimeString().slice(0, 8)}] ${message}`);
|
||||
}
|
||||
@@ -15,11 +15,11 @@ if (PHP_SAPI !== 'cli') {
|
||||
return;
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../autoload.php';
|
||||
$autoloader = require __DIR__ . '/../../autoload.php';
|
||||
require_once __DIR__ . '/../includes/bootstrap.inc';
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
Settings::initialize(DrupalKernel::findSitePath($request));
|
||||
Settings::initialize(DRUPAL_ROOT, DrupalKernel::findSitePath($request), $autoloader);
|
||||
|
||||
$timestamp = time();
|
||||
$token = Crypt::hmacBase64($timestamp, Settings::get('hash_salt'));
|
||||
|
||||
@@ -17,6 +17,7 @@ use Drupal\Core\Test\TestRunnerKernel;
|
||||
use Drupal\simpletest\Form\SimpletestResultsForm;
|
||||
use Drupal\simpletest\TestBase;
|
||||
use Drupal\simpletest\TestDiscovery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
$autoloader = require_once __DIR__ . '/../../autoload.php';
|
||||
@@ -36,7 +37,7 @@ const SIMPLETEST_SCRIPT_EXIT_SUCCESS = 0;
|
||||
const SIMPLETEST_SCRIPT_EXIT_FAILURE = 1;
|
||||
const SIMPLETEST_SCRIPT_EXIT_EXCEPTION = 2;
|
||||
|
||||
if (!class_exists('\PHPUnit_Framework_TestCase')) {
|
||||
if (!class_exists(TestCase::class)) {
|
||||
echo "\nrun-tests.sh requires the PHPUnit testing framework. Please use 'composer install --dev' to ensure that it is present.\n\n";
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
@@ -783,7 +784,7 @@ function simpletest_script_run_one_test($test_id, $test_class) {
|
||||
$methods = array();
|
||||
}
|
||||
$test = new $class_name($test_id);
|
||||
if (is_subclass_of($test_class, '\PHPUnit_Framework_TestCase')) {
|
||||
if (is_subclass_of($test_class, TestCase::class)) {
|
||||
$status = simpletest_script_run_phpunit($test_id, $test_class);
|
||||
}
|
||||
else {
|
||||
@@ -865,7 +866,7 @@ function simpletest_script_command($test_id, $test_class) {
|
||||
* @see simpletest_script_run_one_test()
|
||||
*/
|
||||
function simpletest_script_cleanup($test_id, $test_class, $exitcode) {
|
||||
if (is_subclass_of($test_class, '\PHPUnit_Framework_TestCase')) {
|
||||
if (is_subclass_of($test_class, TestCase::class)) {
|
||||
// PHPUnit test, move on.
|
||||
return;
|
||||
}
|
||||
@@ -1020,7 +1021,7 @@ function simpletest_script_get_test_list() {
|
||||
else {
|
||||
foreach ($matches[1] as $class_name) {
|
||||
$namespace_class = $namespace . '\\' . $class_name;
|
||||
if (is_subclass_of($namespace_class, '\Drupal\simpletest\TestBase') || is_subclass_of($namespace_class, '\PHPUnit_Framework_TestCase')) {
|
||||
if (is_subclass_of($namespace_class, '\Drupal\simpletest\TestBase') || is_subclass_of($namespace_class, TestCase::class)) {
|
||||
$test_list[] = $namespace_class;
|
||||
}
|
||||
}
|
||||
@@ -1074,7 +1075,7 @@ function simpletest_script_get_test_list() {
|
||||
else {
|
||||
foreach ($matches[1] as $class_name) {
|
||||
$namespace_class = $namespace . '\\' . $class_name;
|
||||
if (is_subclass_of($namespace_class, '\Drupal\simpletest\TestBase') || is_subclass_of($namespace_class, '\PHPUnit_Framework_TestCase')) {
|
||||
if (is_subclass_of($namespace_class, '\Drupal\simpletest\TestBase') || is_subclass_of($namespace_class, TestCase::class)) {
|
||||
$test_list[] = $namespace_class;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user