|
2 | 2 |
|
3 | 3 | ## Overview
|
4 | 4 |
|
5 |
| -This guide will get you up and running with Jetpack development as quickly as possible using our recommended tools. |
| 5 | +This guide is designed to get you up and running working with the Jetpack Monorepo quickly following recommended and supported guidelines. |
6 | 6 |
|
7 |
| -**Prerequisites**: You'll need: |
8 |
| -- Node.js installed (any recent LTS version) |
9 |
| -- Git installed and configured |
10 |
| -- Docker installed and running |
| 7 | +**This guide assumes you are using MacOS or a Linux machine and are an Automattician**. For more detailed information, including setting up local dev environments for all contributors, running unit tests, best coding practices, and more, you can use the [full Development Environment guide here](development-environment.md#clone-the-repository). |
11 | 8 |
|
12 | 9 | ## Installation
|
13 | 10 |
|
14 |
| -1. Install the Jetpack CLI: |
15 |
| -```bash |
16 |
| -npm install -g @automattic/jetpack-cli |
17 |
| -``` |
| 11 | +### Using the installation script |
18 | 12 |
|
19 |
| -2. Initialize Jetpack: |
20 |
| -```bash |
21 |
| -jp init |
22 |
| -``` |
| 13 | +To speed up the installation process, you may use our monorepo installation script. To do so: |
23 | 14 |
|
24 |
| -This will: |
25 |
| -- Clone the Jetpack monorepo to your chosen location |
26 |
| -- Guide you through the next steps to get started |
| 15 | +- Clone the Jetpack Monorepo: |
| 16 | + - Using a public SSH key ([recommended](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)): `git clone [email protected]:Automattic/jetpack.git` |
| 17 | + - Or use HTTPS: `git clone https://github.com/Automattic/jetpack.git` |
| 18 | + - Note that the monorepo should not be cloned into the WordPress plugins directory. If you plan on not using the provided Docker environment, read the [full Development Environment guide here](development-environment.md#clone-the-repository) to find out how to add symlinks. |
| 19 | +- `cd` into the cloned `jetpack` folder. |
| 20 | +- Run `tools/install-monorepo.sh` from the monorepo root. |
| 21 | +- You can use the [environment checker script](#check-if-your-environment-is-ready-for-jetpack-development) to confirm that all required tools are installed. |
27 | 22 |
|
28 |
| -## Development Workflow |
| 23 | +Once the installation is complete, continue onto the section [Running Jetpack locally](#running-jetpack-locally). |
29 | 24 |
|
30 |
| -Build and test your changes: |
31 |
| -```bash |
32 |
| -# Build a specific project with dependencies |
33 |
| -jp build plugins/jetpack --deps |
| 25 | +### Installing manually |
34 | 26 |
|
35 |
| -# Or watch for changes |
36 |
| -jp watch plugins/jetpack |
| 27 | +Prior to installation, we recommend using [`Homebrew`](https://brew.sh/) to manage installations and [`nvm`](https://github.com/nvm-sh/nvm/) to manage Node.js versions. If you don't already have those installed, you can do so by copy/pasting each of the following commands and running them in your terminal: |
37 | 28 |
|
38 |
| -# Run tests |
39 |
| -jp test |
40 |
| -``` |
| 29 | +- Homebrew: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` |
| 30 | +- nvm: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash` |
41 | 31 |
|
42 |
| -## Testing with Docker |
| 32 | +The Jetpack Monorepo requires various software to be installed on your machine. |
43 | 33 |
|
44 |
| -Jetpack includes a testing environment using Docker. To start testing: |
| 34 | +- Clone the Jetpack Monorepo: |
| 35 | + - Using a public SSH key ( [recommended ](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)): `git clone [email protected]:Automattic/jetpack.git` |
| 36 | + - Or use HTTPS: `git clone https://github.com/Automattic/jetpack.git` |
| 37 | + - Note that the monorepo should not be cloned into the WordPress plugins directory. If you plan on not using the provided Docker environment, read the [full Development Environment guide here](development-environment.md#clone-the-repository) to find out how to add symlinks. |
| 38 | +- This software needs to be installed or updated system-wide: |
| 39 | + - Bash (will need to be updated from default Mac version): `brew install bash` |
| 40 | + - jq (JSON processor used in scripts): `brew install jq` |
| 41 | +- To install or update the following software, cd into the Jetpack directory that was created when cloning the repo: `cd jetpack`: |
| 42 | + - Node.js (used for build process and our CLI): `nvm install && nvm use` |
| 43 | + - PNPM (a Node.js package manager): `npm install -g pnpm` |
| 44 | + - PHP (the language at the core of the WordPress ecosystem): `source .github/versions.sh && brew install php@$PHP_VERSION` |
| 45 | + - Composer (our PHP package manager): `brew install composer` |
| 46 | + - Jetpack CLI (an internal tool that assists with development): `pnpm install && pnpm jetpack cli link` |
| 47 | + - [You can read more about using the CLI here](https://github.com/Automattic/jetpack/blob/trunk/tools/cli/README.md). |
45 | 48 |
|
46 |
| -1. Start the testing environment: |
47 |
| -```bash |
48 |
| -jp docker up -d |
49 |
| -``` |
| 49 | +### Check if your environment is ready for Jetpack development |
50 | 50 |
|
51 |
| -2. Install WordPress (first time only): |
52 |
| -```bash |
53 |
| -jp docker install |
| 51 | +We provide a script to help you in assessing if everything's ready on your system to contribute to Jetpack. |
| 52 | + |
| 53 | +```sh |
| 54 | +tools/check-development-environment.sh |
54 | 55 | ```
|
55 | 56 |
|
56 |
| -3. Visit http://localhost to see your site! |
| 57 | +Running the script will tell you if you have your environment already set up and what you need to do in order to get it ready for Jetpack development: |
57 | 58 |
|
58 |
| -## Testing WordPress.com Features |
| 59 | +- All green `YES` or `OK` messages mean you're ready to start |
| 60 | +- Red `NO` messages mean something is wrong or missing, and a link will be provided to help you with a fix. |
| 61 | +- Yellow messages indicate something optional is broken or missing. |
59 | 62 |
|
60 |
| -To test features requiring a WordPress.com connection: |
| 63 | +## Running Jetpack locally |
61 | 64 |
|
62 |
| -### For Automatticians: |
63 |
| -Use Jurassic Tube: |
64 |
| -```bash |
65 |
| -jp docker jt-up |
66 |
| -``` |
| 65 | +After everything is installed, you're ready to run Jetpack locally! While there are other supported methods of doing this, we recommend and support using Docker containers. |
67 | 66 |
|
68 |
| -### For External Contributors: |
69 |
| -Use ngrok: |
70 |
| -```bash |
71 |
| -jp docker ngrok-up |
72 |
| -``` |
| 67 | +To setup Docker: |
| 68 | +- Install Docker: |
| 69 | + - Mac: `brew install --cask docker` (This will take a while!) |
| 70 | + - Linux: `brew install docker` |
| 71 | + - `open -a Docker` (or open the app from your Applications folder) to open the GUI application. You will likely need to enter your device password and accept their terms for a first time setup. |
| 72 | +- Copy the settings file from within the monorepo root: `cp tools/docker/default.env tools/docker/.env` |
| 73 | +- Open `tools/docker/.env` and make any modifications you'd like. |
| 74 | + - It's strongly recommend you at least change `WP_ADMIN_PASSWORD` to something more secure. |
| 75 | +- Start the Docker container using `jetpack docker up -d` (this may take some time for the first setup) |
| 76 | +- Install WordPress in your Docker container using `jetpack docker install` |
| 77 | +- Open up http://localhost to see your site! |
| 78 | + |
| 79 | +For more in depth Docker instructions, follow the [Docker environment for Jetpack Development guide](../tools/docker/README.md). |
73 | 80 |
|
74 | 81 | ## Setting up Jurassic Tube
|
75 | 82 |
|
76 | 83 | In order to test features that require a WordPress.com connection and other network related Jetpack features, you'll need a test site that can create local HTTP tunnels. If you're an Automattician, we recommend using Jurassic Tube.
|
77 | 84 |
|
78 | 85 | Note: This is for Automattician use only. For other methods, check out [ngrok](../tools/docker/README.md#using-ngrok-with-jetpack) or [another similar service](https://alternativeto.net/software/ngrok/).
|
79 | 86 |
|
80 |
| -**Warning: This creates a tunnel to your local machine which should not be trusted as secure. If it is compromised, so is your computer and everything it has access to. Only `jp docker jt-up` when needed for testing things that require |
81 |
| -the site to be publicly accessible, and `jp docker jt-down` when completed.** |
| 87 | +**Warning: This creates a tunnel to your local machine which should not be trusted as secure. If it is compromised, so is your computer and everything it has access to. Only `jetpack docker jt-up` when needed for testing things that require the site to be publicly accessible, and `jetpack docker jt-down` when completed.** |
82 | 88 |
|
83 | 89 | - Visit the [jurassic.tube](https://jurassic.tube/) homepage to create a subdomain
|
84 |
| -- Make sure you've run `npm install -g @automattic/jetpack-cli` |
85 |
| -- Make sure Docker is running `jp docker up -d` |
| 90 | +- Make sure you've run `pnpm install && pnpm jetpack cli link` |
| 91 | +- Make sure Docker is running `jetpack docker up -d` |
86 | 92 | - Stand on the monorepo root in your terminal and run `mkdir tools/docker/bin/jt`
|
87 |
| -- Stop and restart the docker env: `jp docker stop && jp docker up -d` |
| 93 | +- Stop and restart the docker env: `jetpack docker stop && jetpack docker up -d` |
88 | 94 | - Download and run the installation script: `curl "https://jurassic.tube/get-installer.php?env=jetpack" -o tools/docker/bin/jt/installer.sh && chmod +x tools/docker/bin/jt/installer.sh && tools/docker/bin/jt/installer.sh`
|
89 |
| -- Set your username: `jp docker jt-config username [your-username-here e.g david]` |
90 |
| -- Set your subdomain: `jp docker jt-config subdomain [your-subdomain-here e.g. spaceman]` |
91 |
| -- Now, you can start your site with `jp docker jt-up` |
| 95 | +- Set your username: `jetpack docker jt-config username [your-username-here e.g david]` |
| 96 | +- Set your subdomain: `jetpack docker jt-config subdomain [your-subdomain-here e.g. spaceman]` |
| 97 | +- Now, you can start your site with `jetpack docker jt-up` |
92 | 98 | - Your site should be available at `https://custom-subdomain.jurassic.tube`
|
93 | 99 |
|
94 |
| -That's all! For more detailed information, see the [Development Environment guide](development-environment.md). |
| 100 | +## Development Workflow |
| 101 | + |
| 102 | +Once you have a local copy of Jetpack and all development tools installed, you can start developing. |
| 103 | + |
| 104 | +1. Make sure the plugin you're developing is activated on your WordPress site. |
| 105 | +2. [Build your project](development-environment.md#building-your-project) using `jetpack build [type/project]` and including its dependencies, such as `jetpack build plugins/jetpack --deps` |
| 106 | +3. Access the plugin's dashboard in your browser. |
| 107 | + |
| 108 | +By default the development build above will run once and if you change any of the files, you need to run `jetpack build` again to see the changes on the site. If you want to avoid that, you can run a continuous build that will rebuild anytime it sees any changes on your local filesystem. To run it, use: |
| 109 | + |
| 110 | +```sh |
| 111 | +jetpack watch |
| 112 | +``` |
| 113 | +### Running Tests |
| 114 | + |
| 115 | +To run PHP, JS, and coverage tests, you can use the Jetpack CLI: `jetpack test` and then choose the project and type of test you'd like to run. |
| 116 | + |
| 117 | +That's all! |
0 commit comments