Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Listr directly for the task runner #27260

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tools/__tasks__/compile/conf/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const rimraf = require('rimraf');

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

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Clear template rendering artefacts',
title: 'Clear template rendering artefacts',
task: () =>
rimraf.sync(path.resolve(paths.root, 'common', 'conf', 'assets')),
};
Expand Down
3 changes: 2 additions & 1 deletion tools/__tasks__/compile/conf/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const cpy = require('cpy');

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

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Copy assets',
title: 'Copy assets',
task: () =>
Promise.all([
cpy('curl.js', paths.conf, {
Expand Down
17 changes: 11 additions & 6 deletions tools/__tasks__/compile/conf/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const copy = require('./copy.js');
const inlineSVGs = require('../inline-svgs/index.js');

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Compile assets for template rendering in Play',
task: [
// prettier: multi-line
copy,
inlineSVGs,
],
title: 'Compile assets for template rendering in Play',
task: (ctx, task) =>
task.newListr(
[
// prettier: multi-line
copy,
inlineSVGs,
],
{ concurrent: false },
),
};

module.exports = task;
3 changes: 2 additions & 1 deletion tools/__tasks__/compile/css/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const rimraf = require('rimraf');

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

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Clear CSS build artefacts',
title: 'Clear CSS build artefacts',
task: () => {
rimraf.sync(path.resolve(paths.target, 'stylesheets'));
rimraf.sync(path.resolve(paths.hash, 'stylesheets'));
Expand Down
21 changes: 13 additions & 8 deletions tools/__tasks__/compile/css/index.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ const mkdir = require('./mkdir.js');
const images = require('../images/index.js');
const sass = require('./sass.js');

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Compile CSS',
task: [
// prettier: multi-line
clean,
mkdir,
images,
sass,
],
title: 'Compile CSS (dev)',
task: (ctx, task) =>
task.newListr(
[
// prettier: multi-line
clean,
mkdir,
images,
sass,
],
{ concurrent: false },
),
};

module.exports = task;
21 changes: 13 additions & 8 deletions tools/__tasks__/compile/css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ const mkdir = require('./mkdir.js');
const images = require('../images/index.js');
const sass = require('./sass.js');

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Compile CSS',
task: [
// prettier: multi-line
clean,
mkdir,
images,
sass,
],
title: 'Compile CSS',
task: (ctx, task) =>
task.newListr(
[
// prettier: multi-line
clean,
mkdir,
images,
sass,
],
{ concurrent: false },
),
};

module.exports = task;
3 changes: 2 additions & 1 deletion tools/__tasks__/compile/css/mkdir.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const mkdirp = require('mkdirp');
const { paths } = require('../../config');

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Create CSS target directory',
title: 'Create CSS target directory',
task: () => mkdirp.sync(`${paths.target}/stylesheets`),
};

Expand Down
84 changes: 45 additions & 39 deletions tools/__tasks__/compile/css/sass.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,51 @@
const compile = require('../../../compile-css');

/** @type {import('listr2').ListrTask} */
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,
title: 'Compile Sass',
task: (ctx, task) =>
task.newListr(
[
{
title: 'Old IE',
task: () =>
compile('old-ie.*.scss', {
browsers: 'Explorer 8',
remify: false,
}),
},
{
title: 'IE9',
task: () =>
compile('ie9.*.scss', {
browsers: 'Explorer 9',
}),
},
{
title: 'Email',
task: () =>
compile('head.email-{article,front}.scss', {
remify: false,
}),
},
{
title: 'Modern',
task: () =>
compile(
'!(_|ie9|old-ie|*email-article|*email-front)*.scss',
),
},
{
title: 'Inline',
task: () => compile('inline/*.scss'),
},
{
title: 'Atoms',
task: () => compile('atoms/*.scss'),
},
],
{ concurrent: !!ctx.verbose ? false : true },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the reason to switch concurrency here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, when concurrent was true, listrify would read this value and convert it to true or false based on a series of check. This makes it more explicit at the point of creation.

),
};

module.exports = task;
3 changes: 2 additions & 1 deletion tools/__tasks__/compile/data/amp.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ const ampIframeHtml = path.join(paths.vendor, 'data/amp-iframe.html');
// The static assets
const staticDir = path.resolve(paths.target, 'data', 'vendor');

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Copy AMP iframe HTML',
title: 'Copy AMP iframe HTML',
task: () =>
cpy(ampIframeHtml, staticDir, {
parents: false,
Expand Down
3 changes: 2 additions & 1 deletion tools/__tasks__/compile/data/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const rimraf = require('rimraf');

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

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Clear Data build artefacts',
title: 'Clear Data build artefacts',
task: () => {
rimraf.sync(path.resolve(paths.target, 'data'));
rimraf.sync(path.resolve(paths.hash, 'data'));
Expand Down
3 changes: 2 additions & 1 deletion tools/__tasks__/compile/data/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ const currentVendorListJSON = path.join(
'data/cmp_vendorlist.json',
);

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Downloading data files',
title: 'Downloading data files',
task: () =>
new Promise((resolve, reject) => {
request(vendorListOfficialUrl, (error, response, body) => {
Expand Down
19 changes: 12 additions & 7 deletions tools/__tasks__/compile/data/index.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ const clean = require('./clean.js');
const download = require('./download.js');
const amp = require('./amp.js');

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Clean download and build data assets (dev)',
task: [
// prettier: multi-line
clean,
download,
amp,
],
title: 'Clean download and build data assets (dev)',
task: (ctx, task) =>
task.newListr(
[
// prettier: multi-line
clean,
download,
amp,
],
{ concurrent: false },
),
};

module.exports = task;
19 changes: 12 additions & 7 deletions tools/__tasks__/compile/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ const clean = require('./clean.js');
const download = require('./download.js');
const amp = require('./amp.js');

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Clean download and build data assets',
task: [
// prettier: multi-line
clean,
download,
amp,
],
title: 'Clean download and build data assets',
task: (ctx, task) =>
task.newListr(
[
// prettier: multi-line
clean,
download,
amp,
],
{ concurrent: false },
),
};

module.exports = task;
19 changes: 12 additions & 7 deletions tools/__tasks__/compile/data/index.watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ const clean = require('./clean.js');
const download = require('./download.js');
const amp = require('./amp.js');

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Clean, download and build data assets (watch)',
task: [
// prettier: multi-line
clean,
download,
amp,
],
title: 'Clean, download and build data assets (watch)',
task: (ctx, task) =>
task.newListr(
[
// prettier: multi-line
clean,
download,
amp,
],
{ concurrent: false },
),
};

module.exports = task;
3 changes: 2 additions & 1 deletion tools/__tasks__/compile/hash/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const rimraf = require('rimraf');

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

/** @type {import('listr2').ListrTask} */
const task = {
description: 'Clear asset hash artefacts',
title: 'Clear asset hash artefacts',
task: () => rimraf.sync(path.resolve(paths.hash, 'assets')),
};

Expand Down
Loading
Loading