MCPcopy Create free account
hub / github.com/celer-pkg/celer / install

Method install

cmds/cmd_install.go:153–208  ·  view source on GitHub ↗
(nameVersion string)

Source from the content-addressed store, hash-verified

151}
152
153func (i *installCmd) install(nameVersion string) error {
154 platformName := expr.If(i.celer.Platform().GetName() != "", i.celer.Platform().GetName(), "native")
155
156 // Display install header.
157 color.Println(color.Title, "=======================================================================")
158 color.Printf(color.Title, "🚀 start to install %s\n", nameVersion)
159 color.Printf(color.Title, "📌 platform: %s\n", platformName)
160 color.Printf(color.Title, "📌 product: %s\n", i.celer.Project().GetName())
161 color.Println(color.Title, "=======================================================================")
162
163 // Init the port.
164 var port = configs.Port{
165 DevDep: i.dev,
166 }
167 if err := port.Init(i.celer, nameVersion); err != nil {
168 if errors.Is(err, errors.ErrPortNotFound) {
169 format := "port %s is not yet available - consider adding it now ?"
170 return color.PrintError(fmt.Errorf(format, nameVersion), "failed to install %s", nameVersion)
171 }
172 return color.PrintError(err, "failed to init %s", nameVersion)
173 }
174
175 // Check circular dependence and version conclict.
176 depcheck := depcheck.NewDepCheck()
177 if err := depcheck.CheckCircular(i.celer, port); err != nil {
178 return color.PrintError(err, "failed to check circular dependence.")
179 }
180 if err := depcheck.CheckConflict(i.celer, port); err != nil {
181 return color.PrintError(err, "failed to check version conflict.")
182 }
183
184 // Do install.
185 options := configs.InstallOptions{
186 Force: i.force,
187 Recursive: i.recursive,
188 }
189 fromWhere, err := port.Install(options)
190 if err != nil {
191 return color.PrintError(err, "failed to install %s", nameVersion)
192 }
193 if fromWhere != "" {
194 if port.DevDep {
195 color.PrintSuccess("install %s from %s as dev successfully.", nameVersion, fromWhere)
196 } else {
197 color.PrintSuccess("install %s from %s successfully.", nameVersion, fromWhere)
198 }
199 } else {
200 if port.DevDep {
201 color.PrintSuccess("install %s as dev successfully.", nameVersion)
202 } else {
203 color.PrintSuccess("install %s successfully.", nameVersion)
204 }
205 }
206
207 return nil
208}
209
210func (i *installCmd) overrideFlags() error {

Callers 1

runInstallMethod · 0.95

Calls 13

IfFunction · 0.92
PrintlnFunction · 0.92
PrintfFunction · 0.92
IsFunction · 0.92
PrintErrorFunction · 0.92
PrintSuccessFunction · 0.92
GetNameMethod · 0.65
PlatformMethod · 0.65
ProjectMethod · 0.65
InitMethod · 0.65
CheckCircularMethod · 0.65
CheckConflictMethod · 0.65

Tested by

no test coverage detected