2022-09-15 03:06:43 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/build/config"
|
|
|
|
"github.com/grafana/grafana/pkg/build/gcloud/storage"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// StoreStorybook implements the sub-command "store-storybook".
|
|
|
|
func StoreStorybook(c *cli.Context) error {
|
|
|
|
deployment := c.String("deployment")
|
|
|
|
|
|
|
|
metadata, err := GenerateMetadata(c)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-09-16 05:26:33 -05:00
|
|
|
buildConfig, err := config.GetBuildConfig(metadata.ReleaseMode.Mode)
|
2022-09-15 03:06:43 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-09-16 05:26:33 -05:00
|
|
|
storybookBucket := buildConfig.Buckets.Storybook
|
|
|
|
srcPath := buildConfig.Buckets.StorybookSrcDir
|
2022-09-15 03:06:43 -05:00
|
|
|
srcPath = filepath.Join(srcPath, deployment)
|
|
|
|
|
|
|
|
gcs, err := storage.New()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
bucket := gcs.Bucket(storybookBucket)
|
|
|
|
|
|
|
|
if err := gcs.DeleteDir(c.Context, bucket, srcPath); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("Successfully cleaned source: %s/%s\n", storybookBucket, srcPath)
|
|
|
|
|
|
|
|
if err := gcs.CopyLocalDir(c.Context, "packages/grafana-ui/dist/storybook", bucket, srcPath, true); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("Successfully stored storybook to: %s/%s!\n", storybookBucket, srcPath)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|