(nameVersion string)
| 151 | } |
| 152 | |
| 153 | func (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 | |
| 210 | func (i *installCmd) overrideFlags() error { |
no test coverage detected