@frontfriend/tailwind 2.1.5 → 2.1.6
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
CHANGED
|
@@ -1,62 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`)};var
|
|
2
|
+
var D=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var v=D((q,x)=>{var u=require("fs"),$=require("path");function P(s={}){let e=s.projectRoot||process.cwd(),o=$.join(e,"node_modules",".cache","frontfriend","icons.json"),i=s.outputPath||$.join(e,"types","frontfriend.d.ts");u.existsSync(o)||(console.error('[FrontFriend] Error: icons.json not found. Please run "npx frontfriend setup" first.'),process.exit(1));try{let p=function(f){for(let c of Object.values(f))typeof c=="string"?l.add(c):typeof c=="object"&&c!==null&&p(c)},y=function(f,c=" "){let a=[];for(let[h,C]of Object.entries(f))typeof C=="string"?a.push(`${c}${h}: '${C}';`):typeof C=="object"&&C!==null&&(a.push(`${c}${h}: {`),a.push(y(C,c+" ")),a.push(`${c}};`));return a.join(`
|
|
3
|
+
`)};var t=p,d=y;let n=JSON.parse(u.readFileSync(o,"utf-8")),l=new Set;p(n);let g=Array.from(l).map(f=>`'${f}'`).join(" | "),S=`// Generated by @frontfriend/tailwind
|
|
4
4
|
// DO NOT EDIT THIS FILE MANUALLY
|
|
5
5
|
|
|
6
6
|
import type { IconSetStructure } from '@frontfriend/tailwind';
|
|
7
7
|
|
|
8
8
|
declare module '@frontfriend/tailwind' {
|
|
9
9
|
// Icon names used in this project
|
|
10
|
-
export type ProjectIconName = ${
|
|
10
|
+
export type ProjectIconName = ${g||"string"};
|
|
11
11
|
|
|
12
12
|
// Typed iconSet structure with exact icon names
|
|
13
13
|
export interface TypedIconSet extends IconSetStructure {
|
|
14
|
-
${
|
|
14
|
+
${y(n)}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// Augment Vue component types with exact icon names
|
|
19
19
|
declare module '*/components/ui/icon/*.vue' {
|
|
20
|
-
export type IconName = ${
|
|
20
|
+
export type IconName = ${g||"string"};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
declare module '@/components/ui/icon/*.vue' {
|
|
24
|
-
export type IconName = ${
|
|
24
|
+
export type IconName = ${g||"string"};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
declare module '@/components/ui/icon' {
|
|
28
|
-
export type IconName = ${
|
|
28
|
+
export type IconName = ${g||"string"};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
declare module '@/src/components/ui/icon' {
|
|
32
|
-
export type IconName = ${
|
|
32
|
+
export type IconName = ${g||"string"};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
declare module '@/src/components/ui/icon/Icon.vue' {
|
|
36
|
-
export type IconName = ${
|
|
36
|
+
export type IconName = ${g||"string"};
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
`);let o=await new
|
|
38
|
+
`,w=$.dirname(i);u.existsSync(w)||u.mkdirSync(w,{recursive:!0}),u.writeFileSync(i,S),console.log("[FrontFriend] \u2713 Generated types at",$.relative(e,i));let r=$.join(e,"tsconfig.json");if(u.existsSync(r)){let f=JSON.parse(u.readFileSync(r,"utf-8"));f.include||(f.include=[]);let c="types/**/*.d.ts";f.include.includes(c)||(f.include.push(c),u.writeFileSync(r,JSON.stringify(f,null,2)),console.log("[FrontFriend] \u2713 Updated tsconfig.json to include generated types"))}}catch(n){console.error("[FrontFriend] Error generating icon types:",n.message),process.exit(1)}}require.main===x&&P();x.exports={generateIconTypes:P}});var{Command:T}=require("commander"),F=require("./lib/config/config-loader"),b=require("./lib/config/cache-manager"),{APIClient:R}=require("./lib/core/api-client"),{ComponentDownloader:O}=require("./lib/core/component-downloader"),E=require("./lib/core/token-processor"),{ConfigError:k,APIError:L,CacheError:j}=require("./lib/core/errors"),I=require("path"),m=new T;m.name("frontfriend").description("FrontFriend Tailwind CLI - Manage design tokens and cache").version("2.0.0");m.command("init").description("Initialize FrontFriend configuration and fetch from API").option("--force","Force refresh even if cache is valid").action(async s=>{try{console.log("\u{1F527} FrontFriend Setup"),console.log(`==================
|
|
39
|
+
`);let o=await new F().load();if(!o.ffId)throw new k(`ff-id not found in frontfriend.config.js
|
|
40
40
|
Please add "ff-id" to your frontfriend.config.js file`,"ff-id");console.log("\u{1F4CB} Configuration loaded"),console.log(` FF_ID: ${o.ffId}`),console.log(` App Root: ${o.appRoot}
|
|
41
|
-
`);let
|
|
42
|
-
`):
|
|
41
|
+
`);let i=new b(o.appRoot);!s.force&&i.exists()&&i.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..."),s.force?console.log(` Force refresh requested
|
|
42
|
+
`):i.exists()?console.log(` Cache expired
|
|
43
43
|
`):console.log(` No cache found
|
|
44
|
-
`),console.log("\u{1F310} Fetching configuration...");let
|
|
45
|
-
`),console.log("\u{1F4BE} Saving cache..."),
|
|
46
|
-
`),console.log("\u2705 Setup complete!"),console.log(" Your FrontFriend configuration has been cached."),console.log(" The Tailwind plugin will now use this cached data.")
|
|
47
|
-
\u{1F524} Generating TypeScript types...`);try{let{generateIconTypes:
|
|
48
|
-
`);let[
|
|
49
|
-
`),console.log("\u2699\uFE0F Processing tokens...");let w=new
|
|
50
|
-
`);let
|
|
51
|
-
`),console.log("\u2705 Setup complete!"),console.log(" Your FrontFriend configuration has been cached."),console.log(" The Tailwind plugin will now use this cached data.")
|
|
52
|
-
\u{1F524} Generating TypeScript types...`);try{let{generateIconTypes:
|
|
53
|
-
`);let
|
|
54
|
-
`);let
|
|
55
|
-
`);let
|
|
56
|
-
`);let
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
`)
|
|
60
|
-
\
|
|
61
|
-
\u{1F4E6} Install dependencies:`),console.log(` npm install ${s.dependencies.join(" ")}`)),s.successful.length===0&&s.failed.length>0&&process.exit(1),process.exit(0)}catch(o){o instanceof C?(console.error("\u274C Configuration Error:",o.message),o.missingKey&&console.error(` Missing key: ${o.missingKey}`)):console.error("\u274C Download failed:",o.message),process.exit(1)}});m.parse(process.argv);process.argv.slice(2).length||(m.outputHelp(),process.exit(0));
|
|
44
|
+
`),console.log("\u{1F310} Fetching configuration...");let t=new R(o.ffId,{baseURL:o["api-url"]||o.apiUrl});(o["api-url"]||o.apiUrl)&&console.log(` Using API URL: ${o["api-url"]||o.apiUrl}`);let d=null;try{d=await t.fetchProcessedTokens()}catch(a){console.log(` \u26A0\uFE0F Failed to fetch pre-processed tokens: ${a.message}`)}if(d){if(console.log(" \u2713 Pre-processed tokens fetched from server"),console.log(` \u2713 Skipping local processing
|
|
45
|
+
`),console.log("\u{1F4BE} Saving cache..."),i.save(d),console.log(` \u2713 Cache saved successfully
|
|
46
|
+
`),console.log("\u2705 Setup complete!"),console.log(" Your FrontFriend configuration has been cached."),console.log(" The Tailwind plugin will now use this cached data."),o.types){console.log(`
|
|
47
|
+
\u{1F524} Generating TypeScript types...`);try{let{generateIconTypes:a}=v(),h=o.aliases&&o.aliases.types?I.join(o.appRoot,o.aliases.types,"frontfriend.d.ts"):void 0;a({projectRoot:o.appRoot,outputPath:h})}catch(a){console.log(" \u26A0\uFE0F Type generation failed:",a.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
|
|
48
|
+
`);let[n,l,p,y,g,S]=await Promise.all([t.fetchTokens(),t.fetchComponentsConfig(),t.fetchFonts(),t.fetchIcons(),t.fetchVersion(),t.fetchCustomCss()]);if(console.log(" \u2713 Tokens fetched"),n.global||n.colors||n.semantic||n.semanticDark){let a=[n.global?"global":null,n.colors?"colors":null,n.semantic?"semantic":null,n.semanticDark?"semanticDark":null].filter(Boolean).join(", ");console.log(` (Found: ${a})`)}console.log(" \u2713 Components config fetched"),console.log(" \u2713 Fonts fetched"),console.log(" \u2713 Icons fetched"),console.log(" \u2713 Version fetched"),console.log(` \u2713 Custom CSS fetched
|
|
49
|
+
`),console.log("\u2699\uFE0F Processing tokens...");let w=new E;console.log(" Processing raw token data...");let r=await w.process({colors:n.colors||n.global,semantic:n.semantic,semanticDark:n.semanticDark,fonts:p,globalTokens:n.global,animations:n.animations,version:g==null?void 0:g.version,ffId:o.ffId,customCss:S});console.log(" \u2713 Colors processed"),console.log(" \u2713 Semantic tokens processed"),r.fontFaces.length>0&&console.log(` \u2713 ${r.fontFaces.length} font faces processed`),Object.keys(r.animations).length>0&&console.log(` \u2713 ${Object.keys(r.animations).length} animations processed`),console.log(`
|
|
50
|
+
`);let f=w.extractClassesFromComponentsConfig(l),c={tokens:r.utilities,variables:r.variables,semanticVariables:r.semanticVariables,semanticDarkVariables:r.semanticDarkVariables,fonts:r.fontFaces,icons:y,componentsConfig:l,keyframes:r.keyframes,animations:r.animations,safelist:r.safelist,version:g,metadata:r.metadata,cls:f||[],custom:r.custom};if(console.log("\u{1F4BE} Saving cache..."),console.log(" Cache data summary:"),console.log(` - Tokens: ${Object.keys(c.tokens||{}).length} utilities`),console.log(` - Variables: ${Object.keys(c.variables||{}).length} CSS variables`),console.log(` - Semantic variables: ${Object.keys(c.semanticVariables||{}).length} semantic variables`),console.log(` - Font faces: ${(c.fonts||[]).length} fonts`),console.log(` - Classes: ${(c.cls||[]).length} extracted classes`),i.save(c),console.log(` \u2713 Cache saved successfully
|
|
51
|
+
`),console.log("\u2705 Setup complete!"),console.log(" Your FrontFriend configuration has been cached."),console.log(" The Tailwind plugin will now use this cached data."),o.types){console.log(`
|
|
52
|
+
\u{1F524} Generating TypeScript types...`);try{let{generateIconTypes:a}=v(),h=o.aliases&&o.aliases.types?I.join(o.appRoot,o.aliases.types,"frontfriend.d.ts"):void 0;a({projectRoot:o.appRoot,outputPath:h})}catch(a){console.log(" \u26A0\uFE0F Type generation failed:",a.message),console.log(' Enable type generation in frontfriend.config.js with "types": true')}}process.exit(0)}catch(e){e instanceof k?console.error("\u274C Configuration Error:",e.message):e instanceof L?(console.error("\u274C API Error:",e.message),console.error(` Status: ${e.statusCode}`),console.error(` URL: ${e.url}`)):e instanceof j?(console.error("\u274C Cache Error:",e.message),console.error(` Operation: ${e.operation}`)):console.error("\u274C Setup failed:",e.message),process.exit(1)}});m.command("clean").description("Remove cached configuration").action(async()=>{try{console.log(`\u{1F9F9} Cleaning FrontFriend cache...
|
|
53
|
+
`);let e=new F().load(),o=new b(e.appRoot);o.exists()?(o.clear(),console.log("\u2705 Cache cleared successfully")):console.log("\u2139\uFE0F No cache found"),process.exit(0)}catch(s){s instanceof j?(console.error("\u274C Cache Error:",s.message),console.error(` Operation: ${s.operation}`)):console.error("\u274C Clean failed:",s.message),process.exit(1)}});m.command("status").description("Show cache status and configuration").action(async()=>{try{console.log("\u{1F4CA} FrontFriend Status"),console.log(`===================
|
|
54
|
+
`);let e=await new F().load();console.log("Configuration:"),console.log(` FF_ID: ${e.ffId||"Not set"}`),console.log(` App Root: ${e.appRoot}
|
|
55
|
+
`);let o=new b(e.appRoot),i=o.getCacheDir();if(console.log("Cache:"),console.log(` Directory: ${I.relative(process.cwd(),i)}`),o.exists()){console.log(` Status: ${o.isValid()?"\u2705 Valid":"\u26A0\uFE0F Expired"}`);let t=o.load();if(t&&t.metadata){let d=new Date(t.metadata.timestamp);console.log(` Created: ${d.toLocaleString()}`),console.log(` Version: ${t.metadata.version||"Unknown"}`)}}else console.log(" Status: \u274C Not found");process.exit(0)}catch(s){s instanceof k?console.error("\u274C Configuration Error:",s.message):s instanceof j?(console.error("\u274C Cache Error:",s.message),console.error(` Operation: ${s.operation}`)):console.error("\u274C Status check failed:",s.message),process.exit(1)}});m.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("--overwrite","Overwrite existing files").action(async(s,e)=>{try{console.log(`\u{1F4E6} Downloading components...
|
|
56
|
+
`);let i=await new F().load();if(!i.ffId)throw new k(`ff-id not found in frontfriend.config.js
|
|
57
|
+
Please add "ff-id" to your frontfriend.config.js file`,"ff-id");let t=new O({appRoot:i.appRoot,config:i,framework:e.framework,outputPath:e.output,overwrite:e.overwrite}),d=s;if(s.length===1&&s[0].toLowerCase()==="all"){let l=await t.getAllComponents(),p=await t.getCustomComponents();l.length===0&&(console.error("\u274C Failed to fetch component list"),process.exit(1)),d=[...l,...p],console.log("\u{1F4CB} Configuration"),console.log(` Framework: ${t.framework}`),console.log(` Output: ${t.outputPath}`),console.log(` Components: All ${l.length} standard components`),p.length>0&&console.log(` Custom: ${p.length} custom components for ff-id: ${i.ffId||i["ff-id"]}`),console.log("")}else console.log("\u{1F4CB} Configuration"),console.log(` Framework: ${t.framework}`),console.log(` Output: ${t.outputPath}`),console.log(` Components: ${s.join(", ")}
|
|
58
|
+
`);let n=await t.downloadComponents(d);n.successful.length>0&&(console.log(`
|
|
59
|
+
\u2705 Download complete!`),console.log(` Downloaded: ${n.successful.length} components`)),n.failed.length>0&&(console.log(""),n.failed.forEach(l=>{l.error.includes("not found")?console.log(`\u274C ${l.error}`):console.log(`\u274C Failed to download ${l.component}: ${l.error}`)})),n.successful.length>0&&n.dependencies.length>0&&(console.log(`
|
|
60
|
+
\u{1F4E6} Install dependencies:`),console.log(` npm install ${n.dependencies.join(" ")}`)),n.successful.length===0&&n.failed.length>0&&process.exit(1),process.exit(0)}catch(o){o instanceof k?(console.error("\u274C Configuration Error:",o.message),o.missingKey&&console.error(` Missing key: ${o.missingKey}`)):console.error("\u274C Download failed:",o.message),process.exit(1)}});m.parse(process.argv);process.argv.slice(2).length||(m.outputHelp(),process.exit(0));
|
|
62
61
|
//# sourceMappingURL=cli-temp.js.map
|
|
@@ -8,10 +8,10 @@ const path = require('path');
|
|
|
8
8
|
* This script reads the icons.json file and generates proper types for the iconSet
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
function generateIconTypes() {
|
|
12
|
-
const projectRoot = process.cwd();
|
|
11
|
+
function generateIconTypes(options = {}) {
|
|
12
|
+
const projectRoot = options.projectRoot || process.cwd();
|
|
13
13
|
const iconsPath = path.join(projectRoot, 'node_modules', '.cache', 'frontfriend', 'icons.json');
|
|
14
|
-
const outputPath = path.join(projectRoot, 'types', 'frontfriend
|
|
14
|
+
const outputPath = options.outputPath || path.join(projectRoot, 'types', 'frontfriend.d.ts');
|
|
15
15
|
|
|
16
16
|
// Check if icons.json exists
|
|
17
17
|
if (!fs.existsSync(iconsPath)) {
|
|
@@ -104,7 +104,7 @@ declare module '@/src/components/ui/icon/Icon.vue' {
|
|
|
104
104
|
// Write the type definition file
|
|
105
105
|
fs.writeFileSync(outputPath, typeDefinition);
|
|
106
106
|
|
|
107
|
-
console.log('[FrontFriend] ✓ Generated
|
|
107
|
+
console.log('[FrontFriend] ✓ Generated types at', path.relative(projectRoot, outputPath));
|
|
108
108
|
|
|
109
109
|
// Check if tsconfig.json exists and update it
|
|
110
110
|
const tsconfigPath = path.join(projectRoot, 'tsconfig.json');
|
package/package.json
CHANGED
|
@@ -8,10 +8,10 @@ const path = require('path');
|
|
|
8
8
|
* This script reads the icons.json file and generates proper types for the iconSet
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
function generateIconTypes() {
|
|
12
|
-
const projectRoot = process.cwd();
|
|
11
|
+
function generateIconTypes(options = {}) {
|
|
12
|
+
const projectRoot = options.projectRoot || process.cwd();
|
|
13
13
|
const iconsPath = path.join(projectRoot, 'node_modules', '.cache', 'frontfriend', 'icons.json');
|
|
14
|
-
const outputPath = path.join(projectRoot, 'types', 'frontfriend
|
|
14
|
+
const outputPath = options.outputPath || path.join(projectRoot, 'types', 'frontfriend.d.ts');
|
|
15
15
|
|
|
16
16
|
// Check if icons.json exists
|
|
17
17
|
if (!fs.existsSync(iconsPath)) {
|
|
@@ -104,7 +104,7 @@ declare module '@/src/components/ui/icon/Icon.vue' {
|
|
|
104
104
|
// Write the type definition file
|
|
105
105
|
fs.writeFileSync(outputPath, typeDefinition);
|
|
106
106
|
|
|
107
|
-
console.log('[FrontFriend] ✓ Generated
|
|
107
|
+
console.log('[FrontFriend] ✓ Generated types at', path.relative(projectRoot, outputPath));
|
|
108
108
|
|
|
109
109
|
// Check if tsconfig.json exists and update it
|
|
110
110
|
const tsconfigPath = path.join(projectRoot, 'tsconfig.json');
|