Skip to content

Commit

Permalink
revert push command
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-przybyl-wttech committed Apr 9, 2024
1 parent 2562b02 commit 828d1b0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 90 deletions.
45 changes: 0 additions & 45 deletions cmd/aem/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func (c *CLI) contentCmd() *cobra.Command {
}
cmd.AddCommand(c.contentCleanCmd())
cmd.AddCommand(c.contentPullCmd())
cmd.AddCommand(c.contentPushCmd())
cmd.AddCommand(c.contentDownloadCmd())
cmd.AddCommand(c.contentCopyCmd())
return cmd
Expand Down Expand Up @@ -157,50 +156,6 @@ func (c *CLI) contentPullCmd() *cobra.Command {
return cmd
}

func (c *CLI) contentPushCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "push",
Aliases: []string{"ps"},
Short: "Push content from JCR root directory or local file to running instance",
Run: func(cmd *cobra.Command, args []string) {
instance, err := c.aem.InstanceManager().One()
if err != nil {
c.Error(err)
return
}
dir, err := determineContentDir(cmd)
if err != nil {
c.Error(err)
return
}
file, err := determineContentFile(cmd)
if err != nil {
c.Error(err)
return
}
if err = instance.ContentManager().Push(pkg.PackageCreateOpts{
PushContent: true,
ContentDir: dir,
ContentFile: file,
}); err != nil {
c.Error(err)
return
}
if dir != "" {
c.SetOutput("dir", dir)
} else if file != "" {
c.SetOutput("file", file)
}
c.Changed("content pushed")
},
}
cmd.Flags().StringP("dir", "d", "", "JCR root path")
cmd.Flags().StringP("file", "f", "", "Local file path")
cmd.Flags().StringP("path", "p", "", "JCR root path or local file path")
cmd.MarkFlagsOneRequired("dir", "file", "path")
return cmd
}

func (c *CLI) contentCopyCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "copy",
Expand Down
14 changes: 0 additions & 14 deletions pkg/content_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,6 @@ func determineCleanFile(file string) string {
return file
}

func (cm *ContentManager) Push(packageOpts PackageCreateOpts) error {
remotePath, err := cm.pkgMgr().Create(packageOpts)
if err != nil {
return err
}
defer func() {
_ = cm.pkgMgr().Delete(remotePath)
}()
if err = cm.pkgMgr().Install(remotePath); err != nil {
return err
}
return nil
}

func (cm *ContentManager) Copy(destInstance *Instance, clean bool, pkgOpts PackageCreateOpts) error {
var pkgFile = pathx.RandomFileName(cm.tmpDir(), "content_copy", ".zip")
defer func() { _ = pathx.DeleteIfExists(pkgFile) }()
Expand Down
31 changes: 0 additions & 31 deletions pkg/package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ type PackageCreateOpts struct {
PID string
FilterRoots []string
FilterFile string
PushContent bool
ContentDir string
ContentFile string
}
Expand Down Expand Up @@ -206,36 +205,6 @@ func (pm *PackageManager) Create(opts PackageCreateOpts) (string, error) {
return "", err
}
}
if len(opts.FilterRoots) == 0 && opts.FilterFile == "" && opts.PushContent {
if opts.ContentDir != "" {
_, after, _ := strings.Cut(opts.ContentDir, content.JCRRoot)
if err = pathx.Ensure(filepath.Join(tmpDir, content.JCRRoot, after)); err != nil {
return "", err
}
if err = filex.CopyDir(opts.ContentDir, filepath.Join(tmpDir, content.JCRRoot, after)); err != nil {
return "", err
}
} else if opts.ContentFile != "" {
dir := filepath.Dir(opts.ContentFile)
_, after, _ := strings.Cut(dir, content.JCRRoot)
if err = pathx.Ensure(filepath.Join(tmpDir, content.JCRRoot, after)); err != nil {
return "", err
}
_, after, _ = strings.Cut(opts.ContentFile, content.JCRRoot)
if err = filex.Copy(opts.ContentFile, filepath.Join(tmpDir, content.JCRRoot, after), true); err != nil {
return "", err
}
if strings.HasSuffix(opts.ContentFile, content.JCRContentFile) {
dir = strings.ReplaceAll(opts.ContentFile, content.JCRContentNode, content.JCRContentDirName)
_, after, _ = strings.Cut(dir, content.JCRRoot)
if pathx.Exists(dir) {
if err = filex.CopyDir(dir, filepath.Join(tmpDir, content.JCRRoot, after)); err != nil {
return "", err
}
}
}
}
}
if err = filex.Archive(tmpDir, tmpFile); err != nil {
return "", err
}
Expand Down

0 comments on commit 828d1b0

Please sign in to comment.