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 Feb 12, 2024
1 parent a1e9fa9 commit 9548f0f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 145 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
README.md merge=ours
* text=auto eol=lf
README.md merge=ours
13 changes: 4 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
default: "18"
experimental:
required: false
default: false
default: "false"
ref:
description: "The branch or tag to checkout"
required: false
Expand Down Expand Up @@ -148,17 +148,12 @@ jobs:
else
echo "Changes detected"
git status
git add .
git diff --staged > changes.diff
exit 1
fi

# If there are changes, capture the changes and upload them as an artifact
- name: Capture changes
if: ${{ failure() }}
id: capture-changes
run: |
git diff
git diff > changes.diff

# If there are changes, capture and upload them as an artifact
- name: Upload changes
if: ${{ failure() }}
uses: actions/upload-artifact@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
# -------------------------------------------------------------
# Validate build for various environments
# -------------------------------------------------------------
# todo: should we limit this to run before merging?
verify_builds:
name: Verify
# Check that the PR is not in draft mode (or if it is, that it has the run_ci label to force a build)
Expand All @@ -61,7 +62,7 @@ jobs:
experimental:
- false
include:
- node-version: 20
- node-version: 21
experimental: true
- system: windows-latest
experimental: true
Expand Down
8 changes: 4 additions & 4 deletions tasks/mod-extractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async function main(inputs) {

/* -- Markdown Output -- */
/* Output as a markdown table in the metadata folder for site rendering */
let destPath = `${dir}/metadata`;
let destPath = path.join(dir, "metadata");

// If the metadata folder doesn't exist, create it
if (!existsSync(destPath)) mkdirSync(destPath);
Expand All @@ -108,7 +108,7 @@ async function main(inputs) {

// Write the results to a markdown file in the metadata folder
promises.push(
writeFile(`${destPath}/mods.md`, finalResult, { encoding: "utf-8" }).then(() => {
writeFile(path.join(destPath, "mods.md"), finalResult, { encoding: "utf-8" }).then(() => {
console.log(`${`✓`.green} ${"metadata/mods.md".yellow} written`);
}).catch((err) => {
if (!err) return;
Expand All @@ -118,7 +118,7 @@ async function main(inputs) {
);

/* -- JSON Output -- */
destPath = `${dir}/dist`;
destPath = path.join(dir, "dist");
// If the dist folder doesn't exist yet, create it
if (!existsSync(destPath)) mkdirSync(destPath);

Expand All @@ -129,7 +129,7 @@ async function main(inputs) {

// Write the JSON output to the dist folder
promises.push(
writeFile(`${destPath}/mods.json`, finalResult, { encoding: "utf-8" }).then(() => {
writeFile(path.join(destPath, "mods.json"), finalResult, { encoding: "utf-8" }).then(() => {
console.log(`${`✓`.green} ${"dist/mods.json".yellow} written`);
}).catch((err) => {
if (!err) return;
Expand Down
3 changes: 1 addition & 2 deletions tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"main": "dist/index.css",
"devDependencies": {
"@adobe/spectrum-tokens": "12.23.3",
"@nxkit/style-dictionary": "^4.0.0",
"postcss": "^8.4.33",
"postcss-cli": "^11.0.0",
"postcss-combine-duplicated-selectors": "^10.0.3",
Expand All @@ -27,7 +26,7 @@
"postcss-rgb-mapping": "^1.1.0",
"postcss-sorting": "^8.0.2",
"prettier": "^2.8.8",
"style-dictionary": "^3.9.1",
"style-dictionary": "^3.9.2",
"style-dictionary-sets": "^2.3.0"
},
"publishConfig": {
Expand Down
10 changes: 4 additions & 6 deletions tokens/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,16 @@
},
"style-dictionary": {
"dependsOn": ["clean"],
"executor": "@nxkit/style-dictionary:build",
"executor": "nx:run-commands",
"inputs": [
"{projectRoot}/postcss.config.js",
"{projectRoot}/style-dictionary.config.js",
"{projectRoot}/utilities/style-dictionary.utils.js"
],
"options": {
"deleteOutputPath": false,
"outputPath": "./tokens",
"platform": "CSS",
"styleDictionaryConfig": "./tokens/style-dictionary.config.js",
"tsConfig": "./tsconfig.json"
"commands": [
"style-dictionary build --config {projectRoot}/style-dictionary.config.js --platform CSS"
]
},
"outputs": [
"{projectRoot}/dist/global-vars.css",
Expand Down
6 changes: 3 additions & 3 deletions tokens/style-dictionary.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

const path = require("path");

const generateFileConfig = require("./utilities/style-dictionary.utils.js");
const generateFileConfig = require(path.join(__dirname, "utilities/style-dictionary.utils.js"));

const StyleDictionary = require("style-dictionary");
const CSSSetsFormatter = require("style-dictionary-sets").CSSSetsFormatter;
Expand All @@ -38,10 +38,10 @@ const tokensDir = path.dirname(tokensPath);
const setNames = ["desktop", "mobile", "light", "dark", "darkest"];

module.exports = {
source: [`${tokensDir}/src/*.json`],
source: [path.join(tokensDir, "src/*.json")],
platforms: {
CSS: {
buildPath: "dist/css/",
buildPath: path.join(__dirname, "dist/css/"),
transforms: [
AttributeSetsTransform.name,
NameKebabTransfom.name,
Expand Down
Loading

0 comments on commit 9548f0f

Please sign in to comment.