Skip to content

Getting started

Willington Vega edited this page Jan 22, 2021 · 15 revisions

Getting Started

0. Setting up your environment

TL;DR:

Ensure you have an SSH key set up in your GitHub account and add the following entries to your .bash_profile (or .zprofile if you use zsh):

export GITHUB_USERNAME="yourusername"
export GITHUB_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export WP_SVN_USER="username"
export SAKE_PRE_RELEASE_PATH="~/path/to/pre-releases/folder/"
  • The WP_SVN_USER variable should contain the username used to commit plugin changes to the WordPress.org SVN repository.
  • The SAKE_PRE_RELEASE_PATH variable should point to a directory where you want to store the zip for pre-release versions of a plugin created with npx sake prerelease. Create the directory if necessary before trying to use sake.

Note: Previous versions of Sake used the DROPBOX_PATH variable instead of SAKE_PRE_RELEASE_PATH. Despite the deceptive name of the DROPBOX_PATH variable, it didn't point to your Dropbox folder. Instead, the path was set to the folder which contains the pre-releases folder.

As an example, if you had a pre-releases folder named prereleases at the following path:

~/Documents/Projects/prereleases/

the DROPBOX_PATH line should had been set to:

export DROPBOX_PATH="~/Documents/Projects/"

Now, the SAKE_PRE_RELEASE_PATH line should be set to:

export SAKE_PRE_RELEASE_PATH="~/Documents/Projects/prereleases/"

Setup Steps

  1. Generate an SSH key and add the SSH key to your GitHub account, unless you've already done this in the past.

  2. Create a personal access token with "repo" access. You will use this token as the GITHUB_API_KEY in your environment variables.

  3. Create the .bash_profile file: Guide 1, Guide 2

  4. Add the following entries to your .bash_profile (or .zprofile if you use zsh):

    export GITHUB_USERNAME="yourusername"
    export GITHUB_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    export WP_SVN_USER="username"
    export SAKE_PRE_RELEASE_PATH="~/path/to/pre-releases/folder/"

    Alternatively, you can create a .env file in the plugin repo root directory. This works for both single- and multi-plugin repos. The entries in the .env file will override any variables set in your bash profile. This is mostly useful when developing and testing sake itself.

    Note: Please make sure to not commit any .env files to the plugin repo.

    GITHUB_USERNAME="alternativeusername"
    GITHUB_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    WP_SVN_USER="username"
    SAKE_PRE_RELEASE_PATH="~/path/to/pre-releases/folder/"
    
  5. Finally, source the bash profile with:

    source ~/.bash_profile

1. Installing Node.js

Check if Node.js is already installed

If you already have Node.js, you can skip to step 2. To check if Node is already installed, open a new Terminal or Console window and type:

node -v

If vx.xx.xx is returned, you're good to go. If you see an error like command not found, Node.js is not installed on your system. Note that Sake requires node 8.9.4+

Use brew to install Node

You can use Homebrew on OS X to install:

brew update && brew install node

Alternatively, if you can't use Homebrew, you can download an installer for your platform and follow the on-screen instructions to install.

2. Installing sake

Sake needs to be installed for each plugin repo you're working with, although only once for multi-plugin repos. We'll use Node's package manager (NPM) to install Sake. Type the following in your command-line tool of choice.

cd path/to/project/

# Editor's note: it appears that the following line is only needed when first _initializing_ Sake for a repo and not every time it is being installed so this line has been commented out and left here for posterity. Once confirmed, we should consider moving this to a separate, optional step. 
# npm i skyverge/sake    # this should only be run on repo that is not using sake yet

npm update               # run this when you've cloned an existing plugin repo that already is using sake

This will install the sake command locally, allowing it to be run from the repo directory with npx, ie npx sake config

Note that you will be asked for your SSH key passphrase if this is the first time you are using it. Mac should store this in the keychain for future connections.