From 494da5f44937e55dc1e3180b62e2e6ef98eecc9f Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Tue, 5 Nov 2019 18:47:37 +0100 Subject: feat: include Sentry for error reporting --- app/class/Config.php | 13 + composer.json | 3 +- composer.lock | 1366 +++++++++++++++++++++++++++++++++++++++++++++++++- index.php | 1 + 4 files changed, 1381 insertions(+), 2 deletions(-) diff --git a/app/class/Config.php b/app/class/Config.php index 1a4bb17..555129b 100644 --- a/app/class/Config.php +++ b/app/class/Config.php @@ -32,6 +32,7 @@ abstract class Config protected static $homeredirect = null; protected static $interfacecss = null; protected static $bookmark = []; + protected static $sentrydsn = ''; // _______________________________________ F U N _______________________________________ @@ -248,6 +249,11 @@ abstract class Config return self::$bookmark; } + public static function sentrydsn() + { + return self::$sentrydsn; + } + // __________________________________________ S E T ______________________________________ @@ -426,6 +432,13 @@ abstract class Config } } + public static function setsentrydsn($sentrydsn) + { + if (is_string($sentrydsn)) { + self::$sentrydsn = $sentrydsn; + } + } + diff --git a/composer.json b/composer.json index b3ddbd0..230c14e 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "altorouter/altorouter": "^1.2", "jamesmoss/flywheel": "^0.5.2", "league/plates": "^3.3", - "michelf/php-markdown": "^1.8" + "michelf/php-markdown": "^1.8", + "sentry/sdk": "^2.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index bbd865c..7523bfb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "52b153ad00e36470a69f2e3fe33019b9", + "content-hash": "96e0ee3f2bc01b230b311421f62799f9", "packages": [ { "name": "altorouter/altorouter", @@ -61,6 +61,230 @@ ], "time": "2015-11-30T00:47:43+00:00" }, + { + "name": "clue/stream-filter", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/clue/php-stream-filter.git", + "reference": "5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71", + "reference": "5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^5.0 || ^4.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Clue\\StreamFilter\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@lueck.tv" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/php-stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ], + "time": "2019-04-09T12:31:48+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "ext-zlib": "*", + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2019-07-01T23:21:34+00:00" + }, + { + "name": "http-interop/http-factory-guzzle", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/http-interop/http-factory-guzzle.git", + "reference": "34861658efb9899a6618cef03de46e2a52c80fc0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/http-interop/http-factory-guzzle/zipball/34861658efb9899a6618cef03de46e2a52c80fc0", + "reference": "34861658efb9899a6618cef03de46e2a52c80fc0", + "shasum": "" + }, + "require": { + "guzzlehttp/psr7": "^1.4.2", + "psr/http-factory": "^1.0" + }, + "provide": { + "psr/http-factory-implementation": "^1.0" + }, + "require-dev": { + "http-interop/http-factory-tests": "^0.5", + "phpunit/phpunit": "^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Factory\\Guzzle\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "An HTTP Factory using Guzzle PSR7", + "keywords": [ + "factory", + "http", + "psr-17", + "psr-7" + ], + "time": "2018-07-31T19:32:56+00:00" + }, { "name": "jamesmoss/flywheel", "version": "0.5.2", @@ -117,6 +341,57 @@ ], "time": "2017-01-31T09:48:58+00:00" }, + { + "name": "jean85/pretty-package-versions", + "version": "1.2", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48", + "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48", + "shasum": "" + }, + "require": { + "ocramius/package-versions": "^1.2.0", + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Jean85\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" + } + ], + "description": "A wrapper for ocramius/package-versions to get pretty versions strings", + "keywords": [ + "composer", + "package", + "release", + "versions" + ], + "time": "2018-06-13T13:22:40+00:00" + }, { "name": "league/plates", "version": "3.3.0", @@ -217,6 +492,1095 @@ "markdown" ], "time": "2018-01-15T00:49:33+00:00" + }, + { + "name": "ocramius/package-versions", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/PackageVersions.git", + "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", + "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0.0", + "php": "^7.1.0" + }, + "require-dev": { + "composer/composer": "^1.6.3", + "doctrine/coding-standard": "^5.0.1", + "ext-zip": "*", + "infection/infection": "^0.7.1", + "phpunit/phpunit": "^7.0.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PackageVersions\\Installer", + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "PackageVersions\\": "src/PackageVersions" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "time": "2019-02-21T12:16:21+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" + }, + { + "name": "php-http/client-common", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/client-common.git", + "reference": "2b8aa3c4910afc21146a9c8f96adb266e869517a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/client-common/zipball/2b8aa3c4910afc21146a9c8f96adb266e869517a", + "reference": "2b8aa3c4910afc21146a9c8f96adb266e869517a", + "shasum": "" + }, + "require": { + "php": "^7.1", + "php-http/httplug": "^2.0", + "php-http/message": "^1.6", + "php-http/message-factory": "^1.0", + "symfony/options-resolver": " ^3.4.20 || ^4.0.15 || ^4.1.9 || ^4.2.1" + }, + "require-dev": { + "doctrine/instantiator": "^1.1", + "guzzlehttp/psr7": "^1.4", + "phpspec/phpspec": "^5.1", + "phpspec/prophecy": "^1.8", + "sebastian/comparator": "^3.0" + }, + "suggest": { + "ext-json": "To detect JSON responses with the ContentTypePlugin", + "ext-libxml": "To detect XML responses with the ContentTypePlugin", + "php-http/cache-plugin": "PSR-6 Cache plugin", + "php-http/logger-plugin": "PSR-3 Logger plugin", + "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\Common\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Common HTTP Client implementations and tools for HTTPlug", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "common", + "http", + "httplug" + ], + "time": "2019-02-03T16:49:09+00:00" + }, + { + "name": "php-http/curl-client", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/curl-client.git", + "reference": "e7a2a5ebcce1ff7d75eaf02b7c85634a6fac00da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/curl-client/zipball/e7a2a5ebcce1ff7d75eaf02b7c85634a6fac00da", + "reference": "e7a2a5ebcce1ff7d75eaf02b7c85634a6fac00da", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": "^7.1", + "php-http/discovery": "^1.6", + "php-http/httplug": "^2.0", + "php-http/message": "^1.2", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "symfony/options-resolver": "^3.4 || ^4.0" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.0", + "php-http/client-integration-tests": "^2.0", + "phpunit/phpunit": "^7.5", + "zendframework/zend-diactoros": "^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\Curl\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Михаил Красильников", + "email": "m.krasilnikov@yandex.ru" + } + ], + "description": "PSR-18 and HTTPlug Async client with cURL", + "homepage": "http://php-http.org", + "keywords": [ + "curl", + "http", + "psr-18" + ], + "time": "2019-03-05T19:59:23+00:00" + }, + { + "name": "php-http/discovery", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "e822f86a6983790aa17ab13aa7e69631e86806b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/e822f86a6983790aa17ab13aa7e69631e86806b6", + "reference": "e822f86a6983790aa17ab13aa7e69631e86806b6", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "conflict": { + "nyholm/psr7": "<1.0" + }, + "require-dev": { + "akeneo/phpspec-skip-example-extension": "^4.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1", + "puli/composer-plugin": "1.0.0-beta10" + }, + "suggest": { + "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories", + "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr7" + ], + "time": "2019-06-30T09:04:27+00:00" + }, + { + "name": "php-http/httplug", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "b3842537338c949f2469557ef4ad4bdc47b58603" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/b3842537338c949f2469557ef4ad4bdc47b58603", + "reference": "b3842537338c949f2469557ef4ad4bdc47b58603", + "shasum": "" + }, + "require": { + "php": "^7.0", + "php-http/promise": "^1.0", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "time": "2018-10-31T09:14:44+00:00" + }, + { + "name": "php-http/message", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/message.git", + "reference": "ce8f43ac1e294b54aabf5808515c3554a19c1e1c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message/zipball/ce8f43ac1e294b54aabf5808515c3554a19c1e1c", + "reference": "ce8f43ac1e294b54aabf5808515c3554a19c1e1c", + "shasum": "" + }, + "require": { + "clue/stream-filter": "^1.4", + "php": "^7.1", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, + "require-dev": { + "akeneo/phpspec-skip-example-extension": "^1.0", + "coduo/phpspec-data-provider-extension": "^1.0", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0", + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4", + "slim/slim": "^3.0", + "zendframework/zend-diactoros": "^1.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation", + "zendframework/zend-diactoros": "Used with Diactoros Factories" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + }, + "files": [ + "src/filters.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", + "keywords": [ + "http", + "message", + "psr-7" + ], + "time": "2019-08-05T06:55:08+00:00" + }, + { + "name": "php-http/message-factory", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "stream", + "uri" + ], + "time": "2015-12-19T14:08:53+00:00" + }, + { + "name": "php-http/promise", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", + "shasum": "" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + }, + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "time": "2016-01-26T13:27:02+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "496a823ef742b632934724bf769560c2a5c7c44e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/496a823ef742b632934724bf769560c2a5c7c44e", + "reference": "496a823ef742b632934724bf769560c2a5c7c44e", + "shasum": "" + }, + "require": { + "php": "^7.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "time": "2018-10-30T23:29:13+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "time": "2019-04-30T12:38:16+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "ramsey/uuid", + "version": "3.8.0", + "source": { + "type": "git", + "url": "https://github.com/ramsey/uuid.git", + "reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/d09ea80159c1929d75b3f9c60504d613aeb4a1e3", + "reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "^1.0|^2.0|9.99.99", + "php": "^5.4 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "replace": { + "rhumsaa/uuid": "self.version" + }, + "require-dev": { + "codeception/aspect-mock": "^1.0 | ~2.0.0", + "doctrine/annotations": "~1.2.0", + "goaop/framework": "1.0.0-alpha.2 | ^1.0 | ~2.1.0", + "ircmaxell/random-lib": "^1.1", + "jakub-onderka/php-parallel-lint": "^0.9.0", + "mockery/mockery": "^0.9.9", + "moontoast/math": "^1.1", + "php-mock/php-mock-phpunit": "^0.3|^1.1", + "phpunit/phpunit": "^4.7|^5.0|^6.5", + "squizlabs/php_codesniffer": "^2.3" + }, + "suggest": { + "ext-ctype": "Provides support for PHP Ctype functions", + "ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator", + "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", + "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", + "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", + "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", + "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marijn Huizendveld", + "email": "marijn.huizendveld@gmail.com" + }, + { + "name": "Thibaud Fabre", + "email": "thibaud@aztech.io" + }, + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", + "homepage": "https://github.com/ramsey/uuid", + "keywords": [ + "guid", + "identifier", + "uuid" + ], + "time": "2018-07-19T23:38:55+00:00" + }, + { + "name": "sentry/sdk", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/getsentry/sentry-php-sdk.git", + "reference": "4c115873c86ad5bd0ac6d962db70ca53bf8fb874" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/getsentry/sentry-php-sdk/zipball/4c115873c86ad5bd0ac6d962db70ca53bf8fb874", + "reference": "4c115873c86ad5bd0ac6d962db70ca53bf8fb874", + "shasum": "" + }, + "require": { + "http-interop/http-factory-guzzle": "^1.0", + "php-http/curl-client": "^1.0|^2.0", + "sentry/sentry": "^2.1.3" + }, + "type": "metapackage", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sentry", + "email": "accounts@sentry.io" + } + ], + "description": "This is a metapackage shipping sentry/sentry with a recommended http client.", + "time": "2019-09-09T19:54:44+00:00" + }, + { + "name": "sentry/sentry", + "version": "2.2.4", + "source": { + "type": "git", + "url": "https://github.com/getsentry/sentry-php.git", + "reference": "a74999536b9119257cb1a4b1aa038e4a08439f67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/a74999536b9119257cb1a4b1aa038e4a08439f67", + "reference": "a74999536b9119257cb1a4b1aa038e4a08439f67", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/promises": "^1.3", + "jean85/pretty-package-versions": "^1.2", + "php": "^7.1", + "php-http/async-client-implementation": "^1.0", + "php-http/client-common": "^1.5|^2.0", + "php-http/discovery": "^1.6.1", + "php-http/httplug": "^1.1|^2.0", + "php-http/message": "^1.5", + "psr/http-message-implementation": "^1.0", + "ramsey/uuid": "^3.3", + "symfony/options-resolver": "^2.7|^3.0|^4.0", + "zendframework/zend-diactoros": "^1.4|^2.0" + }, + "conflict": { + "php-http/client-common": "1.8.0", + "raven/raven": "*" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.13", + "monolog/monolog": "^1.3|^2.0", + "php-http/mock-client": "^1.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.11", + "phpstan/phpstan-phpunit": "^0.11", + "phpunit/phpunit": "^7.5", + "symfony/phpunit-bridge": "^4.3", + "vimeo/psalm": "^3.4" + }, + "suggest": { + "monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "2.2-dev" + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Sentry\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sentry", + "email": "accounts@sentry.io" + } + ], + "description": "A PHP SDK for Sentry (http://sentry.io)", + "homepage": "http://sentry.io", + "keywords": [ + "crash-reporting", + "crash-reports", + "error-handler", + "error-monitoring", + "log", + "logging", + "sentry" + ], + "time": "2019-11-04T10:30:51+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v4.3.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "f46c7fc8e207bd8a2188f54f8738f232533765a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/f46c7fc8e207bd8a2188f54f8738f232533765a4", + "reference": "f46c7fc8e207bd8a2188f54f8738f232533765a4", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "time": "2019-10-28T20:59:01+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.12.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "550ebaac289296ce228a706d0867afc34687e3f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", + "reference": "550ebaac289296ce228a706d0867afc34687e3f4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.12-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-08-06T08:03:45+00:00" + }, + { + "name": "zendframework/zend-diactoros", + "version": "2.1.5", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-diactoros.git", + "reference": "6dcf9e760a6b476f3e9d80abbc9ce9c4aa921f9c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/6dcf9e760a6b476f3e9d80abbc9ce9c4aa921f9c", + "reference": "6dcf9e760a6b476f3e9d80abbc9ce9c4aa921f9c", + "shasum": "" + }, + "require": { + "php": "^7.1", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "ext-curl": "*", + "ext-dom": "*", + "ext-libxml": "*", + "http-interop/http-factory-tests": "^0.5.0", + "php-http/psr7-integration-tests": "dev-master", + "phpunit/phpunit": "^7.0.2", + "zendframework/zend-coding-standard": "~1.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev", + "dev-develop": "2.2.x-dev", + "dev-release-1.8": "1.8.x-dev" + } + }, + "autoload": { + "files": [ + "src/functions/create_uploaded_file.php", + "src/functions/marshal_headers_from_sapi.php", + "src/functions/marshal_method_from_sapi.php", + "src/functions/marshal_protocol_version_from_sapi.php", + "src/functions/marshal_uri_from_sapi.php", + "src/functions/normalize_server.php", + "src/functions/normalize_uploaded_files.php", + "src/functions/parse_cookie_header.php" + ], + "psr-4": { + "Zend\\Diactoros\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "PSR HTTP Message implementations", + "keywords": [ + "http", + "psr", + "psr-7" + ], + "time": "2019-10-10T17:38:20+00:00" } ], "packages-dev": [], diff --git a/index.php b/index.php index 615769d..061509d 100644 --- a/index.php +++ b/index.php @@ -13,6 +13,7 @@ require('./vendor/autoload.php'); $app = new Wcms\Application(); $app->wakeup(); +Sentry\init(['dsn' => Wcms\Config::sentrydsn()]); try { $matchoper = new Wcms\Routes(); -- cgit v1.2.3 From a1a97e168a5d3c802f12e7351b13dab0a4f68db2 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 7 Nov 2019 01:42:54 +0100 Subject: feat: better sentry conf + send catched errors --- index.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 061509d..20a424c 100644 --- a/index.php +++ b/index.php @@ -13,13 +13,24 @@ require('./vendor/autoload.php'); $app = new Wcms\Application(); $app->wakeup(); -Sentry\init(['dsn' => Wcms\Config::sentrydsn()]); +Sentry\init([ + 'dsn' => Wcms\Config::sentrydsn(), + 'release' => 'w_cms_v' . getversion(), + 'project_root' => 'app', +]); +Sentry\configureScope(function (Sentry\State\Scope $scope): void { + $scope->setUser([ + 'id' => Wcms\Config::url(), + 'username' => Wcms\Config::basepath(), + ]); +}); try { $matchoper = new Wcms\Routes(); $matchoper->match(); } catch (Exception $e) { + Sentry\captureException($e); echo '

⚠ Woops ! There is a little problem :

', $e->getMessage(), "\n"; } -- cgit v1.2.3 From f43d03393babc939756c9f5581343913b02c7298 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 7 Nov 2019 14:02:13 +0100 Subject: build: ENV prod enhancements - fix: prod mode not working with target-specific ENV variable - use another sourcemap mode in dev mode - generate souremap files in prod mode --- .gitignore | 1 + Makefile | 20 +++++++------------- webpack.config.js | 2 +- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index fcacc73..49ce50d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .vscode/* .env *.bundle.js +*.bundle.js.map assets/render/* assets/global/* database/* diff --git a/Makefile b/Makefile index 367ef81..0753357 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ GIT_VERSION := $(shell git --no-pager describe --always --tags) js_sources := $(wildcard src/*.js) js_bundles := $(js_sources:src/%.js=assets/js/%.bundle.js) +js_srcmaps := $(js_sources:src/%.js=assets/js/%.bundle.js.map) zip_release := dist/w_cms_$(GIT_VERSION).zip all: vendor build @@ -19,9 +20,9 @@ watch: node_modules release: release-it -dist: ENV := prod -dist: distclean $(zip_release) +dist: distclean $(zip_release) $(js_srcmaps) +dist/%: ENV := prod dist/w_cms_%.zip: all @echo "Building Zip release..." mkdir -p $(dir $@) @@ -42,25 +43,17 @@ dist/w_cms_%.zip: all -x "*test*" \ -x "*docs*" -assets/js/%.bundle.js: src/%.js node_modules +assets/js/%.bundle.js assets/js/%.bundle.map: src/%.js node_modules @echo "Building JS Bundles..." mkdir -p $(dir $@) -ifeq ($(ENV),prod) - webpack $< -o $@ --env prod -p -else - webpack $< -o $@ --env dev -endif + webpack $< -o $@ $(if $(filter $(ENV),prod),--env prod -p,--env dev) .env: cp .default.env .env vendor: composer.json composer.lock @echo "Installing PHP dependencies..." -ifeq ($(ENV),prod) - composer install --no-dev --prefer-dist -else - composer install -endif + composer install $(if $(filter $(ENV),prod),--no-dev --prefer-dist,) node_modules: package.json package-lock.json @echo "Installing JS dependencies..." @@ -78,5 +71,6 @@ distclean: buildclean buildclean: @echo "Cleaning build artifacts..." rm -rf $(js_bundles) + rm -rf $(js_srcmaps) .PHONY: all build watch release dist clean distclean buildclean diff --git a/webpack.config.js b/webpack.config.js index b4a445a..1293e7e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,7 +5,7 @@ module.exports = (env) => { return { // Environment dependent mode: env == 'dev' ? 'development' : 'production', - devtool: env == 'dev' ? 'inline-source-map' : 'none', + devtool: env == 'dev' ? 'cheap-eval-source-map' : 'hidden-source-map', stats: env == 'dev' ? {} : { warnings: false }, // Constant -- cgit v1.2.3 From 14ff62ace7a8fdc21a8d2f84bd0cbd32edca24af Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 7 Nov 2019 14:05:57 +0100 Subject: build: gen VERSION from make instead of release-it - remove @release-it/bumper module - gen VERSION from make - remove VERSION from git --- .gitignore | 1 + .release-it.json | 8 -------- Makefile | 17 +++++++++++++++-- VERSION | 1 - index.php | 2 +- package-lock.json | 32 -------------------------------- package.json | 1 - 7 files changed, 17 insertions(+), 45 deletions(-) delete mode 100644 VERSION diff --git a/.gitignore b/.gitignore index 49ce50d..241abeb 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ vendor/* node_modules/ config.json error_log +VERSION !README.md diff --git a/.release-it.json b/.release-it.json index 0096671..2ac256c 100644 --- a/.release-it.json +++ b/.release-it.json @@ -9,14 +9,6 @@ "dist/*.zip" ] }, - "plugins": { - "@release-it/bumper": { - "out": { - "file": "VERSION", - "type": "text/plain" - } - } - }, "hooks": { "after:git:release": "make dist" } diff --git a/Makefile b/Makefile index 0753357..70722f4 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ include .env export PATH := vendor/bin:node_modules/.bin:$(PATH) -GIT_VERSION := $(shell git --no-pager describe --always --tags) +override GIT_VERSION := $(shell git --no-pager describe --always --tags) +override CUR_VERSION := $(strip $(shell cat VERSION)) js_sources := $(wildcard src/*.js) js_bundles := $(js_sources:src/%.js=assets/js/%.bundle.js) @@ -12,7 +13,7 @@ zip_release := dist/w_cms_$(GIT_VERSION).zip all: vendor build -build: $(js_bundles) +build: VERSION $(js_bundles) watch: node_modules webpack --env dev --watch @@ -38,6 +39,7 @@ dist/w_cms_%.zip: all "package*" \ webpack.config.js zip -r $@ \ + VERSION \ assets/js \ vendor \ -x "*test*" \ @@ -51,6 +53,14 @@ assets/js/%.bundle.js assets/js/%.bundle.map: src/%.js node_modules .env: cp .default.env .env +# use a force (fake) target to always rebuild this file but have Make +# consider this updated if it was actually rewritten (a .PHONY target +# is always considered new) +VERSION: FORCE +ifneq ($(CUR_VERSION),$(GIT_VERSION)) + @echo $(GIT_VERSION) > VERSION +endif + vendor: composer.json composer.lock @echo "Installing PHP dependencies..." composer install $(if $(filter $(ENV),prod),--no-dev --prefer-dist,) @@ -70,7 +80,10 @@ distclean: buildclean buildclean: @echo "Cleaning build artifacts..." + rm -rf VERSION rm -rf $(js_bundles) rm -rf $(js_srcmaps) +FORCE: ; + .PHONY: all build watch release dist clean distclean buildclean diff --git a/VERSION b/VERSION deleted file mode 100644 index 5849151..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.7.5 \ No newline at end of file diff --git a/index.php b/index.php index 20a424c..1c197f6 100644 --- a/index.php +++ b/index.php @@ -15,7 +15,7 @@ $app = new Wcms\Application(); $app->wakeup(); Sentry\init([ 'dsn' => Wcms\Config::sentrydsn(), - 'release' => 'w_cms_v' . getversion(), + 'release' => getversion(), 'project_root' => 'app', ]); Sentry\configureScope(function (Sentry\State\Scope $scope): void { diff --git a/package-lock.json b/package-lock.json index 7dbe19c..b1f576c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -124,20 +124,6 @@ "universal-user-agent": "^4.0.0" } }, - "@release-it/bumper": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@release-it/bumper/-/bumper-1.0.5.tgz", - "integrity": "sha512-LqfiUu5IgzdYAHH8+VwVEg30+Q7sRSD44XuwqbfVwhQJYmScO6Ik0Eet+FOAxYr4EskwK8KM4TjsdX+QurgZqA==", - "dev": true, - "requires": { - "detect-indent": "^6.0.0", - "lodash.castarray": "^4.4.0", - "lodash.get": "^4.4.2", - "lodash.set": "^4.3.2", - "mock-fs": "^4.10.1", - "release-it": "^12.4.2" - } - }, "@sindresorhus/is": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -1531,12 +1517,6 @@ "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", "dev": true }, - "detect-indent": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.0.0.tgz", - "integrity": "sha512-oSyFlqaTHCItVRGK5RmrmjB+CmaMOW7IaNA/kdxqhoa6d17j/5ce9O9eWXmV/KEdRwqpQA+Vqe8a8Bsybu4YnA==", - "dev": true - }, "detect-repo-changelog": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/detect-repo-changelog/-/detect-repo-changelog-1.0.1.tgz", @@ -3479,12 +3459,6 @@ "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, - "lodash.castarray": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz", - "integrity": "sha1-wCUTUV4wna3dTCTGDP3c9ZdtkRU=", - "dev": true - }, "lodash.find": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.find/-/lodash.find-4.6.0.tgz", @@ -3758,12 +3732,6 @@ } } }, - "mock-fs": { - "version": "4.10.2", - "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.10.2.tgz", - "integrity": "sha512-ewPQ83O4U8/Gd8I15WoB6vgTTmq5khxBskUWCRvswUqjCfOOTREmxllztQOm+PXMWUxATry+VBWXQJloAyxtbQ==", - "dev": true - }, "move-concurrently": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", diff --git a/package.json b/package.json index ad88d1d..001c71e 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "codemirror": "^5.49.0" }, "devDependencies": { - "@release-it/bumper": "^1.0.5", "css-loader": "^3.2.0", "prettier": "^1.18.2", "prettier-webpack-plugin": "^1.2.0", -- cgit v1.2.3 From 25119af7a9875275a00e32281685e17b6a9aabd1 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 7 Nov 2019 14:10:00 +0100 Subject: build: add @sentry/cli to release process --- .default.env | 7 ++++- .release-it.json | 3 +- Makefile | 13 +++++++-- package-lock.json | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 5 files changed, 102 insertions(+), 5 deletions(-) diff --git a/.default.env b/.default.env index d6692ef..16df89f 100644 --- a/.default.env +++ b/.default.env @@ -4,4 +4,9 @@ ENV=dev # GitHub token used by release-it to publish releases -GITHUB_TOKEN= \ No newline at end of file +GITHUB_TOKEN= + +# Sentry variables used to publish releases to Sentry +SENTRY_AUTH_TOKEN= +SENTRY_ORG=club1 +SENTRY_PROJECT=wcms \ No newline at end of file diff --git a/.release-it.json b/.release-it.json index 2ac256c..7ab2857 100644 --- a/.release-it.json +++ b/.release-it.json @@ -10,6 +10,7 @@ ] }, "hooks": { - "after:git:release": "make dist" + "after:git:release": "make dist", + "after:release": "make sentryrelease" } } \ No newline at end of file diff --git a/Makefile b/Makefile index 70722f4..7ca1932 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ export PATH := vendor/bin:node_modules/.bin:$(PATH) override GIT_VERSION := $(shell git --no-pager describe --always --tags) -override CUR_VERSION := $(strip $(shell cat VERSION)) +override CUR_VERSION := $(strip $(shell cat VERSION 2>/dev/null)) js_sources := $(wildcard src/*.js) js_bundles := $(js_sources:src/%.js=assets/js/%.bundle.js) @@ -18,9 +18,16 @@ build: VERSION $(js_bundles) watch: node_modules webpack --env dev --watch -release: +release: node_modules release-it +sentryrelease: ENV := prod +sentryrelease: build + sentry-cli releases new $(GIT_VERSION) + sentry-cli releases set-commits $(GIT_VERSION) --auto + sentry-cli releases files $(GIT_VERSION) upload-sourcemaps assets/js --url-prefix '~/assets/js' + sentry-cli releases finalize $(GIT_VERSION) + dist: distclean $(zip_release) $(js_srcmaps) dist/%: ENV := prod @@ -86,4 +93,4 @@ buildclean: FORCE: ; -.PHONY: all build watch release dist clean distclean buildclean +.PHONY: all build watch release sentryrelease dist clean distclean buildclean diff --git a/package-lock.json b/package-lock.json index b1f576c..b31f92e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -124,6 +124,20 @@ "universal-user-agent": "^4.0.0" } }, + "@sentry/cli": { + "version": "1.49.0", + "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-1.49.0.tgz", + "integrity": "sha512-Augz7c42Cxz/xWQ/NOVjUGePKVA370quvskWbCICMUwxcTvKnCLI+7KDdzEoCexj4MSuxFfBzLnrrn4w2+c9TQ==", + "dev": true, + "requires": { + "fs-copy-file-sync": "^1.1.1", + "https-proxy-agent": "^3.0.0", + "mkdirp": "^0.5.1", + "node-fetch": "^2.1.2", + "progress": "2.0.0", + "proxy-from-env": "^1.0.0" + } + }, "@sindresorhus/is": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -362,6 +376,15 @@ "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==", "dev": true }, + "agent-base": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", + "dev": true, + "requires": { + "es6-promisify": "^5.0.0" + } + }, "ajv": { "version": "6.10.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", @@ -1667,6 +1690,21 @@ "is-arrayish": "^0.2.1" } }, + "es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", + "dev": true + }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "dev": true, + "requires": { + "es6-promise": "^4.0.3" + } + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -2097,6 +2135,12 @@ "readable-stream": "^2.0.0" } }, + "fs-copy-file-sync": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/fs-copy-file-sync/-/fs-copy-file-sync-1.1.1.tgz", + "integrity": "sha512-2QY5eeqVv4m2PfyMiEuy9adxNP+ajf+8AR05cEi+OAzPcOj90hvFImeZhTmKLBgSd9EvG33jsD7ZRxsx9dThkQ==", + "dev": true + }, "fs-write-stream-atomic": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", @@ -2919,6 +2963,33 @@ "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, + "https-proxy-agent": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz", + "integrity": "sha512-+ML2Rbh6DAuee7d07tYGEKOEi2voWPUGan+ExdPbPW6Z3svq+JCqr0v8WmKPOkz1vOVykPCBSuobe7G8GJUtVg==", + "dev": true, + "requires": { + "agent-base": "^4.3.0", + "debug": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -4327,6 +4398,12 @@ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, + "progress": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", + "dev": true + }, "promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", @@ -4339,6 +4416,12 @@ "integrity": "sha512-Fx65lf9/YDn3hUX08XUc0J8rSux36rEsyiv21ZGUC1mOyeM3lTRpZLcrm8aAolzS4itwVfm7TAPyxC2E5zd6xg==", "dev": true }, + "proxy-from-env": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", + "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", + "dev": true + }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", diff --git a/package.json b/package.json index 001c71e..58dde93 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "codemirror": "^5.49.0" }, "devDependencies": { + "@sentry/cli": "^1.49.0", "css-loader": "^3.2.0", "prettier": "^1.18.2", "prettier-webpack-plugin": "^1.2.0", -- cgit v1.2.3 From 386b144750d99f0c67c9d370c07b1d489e9b894e Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 7 Nov 2019 17:14:17 +0100 Subject: fix(dist): correct dir permissions + VERSION always included --- Makefile | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 7ca1932..f257a04 100644 --- a/Makefile +++ b/Makefile @@ -34,23 +34,27 @@ dist/%: ENV := prod dist/w_cms_%.zip: all @echo "Building Zip release..." mkdir -p $(dir $@) - git archive --format=zip HEAD -o $@ +# Include git tracked files (everything except ignored) + needed files + zip -r $@ \ + $(shell git ls-tree -r HEAD --name-only) \ + VERSION \ + assets/js \ + vendor \ + -x "*test*" \ + -x "*docs*" +# Include non-empty git tracked directories (to keep dir permissions) + zip $@ $(shell git ls-tree -r HEAD --name-only -d) +# Remove non-useful files zip -d $@ \ - "src*" \ + $(js_sources) \ + $(js_srcmaps) \ .default.env \ .gitignore \ .release-it.json \ - composer.json \ - composer.lock \ Makefile \ + "composer*" \ "package*" \ webpack.config.js - zip -r $@ \ - VERSION \ - assets/js \ - vendor \ - -x "*test*" \ - -x "*docs*" assets/js/%.bundle.js assets/js/%.bundle.map: src/%.js node_modules @echo "Building JS Bundles..." @@ -77,17 +81,17 @@ node_modules: package.json package-lock.json npm install --loglevel=error clean: buildclean - @echo "Cleaning PHP..." + @echo "Cleaning make artifacts..." rm -rf vendor - @echo "Cleaning JS..." rm -rf node_modules + rm -rf VERSION distclean: buildclean + @echo "Cleaning dist artifacts..." rm -rf dist buildclean: @echo "Cleaning build artifacts..." - rm -rf VERSION rm -rf $(js_bundles) rm -rf $(js_srcmaps) -- cgit v1.2.3 From 6eddd69843d78bf442324dd10c501b79bbaf89d1 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 7 Nov 2019 17:58:08 +0100 Subject: feat: include sentry in frontend --- Makefile | 4 +-- app/fn/fn.php | 2 +- app/view/templates/layout.php | 7 +++++ package-lock.json | 60 +++++++++++++++++++++++++++++++++++++++++-- package.json | 1 + src/sentry.js | 10 ++++++++ webpack.config.js | 3 ++- 7 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 src/sentry.js diff --git a/Makefile b/Makefile index f257a04..4b75078 100644 --- a/Makefile +++ b/Makefile @@ -22,10 +22,10 @@ release: node_modules release-it sentryrelease: ENV := prod -sentryrelease: build +sentryrelease: buildclean build sentry-cli releases new $(GIT_VERSION) sentry-cli releases set-commits $(GIT_VERSION) --auto - sentry-cli releases files $(GIT_VERSION) upload-sourcemaps assets/js --url-prefix '~/assets/js' + sentry-cli releases files $(GIT_VERSION) upload-sourcemaps assets/js --url-prefix '~/assets/js' --rewrite sentry-cli releases finalize $(GIT_VERSION) dist: distclean $(zip_release) $(js_srcmaps) diff --git a/app/fn/fn.php b/app/fn/fn.php index f462d2d..f96b8ba 100644 --- a/app/fn/fn.php +++ b/app/fn/fn.php @@ -76,7 +76,7 @@ function idclean(string $input) function getversion() { if(file_exists('VERSION')) { - $version = file_get_contents('VERSION'); + $version = trim(file_get_contents('VERSION')); } else { $version = 'unknown'; } diff --git a/app/view/templates/layout.php b/app/view/templates/layout.php index 85351d6..c249622 100644 --- a/app/view/templates/layout.php +++ b/app/view/templates/layout.php @@ -18,6 +18,13 @@ echo ''; } ?> + + diff --git a/package-lock.json b/package-lock.json index b31f92e..5d5decf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -124,6 +124,17 @@ "universal-user-agent": "^4.0.0" } }, + "@sentry/browser": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-5.7.1.tgz", + "integrity": "sha512-K0x1XhsHS8PPdtlVOLrKZyYvi5Vexs9WApdd214bO6KaGF296gJvH1mG8XOY0+7aA5i2A7T3ttcaJNDYS49lzw==", + "requires": { + "@sentry/core": "5.7.1", + "@sentry/types": "5.7.1", + "@sentry/utils": "5.7.1", + "tslib": "^1.9.3" + } + }, "@sentry/cli": { "version": "1.49.0", "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-1.49.0.tgz", @@ -138,6 +149,52 @@ "proxy-from-env": "^1.0.0" } }, + "@sentry/core": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-5.7.1.tgz", + "integrity": "sha512-AOn3k3uVWh2VyajcHbV9Ta4ieDIeLckfo7UMLM+CTk2kt7C89SayDGayJMSsIrsZlL4qxBoLB9QY4W2FgAGJrg==", + "requires": { + "@sentry/hub": "5.7.1", + "@sentry/minimal": "5.7.1", + "@sentry/types": "5.7.1", + "@sentry/utils": "5.7.1", + "tslib": "^1.9.3" + } + }, + "@sentry/hub": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-5.7.1.tgz", + "integrity": "sha512-evGh323WR073WSBCg/RkhlUmCQyzU0xzBzCZPscvcoy5hd4SsLE6t9Zin+WACHB9JFsRQIDwNDn+D+pj3yKsig==", + "requires": { + "@sentry/types": "5.7.1", + "@sentry/utils": "5.7.1", + "tslib": "^1.9.3" + } + }, + "@sentry/minimal": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-5.7.1.tgz", + "integrity": "sha512-nS/Dg+jWAZtcxQW8wKbkkw4dYvF6uyY/vDiz/jFCaux0LX0uhgXAC9gMOJmgJ/tYBLJ64l0ca5LzpZa7BMJQ0g==", + "requires": { + "@sentry/hub": "5.7.1", + "@sentry/types": "5.7.1", + "tslib": "^1.9.3" + } + }, + "@sentry/types": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.7.1.tgz", + "integrity": "sha512-tbUnTYlSliXvnou5D4C8Zr+7/wJrHLbpYX1YkLXuIJRU0NSi81bHMroAuHWILcQKWhVjaV/HZzr7Y/hhWtbXVQ==" + }, + "@sentry/utils": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.7.1.tgz", + "integrity": "sha512-nhirUKj/qFLsR1i9kJ5BRvNyzdx/E2vorIsukuDrbo8e3iZ11JMgCOVrmC8Eq9YkHBqgwX4UnrPumjFyvGMZ2Q==", + "requires": { + "@sentry/types": "5.7.1", + "tslib": "^1.9.3" + } + }, "@sindresorhus/is": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", @@ -5532,8 +5589,7 @@ "tslib": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", - "dev": true + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" }, "tty-browserify": { "version": "0.0.0", diff --git a/package.json b/package.json index 58dde93..0e640bd 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "repository": "github:vincent-peugnet/wcms", "license": "MIT", "dependencies": { + "@sentry/browser": "^5.7.1", "codemirror": "^5.49.0" }, "devDependencies": { diff --git a/src/sentry.js b/src/sentry.js new file mode 100644 index 0000000..d30752d --- /dev/null +++ b/src/sentry.js @@ -0,0 +1,10 @@ +import * as Sentry from '@sentry/browser'; + +Sentry.init({ + dsn: sentrydsn, + release: version, +}); +Sentry.setUser({ + id: url, + username: basepath, +}); diff --git a/webpack.config.js b/webpack.config.js index 1293e7e..02d9318 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,13 +5,14 @@ module.exports = (env) => { return { // Environment dependent mode: env == 'dev' ? 'development' : 'production', - devtool: env == 'dev' ? 'cheap-eval-source-map' : 'hidden-source-map', + devtool: env == 'dev' ? 'cheap-eval-source-map' : 'source-map', stats: env == 'dev' ? {} : { warnings: false }, // Constant entry: { edit: './src/edit.js', home: './src/home.js', + sentry: './src/sentry.js', }, output: { filename: 'assets/js/[name].bundle.js', -- cgit v1.2.3 From d8032078c39edb42acb99a1de49283daba199d74 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 7 Nov 2019 19:11:04 +0100 Subject: feat: don't include Sentry in front if undefined --- app/view/templates/layout.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/view/templates/layout.php b/app/view/templates/layout.php index c249622..ef28748 100644 --- a/app/view/templates/layout.php +++ b/app/view/templates/layout.php @@ -17,6 +17,7 @@ if (!empty(Wcms\Config::interfacecss())) { echo ''; } + if (!empty(Wcms\Config::sentrydsn())) { ?> + -- cgit v1.2.3 From c0cf03fcb5aeaa4011c9b8eef4b9bc505b24485d Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 7 Nov 2019 20:37:48 +0100 Subject: perf(build): remember previous buid env This allow build the bundles when there is a change in files or in env. This way we can stop calling buildclean before each build. This is a little tricky: it uses a temp file and recursive make commands to set the ENV to prod. --- Makefile | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 4b75078..8503720 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ export PATH := vendor/bin:node_modules/.bin:$(PATH) override GIT_VERSION := $(shell git --no-pager describe --always --tags) override CUR_VERSION := $(strip $(shell cat VERSION 2>/dev/null)) +PREV_ENV_FILE := /tmp/wcms_prev_env +PREV_ENV=$(strip $(shell cat $(PREV_ENV_FILE) 2>/dev/null)) js_sources := $(wildcard src/*.js) js_bundles := $(js_sources:src/%.js=assets/js/%.bundle.js) @@ -13,7 +15,7 @@ zip_release := dist/w_cms_$(GIT_VERSION).zip all: vendor build -build: VERSION $(js_bundles) +build: VERSION $(PREV_ENV_FILE) $(js_bundles) watch: node_modules webpack --env dev --watch @@ -21,16 +23,20 @@ watch: node_modules release: node_modules release-it -sentryrelease: ENV := prod -sentryrelease: buildclean build +sentryrelease: + $(MAKE) .sentryrelease ENV=prod + +.sentryrelease: build sentry-cli releases new $(GIT_VERSION) sentry-cli releases set-commits $(GIT_VERSION) --auto sentry-cli releases files $(GIT_VERSION) upload-sourcemaps assets/js --url-prefix '~/assets/js' --rewrite sentry-cli releases finalize $(GIT_VERSION) -dist: distclean $(zip_release) $(js_srcmaps) +dist: + $(MAKE) .dist ENV=prod + +.dist: distclean $(zip_release) $(js_srcmaps) -dist/%: ENV := prod dist/w_cms_%.zip: all @echo "Building Zip release..." mkdir -p $(dir $@) @@ -56,7 +62,7 @@ dist/w_cms_%.zip: all "package*" \ webpack.config.js -assets/js/%.bundle.js assets/js/%.bundle.map: src/%.js node_modules +assets/js/%.bundle.js assets/js/%.bundle.js.map: src/%.js node_modules @echo "Building JS Bundles..." mkdir -p $(dir $@) webpack $< -o $@ $(if $(filter $(ENV),prod),--env prod -p,--env dev) @@ -67,9 +73,16 @@ assets/js/%.bundle.js assets/js/%.bundle.map: src/%.js node_modules # use a force (fake) target to always rebuild this file but have Make # consider this updated if it was actually rewritten (a .PHONY target # is always considered new) -VERSION: FORCE +VERSION: .FORCE ifneq ($(CUR_VERSION),$(GIT_VERSION)) - @echo $(GIT_VERSION) > VERSION + @echo $(GIT_VERSION) > $@ +endif + +$(PREV_ENV_FILE): .FORCE +ifneq ($(PREV_ENV),$(ENV)) + @echo Build env has changed ! + $(MAKE) buildclean + @echo $(ENV) > $@ endif vendor: composer.json composer.lock @@ -86,7 +99,7 @@ clean: buildclean rm -rf node_modules rm -rf VERSION -distclean: buildclean +distclean: @echo "Cleaning dist artifacts..." rm -rf dist @@ -95,6 +108,6 @@ buildclean: rm -rf $(js_bundles) rm -rf $(js_srcmaps) -FORCE: ; +.FORCE: ; -.PHONY: all build watch release sentryrelease dist clean distclean buildclean +.PHONY: all build watch release sentryrelease .sentryrelease dist .dist clean distclean buildclean -- cgit v1.2.3 From e4bc65433283e0725a2e7bf07ae0c84f7905af17 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 11 Nov 2019 18:50:56 +0100 Subject: feat: make Sentry optional - move sentry to PHP dev requirements. - try...catch Sentry integration in PHP. - update Makefile: - add comments as documentation. - remove recursive call from PREV_ENV_FILE target. - make dist and sentryrelease ENV variable. - add touch target for more efficient rebuilds. - add `dist` build ENV functionnality not to include dev-requirements in the zip release. --- .default.env | 2 +- .gitignore | 1 + Makefile | 116 ++++++++++++++------ composer.json | 4 +- composer.lock | 319 +++++++++++++++++++++++++++--------------------------- index.php | 30 +++-- webpack.config.js | 6 +- 7 files changed, 270 insertions(+), 208 deletions(-) diff --git a/.default.env b/.default.env index 16df89f..4f0192c 100644 --- a/.default.env +++ b/.default.env @@ -1,6 +1,6 @@ # .env -# Build environment. (prod|dev) +# Build environment. (dev|prod|dist) ENV=dev # GitHub token used by release-it to publish releases diff --git a/.gitignore b/.gitignore index 241abeb..2fc5d5d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ database/* fonts/* media/* render/ +build/ dist/ vendor/* node_modules/ diff --git a/Makefile b/Makefile index 8503720..803b57e 100644 --- a/Makefile +++ b/Makefile @@ -2,45 +2,69 @@ include .default.env include .env export +build_dir := build + +# Misc variables. PATH := vendor/bin:node_modules/.bin:$(PATH) override GIT_VERSION := $(shell git --no-pager describe --always --tags) override CUR_VERSION := $(strip $(shell cat VERSION 2>/dev/null)) -PREV_ENV_FILE := /tmp/wcms_prev_env -PREV_ENV=$(strip $(shell cat $(PREV_ENV_FILE) 2>/dev/null)) - -js_sources := $(wildcard src/*.js) -js_bundles := $(js_sources:src/%.js=assets/js/%.bundle.js) -js_srcmaps := $(js_sources:src/%.js=assets/js/%.bundle.js.map) +override WEBPACK_FLAGS += $(if $(filter $(ENV),dist),-p) +override COMPOSER_FLAGS += $(if $(filter $(ENV),dist),--no-dev --prefer-dist) +PREV_ENV_FILE := $(build_dir)/prev_env +PREV_ENV := $(strip $(shell cat $(PREV_ENV_FILE) 2>/dev/null)) + +# Files variables. +js_src_dir := src +js_sources := $(wildcard $(js_src_dir)/*.js) +js_bundles := $(js_sources:$(js_src_dir)/%.js=assets/js/%.bundle.js) +js_srcmaps := $(js_sources:$(js_src_dir)/%.js=assets/js/%.bundle.js.map) zip_release := dist/w_cms_$(GIT_VERSION).zip -all: vendor build +# Default target. This executes everything targets needed to get a fully +# working development environment. +.PHONY: all +all: $(PREV_ENV_FILE) vendor build +# Build generated files. +.PHONY: build build: VERSION $(PREV_ENV_FILE) $(js_bundles) +# Run webpack in watch mode. +.PHONY: watch watch: node_modules webpack --env dev --watch +# Create a new release and upload it on GitHub. +.PHONY: release release: node_modules release-it +# Inform Sentry of a new release. +.PHONY: sentryrelease +sentryrelease: ENV := dist sentryrelease: - $(MAKE) .sentryrelease ENV=prod + $(MAKE) .sentryrelease ENV=$(ENV) -.sentryrelease: build +.PHONY: .sentryrelease +.sentryrelease: $(PREV_ENV_FILE) build $(js_srcmaps) sentry-cli releases new $(GIT_VERSION) sentry-cli releases set-commits $(GIT_VERSION) --auto sentry-cli releases files $(GIT_VERSION) upload-sourcemaps assets/js --url-prefix '~/assets/js' --rewrite sentry-cli releases finalize $(GIT_VERSION) +# Generate the distribution files. +.PHONY: dist +dist: ENV := dist dist: - $(MAKE) .dist ENV=prod + $(MAKE) .dist ENV=$(ENV) +.PHONY: .dist .dist: distclean $(zip_release) $(js_srcmaps) dist/w_cms_%.zip: all - @echo "Building Zip release..." + @echo Building Zip release... mkdir -p $(dir $@) -# Include git tracked files (everything except ignored) + needed files +# Include git tracked files (everything except ignored) + needed files. zip -r $@ \ $(shell git ls-tree -r HEAD --name-only) \ VERSION \ @@ -48,11 +72,11 @@ dist/w_cms_%.zip: all vendor \ -x "*test*" \ -x "*docs*" -# Include non-empty git tracked directories (to keep dir permissions) +# Include non-empty git tracked directories (to keep dir permissions). zip $@ $(shell git ls-tree -r HEAD --name-only -d) -# Remove non-useful files +# Remove non-useful files. zip -d $@ \ - $(js_sources) \ + "$(js_src_dir)/*" \ $(js_srcmaps) \ .default.env \ .gitignore \ @@ -62,52 +86,74 @@ dist/w_cms_%.zip: all "package*" \ webpack.config.js -assets/js/%.bundle.js assets/js/%.bundle.js.map: src/%.js node_modules - @echo "Building JS Bundles..." +# Generate the js bundles (and sourcemaps). +assets/js/%.bundle.js assets/js/%.bundle.js.map: $(js_src_dir)/%.js node_modules + @echo Building JS Bundles... mkdir -p $(dir $@) - webpack $< -o $@ $(if $(filter $(ENV),prod),--env prod -p,--env dev) + webpack $< -o $@ --env $(ENV) $(WEBPACK_FLAGS) +# Generate a .env file if none is present. .env: - cp .default.env .env + cp .default.env $@ -# use a force (fake) target to always rebuild this file but have Make -# consider this updated if it was actually rewritten (a .PHONY target -# is always considered new) +# Generate the VERSION file. VERSION: .FORCE ifneq ($(CUR_VERSION),$(GIT_VERSION)) - @echo $(GIT_VERSION) > $@ + echo $(GIT_VERSION) > $@ endif -$(PREV_ENV_FILE): .FORCE +# Trick to force rebuild if the build environment has changed. ifneq ($(PREV_ENV),$(ENV)) +$(PREV_ENV_FILE): touch +ifdef PREV_ENV @echo Build env has changed ! - $(MAKE) buildclean - @echo $(ENV) > $@ +else + @echo New build env. +endif + mkdir -p $(dir $@) + echo $(ENV) > $@ endif +# Install PHP dependencies. vendor: composer.json composer.lock - @echo "Installing PHP dependencies..." - composer install $(if $(filter $(ENV),prod),--no-dev --prefer-dist,) + @echo Installing PHP dependencies... + composer install $(COMPOSER_FLAGS) +# Install JS dependencies. node_modules: package.json package-lock.json - @echo "Installing JS dependencies..." + @echo Installing JS dependencies... npm install --loglevel=error +# Clean files generated by `make all`. +.PHONY: clean clean: buildclean - @echo "Cleaning make artifacts..." + @echo Cleaning make artifacts... rm -rf vendor rm -rf node_modules rm -rf VERSION +# Clean files generated by `make dist`. +.PHONY: distclean distclean: - @echo "Cleaning dist artifacts..." + @echo Cleaning dist artifacts... rm -rf dist +# Clean files generated by `make build`. +.PHONY: buildclean buildclean: - @echo "Cleaning build artifacts..." + @echo Cleaning build artifacts... rm -rf $(js_bundles) rm -rf $(js_srcmaps) - + rm -rf $(build_dir) + +# Touch files affected by the build environment to force the execution +# of the corresponding targets. +.PHONY: touch +touch: + touch $(js_sources) + touch composer.json + +# Special (fake) target to always run a target but have Make consider +# this updated if it was actually rewritten (a .PHONY target is always +# considered new). .FORCE: ; - -.PHONY: all build watch release sentryrelease .sentryrelease dist .dist clean distclean buildclean diff --git a/composer.json b/composer.json index 230c14e..7b7a74a 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,9 @@ "altorouter/altorouter": "^1.2", "jamesmoss/flywheel": "^0.5.2", "league/plates": "^3.3", - "michelf/php-markdown": "^1.8", + "michelf/php-markdown": "^1.8" + }, + "require-dev": { "sentry/sdk": "^2.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index 7523bfb..032b962 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "96e0ee3f2bc01b230b311421f62799f9", + "content-hash": "e05bfe26b073b9471312ec3c4fdd83fe", "packages": [ { "name": "altorouter/altorouter", @@ -61,6 +61,165 @@ ], "time": "2015-11-30T00:47:43+00:00" }, + { + "name": "jamesmoss/flywheel", + "version": "0.5.2", + "source": { + "type": "git", + "url": "https://github.com/jamesmoss/flywheel.git", + "reference": "869eced5f6b7b11599aa96b753e3540054ca85de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jamesmoss/flywheel/zipball/869eced5f6b7b11599aa96b753e3540054ca85de", + "reference": "869eced5f6b7b11599aa96b753e3540054ca85de", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "mikey179/vfsstream": "1.2.0", + "mockery/mockery": "dev-master@dev", + "mustangostang/spyc": "0.5.*@dev", + "phpunit/phpunit": "3.7.*" + }, + "suggest": { + "mustangostang/spyc": "You must install this if you're using the YAML or Markdown formatters." + }, + "type": "library", + "autoload": { + "psr-0": { + "JamesMoss\\Flywheel\\": [ + "src/", + "test/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "James Moss", + "email": "james@moss.io", + "homepage": "http://moss.io" + } + ], + "description": "A lightweight, flat-file, document database", + "homepage": "http://github.com/jamesmoss/flywheel", + "keywords": [ + "db", + "document", + "file", + "flat" + ], + "time": "2017-01-31T09:48:58+00:00" + }, + { + "name": "league/plates", + "version": "3.3.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/plates.git", + "reference": "b1684b6f127714497a0ef927ce42c0b44b45a8af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/plates/zipball/b1684b6f127714497a0ef927ce42c0b44b45a8af", + "reference": "b1684b6f127714497a0ef927ce42c0b44b45a8af", + "shasum": "" + }, + "require": { + "php": "^5.3 | ^7.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.4", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~1.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Plates\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Reinink", + "email": "jonathan@reinink.ca", + "role": "Developer" + } + ], + "description": "Plates, the native PHP template system that's fast, easy to use and easy to extend.", + "homepage": "http://platesphp.com", + "keywords": [ + "league", + "package", + "templates", + "templating", + "views" + ], + "time": "2016-12-28T00:14:17+00:00" + }, + { + "name": "michelf/php-markdown", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/michelf/php-markdown.git", + "reference": "01ab082b355bf188d907b9929cd99b2923053495" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/michelf/php-markdown/zipball/01ab082b355bf188d907b9929cd99b2923053495", + "reference": "01ab082b355bf188d907b9929cd99b2923053495", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Michelf\\": "Michelf/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Michel Fortin", + "email": "michel.fortin@michelf.ca", + "homepage": "https://michelf.ca/", + "role": "Developer" + }, + { + "name": "John Gruber", + "homepage": "https://daringfireball.net/" + } + ], + "description": "PHP Markdown", + "homepage": "https://michelf.ca/projects/php-markdown/", + "keywords": [ + "markdown" + ], + "time": "2018-01-15T00:49:33+00:00" + } + ], + "packages-dev": [ { "name": "clue/stream-filter", "version": "v1.4.1", @@ -285,62 +444,6 @@ ], "time": "2018-07-31T19:32:56+00:00" }, - { - "name": "jamesmoss/flywheel", - "version": "0.5.2", - "source": { - "type": "git", - "url": "https://github.com/jamesmoss/flywheel.git", - "reference": "869eced5f6b7b11599aa96b753e3540054ca85de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jamesmoss/flywheel/zipball/869eced5f6b7b11599aa96b753e3540054ca85de", - "reference": "869eced5f6b7b11599aa96b753e3540054ca85de", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "require-dev": { - "mikey179/vfsstream": "1.2.0", - "mockery/mockery": "dev-master@dev", - "mustangostang/spyc": "0.5.*@dev", - "phpunit/phpunit": "3.7.*" - }, - "suggest": { - "mustangostang/spyc": "You must install this if you're using the YAML or Markdown formatters." - }, - "type": "library", - "autoload": { - "psr-0": { - "JamesMoss\\Flywheel\\": [ - "src/", - "test/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "James Moss", - "email": "james@moss.io", - "homepage": "http://moss.io" - } - ], - "description": "A lightweight, flat-file, document database", - "homepage": "http://github.com/jamesmoss/flywheel", - "keywords": [ - "db", - "document", - "file", - "flat" - ], - "time": "2017-01-31T09:48:58+00:00" - }, { "name": "jean85/pretty-package-versions", "version": "1.2", @@ -392,107 +495,6 @@ ], "time": "2018-06-13T13:22:40+00:00" }, - { - "name": "league/plates", - "version": "3.3.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/plates.git", - "reference": "b1684b6f127714497a0ef927ce42c0b44b45a8af" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/plates/zipball/b1684b6f127714497a0ef927ce42c0b44b45a8af", - "reference": "b1684b6f127714497a0ef927ce42c0b44b45a8af", - "shasum": "" - }, - "require": { - "php": "^5.3 | ^7.0" - }, - "require-dev": { - "mikey179/vfsstream": "^1.4", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~1.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Plates\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jonathan Reinink", - "email": "jonathan@reinink.ca", - "role": "Developer" - } - ], - "description": "Plates, the native PHP template system that's fast, easy to use and easy to extend.", - "homepage": "http://platesphp.com", - "keywords": [ - "league", - "package", - "templates", - "templating", - "views" - ], - "time": "2016-12-28T00:14:17+00:00" - }, - { - "name": "michelf/php-markdown", - "version": "1.8.0", - "source": { - "type": "git", - "url": "https://github.com/michelf/php-markdown.git", - "reference": "01ab082b355bf188d907b9929cd99b2923053495" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/michelf/php-markdown/zipball/01ab082b355bf188d907b9929cd99b2923053495", - "reference": "01ab082b355bf188d907b9929cd99b2923053495", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Michelf\\": "Michelf/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Michel Fortin", - "email": "michel.fortin@michelf.ca", - "homepage": "https://michelf.ca/", - "role": "Developer" - }, - { - "name": "John Gruber", - "homepage": "https://daringfireball.net/" - } - ], - "description": "PHP Markdown", - "homepage": "https://michelf.ca/projects/php-markdown/", - "keywords": [ - "markdown" - ], - "time": "2018-01-15T00:49:33+00:00" - }, { "name": "ocramius/package-versions", "version": "1.4.0", @@ -1583,7 +1585,6 @@ "time": "2019-10-10T17:38:20+00:00" } ], - "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/index.php b/index.php index 1c197f6..13f7bfa 100644 --- a/index.php +++ b/index.php @@ -13,24 +13,32 @@ require('./vendor/autoload.php'); $app = new Wcms\Application(); $app->wakeup(); -Sentry\init([ - 'dsn' => Wcms\Config::sentrydsn(), - 'release' => getversion(), - 'project_root' => 'app', -]); -Sentry\configureScope(function (Sentry\State\Scope $scope): void { - $scope->setUser([ - 'id' => Wcms\Config::url(), - 'username' => Wcms\Config::basepath(), +try { + Sentry\init([ + 'dsn' => Wcms\Config::sentrydsn(), + 'release' => getversion(), + 'project_root' => 'app', ]); -}); + Sentry\configureScope(function ($scope) { + $scope->setUser([ + 'id' => Wcms\Config::url(), + 'username' => Wcms\Config::basepath(), + ]); + }); +} catch (Throwable $th) { + // No problem: Sentry is optionnal +} try { $matchoper = new Wcms\Routes(); $matchoper->match(); } catch (Exception $e) { - Sentry\captureException($e); + try { + Sentry\captureException($e); + } catch (Throwable $th) { + // No problem: Sentry is optionnal + } echo '

⚠ Woops ! There is a little problem :

', $e->getMessage(), "\n"; } diff --git a/webpack.config.js b/webpack.config.js index 02d9318..8cd7764 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,7 +5,11 @@ module.exports = (env) => { return { // Environment dependent mode: env == 'dev' ? 'development' : 'production', - devtool: env == 'dev' ? 'cheap-eval-source-map' : 'source-map', + devtool: env == 'dev' ? + 'cheap-eval-source-map' : + env == 'dist' ? + 'hidden-source-map' : + 'source-map', stats: env == 'dev' ? {} : { warnings: false }, // Constant -- cgit v1.2.3 From c1843c0a2ef49de3d2030398f5c14549cc1791ab Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Fri, 15 Nov 2019 15:57:46 +0100 Subject: feat: load Sentry browser as an external script - better way to check if we need to report errors in PHP - fix make file $(js_bundles) dependencies (add webpack conf) - update sentry-browser sdk and move it to dev requirements --- Makefile | 2 +- app/fn/fn.php | 5 ++++ app/view/templates/layout.php | 3 ++- index.php | 9 +++---- package-lock.json | 55 ++++++++++++++++++++++++------------------- package.json | 2 +- webpack.config.js | 7 ++++-- 7 files changed, 48 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 803b57e..f4e80b4 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ dist/w_cms_%.zip: all webpack.config.js # Generate the js bundles (and sourcemaps). -assets/js/%.bundle.js assets/js/%.bundle.js.map: $(js_src_dir)/%.js node_modules +assets/js/%.bundle.js assets/js/%.bundle.js.map: $(js_src_dir)/%.js node_modules webpack.config.js @echo Building JS Bundles... mkdir -p $(dir $@) webpack $< -o $@ --env $(ENV) $(WEBPACK_FLAGS) diff --git a/app/fn/fn.php b/app/fn/fn.php index f96b8ba..ccccfb9 100644 --- a/app/fn/fn.php +++ b/app/fn/fn.php @@ -72,6 +72,11 @@ function idclean(string $input) return $input; } +function isreportingerrors() +{ + return function_exists('Sentry\init') && !empty(Wcms\Config::sentrydsn()); +} + function getversion() { diff --git a/app/view/templates/layout.php b/app/view/templates/layout.php index ef28748..9259fda 100644 --- a/app/view/templates/layout.php +++ b/app/view/templates/layout.php @@ -17,7 +17,7 @@ if (!empty(Wcms\Config::interfacecss())) { echo ''; } - if (!empty(Wcms\Config::sentrydsn())) { + if (isreportingerrors()) { ?> + diff --git a/index.php b/index.php index 13f7bfa..fd9fdaa 100644 --- a/index.php +++ b/index.php @@ -13,7 +13,8 @@ require('./vendor/autoload.php'); $app = new Wcms\Application(); $app->wakeup(); -try { + +if (isreportingerrors()) { Sentry\init([ 'dsn' => Wcms\Config::sentrydsn(), 'release' => getversion(), @@ -25,8 +26,6 @@ try { 'username' => Wcms\Config::basepath(), ]); }); -} catch (Throwable $th) { - // No problem: Sentry is optionnal } try { @@ -34,10 +33,8 @@ try { $matchoper->match(); } catch (Exception $e) { - try { + if (isreportingerrors()) { Sentry\captureException($e); - } catch (Throwable $th) { - // No problem: Sentry is optionnal } echo '

⚠ Woops ! There is a little problem :

', $e->getMessage(), "\n"; } diff --git a/package-lock.json b/package-lock.json index 5d5decf..cc91b99 100644 --- a/package-lock.json +++ b/package-lock.json @@ -125,13 +125,14 @@ } }, "@sentry/browser": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-5.7.1.tgz", - "integrity": "sha512-K0x1XhsHS8PPdtlVOLrKZyYvi5Vexs9WApdd214bO6KaGF296gJvH1mG8XOY0+7aA5i2A7T3ttcaJNDYS49lzw==", + "version": "5.9.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-5.9.0.tgz", + "integrity": "sha512-KTpmAau98QyJZtoV7LVYEFd1cdKQGk5yHlRyP3pCkhDcRbgicBNR3umdRDpsI5Ozgix3zNlyQprz0iQPmrPNRQ==", + "dev": true, "requires": { - "@sentry/core": "5.7.1", + "@sentry/core": "5.8.0", "@sentry/types": "5.7.1", - "@sentry/utils": "5.7.1", + "@sentry/utils": "5.8.0", "tslib": "^1.9.3" } }, @@ -150,33 +151,36 @@ } }, "@sentry/core": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-5.7.1.tgz", - "integrity": "sha512-AOn3k3uVWh2VyajcHbV9Ta4ieDIeLckfo7UMLM+CTk2kt7C89SayDGayJMSsIrsZlL4qxBoLB9QY4W2FgAGJrg==", + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-5.8.0.tgz", + "integrity": "sha512-aAh2KLidIXJVGrxmHSVq2eVKbu7tZiYn5ylW6yzJXFetS5z4MA+JYaSBaG2inVYDEEqqMIkb17TyWxxziUDieg==", + "dev": true, "requires": { - "@sentry/hub": "5.7.1", - "@sentry/minimal": "5.7.1", + "@sentry/hub": "5.8.0", + "@sentry/minimal": "5.8.0", "@sentry/types": "5.7.1", - "@sentry/utils": "5.7.1", + "@sentry/utils": "5.8.0", "tslib": "^1.9.3" } }, "@sentry/hub": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-5.7.1.tgz", - "integrity": "sha512-evGh323WR073WSBCg/RkhlUmCQyzU0xzBzCZPscvcoy5hd4SsLE6t9Zin+WACHB9JFsRQIDwNDn+D+pj3yKsig==", + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-5.8.0.tgz", + "integrity": "sha512-VdApn1ZCNwH1wwQwoO6pu53PM/qgHG+DQege0hbByluImpLBhAj9w50nXnF/8KzV4UoMIVbzCb6jXzMRmqqp9A==", + "dev": true, "requires": { "@sentry/types": "5.7.1", - "@sentry/utils": "5.7.1", + "@sentry/utils": "5.8.0", "tslib": "^1.9.3" } }, "@sentry/minimal": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-5.7.1.tgz", - "integrity": "sha512-nS/Dg+jWAZtcxQW8wKbkkw4dYvF6uyY/vDiz/jFCaux0LX0uhgXAC9gMOJmgJ/tYBLJ64l0ca5LzpZa7BMJQ0g==", + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-5.8.0.tgz", + "integrity": "sha512-MIlFOgd+JvAUrBBmq7vr9ovRH1HvckhnwzHdoUPpKRBN+rQgTyZy1o6+kA2fASCbrRqFCP+Zk7EHMACKg8DpIw==", + "dev": true, "requires": { - "@sentry/hub": "5.7.1", + "@sentry/hub": "5.8.0", "@sentry/types": "5.7.1", "tslib": "^1.9.3" } @@ -184,12 +188,14 @@ "@sentry/types": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.7.1.tgz", - "integrity": "sha512-tbUnTYlSliXvnou5D4C8Zr+7/wJrHLbpYX1YkLXuIJRU0NSi81bHMroAuHWILcQKWhVjaV/HZzr7Y/hhWtbXVQ==" + "integrity": "sha512-tbUnTYlSliXvnou5D4C8Zr+7/wJrHLbpYX1YkLXuIJRU0NSi81bHMroAuHWILcQKWhVjaV/HZzr7Y/hhWtbXVQ==", + "dev": true }, "@sentry/utils": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.7.1.tgz", - "integrity": "sha512-nhirUKj/qFLsR1i9kJ5BRvNyzdx/E2vorIsukuDrbo8e3iZ11JMgCOVrmC8Eq9YkHBqgwX4UnrPumjFyvGMZ2Q==", + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.8.0.tgz", + "integrity": "sha512-KDxUvBSYi0/dHMdunbxAxD3389pcQioLtcO6CI6zt/nJXeVFolix66cRraeQvqupdLhvOk/el649W4fCPayTHw==", + "dev": true, "requires": { "@sentry/types": "5.7.1", "tslib": "^1.9.3" @@ -5589,7 +5595,8 @@ "tslib": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true }, "tty-browserify": { "version": "0.0.0", diff --git a/package.json b/package.json index 0e640bd..e2c0a41 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "repository": "github:vincent-peugnet/wcms", "license": "MIT", "dependencies": { - "@sentry/browser": "^5.7.1", "codemirror": "^5.49.0" }, "devDependencies": { + "@sentry/browser": "^5.9.0", "@sentry/cli": "^1.49.0", "css-loader": "^3.2.0", "prettier": "^1.18.2", diff --git a/webpack.config.js b/webpack.config.js index 8cd7764..9c6607d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -19,8 +19,8 @@ module.exports = (env) => { sentry: './src/sentry.js', }, output: { - filename: 'assets/js/[name].bundle.js', - path: path.resolve(__dirname), + filename: '[name].bundle.js', + path: path.resolve(__dirname, 'assets', 'js'), libraryTarget: 'window' }, module: { @@ -41,5 +41,8 @@ module.exports = (env) => { singleQuote: true, }) ], + externals: { + '@sentry/browser': 'Sentry', + }, } }; -- cgit v1.2.3 From a49dca5b92c141cafd89a9908309036179973410 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Fri, 15 Nov 2019 15:59:55 +0100 Subject: fix(home): Cannot set property 'innerHTML' of null home.bundle.js was included even if the user was not connected --- app/view/templates/home.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/view/templates/home.php b/app/view/templates/home.php index 9758c95..01bc0e4 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -173,10 +173,10 @@ insert('footer', ['footer' => $footer]) ?> - + + - -- cgit v1.2.3 From 848da2065ee7e75db88e6d39f9cb8798148b0580 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Fri, 15 Nov 2019 17:20:13 +0100 Subject: docs: add infos on Sentry and build env --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 817d86a..a1464ad 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,19 @@ If you want to contribute to the project. The last two commands can be run at once using only `make`. +There are 3 different build environments that `make` can use: + +- **`dev`** _when developing the application._ + It installs every dependencies and builds big but easy-to-debug js bundles. + +- **`prod`** _when installing from sources a deployed production application._ + It installs every dependencies and builds minified js bundles. + +- **`dist`** _to create the releases' distribution zip._ + It strips all the development dependencies and the error reporting module and the sourcemaps of the js bundles are hidden. It can also be used for a production environment if the error reports are not used. + +The build environment can be set either for each `make` command by changing it in the `.env` file or on a per command basis by adding it at the end of the command (e.g. `make build ENV=prod`). + ## JS development While developing the JS sources it is useful to run webpack in watch mode so that the bundles get built at each file change. To do so, use the following command: @@ -81,11 +94,16 @@ While developing the JS sources it is useful to run webpack in watch mode so tha ## Publish a new release -The release process uses [release-it](https://github.com/release-it/release-it), so to create and publish a new release you will need a [GitHub personnal access token](https://github.com/settings/tokens) with repository access, saved in a `.env` file like so: +The release process uses [release-it](https://github.com/release-it/release-it) and uploads sourcemaps to [Sentry](https://sentry.io/). So to create and publish a new release you will need two access tokens: +- a [GitHub personnal access token](https://github.com/settings/tokens) with `repository` access +- a [Sentry authentification token](https://sentry.io/settings/account/api/auth-tokens/) with `project:read`, `project:releases` and `org:read` access + +saved in a `.env` file like so: ```bash # .env -GITHUB_TOKEN='{{github token value}}' +GITHUB_TOKEN='' +SENTRY_AUTH_TOKEN='' ``` Then, to make the release, run the following command: -- cgit v1.2.3 From 5c0035fe37cdec5f7927c3213365285a7fd4d51b Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Fri, 15 Nov 2019 19:31:20 +0100 Subject: fix: `make watch` now changes prev_env + change default env values --- .default.env | 4 ++-- Makefile | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.default.env b/.default.env index 4f0192c..33fb433 100644 --- a/.default.env +++ b/.default.env @@ -1,12 +1,12 @@ # .env # Build environment. (dev|prod|dist) -ENV=dev +ENV=prod # GitHub token used by release-it to publish releases GITHUB_TOKEN= # Sentry variables used to publish releases to Sentry SENTRY_AUTH_TOKEN= -SENTRY_ORG=club1 +SENTRY_ORG=vincent-peugnet SENTRY_PROJECT=wcms \ No newline at end of file diff --git a/Makefile b/Makefile index f4e80b4..720127e 100644 --- a/Makefile +++ b/Makefile @@ -31,8 +31,13 @@ build: VERSION $(PREV_ENV_FILE) $(js_bundles) # Run webpack in watch mode. .PHONY: watch -watch: node_modules - webpack --env dev --watch +watch: ENV := dev +watch: + $(MAKE) .watch ENV=$(ENV) + +.PHONY: .watch +.watch: $(PREV_ENV_FILE) node_modules + webpack --env $(ENV) --watch # Create a new release and upload it on GitHub. .PHONY: release -- cgit v1.2.3