2022-12-07 01:56:15 -06:00
|
|
|
// Package verifystorybook contains the sub-command "verify-storybook".
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"path/filepath"
|
|
|
|
|
2024-06-14 11:35:30 -05:00
|
|
|
"github.com/grafana/grafana/pkg/build/fsutil"
|
2022-12-07 01:56:15 -06:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// VerifyStorybook Action implements the sub-command "verify-storybook".
|
|
|
|
func VerifyStorybook(c *cli.Context) error {
|
|
|
|
const grafanaDir = "."
|
|
|
|
|
|
|
|
paths := []string{
|
|
|
|
"packages/grafana-ui/dist/storybook/index.html",
|
|
|
|
"packages/grafana-ui/dist/storybook/iframe.html"}
|
|
|
|
for _, p := range paths {
|
2024-06-14 11:35:30 -05:00
|
|
|
exists, err := fsutil.Exists(filepath.Join(grafanaDir, p))
|
2022-12-07 01:56:15 -06:00
|
|
|
if err != nil {
|
2022-12-14 05:32:45 -06:00
|
|
|
return cli.Exit(fmt.Sprintf("failed to verify Storybook build: %s", err), 1)
|
2022-12-07 01:56:15 -06:00
|
|
|
}
|
|
|
|
if !exists {
|
|
|
|
return fmt.Errorf("failed to verify Storybook build, missing %q", p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("Successfully verified Storybook integrity")
|
|
|
|
return nil
|
|
|
|
}
|