diff --git a/.eslintrc.json b/.eslintrc.json index 749ac643..f6146e67 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,7 @@ { + "env": { + "browser": true + }, "extends": [ "plugin:@wordpress/eslint-plugin/recommended" ], "rules": { "no-console": 0, diff --git a/.github/actions/composer-install/action.yml b/.github/actions/composer-install/action.yml new file mode 100644 index 00000000..4548d91c --- /dev/null +++ b/.github/actions/composer-install/action.yml @@ -0,0 +1,62 @@ +name: Composer Install + +inputs: + BUILD_FOLDER: + description: 'Folder to run shell commands in.' + required: false + default: ${{ github.workspace }} + COMPOSER_INSTALL_FLAGS: + description: 'Flags to pass to the `composer install` command.' + required: false + default: '--optimize-autoloader --no-dev' + OP_SERVICE_ACCOUNT_TOKEN: + required: true + description: '1Password service account token to use for populating composer auth.json' + OP_VAULT: + description: '1Password vault to use for populating composer auth.json' + required: true + OP_ITEM: + description: '1Password item to use for populating composer auth.json' + required: true + +runs: + using: "composite" + steps: + - name: 'Configure PHP environment' + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + + - name: 'Get composer cache directory' + working-directory: ${{ inputs.BUILD_FOLDER }} + id: composer-cache + shell: bash + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: 'Cache composer dependencies' + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: 'Install 1Password CLI' + uses: 1password/install-cli-action@v1 + + - name: 'Create auth.json via 1Password CLI' + working-directory: ${{ inputs.BUILD_FOLDER }} + shell: bash + env: + OP_SERVICE_ACCOUNT_TOKEN: ${{ inputs.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ inputs.OP_VAULT }} + OP_ITEM: ${{ inputs.OP_ITEM }} + run: op inject -i auth.template.json -o auth.json + + - name: 'Install Composer' + working-directory: ${{ inputs.BUILD_FOLDER }} + shell: bash + run: | + composer install ${{ inputs.COMPOSER_INSTALL_FLAGS }} + rm auth.json diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index e525170d..15365099 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -16,7 +16,9 @@ jobs: name: 'Coding Standards' uses: ./.github/workflows/phpcs.yml secrets: - COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} linting: name: 'Linting' @@ -27,12 +29,16 @@ jobs: needs: [coding-standards, linting] uses: ./.github/workflows/static-analysis.yml secrets: - COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} # Enable this job if you have PHPUnit tests # slic: # name: 'PHP Tests' # needs: [coding-standards, phpstan, linting] # uses: ./.github/workflows/php-tests.yml -# secrets: -# COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }} +# secrets: +# OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} +# OP_VAULT: ${{ secrets.OP_VAULT }} +# OP_ITEM: ${{ secrets.OP_ITEM }} diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 7ea23181..82564944 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -14,16 +14,6 @@ jobs: DEPLOY_REPO: ${{ secrets.DEV_DEPLOY_REPO }} steps: - - ########## - ### BUILD: General SquareOne build steps - - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php - with: - php-version: '8.2' - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Get Build Repository - name: Check out build branch uses: actions/checkout@v4 @@ -31,24 +21,14 @@ jobs: path: ${{ env.BUILD_FOLDER }} ref: ${{github.ref}} - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v4 + # Composer install + - name: 'Composer install' + uses: ./.github/actions/composer-install with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - # Install composer: Add env for plugin keys, composer install, and cleanup - - name: Install composer dependencies - working-directory: ${{ env.BUILD_FOLDER }} - run: | - echo '${{ secrets.COMPOSER_AUTH_JSON }}' > auth.json - composer install --optimize-autoloader --ignore-platform-reqs --no-dev - rm auth.json + BUILD_FOLDER: ${{ env.BUILD_FOLDER }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} # Set up node version - name: Set up node diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 247f6002..0c09b2c8 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -17,15 +17,6 @@ jobs: steps: - ########## - ### BUILD: General SquareOne build steps - - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php - with: - php-version: '8.2' - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Get Build Repository - name: Check out build branch uses: actions/checkout@v4 @@ -33,24 +24,14 @@ jobs: path: ${{ env.BUILD_FOLDER }} ref: ${{github.ref}} - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v4 + # Composer install + - name: 'Composer install' + uses: ./.github/actions/composer-install with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - # Install composer: Add env for plugin keys, composer install, and cleanup - - name: Install composer dependencies - working-directory: ${{ env.BUILD_FOLDER }} - run: | - echo '${{ secrets.COMPOSER_AUTH_JSON }}' > auth.json - composer install --optimize-autoloader --ignore-platform-reqs --no-dev - rm auth.json + BUILD_FOLDER: ${{ env.BUILD_FOLDER }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} # Set up node version - name: Set up node diff --git a/.github/workflows/deploy-stage.yml b/.github/workflows/deploy-stage.yml index 3cd544c5..436e7661 100644 --- a/.github/workflows/deploy-stage.yml +++ b/.github/workflows/deploy-stage.yml @@ -18,15 +18,6 @@ jobs: steps: - ########## - ### BUILD: General SquareOne build steps - - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php - with: - php-version: '8.2' - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Get Build Repository - name: Check out build branch uses: actions/checkout@v4 @@ -34,24 +25,14 @@ jobs: path: ${{ env.BUILD_FOLDER }} ref: ${{github.ref}} - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache composer dependencies - uses: actions/cache@v4 + # Composer install + - name: 'Composer install' + uses: ./.github/actions/composer-install with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - # Install composer: Add env for plugin keys, composer install, and cleanup - - name: Install composer dependencies - working-directory: ${{ env.BUILD_FOLDER }} - run: | - echo '${{ secrets.COMPOSER_AUTH_JSON }}' > auth.json - composer install --optimize-autoloader --ignore-platform-reqs --no-dev - rm auth.json + BUILD_FOLDER: ${{ env.BUILD_FOLDER }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} # Set up node version - name: Set up node diff --git a/.github/workflows/dokku-dev.yml b/.github/workflows/dokku-dev.yml index f368ed2d..e476d1a4 100644 --- a/.github/workflows/dokku-dev.yml +++ b/.github/workflows/dokku-dev.yml @@ -19,4 +19,6 @@ jobs: github_pat_token: ${{ secrets.GH_BOT_TOKEN }} ssh_private_key: ${{ secrets.DOKKU_DEPLOY_KEY }} slack_webhook: ${{ secrets.SLACK_WEBHOOK }} - composer_auth_json: ${{ secrets.COMPOSER_AUTH_JSON }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} diff --git a/.github/workflows/dokku-review-app.yml b/.github/workflows/dokku-review-app.yml index 9ff4a872..1bc0889b 100644 --- a/.github/workflows/dokku-review-app.yml +++ b/.github/workflows/dokku-review-app.yml @@ -34,7 +34,9 @@ jobs: github_pat_token: ${{ secrets.GH_BOT_TOKEN }} ssh_private_key: ${{ secrets.DOKKU_DEPLOY_KEY }} slack_webhook: ${{ secrets.SLACK_WEBHOOK }} - composer_auth_json: ${{ secrets.COMPOSER_AUTH_JSON }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} destroy_review_app: if: (github.event_name == 'pull_request' && github.event.action == 'closed') && contains(github.event.pull_request.labels.*.name, 'Launch Environment') diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 05918eca..48f4078c 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -21,7 +21,7 @@ jobs: - added|modified: 'wp-content/plugins/core/**/*.{pcss,json,js}' - added|modified: 'wp-content/themes/core/**/*.{pcss,json,js}' - added|modified: 'wp-content/mu-plugins/**/*.{pcss,json,js}' - - added|modified: '*.{json,js}' + - added|modified: './*.{json,js}' - name: Set up node if: steps.changed-files.outputs.linting == 'true' @@ -37,4 +37,4 @@ jobs: - name: Check linting if: steps.changed-files.outputs.linting == 'true' - run: npm run server-lint + run: npm run lint:server diff --git a/.github/workflows/php-tests.yml b/.github/workflows/php-tests.yml index 79741138..79695e1f 100644 --- a/.github/workflows/php-tests.yml +++ b/.github/workflows/php-tests.yml @@ -3,9 +3,13 @@ name: 'PHP Tests' on: workflow_call: secrets: - COMPOSER_AUTH_JSON: + OP_SERVICE_ACCOUNT_TOKEN: required: true - description: Composer auth.json + description: 1Password Service Account Token to use for populating composer auth.json + OP_VAULT: + description: 1Password vault to use for populating composer auth.json + OP_ITEM: + description: 1Password item to use for populating composer auth.json jobs: test: @@ -20,7 +24,7 @@ jobs: runs-on: ubuntu-latest env: build_folder: build - COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH_JSON }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} steps: - name: Checkout the repository @@ -100,11 +104,24 @@ jobs: ${SLIC_BIN} info ${SLIC_BIN} config + - name: Install 1Password CLI + if: steps.changed-files.outputs.tests == 'true' + uses: 1password/install-cli-action@v1 + + - name: Create auth.json via 1Password CLI + if: steps.changed-files.outputs.tests == 'true' + env: + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} + run: op inject -i auth.template.json -o auth.json + - name: Set up site for CI if: steps.changed-files.outputs.tests == 'true' run: | ${SLIC_BIN} use site - ${SLIC_BIN} composer install --ignore-platform-reqs + ${SLIC_BIN} composer install --optimize-autoloader --no-progress + ${SLIC_BIN} rm auth.json - name: Run suite tests if: steps.changed-files.outputs.tests == 'true' diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 789a23bd..1fccc795 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -3,19 +3,25 @@ name: Coding Standards on: workflow_call: secrets: - COMPOSER_AUTH_JSON: + OP_SERVICE_ACCOUNT_TOKEN: required: true - description: Composer auth.json + description: '1Password Service Account Token to use for populating composer auth.json' + OP_VAULT: + description: '1Password vault to use for populating composer auth.json' + required: false + OP_ITEM: + description: '1Password item to use for populating composer auth.json' + required: false jobs: phpcs: name: phpcs runs-on: ubuntu-latest steps: - - name: Checkout + - name: 'Checkout' uses: actions/checkout@v4 - - name: Detect File Changes + - name: 'Detect file changes' uses: dorny/paths-filter@v3 id: changed-files with: @@ -27,35 +33,16 @@ jobs: - added|modified: 'wp-content/mu-plugins/**/*.php' - added|modified: 'phpcs.xml.dist' - - name: Configure PHP environment + - name: 'Composer install' if: steps.changed-files.outputs.phpcs == 'true' - uses: shivammathur/setup-php@v2 + uses: ./.github/actions/composer-install with: - tools: composer:2 - php-version: '8.2' + COMPOSER_INSTALL_FLAGS: '--optimize-autoloader' + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} - - name: Get Composer Cache Directory - id: composer-cache - if: steps.changed-files.outputs.phpcs == 'true' - run: | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v4 - if: steps.changed-files.outputs.phpcs == 'true' - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Install Composer - if: steps.changed-files.outputs.phpcs == 'true' - run: | - echo '${{ secrets.COMPOSER_AUTH_JSON }}' > auth.json - composer install --ignore-platform-reqs --optimize-autoloader --no-progress - rm auth.json - - - name: Run PHPCS + - name: 'Run PHPCS' if: steps.changed-files.outputs.phpcs == 'true' run: | composer phpcs diff --git a/.github/workflows/pipeline-dokku.yml b/.github/workflows/pipeline-dokku.yml index c6aa9839..819b24f7 100644 --- a/.github/workflows/pipeline-dokku.yml +++ b/.github/workflows/pipeline-dokku.yml @@ -30,7 +30,14 @@ on: required: true slack_webhook: required: true - composer_auth_json: + OP_SERVICE_ACCOUNT_TOKEN: + required: true + description: '1Password service account token to use for populating composer auth.json' + OP_VAULT: + description: '1Password vault to use for populating composer auth.json' + required: true + OP_ITEM: + description: '1Password item to use for populating composer auth.json' required: true jobs: @@ -73,9 +80,15 @@ jobs: - name: NPM Build run: npm run dist - - name: Composer Auth Setup - run: | - echo '${{ secrets.composer_auth_json }}' > auth.json + - name: 'Install 1Password CLI' + uses: 1password/install-cli-action@v1 + + - name: 'Create auth.json via 1Password CLI' + env: + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} + run: op inject -i auth.template.json -o auth.json - name: Commit Files uses: moderntribe/actions/utils/commit-files@v1 @@ -105,4 +118,3 @@ jobs: app_url: "${{ steps.define_app.outputs.deploy_app }}.${{ inputs.server }}" gha_url: ${{ env.GHA_URL }} status: ${{ job.status }} - diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 089dbd4c..1dfc09d7 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -3,21 +3,23 @@ name: Static Analysis on: workflow_call: secrets: - COMPOSER_AUTH_JSON: + OP_SERVICE_ACCOUNT_TOKEN: required: true - description: Composer auth.json + description: '1Password Service Account Token to use for populating composer auth.json' + OP_VAULT: + description: '1Password vault to use for populating composer auth.json' + OP_ITEM: + description: '1Password item to use for populating composer auth.json' jobs: phpstsan: name: phpstan runs-on: ubuntu-latest steps: - - name: Checkout + - name: 'Checkout' uses: actions/checkout@v4 - with: - fetch-depth: 1 - - name: Detect File Changes + - name: 'Detect file changes' uses: dorny/paths-filter@v3 id: changed-files with: @@ -29,36 +31,15 @@ jobs: - added|modified: 'wp-content/mu-plugins/**/*.php' - added|modified: 'phpstan.neon.dist' - - name: Configure PHP environment - if: steps.changed-files.outputs.phpstan == 'true' - uses: shivammathur/setup-php@v2 - with: - php-version: '8.2' - extensions: mbstring, intl - coverage: none - tools: composer:2 - - - name: Get Composer Cache Directory - id: composer-cache - if: steps.changed-files.outputs.phpstan == 'true' - run: | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v4 + - name: 'Composer install' if: steps.changed-files.outputs.phpstan == 'true' + uses: ./.github/actions/composer-install with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Install Composer - if: steps.changed-files.outputs.phpstan == 'true' - run: | - echo '${{ secrets.COMPOSER_AUTH_JSON }}' > auth.json - composer install --ignore-platform-reqs --optimize-autoloader --no-progress - rm auth.json + COMPOSER_INSTALL_FLAGS: '--optimize-autoloader' + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + OP_VAULT: ${{ secrets.OP_VAULT }} + OP_ITEM: ${{ secrets.OP_ITEM }} - - name: Run PHPStan static analysis + - name: 'Run PHPStan static analysis' if: steps.changed-files.outputs.phpstan == 'true' run: composer phpstan diff --git a/.lando.yml b/.lando.yml index 384c3dc7..5e60cb10 100644 --- a/.lando.yml +++ b/.lando.yml @@ -1,5 +1,6 @@ name: moose recipe: wordpress + config: php: '8.3' database: mariadb:11.5 @@ -7,11 +8,16 @@ config: via: nginx xdebug: false memcached: true + services: appserver: + build: + - composer create-local-configs overrides: environment: - XDEBUG_TRIGGER=1 + node: + type: node:22 # Enabling MailHog will cause an error on start: `/bin/sh: 1: curl: not found`. # Related GH Issue: https://github.com/lando/mailhog/issues/35 @@ -27,7 +33,14 @@ services: # - appserver_nginx # - appserver +events: + post-start: + - appserver: composer install + - node: npm install && npm run build + tooling: + npm: + service: node xdebug-on: service: appserver description: Enable xdebug for nginx. diff --git a/CHANGELOG.md b/CHANGELOG.md index 8643334f..70315b35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,24 @@ item (Added, Changed, Depreciated, Removed, Fixed, Security). ## [2025.01] +- Added: Node service to Lando so FE assets can be built automatically on start up. +- Updated: project start up scripts to automatically generate the correct contents of the lcoal config files. +- Updated: script to install WordPress so we can use a version constant and not install WP every time composer is + installed or updated. +- Updated: ESLint config now supports browser environment variable such as `IntersectionObserver` - Added: ability for table blocks to utilize the `overflow-x` set on them by setting a `min-width` property for the `table` element within the table block. - Updated: Enabled background images on the Group block; We should try to use this instead of the Cover block where possible. +- Added: 1Password CLI integration for automating the creation of auth.json files. +- Added: A composite GitHub action for composer installs. This composite action can be used in any workflow files that + need to composer install. +- Updated: `lando start` now automatically creates local config files and composer installs on first run. This + eliminates those as manual steps when starting a project for the first time. +- Updated: Misc small tweaks to composer & package files & scripts for consistency and ease of use. +- Updated: GitHub action workflows to use new composite action for composer installs as well other small improvements + and updates to workflows +- Updated: Readme.md and docs for clarity and simplification. ## [2024.12] diff --git a/README.md b/README.md index b121b9ec..40868034 100644 --- a/README.md +++ b/README.md @@ -1,78 +1,103 @@ # Moose -## Requirements - -* Git -* Composer -* Node v16.13.1 or higher & NPM v8.1.2 or higher -* NVM is recommended for managing multiple versions of node on the same workstation. - -## Local Development - -One of the goals of this starter is to allow developers to use whatever local development platform that works best for them. There are some details below for Lando and Local by Flywheel. If you are using a different environment, feel free to add it. - -### Lando +Moose is a WordPress project starter framework. It is a collection of modular tools, configurations, and best practices +for enterprise WordPress design and development. It is designed to be a modern, flexible, and developer-friendly +starting point for WordPress projects. Features include a core plugin, core theme, technical framework, and the +requisite developer tooling to maintain a secure, consistent codebase across teams and projects. Moose is lovingly +maintained by the folks at [Modern Tribe](https://tri.be). -You can use [Lando](https://lando.dev/download/) to for your local development. When starting a new project, change the name value in the `.lando.yml` file to the name of the project. Then run `lando start` to build the environment. The `local-config.php` is setup to support lando out of the box. Once the lando is running, you can follow the BE Setup instructions for the composer commands to finish the setup. When running composer commands make sure to run `lando composer [command]` in order to run composer in the container. +## Requirements -### Local by Flywheel +* [Git](https://git-scm.com/) +* [Composer](https://getcomposer.org/) +* [Node & NPM](https://nodejs.org/) + * [NVM](https://github.com/nvm-sh/nvm) is recommended for managing multiple versions of node on the same + workstation. +* [Lando](https://lando.dev/) (Optional) Provides a consistent local development environment for all team members. +* [1Password CLI](https://developer.1password.com/docs/cli/) (Optional) Automates the creation of composer's `auth.json` + file so that paid 3rd-party plugins like Advanced Custom Fields Pro and Gravity Forms can be installed via composer. -It is recommended to create a blank blueprint in Local by Flywheel in order to make it easier to startup a project. Select the blank blueprint, clone in the repository to the public folder and then follow the BE Setup instructions for getting started. Make sure to use the Open Site Shell option to run composer commands allowing you to have the right PHP version in your shell path. +> [!TIP] +> This starter is designed to allow developers the freedom to use any local development tooling that works best for +> them. The following instructions assume the use of Lando, but any local development platform should work as long as it +> provides a basic LAMP or LEMP stack and uses the correct version of PHP as defined in `composer.json`. ## Getting Started -### BE Setup +1. Clone the repository +2. Run `composer create-auth` to create the `auth.json` file. (Assumes you are using the + [1Password CLI](#1password-cli). See the [Composer Docs](./docs/composer.md#creating-an-authjson-file) for manual + instructions.) +3. Run `lando start` to create the local environment. -Run `composer run setup-project` to copy the `auth.json`, and `local-config` files over. Once that has completed, update the `auth.json` to include the [ACF License for the username](https://www.advancedcustomfields.com/resources/installing-acf-pro-with-composer/) and the site url (`https://moose.lndo.site`) in the password section. Once the keys are up to date, run `composer install` to pull in the required libraries. Then run `composer setup-wordpress` to install WordPress using WP Cli. Depending on your local environment you may need to update your `local-config.php` for the local environment you are working in. +That should be it! After Lando starts the first time, it will automatically create the necessary local config files for +the project. Additionally, each time Lando starts it will automatically run `composer install` and +`npm install && npm run build` to make sure all the project dependencies are installed and the theme assets have been +built. -``` bash -composer setup-project -# ... update auth.json file if you need ACF Pro -composer install -composer setup-wordpress -``` +## Documentation -For WordPress updates, you can change the `--version=` value in the `setup-wordpress` composer script. +### Lando -### Front End Dev +Lando is the preferred local development environment for this project. It provides a consistent environment for all team +members to use and provides a number of helpful features. Below are a number of Lando commands to know: -1. Duplicate the `local-config-sample.json` file into a git-ignored `local-config.json` and update the certsPath and host entries to match your local dev set up. -1. In the root of the project, run `nvm use` to confirm the correct version of node is in-use. -1. Run `npm install` to install the required dependencies. -1. Run `npm run dev` to start the webpack watch & browsersync tasks. +* `lando start` - Starts the local development environment. +* `lando stop` - Stops the local development environment. +* `lando poweroff` - Completely shuts down all running Lando services. +* `lando composer ` - Runs a composer command within the project container. +* `lando wp ` - Runs a WP-CLI command within the project container. +* `lando npm ` - Runs an npm command within the node container. Useful for rebuilding the theme assets. +* `lando db-export` - Exports the project database to a file in the project root. +* `lando db-import ` - Imports a database file into the project database. This file must be located within + the project directory. It can be either an archived (`.zip`) or unarchived SQL (`.sql`) file. +* `lando rebuild` - Rebuilds the project containers. This is useful if you need to update the PHP version or there have + been other changes to the project's Lando configuration. This is a non-destructive action and will not delete any + data. +* `lando destroy` - Destroys the local development environment. *WARNING:* This is a destructive action and will delete + the existing data within the project database and completely remove all the project containers. It will not delete the + project files on your local machine. +* `lando xdebug-on` - Enables Xdebug in the project container (xDebug is disabled by default). +* `lando xdebug-off` - Disables Xdebug in the project container (xDebug is disabled by default). -### Front End Scripts +For further documentation on Lando, please visit the [Lando Docs](https://docs.lando.dev/). -* `npm run dist`: Builds production versions of all assets. -* `npm run dev`: Builds dev assets and starts an instance of browsersync to handle live-reload for changes. -* `npm run create-block`: Starts an interactive shell script to generate a new block per WordPress's [Create Block script](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/) and the theme config. -* `npm run format`: Runs Prettier on all theme assets (css, scss, js, & json files). -* `npm run lint`: Prettifies, lints (and fixes) theme & root assets (css, scss, js, & json files). Also see the sub-tasks for specific file types. -* `npm run server_dist`: Alias for the `dist` task. +### Composer -These scripts are based on WordPress's [WP-Scripts](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) package. See the documentation there for additional information. +Composer is configured to manage PHP dependencies. There are also a number of composer scripts set up to assist with +day-to-day PHP development. You can learn more about the available scripts and how to use them in the +[Composer Docs](./docs/composer.md). -There are also several additional scripts aliased directly from wp-scripts that may be useful: +#### Updating WordPress -* `packages-check` -* `check-engines` -* `check-licenses` +To adjust the installed version of WordPress, run `composer config extra.wordpress-version ` and then +`composer install-wordpress`. -## Testing +### NPM Packages, Scripts & Building Frontend Assets -A test suite is ready to use utilizing [Slic](https://github.com/stellarwp/slic). You can follow the instructions on the Slic readme to configure testing locally. Slic utilizes [WP-Browser](https://wpbrowser.wptestkit.dev/) and [Codeception](https://codeception.com/) to run tests in a docker container allowing us to use all the generate commands those libraries have to offer. +NPM is used for managing frontend dependencies and npm scripts for managing the frontend assets. Learn more about the +available scripts and how to use them in the [NPM Docs](./docs/npm.md). -The only major setup config you must do for slic is set the php-version to 8.0 since the default is 7.4. You can do this by running `slic php-version set 8.0`. +### 1Password CLI -Once Slic is installed, you can go to the project root and enter `slic here` telling slic that you want to run tests from this folder. Then run `slic use site` telling slic that you want to run the tests for the full site and not just a singular plugin or theme. Then you are ready to start testing by running `slic run wpunit`. You can exchange out the `wpunit` for any of the testing suites you would like to run (`wpunit`, `unit`, `functional`, or `acceptance`). +The 1Password CLI can be used to automate the creation of the `auth.json` file for composer. This file is used to store +credentials used by composer to install paid plugins like Advanced Custom Fields Pro and Gravity Forms. See the +[1Password CLI Docs](./docs/1password-cli.md) for further details. -## GitHub Actions +### GitHub Actions -We use GitHub Action as a CI for deployments, testing and many other features. To learn more about each action, checkout the [./docs/actions.md](./docs/actions.md) for details. +We use GitHub Action as a CI for deployments, testing and many other features. Take a look at the +[GitHub Action Docs](./docs/actions.md) to learn more about each action. + +### Additional Documentation -## Additional Documentation Specific features and functionality may have additional documentation in the [./docs](./docs) folder. + +* [Composer](./docs/composer.md) +* [NPM Packages, Scripts & Building Assets](./docs/npm.md) +* [1Password CLI](./docs/1password-cli.md) * [GitHub Actions](./docs/actions.md) +* [PHP Tests](./docs/php-tests.md) * [Create Block Script Templates](./docs/block-templates.md) * [Create WP Controls Script](./docs/wp-controls-templates.md) * [Supported Block Features](./docs/block-features.md) diff --git a/auth-sample.json b/auth-sample.json deleted file mode 100644 index 5a9f39cd..00000000 --- a/auth-sample.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "http-basic": { - "connect.advancedcustomfields.com": { - "username": "ACF License Key", - "password": "https://moose.lando.site" - }, - "composer.gravity.io": { - "username": "GF License Key", - "password": "https://moose.lndo.site" - } - } -} diff --git a/auth.template.json b/auth.template.json new file mode 100644 index 00000000..5d77f579 --- /dev/null +++ b/auth.template.json @@ -0,0 +1,12 @@ +{ + "http-basic": { + "connect.advancedcustomfields.com": { + "username": "{{op://${OP_VAULT:-Engineering}/${OP_ITEM:-MT-Composer-Auth}/ACF/license}}", + "password": "{{op://${OP_VAULT:-Engineering}/${OP_ITEM:-MT-Composer-Auth}/url}}" + }, + "composer.gravity.io": { + "username": "{{op://${OP_VAULT:-Engineering}/${OP_ITEM:-MT-Composer-Auth}/GF/license}}", + "password": "{{op://${OP_VAULT:-Engineering}/${OP_ITEM:-MT-Composer-Auth}/url}}" + } + } +} diff --git a/composer.json b/composer.json index b87a9eb2..9bd8fac5 100644 --- a/composer.json +++ b/composer.json @@ -21,52 +21,47 @@ "minimum-stability": "dev", "prefer-stable": true, "scripts": { + "create-auth": "op inject -i auth.template.json -o auth.json", + "create-local-configs": "php ./dev/scripts/create-local-configs.php", + "install-wordpress": "./dev/scripts/install-wordpress.sh", "phpcbf": "./vendor/bin/phpcbf -s", "phpcs": "./vendor/bin/phpcs", "phpstan": "./vendor/bin/phpstan analyse --memory-limit=-1", - "setup-project": [ - "@php -r \"file_exists('auth.json') || copy('auth-sample.json', 'auth.json');\"", - "@php -r \"file_exists('local-config.php') || copy('local-config-sample.php', 'local-config.php');\"", - "@php -r \"file_exists('local-config.json') || copy('local-config-sample.json', 'local-config.json');\"" - ], - "setup-wordpress": "./vendor/bin/wp core download --version=6.7.1 --skip-content --force", "update-db": "./vendor/bin/wp core update-db", - "post-root-package-install": [ - "@setup-project" - ], "post-install-cmd": [ - "@setup-wordpress" + "@install-wordpress" ], "post-update-cmd": [ - "@setup-wordpress" + "@install-wordpress" ] }, "scripts-descriptions": { + "create-auth": "Create or update the auth.json file for Composer via 1Password CLI.", + "create-local-configs": "Creates local config files for the project.", + "install-wordpress": "Runs the WP CLI command to download and install WordPress. To change the WordPress version, run `composer config extra.wordpress-version `.", "phpcs": "Run PHPCS on the project.", "phpcbf": "Run PHPCBF on the project.", "phpstan": "Run PHPStan on the project.", - "setup-project": "Moves the auth.json, local-config.php, and local-config.json files for setting up the project.", - "setup-wordpress": "Runs the wpcli command to download and install core WordPress. To change the WordPress version, update the --version value.", "update-db": "Runs the wpcli command to update the WordPress database. This is sometimes required after a version update." }, "repositories": { - "gravity": { - "type": "composer", - "url": "https://composer.gravity.io" - }, "0": { "type": "composer", - "url": "https://wpackagist.org" + "url": "https://composer.gravity.io" }, "1": { - "type": "vcs", - "url": "https://github.com/moderntribe/tribe-glomar.git" + "type": "composer", + "url": "https://connect.advancedcustomfields.com" }, "2": { "type": "composer", - "url": "https://connect.advancedcustomfields.com" + "url": "https://wpackagist.org" }, "3": { + "type": "vcs", + "url": "https://github.com/moderntribe/tribe-glomar.git" + }, + "4": { "type": "package", "package": { "name": "block-editor-custom-alignments/block-editor-custom-alignments", @@ -125,6 +120,7 @@ "wpengine/advanced-custom-fields-pro": "6.3.11" }, "extra": { + "wordpress-version": "6.7.1", "installer-paths": { "wp-content/plugins/{$name}": [ "type:wordpress-plugin" diff --git a/composer.lock b/composer.lock index 1276d67d..11ae078c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f360e1ce4b6d57f35b63550a0cdedb5e", + "content-hash": "e1d9d33214967735750a64a8bf6e8f78", "packages": [ { "name": "aws/aws-crt-php", @@ -62,16 +62,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.334.1", + "version": "3.336.6", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "3938b3467f64a30fed7ee1762a6785f808a5ae4d" + "reference": "0a99dab427f0a1c082775301141aeac3558691ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3938b3467f64a30fed7ee1762a6785f808a5ae4d", - "reference": "3938b3467f64a30fed7ee1762a6785f808a5ae4d", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/0a99dab427f0a1c082775301141aeac3558691ad", + "reference": "0a99dab427f0a1c082775301141aeac3558691ad", "shasum": "" }, "require": { @@ -154,9 +154,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.334.1" + "source": "https://github.com/aws/aws-sdk-php/tree/3.336.6" }, - "time": "2024-12-05T01:17:41+00:00" + "time": "2024-12-28T04:16:13+00:00" }, { "name": "block-editor-custom-alignments/block-editor-custom-alignments", @@ -321,16 +321,16 @@ }, { "name": "composer/composer", - "version": "2.8.3", + "version": "2.8.4", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "2a7c71266b2545a3bed9f4860734081963f6e688" + "reference": "112e37d1dca22b3fdb81cf3524ab4994f47fdb8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/2a7c71266b2545a3bed9f4860734081963f6e688", - "reference": "2a7c71266b2545a3bed9f4860734081963f6e688", + "url": "https://api.github.com/repos/composer/composer/zipball/112e37d1dca22b3fdb81cf3524ab4994f47fdb8c", + "reference": "112e37d1dca22b3fdb81cf3524ab4994f47fdb8c", "shasum": "" }, "require": { @@ -415,7 +415,7 @@ "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/composer/issues", "security": "https://github.com/composer/composer/security/policy", - "source": "https://github.com/composer/composer/tree/2.8.3" + "source": "https://github.com/composer/composer/tree/2.8.4" }, "funding": [ { @@ -431,7 +431,7 @@ "type": "tidelift" } ], - "time": "2024-11-17T12:13:04+00:00" + "time": "2024-12-11T10:57:47+00:00" }, { "name": "composer/installers", @@ -675,13 +675,13 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - }, "phpstan": { "includes": [ "extension.neon" ] + }, + "branch-alias": { + "dev-main": "3.x-dev" } }, "autoload": { @@ -3337,12 +3337,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -3540,8 +3540,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -3616,8 +3616,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -3694,8 +3694,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -3778,8 +3778,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -3852,8 +3852,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -3928,8 +3928,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4008,8 +4008,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4149,12 +4149,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -4464,9 +4464,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "cache", @@ -4487,7 +4484,10 @@ "transient set", "transient type", "transient list" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -4539,14 +4539,14 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "core verify-checksums", "plugin verify-checksums" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -4599,9 +4599,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "config", @@ -4615,7 +4612,10 @@ "config path", "config set", "config shuffle-salts" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -4651,21 +4651,21 @@ }, { "name": "wp-cli/core-command", - "version": "v2.1.18", + "version": "v2.1.19", "source": { "type": "git", "url": "https://github.com/wp-cli/core-command.git", - "reference": "f7580f93fe66a5584fa7b7c42bd2c0c1435c9d2e" + "reference": "ab65d194bbf00b018daca9d625b0297c5f813fca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/core-command/zipball/f7580f93fe66a5584fa7b7c42bd2c0c1435c9d2e", - "reference": "f7580f93fe66a5584fa7b7c42bd2c0c1435c9d2e", + "url": "https://api.github.com/repos/wp-cli/core-command/zipball/ab65d194bbf00b018daca9d625b0297c5f813fca", + "reference": "ab65d194bbf00b018daca9d625b0297c5f813fca", "shasum": "" }, "require": { "composer/semver": "^1.4 || ^2 || ^3", - "wp-cli/wp-cli": "^2.5.1" + "wp-cli/wp-cli": "^2.12" }, "require-dev": { "wp-cli/checksum-command": "^1 || ^2", @@ -4676,9 +4676,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "core", @@ -4691,7 +4688,10 @@ "core update", "core update-db", "core version" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -4716,9 +4716,9 @@ "homepage": "https://github.com/wp-cli/core-command", "support": { "issues": "https://github.com/wp-cli/core-command/issues", - "source": "https://github.com/wp-cli/core-command/tree/v2.1.18" + "source": "https://github.com/wp-cli/core-command/tree/v2.1.19" }, - "time": "2024-04-12T09:36:36+00:00" + "time": "2024-12-20T15:13:02+00:00" }, { "name": "wp-cli/cron-command", @@ -4745,9 +4745,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "cron", @@ -4760,7 +4757,10 @@ "cron schedule", "cron schedule list", "cron event unschedule" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -4812,9 +4812,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "db", @@ -4834,7 +4831,10 @@ "db tables", "db size", "db columns" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -4886,9 +4886,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "embed", @@ -4902,7 +4899,10 @@ "embed cache clear", "embed cache find", "embed cache trigger" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -4957,9 +4957,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "comment", @@ -5138,7 +5135,10 @@ "user term set", "user unspam", "user update" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5189,14 +5189,14 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "eval", "eval-file" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5253,13 +5253,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "export" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5315,9 +5315,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "plugin", @@ -5352,7 +5349,10 @@ "theme status", "theme update", "theme mod list" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5388,23 +5388,23 @@ }, { "name": "wp-cli/i18n-command", - "version": "v2.6.3", + "version": "v2.6.4", "source": { "type": "git", "url": "https://github.com/wp-cli/i18n-command.git", - "reference": "065bb3758fcbff922f1b7a01ab702aab0da79803" + "reference": "bf6720f63b6d9fc00cc13d02ef85e1f343e47d3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/i18n-command/zipball/065bb3758fcbff922f1b7a01ab702aab0da79803", - "reference": "065bb3758fcbff922f1b7a01ab702aab0da79803", + "url": "https://api.github.com/repos/wp-cli/i18n-command/zipball/bf6720f63b6d9fc00cc13d02ef85e1f343e47d3c", + "reference": "bf6720f63b6d9fc00cc13d02ef85e1f343e47d3c", "shasum": "" }, "require": { "eftec/bladeone": "3.52", "gettext/gettext": "^4.8", "mck89/peast": "^1.13.11", - "wp-cli/wp-cli": "^2.5" + "wp-cli/wp-cli": "^2.12" }, "require-dev": { "wp-cli/scaffold-command": "^1.2 || ^2", @@ -5451,9 +5451,9 @@ "homepage": "https://github.com/wp-cli/i18n-command", "support": { "issues": "https://github.com/wp-cli/i18n-command/issues", - "source": "https://github.com/wp-cli/i18n-command/tree/v2.6.3" + "source": "https://github.com/wp-cli/i18n-command/tree/v2.6.4" }, - "time": "2024-10-01T11:16:25+00:00" + "time": "2024-12-20T12:34:36+00:00" }, { "name": "wp-cli/import-command", @@ -5480,13 +5480,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "import" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5540,9 +5540,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "language", @@ -5566,7 +5563,10 @@ "language theme uninstall", "language theme update", "site switch-language" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5617,9 +5617,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "maintenance-mode", @@ -5627,7 +5624,10 @@ "maintenance-mode deactivate", "maintenance-mode status", "maintenance-mode is-active" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5680,16 +5680,16 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "media", "media import", "media regenerate", "media image-size" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5794,9 +5794,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "package", @@ -5805,7 +5802,10 @@ "package list", "package update", "package uninstall" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5836,20 +5836,20 @@ }, { "name": "wp-cli/php-cli-tools", - "version": "v0.11.22", + "version": "v0.12.1", "source": { "type": "git", "url": "https://github.com/wp-cli/php-cli-tools.git", - "reference": "a6bb94664ca36d0962f9c2ff25591c315a550c51" + "reference": "d1fe500378f53fb5ae1072c0daa77095c384a082" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/a6bb94664ca36d0962f9c2ff25591c315a550c51", - "reference": "a6bb94664ca36d0962f9c2ff25591c315a550c51", + "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/d1fe500378f53fb5ae1072c0daa77095c384a082", + "reference": "d1fe500378f53fb5ae1072c0daa77095c384a082", "shasum": "" }, "require": { - "php": ">= 5.3.0" + "php": ">= 5.6.0" }, "require-dev": { "roave/security-advisories": "dev-latest", @@ -5893,9 +5893,9 @@ ], "support": { "issues": "https://github.com/wp-cli/php-cli-tools/issues", - "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.22" + "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.12.1" }, - "time": "2023-12-03T19:25:05+00:00" + "time": "2024-10-01T11:13:49+00:00" }, { "name": "wp-cli/rewrite-command", @@ -5920,16 +5920,16 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "rewrite", "rewrite flush", "rewrite list", "rewrite structure" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5980,9 +5980,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "role", @@ -5995,7 +5992,10 @@ "cap add", "cap list", "cap remove" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6047,9 +6047,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "scaffold", @@ -6061,7 +6058,10 @@ "scaffold post-type", "scaffold taxonomy", "scaffold theme-tests" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6115,13 +6115,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "search-replace" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6173,13 +6173,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "server" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6230,13 +6230,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "shell" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6288,16 +6288,16 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "super-admin", "super-admin add", "super-admin list", "super-admin remove" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6349,9 +6349,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "widget", @@ -6364,7 +6361,10 @@ "widget update", "sidebar", "sidebar list" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6395,16 +6395,16 @@ }, { "name": "wp-cli/wp-cli", - "version": "v2.11.0", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/wp-cli/wp-cli.git", - "reference": "53f0df112901fcf95099d0f501912a209429b6a9" + "reference": "0187f2b4ce7e83f31bf4beecd5ad4f11ddf8b57b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/53f0df112901fcf95099d0f501912a209429b6a9", - "reference": "53f0df112901fcf95099d0f501912a209429b6a9", + "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/0187f2b4ce7e83f31bf4beecd5ad4f11ddf8b57b", + "reference": "0187f2b4ce7e83f31bf4beecd5ad4f11ddf8b57b", "shasum": "" }, "require": { @@ -6413,7 +6413,7 @@ "php": "^5.6 || ^7.0 || ^8.0", "symfony/finder": ">2.7", "wp-cli/mustangostang-spyc": "^0.6.3", - "wp-cli/php-cli-tools": "~0.11.2" + "wp-cli/php-cli-tools": "~0.12.1" }, "require-dev": { "roave/security-advisories": "dev-latest", @@ -6427,6 +6427,7 @@ "ext-readline": "Include for a better --prompt implementation", "ext-zip": "Needed to support extraction of ZIP archives when doing downloads or updates" }, + "default-branch": true, "bin": [ "bin/wp", "bin/wp.bat" @@ -6434,7 +6435,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.11.x-dev" + "dev-main": "2.12.x-dev" } }, "autoload": { @@ -6461,7 +6462,7 @@ "issues": "https://github.com/wp-cli/wp-cli/issues", "source": "https://github.com/wp-cli/wp-cli" }, - "time": "2024-08-08T03:04:55+00:00" + "time": "2024-11-26T19:13:58+00:00" }, { "name": "wp-cli/wp-cli-bundle", @@ -6749,16 +6750,16 @@ "packages-dev": [ { "name": "antecedent/patchwork", - "version": "2.2.0", + "version": "2.2.1", "source": { "type": "git", "url": "https://github.com/antecedent/patchwork.git", - "reference": "b07d4fb37c3c723c8755122160c089e077d5de65" + "reference": "1bf183a3e1bd094f231a2128b9ecc5363c269245" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/antecedent/patchwork/zipball/b07d4fb37c3c723c8755122160c089e077d5de65", - "reference": "b07d4fb37c3c723c8755122160c089e077d5de65", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/1bf183a3e1bd094f231a2128b9ecc5363c269245", + "reference": "1bf183a3e1bd094f231a2128b9ecc5363c269245", "shasum": "" }, "require": { @@ -6791,9 +6792,9 @@ ], "support": { "issues": "https://github.com/antecedent/patchwork/issues", - "source": "https://github.com/antecedent/patchwork/tree/2.2.0" + "source": "https://github.com/antecedent/patchwork/tree/2.2.1" }, - "time": "2024-09-27T16:59:55+00:00" + "time": "2024-12-11T10:19:54+00:00" }, { "name": "automattic/vipwpcs", @@ -7981,16 +7982,16 @@ }, { "name": "illuminate/collections", - "version": "v11.34.2", + "version": "v11.36.1", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "fd2103ddc121449a7926fc34a9d220e5b88183c1" + "reference": "21868f9ac221a42d4346dc56495d11ab7e0d339a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/fd2103ddc121449a7926fc34a9d220e5b88183c1", - "reference": "fd2103ddc121449a7926fc34a9d220e5b88183c1", + "url": "https://api.github.com/repos/illuminate/collections/zipball/21868f9ac221a42d4346dc56495d11ab7e0d339a", + "reference": "21868f9ac221a42d4346dc56495d11ab7e0d339a", "shasum": "" }, "require": { @@ -8010,6 +8011,7 @@ }, "autoload": { "files": [ + "functions.php", "helpers.php" ], "psr-4": { @@ -8032,11 +8034,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-11-27T14:51:56+00:00" + "time": "2024-12-13T13:58:10+00:00" }, { "name": "illuminate/conditionable", - "version": "v11.34.2", + "version": "v11.36.1", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -8082,7 +8084,7 @@ }, { "name": "illuminate/contracts", - "version": "v11.34.2", + "version": "v11.36.1", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -8130,7 +8132,7 @@ }, { "name": "illuminate/macroable", - "version": "v11.34.2", + "version": "v11.36.1", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -8176,16 +8178,16 @@ }, { "name": "illuminate/support", - "version": "v11.34.2", + "version": "v11.36.1", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "2b718a86571baed50fdc5d5748a846c2e58e07eb" + "reference": "fba1ff58e30fa280248ce3db9b18d6341c6ac339" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/2b718a86571baed50fdc5d5748a846c2e58e07eb", - "reference": "2b718a86571baed50fdc5d5748a846c2e58e07eb", + "url": "https://api.github.com/repos/illuminate/support/zipball/fba1ff58e30fa280248ce3db9b18d6341c6ac339", + "reference": "fba1ff58e30fa280248ce3db9b18d6341c6ac339", "shasum": "" }, "require": { @@ -8208,11 +8210,12 @@ "spatie/once": "*" }, "suggest": { - "illuminate/filesystem": "Required to use the composer class (^11.0).", + "illuminate/filesystem": "Required to use the Composer class (^11.0).", "laravel/serializable-closure": "Required to use the once function (^1.3).", - "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.0.2).", + "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.6).", + "league/uri": "Required to use the Uri class (^7.5.1).", "ramsey/uuid": "Required to use Str::uuid() (^4.7).", - "symfony/process": "Required to use the composer class (^7.0).", + "symfony/process": "Required to use the Composer class (^7.0).", "symfony/uid": "Required to use Str::ulid() (^7.0).", "symfony/var-dumper": "Required to use the dd function (^7.0).", "vlucas/phpdotenv": "Required to use the Env class and env helper (^5.6.1)." @@ -8248,7 +8251,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-11-27T14:58:17+00:00" + "time": "2024-12-17T20:20:09+00:00" }, { "name": "lucatume/wp-browser", @@ -8581,16 +8584,16 @@ }, { "name": "nesbot/carbon", - "version": "3.8.2", + "version": "3.8.4", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947" + "reference": "129700ed449b1f02d70272d2ac802357c8c30c58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/e1268cdbc486d97ce23fef2c666dc3c6b6de9947", - "reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/129700ed449b1f02d70272d2ac802357c8c30c58", + "reference": "129700ed449b1f02d70272d2ac802357c8c30c58", "shasum": "" }, "require": { @@ -8622,10 +8625,6 @@ ], "type": "library", "extra": { - "branch-alias": { - "dev-master": "3.x-dev", - "dev-2.x": "2.x-dev" - }, "laravel": { "providers": [ "Carbon\\Laravel\\ServiceProvider" @@ -8635,6 +8634,10 @@ "includes": [ "extension.neon" ] + }, + "branch-alias": { + "dev-2.x": "2.x-dev", + "dev-master": "3.x-dev" } }, "autoload": { @@ -8683,20 +8686,20 @@ "type": "tidelift" } ], - "time": "2024-11-07T17:46:48+00:00" + "time": "2024-12-27T09:25:35+00:00" }, { "name": "nikic/php-parser", - "version": "v5.3.1", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" + "reference": "447a020a1f875a434d62f2a401f53b82a396e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494", + "reference": "447a020a1f875a434d62f2a401f53b82a396e494", "shasum": "" }, "require": { @@ -8739,9 +8742,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0" }, - "time": "2024-10-08T18:51:32+00:00" + "time": "2024-12-30T11:07:19+00:00" }, { "name": "phar-io/manifest", @@ -9534,16 +9537,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.12", + "version": "1.12.14", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0" + "reference": "e73868f809e68fff33be961ad4946e2e43ec9e38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", - "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e73868f809e68fff33be961ad4946e2e43ec9e38", + "reference": "e73868f809e68fff33be961ad4946e2e43ec9e38", "shasum": "" }, "require": { @@ -9588,7 +9591,7 @@ "type": "github" } ], - "time": "2024-11-28T22:13:23+00:00" + "time": "2024-12-31T07:26:13+00:00" }, { "name": "phpunit/php-code-coverage", @@ -11249,16 +11252,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.1", + "version": "3.11.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87" + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", - "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", "shasum": "" }, "require": { @@ -11325,7 +11328,7 @@ "type": "open_collective" } ], - "time": "2024-11-16T12:02:36+00:00" + "time": "2024-12-11T16:04:26+00:00" }, { "name": "symfony/browser-kit", @@ -11719,12 +11722,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -11795,8 +11798,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -11965,12 +11968,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { diff --git a/dev/scripts/create-local-configs.php b/dev/scripts/create-local-configs.php new file mode 100644 index 00000000..232f194d --- /dev/null +++ b/dev/scripts/create-local-configs.php @@ -0,0 +1,59 @@ +appserver->via === 'apache' ? $lando_info->appserver : $lando_info->appserver_nginx; + +// Get the cert directory by removing the root `/lando` directory from Lando's internal cert path +$cert_directory = str_replace( '/lando', '', dirname( getenv( 'LANDO_SERVICE_CERT' ) ) ); + +// Create the config array +$config = [ + // Append Lando's cert directory to Lando's local config directory path + 'certPath' => getenv( 'LANDO_CONFIG_DIR' ) . $cert_directory, + // Set the cert name to the base name of Lando's hostname without the `.internal` extension + 'certName' => basename( $http_service_info->hostnames[0], '.internal' ), + // Set the host from Lando's service URL + 'host' => parse_url( $http_service_info->urls[0] )['host'], + 'protocol' => 'https' +]; + +// Write the config values to local-config.json +file_put_contents( 'local-config.json', json_encode( $config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ); + +exit; diff --git a/dev/scripts/install-wordpress.sh b/dev/scripts/install-wordpress.sh new file mode 100755 index 00000000..b5e20154 --- /dev/null +++ b/dev/scripts/install-wordpress.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Simple bash script to check the current version of WordPress and update it if necessary. + +CURRENT_VERSION=$(wp core version) +REQUESTED_VERSION=$(composer config extra.wordpress-version) + +if [ "$CURRENT_VERSION" == "$REQUESTED_VERSION" ]; then + echo "WordPress is already at version $REQUESTED_VERSION. Skipping install." + exit 0 +fi + +echo "Updating WordPress to version $REQUESTED_VERSION..." +wp core download --version=$REQUESTED_VERSION --skip-content --force +exit 0; diff --git a/dev/templates/package.json b/dev/templates/package.json index 1c7422ed..2aca522f 100644 --- a/dev/templates/package.json +++ b/dev/templates/package.json @@ -1,7 +1,7 @@ { - "name": "tribe-block-templates", - "version": "1.0.0", - "description": "Custom block templates for the WP create-block script to use", + "name": "tribe-block-templates", + "version": "1.0.0", + "description": "Custom block templates for the WP create-block script to use", "author": "Modern Tribe ", "license": "GPL-2.0-or-later", "keywords": [], @@ -11,7 +11,7 @@ "email": "admin@tri.be" }, "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - } + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + } } diff --git a/docs/1password-cli.md b/docs/1password-cli.md new file mode 100644 index 00000000..1c4cafac --- /dev/null +++ b/docs/1password-cli.md @@ -0,0 +1,65 @@ +# 1Password CLI + +The 1Password CLI can be used to automate the creation of the `auth.json` file for composer. This file is used to store +credentials used by composer to install paid plugins like Advanced Custom Fields Pro and Gravity Forms. + +The 1Password CLI is used both for local development and in GitHub Actions workflows. + +## Installation for Local Development + +See the [1Password CLI](https://developer.1password.com/docs/cli/get-started/) installation instructions for how to +install & authenticate with the 1Password CLI on your local machine. + +## Creating an `auth.json` File via the 1Password CLI + +Running `composer create-auth` on your local machine (not within a Lando container) will use the 1Password CLI to +create or update the `auth.json`. Note that contrary to most other composer scripts, this one cannot be run inside a +lando container because the container is not authorized to access the 1Password CLI. + +### The `auth.template.json` Template File + +Under the hood, the `composer create-auth` script uses the [1Password `op inject` command](https://developer.1password.com/docs/cli/reference/commands/inject) +to retrieve secrets from a 1Password vault and creates a new file by replacing references in the template file with +those secrets. + +## Adding or Updating Secrets + +Here are steps for adding a new authentication or secret value to the project: +1. Add a new section to the project's 1Password item. +2. Add the new secret(s) within the new section you created in the item. +3. Update the `auth.template.json` file with the new secret key(s) and placeholder value(s). +4. Run `composer create-auth` to update the `auth.json` file with the new secret(s). + +## GitHub Secrets + +1Password provides [their own GitHub Action](https://github.com/1Password/install-cli-action) that is used in the +project workflows. The following GitHub secrets are required to use the 1Password CLI in GitHub Actions: +* `OP_SERVICE_ACCOUNT_TOKEN` - (Required) A 1Password service account token. +* `OP_VAULT` - (Required) The 1Password vault where the secrets are stored. +* `OP_ITEM` - (Required) The 1Password item containing the secrets. + +We have configured a default service account with access to Modern Tribe's Engineering vault. This service account is +sufficient for projects that are just getting started and haven't yet purchased any client-specific licenses. + +> [!IMPORTANT] +> Modern Tribe's default 1Password service account and the plugin licenses in the MT Engineering vault are shared +> across all Modern Tribe projects and are intended for local development and Dokku environments only. If a project is +> deploying to other hosting environments, the project should be using a project-specific 1Password vault and +> client-supplied license keys for GitHub Actions. + +### 1Password Service Account Token + +To use 1Password CLI with GitHub Actions, you must create a [1Password service account](https://developer.1password.com/docs/service-accounts/get-started) +and populate the `OP_SERVICE_ACCOUNT_TOKEN` secret in the project's GitHub repository with the respective service +account token. You may need to ask Modern Tribe leadership or the project manager to create this account for you. + +When creating the service account, be sure that the account can only access the project's vault(s). Service accounts +cannot be modified once they are created and should not be shared between projects. + +### 1Password Vault and Item + +The `OP_VAULT` and `OP_ITEM` secrets tell the 1Password CLI which vault and item to retrieve values from. If they are +not defined, the 1Password CLI will default to the `Engineering` vault and the `MT-Composer-Auth` item. + +When creating a project-specific 1Password vault be sure to follow the structure of the `MT-Composer-Auth` item in the +Engineering vault. The structure of the `auth.template.json` file expects a specific 1Password item structure. diff --git a/docs/actions.md b/docs/actions.md index a58a9362..763a6ddc 100644 --- a/docs/actions.md +++ b/docs/actions.md @@ -1,21 +1,39 @@ # GitHub Actions -We use GitHub Actions for many automated tasks. Some actions run on push, some run when creating a release and others might only run when selecting them in the UI (workflow_dispatch). You can learn more about GitHub Actions through the documentation located at [docs.github.com/en/actions](https://docs.github.com/en/actions). All of these actions are a starting point for your project and you should be adjusting/adding/removing actions to best fit your project needs. +We use GitHub Actions for many automated tasks. Some actions run on push, some run when creating a release and others +might only run when selecting them in the UI (workflow_dispatch). You can learn more about GitHub Actions through the +documentation located at [docs.github.com/en/actions](https://docs.github.com/en/actions). All of these actions are a starting point for your project +and you should be adjusting/adding/removing actions to best fit your project needs. ## Deployments ### Dokku Deployment Workflows -The [Dokku](https://dokku.com/) deployments are for internal qa and development testing. These include the dokku-dev.yml, dokku-review-app.yml, and pipeline-dokku.yml workflows. To use these deployments you need to update the `app_name` from `moose-dev` to the unique name for your projects environment and setup the environment in our private dokku-ansible repo to accept the connection. +The [Dokku](https://dokku.com/) deployments are for internal qa and development testing. These include the dokku-dev.yml, +dokku-review-app.yml, and pipeline-dokku.yml workflows. To use these deployments you need to update the `app_name` +from `moose-dev` to the unique name for your projects environment and setup the environment in our private +dokku-ansible repo to accept the connection. ### Production Deployment Workflows -We have 3 deployment workflows to interface with whatever hosting environment is needed (deploy-dev.yml, deploy-stage.yml, deploy-prod.yml). You will need to update the `[DEV|STAGE|PROD]_DEPLOY_REPO`, `DEPLOY_PRIVATE_SSH_KEY`, and `COMPOSER_AUTH_JSON` secrets to use these deployments in your project. These are intended to be deploying to the hosting service where the site will live. Most hosting companies work with `git` making it the default push we currently use. +We have 3 deployment workflows to interface with whatever hosting environment is needed (deploy-dev.yml, +deploy-stage.yml, deploy-prod.yml). You will need to update the `[DEV|STAGE|PROD]_DEPLOY_REPO`, +`DEPLOY_PRIVATE_SSH_KEY`, and 1Password secrets (`OP_SERVICE_ACCOUNT_TOKEN`, `OP_VAULT`, `OP_ITEM`) to use these +deployments in your project. These are intended to be deploying to the hosting service where the site will live. Most +hosting companies work with `git` making it the default push we currently use. ## Static Analysis and Testing -There are a series of workflows that must pass in order to allow a pull request to be merged. These are highlighted in the `workflows.yml` file and include the coding standards, static analysis, linting, and the php test suite using [Slic](https://github.com/stellarwp/slic). +There are a series of workflows that must pass in order to allow a pull request to be merged. These are highlighted in +the `workflows.yml` file and include the coding standards, static analysis, linting, and the php test suite using +[Slic](https://github.com/stellarwp/slic). ## Lighthouse Testing -We are using the [Lighthouse CI](https://github.com/treosh/lighthouse-ci-action/tree/main) for testing list of production urls that we would like to run lighthouse tests on and stores the results as artifacts of the action. There are parameters that we set in the [lighthouserc.json](../.github/lighthouse/lighthouserc.json) file allowing us to set the minimum values for each of the lighthouse matrix. There are minimum values set as a baseline but each value should be updated once a project is live in order to track that updates made do not effect the results over time along with the urls that you want to check. It is recommended that you check production URLs so that you are getting a realistic representation of the content, images, and caching for the live site. **You will need to edit the lighthouserc.json file for your project to take advantage of this action**. +We are using the [Lighthouse CI](https://github.com/treosh/lighthouse-ci-action/tree/main) for testing list of production urls that we would like to run lighthouse tests on +and stores the results as artifacts of the action. There are parameters that we set in the [lighthouserc.json](../.github/lighthouse/lighthouserc.json) +file allowing us to set the minimum values for each of the lighthouse matrix. There are minimum values set as a +baseline but each value should be updated once a project is live in order to track that updates made do not effect the +results over time along with the urls that you want to check. It is recommended that you check production URLs so that +you are getting a realistic representation of the content, images, and caching for the live site. **You will need to +edit the lighthouserc.json file for your project to take advantage of this action**. diff --git a/docs/composer.md b/docs/composer.md new file mode 100644 index 00000000..46f45321 --- /dev/null +++ b/docs/composer.md @@ -0,0 +1,62 @@ +# Composer + +Composer is configured to manage PHP dependencies. There are also a number of composer scripts set up to assist with +day-to-day PHP development. + +> [!WARNING] +> Running composer commands directly on your local machine will cause conflicts if your locally installed version of +> PHP is different from the version required in `composer.json`. Always be sure you have the correct version of php +> installed locally or run composer commands from within the Lando environment by prefixing them with `lando ...` such +> as: `lando composer install`. + +## Composer Scripts + +* `composer create-auth` - Create or update the auth.json file for Composer via 1Password CLI. (Cannot be run within a + Lando container.) +* `composer create-local-configs` - Creates the `local-config.php` and `local-config.json` files as needed for the + project. +* `composer install-wordpress` - Runs the WP CLI command to download and install WordPress core. +* `composer phpcs` - Run PHPCS on the project. +* `composer phpcbf` - Run PHPCBF on the project. +* `composer phpstan` - Run PHPStan on the project. +* `composer update-db` - Runs the WP CLI command to update the WordPress database. This is often required after a + WordPress version update. + +## Updating WordPress + +To adjust the installed version of WordPress, run `composer config extra.wordpress-version ` and then +`composer install-wordpress`. + +## Adding a Paid or Premium WordPress Plugin + +A number of premium or paid WordPress plugins may be used for a project. Often, these plugins are not available in the +WordPress plugin directory and thus can't be installed from `https://wpackagist.org`. There are a few options for +installing such premium plugins: + +1. Check to see if the plugin maker provides its own composer-based installation method. This is the best option. + Many providers including Advanced Custom Fields (ACF), Gravity Forms, and Yoast SEO provide composer-based + installation + options. This project is already configured to use composer for both ACF and Gravity Forms. +1. Check the plugin files into the repository directly. This is the simplest option but is not ideal for a number of + reasons, including licensing, security, and ease of management. + +### Creating an auth.json File + +If the plugin maker provides a composer-based installation method, you will likely create an `auth.json` file to +store the required credentials. This file is used by composer to install the plugin. This project provides an +auth.json template file that the 1Password CLI can use to automatically generate the required `auth.json` file. See the +[1Password CLI Docs](./1password-cli.md) for more information on this integration. + +To manually create the `auth.json` file, copy the `auth.template.json` file to `auth.json` and update the placeholder +values within the file with the required credentials. + +> [!IMPORTANT] +> The populated `auth.json` file should never be checked into the git repository as it contains +> project-specific secrets (software license keys) which should never be available in source control. + +## Platform Dependencies + +There are several PHP platform dependencies added as composer requirements. These dependencies include the required +version of PHP as well as several PHP extensions required by WordPress (`ext-exif`, `ext-gd`, `ext-intl`, & `ext-json`). +These PHP extensions are installed within a [project's Dokku env](actions.md#dokku-deployment-workflows) and should not +be removed unless or until Dokku is not utilized by the project. diff --git a/docs/npm.md b/docs/npm.md new file mode 100644 index 00000000..9887d9af --- /dev/null +++ b/docs/npm.md @@ -0,0 +1,49 @@ +# NPM Packages, Scripts & Building Assets + +NPM is used to manage frontend dependencies. There are also a number of npm scripts defined to assist in day-to-day +development. These npm scripts are based on +WordPress's [WP-Scripts](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) +package. See the documentation there for further details. + +## Building Assets + +If you are not working with the theme assets locally, and you are using Lando, you can skip this section. Lando will +automatically build the assets for you each time the project is started. To manually build the theme assets for your +local development environment, use the following steps: + +1. In the root of the project, run `nvm use` to confirm the correct version of node is in-use. +1. Run `npm install` to install the required dependencies. +1. Run `npm run build` to build the non-production assets. + +## Using Browsersync for Local Dev + +To handle live-reload for changes, this project utilizes Browsersync to watch for asset file changes and reload the +browser. In addition, Browsersync can be configured via a `local-config.json` file to proxy your local environment's +SSL configuration to allow live-reloading from a specific local project URL rather than localhost. + +Lando will automatically generate an proper local-config.json file the first time a project is started. If you are not +using Lando, you'll need to manually create this file using the steps below: + +1. Duplicate the `local-config-sample.json` file into a git-ignored `local-config.json` and update the `certsPath`, + `certName` and `host` values to match your local dev set up. Examples are provided for Lando and LocalWP. +1. In the root of the project, run `nvm use` to confirm the correct version of node is in-use. +1. Run `npm install` to install the required dependencies. +1. Run `npm run dev` to start the webpack watch & browsersync tasks. + +## NPM Scripts + +* `npm run dist` - Builds production versions of all assets. +* `npm run build` - Builds non-production versions of all assets. +* `npm run dev` - Builds dev assets and starts an instance of browsersync to handle live-reload for changes. +* `npm run format` - Runs Prettier on all theme assets (css, scss, js, & json files). +* `npm run lint` - Prettifies, lints (and fixes) theme & root assets (css, scss, js, & json files). +* `npm run create-block` - Starts an interactive shell script to generate a new block per WordPress's + [Create Block script](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/) + and the theme config. + +Several scripts have sub-tasks that can be run individually. Reference `package.json` for details. +Additionally, there are several scripts aliased directly from wp-scripts that may be useful: + +* `packages-check` +* `check-engines` +* `check-licenses` diff --git a/docs/php-tests.md b/docs/php-tests.md new file mode 100644 index 00000000..87267bdb --- /dev/null +++ b/docs/php-tests.md @@ -0,0 +1,13 @@ +# PHP Tests + +A test suite is ready to use utilizing [Slic](https://github.com/stellarwp/slic). You can follow the instructions on the Slic readme to configure +testing locally. Slic utilizes [WP-Browser](https://wpbrowser.wptestkit.dev/) and [Codeception](https://codeception.com/) to run tests in a docker container allowing us +to use all the generate commands those libraries have to offer. + +The only major setup config you must do for slic is set the php-version to the correct version for this project. +You can do this by running `slic php-version set `. + +Once Slic is installed, you can go to the project root and enter `slic here` telling slic that you want to run tests +from this folder. Then run `slic use site` telling slic that you want to run the tests for the full site and not just +a singular plugin or theme. Then you are ready to start testing by running `slic run wpunit`. You can exchange out the +`wpunit` for any of the testing suites you would like to run (`wpunit`, `unit`, `functional`, or `acceptance`). diff --git a/local-config-sample.php b/local-config-sample.php index b36f258c..6d4b314e 100644 --- a/local-config-sample.php +++ b/local-config-sample.php @@ -20,10 +20,6 @@ define( 'DB_USER', $database_config->creds->user ); define( 'DB_PASSWORD', $database_config->creds->password ); define( 'DB_HOST', $database_config->internal_connection->host ); - - /** URL routing (Optional, may not be necessary) */ - // define('WP_HOME','http://mysite.lndo.site'); - // define('WP_SITEURL','http://mysite.lndo.site'); } /** diff --git a/package.json b/package.json index 7b921852..2385ca64 100644 --- a/package.json +++ b/package.json @@ -55,10 +55,10 @@ "lint:configs": "wp-scripts lint-js \"./*.js\"", "lint:configs:fix": "wp-scripts lint-js \"./*.js\" --fix", "lint:pkg-json": "wp-scripts lint-pkg-json \"./package.json\"", + "lint:server": "npm run lint:js && npm run lint:css && npm run lint:configs && npm run lint:pkg-json", "create-block": "cd \"$npm_package_config_coreThemeBlocksDir/tribe\" && npx @wordpress/create-block --no-plugin --namespace tribe --template $npm_package_config_coreBlockTemplatesDir", "packages-update": "wp-scripts packages-update", "check-engines": "wp-scripts check-engines", - "check-licenses": "wp-scripts check-licenses", - "server-lint": "npm run lint:js && npm run lint:css && npm run lint:configs && npm run lint:pkg-json" + "check-licenses": "wp-scripts check-licenses" } }