Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add more flexibility #413

Merged
merged 29 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
77c4063
fix deprecation warning, support a more modern layout
dustinrue Jul 5, 2024
cb6d5c9
fix typo in readme
dustinrue Jul 5, 2024
80092f3
improved init and build systems
dustinrue Jul 5, 2024
147c729
attempt to make linter happy
dustinrue Jul 5, 2024
bbaae33
fix description for create-payload
dustinrue Aug 9, 2024
a50a15d
monorepo instead of modern, common instead of legacy, improve init pr…
dustinrue Aug 9, 2024
686b4e4
convenience method for updating the composer lock file
dustinrue Aug 9, 2024
83b03a4
ability to package into a container image, updated readme
dustinrue Aug 9, 2024
14e3cdc
Remove directory slash detection; properly name templateInitPath vari…
tlovett1 Aug 15, 2024
da5a17b
Merge branch 'feature/add-more-flexibility' into feature/add-more-fle…
tlovett1 Aug 15, 2024
71547ff
Change standard layout to wpparent; remove create-payload and support…
tlovett1 Aug 15, 2024
53698e1
Fix typo
tlovett1 Aug 15, 2024
81dc4c4
Use wpparent
tlovett1 Aug 15, 2024
2741ae7
Remove build_script_path as it's not needed anymore
tlovett1 Aug 15, 2024
e31e262
Remove deploy_script_path
tlovett1 Aug 15, 2024
ea8fc46
Rename build-setup.sh to scripts.sh
tlovett1 Aug 15, 2024
345a06e
Now we get the git branch in node so we can pass the proper environme…
tlovett1 Aug 15, 2024
470ae80
Add skip ci option
tlovett1 Aug 19, 2024
fc3f2c9
Remove unneeded default variable
tlovett1 Aug 19, 2024
4356cdd
Remove duplicate composer installs; fix project layout checking logic
tlovett1 Aug 19, 2024
f848f27
Fix variables
tlovett1 Aug 19, 2024
800b38d
Doc updates
tlovett1 Aug 19, 2024
c6700d8
Doc updates
tlovett1 Aug 19, 2024
47aef83
Fix message
tlovett1 Aug 19, 2024
99fafc7
Only pushd and popd in wpparent layout
tlovett1 Aug 20, 2024
9a76fed
Merge pull request #421 from 10up/feature/add-more-flexibility-tl
tlovett1 Aug 20, 2024
a4499e8
keep consistent with the project on tabs vs spaces
dustinrue Aug 20, 2024
61ba982
maybe support shells other than bash
dustinrue Aug 20, 2024
8587947
Add changeset
tlovett1 Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-pumpkins-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"10up-toolkit": patch
---

Simple enhancements to toolkit project command to align with devops needs.
24 changes: 8 additions & 16 deletions packages/toolkit/PROJECTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,42 +58,34 @@ In this scenario, `deploy_from` would be set to `wp` and `deploy_to_subdir` woul

`deploy_type` currently supports `rsync`, `wpe` (WP Engine), and `pantheon`. It defaults to `rsync`. If WPE or Pantheon is choosen, `deploy_to` should contain a Git URL. More deploy types will be added in the future.

The following are additional optional variables that allow you to use custom scripts different than the ones provided by 10up Toolkit. You shouldn't need to use these unless you are doing something super custom. All these paths are relative from the root of your project.

```yaml
deploy_script_path: "" # Custom deploy script
build_script_path: "" # For using a build script in a different location
create_payload_script_path: "" # Custom create payload script
```

## Commands

The project subcommand provides a variety of utlities for creating, building, and deploying 10up-specific projects.

List of commands:

```bash
10up-toolkit project init [<path>] [--template=<Git repository>] [--name=<Project Name>] [--confirm] [--skip-composer]
10up-toolkit project init [--path=<path>] [--layout=<layout>] [--template=<Git repository>] [--name=<Project Name>] [--confirm] [--skip-composer] [--skip-ci]
```

`init` creates a project. You can optionally provide it a number of parameters or answer the prompts. If no path is provided, it will initialize the project in the current directory. You will be prompted to choose a template e.g. [WP Scaffold](https://github.com/10up/wp-scaffold). Init will automatically search and replace prefixes using the project name you provide.
`init` creates a project. You can optionally provide it a number of parameters or answer the prompts. If no path is provided, it will initialize the project in the current directory. If no layout is provided, it will default to `wpcontent` which means the project is rooted in `wp-content` (The other option is `wpparent` where the root of the project is one directory above WordPress). You will be prompted to choose a template e.g. [WP Scaffold](https://github.com/10up/wp-scaffold). Init will automatically search and replace prefixes using the project name you provide.

```bash
10up-toolkit project build
10up-toolkit project build [--type=<type>]
```

`build` simply executes your `scripts/build.sh` file (or other path you specify). `build` will be executed before deploying files.
`build` will build your project e.g. `composer install`, `npm install`, and `npm run build`. It will execute all the `.sh` files in your `scripts/` directory where you can add custom build logic for your particular project. `--type` defaults to local e.g. build for your local environment. In CI, type will be set to `full`.

```bash
10up-toolkit project create-payload <branch>
10up-toolkit project generate-ci [--confirm] [--path=<path>]
```

This command creates a payload directory of the built project (including WordPress) for deployment. Engineers likely won't need to run this command themselves as GitLab does it automatically. You must provide a branch that corresponds to an environment in `.tenup.yml`.
This command generates necessary CI files. For GitLab, this would be `.gitlab-ci.yml`. Right now this only supports GitLab but we will add support for GitHub in the future.

```bash
10up-toolkit project generate-ci [--confirm] [--path=<path>]
10up-toolkit project update-composer
```

This command generates necessary CI files. For GitLab, this would be `.gitlab-ci.yml`. Right now this only supports GitLab but we will add support for GitHub in the future.
Convenience function to update all dependencies in all found composer.json files. Also generates updated lock files.

**Note that generating CI files is currently in alpha and may require manual editing to fix issues.**
3 changes: 0 additions & 3 deletions packages/toolkit/project/default-variables.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"project_name": "10up Project",
"php_version": "8.2",
"build_script_path": "",
"wordpress_version": "",
"deploy_script_path": "",
"create_payload_script_path": "",
"environments": []
}
2 changes: 1 addition & 1 deletion packages/toolkit/project/gitlab/.gitlab-ci.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ build_plugins_and_themes:
stage: build
script:
- nvm install 18
- npx 10up-toolkit project create-payload $CI_COMMIT_REF_NAME
- npx 10up-toolkit project build --type=full
artifacts:
paths:
- payload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ deploy_production:
MULTI_DEV_ENVIRONMENT: "{{branch}}"
WORDPRESS_VERSION: {{wordpress_version}}
GIT_URL: {{deploy_to}}
EXCLUDES: {{deploy_file_excludes}}
EXCLUDES: {{rsync_file_excludes}}
allow_failure: false
only:
refs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ deploy_{{branch}}:
MULTI_DEV_ENVIRONMENT: "{{branch}}"
WORDPRESS_VERSION: {{wordpress_version}}
GIT_URL: {{deploy_to}}
EXCLUDES: {{deploy_file_excludes}}
EXCLUDES: {{rsync_file_excludes}}
allow_failure: false
only:
refs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ deploy_production:
variables:
DESTINATION: {{deploy_to}}
SUBDIR: {{deploy_to_subdir}}
EXCLUDES: {{deploy_file_excludes}}
EXCLUDES: {{rsync_file_excludes}}
only:
refs:
- {{branch}}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ deploy_{{branch}}:
variables:
DESTINATION: {{deploy_to}}
SUBDIR: {{deploy_to_subdir}}
EXCLUDES: {{deploy_file_excludes}}
EXCLUDES: {{rsync_file_excludes}}
only:
refs:
- {{branch}}
26 changes: 26 additions & 0 deletions packages/toolkit/project/local/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
payload
build/vendor
build/composer.lock
build/composer.json
/vendor
wordpress/.env
wordpress/*php
wordpress/wp-content/uploads
wordpress/wp-includes
wordpress/wp-admin
wordpress/license.txt
wordpress/readme.html
!wordpress/wp-config.php
docker-compose.override.yml
.config.json
wordpress/wp-content/advanced-cache.php
wordpress/wp-content/mu-plugins/10up-experience.php
wordpress/wp-content/mu-plugins/10up-experience/
wordpress/wp-content/mu-plugins/batcache.php
wordpress/wp-content/mu-plugins/batcache/
wordpress/wp-content/mu-plugins/redis-cache.php
wordpress/wp-content/mu-plugins/redis-cache/
wordpress/wp-content/mu-plugins/s3-uploads.php
wordpress/wp-content/mu-plugins/s3-uploads/
wordpress/wp-content/object-cache.php
.lock
21 changes: 17 additions & 4 deletions packages/toolkit/project/local/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Add builds scripts here. This script will be run from the root of your project (same directory as .tenup.yml).
#!/usr/bin/env bash -l
# NOTE: you should keep the above line, at line 1. Only modify if you know what you are doing.

nvm install
node -v
npm install
# You should use npx 10up-toolkit build to build your project. When you do, there are a number of things
# you get "for free" including nvm handling and the basics of building are handled automatically. You
# only need to provide additional build routines if the default build system doesn't quite get things
# right. Adding build scripts is easy. Create as many .sh files as you need in this scripts directory.

# Here is an example script you can use to get you started It assumes you are using a "modern" layout.

# change directories to your theme or plugin
pushd .

# run your build commands
echo "Hello World!"

# return to where we were so the next build script starts off from the same place
popd
7 changes: 7 additions & 0 deletions packages/toolkit/scripts/project/bash/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:latest

USER root
WORKDIR /var/www/html
COPY payload .
RUN mkdir wp-content/uploads && \
chown 33:33 wp-content/uploads
13 changes: 0 additions & 13 deletions packages/toolkit/scripts/project/bash/build-setup.sh

This file was deleted.

20 changes: 0 additions & 20 deletions packages/toolkit/scripts/project/bash/create-payload.sh

This file was deleted.

Loading
Loading