@frontfriend/tailwind 4.0.7 → 4.0.8
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.
- package/dist/cli.js +34 -34
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`,{mode:384});try{
|
|
4
|
-
`)};var s=
|
|
2
|
+
var P=(e,o)=>()=>(o||e((o={exports:{}}).exports,o),o.exports);var K=P((jn,Z)=>{var we="https://app.frontfriend.dev",Se="https://registry-legacy.frontfriend.dev",xe=".cache/frontfriend",je={JS:["tokens.js","variables.js","semanticVariables.js","semanticDarkVariables.js","safelist.js","custom.js"],JSON:["fonts.json","icons.json","components-config.json","version.json","metadata.json"]},ke={FF_ID:"FF_ID",FF_API_URL:"FF_API_URL",FF_USE_LOCAL:"FF_USE_LOCAL",FF_AUTH_TOKEN:"FF_AUTH_TOKEN"};Z.exports={DEFAULT_API_URL:we,LEGACY_API_URL:Se,CACHE_DIR_NAME:xe,CACHE_TTL_DAYS:7,CACHE_TTL_MS:6048e5,CACHE_FILES:je,ENV_VARS:ke}});var ie=P((kn,re)=>{var F=require("fs"),W=require("path"),Fe=require("os"),be=require("https"),$e=require("http"),{URL:_e}=require("url"),{DEFAULT_API_URL:Q}=K(),X=W.join(Fe.homedir(),".frontfriend"),b=W.join(X,"credentials");function Te(){return b}function ee(){try{return F.existsSync(b)?JSON.parse(F.readFileSync(b,"utf8")):null}catch{return null}}function ne(e){F.mkdirSync(X,{recursive:!0,mode:448}),F.writeFileSync(b,`${JSON.stringify(e,null,2)}
|
|
3
|
+
`,{mode:384});try{F.chmodSync(b,384)}catch{}}function Ee(){return F.existsSync(b)?(F.unlinkSync(b),!0):!1}function oe(e,o=60*1e3){return!(e!=null&&e.accessToken)||!e.expiresAt||Date.now()+o>=e.expiresAt}function O(e){let o=new Error(`${e}. Run \`frontfriend login\` to re-authenticate.`);return o.code="FF_AUTH_REFRESH_FAILED",o}function te(e,o,n){return new Promise((t,s)=>{let r=new _e(e),i=r.protocol==="https:"?be:$e,f=JSON.stringify(o||{}),c=i.request({hostname:r.hostname,port:r.port,path:`${r.pathname}${r.search}`,method:"POST",headers:{"content-type":"application/json","content-length":Buffer.byteLength(f),...n?{authorization:`Bearer ${n}`}:{}}},a=>{let d="";a.on("data",l=>{d+=l}),a.on("end",()=>{if(a.statusCode>=300&&a.statusCode<400){let g=a.headers.location?` to ${a.headers.location}`:"",y=new Error(`HTTP ${a.statusCode}: redirected${g}`);y.statusCode=a.statusCode,y.body=d,s(y);return}let l=null;try{l=d?JSON.parse(d):null}catch(g){if(a.statusCode>=400){let y=new Error(`HTTP ${a.statusCode}: ${a.statusMessage||"Non-JSON response"}`);y.statusCode=a.statusCode,y.body=d,s(y);return}s(g);return}if(a.statusCode>=400){let g=new Error((l==null?void 0:l.error_description)||(l==null?void 0:l.error)||`HTTP ${a.statusCode}`);g.statusCode=a.statusCode,g.body=l,s(g);return}t(l)})});c.on("error",s),c.write(f),c.end()})}async function se(e,o=Q){if(!(e!=null&&e.refreshToken)||!(e!=null&&e.deviceId))throw O("FrontFriend session expired");let n;try{n=await te(`${o}/api/plugin/token`,{grant_type:"refresh_token",refresh_token:e.refreshToken,device_id:e.deviceId})}catch(s){throw O((s==null?void 0:s.message)||"Could not refresh FrontFriend session")}if(!(n!=null&&n.access_token)||!(n!=null&&n.refresh_token))throw O("Could not refresh FrontFriend session");let t={accessToken:n.access_token,refreshToken:n.refresh_token,deviceId:n.device_id||e.deviceId,expiresAt:Date.now()+(n.expires_in||900)*1e3,refreshExpiresAt:Date.now()+(n.refresh_expires_in||604800)*1e3,ffApiUrl:o};return ne(t),t}async function Ae(e={}){if(!e.skipCredentials){let o=ee();if(o!=null&&o.accessToken||o!=null&&o.refreshToken){let n=e.baseURL||o.ffApiUrl||Q;return o.accessToken&&!oe(o)?o.accessToken:(await se(o,n)).accessToken}}return e.envToken?e.envToken:e.legacyToken?(e.silent||console.warn("\u26A0\uFE0F auth-token in frontfriend.config.js is deprecated. Run `frontfriend login` to store credentials outside the repo."),e.legacyToken):null}re.exports={getCredentialsPath:Te,readCredentials:ee,writeCredentials:ne,deleteCredentials:Ee,isExpired:oe,postJson:te,refreshCredentials:se,resolveAuthToken:Ae,createAuthRefreshError:O}});var ce=P((Fn,Ie)=>{Ie.exports={name:"@frontfriend/tailwind",version:"4.0.8",description:"Design token management for Tailwind CSS",main:"./dist/index.js",types:"./dist/types/index.d.ts",bin:{frontfriend:"dist/cli.js"},exports:{".":{types:"./dist/types/index.d.ts",browser:"./dist/browser.mjs",import:"./dist/index.mjs",require:"./dist/index.js",default:"./dist/index.js"},"./runtime":{types:"./dist/runtime.d.ts",default:"./dist/runtime.js"},"./next":{types:"./dist/next.d.ts",default:"./dist/next.js"},"./vite":{types:"./dist/vite.d.ts",default:"./dist/vite.mjs"},"./lib/react/utils":{types:"./dist/lib/react/utils.d.ts",default:"./dist/lib/react/utils.mjs"},"./lib/vue/utils":{types:"./dist/lib/vue/utils.d.ts",default:"./dist/lib/vue/utils.mjs"},"./ffdc":{types:"./dist/ffdc.d.ts",default:"./dist/ffdc.js"},"./theme":"./src/theme.css","./theme.css":"./src/theme.css","./components-config-schema":{types:"./dist/components-config-schema.d.ts",require:"./dist/components-config-schema.js",import:"./dist/components-config-schema.js",default:"./dist/components-config-schema.js"}},scripts:{test:"jest",build:"node scripts/build.js",prepublishOnly:"npm run build"},keywords:["tailwindcss","design-tokens","frontfriend"],author:"Donux",license:"SEE LICENSE IN LICENSE",files:["dist/","src/theme.css","scripts/","README.md","LICENSE"],dependencies:{commander:"^11.0.0",dotenv:"^16.0.0",color:"^4.2.3",clsx:"^2.0.0","tailwind-merge":"^2.0.0","tw-animate-css":"^1.3.4"},peerDependencies:{tailwindcss:"^3.0.0 || ^4.0.0",react:"^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",vue:">=3.0.0"},devDependencies:{jest:"^29.0.0",esbuild:"^0.19.0",glob:"^10.0.0"}}});var N=P((bn,U)=>{var j=require("fs"),E=require("path");function ae(e={}){let o=e.projectRoot||process.cwd(),n=E.join(o,"node_modules",".cache","frontfriend","icons.json"),t=e.outputPath||E.join(o,"types","frontfriend.d.ts");j.existsSync(n)||(console.error('[FrontFriend] Error: icons.json not found. Please run "npx frontfriend init" first.'),process.exit(1));try{let c=function(h){for(let C of Object.values(h))typeof C=="string"?f.add(C):typeof C=="object"&&C!==null&&c(C)},a=function(h,C=" "){let w=[];for(let[I,x]of Object.entries(h))typeof x=="string"?w.push(`${C}${I}: '${x}';`):typeof x=="object"&&x!==null&&(w.push(`${C}${I}: {`),w.push(a(x,C+" ")),w.push(`${C}};`));return w.join(`
|
|
4
|
+
`)};var s=c,r=a;let i=JSON.parse(j.readFileSync(n,"utf-8")),f=new Set;c(i);let d=Array.from(f).map(h=>`'${h}'`).join(" | "),l=`// Generated by @frontfriend/tailwind
|
|
5
5
|
// DO NOT EDIT THIS FILE MANUALLY
|
|
6
6
|
|
|
7
7
|
import type { IconSetStructure } from '@frontfriend/tailwind';
|
|
8
8
|
|
|
9
9
|
declare module '@frontfriend/tailwind' {
|
|
10
10
|
// Icon names used in this project
|
|
11
|
-
export type ProjectIconName = ${
|
|
11
|
+
export type ProjectIconName = ${d||"string"};
|
|
12
12
|
|
|
13
13
|
// Typed iconSet structure with exact icon names
|
|
14
14
|
export interface TypedIconSet extends IconSetStructure {
|
|
@@ -18,61 +18,61 @@ ${a(i)}
|
|
|
18
18
|
|
|
19
19
|
// Augment Vue component types with exact icon names
|
|
20
20
|
declare module '*/components/ui/icon/*.vue' {
|
|
21
|
-
export type IconName = ${
|
|
21
|
+
export type IconName = ${d||"string"};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
declare module '@/components/ui/icon/*.vue' {
|
|
25
|
-
export type IconName = ${
|
|
25
|
+
export type IconName = ${d||"string"};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
declare module '@/components/ui/icon' {
|
|
29
|
-
export type IconName = ${
|
|
29
|
+
export type IconName = ${d||"string"};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
declare module '@/src/components/ui/icon' {
|
|
33
|
-
export type IconName = ${
|
|
33
|
+
export type IconName = ${d||"string"};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
declare module '@/src/components/ui/icon/Icon.vue' {
|
|
37
|
-
export type IconName = ${
|
|
37
|
+
export type IconName = ${d||"string"};
|
|
38
38
|
}
|
|
39
|
-
`,
|
|
40
|
-
`)}var
|
|
39
|
+
`,g=E.dirname(t);j.existsSync(g)||j.mkdirSync(g,{recursive:!0}),j.writeFileSync(t,l),console.log("[FrontFriend] \u2713 Generated types at",E.relative(o,t));let y=E.join(o,"tsconfig.json");if(j.existsSync(y)){let h=JSON.parse(j.readFileSync(y,"utf-8"));h.include||(h.include=[]);let C="types/**/*.d.ts";h.include.includes(C)||(h.include.push(C),j.writeFileSync(y,JSON.stringify(h,null,2)),console.log("[FrontFriend] \u2713 Updated tsconfig.json to include generated types"))}}catch(i){console.error("[FrontFriend] Error generating icon types:",i.message),process.exit(1)}}require.main===U&&ae();U.exports={generateIconTypes:ae}});var{loadEnvLocal:Pe}=require("./lib/core/env-utils");Pe();var{Command:Oe}=require("commander"),A=require("./lib/core/config-loader"),L=require("./lib/core/cache-manager"),{APIClient:de}=require("./lib/core/api-client"),{getCredentialsPath:De,writeCredentials:Le,readCredentials:Ue,deleteCredentials:Ne,postJson:R}=ie(),{ComponentDownloader:Re}=require("./lib/core/component-downloader"),Me=require("./lib/core/token-processor"),{ConfigError:k,APIError:Ve,CacheError:G}=require("./lib/core/errors"),u=require("path"),p=require("fs"),{spawn:qe}=require("child_process"),S=new Oe,{version:ue}=ce(),Je="https://registry.frontfriend.dev/r/v4",le='@import "@frontfriend/tailwind/theme.css";';function Ge(e){return(e||process.env.FF_REGISTRY_URL||Je).replace(/\/+$/,"")}function _(e){try{return JSON.parse(p.readFileSync(e,"utf8"))}catch{return null}}function B(e,o){p.mkdirSync(u.dirname(e),{recursive:!0}),p.writeFileSync(e,`${JSON.stringify(o,null,2)}
|
|
40
|
+
`)}var Be=u.join("node_modules",".cache","frontfriend","migrated-components.json");function He(e){let o=_(u.join(e,"package.json"))||{},n={...o.dependencies||{},...o.devDependencies||{}};return n.vue||n["@vitejs/plugin-vue"]?"vue":"react"}function ze(e){let o=_(u.join(e,"package.json"))||{},n={...o.dependencies||{},...o.devDependencies||{}};return n.next||p.existsSync(u.join(e,"next.config.js"))||p.existsSync(u.join(e,"next.config.mjs"))?"next":n.vite||p.existsSync(u.join(e,"vite.config.ts"))||p.existsSync(u.join(e,"vite.config.js"))?"vite":null}function Ye(e,o,n){let t=u.join(e,"components.json");if(!p.existsSync(t))return!1;let s=_(t)||{};s.registries=s.registries||{};let r=`${Ge(n)}/${o}/{name}.json`;return s.registries["@frontfriend"]===r?!1:(s.registries["@frontfriend"]=r,B(t,s),!0)}function Ze(e){let o=u.join(e,"package.json"),n=_(o);return n?(n.dependencies=n.dependencies||{},n.dependencies["@frontfriend/tailwind"]?!1:(n.dependencies["@frontfriend/tailwind"]="^4.0.0",B(o,n),!0)):!1}function Ke(e){let o=u.join(e,"next.config.js");return p.existsSync(o)&&p.readFileSync(o,"utf8").includes("@frontfriend/tailwind/next")?!1:(p.writeFileSync(o,`const frontfriend = require('@frontfriend/tailwind/next');
|
|
41
41
|
|
|
42
42
|
module.exports = frontfriend({});
|
|
43
|
-
`),!0)}function
|
|
43
|
+
`),!0)}function We(e){let o=p.existsSync(u.join(e,"vite.config.ts"))?u.join(e,"vite.config.ts"):u.join(e,"vite.config.js");return p.existsSync(o)&&p.readFileSync(o,"utf8").includes("@frontfriend/tailwind/vite")?!1:(p.writeFileSync(o,`import { defineConfig } from 'vite';
|
|
44
44
|
import frontfriend from '@frontfriend/tailwind/vite';
|
|
45
45
|
|
|
46
46
|
export default defineConfig({
|
|
47
47
|
plugins: [frontfriend()],
|
|
48
48
|
});
|
|
49
|
-
`),!0)}function
|
|
50
|
-
${t}`),{changed:!0,relativePath:n})}function
|
|
51
|
-
`))}function
|
|
49
|
+
`),!0)}function Qe(e){let t=["app/globals.css","src/app/globals.css","styles/globals.css","src/styles/globals.css","src/index.css"].find(r=>p.existsSync(u.join(e,r)))||"app/globals.css",s=u.join(e,t);return p.mkdirSync(u.dirname(s),{recursive:!0}),p.existsSync(s)||p.writeFileSync(s,""),{fullPath:s,relativePath:t}}function Xe(e){let{fullPath:o,relativePath:n}=Qe(e),t=p.readFileSync(o,"utf8");return t.includes(le)?{changed:!1,relativePath:n}:(p.writeFileSync(o,`${le}
|
|
50
|
+
${t}`),{changed:!0,relativePath:n})}function en(e,o={}){let n=u.join(e,"components.json");if(!p.existsSync(n))return{isShadcnProject:!1,changes:[]};let t=He(e),s=ze(e),r=[];Ye(e,t,o.registryUrl)&&r.push(`registered @frontfriend registry for ${t}`),Ze(e)&&r.push("added @frontfriend/tailwind dependency"),s==="next"&&Ke(e)&&r.push("wired Next.js plugin"),s==="vite"&&We(e)&&r.push("wired Vite plugin");let i=Xe(e);return i.changed&&r.push(`imported bundled theme in ${i.relativePath}`),{isShadcnProject:!0,changes:r,framework:t,buildTool:s}}function nn(e){return new Promise(o=>setTimeout(o,e))}function on(e){let o=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",n=process.platform==="win32"?["/c","start","",e]:[e];try{return qe(o,n,{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function tn(e){e.isShadcnProject&&(console.log("\u{1F9E9} shadcn project wiring"),e.changes.length===0?console.log(" \u2713 Already configured"):e.changes.forEach(o=>console.log(` \u2713 ${o}`)),console.log(` Next: npx shadcn add @frontfriend/button
|
|
51
|
+
`))}function sn(e,o){let n=e.indexOf(`${o}:`);if(n===-1)return null;let t=e.indexOf("{",n);if(t===-1)return null;let s=0;for(let r=t;r<e.length;r+=1){let i=e[r];if(i==="{"&&(s+=1),i==="}"&&(s-=1),s===0)return e.slice(t+1,r)}return null}function rn(e){let o={},n=/([A-Za-z0-9_-]+):\s*(['"`])([\s\S]*?)\2/g,t;for(;t=n.exec(e||"");)o[t[1]]=t[3].replace(/\s+/g," ").trim();return o}function cn(e,o){let n=o;for(;/\s|,/.test(e[n]||"");)n+=1;let t=e[n];if(t==='"'||t==="'"||t==="`"){let r=e.indexOf(t,n+1);return r===-1?null:{name:e.slice(n+1,r),end:r+1}}let s=e.slice(n).match(/^([A-Za-z0-9_-]+)/);return s?{name:s[1],end:n+s[1].length}:null}function an(e){let o={},n=0;for(;n<(e||"").length;){let t=cn(e,n);if(!t){n+=1;continue}for(n=t.end;/\s/.test(e[n]||"");)n+=1;if(e[n]!==":")continue;for(n+=1;/\s/.test(e[n]||"");)n+=1;if(e[n]!=="{")continue;let s=0,r=n;for(;n<e.length;n+=1)if(e[n]==="{"&&(s+=1),e[n]==="}"&&(s-=1),s===0){o[t.name]=rn(e.slice(r+1,n)),n+=1;break}}return o}function D(e){return String(e||"").replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}function ln(e){return String(e||"").replace(/-([a-z0-9])/g,(o,n)=>n.toUpperCase())}function fn(e){return String(e||"").replace(/(^|[-_\s]+)([a-z0-9])/g,(o,n,t)=>t.toUpperCase())}function M(e,o,n,t){let s=0,r=null,i=!1;for(let f=o;f<e.length;f+=1){let c=e[f];if(r){i?i=!1:c==="\\"?i=!0:c===r&&(r=null);continue}if(c==='"'||c==="'"||c==="`"){r=c;continue}if(c===n&&(s+=1),c===t&&(s-=1),s===0)return f}return-1}function dn(e){let o=[],n=/(?:export\s+)?function\s+([A-Z][A-Za-z0-9_]*)\s*\(/g,t;for(;t=n.exec(e);){let r=t[1],i=e.indexOf("(",t.index),f=i===-1?-1:M(e,i,"(",")"),c=f===-1?-1:e.indexOf("{",f);if(c===-1)continue;let a=M(e,c,"{","}");a!==-1&&(o.push({name:r,body:e.slice(c,a+1)}),n.lastIndex=a+1)}let s=/(?:export\s+)?const\s+([A-Z][A-Za-z0-9_]*)\s*=/g;for(;t=s.exec(e);){let r=t[1],i=t.index,f=e.slice(i+1).search(/\n(?:export\s+)?(?:const|function)\s+[A-Z][A-Za-z0-9_]*\b|\nexport\s*\{/),c=f===-1?e.length:i+1+f;o.push({name:r,body:e.slice(i,c)})}return o}function ge(e,o){let n=e[o],t="",s=!1;for(let r=o+1;r<e.length;r+=1){let i=e[r];if(s){t+=i,s=!1;continue}if(i==="\\"){s=!0;continue}if(i===n)return{value:t,end:r+1};t+=i}return null}function un(e){let o=[];for(let n=0;n<e.length;n+=1){let t=e[n];if(t!=='"'&&t!=="'"&&t!=="`")continue;let s=ge(e,n);s&&((t!=="`"||!s.value.includes("${"))&&o.push(s.value.replace(/\s+/g," ").trim()),n=s.end-1)}return o.filter(Boolean)}function gn(e,o){let n=o;for(;/\s/.test(e[n]||"");)n+=1;if(e[n]!=="=")return null;for(n+=1;/\s/.test(e[n]||"");)n+=1;if(e[n]==='"'||e[n]==="'"){let t=ge(e,n);return t?{value:t.value,end:t.end}:null}if(e[n]==="{"){let t=M(e,n,"{","}");return t===-1?null:{expression:e.slice(n+1,t),end:t+1}}return null}function pn(e){let o=e.match(/\bdata-slot\s*=\s*(?:"([^"]+)"|'([^']+)'|\{\s*["'`]([^"'`]+)["'`]\s*\})/);return o?o[1]||o[2]||o[3]:null}function mn(e,o,n){let t=D(n),s=D(e||o);if(s===t)return"root";if(s.startsWith(`${t}-`))s=s.slice(t.length+1);else{let r=fn(n);!e&&o.startsWith(r)&&(s=D(o.slice(r.length)))}return s?ln(s):"root"}function hn(e,o){let n={},t=[];for(let s of dn(e)){let r=/\bclassName\s*=/g,i,f=!1;for(;i=r.exec(s.body);){let c=gn(s.body,i.index+9);if(!c){t.push(`${s.name}: unreadable className`);continue}let d=(c.value!==void 0?[c.value]:un(c.expression||"")).join(" ").replace(/\s+/g," ").trim();if(!d){t.push(`${s.name}: dynamic className without literal classes`);continue}let l=s.body.lastIndexOf("<",i.index),g=c.end?s.body.indexOf(">",c.end):-1,y=l===-1?"":s.body.slice(l,g===-1?Math.min(s.body.length,c.end+300):g+1),h=mn(pn(y),s.name,o);n[h]=n[h]?`${n[h]} ${d}`.replace(/\s+/g," ").trim():d,f=!0}!f&&/\bclassName\b/.test(s.body)&&t.push(`${s.name}: className present but no literal classes captured`)}return{slots:n,missed:t}}function V(e,o){let n=e.includes("cva(")&&e.includes("variants:"),t=e.match(/cva\(\s*(['"`])([\s\S]*?)\1\s*,/),s=sn(e,"variants"),r=an(s),i=Object.values(r).some(d=>Object.keys(d).length>0),f=hn(e,o),c={default:"main",outline:"tertiary",destructive:"destructive",secondary:"secondary",ghost:"ghost",link:"link"},a={};if(t&&(a.root=t[2].replace(/\s+/g," ").trim()),i){a.variants={};for(let[d,l]of Object.entries(r)){a.variants[d]={};for(let[g,y]of Object.entries(l)){let h=o==="button"&&d==="variant"&&c[g]||g;a.variants[d][h]=y}}}for(let[d,l]of Object.entries(f.slots))a.slots=a.slots||{},a.slots[d]={root:l};return!n&&Object.keys(f.slots).length===0?{skipped:!0,reason:f.missed.length>0?f.missed.join("; "):`${o} has no cva variants or literal className slots`}:n&&!i&&Object.keys(f.slots).length===0?{skipped:!0,reason:"cva component has no variant class maps or literal className slots"}:{skipped:!1,config:{[o]:a},warnings:f.missed}}function q(...e){return e.reduce((o,n)=>({...o,...n||{}}),{})}function yn(e){let o=require("./lib/core/token-processor"),{mergeComponentsConfig:n}=require("./lib/core/default-config"),t=new o,s=n(e),r=t.extractClassesFromComponentsConfig(s);return{componentsConfig:s,icons:{},safelist:r,classesContent:t.generateClassesContent(r),themeCSS:t.generateThemeCSS({}),metadata:{version:"local-components"}}}function pe(e,o){let n=new L(e),t=n.exists()?n.load()||{}:{},s=q(t.componentsConfig,o),r=yn(s);return n.save({...t,...r,icons:t.icons||{}}),r.componentsConfig}function J(e){return u.basename(e).replace(/\.(tsx|ts|jsx|js|vue)$/,"").replace(/[-_]([a-z])/g,(o,n)=>n.toUpperCase())}var Cn=["tsx","ts","jsx","js","vue"],me=/\.(tsx|ts|jsx|js|vue)$/;function vn(e){let o={};for(let n of["tsconfig.json","tsconfig.app.json","jsconfig.json"]){let t=_(u.join(e,n)),s=t&&t.compilerOptions&&t.compilerOptions.paths;s&&Object.assign(o,s)}return o}function wn(e,o){if(!o)return null;let n=vn(e);for(let[t,s]of Object.entries(n))if(!(!Array.isArray(s)||s.length===0)){if(t.endsWith("/*")){let r=t.slice(0,-1);if(o.startsWith(r)){let i=o.slice(r.length),f=s[0].replace(/\*+$/,"");return u.resolve(e,f,i)}}else if(t===o)return u.resolve(e,s[0])}return o.startsWith("@/")?u.resolve(e,"src",o.slice(2)):u.resolve(e,o)}function Sn(e){let o=_(u.join(e,"components.json")),n=o&&o.aliases&&o.aliases.ui,t=[n?wn(e,n):null,u.join(e,"src","components","ui"),u.join(e,"components","ui")].filter(Boolean);return[...new Set(t)].filter(s=>p.existsSync(s))}function fe(e,o){for(let t of Cn){let s=u.join(e,`${o}.${t}`);if(p.existsSync(s))return s}let n=u.join(e,o);if(p.existsSync(n)&&p.statSync(n).isDirectory()){let t=p.readdirSync(n).filter(i=>me.test(i)),s=t.filter(i=>!/^index\./i.test(i)),r=s.find(i=>i.toLowerCase().startsWith(`${o.toLowerCase()}.`))||s[0]||t.find(i=>/^index\./i.test(i));if(r)return u.join(n,r)}return null}function he(e,o){let n=Sn(e);if(o&&o!=="all"){for(let r of n){let i=fe(r,o);if(i)return[{component:o,inputPath:i}]}return[]}let t=new Set,s=[];for(let r of n)for(let i of p.readdirSync(r,{withFileTypes:!0})){let f,c=null;if(i.isFile()&&me.test(i.name)&&!/^index\./i.test(i.name)?(f=J(i.name),c=u.join(r,i.name)):i.isDirectory()&&(f=J(i.name),c=fe(r,i.name)),!c||!f)continue;let a=f.toLowerCase();t.has(a)||(t.add(a),s.push({component:f,inputPath:c}))}return s}function ye(e){let o={},n=[],t=he(e,"all");for(let{component:s,inputPath:r}of t){let i=V(p.readFileSync(r,"utf8"),s);if(i.skipped){n.push({component:s,reason:i.reason});continue}Object.assign(o,i.config)}return{config:o,skipped:n}}S.name("frontfriend").description("FrontFriend Tailwind CLI - Manage design tokens and cache").version(ue);S.command("login").description("Authenticate FrontFriend CLI with an 8-digit device code").option("--api-url <url>","FrontFriend API URL",process.env.FF_API_URL||"https://app.frontfriend.dev").option("--no-open","Do not open the browser automatically").action(async e=>{try{let o=e.apiUrl.replace(/\/$/,""),n=await R(`${o}/api/auth/device/start`,{}),t=n.interval||5,s=Date.now()+(n.expires_in||600)*1e3;for(console.log("\u{1F510} FrontFriend Login"),console.log(`====================
|
|
52
52
|
`),console.log(`Go to ${n.verification_uri} and enter the code:`),console.log(`
|
|
53
53
|
${n.user_code}
|
|
54
|
-
`),e.open!==!1&&
|
|
55
|
-
`);Date.now()<s;){await
|
|
56
|
-
`);let t=await new
|
|
57
|
-
Please add "ff-id" to your frontfriend.config.js file`,"ff-id");let i=e.tag||t.tag,
|
|
58
|
-
`):
|
|
54
|
+
`),e.open!==!1&&on(n.verification_uri)&&console.log("Opened the browser for you."),console.log(`Waiting for approval...
|
|
55
|
+
`);Date.now()<s;){await nn(t*1e3);let r=await R(`${o}/api/auth/device/poll`,{device_code:n.device_code});if(r.error!=="authorization_pending"){if(r.error==="slow_down"){t=r.interval||t+5;continue}if(r.error)throw new Error(`${r.error}: ${r.error_description||"Authentication failed"}`);if(!r.access_token||!r.refresh_token||!r.device_id)throw new Error("Invalid login response from FrontFriend. Run `frontfriend login` again.");Le({accessToken:r.access_token,refreshToken:r.refresh_token,deviceId:r.device_id,expiresAt:Date.now()+(r.expires_in||900)*1e3,refreshExpiresAt:Date.now()+(r.refresh_expires_in||604800)*1e3,ffApiUrl:o}),console.log("\u2705 Login complete!"),console.log(` Credentials saved to ${De()}`),process.exit(0)}}throw new Error("expired_token: the code has expired, run `frontfriend login` again.")}catch(o){console.error("\u274C Login failed:",o.message),process.exit(1)}});S.command("logout").description("Remove FrontFriend CLI credentials").option("--api-url <url>","FrontFriend API URL",process.env.FF_API_URL||"https://app.frontfriend.dev").action(async e=>{let o=Ue(),n=(e.apiUrl||(o==null?void 0:o.ffApiUrl)||"https://app.frontfriend.dev").replace(/\/$/,"");if(o!=null&&o.accessToken&&(o!=null&&o.deviceId))try{await R(`${n}/api/plugin/logout`,{device_id:o.deviceId},o.accessToken)}catch{}let t=Ne();console.log(t?"\u2705 Logged out. Credentials removed.":"\u2139\uFE0F No stored credentials found."),process.exit(0)});S.command("init").description("Initialize FrontFriend configuration and fetch from API").option("--force","Force refresh even if cache is valid").option("--verbose","Show detailed output including safelist size and token counts").option("--tag <tag>","Fetch specific tag (e.g., dev, next, latest)").option("--version <version>","Fetch specific version (e.g., v1.0.0)").option("--registry-url <url>","Registry base URL for components.json (overrides FF_REGISTRY_URL)").action(async e=>{var o;try{console.log("\u{1F527} FrontFriend Setup"),console.log(`==================
|
|
56
|
+
`);let t=await new A().load(),s=en(t.appRoot,{registryUrl:e.registryUrl}),r=s.isShadcnProject?ye(t.appRoot):{config:{},skipped:[]};if(tn(s),!t.ffId)throw s.isShadcnProject&&(pe(t.appRoot,r.config),console.log("\u2705 Local FrontFriend wiring complete!"),console.log(` Local component config cached (${Object.keys(r.config).length||"default"} component${Object.keys(r.config).length===1?"":"s"}).`),console.log(' Add frontfriend.config.js with "ff-id" later to fetch cloud design tokens.'),process.exit(0)),new k(`ff-id not found in frontfriend.config.js
|
|
57
|
+
Please add "ff-id" to your frontfriend.config.js file`,"ff-id");let i=e.tag||t.tag,f=e.version||t.version;console.log("\u{1F4CB} Configuration loaded"),console.log(` FF_ID: ${t.ffId}`),console.log(` App Root: ${t.appRoot}`),i&&console.log(` Tag: ${i}`),f&&console.log(` Version: ${f}`),console.log("");let c=new L(t.appRoot);!e.force&&c.exists()&&c.isValid()&&(console.log("\u2705 Cache is valid and up to date"),console.log(" Use --force to refresh anyway"),process.exit(0)),console.log("\u{1F50D} Checking cache..."),e.force?console.log(` Force refresh requested
|
|
58
|
+
`):c.exists()?console.log(` Cache expired
|
|
59
59
|
`):console.log(` No cache found
|
|
60
|
-
`),console.log("\u{1F310} Fetching configuration...");let a=new
|
|
60
|
+
`),console.log("\u{1F310} Fetching configuration...");let a=new de(t.ffId,{baseURL:t["api-url"]||t.apiUrl,authToken:t["auth-token"]||t.authToken});(t["api-url"]||t.apiUrl)&&console.log(` Using API URL: ${t["api-url"]||t.apiUrl}`);let d=new Me,l=null;try{l=await a.fetchProcessedTokens({tag:i,version:f,tailwindV4:d.useTailwindV4})}catch(m){console.log(` \u26A0\uFE0F Failed to fetch pre-processed tokens: ${m.message}`)}if(l){if(console.log(" \u2713 Pre-processed tokens fetched from server"),console.log(" \u2713 Skipping local processing"),Object.keys(r.config).length>0&&(l.componentsConfig=q(l.componentsConfig,r.config),console.log(` \u2713 Preserved host component classes for ${Object.keys(r.config).join(", ")}`)),l.versionMetadata){let m=l.versionMetadata;console.log(" \u2139\uFE0F Version Information:"),m.version&&console.log(` Version: ${m.version}`),m.tag&&console.log(` Tag: ${m.tag}`),m.cached!==void 0&&console.log(` From Cache: ${m.cached?"Yes":"No"}`)}if(console.log(""),(!((o=l.tokens)!=null&&o.fontFamily)||Object.keys(l.tokens.fontFamily).length===0)&&(console.log("\u26A0\uFE0F Warning: No font family utilities found"),console.log(" Font classes like font-primary and font-secondary will not be available"),l.globalTokens?console.log(` Global tokens are present - font processor may need to be updated
|
|
61
61
|
`):console.log(` Consider adding font family tokens to your design system
|
|
62
|
-
`)),
|
|
62
|
+
`)),d.useTailwindV4){let m=d.extractClassesFromComponentsConfig(l.componentsConfig),T=[...l.safelist||[],...m||[]];l.safelist=[...new Set(T)].sort(),l.themeCSS||(l.themeCSS=d.generateThemeCSS({variables:l.variables||{},semanticVariables:l.semanticVariables||{},semanticDarkVariables:l.semanticDarkVariables||{},fontFaces:l.fonts||[],keyframes:l.keyframes||{},animations:l.animations||{},custom:l.custom||{}})),(!l.classesContent||Object.keys(r.config).length>0)&&(l.classesContent=d.generateClassesContent(l.safelist))}if(console.log("\u{1F4BE} Saving cache..."),(process.env.FF_VERBOSE==="true"||e.verbose)&&console.log(` Safelist has ${l.safelist?l.safelist.length:0} items`),c.save(l),console.log(` \u2713 Cache saved successfully
|
|
63
63
|
`),console.log("\u2705 Setup complete!"),console.log(" Your FrontFriend configuration has been cached."),console.log(" The Tailwind plugin will now use this cached data."),t.types){console.log(`
|
|
64
|
-
\u{1F524} Generating TypeScript types...`);try{let{generateIconTypes:m}=
|
|
65
|
-
`);let[
|
|
66
|
-
`),console.log("\u2699\uFE0F Processing tokens..."),console.log(" Processing raw token data...");let
|
|
67
|
-
`);let
|
|
68
|
-
`));let
|
|
64
|
+
\u{1F524} Generating TypeScript types...`);try{let{generateIconTypes:m}=N(),T=t.aliases&&t.aliases.types?u.join(t.appRoot,t.aliases.types,"frontfriend.d.ts"):void 0;m({projectRoot:t.appRoot,outputPath:T})}catch(m){console.log(" \u26A0\uFE0F Type generation failed:",m.message),console.log(' Enable type generation in frontfriend.config.js with "types": true')}}process.exit(0)}console.log(` \u2139\uFE0F Pre-processed tokens not available, falling back to local processing
|
|
65
|
+
`);let[g,y,h,C,w,I]=await Promise.all([a.fetchTokens(),a.fetchComponentsConfig(),a.fetchFonts(),a.fetchIcons(),a.fetchVersion(),a.fetchCustomCss()]),x=q(y,r.config);if(console.log(" \u2713 Tokens fetched"),g.global||g.colors||g.semantic||g.semanticDark){let m=[g.global?"global":null,g.colors?"colors":null,g.semantic?"semantic":null,g.semanticDark?"semanticDark":null].filter(Boolean).join(", ");console.log(` (Found: ${m})`)}console.log(" \u2713 Components config fetched"),Object.keys(r.config).length>0&&console.log(` \u2713 Preserved host component classes for ${Object.keys(r.config).join(", ")}`),console.log(" \u2713 Fonts fetched"),console.log(" \u2713 Icons fetched"),console.log(" \u2713 Version fetched"),console.log(` \u2713 Custom CSS fetched
|
|
66
|
+
`),console.log("\u2699\uFE0F Processing tokens..."),console.log(" Processing raw token data...");let v=await d.process({colors:g.colors||g.global,semantic:g.semantic,semanticDark:g.semanticDark,fonts:h,globalTokens:g.global,animations:g.animations,version:w==null?void 0:w.version,ffId:t.ffId,customCss:I});console.log(" \u2713 Colors processed"),console.log(" \u2713 Semantic tokens processed"),v.fontFaces.length>0&&console.log(` \u2713 ${v.fontFaces.length} font faces processed`),Object.keys(v.animations).length>0&&console.log(` \u2713 ${Object.keys(v.animations).length} animations processed`),console.log(`
|
|
67
|
+
`);let Ce=d.extractClassesFromComponentsConfig(x),ve=[...v.safelist||[],...Ce||[]],H=[...new Set(ve)].sort(),z,Y;d.useTailwindV4&&(console.log("\u{1F3A8} Generating Tailwind v4 CSS artifacts..."),z=d.generateThemeCSS(v),Y=d.generateClassesContent(H),console.log(" \u2713 theme.css generated"),console.log(` \u2713 classes.css generated for @source scanning
|
|
68
|
+
`));let $={tokens:v.utilities,variables:v.variables,semanticVariables:v.semanticVariables,semanticDarkVariables:v.semanticDarkVariables,fonts:v.fontFaces,icons:C,componentsConfig:x,keyframes:v.keyframes,animations:v.animations,safelist:H,version:w,metadata:v.metadata,custom:v.custom,themeCSS:z,classesContent:Y};if(console.log("\u{1F4BE} Saving cache..."),(process.env.FF_VERBOSE==="true"||e.verbose)&&(console.log(" Cache data summary:"),console.log(` - Tokens: ${Object.keys($.tokens||{}).length} utilities`),console.log(` - Variables: ${Object.keys($.variables||{}).length} CSS variables`),console.log(` - Semantic variables: ${Object.keys($.semanticVariables||{}).length} semantic variables`),console.log(` - Font faces: ${($.fonts||[]).length} fonts`),console.log(` - Safelist: ${($.safelist||[]).length} safelist classes`)),c.save($),console.log(` \u2713 Cache saved successfully
|
|
69
69
|
`),console.log("\u2705 Setup complete!"),console.log(" Your FrontFriend configuration has been cached."),console.log(" The Tailwind plugin will now use this cached data."),t.types){console.log(`
|
|
70
|
-
\u{1F524} Generating TypeScript types...`);try{let{generateIconTypes:m}=
|
|
71
|
-
`);let o=new
|
|
72
|
-
`),console.log("Package:"),console.log(` Version: ${
|
|
73
|
-
`);let t=await new
|
|
74
|
-
Please add "ff-id" to your frontfriend.config.js file`,"ff-id");let s=new
|
|
70
|
+
\u{1F524} Generating TypeScript types...`);try{let{generateIconTypes:m}=N(),T=t.aliases&&t.aliases.types?u.join(t.appRoot,t.aliases.types,"frontfriend.d.ts"):void 0;m({projectRoot:t.appRoot,outputPath:T})}catch(m){console.log(" \u26A0\uFE0F Type generation failed:",m.message),console.log(' Enable type generation in frontfriend.config.js with "types": true')}}process.exit(0)}catch(n){n instanceof k?console.error("\u274C Configuration Error:",n.message):n instanceof Ve?(console.error("\u274C API Error:",n.message),console.error(` Status: ${n.statusCode}`),console.error(` URL: ${n.url}`)):n instanceof G?(console.error("\u274C Cache Error:",n.message),console.error(` Operation: ${n.operation}`)):console.error("\u274C Setup failed:",n.message),process.exit(1)}});S.command("clean").description("Remove cached configuration").action(async()=>{try{console.log(`\u{1F9F9} Cleaning FrontFriend cache...
|
|
71
|
+
`);let o=new A().load(),n=new L(o.appRoot);n.exists()?(n.clear(),console.log("\u2705 Cache cleared successfully")):console.log("\u2139\uFE0F No cache found"),process.exit(0)}catch(e){e instanceof G?(console.error("\u274C Cache Error:",e.message),console.error(` Operation: ${e.operation}`)):console.error("\u274C Clean failed:",e.message),process.exit(1)}});S.command("status").description("Show cache status and configuration").action(async()=>{try{console.log("\u{1F4CA} FrontFriend Status"),console.log(`===================
|
|
72
|
+
`),console.log("Package:"),console.log(` Version: ${ue}`),console.log("");let o=await new A().load();console.log("Configuration:"),console.log(` FF_ID: ${o.ffId||"Not set"}`),console.log(` App Root: ${o.appRoot}`),o.tag&&console.log(` Tag: ${o.tag}`),o.version&&console.log(` Version: ${o.version}`),console.log("");let n=new L(o.appRoot),t=n.getCacheDir();if(console.log("Cache:"),console.log(` Directory: ${u.relative(process.cwd(),t)}`),n.exists()){console.log(` Status: ${n.isValid()?"\u2705 Valid":"\u26A0\uFE0F Expired"}`);let s=n.load();if(s&&s.metadata){let r=new Date(s.metadata.timestamp);console.log(` Created: ${r.toLocaleString()}`),console.log(` Format Version: ${s.metadata.version||"Unknown"}`)}s&&s.versionMetadata&&(console.log(" Cached Version Info:"),s.versionMetadata.version&&console.log(` Version: ${s.versionMetadata.version}`),s.versionMetadata.tag&&console.log(` Tag: ${s.versionMetadata.tag}`))}else console.log(" Status: \u274C Not found");process.exit(0)}catch(e){e instanceof k?console.error("\u274C Configuration Error:",e.message):e instanceof G?(console.error("\u274C Cache Error:",e.message),console.error(` Operation: ${e.operation}`)):console.error("\u274C Status check failed:",e.message),process.exit(1)}});S.command("migrate").description("Migrate cva-structured shadcn components into FrontFriend config").option("--component <name>",'Component to migrate, or "all" to scan the UI dir',"all").option("--input <path>","Path to the shadcn component source").option("--output <path>","Output JSON path for migrated config",Be).option("--no-push","Do not push migrated config to the configured FrontFriend cloud").action(async e=>{try{let n=await new A().load(),t=n.appRoot,s=e.input&&e.component==="all"?J(e.input):e.component,r;if(e.input){let c=u.resolve(t,e.input);if(!p.existsSync(c))throw new k(`Component source not found: ${u.relative(t,c)}`);let a=p.readFileSync(c,"utf8");r=V(a,s)}else if(s==="all")r=ye(t);else{let c=he(t,s);if(c.length===0)throw new k(`Component source "${s}" not found under components/ui or src/components/ui`,"component");let a=p.readFileSync(c[0].inputPath,"utf8");r=V(a,s)}if(r.skipped===!0||Object.keys(r.config||{}).length===0){let c=r.reason||(Array.isArray(r.skipped)&&r.skipped.length>0?r.skipped.map(a=>`${a.component} (${a.reason})`).join(", "):"no cva-structured components or literal className slots found");console.log(`\u23ED\uFE0F Skipped ${s}: ${c}`),process.exit(0)}let i=u.resolve(t,e.output);B(i,r.config),pe(t,r.config);let f=!1;e.push&&n.ffId&&(await new de(n.ffId,{baseURL:n["api-url"]||n.apiUrl,authToken:n["auth-token"]||n.authToken}).pushComponentsConfig(r.config),f=!0),console.log("\u2705 Migration complete!"),console.log(` Component: ${s==="all"?Object.keys(r.config).join(", "):s}`),console.log(` Output: ${u.relative(t,i)}`),console.log(" Local config: cached for the FrontFriend plugin"),r.skipped&&r.skipped.length>0&&console.log(` Skipped: ${r.skipped.map(c=>`${c.component} (${c.reason})`).join(", ")}`),console.log(f?" Cloud config: pushed user override":" Cloud config: not pushed (missing ff-id or --no-push)"),process.exit(0)}catch(o){o instanceof k?console.error("\u274C Migration Error:",o.message):console.error("\u274C Migration failed:",o.message),process.exit(1)}});S.command("download").description("Download components from registry").argument("<components...>",'component names to download (or "all" to download all components)').option("-f, --framework <framework>","Framework to download components for (react/vue)").option("-o, --output <path>","Output directory for components").option("--registry <generation>","Registry generation to use (legacy/v4)").option("--overwrite","Overwrite existing files").action(async(e,o)=>{try{console.log(`\u{1F4E6} Downloading components...
|
|
73
|
+
`);let t=await new A().load();if(!t.ffId)throw new k(`ff-id not found in frontfriend.config.js
|
|
74
|
+
Please add "ff-id" to your frontfriend.config.js file`,"ff-id");let s=new Re({appRoot:t.appRoot,config:t,framework:o.framework,registryGeneration:o.registry,outputPath:o.output,overwrite:o.overwrite}),r=e;if(e.length===1&&e[0].toLowerCase()==="all"){let f=await s.getAllComponents(),c=await s.getCustomComponents();process.env.FF_DEBUG&&console.log(`Debug: Found ${c.length} custom components: ${c.join(", ")}`),f.length===0&&(console.error("\u274C Failed to fetch component list"),process.exit(1));let a=new Set(c),d=f.filter(l=>!a.has(l));r=[...c,...d],console.log("\u{1F4CB} Configuration"),console.log(` Framework: ${s.framework}`),console.log(` Registry: ${s.registryGeneration}`),console.log(` Output: ${s.outputPath}`),console.log(` Components: All ${r.length} components`),process.env.FF_DEBUG&&c.length>0&&console.log(` Debug: ${c.length} custom components will override standard ones`),console.log("")}else console.log("\u{1F4CB} Configuration"),console.log(` Framework: ${s.framework}`),console.log(` Registry: ${s.registryGeneration}`),console.log(` Output: ${s.outputPath}`),console.log(` Components: ${e.join(", ")}
|
|
75
75
|
`);let i=await s.downloadComponents(r);i.successful.length>0&&(console.log(`
|
|
76
|
-
\u2705 Download complete!`),console.log(` Downloaded: ${i.successful.length} components`)),i.failed.length>0&&(console.log(""),i.failed.forEach(
|
|
77
|
-
\u{1F4E6} Install dependencies:`),console.log(` npm install ${i.dependencies.join(" ")}`)),i.successful.length===0&&i.failed.length>0&&process.exit(1),process.exit(0)}catch(n){n instanceof
|
|
76
|
+
\u2705 Download complete!`),console.log(` Downloaded: ${i.successful.length} components`)),i.failed.length>0&&(console.log(""),i.failed.forEach(f=>{f.error.includes("not found")?console.log(`\u274C ${f.error}`):console.log(`\u274C Failed to download ${f.component}: ${f.error}`)})),i.successful.length>0&&i.dependencies.length>0&&(console.log(`
|
|
77
|
+
\u{1F4E6} Install dependencies:`),console.log(` npm install ${i.dependencies.join(" ")}`)),i.successful.length===0&&i.failed.length>0&&process.exit(1),process.exit(0)}catch(n){n instanceof k?(console.error("\u274C Configuration Error:",n.message),n.missingKey&&console.error(` Missing key: ${n.missingKey}`)):console.error("\u274C Download failed:",n.message),process.exit(1)}});S.parse(process.argv);process.argv.slice(2).length||(S.outputHelp(),process.exit(0));
|
|
78
78
|
//# sourceMappingURL=cli-temp.js.map
|