remove the console command

This commit is contained in:
James 2020-03-06 13:34:37 +00:00
parent 3ab51ccff9
commit 7f2b819861
5 changed files with 48 additions and 377 deletions

View File

@ -1,13 +0,0 @@
#!/usr/bin/env php
<?php
if (file_exists(__DIR__.'/../vendor/autoload.php')) {
require __DIR__.'/../vendor/autoload.php';
} else {
require __DIR__.'/../../../autoload.php';
}
$application = new JHodges\Sitemap\ConsoleApplication();
$application->run();

View File

@ -1,11 +1,10 @@
{ {
"name": "jhodges/sitemap", "name": "jhodges/sitemap",
"description": "Generate full sitemap report using spatie/crawler", "description": "Generate full sitemap report using spatie/crawler",
"type": "project", "type": "library",
"require": { "require": {
"php": "^7.1", "php": "^7.1",
"spatie/crawler": "^4.6", "spatie/crawler": "^4.6",
"symfony/console": "^4.0|^5.0",
"cweagans/composer-patches": "~1.0" "cweagans/composer-patches": "~1.0"
}, },
"require-dev": { "require-dev": {

333
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "0f0e1a413fb5eda56634b65a8abfdbf4", "content-hash": "ae8a16f174016481a2eb2bbff7a3c8be",
"packages": [ "packages": [
{ {
"name": "cweagans/composer-patches", "name": "cweagans/composer-patches",
@ -83,6 +83,9 @@
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "6.5-dev" "dev-master": "6.5-dev"
},
"patches_applied": {
"Status code must be an integer value between 1xx and 5xx": "https://patch-diff.githubusercontent.com/raw/guzzle/guzzle/pull/2591.patch"
} }
}, },
"autoload": { "autoload": {
@ -490,55 +493,6 @@
"description": "A basic but flexible php tree data structure and a fluent tree builder implementation.", "description": "A basic but flexible php tree data structure and a fluent tree builder implementation.",
"time": "2015-08-20T20:50:35+00:00" "time": "2015-08-20T20:50:35+00:00"
}, },
{
"name": "psr/container",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"time": "2017-02-14T16:28:37+00:00"
},
{ {
"name": "psr/http-message", "name": "psr/http-message",
"version": "1.0.1", "version": "1.0.1",
@ -678,16 +632,16 @@
}, },
{ {
"name": "spatie/browsershot", "name": "spatie/browsershot",
"version": "3.34.0", "version": "3.35.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/spatie/browsershot.git", "url": "https://github.com/spatie/browsershot.git",
"reference": "483f62d03ea8cfc20091b9c2db1ed3f597d659f1" "reference": "adb9e91c409462152b0baff473b2fa47cf413150"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/spatie/browsershot/zipball/483f62d03ea8cfc20091b9c2db1ed3f597d659f1", "url": "https://api.github.com/repos/spatie/browsershot/zipball/adb9e91c409462152b0baff473b2fa47cf413150",
"reference": "483f62d03ea8cfc20091b9c2db1ed3f597d659f1", "reference": "adb9e91c409462152b0baff473b2fa47cf413150",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -730,7 +684,7 @@
"screenshot", "screenshot",
"webpage" "webpage"
], ],
"time": "2020-01-04T22:37:18+00:00" "time": "2020-03-05T08:48:51+00:00"
}, },
{ {
"name": "spatie/crawler", "name": "spatie/crawler",
@ -991,94 +945,18 @@
], ],
"time": "2019-12-15T18:52:09+00:00" "time": "2019-12-15T18:52:09+00:00"
}, },
{
"name": "symfony/console",
"version": "v5.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "91c294166c38d8c0858a86fad76d8c14dc1144c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/91c294166c38d8c0858a86fad76d8c14dc1144c8",
"reference": "91c294166c38d8c0858a86fad76d8c14dc1144c8",
"shasum": ""
},
"require": {
"php": "^7.2.5",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php73": "^1.8",
"symfony/service-contracts": "^1.1|^2"
},
"conflict": {
"symfony/dependency-injection": "<4.4",
"symfony/event-dispatcher": "<4.4",
"symfony/lock": "<4.4",
"symfony/process": "<4.4"
},
"provide": {
"psr/log-implementation": "1.0"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "^4.4|^5.0",
"symfony/dependency-injection": "^4.4|^5.0",
"symfony/event-dispatcher": "^4.4|^5.0",
"symfony/lock": "^4.4|^5.0",
"symfony/process": "^4.4|^5.0",
"symfony/var-dumper": "^4.4|^5.0"
},
"suggest": {
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/lock": "",
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Console\\": ""
},
"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 Console Component",
"homepage": "https://symfony.com",
"time": "2020-01-25T15:56:29+00:00"
},
{ {
"name": "symfony/dom-crawler", "name": "symfony/dom-crawler",
"version": "v5.0.4", "version": "v5.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/dom-crawler.git", "url": "https://github.com/symfony/dom-crawler.git",
"reference": "439c3c7be4daa569deef0dd1e30cf3562108d062" "reference": "4368bdd61b83af365b8f23e9616d2a2ed52cbe7c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/439c3c7be4daa569deef0dd1e30cf3562108d062", "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/4368bdd61b83af365b8f23e9616d2a2ed52cbe7c",
"reference": "439c3c7be4daa569deef0dd1e30cf3562108d062", "reference": "4368bdd61b83af365b8f23e9616d2a2ed52cbe7c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1126,7 +1004,7 @@
], ],
"description": "Symfony DomCrawler Component", "description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2020-01-04T14:08:26+00:00" "time": "2020-02-29T10:07:09+00:00"
}, },
{ {
"name": "symfony/polyfill-ctype", "name": "symfony/polyfill-ctype",
@ -1245,76 +1123,18 @@
], ],
"time": "2020-01-13T11:15:53+00:00" "time": "2020-01-13T11:15:53+00:00"
}, },
{
"name": "symfony/polyfill-php73",
"version": "v1.14.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php73.git",
"reference": "5e66a0fa1070bf46bec4bea7962d285108edd675"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/5e66a0fa1070bf46bec4bea7962d285108edd675",
"reference": "5e66a0fa1070bf46bec4bea7962d285108edd675",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.14-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php73\\": ""
},
"files": [
"bootstrap.php"
],
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"time": "2020-01-13T11:15:53+00:00"
},
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v5.0.4", "version": "v5.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "f9ffd870f5ac01abec7b2b5e15f904ca9400ecd1" "reference": "fd4a86dd7e36437f2fc080d8c42c7415d828a0a8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/f9ffd870f5ac01abec7b2b5e15f904ca9400ecd1", "url": "https://api.github.com/repos/symfony/process/zipball/fd4a86dd7e36437f2fc080d8c42c7415d828a0a8",
"reference": "f9ffd870f5ac01abec7b2b5e15f904ca9400ecd1", "reference": "fd4a86dd7e36437f2fc080d8c42c7415d828a0a8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1350,78 +1170,20 @@
], ],
"description": "Symfony Process Component", "description": "Symfony Process Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2020-01-09T09:53:06+00:00" "time": "2020-02-08T17:00:58+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v2.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "144c5e51266b281231e947b51223ba14acf1a749"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/144c5e51266b281231e947b51223ba14acf1a749",
"reference": "144c5e51266b281231e947b51223ba14acf1a749",
"shasum": ""
},
"require": {
"php": "^7.2.5",
"psr/container": "^1.0"
},
"suggest": {
"symfony/service-implementation": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\Service\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Generic abstractions related to writing services",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"time": "2019-11-18T17:27:11+00:00"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v5.0.4", "version": "v5.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
"reference": "923591cfb78a935f0c98968fedfad05bfda9d01f" "reference": "3a37aeb1132d1035536d3d6aa9cb06c2ff9355e9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/923591cfb78a935f0c98968fedfad05bfda9d01f", "url": "https://api.github.com/repos/symfony/var-dumper/zipball/3a37aeb1132d1035536d3d6aa9cb06c2ff9355e9",
"reference": "923591cfb78a935f0c98968fedfad05bfda9d01f", "reference": "3a37aeb1132d1035536d3d6aa9cb06c2ff9355e9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1483,20 +1245,20 @@
"debug", "debug",
"dump" "dump"
], ],
"time": "2020-01-25T15:56:29+00:00" "time": "2020-02-26T22:30:10+00:00"
}, },
{ {
"name": "tightenco/collect", "name": "tightenco/collect",
"version": "v6.16.0", "version": "v6.17.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/tightenco/collect.git", "url": "https://github.com/tightenco/collect.git",
"reference": "75e997d1803c2e979ce6f314a5df8a97a8af93b0" "reference": "bc554bfb79fc02b4e6e1dd463a7fa8470119e9ab"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/tightenco/collect/zipball/75e997d1803c2e979ce6f314a5df8a97a8af93b0", "url": "https://api.github.com/repos/tightenco/collect/zipball/bc554bfb79fc02b4e6e1dd463a7fa8470119e9ab",
"reference": "75e997d1803c2e979ce6f314a5df8a97a8af93b0", "reference": "bc554bfb79fc02b4e6e1dd463a7fa8470119e9ab",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1533,7 +1295,7 @@
"collection", "collection",
"laravel" "laravel"
], ],
"time": "2020-02-18T17:25:13+00:00" "time": "2020-02-25T19:45:47+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
@ -1797,16 +1559,16 @@
}, },
{ {
"name": "phpdocumentor/reflection-docblock", "name": "phpdocumentor/reflection-docblock",
"version": "5.0.0", "version": "5.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "a48807183a4b819072f26e347bbd0b5199a9d15f" "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/a48807183a4b819072f26e347bbd0b5199a9d15f", "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e",
"reference": "a48807183a4b819072f26e347bbd0b5199a9d15f", "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1846,30 +1608,29 @@
} }
], ],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2020-02-09T09:16:15+00:00" "time": "2020-02-22T12:28:44+00:00"
}, },
{ {
"name": "phpdocumentor/type-resolver", "name": "phpdocumentor/type-resolver",
"version": "1.0.1", "version": "1.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git", "url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" "reference": "7462d5f123dfc080dfdf26897032a6513644fc95"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95",
"reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "reference": "7462d5f123dfc080dfdf26897032a6513644fc95",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1", "php": "^7.2",
"phpdocumentor/reflection-common": "^2.0" "phpdocumentor/reflection-common": "^2.0"
}, },
"require-dev": { "require-dev": {
"ext-tokenizer": "^7.1", "ext-tokenizer": "^7.2",
"mockery/mockery": "~1", "mockery/mockery": "~1"
"phpunit/phpunit": "^7.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -1893,20 +1654,20 @@
} }
], ],
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"time": "2019-08-22T18:11:29+00:00" "time": "2020-02-18T18:59:58+00:00"
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
"version": "v1.10.2", "version": "v1.10.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpspec/prophecy.git", "url": "https://github.com/phpspec/prophecy.git",
"reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9" "reference": "451c3cd1418cf640de218914901e51b064abb093"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9", "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093",
"reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9", "reference": "451c3cd1418cf640de218914901e51b064abb093",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1956,7 +1717,7 @@
"spy", "spy",
"stub" "stub"
], ],
"time": "2020-01-20T15:57:02+00:00" "time": "2020-03-05T15:02:03+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",

View File

@ -1,22 +0,0 @@
<?php
namespace JHodges\Sitemap;
use Symfony\Component\Console\Application;
class ConsoleApplication extends Application
{
public function __construct()
{
error_reporting(-1);
parent::__construct('Sitempa', '0.1.0');
$this->add(new CrawlCommand());
}
public function getLongVersion()
{
return parent::getLongVersion().' by <comment>JHodges</comment>';
}
}

View File

@ -1,54 +0,0 @@
<?php
namespace JHodges\Sitemap;
use GuzzleHttp\RequestOptions;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
class CrawlCommand extends Command
{
protected function configure()
{
$this->setName('crawl')
->setDescription('Crawl and generate sitemap for the website.')
->addArgument(
'url',
InputArgument::REQUIRED,
'The url to check'
)->addOption(
'found-on',
'f',
InputOption::VALUE_NONE,
'Display found on URLs'
);
}
/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$baseUrl = $input->getArgument('url');
$crawler=new Crawler([RequestOptions::CONNECT_TIMEOUT => 60, RequestOptions::TIMEOUT => 60]);
$crawler->crawl($baseUrl);
foreach($crawler->getResults() as $url=>$result){
$output->writeln("{$result['code']} {$url}");
if($input->getOption('found-on')){
foreach($result['foundOn'] as $url=>$count){
$output->writeln(" -> ($count) $url");
}
}
}
return 0;
}
}