| 1 |
// Copyright 2024 The Hugo Authors. All rights reserved. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
// |
| 8 |
// Unless required by applicable law or agreed to in writing, software |
| 9 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 |
// See the License for the specific language governing permissions and |
| 12 |
// limitations under the License. |
| 13 |
|
| 14 |
//go:build withdeploy |
| 15 |
|
| 16 |
package commands |
| 17 |
|
| 18 |
import ( |
| 19 |
"context" |
| 20 |
|
| 21 |
"github.com/gohugoio/hugo/deploy" |
| 22 |
|
| 23 |
"github.com/bep/simplecobra" |
| 24 |
"github.com/spf13/cobra" |
| 25 |
) |
| 26 |
|
| 27 |
func newDeployCommand() simplecobra.Commander { |
| 28 |
return &simpleCommand{ |
| 29 |
name: "deploy", |
| 30 |
short: "Deploy your project to a cloud provider", |
| 31 |
long: `Deploy your project to a cloud provider |
| 32 |
|
| 33 |
See https://gohugo.io/hosting-and-deployment/hugo-deploy/ for detailed |
| 34 |
documentation. |
| 35 |
`, |
| 36 |
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error { |
| 37 |
h, err := r.Hugo(flagsToCfgWithAdditionalConfigBase(cd, nil, "deployment")) |
| 38 |
if err != nil { |
| 39 |
return err |
| 40 |
} |
| 41 |
deployer, err := deploy.New(h.Configs.GetFirstLanguageConfig(), h.Log, h.PathSpec.PublishFs) |
| 42 |
if err != nil { |
| 43 |
return err |
| 44 |
} |
| 45 |
return deployer.Deploy(ctx) |
| 46 |
}, |
| 47 |
withc: func(cmd *cobra.Command, r *rootCommand) { |
| 48 |
applyDeployFlags(cmd, r) |
| 49 |
}, |
| 50 |
} |
| 51 |
} |