FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
whatsdiff/src/Application.php at main · whatsdiff/whatsdiff · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
whatsdiff
/
whatsdiff
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
2
Star
76
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
whatsdiff
/
src
/
Application.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
130 lines (105 loc) · 4.99 KB
Breadcrumbs
whatsdiff
/
src
/
Application.php
Copy path
File metadata and controls
130 lines (105 loc) · 4.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
declare
(strict_types=
1
);
namespace
Whatsdiff
;
use
League
\
Container
\
Container
;
use
League
\
Container
\
ReflectionContainer
;
use
Psr
\
Container
\
ContainerInterface
;
use
Symfony
\
Component
\
Console
\
Application
as
BaseApplication
;
use
Whatsdiff
\
Analyzers
\
ComposerAnalyzer
;
use
Whatsdiff
\
Analyzers
\
NpmAnalyzer
;
use
Whatsdiff
\
Analyzers
\
PackageManagerType
;
use
Whatsdiff
\
Analyzers
\
PnpmAnalyzer
;
use
Whatsdiff
\
Analyzers
\
ReleaseNotes
\
Fetchers
\
GithubChangelogFetcher
;
use
Whatsdiff
\
Analyzers
\
ReleaseNotes
\
Fetchers
\
GithubReleaseFetcher
;
use
Whatsdiff
\
Analyzers
\
ReleaseNotes
\
Fetchers
\
LocalVendorChangelogFetcher
;
use
Whatsdiff
\
Analyzers
\
ReleaseNotes
\
ReleaseNotesResolver
;
use
Whatsdiff
\
Analyzers
\
SecurityAdvisories
\
Fetchers
\
GithubAdvisorySeverityFetcher
;
use
Whatsdiff
\
Analyzers
\
SecurityAdvisories
\
Fetchers
\
OsvSeverityFetcher
;
use
Whatsdiff
\
Analyzers
\
SecurityAdvisories
\
SeverityResolver
;
use
Whatsdiff
\
Commands
\
AnalyseCommand
;
use
Whatsdiff
\
Commands
\
AuditCommand
;
use
Whatsdiff
\
Commands
\
BetweenCommand
;
use
Whatsdiff
\
Commands
\
ChangelogCommand
;
use
Whatsdiff
\
Commands
\
CheckCommand
;
use
Whatsdiff
\
Commands
\
ConfigCommand
;
use
Whatsdiff
\
Commands
\
TuiCommand
;
use
Whatsdiff
\
Services
\
AgentEnvironment
;
use
Whatsdiff
\
Services
\
AnalyzerRegistry
;
class
Application
extends
BaseApplication
{
private
const
VERSION
=
'
@git_tag@
'
;
private
ContainerInterface
$
container
;
public
function
__construct
()
{
parent
::
__construct
(
'
whatsdiff
'
,
self
::
getVersionString
());
// Initialize container with autowiring and service configuration
$
this
->
container
=
self
::
instantiateContainer
();
$
this
->
addCommand
(
$
this
->
container
->
get
(AnalyseCommand::class));
$
this
->
addCommand
(
$
this
->
container
->
get
(AuditCommand::class));
$
this
->
addCommand
(
$
this
->
container
->
get
(BetweenCommand::class));
$
this
->
addCommand
(
$
this
->
container
->
get
(TuiCommand::class));
$
this
->
addCommand
(
$
this
->
container
->
get
(CheckCommand::class));
$
this
->
addCommand
(
$
this
->
container
->
get
(ConfigCommand::class));
$
this
->
addCommand
(
$
this
->
container
->
get
(ChangelogCommand::class));
$
this
->
setDefaultCommand
(
'
analyse
'
);
}
public
function
getContainer
():
ContainerInterface
{
return
$
this
->
container
;
}
/**
* Create and configure the dependency injection container.
* This method is shared between the CLI application and MCP server.
*/
public
static
function
instantiateContainer
(?
AgentEnvironment
$
agentEnvironment
=
null
):
ContainerInterface
{
$
container
=
new
Container
;
// Enable autowiring via ReflectionContainer delegate (with caching for performance)
$
container
->
delegate
(
new
ReflectionContainer
(
true
));
// Register the container itself for services that need it
$
container
->
add
(ContainerInterface::class,
$
container
);
// Register the detected agent environment so commands can adapt their defaults.
$
container
->
add
(AgentEnvironment::class,
$
agentEnvironment
?? AgentEnvironment::
detect
());
// Configure AnalyzerRegistry with package manager analyzers
// Analyzers are lazy-loaded only when needed
$
container
->
add
(AnalyzerRegistry::class,
function
()
use
(
$
container
) {
$
registry
=
new
AnalyzerRegistry
(
$
container
);
$
registry
->
register
(PackageManagerType::
COMPOSER
, ComposerAnalyzer::class);
$
registry
->
register
(PackageManagerType::
NPM
, NpmAnalyzer::class);
$
registry
->
register
(PackageManagerType::
PNPM
, PnpmAnalyzer::class);
return
$
registry
;
});
// Configure ReleaseNotesResolver with fetchers
// Order matters: try fastest/most reliable sources first
$
container
->
add
(ReleaseNotesResolver::class)
->
addMethodCall
(
'
addFetcher
'
, [LocalVendorChangelogFetcher::class])
->
addMethodCall
(
'
addFetcher
'
, [GithubReleaseFetcher::class])
->
addMethodCall
(
'
addFetcher
'
, [GithubChangelogFetcher::class]);
// Configure SeverityResolver with fetchers for cross-source severity backfill.
// GHSA first (best coverage for composer/npm CVEs), OSV as fallback.
$
container
->
add
(SeverityResolver::class)
->
addMethodCall
(
'
addFetcher
'
, [GithubAdvisorySeverityFetcher::class])
->
addMethodCall
(
'
addFetcher
'
, [OsvSeverityFetcher::class]);
return
$
container
;
}
public
function
getLongVersion
():
string
{
$
version
=
parent
::
getLongVersion
();
$
version
.=
PHP_EOL
.
PHP_EOL
;
$
version
.=
'
PHP version:
'
.
phpversion
().
PHP_EOL
;
if
(
self
::
getVersion
() !==
'
dev
'
) {
$
version
.=
'
Built with https://github.com/box-project/box
'
.
PHP_EOL
;
}
if
(
php_sapi_name
() ===
'
micro
'
) {
$
version
.=
'
Compiled with https://github.com/crazywhalecc/static-php-cli
'
.
PHP_EOL
;
}
return
$
version
;
}
public
static
function
getVersionString
():
string
{
if
(!
str_starts_with
(
self
::
VERSION
,
'
@git_tag
'
)) {
return
self
::
VERSION
;
}
return
'
dev
'
;
}
}
Back
|
FazBrowse Home
|
New Git URL