Skip to content

Commit

Permalink
fix(tokens): support style-dictionary build in windows env
Browse files Browse the repository at this point in the history
  • Loading branch information
castastrophe committed Dec 21, 2024
1 parent 2897fd1 commit 38921ac
Show file tree
Hide file tree
Showing 44 changed files with 9,088 additions and 98 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
default: "20"
experimental:
required: false
default: false
default: "false"
ref:
description: "The branch or tag to checkout"
required: false
Expand Down Expand Up @@ -153,7 +153,6 @@ jobs:
git diff --staged > changes.diff
exit 1
fi
- name: Upload changes
if: ${{ failure() }}
uses: actions/upload-artifact@v4
Expand Down
6 changes: 3 additions & 3 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
],
"options": {
"commands": [
"node --no-warnings -e 'require(\"./tasks/component-builder.js\").default()'"
"node --no-warnings ./tasks/component-builder.js {projectName}"
]
},
"outputs": [
Expand Down Expand Up @@ -102,7 +102,7 @@
],
"options": {
"commands": [
"node --no-warnings ./tasks/compare-compiled-output.js $NX_TASK_TARGET_PROJECT"
"node --no-warnings ./tasks/compare-compiled-output.js {projectName}"
]
},
"outputs": ["{workspaceRoot}/.diff-output"]
Expand Down Expand Up @@ -155,7 +155,7 @@
],
"options": {
"commands": [
"cross-env NODE_OPTIONS=\"--no-warnings\" node -e 'require(\"./tasks/component-reporter.js\").default()'"
"node --no-warnings ./tasks/component-reporter.js {projectName}"
]
},
"outputs": [
Expand Down
13 changes: 11 additions & 2 deletions tasks/component-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const fs = require("fs");
const fsp = fs.promises;
const path = require("path");

const { hideBin } = require("yargs/helpers");
const yargs = require("yargs");

const postcss = require("postcss");
const postcssrc = require("postcss-load-config");
const prettier = require("prettier");
Expand Down Expand Up @@ -223,8 +226,8 @@ async function buildThemes({ cwd = process.cwd(), clean = false } = {}) {
const theme = path.basename(input, ".css");
return processCSS(
content,
path.join(cwd, input),
path.join(cwd, "dist", input),
input,
path.join(cwd, "dist", "themes", `${theme}.css`),
{
cwd,
clean,
Expand Down Expand Up @@ -334,3 +337,9 @@ async function main({
exports.processCSS = processCSS;
exports.fetchContent = fetchContent;
exports.default = main;

let {
_: components,
} = yargs(hideBin(process.argv)).argv;

Promise.all(components.map((componentName) => main({ componentName })));
9 changes: 9 additions & 0 deletions tasks/component-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const fs = require("fs");
const fsp = fs.promises;
const path = require("path");

const { hideBin } = require("yargs/helpers");
const yargs = require("yargs");

const postcss = require("postcss");
const prettier = require("prettier");

Expand Down Expand Up @@ -268,3 +271,9 @@ async function main({

exports.extractModifiers = extractModifiers;
exports.default = main;

let {
_: components,
} = yargs(hideBin(process.argv)).argv;

Promise.all(components.map((componentName) => main({ componentName })));
34 changes: 13 additions & 21 deletions tasks/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,27 +200,20 @@ async function fetchContent(
})),
);

// Combine the content into 1 file; @todo do this in future using CSS imports
if (shouldCombine) {
let content = "";
fileData.forEach((dataset) => {
if (dataset.content) content += "\n\n" + dataset.content;
});
if (!shouldCombine) return Promise.resolve(fileData);

return Promise.resolve([
{
content,
input: fileData[0].input,
},
]);
}
// Combine the content into 1 file; @todo do this in future using CSS imports
let content = "";
fileData.forEach((dataset) => {
if (dataset.content) content += "\n\n" + dataset.content;
});

return Promise.all(
files.map(async (file) => ({
content: await fsp.readFile(path.join(cwd, file), "utf8"),
input: file,
})),
);
return Promise.resolve([
{
content,
input: fileData[0].input,
},
]);
}

/**
Expand Down Expand Up @@ -286,8 +279,7 @@ async function writeAndReport(content, output, { cwd = process.cwd() } = {}) {
})
.catch((err) => {
if (!err) return;
const relativePath = path.relative(cwd, output);
console.log(`${"✗".red} ${relativePath.yellow} not written`);
console.log(`${"✗".red} ${relativePrint(cwd, output).yellow} not written`);
return Promise.reject(err);
});
}
Expand Down
Loading

0 comments on commit 38921ac

Please sign in to comment.