Skip to content

Commit

Permalink
Format tools directory (#27250)
Browse files Browse the repository at this point in the history
prepare for ESM migration
by reducing the git difference:

- default export on separate line
- multi-line task arrays
- explicit config paths
- chore: update hash of eslint plugin

Co-authored-by: Ravi <[email protected]>
  • Loading branch information
mxdvl and arelra authored Jun 24, 2024
1 parent 0dc52f3 commit e343cc0
Show file tree
Hide file tree
Showing 72 changed files with 1,755 additions and 1,601 deletions.
11 changes: 7 additions & 4 deletions tools/__tasks__/compile/conf/clean.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const path = require('path');
const rimraf = require('rimraf');

const { root } = require('../../config').paths;
const { paths } = require('../../config');

module.exports = {
description: 'Clear template rendering artefacts',
task: () => rimraf.sync(path.resolve(root, 'common', 'conf', 'assets')),
const task = {
description: 'Clear template rendering artefacts',
task: () =>
rimraf.sync(path.resolve(paths.root, 'common', 'conf', 'assets')),
};

module.exports = task;
56 changes: 29 additions & 27 deletions tools/__tasks__/compile/conf/copy.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
const path = require('path');
const cpy = require('cpy');

const { conf, target, hash, src } = require('../../config').paths;
const { paths } = require('../../config');

module.exports = {
description: 'Copy assets',
task: () =>
Promise.all([
cpy('curl.js', conf, {
cwd: path.resolve(
path.dirname(require.resolve('curl')),
'..',
'dist',
'curl-with-js-and-domReady'
),
}),
cpy(
['**/head*.css', 'inline/**/*.css'],
path.resolve(conf, 'inline-stylesheets'),
{
cwd: path.resolve(target, 'stylesheets'),
}
),
cpy(['**/assets.map'], path.resolve(conf), {
cwd: path.resolve(hash, 'assets'),
}),
cpy(['polyfill.io'], path.resolve(conf), {
cwd: path.resolve(src, 'javascripts'),
}),
]),
const task = {
description: 'Copy assets',
task: () =>
Promise.all([
cpy('curl.js', paths.conf, {
cwd: path.resolve(
path.dirname(require.resolve('curl')),
'..',
'dist',
'curl-with-js-and-domReady',
),
}),
cpy(
['**/head*.css', 'inline/**/*.css'],
path.resolve(paths.conf, 'inline-stylesheets'),
{
cwd: path.resolve(paths.target, 'stylesheets'),
},
),
cpy(['**/assets.map'], path.resolve(paths.conf), {
cwd: path.resolve(paths.hash, 'assets'),
}),
cpy(['polyfill.io'], path.resolve(paths.conf), {
cwd: path.resolve(paths.src, 'javascripts'),
}),
]),
};

module.exports = task;
12 changes: 9 additions & 3 deletions tools/__tasks__/compile/conf/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
module.exports = {
description: 'Compile assets for template rendering in Play',
task: [require('./copy'), require('../inline-svgs')],
const task = {
description: 'Compile assets for template rendering in Play',
task: [
// prettier: multi-line
require('./copy'),
require('../inline-svgs'),
],
};

module.exports = task;
16 changes: 9 additions & 7 deletions tools/__tasks__/compile/css/clean.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const path = require('path');
const rimraf = require('rimraf');

const { target, hash } = require('../../config').paths;
const { paths } = require('../../config');

module.exports = {
description: 'Clear CSS build artefacts',
task: () => {
rimraf.sync(path.resolve(target, 'stylesheets'));
rimraf.sync(path.resolve(hash, 'stylesheets'));
},
const task = {
description: 'Clear CSS build artefacts',
task: () => {
rimraf.sync(path.resolve(paths.target, 'stylesheets'));
rimraf.sync(path.resolve(paths.hash, 'stylesheets'));
},
};

module.exports = task;
19 changes: 11 additions & 8 deletions tools/__tasks__/compile/css/index.dev.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
module.exports = {
description: 'Compile CSS',
task: [
require('./clean'),
require('./mkdir'),
require('../images'),
require('./sass'),
],
const task = {
description: 'Compile CSS',
task: [
// prettier: multi-line
require('./clean'),
require('./mkdir'),
require('../images'),
require('./sass'),
],
};

module.exports = task;
19 changes: 11 additions & 8 deletions tools/__tasks__/compile/css/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
module.exports = {
description: 'Compile CSS',
task: [
require('./clean'),
require('./mkdir'),
require('../images'),
require('./sass'),
],
const task = {
description: 'Compile CSS',
task: [
// prettier: multi-line
require('./clean'),
require('./mkdir'),
require('../images'),
require('./sass'),
],
};

module.exports = task;
10 changes: 6 additions & 4 deletions tools/__tasks__/compile/css/mkdir.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const mkdirp = require('mkdirp');
const { target } = require('../../config').paths;
const { paths } = require('../../config');

module.exports = {
description: 'Create CSS target directory',
task: () => mkdirp.sync(`${target}/stylesheets`),
const task = {
description: 'Create CSS target directory',
task: () => mkdirp.sync(`${paths.target}/stylesheets`),
};

module.exports = task;
82 changes: 42 additions & 40 deletions tools/__tasks__/compile/css/sass.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
const compile = require('../../../compile-css');

module.exports = {
description: 'Compile Sass',
task: [
{
description: 'Old IE',
task: () =>
compile('old-ie.*.scss', {
browsers: 'Explorer 8',
remify: false,
}),
},
{
description: 'IE9',
task: () =>
compile('ie9.*.scss', {
browsers: 'Explorer 9',
}),
},
{
description: 'Email',
task: () =>
compile('head.email-{article,front}.scss', {
remify: false,
}),
},
{
description: 'Modern',
task: () =>
compile('!(_|ie9|old-ie|*email-article|*email-front)*.scss'),
},
{
description: 'Inline',
task: () => compile('inline/*.scss'),
},
{
description: 'Atoms',
task: () => compile('atoms/*.scss'),
},
],
concurrent: true,
const task = {
description: 'Compile Sass',
task: [
{
description: 'Old IE',
task: () =>
compile('old-ie.*.scss', {
browsers: 'Explorer 8',
remify: false,
}),
},
{
description: 'IE9',
task: () =>
compile('ie9.*.scss', {
browsers: 'Explorer 9',
}),
},
{
description: 'Email',
task: () =>
compile('head.email-{article,front}.scss', {
remify: false,
}),
},
{
description: 'Modern',
task: () =>
compile('!(_|ie9|old-ie|*email-article|*email-front)*.scss'),
},
{
description: 'Inline',
task: () => compile('inline/*.scss'),
},
{
description: 'Atoms',
task: () => compile('atoms/*.scss'),
},
],
concurrent: true,
};

module.exports = task;
22 changes: 12 additions & 10 deletions tools/__tasks__/compile/data/amp.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
const path = require('path');
const cpy = require('cpy');

const { vendor, target } = require('../../config').paths;
const { paths } = require('../../config');

// Source
const ampIframeHtml = path.join(vendor, 'data/amp-iframe.html');
const ampIframeHtml = path.join(paths.vendor, 'data/amp-iframe.html');

// Destinations
// The static assets
const staticDir = path.resolve(target, 'data', 'vendor');
const staticDir = path.resolve(paths.target, 'data', 'vendor');

module.exports = {
description: 'Copy AMP iframe HTML',
task: () =>
cpy(ampIframeHtml, staticDir, {
parents: false,
nodir: false,
}),
const task = {
description: 'Copy AMP iframe HTML',
task: () =>
cpy(ampIframeHtml, staticDir, {
parents: false,
nodir: false,
}),
};

module.exports = task;
16 changes: 9 additions & 7 deletions tools/__tasks__/compile/data/clean.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const path = require('path');
const rimraf = require('rimraf');

const { target, hash } = require('../../config').paths;
const { paths } = require('../../config');

module.exports = {
description: 'Clear Data build artefacts',
task: () => {
rimraf.sync(path.resolve(target, 'data'));
rimraf.sync(path.resolve(hash, 'data'));
},
const task = {
description: 'Clear Data build artefacts',
task: () => {
rimraf.sync(path.resolve(paths.target, 'data'));
rimraf.sync(path.resolve(paths.hash, 'data'));
},
};

module.exports = task;
Loading

0 comments on commit e343cc0

Please sign in to comment.