Skip to content
This repository was archived by the owner on Apr 21, 2024. It is now read-only.
6 changes: 3 additions & 3 deletions yarn-plugins/babel/bundles/@yarnpkg/plugin-babel.js

Large diffs are not rendered by default.

42 changes: 25 additions & 17 deletions yarn-plugins/babel/src/hooks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const BABEL_COMMANDS = [
];

const preparePlugin = {
title: 'Preparing babel plugin',
title: 'Prepare babel plugin',
task: async ctx => {
const { workspaces } = ctx;

Expand Down Expand Up @@ -40,10 +40,15 @@ const preparePlugin = {
};

const prepareBabelWorkspaces = {
title: 'Preparing babel presets/plugins in workspaces',
title: 'Prepare babel presets/plugins in workspaces',
enabled: ({ babelWorkspaces }) => babelWorkspaces?.length !== 0,
task: ({ babelWorkspaces }) =>
Promise.all(
task: async ctx => {
const { babelWorkspaces } = ctx;

ctx.babelEnv = process.env.BABEL_ENV;
process.env.BABEL_ENV = 'pre';

await Promise.all(
babelWorkspaces.map(async ({ cwd, manifest: { main } }) => {
const mainFilePath = ppath.join(cwd, main);
const mainDirPath = ppath.dirname(mainFilePath);
Expand All @@ -57,28 +62,30 @@ const prepareBabelWorkspaces = {
'module.exports = function fakeBabel() { return {}; }',
);
}),
),
);
},
};

const buildBabelWorkspaces = {
title: 'Building babel presets/plugins in workspaces',
title: 'Build babel presets/plugins in workspaces',
enabled: ({ babelWorkspaces }) => babelWorkspaces?.length !== 0,
task: async ({ babelWorkspaces, runWithWorkspaces }, task) => {
process.env.BABEL_ENV = 'pre';
await runWithWorkspaces(babelWorkspaces, BABEL_COMMANDS, {
stdout: task.stdout(),
});
delete process.env.BABEL_ENV;
task: ({ babelWorkspaces, workspacesTasks }, task) =>
workspacesTasks(task, babelWorkspaces, BABEL_COMMANDS),
};

const resetBabelEnv = {
title: 'Reset BABEL_ENV',
enabled: ({ babelWorkspaces }) => babelWorkspaces?.length !== 0,
task: ({ babelEnv }) => {
process.env.BABEL_ENV = babelEnv;
},
};

const buildWorkspaces = {
title: 'Building workspaces with babel',
title: 'Build workspaces with babel',
enabled: ({ useBabelWorkspaces }) => useBabelWorkspaces?.length !== 0,
task: ({ useBabelWorkspaces, runWithWorkspaces }, task) =>
runWithWorkspaces(useBabelWorkspaces, BABEL_COMMANDS, {
stdout: task.stdout(),
}),
task: ({ useBabelWorkspaces, workspacesTasks }, task) =>
workspacesTasks(task, useBabelWorkspaces, BABEL_COMMANDS),
};

export default tasks =>
Expand All @@ -89,6 +96,7 @@ export default tasks =>
preparePlugin,
prepareBabelWorkspaces,
buildBabelWorkspaces,
resetBabelEnv,
buildWorkspaces,
]),
});
2 changes: 1 addition & 1 deletion yarn-plugins/builder/bundles/@yarnpkg/plugin-builder.js

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions yarn-plugins/builder/src/hooks/build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { scriptUtils } from '@yarnpkg/core';

const preparePlugin = {
title: 'Preparing builder plugin',
title: 'Prepare builder plugin',
task: async ctx => {
const { workspaces } = ctx;

Expand All @@ -20,12 +20,10 @@ const preparePlugin = {
};

const buildWorkspaces = {
title: 'Building yarn plugins in workspaces',
title: 'Build yarn plugins in workspaces',
enabled: ({ useBuilderWorkspaces }) => useBuilderWorkspaces?.length !== 0,
task: ({ useBuilderWorkspaces, runWithWorkspaces }, task) =>
runWithWorkspaces(useBuilderWorkspaces, ['builder', 'build', 'plugin'], {
stdout: task.stdout(),
}),
task: ({ useBuilderWorkspaces, workspacesTasks }, task) =>
workspacesTasks(task, useBuilderWorkspaces, ['builder', 'build', 'plugin']),
};

export default tasks =>
Expand Down
32 changes: 16 additions & 16 deletions yarn-plugins/miko/bundles/@yarnpkg/plugin-miko.js

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions yarn-plugins/miko/src/commands/Miko.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, Option } from 'clipanion';
import { Configuration, Project } from '@yarnpkg/core';
import { Configuration, Project, structUtils } from '@yarnpkg/core';
import { Listr } from 'listr2';

import buildUsage from '../utils/buildUsage';
Expand Down Expand Up @@ -38,13 +38,20 @@ export default class Miko extends Command {
await configuration.triggerHook(hooks => hooks[name], listr);
await listr.run({
workspaces,
runWithWorkspaces: (workspaces, commands, options) =>
Promise.all(
workspaces.map(({ cwd }) =>
this.cli.run(commands, { ...options, cwd }),
),
),
normalizeTasks,
workspacesTasks: (task, selectedWorkspaces, commands) =>
normalizeTasks(
task,
selectedWorkspaces.map(({ locator, cwd }) => ({
title: structUtils.stringifyIdent(locator),
task: (_, subTask) =>
this.cli.run(commands, {
cwd,
stdout: subTask.stdout(),
}),
})),
{ concurrent: true },
),
});
};
}