From 3be4c2c1d28374115f45d9bc782c43aa40c24c14 Mon Sep 17 00:00:00 2001 From: mbehzad Date: Wed, 10 Apr 2024 16:12:27 +0200 Subject: [PATCH] feat(pv-stylemark): add support for the `aasets` option of stylemark see https://github.com/mpetrovich/stylemark?tab=readme-ov-file#configuration-file --- packages/pv-stylemark/tasks/lsg/buildDDS.js | 2 ++ packages/pv-stylemark/tasks/lsg/copyAssets.js | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 packages/pv-stylemark/tasks/lsg/copyAssets.js diff --git a/packages/pv-stylemark/tasks/lsg/buildDDS.js b/packages/pv-stylemark/tasks/lsg/buildDDS.js index f24acd3..afa2abf 100644 --- a/packages/pv-stylemark/tasks/lsg/buildDDS.js +++ b/packages/pv-stylemark/tasks/lsg/buildDDS.js @@ -2,6 +2,7 @@ const { buildLsgPage } = require("./buildLsgPage"); const { getLsgData } = require("./getLsgData"); const { buildLsgExamples } = require("./buildLsgExamples"); const { copyUiAssets } = require("./copyUiAssets"); +const { copyAssets } = require("./copyAssets"); const { getLsgConfig } = require("../../helper/config-helper"); const { resolveApp, getAppConfig, join } = require("../../helper/paths"); @@ -12,6 +13,7 @@ const buildDDS = async () => { await buildLsgPage(lsgData, config); await buildLsgExamples(lsgData, config); await copyUiAssets(); + await copyAssets(config); }; module.exports = { diff --git a/packages/pv-stylemark/tasks/lsg/copyAssets.js b/packages/pv-stylemark/tasks/lsg/copyAssets.js new file mode 100644 index 0000000..58abdf7 --- /dev/null +++ b/packages/pv-stylemark/tasks/lsg/copyAssets.js @@ -0,0 +1,23 @@ + +const { basename } = require("path"); +const { copy } = require("fs-extra"); + +const { resolveApp, getAppConfig, join } = require("../../helper/paths"); + +async function copyAssets(config) { + if (!config.assets) return; + + for (const assetPath of config.assets) { + const srcPath = resolveApp(assetPath); + const targetPath = resolveApp(join(getAppConfig().destPath, "styleguide", basename(assetPath))); + try { + await copy(srcPath, targetPath); + } catch (error) { + console.error(error); + } + } +}; + +module.exports = { + copyAssets, +};