1
- import { Effect , Layer , pipe , Schema } from "effect"
1
+ import { Effect , Layer } from "effect"
2
2
import { CliOptions } from "@cli/contexts/cli-options.js"
3
3
import { Doctor } from "@cli/services/commands/doctor.js"
4
4
import { ProjectConfig } from "../project-config.js"
@@ -25,11 +25,7 @@ class Add extends Effect.Service<Add>()("Add", {
25
25
Effect . gen ( function * ( ) {
26
26
yield * Effect . logDebug ( `Add options: ${ JSON . stringify ( options , null , 2 ) } ` )
27
27
28
- const componentJson = yield * projectConfig . getComponentJson ( )
29
- const style = yield * pipe (
30
- componentJson . style ,
31
- Schema . decodeUnknown ( Schema . Union ( Schema . Literal ( "default" ) , Schema . Literal ( "new-york" ) ) )
32
- )
28
+ yield * projectConfig . getComponentJson ( ) // ensure components.json config is valid and prompt if not
33
29
34
30
const components = options . all ? PROJECT_MANIFEST . components : ( options . args ?. components ?? [ ] )
35
31
@@ -54,10 +50,22 @@ class Add extends Effect.Service<Add>()("Add", {
54
50
55
51
const baseUrl =
56
52
process . env . NODE_ENV === "development"
57
- ? "http://localhost:3000/local/r"
58
- : "https://reactnativereusables.com/r"
53
+ ? "http://localhost:3000/local/r/new-york"
54
+ : "https://reactnativereusables.com/r/new-york"
55
+
56
+ const manifestComponentsSet = new Set (
57
+ PROJECT_MANIFEST . components . map ( ( component ) => component . toLocaleLowerCase ( ) )
58
+ )
59
+
60
+ const componentUrls = components . map ( ( component ) => {
61
+ const lowerCaseComponent = component . toLocaleLowerCase ( )
59
62
60
- const componentUrls = components . map ( ( component ) => `${ baseUrl } /${ style } /${ component } .json` )
63
+ if ( manifestComponentsSet . has ( lowerCaseComponent ) ) {
64
+ return `${ baseUrl } /${ lowerCaseComponent } .json`
65
+ }
66
+
67
+ return component
68
+ } )
61
69
62
70
const shadcnOptions = toShadcnOptions ( options )
63
71
0 commit comments