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

Upgrade to Symfony 6.4 & Asset Mapper #2

Merged
merged 2 commits into from
Dec 8, 2023
Merged
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/assets/vendor/
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"eslint:recommended",
"plugin:json/recommended"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
Expand Down
21 changes: 5 additions & 16 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ jobs:
- name: 'Checkout'
uses: actions/checkout@v3

- name: 'Setup node'
uses: actions/setup-node@v2
with:
node-version: '16'

- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
Expand All @@ -45,40 +40,34 @@ jobs:
path: public/resized
key: resized-images-${{ secrets.CACHE_VERSION }}

- name: 'Cache NPM dependencies'
uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('package-lock.json') }}

- name: 'Install dependencies'
run: |
echo "::group::composer install"
composer install --no-progress --ansi
echo "::endgroup::"

echo "::group::npm install"
npm install --color=always --no-progress --no-audit
echo "::group::importmap install"
symfony console importmap:install --ansi
echo "::endgroup::"

- name: 'Warmup'
run: |
echo "::group::warmup production env"
npx encore production --color
bin/console cache:clear --ansi
bin/console cache:warmup --ansi
bin/console sass:build --ansi
bin/console asset-map:compile --ansi
echo "::endgroup::"
env:
NODE_ENV: production
APP_ENV: prod
WEBPACK_PUBLIC_PATH: /${{ github.event.repository.name }}/build

- name: 'Build static site'
run: bin/console stenope:build --no-interaction -vvv --ansi
env:
APP_ENV: prod
# Replace with your GH Pages URL:
ROUTER_DEFAULT_URI: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
APP_BASE_PATH: /${{ github.event.repository.name }}

# https://github.com/marketplace/actions/deploy-to-github-pages
- name: '🚀 Deploy'
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ jobs:
path: public/resized
key: resized-images-tests-${{ secrets.CACHE_VERSION }}

- name: 'Cache blurhash images'
uses: actions/cache@v2
with:
path: var/cache/pools/app
key: resized-blurhash-tests-${{ secrets.CACHE_VERSION }}

- name: 'Install dependencies'
id: deps
run: |
Expand All @@ -68,6 +62,10 @@ jobs:
npm install --color=always --no-progress --no-audit
echo "::endgroup::"

echo "::group::importmap install"
symfony console importmap:install --ansi
echo "::endgroup::"

- name: 'Warmup'
run: |
bin/console cache:clear --ansi --no-warmup
Expand Down Expand Up @@ -108,7 +106,8 @@ jobs:

- name: 'Check build static'
run: |
npx encore production --color
bin/console sass:build --ansi
bin/console asset-map:compile --ansi
bin/console stenope:build --no-interaction -vvv --ansi
env:
APP_ENV: prod
Expand Down
20 changes: 11 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
Expand All @@ -13,14 +12,6 @@
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###

/build/

###> friendsofphp/php-cs-fixer ###
Expand All @@ -31,3 +22,14 @@ yarn-error.log
###> glide ###
/public/resized
###< glide ###

###> symfony/asset-mapper ###
/public/assets/
/assets/vendor
###< symfony/asset-mapper ###

/node_modules/

###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
->in(__DIR__)
->exclude('var')
->exclude('node_modules')
->notPath('importmap.php')
;

return (new PhpCsFixer\Config())
Expand Down
50 changes: 27 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,76 +9,80 @@ include ./.make/help.mk
###########

## Install dependencies
install: install.composer install.npm
install: install.composer install.npm install.assets

install.composer:
symfony composer install

install.npm:
npm install

install.assets:
symfony console importmap:install

## Update dependencies
update: update.composer update.npm
update: update.composer

update.composer:
symfony composer update

update.npm:
npm update

###############
# Development #
###############

## Dev - Start the whole application for development purposes (local only)
serve:
serve: clear.assets
# https://www.npmjs.com/package/concurrently
npx concurrently "make serve.php" "make serve.assets" --names="Symfony,Webpack" --prefix=name --kill-others --kill-others-on-fail
npx concurrently "make serve.php" "make serve.assets" --names="Symfony,Assets" --prefix=name --kill-others --kill-others-on-fail

## Dev - Start Symfony server
serve.php:
symfony server:start --no-tls

## Dev - Start webpack dev server with HMR (Hot reload)
## Dev - Build Saas files
serve.assets:
npx encore dev-server --mode=development
symfony console sass:build --watch

## Dev - Watch assets
watch.assets:
npm run watch
## Clear - Clear the assets
clear.assets:
rm -rf public/assets

## Clear - Clear the build dir and assets
clear.build:
rm -rf build public/build
clear.build: clear.assets
rm -rf build

## Clear - Clear resized images cache
clear.images:
rm -rf public/resized

## Clear - Clear symfony cache
clear.cache:
symfony console cache:clear

#########
# Build #
#########

## Build - Build assets
build.assets: export APP_ENV = prod
build.assets:
npm run build
symfony console sass:build
symfony console asset-map:compile

## Build - Build static site
build.content: export APP_ENV = prod
build.content:
rm -rf public/resized
symfony console cache:clear
build.content: clear.images clear.cache
symfony console stenope:build

## Build - Build static site without resizing images, for moar speed
build.content.without-images: export APP_ENV = prod
build.content.without-images: export GLIDE_PRE_GENERATE_CACHE = 0
build.content.without-images:
symfony console cache:clear
build.content.without-images: clear.cache
symfony console stenope:build

## Build - Build static site with assets
build.static: build.assets build.content
build.static: export APP_ENV = prod
build.static: clear.cache build.assets build.content

## Serve - Serve the static version
serve.static:
Expand Down Expand Up @@ -131,10 +135,10 @@ lint.phpstan@integration:
symfony php vendor/bin/phpstan --no-progress --no-interaction analyse

lint.eslint:
npx eslint assets/js --ext .js,.json --fix
npx eslint assets --ext .js,.json --fix

lint.eslint@integration:
npx eslint assets/js --ext .js,.json
npx eslint assets --ext .js,.json

########
# Test #
Expand Down
2 changes: 2 additions & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// start the Stimulus application
import './bootstrap.js';
3 changes: 3 additions & 0 deletions assets/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { startStimulusApp } from '@symfony/stimulus-bundle';

startStimulusApp();
4 changes: 0 additions & 4 deletions assets/js/app.js

This file was deleted.

9 changes: 0 additions & 9 deletions assets/js/bootstrap.js

This file was deleted.

4 changes: 0 additions & 4 deletions assets/scss/app.scss

This file was deleted.

9 changes: 9 additions & 0 deletions assets/styles/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Remove the skeleton CSS
@import "skeleton-theme";

// and write your own CSS here

// Make the mini Sf toolbar more visible on white background
.sf-minitoolbar {
background-color: #8d8d8d !important;
}
10 changes: 7 additions & 3 deletions bin/phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ if (!ini_get('date.timezone')) {
}

if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
if (PHP_VERSION_ID >= 80000) {
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
} else {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
}
} else {
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
Expand Down
Loading
Loading