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

fix: windows compatibility issues #129

Open
wants to merge 13 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
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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/
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
208 changes: 114 additions & 94 deletions README.md

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}\" --",
Expand Down
2 changes: 1 addition & 1 deletion scripts/export-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions scripts/import-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
3 changes: 2 additions & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions wp-configs/phpcs-rules-standard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<exclude name="Generic.Files.LineEndings.InvalidEOLChar" />
<!-- exclude other stuff as you wish -->
</rule>
</ruleset>