diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..7b86682a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,22 @@ +# https://www.git-scm.com/docs/gitattributes + +# Set default behavior to automatically normalize line endings. +* text=auto + +# Force bash scripts to always use LF line endings so that if a repo is accessed +# in Unix via a file share from Windows, the scripts will work. +*.sh text eol=lf + +# Set specific extensions manually as binary. +# https://www.git-scm.com/docs/gitattributes#_marking_files_as_binary +*.data -diff + +# Configure non-standard file extensions. Set as text to allow for line ending +# conversion to LF, diff type for Git, and syntax highlighting language for GitHub. +# https://github.com/github-linguist/linguist/blob/master/docs/overrides.md +*.module text diff=php linguist-language=php +*.rs.example text diff=rust linguist-language=rust + +# Windows-specific extensions that require CRLF line endings +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c6ba2024..33274d12 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,6 @@ Here's a few things you should know before you submit your PR: - Ensure tests pass: `npm test` - Make changes and then make sure the linters and tests still pass - Push your branch/fork and [submit a PR][pr] -- Assign a [sparkboxer][contributors] to review your PR ## Commit Style @@ -44,5 +43,4 @@ feature: add new linting rule for ... [issues]: ./issues [pr]: ./compare -[contributors]: ./graphs/contributors [conventional commits]: https://www.conventionalcommits.org/en/v1.0.0/ diff --git a/Dockerfile b/Dockerfile index 752cec93..40ee76b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ RUN docker-php-ext-install gd mysqli pdo_mysql zip RUN a2enmod rewrite headers xml2enc proxy proxy_fcgi COPY ./composer.json /var/www/html/composer.json +COPY ./composer.lock /var/www/html/composer.lock COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer RUN composer install @@ -36,6 +37,7 @@ RUN find /var/www/ -type f -exec chmod 644 {} \; # make the linters executable so we can run them from containers RUN chmod +x vendor/bin/phpcs +RUN chmod +x vendor/bin/phpcbf RUN chmod +x vendor/bin/twigcs FROM dev as prod diff --git a/README.md b/README.md index f49c66b8..bb8cbcb9 100644 --- a/README.md +++ b/README.md @@ -8,37 +8,42 @@ Out of the box, this template provides a minimal WordPress theme with basic supp - Support for SCSS with an ITCSS structure already in place - Support for bundling JS with `esbuild` and testing JS with `vitest` - Support for [Twig][twig] templates using [Timber][timber] -- Database import and export scripts to make syncing between environments simple and fast +- Database/uploads import and export scripts to make syncing between environments simple and fast - Generator scripts to speed up the process of adding: - Page templates - Custom post types - Shortcodes - Custom taxonomies - Reusable patterns + - Custom blocks plugins + - Custom blocks - Meta boxes -- Sample custom blocks which you can reference to create your own custom blocks - Code style rules that are enforced by language-specific linters - GitHub Action workflows for code quality, release management, and deployment processes ## Table of Contents -| Developer Documentation | -| --------------------------------------------------- | -| [Quickstart](#quickstart) | -| [Customization](#customization) | -| [Local Development Setup](#local-development-setup) | -| [WordPress](#wordpress) | -| [Project Structure](#project-structure) | -| [Generators](#generators) | -| [Plugins](#plugins) | -| [Custom Blocks](#custom-blocks) | -| [Deployment](#deployment) | -| [How to Contribute](./CONTRIBUTING.md) | -| [Code of Conduct](./CODE_OF_CONDUCT.md) | +| Developer Documentation | +| --------------------------------------------------------- | +| [Quickstart](#quickstart) | +| [Customization](#customization) | +| [Local Development Setup](#local-development-setup) | +| [WordPress](#wordpress) | +| [Project Structure](#project-structure) | +| [Plugins](#plugins) | +| [Generators](#generators) | +| [Implementing Custom Blocks](#implementing-custom-blocks) | +| [Deployment](#deployment) | +| [How to Contribute](./CONTRIBUTING.md) | +| [Code of Conduct](./CODE_OF_CONDUCT.md) | ## Quickstart -This project requires [Docker][docker] and [Node.js][node] for local development. You may also find it useful to install [Composer][composer] for linting in your editor, but it isn't strictly necessary. To run the project for the first time, do the following: +This project requires [Docker][docker] and [Node.js][node] for local development. For a better editing experience for PHP and Twig files, it's useful to have [PHP installed][php-install] on your system as well, but it isn't required. + +If you're using Windows, it's best to use Git Bash (included when you install [Git](https://git-scm.com/downloads)) for command line operations for compatibility. If using [VS Code][vs-code], you can [set Git Bash as your default terminal](https://code.visualstudio.com/docs/sourcecontrol/intro-to-git#_git-bash-on-windows). + +To run the project for the first time, do the following: 1. Duplicate `.env.example` and rename it `.env`, changing variables [as needed](#setting-local-environment-variables) 1. Run `npm install` @@ -65,9 +70,6 @@ After generating a new repo from the Sparkpress template, you will need to chang - [ ] `.github/workflows/deploy.docker.yml` (references to the container registry or delete the file if not using a docker deployment process) - [ ] `.github/workflows/deploy.pantheon.yml` (theme folder names) - [ ] `.github/workflows/release-please.yml` (`package-name` field) - - [ ] `scripts/export-db.sh` (db container name) - - [ ] `scripts/import-db.sh` (db container names) - - [ ] `scripts/run.sh` (container name) - [ ] `src/php/style.css` (theme name plus the other metadata in the file) - [ ] `src/php/inc/theme-scripts.php` (metadata and prefixes for function/script names) - [ ] `src/php/inc/theme-setup.php` (metadata and prefixes for function names) @@ -84,9 +86,13 @@ Beyond that, it's up to you to customize the site based on your project's needs. ## Local Development Setup +### npm scripts + +This project uses [npm scripts][npm-scripts] for most development tasks, and they are defined in the `scripts` field in `package.json`. If you're developing on Windows, you may need to run `npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"` for some scripts to work. + ### Setting Local Environment Variables -For the local environment we are using a `.env` to define the username, passwords, and the database name used in the Docker container. +For the local environment we are using a `.env` file to define the username, passwords, and the database name used in the Docker container. - `MYSQL_USER` is the username WordPress will use to access the database - `MYSQL_PASSWORD` is the password for `MYSQL_USER` @@ -97,9 +103,9 @@ For the local environment we are using a `.env` to define the username, password ### Linting -This theme uses the following files for linting: +This theme uses the following tools for linting: -- ESLint for JS files with recommended rules for vanilla JS and React +- ESLint for JS files with recommended rules for vanilla JS, React, and WordPress - Stylelint for SCSS files with standard CSS and SCSS rules - PHP_Codesniffer for PHP Files with rules from `wp-configs/phpcs-rules-standard.xml` which extends the WordPress Coding Standards. - Twig_Codesniffer with default rules @@ -179,17 +185,12 @@ You can export your `uploads` folder for another developer to import or to impor This will happen automatically on import, but if you want to manually backup your `uploads` folder, you can run `npm run backup:uploads`. This functions nearly identically to the `export:uploads` script, except for using a different prefix and putting the zip file in `sync/uploads/backups`. As with `export:uploads`, you can specify a name for your backup if you want. -### Atom +### VS Code -If you use Atom, go to Preferences > Packages. Open the `language-php` Core Package settings. Go to the Tab Type setting and set the drop down option to `hard`. - -#### VS Code - -If you use Microsoft VS Code, create a `settings.json` inside a `.vscode` directory at the root of the project. Include this in your setting (it will help make developing with PHP_Codesniffer much easier): +If you use [VS Code][vs-code], you can create a `settings.json` file inside a `.vscode` directory at the root of the project to change how PHP or other languages are treated by the editor. ```json { - "phpcs.standard": "wp-configs/phpcs-rules-standard.xml", "editor.tabSize": 2, "[php]": { "editor.tabSize": 4, @@ -199,10 +200,30 @@ If you use Microsoft VS Code, create a `settings.json` inside a `.vscode` direct } ``` -Helpful VS Code Extensions: +#### Helpful VS Code Extensions + +We recommend these extensions to make working with PHP and Twig easier. + +- [PHP Sniffer & Beautifier][phpsab-vscode] (may not work on Windows) +- [Twig][twig-vscode] +- [twigcs][twigcs-vscode] (may not work on Windows) -- [phpcs][phpcs_vscode] -- [Twig][twig_vscode] +Note: you will need to have vendor files available on your host machine (not the container they're installed in) for the linters to highlight code while you're working. You can run `npm run map-vendor-files` to make them available at the paths specified in the example `settings.json` below, and as long as you have PHP installed on your system, they _should_ work. Windows has limited support for PHP, though, so you may not be able to get real-time error highlighting on PHP/Twig files. + +```json +{ + "phpsab.executablePathCS": "vendor/bin/phpcs", + "phpsab.executablePathCBF": "vendor/bin/phpcbf", + "phpsab.standard": "wp-configs/phpcs-rules-standard.xml", + "twigcs.executablePath": "vendor/bin/twigcs", + "editor.tabSize": 2, + "[php]": { + "editor.tabSize": 4, + "editor.insertSpaces": false, + "editor.detectIndentation": false + } +} +``` ## WordPress @@ -215,7 +236,7 @@ Whenever a new version of WordPress is released, follow this process to update t 1. Change `WP_VERSION` in `Dockerfile` to the latest version 1. Submit a PR with the update 1. If your hosting provider manages the WordPress version, update it through their mechanism for staging, test, and/or production enviroments -1. If the update made breaking changes, create a bug card and _do not_ push any changes +1. If the update made breaking changes, create a bug card/issue and _do not_ push any changes ### Permalink Settings @@ -331,6 +352,42 @@ The `php/` directory holds the PHP template files for the WordPress theme. Other - `partials` - Twig templates for components or pieces of the page to be reused should go here. - `shortcodes` - Twig templates for shortcodes should go here. +## Plugins + +### Installing Plugins + +Install plugins via `composer` by running `npm run php:run composer require wpackagist-plugin/:`. For example: + +```sh +# install a specific version/range for advanced-custom-fields +npm run php:run composer require wpackagist-plugin/advanced-custom-fields:^6.1 + +# or just install the latest version, letting composer resolve the range +npm run php:run composer require wpackagist-plugin/advanced-custom-fields +``` + +Running this command will update `composer.json` and `composer.lock`, but you will need to rebuild (`docker compose build`) and restart your container (`npm start` or `npm run serve:dev`) to see the new plugin reflected in the WordPress admin. + +### Updating Plugins + +You can run `composer require` as above to update existing plugins, or you can do the following. + +1. Update the version number in the "require" list in `composer.json`. +1. Run `npm run php:run composer update` to update `composer.lock`. + +Again, you'll need to rebuild and restart your container to see the changes reflected in WordPress. + +### Recommended Plugins + +This is a non-comprehensive list of plugins that we have found useful on other projects. + +- [Metabox][metabox] +- [Advanced Custom Fields][advanced-custom-fields] +- [Yoast SEO][yoast-seo] +- [Google Site Kit][google-site-kit] +- [Contact Form 7][contact-form-7] +- [Rollbar][rollbar] + ## Generators We have a handful of generators to make it easier to add new custom post types, taxonomies, shortcodes, and page templates. If none of the generators give you what you need, you can try using https://generatewp.com/ to get more relevant code snippets. @@ -468,45 +525,9 @@ The following file will be created based on your input: [Meta Box documentation](https://developer.wordpress.org/plugins/metadata/custom-meta-boxes/) -## Plugins +## Implementing Custom Blocks -### Installing Plugins - -Install plugins via `composer` by running `npm run php:run composer require wpackagist-plugin/:`. For example: - -```sh -# install a specific version/range for advanced-custom-fields -npm run php:run composer require wpackagist-plugin/advanced-custom-fields:^6.1 - -# or just install the latest version, letting composer resolve the range -npm run php:run composer require wpackagist-plugin/advanced-custom-fields -``` - -Running this command will update `composer.json` and `composer.lock`, but you will need to rebuild (`docker compose build`) and restart your container (`npm start` or `npm run serve:dev`) to see the new plugin reflected in the WordPress admin. - -### Updating Plugins - -You can run `composer require` as above to update existing plugins, or you can do the following. - -1. Update the version number in the "require" list in `composer.json`. -1. Run `npm run php:run composer update` to update `composer.lock`. - -Again, you'll need to rebuild and restart your container to see the changes reflected in WordPress. - -### Recommended Plugins - -This is a non-comprehensive list of plugins that we have found useful on other projects. - -- [Metabox][metabox] -- [Advanced Custom Fields][advanced-custom-fields] -- [Yoast SEO][yoast-seo] -- [Google Site Kit][google-site-kit] -- [Contact Form 7][contact-form-7] -- [Rollbar][rollbar] - -## Custom Blocks - -We have two [generators](#generators) that can be used in tandem to create the necessary scaffolding for custom blocks. The first is `npm run generate:custom-blocks-plugin`, which should be run first to create the plugin config, readme, directory, and `package.json`/`docker-compose.yml` changes necessary to make the plugin available to WordPress. The second is `npm run generate:custom-block`, which creates the boilerplate files necessary to create a single custom block within the plugin. +To implement custom blocks, begin by using the two [generators](#generators) in tandem to create the necessary scaffolding for custom blocks. The first is `npm run generate:custom-blocks-plugin`, which should be run first to create the plugin config, readme, directory, and `package.json`/`docker-compose.yml` changes necessary to make the plugin available to WordPress. The second is `npm run generate:custom-block`, which creates the boilerplate files necessary to create a single custom block within the plugin. Note: you will need to restart your development process to pick up the changes after adding a custom blocks plugin and/or a custom block. @@ -568,7 +589,7 @@ This starter template includes a couple of options for deployment workflows, inc ### Docker deployment workflow -This repo includes a [GitHub workflow for building a docker image](./.github/workflows/deploy.docker.yml) that gets pushed GitHub's container registry. This image can be deployed to any hosting provider that supports docker containers. +This repo includes a [GitHub workflow for building a docker image](./.github/workflows/deploy.docker.yml) that gets pushed to GitHub's container registry. This image can be deployed to any hosting provider that supports docker containers. The image includes all core WordPress files for the version specified for `WP_VERSION` in the `Dockerfile`, as well as the theme and plugin files necessary for the site. The other element required for the site to run is the database, which is excluded, since each environment should have its own database that is specified by environment variables. This allows local developers to test against local data without interfering with production or staging environments. @@ -673,30 +694,29 @@ Deployment to Pantheon requires setting the following variables and secrets in G -[docker]: https://www.docker.com -[composer]: https://getcomposer.org/download/ -[node]: https://nodejs.org/en/ -[twig_vscode]: https://marketplace.visualstudio.com/items?itemName=whatwedo.twig -[phpcs_vscode]: https://marketplace.visualstudio.com/items?itemName=shevaua.phpcs -[babel]: https://babeljs.io -[sb-eslint]: https://github.com/sparkbox/eslint-config-sparkbox -[sb-stylelint]: https://github.com/sparkbox/stylelint-config-sparkbox -[wpcs]: https://github.com/WordPress/WordPress-Coding-Standards +[advanced-custom-fields]: https://www.advancedcustomfields.com/ [bemit]: https://csswizardry.com/2015/08/bemit-taking-the-bem-naming-convention-a-step-further/ -[twig]: https://twig.symfony.com/ -[timber]: https://timber.github.io/docs/ +[contact-form-7]: https://contactform7.com/ +[docker]: https://www.docker.com +[gh-personal-access-token]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic +[gh-secrets]: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository +[gh-variables]: https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository +[google-site-kit]: https://sitekit.withgoogle.com/ [html-extension]: https://github.com/twigphp/html-extra -[string-extension]: https://github.com/twigphp/string-extra -[widgets]: https://developer.wordpress.org/themes/functionality/sidebars/ +[itcss]: https://www.xfive.co/blog/itcss-scalable-maintainable-css-architecture/ [metabox]: https://metabox.io/ -[advanced-custom-fields]: https://www.advancedcustomfields.com/ -[yoast-seo]: https://wordpress.org/plugins/wordpress-seo/ -[google-site-kit]: https://sitekit.withgoogle.com/ -[contact-form-7]: https://contactform7.com/ +[node]: https://nodejs.org/en/ +[npm-scripts]: https://docs.npmjs.com/cli/v6/using-npm/scripts +[php-install]: https://www.php.net/manual/en/install.php +[phpsab-vscode]: https://marketplace.visualstudio.com/items?itemName=ValeryanM.vscode-phpsab [rollbar]: https://docs.rollbar.com/docs/wordpress -[itcss]: https://www.xfive.co/blog/itcss-scalable-maintainable-css-architecture/ -[bem]: http://getbem.com [sass]: https://sass-lang.com/ -[gh-variables]: https://docs.github.com/en/actions/learn-github-actions/variables#creating-configuration-variables-for-a-repository -[gh-secrets]: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository -[gh-personal-access-token]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic +[string-extension]: https://github.com/twigphp/string-extra +[timber]: https://timber.github.io/docs/ +[twig-vscode]: https://marketplace.visualstudio.com/items?itemName=whatwedo.twig +[twig]: https://twig.symfony.com/ +[twigcs-vscode]: https://marketplace.visualstudio.com/items?itemName=cerzat43.twigcs +[vs-code]: https://code.visualstudio.com/ +[widgets]: https://developer.wordpress.org/themes/functionality/sidebars/ +[wpcs]: https://github.com/WordPress/WordPress-Coding-Standards +[yoast-seo]: https://wordpress.org/plugins/wordpress-seo/ diff --git a/composer.lock b/composer.lock index 65951eb2..fd052d81 100644 --- a/composer.lock +++ b/composer.lock @@ -417,16 +417,16 @@ }, { "name": "symfony/mime", - "version": "v6.3.3", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "9a0cbd52baa5ba5a5b1f0cacc59466f194730f98" + "reference": "d5179eedf1cb2946dbd760475ebf05c251ef6a6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/9a0cbd52baa5ba5a5b1f0cacc59466f194730f98", - "reference": "9a0cbd52baa5ba5a5b1f0cacc59466f194730f98", + "url": "https://api.github.com/repos/symfony/mime/zipball/d5179eedf1cb2946dbd760475ebf05c251ef6a6e", + "reference": "d5179eedf1cb2946dbd760475ebf05c251ef6a6e", "shasum": "" }, "require": { @@ -481,7 +481,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v6.3.3" + "source": "https://github.com/symfony/mime/tree/v6.3.5" }, "funding": [ { @@ -497,7 +497,7 @@ "type": "tidelift" } ], - "time": "2023-07-31T07:08:24+00:00" + "time": "2023-09-29T06:59:36+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1077,16 +1077,16 @@ }, { "name": "symfony/string", - "version": "v6.3.2", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "53d1a83225002635bca3482fcbf963001313fb68" + "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68", - "reference": "53d1a83225002635bca3482fcbf963001313fb68", + "url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339", + "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339", "shasum": "" }, "require": { @@ -1143,7 +1143,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.3.2" + "source": "https://github.com/symfony/string/tree/v6.3.5" }, "funding": [ { @@ -1159,7 +1159,7 @@ "type": "tidelift" } ], - "time": "2023-07-05T08:41:27+00:00" + "time": "2023-09-18T10:38:32+00:00" }, { "name": "symfony/translation-contracts", @@ -2270,16 +2270,16 @@ }, { "name": "symfony/finder", - "version": "v6.3.3", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e" + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/9915db259f67d21eefee768c1abcf1cc61b1fc9e", - "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e", + "url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4", + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4", "shasum": "" }, "require": { @@ -2314,7 +2314,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.3.3" + "source": "https://github.com/symfony/finder/tree/v6.3.5" }, "funding": [ { @@ -2330,7 +2330,7 @@ "type": "tidelift" } ], - "time": "2023-07-31T08:31:44+00:00" + "time": "2023-09-26T12:56:25+00:00" }, { "name": "symfony/service-contracts", @@ -2490,5 +2490,5 @@ "php": "^8.1" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/docker-compose.yml b/docker-compose.yml index c48e5d72..2f7db873 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,10 @@ services: - ./wp-configs/php.ini:/var/www/html/php.ini - ./.env:/var/www/html/.env - ./wp-configs/.htaccess:/var/www/html/.htaccess + - ./wp-configs/phpcs-rules-standard.xml:/var/www/html/wp-configs/phpcs-rules-standard.xml + - ./src:/var/www/html/src + - ./composer.json:/var/www/html/composer.json + - ./composer.lock:/var/www/html/composer.lock db: image: mysql:8.1 container_name: sparkpress_db diff --git a/package.json b/package.json index 60a851b1..aef23203 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "lint:scss": "stylelint \"src/**/*.scss\" --color --formatter verbose", "lint:twig": "./scripts/run.sh vendor/bin/twigcs src/php/views", "lint": "run-s lint:*", + "map-vendor-files": "mkdir -p vendor && docker compose cp web:/var/www/html/vendor .", "php:run": "./scripts/run.sh", "export": "run-s \"export:* {1}\" --", "backup": "run-s \"backup:* {1}\" --", diff --git a/scripts/export-db.sh b/scripts/export-db.sh index 7e803b8e..8bcf80ea 100755 --- a/scripts/export-db.sh +++ b/scripts/export-db.sh @@ -23,7 +23,7 @@ fi mkdir -p $path # generate SQL dump -docker exec -i sparkpress_db mysqldump --user=root --password=$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE > $path/$prefix-raw.sql +docker compose exec -i db mysqldump --user=root --password=$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE > $path/$prefix-raw.sql # replace localhost URLs with target environment URL sed "s/http:\/\/localhost:8000/$SITE_URL/g" $path/$prefix-raw.sql > $filename diff --git a/scripts/import-db.sh b/scripts/import-db.sh index 865edce4..20550a76 100755 --- a/scripts/import-db.sh +++ b/scripts/import-db.sh @@ -17,9 +17,9 @@ gunzip sync/sql/db-import-raw.sql.gz sed "s/$SITE_URL/http:\/\/localhost:8000/g" sync/sql/db-import-raw.sql > sync/sql/db-import.sql # drop existing database, create a new one, and load it up with data -docker exec -i sparkpress_db mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD -e "drop database if exists $MYSQL_DATABASE" -docker exec -i sparkpress_db mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD -e "create database $MYSQL_DATABASE" -docker exec -i sparkpress_db mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD $MYSQL_DATABASE < sync/sql/db-import.sql +docker compose exec -i db mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD -e "drop database if exists $MYSQL_DATABASE" +docker compose exec -i db mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD -e "create database $MYSQL_DATABASE" +docker compose exec -iT db mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD $MYSQL_DATABASE < sync/sql/db-import.sql # clean up files that aren't useful after import rm sync/sql/db-import* diff --git a/scripts/run.sh b/scripts/run.sh index 2b90f4c3..e93531a5 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -12,5 +12,6 @@ if [ "$CI" == "true" ]; then exec "$@" else # Run the command inside the Docker container - docker run --rm -v .:/tmp -w=/tmp sparkpress-wordpress-starter-web "$@" + # use exec if the container's already running, or spin up a temporary container to run it + docker compose exec -it web "$@" || docker compose run --rm --no-deps --remove-orphans web "$@" fi diff --git a/wp-configs/phpcs-rules-standard.xml b/wp-configs/phpcs-rules-standard.xml index 24ee38ae..a44ced83 100644 --- a/wp-configs/phpcs-rules-standard.xml +++ b/wp-configs/phpcs-rules-standard.xml @@ -7,6 +7,7 @@ +