-
Notifications
You must be signed in to change notification settings - Fork 139
Check and generate multiple readme files in one package #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
12a17ea
a3886c0
ae666b8
0981abe
d57e8ba
7ef4eb5
3e762da
303bb12
17afb55
4f603f8
5898df2
6cf1ce4
e5983ce
380019c
41c2ff2
9d9039c
9a85bb5
da89e55
cb3e976
9ff5e57
1673749
d24311c
17506c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,15 @@ | |
| package cmd | ||
|
|
||
| import ( | ||
| "io/ioutil" | ||
| "path/filepath" | ||
|
|
||
| "github.com/pkg/errors" | ||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/elastic/elastic-package/internal/builder" | ||
| "github.com/elastic/elastic-package/internal/docs" | ||
| "github.com/elastic/elastic-package/internal/packages" | ||
| ) | ||
|
|
||
| const buildLongDescription = `Use this command to build a package. Currently it supports only the "integration" package type. | ||
|
|
@@ -36,19 +40,35 @@ func setupBuildCommand() *cobra.Command { | |
| func buildCommandAction(cmd *cobra.Command, args []string) error { | ||
| cmd.Println("Build the package") | ||
|
|
||
| target, err := docs.UpdateReadme() | ||
| if err != nil { | ||
| return errors.Wrapf(err, "updating %s file failed", docs.ReadmeFile) | ||
| packageRootPath, found, err := packages.FindPackageRoot() | ||
| if !found { | ||
| return errors.New("package root not found") | ||
| } | ||
| if target != "" { | ||
| cmd.Printf("%s file rendered: %s\n", docs.ReadmeFile, target) | ||
| if err != nil { | ||
| return errors.Wrap(err, "locating package root failed") | ||
| } | ||
|
|
||
| target, err = builder.BuildPackage() | ||
| readmeFiles, err := ioutil.ReadDir(filepath.Join(packageRootPath, "_dev", "build", "docs")) | ||
|
kaiyan-sheng marked this conversation as resolved.
Outdated
|
||
| if err != nil { | ||
| return errors.Wrap(err, "building package failed") | ||
| return errors.Wrapf(err, "failed to return a list of directory entries from %s", packageRootPath) | ||
| } | ||
|
|
||
| for _, readme := range readmeFiles { | ||
| fileName := readme.Name() | ||
| target, err := docs.UpdateReadme(fileName) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "updating %s file failed", fileName) | ||
| } | ||
| if target != "" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the case that the target is empty?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be empty when README file is static and can't be generated from the template file. This came from
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see! It might be cleaner to skip this file on the lower layer (in the |
||
| cmd.Printf("%s file rendered: %s\n", fileName, target) | ||
| } | ||
|
|
||
| target, err = builder.BuildPackage() | ||
| if err != nil { | ||
| return errors.Wrap(err, "building package failed") | ||
| } | ||
| cmd.Printf("Package built: %s\n", target) | ||
| } | ||
| cmd.Printf("Package built: %s\n", target) | ||
|
|
||
| cmd.Println("Done") | ||
| return nil | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.