@foundrykit/cli 1.0.9 → 1.0.10
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/CHANGELOG.md +8 -0
- package/dist/cli.js +108 -40
- package/dist/cli.js.map +1 -1
- package/dist/index.js +108 -40
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/add.ts +125 -39
- package/src/commands/init.ts +37 -16
- package/components.json +0 -20
package/src/commands/add.ts
CHANGED
|
@@ -476,48 +476,116 @@ async function loadConfig(): Promise<any> {
|
|
|
476
476
|
function transformImportsForConfig(content: string, config: any): string {
|
|
477
477
|
let transformed = content;
|
|
478
478
|
|
|
479
|
-
//
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
-
|
|
479
|
+
// Ensure config.paths exists with fallbacks
|
|
480
|
+
const paths = config?.paths || {
|
|
481
|
+
primitives: 'components/primitives',
|
|
482
|
+
components: 'components',
|
|
483
|
+
blocks: 'components/blocks',
|
|
484
|
+
animations: 'components/animations',
|
|
485
|
+
utils: 'lib/utils',
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
// Transform imports using regex to capture component names and build proper paths
|
|
489
|
+
// Handle @/components/primitives imports
|
|
483
490
|
transformed = transformed.replace(
|
|
484
|
-
|
|
485
|
-
|
|
491
|
+
/import\s+{([^}]+)}\s+from\s+["']@\/components\/primitives["']/g,
|
|
492
|
+
(match, imports) => {
|
|
493
|
+
const componentNames = imports.split(',').map(
|
|
494
|
+
(imp: string) =>
|
|
495
|
+
imp
|
|
496
|
+
?.trim()
|
|
497
|
+
.split(/\s+as\s+/)[0]
|
|
498
|
+
?.trim() || ''
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
const primitivesPath = paths.primitives
|
|
502
|
+
.replace(/^\.\//, '')
|
|
503
|
+
.replace(/\/$/, '');
|
|
504
|
+
|
|
505
|
+
return `import {${imports}} from "@/${primitivesPath}/${componentNames[0].toLowerCase()}"`;
|
|
506
|
+
}
|
|
486
507
|
);
|
|
487
508
|
|
|
488
|
-
//
|
|
509
|
+
// Handle @/components/ui imports (legacy, maps to primitives)
|
|
489
510
|
transformed = transformed.replace(
|
|
490
|
-
|
|
491
|
-
|
|
511
|
+
/import\s+{([^}]+)}\s+from\s+["']@\/components\/ui["']/g,
|
|
512
|
+
(match, imports) => {
|
|
513
|
+
const componentNames = imports.split(',').map(
|
|
514
|
+
(imp: string) =>
|
|
515
|
+
imp
|
|
516
|
+
?.trim()
|
|
517
|
+
.split(/\s+as\s+/)[0]
|
|
518
|
+
?.trim() || ''
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
const primitivesPath = paths.primitives
|
|
522
|
+
.replace(/^\.\//, '')
|
|
523
|
+
.replace(/\/$/, '');
|
|
524
|
+
|
|
525
|
+
return `import {${imports}} from "@/${primitivesPath}/${componentNames[0].toLowerCase()}"`;
|
|
526
|
+
}
|
|
492
527
|
);
|
|
493
528
|
|
|
494
|
-
//
|
|
495
|
-
const componentsPath = config.paths.components
|
|
496
|
-
.replace(/^\.\//, '')
|
|
497
|
-
.replace(/\/$/, '');
|
|
529
|
+
// Handle @/components/components imports
|
|
498
530
|
transformed = transformed.replace(
|
|
499
|
-
|
|
500
|
-
|
|
531
|
+
/import\s+{([^}]+)}\s+from\s+["']@\/components\/components["']/g,
|
|
532
|
+
(match, imports) => {
|
|
533
|
+
const componentNames = imports.split(',').map(
|
|
534
|
+
(imp: string) =>
|
|
535
|
+
imp
|
|
536
|
+
?.trim()
|
|
537
|
+
.split(/\s+as\s+/)[0]
|
|
538
|
+
?.trim() || ''
|
|
539
|
+
);
|
|
540
|
+
|
|
541
|
+
const componentsPath = paths.components
|
|
542
|
+
.replace(/^\.\//, '')
|
|
543
|
+
.replace(/\/$/, '');
|
|
544
|
+
|
|
545
|
+
return `import {${imports}} from "@/${componentsPath}/${componentNames[0].toLowerCase()}"`;
|
|
546
|
+
}
|
|
501
547
|
);
|
|
502
548
|
|
|
503
|
-
|
|
504
|
-
.replace(/^\.\//, '')
|
|
505
|
-
.replace(/\/$/, '');
|
|
549
|
+
// Handle @/components/blocks imports
|
|
506
550
|
transformed = transformed.replace(
|
|
507
|
-
|
|
508
|
-
|
|
551
|
+
/import\s+{([^}]+)}\s+from\s+["']@\/components\/blocks["']/g,
|
|
552
|
+
(match, imports) => {
|
|
553
|
+
const componentNames = imports.split(',').map(
|
|
554
|
+
(imp: string) =>
|
|
555
|
+
imp
|
|
556
|
+
?.trim()
|
|
557
|
+
.split(/\s+as\s+/)[0]
|
|
558
|
+
?.trim() || ''
|
|
559
|
+
);
|
|
560
|
+
|
|
561
|
+
const blocksPath = paths.blocks.replace(/^\.\//, '').replace(/\/$/, '');
|
|
562
|
+
|
|
563
|
+
return `import {${imports}} from "@/${blocksPath}/${componentNames[0].toLowerCase()}"`;
|
|
564
|
+
}
|
|
509
565
|
);
|
|
510
566
|
|
|
511
|
-
|
|
512
|
-
.replace(/^\.\//, '')
|
|
513
|
-
.replace(/\/$/, '');
|
|
567
|
+
// Handle @/components/animations imports
|
|
514
568
|
transformed = transformed.replace(
|
|
515
|
-
|
|
516
|
-
|
|
569
|
+
/import\s+{([^}]+)}\s+from\s+["']@\/components\/animations["']/g,
|
|
570
|
+
(match, imports) => {
|
|
571
|
+
const componentNames = imports.split(',').map(
|
|
572
|
+
(imp: string) =>
|
|
573
|
+
imp
|
|
574
|
+
?.trim()
|
|
575
|
+
.split(/\s+as\s+/)[0]
|
|
576
|
+
?.trim() || ''
|
|
577
|
+
);
|
|
578
|
+
|
|
579
|
+
const animationsPath = paths.animations
|
|
580
|
+
.replace(/^\.\//, '')
|
|
581
|
+
.replace(/\/$/, '');
|
|
582
|
+
|
|
583
|
+
return `import {${imports}} from "@/${animationsPath}/${componentNames[0].toLowerCase()}"`;
|
|
584
|
+
}
|
|
517
585
|
);
|
|
518
586
|
|
|
519
587
|
// Handle utils imports
|
|
520
|
-
const utilsPath =
|
|
588
|
+
const utilsPath = paths.utils
|
|
521
589
|
.replace(/^\.\//, '')
|
|
522
590
|
.replace(/\/$/, '')
|
|
523
591
|
.replace(/\.(ts|js)$/, '');
|
|
@@ -534,13 +602,22 @@ function resolveComponentPath(
|
|
|
534
602
|
category: ComponentCategory,
|
|
535
603
|
config: any
|
|
536
604
|
): string {
|
|
605
|
+
// Ensure config.paths exists with fallbacks
|
|
606
|
+
const paths = config?.paths || {
|
|
607
|
+
primitives: 'components/primitives',
|
|
608
|
+
components: 'components',
|
|
609
|
+
blocks: 'components/blocks',
|
|
610
|
+
animations: 'components/animations',
|
|
611
|
+
utils: 'lib/utils',
|
|
612
|
+
};
|
|
613
|
+
|
|
537
614
|
// Special handling for utils files - they should go directly to lib/utils.ts
|
|
538
615
|
if (originalPath === 'lib/utils.ts') {
|
|
539
|
-
return
|
|
616
|
+
return paths.utils || 'lib/utils.ts';
|
|
540
617
|
}
|
|
541
618
|
|
|
542
619
|
// Get the base path for the category from config
|
|
543
|
-
const categoryPath =
|
|
620
|
+
const categoryPath = paths[category] || paths.components;
|
|
544
621
|
|
|
545
622
|
// Extract just the filename from the original path
|
|
546
623
|
const fileName = path.basename(originalPath);
|
|
@@ -550,17 +627,16 @@ function resolveComponentPath(
|
|
|
550
627
|
if (category === 'primitives') {
|
|
551
628
|
return path.join(categoryPath, componentName, fileName);
|
|
552
629
|
} else if (category === 'components') {
|
|
553
|
-
return path.join(
|
|
630
|
+
return path.join(paths.components, componentName, fileName);
|
|
554
631
|
} else if (category === 'blocks') {
|
|
555
632
|
return path.join(
|
|
556
|
-
|
|
633
|
+
paths.blocks || path.join(paths.components, 'blocks'),
|
|
557
634
|
componentName,
|
|
558
635
|
fileName
|
|
559
636
|
);
|
|
560
637
|
} else if (category === 'animations') {
|
|
561
638
|
return path.join(
|
|
562
|
-
|
|
563
|
-
path.join(config.paths.components, 'animations'),
|
|
639
|
+
paths.animations || path.join(paths.components, 'animations'),
|
|
564
640
|
componentName,
|
|
565
641
|
fileName
|
|
566
642
|
);
|
|
@@ -574,25 +650,35 @@ function resolveComponentPath(
|
|
|
574
650
|
* Get import path for a component
|
|
575
651
|
*/
|
|
576
652
|
function getImportPath(componentData: ComponentData, config: any): string {
|
|
577
|
-
|
|
653
|
+
// Ensure config.paths exists with fallbacks
|
|
654
|
+
const paths = config?.paths || {
|
|
655
|
+
primitives: 'components/primitives',
|
|
656
|
+
components: 'components',
|
|
657
|
+
blocks: 'components/blocks',
|
|
658
|
+
animations: 'components/animations',
|
|
659
|
+
utils: 'lib/utils',
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
const componentName = path.basename(
|
|
663
|
+
componentData.files[0]?.path || '',
|
|
664
|
+
'.tsx'
|
|
665
|
+
);
|
|
578
666
|
|
|
579
667
|
if (componentData.category === 'primitives') {
|
|
580
|
-
const primitivesPath =
|
|
668
|
+
const primitivesPath = paths.primitives
|
|
581
669
|
.replace(/^\.\//, '')
|
|
582
670
|
.replace(/\/$/, '');
|
|
583
671
|
return `@/${primitivesPath}/${componentName}`;
|
|
584
672
|
} else if (componentData.category === 'components') {
|
|
585
|
-
const componentsPath =
|
|
673
|
+
const componentsPath = paths.components
|
|
586
674
|
.replace(/^\.\//, '')
|
|
587
675
|
.replace(/\/$/, '');
|
|
588
676
|
return `@/${componentsPath}/${componentName}`;
|
|
589
677
|
} else if (componentData.category === 'blocks') {
|
|
590
|
-
const blocksPath =
|
|
591
|
-
.replace(/^\.\//, '')
|
|
592
|
-
.replace(/\/$/, '');
|
|
678
|
+
const blocksPath = paths.blocks.replace(/^\.\//, '').replace(/\/$/, '');
|
|
593
679
|
return `@/${blocksPath}/${componentName}`;
|
|
594
680
|
} else if (componentData.category === 'animations') {
|
|
595
|
-
const animationsPath =
|
|
681
|
+
const animationsPath = paths.animations
|
|
596
682
|
.replace(/^\.\//, '')
|
|
597
683
|
.replace(/\/$/, '');
|
|
598
684
|
return `@/${animationsPath}/${componentName}`;
|
package/src/commands/init.ts
CHANGED
|
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
|
-
import { exec
|
|
6
|
+
import { exec } from 'child_process';
|
|
7
7
|
import { promisify } from 'util';
|
|
8
8
|
import { CLI_VERSION, DEFAULT_REGISTRY_URL } from '../lib/constants.js';
|
|
9
9
|
|
|
@@ -91,6 +91,8 @@ export function initCommand() {
|
|
|
91
91
|
await installDependencies();
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
console.log(pathConfig);
|
|
95
|
+
|
|
94
96
|
// Create configuration file with custom paths
|
|
95
97
|
await createConfigFile(options, projectStructure, pathConfig);
|
|
96
98
|
|
|
@@ -790,17 +792,26 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
790
792
|
`theme-provider${structure.isTypeScript ? '.tsx' : '.jsx'}`
|
|
791
793
|
);
|
|
792
794
|
|
|
793
|
-
const providersContent = `
|
|
795
|
+
const providersContent = `
|
|
796
|
+
'use client';
|
|
794
797
|
|
|
795
|
-
import
|
|
798
|
+
import type * as React from 'react';
|
|
799
|
+
import { ThemeProvider as NextThemesProvider } from 'next-themes';
|
|
796
800
|
|
|
797
801
|
export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
|
798
802
|
return (
|
|
799
|
-
<
|
|
803
|
+
<NextThemesProvider
|
|
804
|
+
attribute='class'
|
|
805
|
+
defaultTheme='system'
|
|
806
|
+
enableSystem
|
|
807
|
+
disableTransitionOnChange
|
|
808
|
+
enableColorScheme
|
|
809
|
+
>
|
|
800
810
|
{children}
|
|
801
|
-
</
|
|
811
|
+
</NextThemesProvider>
|
|
802
812
|
);
|
|
803
813
|
}
|
|
814
|
+
|
|
804
815
|
`;
|
|
805
816
|
|
|
806
817
|
if (!fs.existsSync(providersPath)) {
|
|
@@ -847,28 +858,38 @@ async function createConfigFile(
|
|
|
847
858
|
}
|
|
848
859
|
|
|
849
860
|
// Create configuration with custom paths
|
|
861
|
+
// Normalize paths - ensure they start with ./ if they're relative
|
|
862
|
+
const normalizePath = (p: string) => {
|
|
863
|
+
if (p.startsWith('./') || p.startsWith('../') || path.isAbsolute(p)) {
|
|
864
|
+
return p;
|
|
865
|
+
}
|
|
866
|
+
return `./${p}`;
|
|
867
|
+
};
|
|
868
|
+
|
|
850
869
|
const config = {
|
|
851
870
|
version: CLI_VERSION,
|
|
852
871
|
registry: DEFAULT_REGISTRY_URL,
|
|
853
872
|
paths: {
|
|
854
|
-
utils: pathConfig.utils,
|
|
855
|
-
primitives: pathConfig.primitives,
|
|
856
|
-
components: pathConfig.components,
|
|
857
|
-
blocks: pathConfig.blocks,
|
|
858
|
-
hooks: pathConfig.hooks,
|
|
859
|
-
animations: pathConfig.animations,
|
|
873
|
+
utils: normalizePath(pathConfig.utils),
|
|
874
|
+
primitives: normalizePath(pathConfig.primitives),
|
|
875
|
+
components: normalizePath(pathConfig.components),
|
|
876
|
+
blocks: normalizePath(pathConfig.blocks),
|
|
877
|
+
hooks: normalizePath(pathConfig.hooks),
|
|
878
|
+
animations: normalizePath(pathConfig.animations),
|
|
860
879
|
},
|
|
861
880
|
packageManager: structure.packageManager,
|
|
862
881
|
typescript: structure.isTypeScript,
|
|
863
882
|
framework: structure.framework,
|
|
864
883
|
tailwind: {
|
|
865
|
-
css: pathConfig.styles,
|
|
884
|
+
css: normalizePath(pathConfig.styles),
|
|
866
885
|
},
|
|
867
886
|
aliases: {
|
|
868
|
-
'@': structure.baseDir.replace(/\/$/, '') || '.',
|
|
869
|
-
'@/components':
|
|
870
|
-
|
|
871
|
-
|
|
887
|
+
'@': normalizePath(structure.baseDir.replace(/\/$/, '') || '.'),
|
|
888
|
+
'@/components': normalizePath(
|
|
889
|
+
path.dirname(pathConfig.components).replace(/\/$/, '')
|
|
890
|
+
),
|
|
891
|
+
'@/lib': normalizePath(pathConfig.lib.replace(/\/$/, '')),
|
|
892
|
+
'@/hooks': normalizePath(pathConfig.hooks.replace(/\/$/, '')),
|
|
872
893
|
},
|
|
873
894
|
};
|
|
874
895
|
|
package/components.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
-
"style": "new-york",
|
|
4
|
-
"rsc": true,
|
|
5
|
-
"tsx": true,
|
|
6
|
-
"tailwind": {
|
|
7
|
-
"config": "",
|
|
8
|
-
"css": "src/styles/globals.css",
|
|
9
|
-
"baseColor": "neutral",
|
|
10
|
-
"cssVariables": true
|
|
11
|
-
},
|
|
12
|
-
"iconLibrary": "lucide",
|
|
13
|
-
"aliases": {
|
|
14
|
-
"components": "@workspace/ui/components",
|
|
15
|
-
"utils": "@workspace/ui/lib/utils",
|
|
16
|
-
"hooks": "@workspace/ui/hooks",
|
|
17
|
-
"lib": "@workspace/ui/lib",
|
|
18
|
-
"ui": "@workspace/ui/components"
|
|
19
|
-
}
|
|
20
|
-
}
|