Stop using grunt and use grumphp and robo instead

This commit is contained in:
Pierre Rudloff 2019-11-30 16:33:39 +01:00
parent b7fc304375
commit 2f3ab77e8b
16 changed files with 1590 additions and 2430 deletions

View file

@ -5,9 +5,7 @@ addons:
apt:
packages:
- language-pack-fr
install:
- composer install --no-progress
- yarn install
install: composer install --no-progress
script:
- grunt lint
- grunt test
- composer lint
- composer test

View file

@ -1,21 +1,14 @@
FROM php:7.3-apache
RUN apt-get update && apt-get install -my gnupg
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update
RUN apt-get install -y libicu-dev xz-utils git zlib1g-dev python nodejs libgmp-dev gettext yarn libxslt1-dev libzip-dev
RUN apt-get install -y libicu-dev xz-utils git zlib1g-dev python libgmp-dev gettext libzip-dev
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install intl
RUN docker-php-ext-install zip
RUN docker-php-ext-install gmp
RUN docker-php-ext-install gettext
RUN docker-php-ext-install xsl
RUN a2enmod rewrite
RUN curl -sS https://getcomposer.org/installer | php
COPY resources/php.ini /usr/local/etc/php/
COPY . /var/www/html/
RUN php composer.phar install --prefer-dist --no-progress
RUN yarn install --prod
RUN yarn grunt
ENV CONVERT=1

View file

@ -1,162 +0,0 @@
/*jslint node: true */
module.exports = function (grunt) {
'use strict';
grunt.initConfig(
{
githash: {
main: {
options: {}
}
},
cssmin: {
combine: {
files: {
'dist/main.css': ['css/*.css']
}
}
},
watch: {
styles: {
files: ['css/*.css'],
tasks: ['cssmin']
}
},
phpcs: {
options: {
standard: 'PSR12',
bin: 'vendor/bin/phpcs'
},
php: {
src: ['*.php', 'classes/*.php', 'classes/*/*.php', 'controllers/*.php']
},
tests: {
src: ['tests/*.php']
}
},
phpstan: {
options: {
level: 'max',
bin: 'vendor/bin/phpstan',
config: 'phpstan.neon'
},
php: {
src: ['*.php', 'classes/*.php', 'controllers/*.php']
},
tests: {
src: ['tests/*.php']
}
},
jslint: {
Gruntfile: {
src: ['Gruntfile.js']
}
},
phpunit: {
options: {
bin: 'vendor/bin/phpunit',
stopOnError: true,
stopOnFailure: true,
followOutput: true
},
classes: {
dir: 'tests/'
}
},
compress: {
release: {
options: {
archive: 'alltube-<%= githash.main.tag %>.zip'
},
src: ['*.php', 'config/*', '!config/config.yml', 'dist/**', '.htaccess', 'img/**', 'LICENSE', 'README.md', 'robots.txt', 'resources/sitemap.xml', 'resources/manifest.json', 'templates/**', 'templates_c/', 'vendor/**', 'classes/**', 'controllers/**', 'bower_components/**', 'i18n/**', '!vendor/ffmpeg/**', '!vendor/bin/ffmpeg', '!vendor/anam/phantomjs-linux-x86-binary/**', '!vendor/bin/phantomjs', '!vendor/phpunit/**', '!vendor/squizlabs/**', '!vendor/rinvex/countries/resources/geodata/*.json', '!vendor/countries/country/resources/flags/*.svg', 'node_modules/open-sans-fontface/fonts/**']
}
},
phpdocumentor: {
doc: {
options: {
directory: 'classes/,controllers/,tests/'
}
}
},
jsonlint: {
manifests: {
src: ['*.json', 'resources/*.json'],
options: {
format: true
}
}
},
fixpack: {
package: {
src: 'package.json'
}
},
potomo: {
dist: {
options: {
poDel: false
},
files: {
'i18n/fr_FR/LC_MESSAGES/Alltube.mo': 'i18n/fr_FR/LC_MESSAGES/Alltube.po',
'i18n/zh_CN/LC_MESSAGES/Alltube.mo': 'i18n/zh_CN/LC_MESSAGES/Alltube.po',
'i18n/es_ES/LC_MESSAGES/Alltube.mo': 'i18n/es_ES/LC_MESSAGES/Alltube.po',
'i18n/de_DE/LC_MESSAGES/Alltube.mo': 'i18n/de_DE/LC_MESSAGES/Alltube.po',
'i18n/pt_BR/LC_MESSAGES/Alltube.mo': 'i18n/pt_BR/LC_MESSAGES/Alltube.po',
'i18n/ar/LC_MESSAGES/Alltube.mo': 'i18n/ar/LC_MESSAGES/Alltube.po'
}
}
},
csslint: {
options: {
'box-sizing': false,
'bulletproof-font-face': false
},
css: {
src: 'css/*'
}
},
markdownlint: {
doc: {
src: ['README.md', 'CONTRIBUTING.md', 'resources/*.md']
}
},
githooks: {
all: {
'pre-commit': 'lint'
}
}
}
);
grunt.loadNpmTasks('grunt-githash');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-phpcs');
grunt.loadNpmTasks('grunt-phpunit');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-jslint');
grunt.loadNpmTasks('grunt-phpdocumentor');
grunt.loadNpmTasks('grunt-jsonlint');
grunt.loadNpmTasks('grunt-fixpack');
grunt.loadNpmTasks('grunt-potomo');
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-markdownlint');
grunt.loadNpmTasks('grunt-phpstan');
grunt.loadNpmTasks('grunt-githooks');
grunt.loadNpmTasks('grunt-changed');
grunt.registerTask('default', ['cssmin', 'potomo', 'phpdocumentor']);
grunt.registerTask(
'lint',
[
'csslint',
'jslint',
'fixpack',
'jsonlint',
'markdownlint',
'changed:phpcs',
'changed:phpstan'
]
);
grunt.registerTask('test', ['phpunit']);
grunt.registerTask('release', ['default', 'githash', 'compress']);
};

View file

@ -17,10 +17,9 @@ You just have to unzip it on your server and it should be ready to use.
### From Git
In order to get AllTube working,
you need to use [Yarn](https://yarnpkg.com/) and [Composer](https://getcomposer.org/):
you need to use [Composer](https://getcomposer.org/):
```bash
yarn install
composer install
```
@ -44,11 +43,10 @@ you need to set the `AllowOverride` setting to `All` or `FileInfo`.
#### Update
When updating from Git, you need to run yarn and Composer again:
When updating from Git, you need to run Composer again:
```bash
git pull
yarn install --prod
composer install
```
@ -66,7 +64,7 @@ cp config/config.example.yml config/config.yml
## PHP requirements
You will need PHP 5.5 (or higher) and the following PHP modules:
You will need PHP 7.1 (or higher) and the following PHP modules:
* fileinfo
* intl

64
RoboFile.php Normal file
View file

@ -0,0 +1,64 @@
<?php
use Robo\Tasks;
use Symfony\Component\Finder\Finder;
/**
* Manage robo tasks.
*/
class RoboFile extends Tasks
{
/**
* Create release archive
* @return void
*/
public function release()
{
$result = $this->taskExec('git')
->args('describe')
->printOutput(false)
->run();
$result->provideOutputdata();
$tag = $result->getOutputData();
// We don't want the whole vendor directory.
$finder = new Finder();
$finder->files()
->in(__DIR__ . '/vendor/')
->exclude(
[
'ffmpeg/',
'bin/',
'anam/phantomjs-linux-x86-binary/',
'phpunit/',
'squizlabs/',
'rinvex/countries/resources/geodata/',
'rinvex/countries/resources/flags/'
]
);
$zipTask = $this->taskPack('alltube-' . $tag . '.zip')
->add('index.php')
->add('config/config.example.yml')
->add('.htaccess')
->add('img')
->add('LICENSE')
->add('README.md')
->add('robots.txt')
->add('resources')
->add('templates')
->add('templates_c/')
->add('classes')
->add('controllers')
->add('i18n');
foreach ($finder as $file) {
if ($path = $file->getRelativePathname()) {
$zipTask->add('vendor/' . $path);
}
}
$zipTask->run();
}
}

View file

@ -14,9 +14,6 @@
{
"url": "heroku/php"
},
{
"url": "heroku/nodejs"
},
{
"url": "heroku/python"
}

View file

@ -9,7 +9,7 @@ namespace Alltube;
use Aura\Session\Segment;
use Symfony\Component\Process\Process;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\MoFileLoader;
use Symfony\Component\Translation\Loader\PoFileLoader;
/**
* Class used to manage locales.
@ -72,11 +72,11 @@ class LocaleManager
$this->setLocale(new Locale($cookieLocale));
}
$this->translator->addLoader('gettext', new MoFileLoader());
$this->translator->addLoader('gettext', new PoFileLoader());
foreach ($this->getSupportedLocales() as $locale) {
$this->translator->addResource(
'gettext',
__DIR__ . '/../i18n/' . $locale->getIso15897() . '/LC_MESSAGES/Alltube.mo',
__DIR__ . '/../i18n/' . $locale->getIso15897() . '/LC_MESSAGES/Alltube.po',
$locale->getIso15897()
);
}

View file

@ -10,26 +10,29 @@
"guzzlehttp/guzzle": "~6.3.0",
"jawira/case-converter": "^1.2",
"mathmarques/smarty-view": "~1.1.0",
"npm-asset/open-sans-fontface": "^1.4",
"rinvex/countries": "~3.1.0",
"slim/slim": "~3.12.1",
"symfony/process": "^5.0",
"symfony/translation": "^5.0",
"symfony/yaml": "^5.0",
"symfony/process": "^4.0",
"symfony/translation": "^4.0",
"symfony/yaml": "^4.0",
"zonuexe/http-accept-language": "~0.4.1"
},
"require-dev": {
"anam/phantomjs-linux-x86-binary": "~2.1.1",
"consolidation/robo": "^2.0",
"ffmpeg/ffmpeg": "^4.1",
"heroku/heroku-buildpack-php": "^162.0",
"php-mock/php-mock-mockery": "^1.3",
"phpro/grumphp": "^0.17.0",
"phpstan/phpstan": "~0.9.2",
"phpunit/phpunit": "^8.4",
"rg3/youtube-dl": "^2019.09",
"roave/security-advisories": "dev-master",
"smarty-gettext/smarty-gettext": "^1.6",
"squizlabs/php_codesniffer": "^3.5",
"symfony/debug": "^4.4",
"symfony/var-dumper": "^5.0"
"symfony/debug": "^4.0",
"symfony/var-dumper": "^4.0"
},
"extra": {
"paas": {
@ -39,6 +42,10 @@
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
},
{
"type": "package",
"package": {
@ -90,6 +97,9 @@
},
"scripts": {
"compile": "composer install --ignore-platform-reqs",
"lint": "grumphp run --ansi",
"test": "phpunit",
"release": "robo release",
"update-locales": [
"tsmarty2c.php templates > i18n/template.pot",
"xgettext --omit-header -kt -j -o i18n/template.pot classes/*.php classes/*/*.php controllers/*"

1530
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -2,13 +2,13 @@
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
src: local('Open Sans Light'), local('OpenSans-Light'), url(../node_modules/open-sans-fontface/fonts/Light/OpenSans-Regular.ttf);
src: local('Open Sans Light'), local('OpenSans-Light'), url(../vendor/npm-asset/open-sans-fontface/fonts/Light/OpenSans-Regular.ttf);
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans'), local('OpenSans'), url(../node_modules/open-sans-fontface/fonts/Regular/OpenSans-Regular.ttf);
src: local('Open Sans'), local('OpenSans'), url(../vendor/npm-asset/open-sans-fontface/fonts/Regular/OpenSans-Regular.ttf);
}
.small-font {

16
grumphp.yml Normal file
View file

@ -0,0 +1,16 @@
---
parameters:
ascii: ~
tasks:
jsonlint: ~
xmllint: ~
yamllint: ~
phpcs:
standard: PSR12
ignore_patterns:
- RoboFile.php
phpstan:
level: max
configuration: phpstan.neon
ignore_patterns:
- RoboFile.php

View file

@ -1,50 +0,0 @@
{
"name": "alltube",
"description": "HTML GUI for youtube-dl",
"version": "2.1.0",
"author": "Pierre Rudloff",
"bugs": "https://github.com/Rudloff/alltube/issues",
"dependencies": {
"grunt": "~1.0.1",
"grunt-contrib-cssmin": "~2.2.1",
"grunt-phpdocumentor": "^0.4.1",
"grunt-potomo": "~3.5.0",
"open-sans-fontface": "~1.4.0"
},
"devDependencies": {
"grunt-changed": "^3.0.0",
"grunt-contrib-compress": "~1.5.0",
"grunt-contrib-csslint": "~2.0.0",
"grunt-contrib-watch": "~1.1.0",
"grunt-fixpack": "~0.1.0",
"grunt-githash": "~0.1.3",
"grunt-githooks": "^0.6.0",
"grunt-jslint": "~1.1.15",
"grunt-jsonlint": "^2.0.0",
"grunt-markdownlint": "^2.7.0",
"grunt-phpcs": "~0.4.0",
"grunt-phpstan": "~0.2.0",
"grunt-phpunit": "~0.3.6"
},
"homepage": "https://www.alltubedownload.net/",
"keywords": [
"alltube",
"download",
"video",
"youtube"
],
"license": "GPL-3.0",
"main": "Gruntfile.js",
"repository": {
"type": "git",
"url": "https://github.com/Rudloff/alltube.git"
},
"resolutions": {
"grunt-fixpack/fixpack/rc": "^1.2.8",
"grunt-githooks/handlebars": "^4.3.0"
},
"scripts": {
"postinstall": "grunt",
"prepare": "grunt githooks"
}
}

View file

@ -1,4 +1,4 @@
parameters:
ignoreErrors:
# The Archive constructor messes up the output buffering.
- '#Alltube\\PlaylistArchiveStream::__construct\(\) does not call parent constructor from Barracuda\\ArchiveStream\\ZipArchive\.#'
- '#Alltube\\Stream\\PlaylistArchiveStream::__construct\(\) does not call parent constructor from Barracuda\\ArchiveStream\\ZipArchive\.#'

View file

@ -73,14 +73,6 @@ There are two known workarounds:
Please note that this can use a lot of resources on the server
(which is why we won't enable it on alltubedownload.net).
## CSS and JavaScript files are missing
You probably don't have the minified files (in the `dist` folder).
You need to either:
* Use a [release package](https://github.com/Rudloff/alltube/releases)
* Run `yarn install` (see detailed instructions in the [README](../README.md#from-git))
## I get a 404 error on every page except the index
This is probably because your server does not have [mod_rewrite](https://httpd.apache.org/docs/current/mod/mod_rewrite.html)

View file

@ -8,7 +8,8 @@
<meta name="twitter:description" content="{$description|escape}" />
<meta property="og:description" content="{$description|escape}" />
{/if}
<link rel="stylesheet" href="{base_url}/dist/main.css" />
<link rel="stylesheet" href="{base_url}/css/fonts.css" />
<link rel="stylesheet" href="{base_url}/css/style.css" />
<title>{$config->appName}{if isset($title)} - {$title|escape}{/if}</title>
<link rel="canonical" href="{$canonical}" />
<link rel="icon" href="{base_url}/img/favicon.png" />

2127
yarn.lock

File diff suppressed because it is too large Load diff