MCPcopy Index your code
hub / github.com/celer-pkg/celer / Command

Method Command

cmds/cmd_deploy.go:28–96  ·  view source on GitHub ↗
(celer *configs.Celer)

Source from the content-addressed store, hash-verified

26}
27
28func (d *deployCmd) Command(celer *configs.Celer) *cobra.Command {
29 d.celer = celer
30 command := &cobra.Command{
31 Use: "deploy",
32 Short: "Deploy with selected platform and project.",
33 Long: `Deploy builds and installs all packages defined in the current project.
34
35After successful deployment, you can optionally export a snapshot
36for reproducible builds using the --snapshot flag, and you can also
37strip installed binaries and libraies with --strip.
38
39Examples:
40 celer deploy --force # Force deploy and ignore installed
41 celer deploy --snapshot=${filepath} # Initialize with conf repo
42 celer deploy --strip # Strip installed binaries and libraries`,
43 Args: d.validateArgs,
44 RunE: func(cmd *cobra.Command, args []string) error {
45 if err := d.celer.Init(); err != nil {
46 return color.PrintError(err, "failed to init celer.")
47 }
48
49 platformName := expr.If(d.celer.Platform().GetName() != "", d.celer.Platform().GetName(), "native")
50 projectName := d.celer.Project().GetName()
51
52 // Display deployment header.
53 color.Println(color.Title, "=======================================================================")
54 color.Printf(color.Title, "🚀 start to deploy:\n")
55 color.Printf(color.Title, "📌 platform: %s\n", platformName)
56 color.Printf(color.Title, "📌 project: %s\n", projectName)
57 color.Println(color.Title, "=======================================================================")
58
59 // Check circular dependency and version conflict.
60 if err := d.checkProject(); err != nil {
61 return color.PrintError(err, "failed to check circular dependency and version conflict.")
62 }
63
64 // Resolve all dependency refs before any clone/download begins.
65 if err := d.resolveAllRefs(); err != nil {
66 return color.PrintError(err, "failed to resolve refs.")
67 }
68
69 if err := d.celer.Deploy(d.force, d.strip); err != nil {
70 return color.PrintError(err, "failed to deploy celer.")
71 }
72
73 color.PrintSuccess("%s has been successfully deployed.", projectName)
74
75 // Export snapshot if requested.
76 if d.snapshotPath != "" {
77 if err := snapshot.Export(d.celer, d.snapshotPath); err != nil {
78 return fmt.Errorf("failed to export snapshot -> %w", err)
79 }
80 }
81
82 return nil
83 },
84 ValidArgsFunction: d.completion,
85 }

Callers 3

TestDeployCmd_CompletionFunction · 0.95
TestDeployCmd_SuccessFunction · 0.95

Calls 13

checkProjectMethod · 0.95
resolveAllRefsMethod · 0.95
PrintErrorFunction · 0.92
IfFunction · 0.92
PrintlnFunction · 0.92
PrintfFunction · 0.92
PrintSuccessFunction · 0.92
ExportFunction · 0.92
DeployMethod · 0.80
InitMethod · 0.65
GetNameMethod · 0.65
PlatformMethod · 0.65

Tested by 3

TestDeployCmd_CompletionFunction · 0.76
TestDeployCmd_SuccessFunction · 0.76