1
- import { Effect , Layer } from "effect"
2
1
import { CliOptions } from "@cli/contexts/cli-options.js"
3
- import { Doctor } from "@cli/services/commands/doctor.js"
4
- import { ProjectConfig } from "../project-config.js"
5
- import { Prompt } from "@effect/cli"
6
2
import { PROJECT_MANIFEST } from "@cli/project-manifest.js"
3
+ import { Doctor } from "@cli/services/commands/doctor.js"
7
4
import { runCommand } from "@cli/utils/run-command.js"
5
+ import { Prompt } from "@effect/cli"
6
+ import { Effect , Layer } from "effect"
7
+ import { PackageManager } from "../package-manager.js"
8
+ import { ProjectConfig } from "../project-config.js"
8
9
9
10
type AddOptions = {
10
11
cwd : string
@@ -16,9 +17,11 @@ type AddOptions = {
16
17
}
17
18
18
19
class Add extends Effect . Service < Add > ( ) ( "Add" , {
20
+ dependencies : [ PackageManager . Default ] ,
19
21
effect : Effect . gen ( function * ( ) {
20
22
const doctor = yield * Doctor
21
23
const projectConfig = yield * ProjectConfig
24
+ const packageManager = yield * PackageManager
22
25
23
26
return {
24
27
run : ( options : AddOptions ) =>
@@ -60,11 +63,20 @@ class Add extends Effect.Service<Add>()("Add", {
60
63
61
64
const shadcnOptions = toShadcnOptions ( options )
62
65
63
- const commandArgs = [ "--yes" , "shadcn@latest" , "add" , ...shadcnOptions , ...componentUrls ]
66
+ const binaryRunner = yield * packageManager . getBinaryRunner ( options . cwd )
67
+
68
+ const commandArgs = [
69
+ binaryRunner [ 1 ] ,
70
+ "--yes" ,
71
+ "shadcn@latest" ,
72
+ "add" ,
73
+ ...shadcnOptions ,
74
+ ...componentUrls
75
+ ] . filter ( ( option ) => option !== undefined )
64
76
65
- yield * Effect . logDebug ( `Running command: npx ${ commandArgs . join ( " " ) } ` )
77
+ yield * Effect . logDebug ( `Running command: ${ binaryRunner [ 0 ] } ${ commandArgs . join ( " " ) } ` )
66
78
67
- yield * runCommand ( "npx" , commandArgs , {
79
+ yield * runCommand ( binaryRunner [ 0 ] , commandArgs , {
68
80
cwd : options . cwd ,
69
81
stdio : "inherit"
70
82
} )
0 commit comments