mirror of
https://github.com/iconoir-icons/iconoir
synced 2026-03-14 14:05:44 +01:00
Use worker threads for building targets
This commit is contained in:
parent
4b26faf0d2
commit
c5b1c480a8
4 changed files with 30 additions and 28 deletions
|
|
@ -4,6 +4,7 @@ import process from 'node:process';
|
|||
import { fileURLToPath } from 'node:url';
|
||||
import { Listr } from 'listr2';
|
||||
import { pascalCase, snakeCase } from 'scule';
|
||||
import Tinypool from 'tinypool';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
|
|
@ -38,14 +39,12 @@ const targets = {
|
|||
},
|
||||
};
|
||||
|
||||
const cliTargets = [];
|
||||
|
||||
const tasks = new Listr(
|
||||
[
|
||||
{
|
||||
title: 'Fetching icons',
|
||||
task: async (ctx) => {
|
||||
ctx.icons = {};
|
||||
ctx.tasks = { global: { rootDir, defaultVariant }, icons: {} };
|
||||
|
||||
const iconsVariantsDirs = Object.fromEntries(
|
||||
iconsVariants.map((variant) => [
|
||||
|
|
@ -74,32 +73,18 @@ const tasks = new Listr(
|
|||
};
|
||||
});
|
||||
|
||||
ctx.icons[variant] = icons;
|
||||
ctx.tasks.icons[variant] = icons;
|
||||
}
|
||||
|
||||
ctx.global = { defaultVariant };
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Building targets',
|
||||
task: (_, task) =>
|
||||
task: (ctx, task) =>
|
||||
task.newListr(
|
||||
Object.entries(targets).map(([targetName, targetConfig]) => ({
|
||||
title: targetConfig.title,
|
||||
enabled: () =>
|
||||
cliTargets.length === 0 || cliTargets.includes(targetName),
|
||||
task: async (ctx) => {
|
||||
const { default: task } = await import(
|
||||
`./targets/${targetConfig.target || targetName}/index.js`
|
||||
);
|
||||
|
||||
targetConfig.path = path.join(
|
||||
rootDir,
|
||||
...targetConfig.path.split(path.posix.sep),
|
||||
);
|
||||
|
||||
return task(ctx, targetConfig);
|
||||
},
|
||||
enabled: () => ctx.cliTargets.length === 0 || ctx.cliTargets.includes(targetName),
|
||||
task: async (ctx) => ctx.pool.run({ targetName, config: ctx.tasks, targetConfig }),
|
||||
})),
|
||||
{ concurrent: true, exitOnError: false },
|
||||
),
|
||||
|
|
@ -113,6 +98,8 @@ const tasks = new Listr(
|
|||
},
|
||||
);
|
||||
|
||||
const cliTargets = [];
|
||||
|
||||
// Get targets from command line arguments
|
||||
// (build all targets if no arguments given)
|
||||
for (const arg of process.argv.slice(2)) {
|
||||
|
|
@ -131,4 +118,15 @@ for (const arg of process.argv.slice(2)) {
|
|||
}
|
||||
}
|
||||
|
||||
await tasks.run();
|
||||
const pool = new Tinypool({
|
||||
filename: new URL('./worker.js', import.meta.url).href,
|
||||
minThreads: 0,
|
||||
resourceLimits: {
|
||||
// Vue target (Vite/Rollup) takes up a lot of memory
|
||||
maxOldGenerationSizeMb: 8192,
|
||||
},
|
||||
});
|
||||
|
||||
await tasks.run({ cliTargets, pool });
|
||||
|
||||
await pool.destroy();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import process from 'node:process';
|
|||
import { updateYamlKey } from '@atomist/yaml-updater';
|
||||
import semver from 'semver';
|
||||
|
||||
const PACKAGE_BASE = '';
|
||||
|
||||
const newVersion = semver.valid(semver.coerce(process.env.TAG_NAME));
|
||||
console.info('New version is %s', newVersion);
|
||||
|
||||
|
|
@ -31,10 +29,6 @@ function publishNpmPackage(name) {
|
|||
const contents = JSON.parse(fs.readFileSync(packageJsonPath).toString());
|
||||
contents.version = newVersion;
|
||||
|
||||
if (PACKAGE_BASE) {
|
||||
contents.name = `${PACKAGE_BASE}/${name}`;
|
||||
}
|
||||
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(contents, undefined, 2));
|
||||
console.info('package.json updated');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
"prettier": "^3.4.2",
|
||||
"scule": "^1.3.0",
|
||||
"semver": "^7.6.3",
|
||||
"tinypool": "1.0.2",
|
||||
"typescript": "~5.7.2",
|
||||
"vite": "^6.0.4",
|
||||
"vite-plugin-dts": "^4.4.0"
|
||||
|
|
|
|||
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
|
|
@ -55,6 +55,9 @@ importers:
|
|||
semver:
|
||||
specifier: ^7.6.3
|
||||
version: 7.6.3
|
||||
tinypool:
|
||||
specifier: 1.0.2
|
||||
version: 1.0.2
|
||||
typescript:
|
||||
specifier: ~5.7.2
|
||||
version: 5.7.2
|
||||
|
|
@ -6507,6 +6510,10 @@ packages:
|
|||
tinyexec@0.3.1:
|
||||
resolution: {integrity: sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==}
|
||||
|
||||
tinypool@1.0.2:
|
||||
resolution: {integrity: sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
|
||||
tmp@0.0.33:
|
||||
resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==}
|
||||
engines: {node: '>=0.6.0'}
|
||||
|
|
@ -14876,6 +14883,8 @@ snapshots:
|
|||
|
||||
tinyexec@0.3.1: {}
|
||||
|
||||
tinypool@1.0.2: {}
|
||||
|
||||
tmp@0.0.33:
|
||||
dependencies:
|
||||
os-tmpdir: 1.0.2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue