Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(exporter-tokens): Pass all tokens to the computeTokensByApplyingThemes so references work #1729

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exporters/tokens/generated/exporter.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ ${a?`};
`}`;return ue(f,a)},ko=async(n,a,u,i,m)=>{const y=[],f=L(n,a,u,J),r=L(n,a,u,J,!0),t=w(f),o=w(r,!0);y.push(...f.map(c=>({path:`./${R}/${N}`,fileName:`_${c.fileName}.scss`,content:c.content})),...r.map(c=>({path:`./${x}/${N}/`,fileName:`${c.fileName}.ts`,content:c.content}))),y.push({path:`./${R}/${N}/`,fileName:"index.scss",content:t}),y.push({path:`./${x}/${N}/`,fileName:"index.ts",content:o}),y.push({path:`./${R}/`,fileName:"@global.scss",content:`@forward '${N}';
`}),y.push({path:`./${x}/`,fileName:"index.ts",content:`export * from './${N}';
export * from './${D}';
`});const e=await Promise.all(i.map(async c=>({themedTokens:m.tokens.computeTokensByApplyingThemes([],n,[c]),theme:c})));for(const{themedTokens:c,theme:p}of e){const l=L(c,a,u,ee),d=L(c,a,u,ee,!0),g=w(l),S=w(d,!0);y.push(...l.map(b=>({path:`./${R}/${D}/${p.name}/`,fileName:`_${b.fileName}.scss`,content:b.content})),...d.map(b=>({path:`./${x}/${D}/${p.name}/`,fileName:`${b.fileName}.ts`,content:b.content}))),y.push({path:`./${R}/${D}/${p.name}/`,fileName:"index.scss",content:g}),y.push({path:`./${x}/${D}/${p.name}/`,fileName:"index.ts",content:S})}const s=te(i),T=te(i,!0);return y.push({path:`./${R}/`,fileName:"@themes.scss",content:s}),y.push({path:`./${x}/${D}`,fileName:"index.ts",content:T}),y},Co=n=>{let a=[];const u=JSON.stringify(n,(i,m)=>{if(typeof m=="object"&&m!==null){if(a!=null&&a.includes(m))return"CIRCULAR_REFERENCE";a==null||a.push(m)}return m},2);return a=null,u},ve=Pulsar.exportConfig();Pulsar.export(async(n,a)=>{const u={designSystemId:a.dsId,versionId:a.versionId};let i=await n.tokens.getTokens(u),m=await n.tokens.getTokenGroups(u);a.brandId&&(i=i.filter(e=>e.brandId===a.brandId),m=m.filter(e=>e.brandId===a.brandId));const y=new Map(i.map(e=>[e.id,e])),f=await n.tokens.getTokenThemes(u),r=(e,s,T)=>P.FileHelper.createTextFile({relativePath:e,fileName:s,content:T});let t=[];return t=(await ko(i,y,m,f,n)).map(e=>r(e.path,e.fileName,e.content)),ve.generateOriginalDataFiles&&t.push(r("./original-data/","_original-tokens.json",Co(i)),r("./original-data/","_original-groups.json",JSON.stringify(m,null,2))),t});exports.exportConfiguration=ve;
`});const e=await Promise.all(i.map(async c=>({themedTokens:m.tokens.computeTokensByApplyingThemes(n,n,[c]),theme:c})));for(const{themedTokens:c,theme:p}of e){const l=L(c,a,u,ee),d=L(c,a,u,ee,!0),g=w(l),S=w(d,!0);y.push(...l.map(b=>({path:`./${R}/${D}/${p.name}/`,fileName:`_${b.fileName}.scss`,content:b.content})),...d.map(b=>({path:`./${x}/${D}/${p.name}/`,fileName:`${b.fileName}.ts`,content:b.content}))),y.push({path:`./${R}/${D}/${p.name}/`,fileName:"index.scss",content:g}),y.push({path:`./${x}/${D}/${p.name}/`,fileName:"index.ts",content:S})}const s=te(i),T=te(i,!0);return y.push({path:`./${R}/`,fileName:"@themes.scss",content:s}),y.push({path:`./${x}/${D}`,fileName:"index.ts",content:T}),y},Co=n=>{let a=[];const u=JSON.stringify(n,(i,m)=>{if(typeof m=="object"&&m!==null){if(a!=null&&a.includes(m))return"CIRCULAR_REFERENCE";a==null||a.push(m)}return m},2);return a=null,u},ve=Pulsar.exportConfig();Pulsar.export(async(n,a)=>{const u={designSystemId:a.dsId,versionId:a.versionId};let i=await n.tokens.getTokens(u),m=await n.tokens.getTokenGroups(u);a.brandId&&(i=i.filter(e=>e.brandId===a.brandId),m=m.filter(e=>e.brandId===a.brandId));const y=new Map(i.map(e=>[e.id,e])),f=await n.tokens.getTokenThemes(u),r=(e,s,T)=>P.FileHelper.createTextFile({relativePath:e,fileName:s,content:T});let t=[];return t=(await ko(i,y,m,f,n)).map(e=>r(e.path,e.fileName,e.content)),ve.generateOriginalDataFiles&&t.push(r("./original-data/","_original-tokens.json",Co(i)),r("./original-data/","_original-groups.json",JSON.stringify(m,null,2))),t});exports.exportConfiguration=ve;
2 changes: 1 addition & 1 deletion exporters/tokens/src/generators/fileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const generateOutputFilesByThemes = async (
// Compute themed tokens for all themes in parallel
const allThemes = await Promise.all(
themes.map(async (theme) => {
const themedTokens = sdk.tokens.computeTokensByApplyingThemes([], tokens, [theme]);
const themedTokens = sdk.tokens.computeTokensByApplyingThemes(tokens, tokens, [theme]);

return { themedTokens, theme };
}),
Expand Down
Loading