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

Manage frontend dependencies with npm/yarn and webpack #1072

Merged
merged 5 commits into from
Mar 28, 2018
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{htaccess,html,xml}]
[*.{htaccess,html,xml,js}]
indent_size = 2

[*.php]
Expand Down
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
"extends": "airbnb-base",
"env": {
"browser": true,
},
"rules": {
"no-param-reassign": 0, // manipulate DOM style properties
"no-restricted-globals": 0, // currently Shaarli uses alert/confirm, could be be improved later
"no-alert": 0, // currently Shaarli uses alert/confirm, could be be improved later
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time to raise some issues then :)

I'm about to do the same for the TODOs concerning usage of die() and exit() in PHP code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue raised in #1095

"no-cond-assign": [2, "except-parens"], // assignment in while loops is readable and avoid assignment duplication
}
};
27 changes: 14 additions & 13 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ Dockerfile text
*.mo binary

# Exclude from Git archives
.editorconfig export-ignore
.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
.travis.yml export-ignore
doc/**/*.json export-ignore
doc/**/*.md export-ignore
docker/ export-ignore
Doxyfile export-ignore
Makefile export-ignore
mkdocs.yml export-ignore
phpunit.xml export-ignore
tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
.travis.yml export-ignore
doc/**/*.json export-ignore
doc/**/*.md export-ignore
docker/ export-ignore
Doxyfile export-ignore
Makefile export-ignore
node_modules/ export-ignore
mkdocs.yml export-ignore
phpunit.xml export-ignore
tests/ export-ignore
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ doc/html/
tpl/*
!tpl/default
!tpl/vintage

# Front end
node_modules
tpl/default/js
tpl/default/css
tpl/default/fonts
tpl/default/img
tpl/vintage/js
tpl/vintage/css
tpl/vintage/img
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ sudo: false
dist: trusty
language: php
cache:
yarn: true
directories:
- $HOME/.composer/cache
- $HOME/.cache/yarn
php:
- 7.2
- 7.1
- 7.0
- 5.6
install:
- composer self-update
- yarn install
- composer install --prefer-dist
- locale -a
before_script:
- PATH=${PATH//:\.\/node_modules\/\.bin/}
script:
- make clean
- make check_permissions
- make eslint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frontend lint & tests should be run in a dedicated JS / Node matrix to avoid cluttering the PHP test environments

this will be a bit tricky so it's OK to address this point in a separate PR

- make all_tests
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,23 @@ composer_dependencies: clean
composer install --no-dev --prefer-dist
find vendor/ -name ".git" -type d -exec rm -rf {} +

### download 3rd-party frontend libraries
frontend_dependencies:
yarn install

### Build frontend dependencies
build_frontend: frontend_dependencies
yarn run build

### generate a release tarball and include 3rd-party dependencies and translations
release_tar: composer_dependencies htmldoc translate
release_tar: composer_dependencies htmldoc translate build_frontend
git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD
tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/
tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/
gzip $(ARCHIVE_VERSION).tar

### generate a release zip and include 3rd-party dependencies and translations
release_zip: composer_dependencies htmldoc translate
release_zip: composer_dependencies htmldoc translate build_frontend
git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).zip -9 HEAD
mkdir -p $(ARCHIVE_PREFIX)/{doc,vendor}
rsync -a doc/html/ $(ARCHIVE_PREFIX)doc/html/
Expand Down Expand Up @@ -207,3 +215,8 @@ htmldoc:
### Generate Shaarli's translation compiled file (.mo)
translate:
@find inc/languages/ -name shaarli.po -execdir msgfmt shaarli.po -o shaarli.mo \;

### Run ESLint check against Shaarli's JS files
eslint:
@yarn run eslint assets/vintage/js/
@yarn run eslint assets/default/js/
13 changes: 13 additions & 0 deletions assets/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<IfModule version_module>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
<IfVersion < 2.4>
Allow from none
Deny from all
</IfVersion>
</IfModule>

<IfModule !version_module>
Require all denied
</IfModule>
10 changes: 10 additions & 0 deletions assets/common/js/picwall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Blazy from 'blazy';

(() => {
const picwall = document.getElementById('picwall_container');
if (picwall != null) {
// Suppress ESLint error because that's how bLazy works
/* eslint-disable no-new */
new Blazy();
}
})();
File renamed without changes
File renamed without changes
File renamed without changes
Loading