@@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
54
54
$ version = substr ($ package , 1 + strrpos ($ package , '/ ' ));
55
55
$ package = substr ($ package , 0 , -1 - \strlen ($ version ));
56
56
57
- $ this ->generatePackageJson ($ repository , $ sourceBranch , $ contrib , $ package , $ version , $ manifest , $ tree , $ outputDir );
57
+ $ this ->generatePackageJson ($ package , $ version , $ manifest , $ tree , $ outputDir );
58
58
59
59
foreach ($ manifest ['aliases ' ] ?? [] as $ alias ) {
60
60
$ aliases [$ alias ] = $ package ;
@@ -78,16 +78,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
78
78
'aliases ' => $ aliases ,
79
79
'recipes ' => $ recipes ,
80
80
'versions ' => $ contrib ? [] : HttpClient::create ()->request ('GET ' , 'https://flex.symfony.com/versions.json ' )->toArray (),
81
- 'git_url ' => sprintf ('https://github.com/%s.git ' , $ repository ),
82
- 'tree_template ' => sprintf ('https://github.com/%s/tree/{tree}/{package}/{version} ' , $ repository ),
83
- 'recipe_template ' => sprintf ('https://api.github.com/repos/%s/contents/{package_dotted}.{version}.json?ref=%s ' , $ repository , $ flexBranch ),
81
+ 'branch ' => $ sourceBranch ,
84
82
'is_contrib ' => $ contrib ,
83
+ '_links ' => [
84
+ 'repository ' => sprintf ('github.com/%s ' , $ repository ),
85
+ 'origin_template ' => sprintf ('{package}:{version}@github.com/%s:%s ' , $ repository , $ sourceBranch ),
86
+ 'recipe_template ' => sprintf ('https://api.github.com/repos/%s/contents/{package_dotted}.{version}.json?ref=%s ' , $ repository , $ flexBranch ),
87
+ ],
85
88
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ));
86
89
87
90
return 0 ;
88
91
}
89
92
90
- private function generatePackageJson (string $ repository , string $ sourceBranch , bool $ contrib , string $ package , string $ version , array $ manifest , string $ tree , string $ outputDir )
93
+ private function generatePackageJson (string $ package , string $ version , array $ manifest , string $ tree , string $ outputDir )
91
94
{
92
95
$ files = [];
93
96
$ it = new \RecursiveDirectoryIterator ($ package .'/ ' .$ version );
@@ -107,35 +110,18 @@ private function generatePackageJson(string $repository, string $sourceBranch, b
107
110
continue ;
108
111
}
109
112
$ contents = file_get_contents ($ path );
110
- $ isUtf8 = preg_match ('//u ' , $ contents );
111
113
$ files [$ file ] = [
112
- 'contents ' => $ isUtf8 ? $ contents : base64_encode ($ contents ),
114
+ 'contents ' => preg_match ( ' //u ' , $ contents ) ? explode ( "\n" , $ contents) : base64_encode ($ contents ),
113
115
'executable ' => is_executable ($ path ),
114
- 'encoding ' => $ isUtf8 ? '' : 'base64 ' ,
115
116
];
116
117
}
117
118
118
119
file_put_contents (sprintf ('%s/%s.%s.json ' , $ outputDir , str_replace ('/ ' , '. ' , $ package ), $ version ), json_encode ([
119
- 'locks ' => [
120
- $ package => [
121
- 'version ' => $ version ,
122
- 'recipe ' => [
123
- 'repo ' => $ version ,
124
- 'branch ' => $ sourceBranch ,
125
- 'version ' => $ version ,
126
- 'ref ' => $ tree ,
127
- ],
128
- ],
129
- ],
130
120
'manifests ' => [
131
121
$ package => [
132
- 'repository ' => sprintf ('github.com/%s ' , $ repository ),
133
- 'package ' => $ package ,
134
- 'version ' => $ version ,
135
122
'manifest ' => $ manifest ,
136
123
'files ' => $ files ,
137
- 'origin ' =>
sprintf (
'%s:%[email protected] /%s:%s ' ,
$ package,
$ version,
$ repository,
$ sourceBranch),
138
- 'is_contrib ' => $ contrib ,
124
+ 'ref ' => $ tree ,
139
125
],
140
126
],
141
127
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ));
0 commit comments