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

Drupal10 #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .ddev/commands/web/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

## Description: Run phpunit on drupal-rector itseld
## Usage: phpunit
## Example: "ddev phpunit"

echo "Checking dependencies..."
./develop-rector.sh

echo "vendor/bin/phpunit --testdox"
cd drupal-rector
vendor/bin/phpunit --testdox
41 changes: 41 additions & 0 deletions .ddev/commands/web/rector
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

## Description: Run drupal rector on a specific module.
## Usage: rector MODULE_NAME [-d|--dry-run]
## Example: "ddev rector admin_toolbar" or "ddev rector admin_toolbar -d"

# Copy any new tests from the test module.
if [ ! -e "web/modules/contrib/rector_examples/rector_examples.info.yml" ]; then
cp -R drupal-rector/fixtures/d9/rector_examples web/modules/contrib
fi

if [ $# -eq 0 ]
then
echo "You must specify a module; e.g. 'ddev rector admin_toolbar'"
exit
fi

if [ $# -eq 2 ]
then
DRYRUN="--dry-run"
if [ "$1" != "-d" ] && [ "$1" != "--dry-run" ]
then
MODULE="$1"
else
MODULE="$2"
fi
else
MODULE="$1"
DRYRUN=""
fi

if [ ! -d "web/modules/contrib/$MODULE" ]
then
echo "The specified module [$MODULE] does not exist in /web/modules/contrib."
exit
fi

echo "===================="
echo "Running rector with: /web/modules/contrib/$MODULE $DRYRUN"
echo "===================="
vendor/bin/rector process web/modules/contrib/$MODULE $DRYRUN
7 changes: 3 additions & 4 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: drupal-rector-sandbox
type: drupal8
type: drupal9
docroot: web
php_version: "7.4"
php_version: "8.2"
webserver_type: nginx-fpm
router_http_port: "80"
router_https_port: "443"
Expand All @@ -16,7 +16,6 @@ use_dns_when_possible: true
composer_version: ""
web_environment: []


# This config.yaml was created with ddev version v1.17.5
# webimage: drud/ddev-webserver:v1.17.4
# dbimage: drud/ddev-dbserver-mariadb-10.3:v1.17.3
Expand Down Expand Up @@ -160,7 +159,7 @@ web_environment: []
# In this case the user must provide all such settings.

# You can inject environment variables into the web container with:
# web_environment:
# web_environment:
# - SOMEENV=somevalue
# - SOMEOTHERENV=someothervalue

Expand Down
16 changes: 8 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@
*.config text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.css text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.dist text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.engine text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.engine text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.html text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=html
*.inc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.install text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.inc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.install text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.js text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.json text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.lock text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.map text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.md text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.module text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.module text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.po text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.profile text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.profile text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.script text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.sh text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.sh text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.sql text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.svg text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.theme text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.theme text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.twig text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.txt text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.xml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
# Include Drupal settings files
!/web/sites/*/settings.php
!/web/sites/*/services.yml
/web/.ht.router.php
/web/.htaccess
/web/INSTALL.txt
/web/example.gitignore
/web/robots.txt
/web/sites/default/default.services.yml
/web/sites/default/default.settings.php
/web/sites/example.settings.local.php
/web/sites/example.sites.php
/web/update.php
/web/web.config

# Ignore local and generated settings files
/web/sites/*/settings.local.php
Expand Down
44 changes: 15 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@

This is the development repository for the Drupal Rector Sandbox. It contains the codebase and an environment to run the site for development.

## php7 branch
## Specifications

This is the php7 branch, suitable for use developing upgrade rules for Drupal 8 to Drupal 9.

### Switching branches

If you need to switch from php7 to php8 (the `php8` [branch of the sandbox](https://github.com/palantirnet/drupal-rector-sandbox/tree/php8/web)), follow these steps.

- Checkout the branch you want (e.g. `git checkout main` or `git checkout php8`)
- `rm -rf vendor`
- `ddev restart`
- `ddev . composer install`

## Development Note

In preparation for Drupal 10, we will start supporting PHP 7.4 and PHP 8 for development. To do so requires configuring DDEV, and as a result, we encourage you to run all `composer` and `rector` commands via `ddev exec` (alias `ddev .`).
This version of the sandbox runs Drupal core 10.1 on PHP 8.2.

## Table of Contents

Expand All @@ -39,23 +26,15 @@ In preparation for Drupal 10, we will start supporting PHP 7.4 and PHP 8 for dev

Run `ddev . composer install`

You can view the Rector report by running:

`ddev . vendor/bin/rector process web/modules/custom/my-module --dry-run`
### ddev rector

Rector can update your code by running:
**Command:** `ddev rector MODULE` or `ddev rector MODULE -d` or `ddev rector MODULE --dry-run`

`ddev . vendor/bin/rector process web/modules/custom/my-module`
**Example:** `ddev rector rector_examples`

### Running Drupal Rector against a test module
**Example:** `ddev rector rector_examples -d`

Drupal Rector comes with a test module that you can use to confirm rules are working:

`ddev . vendor/bin/rector process drupal-rector/rector_examples --dry-run`

This command is aliased in the `test-rector.sh` script in project root, so you can run this from project root instead:

`./test-rector.sh`
The `rector` command will run Drupal Rector updates against the selected module, potentially rewriting the module's code. Using the `-d` or `--dry-run` flag will not perform the changes, but instead show the suggested changes.

## Developing with Drupal Rector

Expand All @@ -75,12 +54,19 @@ environment under `drupal-project/` directory.
1. Run Rector against the examples

```console
ddev . vendor/bin/rector process drupal-rector/rector_examples --dry-run
`ddev rector rector_examples -d`
```
Note that this command will test the Drupal 9 rule set. You can create and test new rules here.

1. Submit a PR to https://github.com/palantirnet/drupal-rector.
2. Reference the PR in a Drupal.org issue: https://www.drupal.org/project/issues/rector

### Running phpunit tests

`drupal-rector` itself uses phpunit for internal testing.

`ddev phpunit` will run the tests for you.

## Development Environment

* [Docker](https://ddev.readthedocs.io/en/stable/users/docker_installation/)
Expand Down
27 changes: 19 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"docs": "https://www.drupal.org/docs/user_guide/en/index.html",
"chat": "https://www.drupal.org/node/314178"
},
"platform": {
"php": "8.2"
},
"repositories": [
{
"type": "composer",
Expand All @@ -22,21 +25,29 @@
}
],
"require": {
"composer/installers": "^1.2",
"drupal/core-composer-scaffold": "^8.8",
"drupal/core-project-message": "^8.8",
"drupal/core-recommended": "^8.8",
"drush/drush": "^10.5",
"palantirnet/drupal-rector": "dev-main",
"phpunit/phpunit": "~7.5"
"composer/installers": "^2.0",
"drupal/admin_toolbar": "^3.4",
"drupal/config_inspector": "^2.1",
"drupal/core-composer-scaffold": "^10.1",
"drupal/core-project-message": "^10.1",
"drupal/core-recommended": "^10.1",
"drupal/devel": "^5.1",
"drupal/examples": "^4.0",
"drush/drush": "^11.4",
"palantirnet/drupal-rector": "dev-main"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"drupal/core-composer-scaffold": true,
"drupal/core-project-message": true
}
},
"scripts": {
"develop-rector": [
Expand Down
Loading