From 34c3601874d9702ef13ee20942da4ea71d8998c5 Mon Sep 17 00:00:00 2001 From: Leo Heinman Date: Mon, 22 Jul 2019 11:00:00 -0700 Subject: [PATCH 1/6] Fixes for Windows Linux subsystem shell and Cygwin bash --- repo/repo | 18 +++++++++++++++++- repo/repoUpload.ps1 | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 repo/repoUpload.ps1 diff --git a/repo/repo b/repo/repo index f907f2c..bcef143 100755 --- a/repo/repo +++ b/repo/repo @@ -532,6 +532,18 @@ while [ $# -gt 0 ]; do shift done +# Running in either Windows Linux subsystem shell or Cygwin bash: +# - the assumption is that the backslashes in the path have already been converted to forward slashes. +if [[ $path =~ ^[A-Z]: ]]; then + rematch=${BASH_REMATCH[0]} # BASH_REMATCH is undefined inside the nested if + drive=${rematch,,} # lower case + if [[ $(uname) =~ CYGWIN_NT.* ]]; then + path=${path/${rematch}/\/cygdrive\/${drive/:/}} + else + path=${path/${rematch}/\/mnt\/${drive/:/}} + fi +fi + if [ $action == "checkout" ]; then # special checkout init steps # path argument must be a jcr path @@ -653,7 +665,11 @@ packageName="repo${packageName//[^[:alpha:][:digit:].-]/}" packageVersion=$(date +"%s") # prepare zip contents in temp directory -tmpDir=`mktemp -d -t repo.XXX` +if [[ $(uname) =~ CYGWIN_NT.* ]]; then + tmpDir=`mktemp -d -p .. -t repo.XXX` +else + tmpDir=`mktemp -d -t repo.XXX` +fi # store list of excludes in a file for use by commands later excludes=$tmpDir/.excludes diff --git a/repo/repoUpload.ps1 b/repo/repoUpload.ps1 new file mode 100644 index 0000000..86aa342 --- /dev/null +++ b/repo/repoUpload.ps1 @@ -0,0 +1,25 @@ + +# Script for running 'repo' tool in either Windows Linux subsystem shell or Cygwin bash +# see https://github.com/Adobe-Marketing-Cloud/tools/blob/master/repo/repo + +Param($command, $path) + +function cleanup { + $tmpPkg = "C:\temp\pkg.zip" + + if (Test-Path $tmpPkg) { + rm $tmpPkg + } +} + +if (Test-Path $path) { + $path = $($path -replace '\\','/') + $ret = $(bash -l ./repo $command -f $path) + #$ret = (C:\cygwin64\bin\bash.exe -l .\repo $command -f $path) +} +else{ + Write-Error "File $path not found" + exit 1 +} +cleanup +Write-Output "File $path has been uploaded" \ No newline at end of file From 0fb3d2ff4048eefad9a35af4d58b62590fda40ab Mon Sep 17 00:00:00 2001 From: Leo Heinman Date: Mon, 22 Jul 2019 13:56:16 -0700 Subject: [PATCH 2/6] Updated README.md, moved code around --- repo/README.md | 24 ++++++++++++++---------- repo/repo | 12 ------------ repo/repoUpload.ps1 | 25 ------------------------- repo/repoWrapper.ps1 | 29 +++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 47 deletions(-) delete mode 100644 repo/repoUpload.ps1 create mode 100644 repo/repoWrapper.ps1 diff --git a/repo/README.md b/repo/README.md index 0597de3..4f6cb4d 100644 --- a/repo/README.md +++ b/repo/README.md @@ -83,25 +83,29 @@ Below shortcuts are examples, your milage may vary. #### Windows: -Cygwin is required, and repo must be called explicitly using Cygwin's `bash`. +Cygwin or Windows Subsystem for Linux is required, and repo must be called explicitly using Cygwin's or Linux's `bash`. -Make sure the folder containing `repo` is in cygwin's `$PATH` variable. Alternatively replace `-l repo` in the parameters below with the full absolute path, for example `-l c:\repoinstallfolder\repo`. +Make sure the folder containing `repo` is in Windows' `$Path` variable. Alternatively replace `repoWrapper.ps1` in the parameters below with the full absolute path, for example `C:\tools\repoWrapper.ps1`. * put - * Program: `\bin\bash` - for example: `C:\cygwin64\bin\bash` - * Parameters: `-l repo put -f $FilePath$` + * Program: `powershell` + * Parameters: `repoWrapper.ps1 put mnt $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` * get - * Program: `\bin\bash` - * Parameters: `-l repo get -f $FilePath$` + * Program: `powershell` + * Parameters: `repoWrapper.ps1 get mnt $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + R` * status - * Program: `\bin\bash` - * Parameters: `-l repo st $FilePath$` + * Program: `powershell` + * Parameters: `repoWrapper.ps1 status mnt $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` * diff - * Program: `\bin\bash` - * Parameters: `-l repo diff $FilePath$` + * Program: `powershell` + * Parameters: `repoWrapper.ps1 diff mnt $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + E` ### Integration into Eclipse diff --git a/repo/repo b/repo/repo index bcef143..9ac5441 100755 --- a/repo/repo +++ b/repo/repo @@ -532,18 +532,6 @@ while [ $# -gt 0 ]; do shift done -# Running in either Windows Linux subsystem shell or Cygwin bash: -# - the assumption is that the backslashes in the path have already been converted to forward slashes. -if [[ $path =~ ^[A-Z]: ]]; then - rematch=${BASH_REMATCH[0]} # BASH_REMATCH is undefined inside the nested if - drive=${rematch,,} # lower case - if [[ $(uname) =~ CYGWIN_NT.* ]]; then - path=${path/${rematch}/\/cygdrive\/${drive/:/}} - else - path=${path/${rematch}/\/mnt\/${drive/:/}} - fi -fi - if [ $action == "checkout" ]; then # special checkout init steps # path argument must be a jcr path diff --git a/repo/repoUpload.ps1 b/repo/repoUpload.ps1 deleted file mode 100644 index 86aa342..0000000 --- a/repo/repoUpload.ps1 +++ /dev/null @@ -1,25 +0,0 @@ - -# Script for running 'repo' tool in either Windows Linux subsystem shell or Cygwin bash -# see https://github.com/Adobe-Marketing-Cloud/tools/blob/master/repo/repo - -Param($command, $path) - -function cleanup { - $tmpPkg = "C:\temp\pkg.zip" - - if (Test-Path $tmpPkg) { - rm $tmpPkg - } -} - -if (Test-Path $path) { - $path = $($path -replace '\\','/') - $ret = $(bash -l ./repo $command -f $path) - #$ret = (C:\cygwin64\bin\bash.exe -l .\repo $command -f $path) -} -else{ - Write-Error "File $path not found" - exit 1 -} -cleanup -Write-Output "File $path has been uploaded" \ No newline at end of file diff --git a/repo/repoWrapper.ps1 b/repo/repoWrapper.ps1 new file mode 100644 index 0000000..d7433b3 --- /dev/null +++ b/repo/repoWrapper.ps1 @@ -0,0 +1,29 @@ + +# Script for running 'repo' tool in either Windows Subsystem for Linux's or Cygwin's bash + +Param($command, $drive, $path) + +function Get-ScriptDirectory { + Split-Path -parent $PSCommandPath +} + +if (Test-Path $path) { + $cmdPath = Get-ScriptDirectory + $path = $($path -replace '\\','/') + $path = ($path -replace '.:',"/$drive/c") + + if ($drive -ne "cygdrive") { + $cmdPath = $($cmdPath -replace '\\','/') + $cmdPath = ($cmdPath -replace '.:',"/$drive/c") + + $ret = $(bash -l "$cmdPath/repo" $command -f $path) + } + else { + $ret = (C:\cygwin64\bin\bash.exe -l "$cmdPath\repo" $command -f $path) + } +} +else { + Write-Error "File $path not found" + exit 1 +} +Write-Output "Executed $command on $path" \ No newline at end of file From 73fbb2e04da570f88945db06c549016ae63e3cee Mon Sep 17 00:00:00 2001 From: Leo Heinman Date: Mon, 22 Jul 2019 20:37:30 -0700 Subject: [PATCH 3/6] Clirified use of Cygwin in the wrapper script; wrapper code cleanup --- repo/README.md | 2 +- repo/repoWrapper.ps1 | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/repo/README.md b/repo/README.md index 4f6cb4d..50984a5 100644 --- a/repo/README.md +++ b/repo/README.md @@ -83,7 +83,7 @@ Below shortcuts are examples, your milage may vary. #### Windows: -Cygwin or Windows Subsystem for Linux is required, and repo must be called explicitly using Cygwin's or Linux's `bash`. +Cygwin or Windows Subsystem for Linux (WSL) is required, and repo must be called explicitly using Cygwin's or WSL's `bash`. The examples below are for WSL. In order to use Cygwin, replace `mnt` with `cygdrive` as the second parameter for repoWrapper.ps1. Make sure the folder containing `repo` is in Windows' `$Path` variable. Alternatively replace `repoWrapper.ps1` in the parameters below with the full absolute path, for example `C:\tools\repoWrapper.ps1`. diff --git a/repo/repoWrapper.ps1 b/repo/repoWrapper.ps1 index d7433b3..650b33e 100644 --- a/repo/repoWrapper.ps1 +++ b/repo/repoWrapper.ps1 @@ -3,23 +3,16 @@ Param($command, $drive, $path) -function Get-ScriptDirectory { - Split-Path -parent $PSCommandPath -} - if (Test-Path $path) { - $cmdPath = Get-ScriptDirectory - $path = $($path -replace '\\','/') + $path = ($path -replace '\\','/') $path = ($path -replace '.:',"/$drive/c") if ($drive -ne "cygdrive") { - $cmdPath = $($cmdPath -replace '\\','/') - $cmdPath = ($cmdPath -replace '.:',"/$drive/c") - - $ret = $(bash -l "$cmdPath/repo" $command -f $path) + bash -l repo $command -f $path } else { - $ret = (C:\cygwin64\bin\bash.exe -l "$cmdPath\repo" $command -f $path) + $cmdPath = (Split-Path -parent $PSCommandPath) + C:\cygwin64\bin\bash.exe -l "$cmdPath\repo" $command -f $path } } else { From 146b85b7afbd1b73d43419f424c8e11c565fdaec Mon Sep 17 00:00:00 2001 From: Leo Heinman Date: Mon, 22 Jul 2019 21:17:23 -0700 Subject: [PATCH 4/6] renamed repoWrapper into repoWin; reverted some of repoWin code cleanup --- repo/README.md | 14 ++++++++------ repo/{repoWrapper.ps1 => repoWin.ps1} | 7 +++++-- 2 files changed, 13 insertions(+), 8 deletions(-) rename repo/{repoWrapper.ps1 => repoWin.ps1} (69%) diff --git a/repo/README.md b/repo/README.md index 50984a5..5928c86 100644 --- a/repo/README.md +++ b/repo/README.md @@ -83,28 +83,30 @@ Below shortcuts are examples, your milage may vary. #### Windows: -Cygwin or Windows Subsystem for Linux (WSL) is required, and repo must be called explicitly using Cygwin's or WSL's `bash`. The examples below are for WSL. In order to use Cygwin, replace `mnt` with `cygdrive` as the second parameter for repoWrapper.ps1. +Cygwin or Windows Subsystem for Linux (WSL) is required, and repo must be called explicitly using Cygwin's or WSL's `bash`. The examples below are for WSL. +* In order to use Cygwin, replace `mnt` with `cygdrive` as the second parameter for `repoWin.ps1`. +* `repoWin.ps1` makes an assumption that Cygwin is installed under `C:\cygwin64`. -Make sure the folder containing `repo` is in Windows' `$Path` variable. Alternatively replace `repoWrapper.ps1` in the parameters below with the full absolute path, for example `C:\tools\repoWrapper.ps1`. +Make sure the folder containing `repo` is in Windows' `$Path` variable. Alternatively replace `repoWin.ps1` in the parameters below with the full absolute path, for example `C:\tools\repoWin.ps1`. * put * Program: `powershell` - * Parameters: `repoWrapper.ps1 put mnt $FilePath$` + * Parameters: `repoWin.ps1 put mnt $FilePath$` * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` * get * Program: `powershell` - * Parameters: `repoWrapper.ps1 get mnt $FilePath$` + * Parameters: `repoWin.ps1 get mnt $FilePath$` * Keyboard Shortcut: `Ctrl + Alt + Shift + R` * status * Program: `powershell` - * Parameters: `repoWrapper.ps1 status mnt $FilePath$` + * Parameters: `repoWin.ps1 status mnt $FilePath$` * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` * diff * Program: `powershell` - * Parameters: `repoWrapper.ps1 diff mnt $FilePath$` + * Parameters: `repoWin.ps1 diff mnt $FilePath$` * Keyboard Shortcut: `Ctrl + Alt + Shift + E` ### Integration into Eclipse diff --git a/repo/repoWrapper.ps1 b/repo/repoWin.ps1 similarity index 69% rename from repo/repoWrapper.ps1 rename to repo/repoWin.ps1 index 650b33e..822282a 100644 --- a/repo/repoWrapper.ps1 +++ b/repo/repoWin.ps1 @@ -6,12 +6,15 @@ Param($command, $drive, $path) if (Test-Path $path) { $path = ($path -replace '\\','/') $path = ($path -replace '.:',"/$drive/c") + $cmdPath = (Split-Path -parent $PSCommandPath) if ($drive -ne "cygdrive") { - bash -l repo $command -f $path + $cmdPath = $($cmdPath -replace '\\','/') + $cmdPath = ($cmdPath -replace '.:',"/$drive/c") + + bash -l "$cmdPath/repo" $command -f $path } else { - $cmdPath = (Split-Path -parent $PSCommandPath) C:\cygwin64\bin\bash.exe -l "$cmdPath\repo" $command -f $path } } From 7e5c00d629b281bb9961c968bf239030379aafb5 Mon Sep 17 00:00:00 2001 From: Leo Heinman Date: Tue, 23 Jul 2019 22:41:43 -0700 Subject: [PATCH 5/6] moved backslash flipping code into 'repo' bash shell script --- repo/README.md | 790 ++++++++++++++++++++++++----------------------- repo/repo | 17 +- repo/repoWin.ps1 | 58 ++-- 3 files changed, 451 insertions(+), 414 deletions(-) diff --git a/repo/README.md b/repo/README.md index 5928c86..cbcd21b 100644 --- a/repo/README.md +++ b/repo/README.md @@ -1,388 +1,402 @@ -# repo - FTP-like tool for JCR content - -Transfers filevault JCR content between the filesystem (unzipped content package) and a server such as AEM (running the package manager HTTP API). Great for development. - -Similar to the `vlt` command line tool from [jackrabbit-filevault](http://jackrabbit.apache.org/filevault/overview.html), but faster, bash-script-only and with minimal dependencies. - -How it works: For a given path inside a `jcr_root` filevault structure on the filesystem, it creates a package with a single filter for the entire subtree and pushes that to the server (put), fetches it from the server (get) or compares the differences (status and diff). Please note that it will always overwrite the entire file or directory specified. Does not support multiple filter paths or vlt's filter.xml. - -[Licensed under Apache 2.0](../LICENSE). - -## Table of Contents - -* [Installation](#installation) - * [Homebrew (Mac)](#homebrew-mac) - * [Manual installation](#manual-installation) - * [Integration into IntelliJ](#integration-into-intellij) - * [Integration into Eclipse](#integration-into-eclipse) - * [Integration into Visual Studio Code](#integration-into-visual-studio-code) -* [Usage](#usage) - * [common options](#common-options) - * [repo checkout (since 1.4)](#repo-checkout-since-14) - * [repo put](#repo-put) - * [repo get](#repo-get) - * [repo status](#repo-status) - * [repo diff](#repo-diff) - * [repo localdiff](#repo-localdiff) - * [repo serverdiff](#repo-serverdiff) - -## Installation - -Official release versions are [tracked here on github](https://github.com/Adobe-Marketing-Cloud/tools/releases). - -### Homebrew (Mac) - -For [Homebrew](http://brew.sh) users releases are available via the [adobe-marketing-cloud/brews tap](https://github.com/Adobe-Marketing-Cloud/homebrew-brews): -``` -brew tap adobe-marketing-cloud/brews -brew install adobe-marketing-cloud/brews/repo -``` - -### Manual installation - -`repo` is a single bash script depending on basic unix tools (zip, unzip, curl, rsync, mktemp). - -Download and put it onto your `$PATH`: - -* [Download latest release](https://github.com/Adobe-Marketing-Cloud/tools/releases/latest). -* [Download latest beta](repo) - just the script directly from this github repository. - -Supported platforms: - -- Mac OSX (+ curl, rsync) -- Linux (+ curl, rsync) -- Windows with Cygwin (+ zip, unzip, curl, rsync packages) - -### Integration into IntelliJ - -Want to hit a shortcut like `ctrl + cmd + P` and have your current open file or selected folder pushed to the server from within IntelliJ? Without having to save or anything else? Just set up these tools below. - -Setup external tools under Settings > Tools > External Tools. -Add a group "repo" and add commands below, leaving the "Working directory" empty. -Keyboard shortcuts are managed under Settings > Keymap, search for "repo" after you created the external tool entries. -Below shortcuts are examples, your milage may vary. - -#### Mac: - -* put - * Program: `repo` (if in `$PATH`, otherwise use the absolute path to repo here) - * Parameters: `put -f $FilePath$` - * Keyboard Shortcut: `ctrl + cmd + P` -* get - * Program: `repo` - * Parameters: `get -f $FilePath$` - * Keyboard Shortcut: `ctrl + cmd + G` (note: already used by default keymap for grepping) -* status - * Program: `repo` - * Parameters: `st $FilePath$` - * Keyboard Shortcut: `ctrl + cmd + S` -* diff - * Program: `repo` - * Parameters: `diff $FilePath$` - * Keyboard Shortcut: `ctrl + cmd + D` - -#### Windows: - -Cygwin or Windows Subsystem for Linux (WSL) is required, and repo must be called explicitly using Cygwin's or WSL's `bash`. The examples below are for WSL. -* In order to use Cygwin, replace `mnt` with `cygdrive` as the second parameter for `repoWin.ps1`. -* `repoWin.ps1` makes an assumption that Cygwin is installed under `C:\cygwin64`. - -Make sure the folder containing `repo` is in Windows' `$Path` variable. Alternatively replace `repoWin.ps1` in the parameters below with the full absolute path, for example `C:\tools\repoWin.ps1`. - -* put - * Program: `powershell` - * Parameters: `repoWin.ps1 put mnt $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` - -* get - * Program: `powershell` - * Parameters: `repoWin.ps1 get mnt $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + R` - -* status - * Program: `powershell` - * Parameters: `repoWin.ps1 status mnt $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` - -* diff - * Program: `powershell` - * Parameters: `repoWin.ps1 diff mnt $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + E` - -### Integration into Eclipse - -Setup external tools under `Run > Exernal Tools > Exernal Tool Configurations...`. -Add a Programm which points to the `repo` shell script for each desired REPO operation. -I would recommend to disable `Build before launch` in the Build tab. - -Examples: - -* put - * Location: `/repo` - * Working Directory: `${container_loc}` - * Arguments: `put -f ${selected_resource_name}` -* get - * Location: `/repo` - * Working Directory: `${container_loc}` - * Arguments: `get -f ${selected_resource_name}` - -### Integration into Visual Studio Code - -Configure custom tasks under `Terminal > Configure Tasks... > Create tasks.json file from template > Others`. -This will create a `tasks.json` beneath a `.vscode` directory in the current workspace. - -Below are examples for tasks using `repo`, assuming `repo` has been added and available at the terminal path. - -*Note, variables available are scoped to the current opened file. See [Variables Reference](https://code.visualstudio.com/docs/editor/variables-reference) for more info.* - -``` -// .vscode/tasks.json -{ - // examples of using repo to push and pull files and folders from a server running at localhost:4502 - // the tasks with folders actions will be perfomed on the folder of the current file open in the editor - // see https://code.visualstudio.com/docs/editor/variables-reference for more details - - "version": "2.0.0", - "tasks": [ - { - "label": "put file", - "type": "shell", - "command": "repo put -f ${file}", - "problemMatcher": [] - }, - { - "label": "put folder", - "type": "shell", - "command": "repo put -f ${fileDirname}", - "problemMatcher": [] - }, - { - "label": "get file", - "type": "shell", - "command": "repo get -f ${file}", - "problemMatcher": [] - }, - { - "label": "get folder", - "type": "shell", - "command": "repo get -f ${fileDirname}", - "problemMatcher": [] - } - ] -} -``` -Keyboard shortcuts can be created under `Code > Preferences > Keyboard Shortcuts > edit keybindings.json` - -Below are examples of keyboard shortcuts to trigger the custom tasks, your mileage may vary. - -``` -// keybindings.json -// keyboard shortcuts for repo tasks -[ - { - "key": "ctrl+cmd+p", - "command": "workbench.action.tasks.runTask", - "args": "put file" - }, - { - "key": "shift+cmd+p", - "command": "workbench.action.tasks.runTask", - "args": "put folder" - }, - { - "key": "ctrl+cmd+g", - "command": "commandId", - "when": "editorTextFocus" - },{ - "key": "ctrl+cmd+g", - "command": "workbench.action.tasks.runTask", - "args": "get file" - }, - { - "key": "shift+cmd+g", - "command": "workbench.action.tasks.runTask", - "args": "get folder" - } -] -``` - -## Usage - -``` -Usage: repo [opts] [] - -FTP-like tool for JCR content, with support for diffing. - -Transfers filevault JCR content between the filesystem (unzipped content package) -and a server such as AEM (running the package manager HTTP API). - -For a given path inside a jcr_root filevault structure on the filesystem, it -creates a package with a single filter for the entire subtree and pushes that to -the server (put), fetches it from the server (get) or compares the differences -(status and diff). Please note that it will always overwrite the entire file or -directory specified. Does not support multiple filter paths or vlt's filter.xml. - -Available commands: - - checkout intial checkout of server content on file system - put upload local file system content to server - get download server content to local file system - status (st) list status of modified/added/deleted files - diff show differences, same as 'localdiff' - - localdiff show differences done locally compared to server - serverdiff show differences done on the server compared to local - -Config files: - - .repo - - Can be placed in checkout or any parent directory. Allows to configure - server and credentials. Note that command line options take precedence. - - server=http://server.com:8080 - credentials=user:pwd - - - .repoignore - - Placed in the jcr_root directory, this file can list files to ignore - using glob patterns. Also supported are .vltignore files. - -Examples: - - Assume a running CQ server on http://localhost:4502 - - (1) Start from scratch, working on /apps/project available on server - - repo checkout /apps/project - - (2) Upload changes to server - - cd jcr_root/apps/project - vim .content.xml # some modifications - repo put # upload & overwrite entire dir - touch file.jsp # add new file - repo put file.jsp # just push single file - - (3) Download changes from server - - repo get - - (4) Show status and diff - - repo st - repo diff - - (5) Use custom server & credentials - - repo st -s localhost:8888 -u user:pwd - - (6) Avoid interactive confirmation (force) - Be careful, easy to wipe out your repository! - - repo put -f - -Use 'repo -h' for help on a specific command. -``` - -## common options - -``` -Arguments: - local directory or file to sync; defaults to current dir - -Options: - -h --help show this help - -s server, defaults to 'http://localhost:4502' - include context path if needed - -u : user and password, defaults to 'admin:admin' -``` - -## repo checkout (since 1.4) - -``` -Usage: repo checkout [opts] [] - -Initially check out from the server on the file system. - -This will create a jcr_root folder in the current directory and check -out the in there. If this is called within a jcr_root or -a jcr_root exists within the current directory, it will detect that -and check out the in there. - -Arguments: - jcr path to checkout (should be a folder) -``` - -## repo put - -``` -Usage: repo put [opts] [] - -Upload local file system content to server for the given path. - -Options: - -f force, don't ask for confirmation - -q quiet, don't output anything -``` - -## repo get - -``` -Usage: repo get [opts] [] - -Download server content to local filesystem for the given path. - -Options: - -f force, don't ask for confirmation - -q quiet, don't output anything -``` - -## repo status - -``` -Usage: repo status [opts] [] - -List status of files compared to the server at the given path. - -Status legend: - M modified - A added locally / deleted remotely - D removed locally / added remotely - ~ fd conflict: local file vs. remote directory - ~ df conflict: local directory vs. remote file -``` - -## repo diff - -``` -Usage: repo diff [opts] [] - -Show differences done locally compared to server at the given path. - -Same as 'localdiff', showing +++ if things were added locally. -If you made changes on the server, use 'serverdiff' instead. -``` - -## repo localdiff - -``` -Usage: repo localdiff [opts] [] - -Show differences done locally compared to server at the given path. - -Showing +++ if things were added locally (or removed on the server). -If you made changes on the server, use 'serverdiff' instead. -``` - -## repo serverdiff - -``` -Usage: repo serverdiff [opts] [] - -Show differences done on the server compared to local at the given path. - -Showing +++ if things were added on the server (or removed locally). -If you made changes locally, use 'localdiff' instead. -``` +# repo - FTP-like tool for JCR content + +Transfers filevault JCR content between the filesystem (unzipped content package) and a server such as AEM (running the package manager HTTP API). Great for development. + +Similar to the `vlt` command line tool from [jackrabbit-filevault](http://jackrabbit.apache.org/filevault/overview.html), but faster, bash-script-only and with minimal dependencies. + +How it works: For a given path inside a `jcr_root` filevault structure on the filesystem, it creates a package with a single filter for the entire subtree and pushes that to the server (put), fetches it from the server (get) or compares the differences (status and diff). Please note that it will always overwrite the entire file or directory specified. Does not support multiple filter paths or vlt's filter.xml. + +[Licensed under Apache 2.0](../LICENSE). + +## Table of Contents + +* [Installation](#installation) + * [Homebrew (Mac)](#homebrew-mac) + * [Manual installation](#manual-installation) + * [Integration into IntelliJ](#integration-into-intellij) + * [Integration into Eclipse](#integration-into-eclipse) + * [Integration into Visual Studio Code](#integration-into-visual-studio-code) +* [Usage](#usage) + * [common options](#common-options) + * [repo checkout (since 1.4)](#repo-checkout-since-14) + * [repo put](#repo-put) + * [repo get](#repo-get) + * [repo status](#repo-status) + * [repo diff](#repo-diff) + * [repo localdiff](#repo-localdiff) + * [repo serverdiff](#repo-serverdiff) + +## Installation + +Official release versions are [tracked here on github](https://github.com/Adobe-Marketing-Cloud/tools/releases). + +### Homebrew (Mac) + +For [Homebrew](http://brew.sh) users releases are available via the [adobe-marketing-cloud/brews tap](https://github.com/Adobe-Marketing-Cloud/homebrew-brews): +``` +brew tap adobe-marketing-cloud/brews +brew install adobe-marketing-cloud/brews/repo +``` + +### Manual installation + +`repo` is a single bash script depending on basic unix tools (zip, unzip, curl, rsync, mktemp). + +Download and put it onto your `$PATH`: + +* [Download latest release](https://github.com/Adobe-Marketing-Cloud/tools/releases/latest). +* [Download latest beta](repo) - just the script directly from this github repository. + +Supported platforms: + +- Mac OSX (+ curl, rsync) +- Linux (+ curl, rsync) +- Windows with Cygwin (+ zip, unzip, curl, rsync packages) + +### Integration into IntelliJ + +Want to hit a shortcut like `ctrl + cmd + P` and have your current open file or selected folder pushed to the server from within IntelliJ? Without having to save or anything else? Just set up these tools below. + +Setup external tools under Settings > Tools > External Tools. +Add a group "repo" and add commands below, leaving the "Working directory" empty. +Keyboard shortcuts are managed under Settings > Keymap, search for "repo" after you created the external tool entries. +Below shortcuts are examples, your milage may vary. + +#### Mac: + +* put + * Program: `repo` (if in `$PATH`, otherwise use the absolute path to repo here) + * Parameters: `put -f $FilePath$` + * Keyboard Shortcut: `ctrl + cmd + P` +* get + * Program: `repo` + * Parameters: `get -f $FilePath$` + * Keyboard Shortcut: `ctrl + cmd + G` (note: already used by default keymap for grepping) +* status + * Program: `repo` + * Parameters: `st $FilePath$` + * Keyboard Shortcut: `ctrl + cmd + S` +* diff + * Program: `repo` + * Parameters: `diff $FilePath$` + * Keyboard Shortcut: `ctrl + cmd + D` + +#### Windows: + +Cygwin or Windows Subsystem for Linux (WSL) are required, and repo must be called explicitly using Cygwin's or WSL's `bash`. + +Make sure the folder containing `repo` is in Windows' `$Path` variable. Alternatively replace `repoWin.ps1` in the parameters below with the full absolute path, for example `C:\tools\repoWin.ps1`. + +* put + * Program: `powershell` + * Parameters: `repoWin.ps1 put $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` +* get + * Program: `powershell` + * Parameters: `repoWin.ps1 get $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + R` +* status + * Program: `powershell` + * Parameters: `repoWin.ps1 status $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` +* diff + * Program: `powershell` + * Parameters: `repoWin.ps1 diff $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + E` + +An alternative way to run `repo` under Cygwin is to make sure the path to Cygwin installation directory is the first on the `$Path` variable list and provide the following external tools settings: + +* put + * Program: `bash` (use the absolute path to `bash` here) + * Parameters: `repo put -f $FilePath$` (use the absolute path to `repo` here) + * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` +* get + * Program: `bash` + * Parameters: `repo get -f $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + R` +* status + * Program: `bash` + * Parameters: `repo st $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` +* diff + * Program: `bash` + * Parameters: `repo diff $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + E` + +### Integration into Eclipse + +Setup external tools under `Run > Exernal Tools > Exernal Tool Configurations...`. +Add a Programm which points to the `repo` shell script for each desired REPO operation. +I would recommend to disable `Build before launch` in the Build tab. + +Examples: + +* put + * Location: `/repo` + * Working Directory: `${container_loc}` + * Arguments: `put -f ${selected_resource_name}` +* get + * Location: `/repo` + * Working Directory: `${container_loc}` + * Arguments: `get -f ${selected_resource_name}` + +### Integration into Visual Studio Code + +Configure custom tasks under `Terminal > Configure Tasks... > Create tasks.json file from template > Others`. +This will create a `tasks.json` beneath a `.vscode` directory in the current workspace. + +Below are examples for tasks using `repo`, assuming `repo` has been added and available at the terminal path. + +*Note, variables available are scoped to the current opened file. See [Variables Reference](https://code.visualstudio.com/docs/editor/variables-reference) for more info.* + +``` +// .vscode/tasks.json +{ + // examples of using repo to push and pull files and folders from a server running at localhost:4502 + // the tasks with folders actions will be perfomed on the folder of the current file open in the editor + // see https://code.visualstudio.com/docs/editor/variables-reference for more details + + "version": "2.0.0", + "tasks": [ + { + "label": "put file", + "type": "shell", + "command": "repo put -f ${file}", + "problemMatcher": [] + }, + { + "label": "put folder", + "type": "shell", + "command": "repo put -f ${fileDirname}", + "problemMatcher": [] + }, + { + "label": "get file", + "type": "shell", + "command": "repo get -f ${file}", + "problemMatcher": [] + }, + { + "label": "get folder", + "type": "shell", + "command": "repo get -f ${fileDirname}", + "problemMatcher": [] + } + ] +} +``` +Keyboard shortcuts can be created under `Code > Preferences > Keyboard Shortcuts > edit keybindings.json` + +Below are examples of keyboard shortcuts to trigger the custom tasks, your mileage may vary. + +``` +// keybindings.json +// keyboard shortcuts for repo tasks +[ + { + "key": "ctrl+cmd+p", + "command": "workbench.action.tasks.runTask", + "args": "put file" + }, + { + "key": "shift+cmd+p", + "command": "workbench.action.tasks.runTask", + "args": "put folder" + }, + { + "key": "ctrl+cmd+g", + "command": "commandId", + "when": "editorTextFocus" + },{ + "key": "ctrl+cmd+g", + "command": "workbench.action.tasks.runTask", + "args": "get file" + }, + { + "key": "shift+cmd+g", + "command": "workbench.action.tasks.runTask", + "args": "get folder" + } +] +``` + +## Usage + +``` +Usage: repo [opts] [] + +FTP-like tool for JCR content, with support for diffing. + +Transfers filevault JCR content between the filesystem (unzipped content package) +and a server such as AEM (running the package manager HTTP API). + +For a given path inside a jcr_root filevault structure on the filesystem, it +creates a package with a single filter for the entire subtree and pushes that to +the server (put), fetches it from the server (get) or compares the differences +(status and diff). Please note that it will always overwrite the entire file or +directory specified. Does not support multiple filter paths or vlt's filter.xml. + +Available commands: + + checkout intial checkout of server content on file system + put upload local file system content to server + get download server content to local file system + status (st) list status of modified/added/deleted files + diff show differences, same as 'localdiff' + + localdiff show differences done locally compared to server + serverdiff show differences done on the server compared to local + +Config files: + + .repo + + Can be placed in checkout or any parent directory. Allows to configure + server and credentials. Note that command line options take precedence. + + server=http://server.com:8080 + credentials=user:pwd + + + .repoignore + + Placed in the jcr_root directory, this file can list files to ignore + using glob patterns. Also supported are .vltignore files. + +Examples: + + Assume a running CQ server on http://localhost:4502 + + (1) Start from scratch, working on /apps/project available on server + + repo checkout /apps/project + + (2) Upload changes to server + + cd jcr_root/apps/project + vim .content.xml # some modifications + repo put # upload & overwrite entire dir + touch file.jsp # add new file + repo put file.jsp # just push single file + + (3) Download changes from server + + repo get + + (4) Show status and diff + + repo st + repo diff + + (5) Use custom server & credentials + + repo st -s localhost:8888 -u user:pwd + + (6) Avoid interactive confirmation (force) + Be careful, easy to wipe out your repository! + + repo put -f + +Use 'repo -h' for help on a specific command. +``` + +## common options + +``` +Arguments: + local directory or file to sync; defaults to current dir + +Options: + -h --help show this help + -s server, defaults to 'http://localhost:4502' + include context path if needed + -u : user and password, defaults to 'admin:admin' +``` + +## repo checkout (since 1.4) + +``` +Usage: repo checkout [opts] [] + +Initially check out from the server on the file system. + +This will create a jcr_root folder in the current directory and check +out the in there. If this is called within a jcr_root or +a jcr_root exists within the current directory, it will detect that +and check out the in there. + +Arguments: + jcr path to checkout (should be a folder) +``` + +## repo put + +``` +Usage: repo put [opts] [] + +Upload local file system content to server for the given path. + +Options: + -f force, don't ask for confirmation + -q quiet, don't output anything +``` + +## repo get + +``` +Usage: repo get [opts] [] + +Download server content to local filesystem for the given path. + +Options: + -f force, don't ask for confirmation + -q quiet, don't output anything +``` + +## repo status + +``` +Usage: repo status [opts] [] + +List status of files compared to the server at the given path. + +Status legend: + M modified + A added locally / deleted remotely + D removed locally / added remotely + ~ fd conflict: local file vs. remote directory + ~ df conflict: local directory vs. remote file +``` + +## repo diff + +``` +Usage: repo diff [opts] [] + +Show differences done locally compared to server at the given path. + +Same as 'localdiff', showing +++ if things were added locally. +If you made changes on the server, use 'serverdiff' instead. +``` + +## repo localdiff + +``` +Usage: repo localdiff [opts] [] + +Show differences done locally compared to server at the given path. + +Showing +++ if things were added locally (or removed on the server). +If you made changes on the server, use 'serverdiff' instead. +``` + +## repo serverdiff + +``` +Usage: repo serverdiff [opts] [] + +Show differences done on the server compared to local at the given path. + +Showing +++ if things were added on the server (or removed locally). +If you made changes locally, use 'localdiff' instead. +``` diff --git a/repo/repo b/repo/repo index 9ac5441..ec8d93d 100755 --- a/repo/repo +++ b/repo/repo @@ -532,6 +532,21 @@ while [ $# -gt 0 ]; do shift done +if [[ $(uname -o) == 'Cygwin' ]]; then + # replace every // backslash \\ with / slash / + path=${path//\\//} + + # if $path starts with + if [[ $path =~ ^[A-Z]: ]]; then + # make lower case + drive=${BASH_REMATCH[0],,} + + # strip ':' from + # replace with /cygdrive/ + path=${path/${BASH_REMATCH[0]}/\/cygdrive\/${drive/:/}} + fi +fi + if [ $action == "checkout" ]; then # special checkout init steps # path argument must be a jcr path @@ -653,7 +668,7 @@ packageName="repo${packageName//[^[:alpha:][:digit:].-]/}" packageVersion=$(date +"%s") # prepare zip contents in temp directory -if [[ $(uname) =~ CYGWIN_NT.* ]]; then +if [[ $(uname -o) == 'Cygwin' ]]; then tmpDir=`mktemp -d -p .. -t repo.XXX` else tmpDir=`mktemp -d -t repo.XXX` diff --git a/repo/repoWin.ps1 b/repo/repoWin.ps1 index 822282a..ad41634 100644 --- a/repo/repoWin.ps1 +++ b/repo/repoWin.ps1 @@ -1,25 +1,33 @@ - -# Script for running 'repo' tool in either Windows Subsystem for Linux's or Cygwin's bash - -Param($command, $drive, $path) - -if (Test-Path $path) { - $path = ($path -replace '\\','/') - $path = ($path -replace '.:',"/$drive/c") - $cmdPath = (Split-Path -parent $PSCommandPath) - - if ($drive -ne "cygdrive") { - $cmdPath = $($cmdPath -replace '\\','/') - $cmdPath = ($cmdPath -replace '.:',"/$drive/c") - - bash -l "$cmdPath/repo" $command -f $path - } - else { - C:\cygwin64\bin\bash.exe -l "$cmdPath\repo" $command -f $path - } -} -else { - Write-Error "File $path not found" - exit 1 -} -Write-Output "Executed $command on $path" \ No newline at end of file + +# Script for running 'repo' tool in either Windows Subsystem for Linux's or Cygwin's bash + +Param($command, $path) + +if (Test-Path $path) { + $cmdPath = Split-Path -parent $PSCommandPath + + #if Windows Subsystem for Linux (WSL) + if ( $(Get-Command bash).Source -eq "C:\WINDOWS\system32\bash.exe") { + $path = $path -replace '\\','/' + $path = $path -replace '.:',"/mnt/c" + + $cmdPath = $cmdPath -replace '\\','/' + $cmdPath = $cmdPath -replace '.:','/mnt/c' + + bash -l "$cmdPath/repo" $command -f $path + } + # if Cygwin is installed and CYGWIN environment variable pointing to its installation location is defined + elseif (Test-Path env:CYGWIN) { + $cygwin = "$($env:CYGWIN)\bin\bash.exe" + $params = '-l',"$cmdPath\repo","$command",'-f',"$path" + & $cygwin $params + } + else { + Write-Error "'bash' cannot be found. Please install either Windows Subsystem for Linux or Cygwin. If the latter, define CYGWIN environment variable pointing to the installation location." + exit 2 + } +} +else { + Write-Error "File $path not found" + exit 1 +} From 1c6a2ee71f94c2fbcd01e8b45987015393e4f959 Mon Sep 17 00:00:00 2001 From: Leo Heinman Date: Tue, 23 Jul 2019 22:44:17 -0700 Subject: [PATCH 6/6] changed EOLs in README.md --- repo/README.md | 804 ++++++++++++++++++++++++------------------------- 1 file changed, 402 insertions(+), 402 deletions(-) diff --git a/repo/README.md b/repo/README.md index cbcd21b..0956f00 100644 --- a/repo/README.md +++ b/repo/README.md @@ -1,402 +1,402 @@ -# repo - FTP-like tool for JCR content - -Transfers filevault JCR content between the filesystem (unzipped content package) and a server such as AEM (running the package manager HTTP API). Great for development. - -Similar to the `vlt` command line tool from [jackrabbit-filevault](http://jackrabbit.apache.org/filevault/overview.html), but faster, bash-script-only and with minimal dependencies. - -How it works: For a given path inside a `jcr_root` filevault structure on the filesystem, it creates a package with a single filter for the entire subtree and pushes that to the server (put), fetches it from the server (get) or compares the differences (status and diff). Please note that it will always overwrite the entire file or directory specified. Does not support multiple filter paths or vlt's filter.xml. - -[Licensed under Apache 2.0](../LICENSE). - -## Table of Contents - -* [Installation](#installation) - * [Homebrew (Mac)](#homebrew-mac) - * [Manual installation](#manual-installation) - * [Integration into IntelliJ](#integration-into-intellij) - * [Integration into Eclipse](#integration-into-eclipse) - * [Integration into Visual Studio Code](#integration-into-visual-studio-code) -* [Usage](#usage) - * [common options](#common-options) - * [repo checkout (since 1.4)](#repo-checkout-since-14) - * [repo put](#repo-put) - * [repo get](#repo-get) - * [repo status](#repo-status) - * [repo diff](#repo-diff) - * [repo localdiff](#repo-localdiff) - * [repo serverdiff](#repo-serverdiff) - -## Installation - -Official release versions are [tracked here on github](https://github.com/Adobe-Marketing-Cloud/tools/releases). - -### Homebrew (Mac) - -For [Homebrew](http://brew.sh) users releases are available via the [adobe-marketing-cloud/brews tap](https://github.com/Adobe-Marketing-Cloud/homebrew-brews): -``` -brew tap adobe-marketing-cloud/brews -brew install adobe-marketing-cloud/brews/repo -``` - -### Manual installation - -`repo` is a single bash script depending on basic unix tools (zip, unzip, curl, rsync, mktemp). - -Download and put it onto your `$PATH`: - -* [Download latest release](https://github.com/Adobe-Marketing-Cloud/tools/releases/latest). -* [Download latest beta](repo) - just the script directly from this github repository. - -Supported platforms: - -- Mac OSX (+ curl, rsync) -- Linux (+ curl, rsync) -- Windows with Cygwin (+ zip, unzip, curl, rsync packages) - -### Integration into IntelliJ - -Want to hit a shortcut like `ctrl + cmd + P` and have your current open file or selected folder pushed to the server from within IntelliJ? Without having to save or anything else? Just set up these tools below. - -Setup external tools under Settings > Tools > External Tools. -Add a group "repo" and add commands below, leaving the "Working directory" empty. -Keyboard shortcuts are managed under Settings > Keymap, search for "repo" after you created the external tool entries. -Below shortcuts are examples, your milage may vary. - -#### Mac: - -* put - * Program: `repo` (if in `$PATH`, otherwise use the absolute path to repo here) - * Parameters: `put -f $FilePath$` - * Keyboard Shortcut: `ctrl + cmd + P` -* get - * Program: `repo` - * Parameters: `get -f $FilePath$` - * Keyboard Shortcut: `ctrl + cmd + G` (note: already used by default keymap for grepping) -* status - * Program: `repo` - * Parameters: `st $FilePath$` - * Keyboard Shortcut: `ctrl + cmd + S` -* diff - * Program: `repo` - * Parameters: `diff $FilePath$` - * Keyboard Shortcut: `ctrl + cmd + D` - -#### Windows: - -Cygwin or Windows Subsystem for Linux (WSL) are required, and repo must be called explicitly using Cygwin's or WSL's `bash`. - -Make sure the folder containing `repo` is in Windows' `$Path` variable. Alternatively replace `repoWin.ps1` in the parameters below with the full absolute path, for example `C:\tools\repoWin.ps1`. - -* put - * Program: `powershell` - * Parameters: `repoWin.ps1 put $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` -* get - * Program: `powershell` - * Parameters: `repoWin.ps1 get $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + R` -* status - * Program: `powershell` - * Parameters: `repoWin.ps1 status $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` -* diff - * Program: `powershell` - * Parameters: `repoWin.ps1 diff $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + E` - -An alternative way to run `repo` under Cygwin is to make sure the path to Cygwin installation directory is the first on the `$Path` variable list and provide the following external tools settings: - -* put - * Program: `bash` (use the absolute path to `bash` here) - * Parameters: `repo put -f $FilePath$` (use the absolute path to `repo` here) - * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` -* get - * Program: `bash` - * Parameters: `repo get -f $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + R` -* status - * Program: `bash` - * Parameters: `repo st $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` -* diff - * Program: `bash` - * Parameters: `repo diff $FilePath$` - * Keyboard Shortcut: `Ctrl + Alt + Shift + E` - -### Integration into Eclipse - -Setup external tools under `Run > Exernal Tools > Exernal Tool Configurations...`. -Add a Programm which points to the `repo` shell script for each desired REPO operation. -I would recommend to disable `Build before launch` in the Build tab. - -Examples: - -* put - * Location: `/repo` - * Working Directory: `${container_loc}` - * Arguments: `put -f ${selected_resource_name}` -* get - * Location: `/repo` - * Working Directory: `${container_loc}` - * Arguments: `get -f ${selected_resource_name}` - -### Integration into Visual Studio Code - -Configure custom tasks under `Terminal > Configure Tasks... > Create tasks.json file from template > Others`. -This will create a `tasks.json` beneath a `.vscode` directory in the current workspace. - -Below are examples for tasks using `repo`, assuming `repo` has been added and available at the terminal path. - -*Note, variables available are scoped to the current opened file. See [Variables Reference](https://code.visualstudio.com/docs/editor/variables-reference) for more info.* - -``` -// .vscode/tasks.json -{ - // examples of using repo to push and pull files and folders from a server running at localhost:4502 - // the tasks with folders actions will be perfomed on the folder of the current file open in the editor - // see https://code.visualstudio.com/docs/editor/variables-reference for more details - - "version": "2.0.0", - "tasks": [ - { - "label": "put file", - "type": "shell", - "command": "repo put -f ${file}", - "problemMatcher": [] - }, - { - "label": "put folder", - "type": "shell", - "command": "repo put -f ${fileDirname}", - "problemMatcher": [] - }, - { - "label": "get file", - "type": "shell", - "command": "repo get -f ${file}", - "problemMatcher": [] - }, - { - "label": "get folder", - "type": "shell", - "command": "repo get -f ${fileDirname}", - "problemMatcher": [] - } - ] -} -``` -Keyboard shortcuts can be created under `Code > Preferences > Keyboard Shortcuts > edit keybindings.json` - -Below are examples of keyboard shortcuts to trigger the custom tasks, your mileage may vary. - -``` -// keybindings.json -// keyboard shortcuts for repo tasks -[ - { - "key": "ctrl+cmd+p", - "command": "workbench.action.tasks.runTask", - "args": "put file" - }, - { - "key": "shift+cmd+p", - "command": "workbench.action.tasks.runTask", - "args": "put folder" - }, - { - "key": "ctrl+cmd+g", - "command": "commandId", - "when": "editorTextFocus" - },{ - "key": "ctrl+cmd+g", - "command": "workbench.action.tasks.runTask", - "args": "get file" - }, - { - "key": "shift+cmd+g", - "command": "workbench.action.tasks.runTask", - "args": "get folder" - } -] -``` - -## Usage - -``` -Usage: repo [opts] [] - -FTP-like tool for JCR content, with support for diffing. - -Transfers filevault JCR content between the filesystem (unzipped content package) -and a server such as AEM (running the package manager HTTP API). - -For a given path inside a jcr_root filevault structure on the filesystem, it -creates a package with a single filter for the entire subtree and pushes that to -the server (put), fetches it from the server (get) or compares the differences -(status and diff). Please note that it will always overwrite the entire file or -directory specified. Does not support multiple filter paths or vlt's filter.xml. - -Available commands: - - checkout intial checkout of server content on file system - put upload local file system content to server - get download server content to local file system - status (st) list status of modified/added/deleted files - diff show differences, same as 'localdiff' - - localdiff show differences done locally compared to server - serverdiff show differences done on the server compared to local - -Config files: - - .repo - - Can be placed in checkout or any parent directory. Allows to configure - server and credentials. Note that command line options take precedence. - - server=http://server.com:8080 - credentials=user:pwd - - - .repoignore - - Placed in the jcr_root directory, this file can list files to ignore - using glob patterns. Also supported are .vltignore files. - -Examples: - - Assume a running CQ server on http://localhost:4502 - - (1) Start from scratch, working on /apps/project available on server - - repo checkout /apps/project - - (2) Upload changes to server - - cd jcr_root/apps/project - vim .content.xml # some modifications - repo put # upload & overwrite entire dir - touch file.jsp # add new file - repo put file.jsp # just push single file - - (3) Download changes from server - - repo get - - (4) Show status and diff - - repo st - repo diff - - (5) Use custom server & credentials - - repo st -s localhost:8888 -u user:pwd - - (6) Avoid interactive confirmation (force) - Be careful, easy to wipe out your repository! - - repo put -f - -Use 'repo -h' for help on a specific command. -``` - -## common options - -``` -Arguments: - local directory or file to sync; defaults to current dir - -Options: - -h --help show this help - -s server, defaults to 'http://localhost:4502' - include context path if needed - -u : user and password, defaults to 'admin:admin' -``` - -## repo checkout (since 1.4) - -``` -Usage: repo checkout [opts] [] - -Initially check out from the server on the file system. - -This will create a jcr_root folder in the current directory and check -out the in there. If this is called within a jcr_root or -a jcr_root exists within the current directory, it will detect that -and check out the in there. - -Arguments: - jcr path to checkout (should be a folder) -``` - -## repo put - -``` -Usage: repo put [opts] [] - -Upload local file system content to server for the given path. - -Options: - -f force, don't ask for confirmation - -q quiet, don't output anything -``` - -## repo get - -``` -Usage: repo get [opts] [] - -Download server content to local filesystem for the given path. - -Options: - -f force, don't ask for confirmation - -q quiet, don't output anything -``` - -## repo status - -``` -Usage: repo status [opts] [] - -List status of files compared to the server at the given path. - -Status legend: - M modified - A added locally / deleted remotely - D removed locally / added remotely - ~ fd conflict: local file vs. remote directory - ~ df conflict: local directory vs. remote file -``` - -## repo diff - -``` -Usage: repo diff [opts] [] - -Show differences done locally compared to server at the given path. - -Same as 'localdiff', showing +++ if things were added locally. -If you made changes on the server, use 'serverdiff' instead. -``` - -## repo localdiff - -``` -Usage: repo localdiff [opts] [] - -Show differences done locally compared to server at the given path. - -Showing +++ if things were added locally (or removed on the server). -If you made changes on the server, use 'serverdiff' instead. -``` - -## repo serverdiff - -``` -Usage: repo serverdiff [opts] [] - -Show differences done on the server compared to local at the given path. - -Showing +++ if things were added on the server (or removed locally). -If you made changes locally, use 'localdiff' instead. -``` +# repo - FTP-like tool for JCR content + +Transfers filevault JCR content between the filesystem (unzipped content package) and a server such as AEM (running the package manager HTTP API). Great for development. + +Similar to the `vlt` command line tool from [jackrabbit-filevault](http://jackrabbit.apache.org/filevault/overview.html), but faster, bash-script-only and with minimal dependencies. + +How it works: For a given path inside a `jcr_root` filevault structure on the filesystem, it creates a package with a single filter for the entire subtree and pushes that to the server (put), fetches it from the server (get) or compares the differences (status and diff). Please note that it will always overwrite the entire file or directory specified. Does not support multiple filter paths or vlt's filter.xml. + +[Licensed under Apache 2.0](../LICENSE). + +## Table of Contents + +* [Installation](#installation) + * [Homebrew (Mac)](#homebrew-mac) + * [Manual installation](#manual-installation) + * [Integration into IntelliJ](#integration-into-intellij) + * [Integration into Eclipse](#integration-into-eclipse) + * [Integration into Visual Studio Code](#integration-into-visual-studio-code) +* [Usage](#usage) + * [common options](#common-options) + * [repo checkout (since 1.4)](#repo-checkout-since-14) + * [repo put](#repo-put) + * [repo get](#repo-get) + * [repo status](#repo-status) + * [repo diff](#repo-diff) + * [repo localdiff](#repo-localdiff) + * [repo serverdiff](#repo-serverdiff) + +## Installation + +Official release versions are [tracked here on github](https://github.com/Adobe-Marketing-Cloud/tools/releases). + +### Homebrew (Mac) + +For [Homebrew](http://brew.sh) users releases are available via the [adobe-marketing-cloud/brews tap](https://github.com/Adobe-Marketing-Cloud/homebrew-brews): +``` +brew tap adobe-marketing-cloud/brews +brew install adobe-marketing-cloud/brews/repo +``` + +### Manual installation + +`repo` is a single bash script depending on basic unix tools (zip, unzip, curl, rsync, mktemp). + +Download and put it onto your `$PATH`: + +* [Download latest release](https://github.com/Adobe-Marketing-Cloud/tools/releases/latest). +* [Download latest beta](repo) - just the script directly from this github repository. + +Supported platforms: + +- Mac OSX (+ curl, rsync) +- Linux (+ curl, rsync) +- Windows with Cygwin (+ zip, unzip, curl, rsync packages) + +### Integration into IntelliJ + +Want to hit a shortcut like `ctrl + cmd + P` and have your current open file or selected folder pushed to the server from within IntelliJ? Without having to save or anything else? Just set up these tools below. + +Setup external tools under Settings > Tools > External Tools. +Add a group "repo" and add commands below, leaving the "Working directory" empty. +Keyboard shortcuts are managed under Settings > Keymap, search for "repo" after you created the external tool entries. +Below shortcuts are examples, your milage may vary. + +#### Mac: + +* put + * Program: `repo` (if in `$PATH`, otherwise use the absolute path to repo here) + * Parameters: `put -f $FilePath$` + * Keyboard Shortcut: `ctrl + cmd + P` +* get + * Program: `repo` + * Parameters: `get -f $FilePath$` + * Keyboard Shortcut: `ctrl + cmd + G` (note: already used by default keymap for grepping) +* status + * Program: `repo` + * Parameters: `st $FilePath$` + * Keyboard Shortcut: `ctrl + cmd + S` +* diff + * Program: `repo` + * Parameters: `diff $FilePath$` + * Keyboard Shortcut: `ctrl + cmd + D` + +#### Windows: + +Cygwin or Windows Subsystem for Linux (WSL) are required, and repo must be called explicitly using Cygwin's or WSL's `bash`. + +Make sure the folder containing `repo` is in Windows' `$Path` variable. Alternatively replace `repoWin.ps1` in the parameters below with the full absolute path, for example `C:\tools\repoWin.ps1`. + +* put + * Program: `powershell` + * Parameters: `repoWin.ps1 put $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` +* get + * Program: `powershell` + * Parameters: `repoWin.ps1 get $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + R` +* status + * Program: `powershell` + * Parameters: `repoWin.ps1 status $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` +* diff + * Program: `powershell` + * Parameters: `repoWin.ps1 diff $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + E` + +An alternative way to run `repo` under Cygwin is to make sure the path to Cygwin installation directory is the first on the `$Path` variable list and provide the following external tools settings: + +* put + * Program: `bash` (use the absolute path to `bash` here) + * Parameters: `repo put -f $FilePath$` (use the absolute path to `repo` here) + * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` +* get + * Program: `bash` + * Parameters: `repo get -f $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + R` +* status + * Program: `bash` + * Parameters: `repo st $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` +* diff + * Program: `bash` + * Parameters: `repo diff $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + E` + +### Integration into Eclipse + +Setup external tools under `Run > Exernal Tools > Exernal Tool Configurations...`. +Add a Programm which points to the `repo` shell script for each desired REPO operation. +I would recommend to disable `Build before launch` in the Build tab. + +Examples: + +* put + * Location: `/repo` + * Working Directory: `${container_loc}` + * Arguments: `put -f ${selected_resource_name}` +* get + * Location: `/repo` + * Working Directory: `${container_loc}` + * Arguments: `get -f ${selected_resource_name}` + +### Integration into Visual Studio Code + +Configure custom tasks under `Terminal > Configure Tasks... > Create tasks.json file from template > Others`. +This will create a `tasks.json` beneath a `.vscode` directory in the current workspace. + +Below are examples for tasks using `repo`, assuming `repo` has been added and available at the terminal path. + +*Note, variables available are scoped to the current opened file. See [Variables Reference](https://code.visualstudio.com/docs/editor/variables-reference) for more info.* + +``` +// .vscode/tasks.json +{ + // examples of using repo to push and pull files and folders from a server running at localhost:4502 + // the tasks with folders actions will be perfomed on the folder of the current file open in the editor + // see https://code.visualstudio.com/docs/editor/variables-reference for more details + + "version": "2.0.0", + "tasks": [ + { + "label": "put file", + "type": "shell", + "command": "repo put -f ${file}", + "problemMatcher": [] + }, + { + "label": "put folder", + "type": "shell", + "command": "repo put -f ${fileDirname}", + "problemMatcher": [] + }, + { + "label": "get file", + "type": "shell", + "command": "repo get -f ${file}", + "problemMatcher": [] + }, + { + "label": "get folder", + "type": "shell", + "command": "repo get -f ${fileDirname}", + "problemMatcher": [] + } + ] +} +``` +Keyboard shortcuts can be created under `Code > Preferences > Keyboard Shortcuts > edit keybindings.json` + +Below are examples of keyboard shortcuts to trigger the custom tasks, your mileage may vary. + +``` +// keybindings.json +// keyboard shortcuts for repo tasks +[ + { + "key": "ctrl+cmd+p", + "command": "workbench.action.tasks.runTask", + "args": "put file" + }, + { + "key": "shift+cmd+p", + "command": "workbench.action.tasks.runTask", + "args": "put folder" + }, + { + "key": "ctrl+cmd+g", + "command": "commandId", + "when": "editorTextFocus" + },{ + "key": "ctrl+cmd+g", + "command": "workbench.action.tasks.runTask", + "args": "get file" + }, + { + "key": "shift+cmd+g", + "command": "workbench.action.tasks.runTask", + "args": "get folder" + } +] +``` + +## Usage + +``` +Usage: repo [opts] [] + +FTP-like tool for JCR content, with support for diffing. + +Transfers filevault JCR content between the filesystem (unzipped content package) +and a server such as AEM (running the package manager HTTP API). + +For a given path inside a jcr_root filevault structure on the filesystem, it +creates a package with a single filter for the entire subtree and pushes that to +the server (put), fetches it from the server (get) or compares the differences +(status and diff). Please note that it will always overwrite the entire file or +directory specified. Does not support multiple filter paths or vlt's filter.xml. + +Available commands: + + checkout intial checkout of server content on file system + put upload local file system content to server + get download server content to local file system + status (st) list status of modified/added/deleted files + diff show differences, same as 'localdiff' + + localdiff show differences done locally compared to server + serverdiff show differences done on the server compared to local + +Config files: + + .repo + + Can be placed in checkout or any parent directory. Allows to configure + server and credentials. Note that command line options take precedence. + + server=http://server.com:8080 + credentials=user:pwd + + + .repoignore + + Placed in the jcr_root directory, this file can list files to ignore + using glob patterns. Also supported are .vltignore files. + +Examples: + + Assume a running CQ server on http://localhost:4502 + + (1) Start from scratch, working on /apps/project available on server + + repo checkout /apps/project + + (2) Upload changes to server + + cd jcr_root/apps/project + vim .content.xml # some modifications + repo put # upload & overwrite entire dir + touch file.jsp # add new file + repo put file.jsp # just push single file + + (3) Download changes from server + + repo get + + (4) Show status and diff + + repo st + repo diff + + (5) Use custom server & credentials + + repo st -s localhost:8888 -u user:pwd + + (6) Avoid interactive confirmation (force) + Be careful, easy to wipe out your repository! + + repo put -f + +Use 'repo -h' for help on a specific command. +``` + +## common options + +``` +Arguments: + local directory or file to sync; defaults to current dir + +Options: + -h --help show this help + -s server, defaults to 'http://localhost:4502' + include context path if needed + -u : user and password, defaults to 'admin:admin' +``` + +## repo checkout (since 1.4) + +``` +Usage: repo checkout [opts] [] + +Initially check out from the server on the file system. + +This will create a jcr_root folder in the current directory and check +out the in there. If this is called within a jcr_root or +a jcr_root exists within the current directory, it will detect that +and check out the in there. + +Arguments: + jcr path to checkout (should be a folder) +``` + +## repo put + +``` +Usage: repo put [opts] [] + +Upload local file system content to server for the given path. + +Options: + -f force, don't ask for confirmation + -q quiet, don't output anything +``` + +## repo get + +``` +Usage: repo get [opts] [] + +Download server content to local filesystem for the given path. + +Options: + -f force, don't ask for confirmation + -q quiet, don't output anything +``` + +## repo status + +``` +Usage: repo status [opts] [] + +List status of files compared to the server at the given path. + +Status legend: + M modified + A added locally / deleted remotely + D removed locally / added remotely + ~ fd conflict: local file vs. remote directory + ~ df conflict: local directory vs. remote file +``` + +## repo diff + +``` +Usage: repo diff [opts] [] + +Show differences done locally compared to server at the given path. + +Same as 'localdiff', showing +++ if things were added locally. +If you made changes on the server, use 'serverdiff' instead. +``` + +## repo localdiff + +``` +Usage: repo localdiff [opts] [] + +Show differences done locally compared to server at the given path. + +Showing +++ if things were added locally (or removed on the server). +If you made changes on the server, use 'serverdiff' instead. +``` + +## repo serverdiff + +``` +Usage: repo serverdiff [opts] [] + +Show differences done on the server compared to local at the given path. + +Showing +++ if things were added on the server (or removed locally). +If you made changes locally, use 'localdiff' instead. +```