SWAP

Simple components sharing tool

Installation

pip install swp

Optionnal dependencies

# Linux
apt install tree

# MacOS
brew install tree

Documentation

Swapfile

swap.yaml example:

git@github.com:mathix420/pylone.git:
    # name: local_path:remote_path@optionnal_branch_or_commitID
    pylone_utils: utils:pylone/utils

git@github.com:vuejs/ui.git:
    vue_ui: components/vue_ui:src/components

Commands

  • swp init Will guide you for creating a new config file.
  • swp tree Will show you the path structure of remotes.
  • swp sync Will by directionnal update of tracked modules/files.
  • swp add Will add the specified path to the swapfile.
  • swp rm Will remove the specified path from the swapfile.
  • swp get Will pull a module/file from a specified remote URL and add it to the swapfile.

As swp sync will push local updates to remote, I recommand you to fork repositories like vuejs/ui to have write rights on thems.

Detailed command usage

SWP SYNC

usage: swp sync [-h] [-m COMMIT_MSG] [-f] [NAME [NAME ...]]

positional arguments:
  NAME                  component(s) to sync

optional arguments:
  -h, --help            show this help message and exit
  -m COMMIT_MSG, --commit-msg COMMIT_MSG
                        commit message
  -f, --force           force pushing updates

Pulling

If this file got modified over time on the remote and if you run the command swp sync, SWAP will update this file to it's latest version.

Pushing

If you modified this file locally and have push right to the remote, you can also run swp sync to automatically update the remote version of this file.

SWP ADD

usage: swp add [-h] [-n [NAME]] PATH [DEST] REMOTE

positional arguments:
  PATH                  path of the component
  DEST                  path of the remote component
  REMOTE                git remote url

optional arguments:
  -h, --help            show this help message and exit
  -n [NAME], --name [NAME]
                        name of the component

To sync a new component (which do not exist on remote), you can use the command swp add or you can update the swapfile (swap.yaml) manually.

Example

Original swap.yaml:

git@github.com:example/test.git:
  readme: readme.md:README.md

Running:

swp add my-new-file git@github.com:example/test.git

Will update the swapfile like so:

git@github.com:example/test.git:
  readme: readme.md:README.md
  my-new-file: my-new-file:my-new-file

SWP GET

usage: swp get [-h] [-n [NAME]] PATH [DEST] REMOTE

positional arguments:
  PATH                  remote path of the component
  DEST                  local path of the component
  REMOTE                git remote url

optional arguments:
  -h, --help            show this help message and exit
  -n [NAME], --name [NAME]
                        name of the component

To pull an existing component from remote and sync it, you can use swp get. This command is working just like swp add but pull the file instead of pushing it to remote.

SWP RM

usage: swp rm [-h] NAME

positional arguments:
  NAME        path of the component

optional arguments:
  -h, --help  show this help message and exit

To stop syncing a component, just run swp rm MY-COMPONENT to remove it from the swapfile.

Example

Original swap.yaml:

git@github.com:example/test.git:
  readme: readme.md:README.md
  my-new-file: my-new-file:my-new-file

To stop syncing my-new-file:

swp rm my-new-file

And the swapfile will now look like this:

git@github.com:example/test.git:
  readme: readme.md:README.md

SWP TREE

usage: swp tree [-h]

optional arguments:
  -h, --help  show this help message and exit

With this command you can view all files in all remotes present in the swapfile.

SWP INIT

usage: swp init [-h] [--remote REMOTE] [--folder FOLDER]

optional arguments:
  -h, --help            show this help message and exit

The swp init command can be used to generate a blank swapfile with comments and help to get started.