@webority/tokens 0.109.0 → 0.109.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  "format": "webority-theme-tokens/2",
3
3
  "source": {
4
4
  "package": "@webority/tokens",
5
- "version": "0.109.0",
5
+ "version": "0.109.2",
6
6
  "brand": null,
7
7
  "platform": "phone",
8
8
  "width": null
@@ -2,7 +2,7 @@
2
2
  "format": "webority-theme-tokens/2",
3
3
  "source": {
4
4
  "package": "@webority/tokens",
5
- "version": "0.109.0",
5
+ "version": "0.109.2",
6
6
  "brand": null,
7
7
  "platform": "web",
8
8
  "width": 390
@@ -2,7 +2,7 @@
2
2
  "format": "webority-theme-tokens/2",
3
3
  "source": {
4
4
  "package": "@webority/tokens",
5
- "version": "0.109.0",
5
+ "version": "0.109.2",
6
6
  "brand": null,
7
7
  "platform": "web",
8
8
  "width": 1440
package/dist/check.js CHANGED
@@ -1,2 +1,4 @@
1
1
  import{__toESM as e}from"./_virtual/_rolldown/runtime.js";import{BRAND_OUTPUT_FILES as t}from"./brand.js";import{require__2020 as n}from"./node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js";import{loadModel as r}from"./model/index.js";import{brand as i}from"./build.js";import{readFileSync as a,readdirSync as o}from"node:fs";import{join as s,resolve as c}from"node:path";import{spawnSync as l}from"node:child_process";var u=e(n(),1),d=`.webority/design.json`,f=c(import.meta.dirname,`../schema/design-map.schema.json`),p=new Set([`vite.config.js`,`vite.config.mjs`,`vite.config.cjs`,`vite.config.ts`,`vite.config.mts`,`vite.config.cts`]);async function m(e={},t={}){let{brand:n=i,repoChecks:a=w,loadModel:o=r}=t,s=e.root??process.cwd(),c=[],l=h(s,c);return l!==null&&(g(l,c),c.length===0&&l.tokens!==void 0&&v(l,s,c)),c.length===0&&(await b(l,s,o,c),l.tokens!==void 0&&await S(l,s,n,c)),await C(s,a,c),{findings:c}}function h(e,t){let n;try{n=a(s(e,d),`utf8`)}catch{return t.push({check:`design-map`,file:d,message:`Cannot read the file. Run webority check from the repo root and create the file.`}),null}try{return JSON.parse(n)}catch(e){return t.push({check:`design-map`,file:d,message:`${e.message}. Fix the file.`}),null}}function g(e,t){let n=new u.Ajv2020({allErrors:!0}).compile(JSON.parse(a(f,`utf8`)));if(!n(e))for(let r of n.errors)t.push({check:`design-map`,file:d,message:_(r,e)})}function _(e,t){let n=e.instancePath.split(`/`).filter(Boolean),r=n.length>0?n.join(`.`):`design.json`;if(e.keyword===`additionalProperties`)return r+=`.${e.params.additionalProperty}`,`${r}: is not a design map key, retired or misspelled. Remove it.`;if(e.keyword===`required`)return r+=`.${e.params.missingProperty}`,`${r}: is required. Add it.`;let i=n.reduce((e,t)=>e?.[t],t);return typeof i==`string`&&(i.startsWith(`--`)||i.includes(`var(`))?`${r}: a CSS variable is not a role. Use the meaning name, or <group>.<name> for a scale role.`:`${r}: ${e.message}. Fix the file.`}function v(e,t,n){let r=e.tokens.brands,i=e.tokens.heads??[],a=e=>n.push({check:`design-map`,file:d,message:e}),o=new Map;for(let e of r)o.set(e.name,(o.get(e.name)??0)+1);for(let[e,t]of o)t>1&&a(`tokens.brands: ${e} is listed more than once. Give each brand its own name.`);let c=new Set(r.map(e=>e.name));i.forEach((e,t)=>{c.has(e.brand)||a(`tokens.heads[${t}]: brand ${e.brand} is not in tokens.brands. Use a listed brand name.`)});let l=new Set(i.map(e=>e.brand));for(let e of r)e.source!==`library`&&!l.has(e.name)&&a(`tokens.brands: ${e.name} has no head. List a head for it or remove the brand.`);if(r.length>1)for(let e of r)e.source===`library`&&a(`tokens.brands: a library source cannot be combined with other brands. Keep one brand.`);i.forEach((e,n)=>{let r=y(s(t,e.path));r!==null&&(e.kind===`spa`&&r.some(e=>e.endsWith(`.csproj`))&&a(`tokens.heads[${n}]: ${e.path} holds a .csproj, so its kind is razor. Set kind razor.`),e.kind===`razor`&&r.some(e=>p.has(e))&&a(`tokens.heads[${n}]: ${e.path} holds a Vite project, so its kind is spa. Set kind spa.`))})}function y(e){try{return o(e)}catch{return null}}async function b(e,n,r,i){let a=e=>i.push({check:`design-map`,file:d,message:e});if(e.tokens!==void 0)for(let r of e.tokens.brands){let i=r.source===`library`?`${r.export}/canvas`:r.export,o=x(s(n,i));if(o!==null)for(let[n,s]of Object.entries(e.color?.roles??{}))o.has(s)||a(`color.roles.${n}: ${s} is not a colour of brand ${r.name}. Use a name from ${i}/${t.web}.`)}let o=[];for(let[t,n]of Object.entries(e.scale??{})){for(let[e,r]of Object.entries(n.roles??{}))o.push([`scale.${t}.roles.${e}`,r]);for(let[e,r]of Object.entries(n.durations??{}))o.push([`scale.${t}.durations.${e}`,r])}for(let[t,n]of Object.entries(e.iconography?.sizes??{}))o.push([`iconography.sizes.${t}`,n]);if(o.length===0)return;let c;try{c=await r()}catch(e){i.push({check:`design-map`,file:null,message:`${e.message}. Fix the token source.`});return}let l=new Set;for(let e of c.tokens.values())l.add(`${e.group}.${e.name}`);for(let[e,t]of o)l.has(t)||a(`${e}: ${t} is not a token. Use a <group>.<name> the library defines.`)}function x(e){let n=new Set,r=!1;for(let i of[t.web,t.phoneTheme]){let t;try{t=JSON.parse(a(s(e,i),`utf8`))}catch{continue}r=!0;for(let e of Object.keys(t?.colors?.light??{}))n.add(e)}return r?n:null}async function S(e,t,n,r){let i=e.tokens.brands,a=i.length===1&&i[0].source===`library`,o;try{o=a?await n({root:t,library:!0,out:i[0].export,check:!0}):await n({root:t,check:!0})}catch(e){for(let t of String(e?.message??e).split(`
2
- `))t.trim()!==``&&r.push({check:`generated`,file:null,message:t});return}let s=a?`stale. Run webority brand --library --out ${i[0].export}`:`stale. Run webority brand`;for(let e of o.stale)r.push({check:`generated`,file:e,message:s})}async function C(e,t,n){let r;try{r=await t(e)}catch{n.push({check:`repo-checks`,file:null,message:`repo-checks did not run. Add @webority/repo-checks at the lockstep version.`});return}for(let e of r.new)n.push({check:`repo-checks`,file:e.pkg===`.`?null:e.pkg,message:`${e.id}: ${e.message}`})}function w(e){let t=l(`corepack pnpm exec webority-repo-checks --json`,{cwd:e,encoding:`utf8`,shell:!0,maxBuffer:64*1024*1024}),n;try{n=JSON.parse(t.stdout??``)}catch{throw Error(`repo-checks printed no JSON`)}if(!Array.isArray(n?.new))throw Error(`repo-checks printed no new array`);return n}export{m as check};
2
+ `))t.trim()!==``&&r.push({check:`generated`,file:null,message:t});return}let s=a?`stale. Run webority brand --library --out ${i[0].export}`:`stale. Run webority brand`;for(let e of o.stale)r.push({check:`generated`,file:e,message:s})}async function C(e,t,n){let r;try{r=await t(e)}catch{n.push({check:`repo-checks`,file:null,message:`repo-checks did not run. Add @webority/repo-checks at the lockstep version.`});return}for(let e of r.new)n.push({check:`repo-checks`,file:e.pkg===`.`?null:e.pkg,message:`${e.id}: ${e.message}`})}function w(e){return T(l(`corepack pnpm exec webority-repo-checks --json`,{cwd:e,encoding:`utf8`,shell:!0,maxBuffer:64*1024*1024}).stdout??``)}function T(e){let t=e.split(`
3
+ `),n=t.findIndex(e=>e.startsWith(`{`)),r;try{if(n===-1)throw Error(`no JSON line`);r=JSON.parse(t.slice(n).join(`
4
+ `))}catch{throw Error(`repo-checks printed no JSON`)}if(!Array.isArray(r?.new))throw Error(`repo-checks printed no new array`);return r}export{m as check,T as parseRepoChecksOutput};
@@ -2,7 +2,7 @@
2
2
  "format": "webority-meanings/1",
3
3
  "source": {
4
4
  "package": "@webority/tokens",
5
- "version": "0.109.0"
5
+ "version": "0.109.2"
6
6
  },
7
7
  "color": {
8
8
  "bg": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/tokens",
3
- "version": "0.109.0",
3
+ "version": "0.109.2",
4
4
  "description": "The Webority design tokens in one W3C Design Tokens source (palette, scale, meaning and component tiers, with light and dark, web and phone, and 390 and 1440 widths), and the webority command that brands a product, upgrades it between releases and checks it against the token source.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",