FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeception.github.com/RoboFile.php at master · MercerMorning/codeception.github.com · GitHub
MercerMorning
/
codeception.github.com
Public
forked from
Codeception/codeception.github.com
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeception.github.com
/
RoboFile.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
744 lines (668 loc) · 27.4 KB
Breadcrumbs
codeception.github.com
/
RoboFile.php
Copy path
File metadata and controls
744 lines (668 loc) · 27.4 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
<?php
use
Codeception
\
Util
\
DocumentationHelpers
;
use
Symfony
\
Component
\
Finder
\
Finder
;
require
__DIR__
.
'
/vendor/autoload.php
'
;
class
RoboFile
extends
\
Robo
\Tasks
{
use
DocumentationHelpers;
const
REPO_BLOB_URL
=
'
https://github.com/Codeception/Codeception/blob
'
;
const
BRANCH_4x
=
'
4.2
'
;
const
BRANCH_5x
=
'
5.1
'
;
const
BRANCH_MAIN
=
'
main
'
;
function
post
()
{
$
title
=
$
this
->
ask
(
"
Post title
"
);
$
file
=
strtolower
(
str_replace
([
'
'
,
'
:
'
], [
'
-
'
,
'
-
'
],
$
title
));
$
date
=
date
(
'
Y-m-d
'
);
$
this
->
taskWriteToFile
(
"
_posts/
$
date
-
$
file
.markdown
"
)
->
line
(
'
---
'
)
->
line
(
'
layout: post
'
)
->
line
(
"
title:
\"
$
title
\""
)
->
line
(
"
date:
$
date
01:03:50
"
)
->
line
(
"
---
\n"
)
->
run
();
}
function
publish
()
{
$
this
->
taskGitStack
()
->
add
(
'
-A
'
)
->
commit
(
'
updated
'
)
->
pull
()
->
push
()
->
run
();
}
/**
* @desc generates modules reference from source files
*/
public
function
buildDocs
()
{
$
this
->
say
(
'
generating documentation from source files
'
);
$
this
->
taskComposerUpdate
()->
preferSource
()->
run
();
$
this
->
buildDocsModules
();
$
this
->
buildDocsUtils
();
$
this
->
buildDocsCommands
();
$
this
->
buildDocsStub
();
$
this
->
buildDocsApi
();
$
this
->
buildDocsExtensions
();
$
this
->
changelog
();
}
public
function
buildDocsModules
()
{
$
this
->
taskCleanDir
(
'
docs/modules
'
)->
run
();
$
this
->
say
(
"
Modules
"
);
$
modules
= Finder::
create
()->
files
()->
name
(
'
*.php
'
)->
in
(
__DIR__
.
'
/vendor/codeception/module-*/src/Codeception/Module
'
)->
depth
(
'
== 0
'
);
foreach
(
$
modules
as
$
module
) {
$
moduleName
=
basename
(
substr
(
$
module
,
0
, -
4
));
$
className
=
'
Codeception\Module
\\'
.
$
moduleName
;
$
classPath
=
'
Codeception/Module/
'
.
$
moduleName
;
$
repositoryName
=
basename
(
substr
(
$
module
,
0
, -
1
* (
strlen
(
$
classPath
) +
9
)));
//echo $classPath, " ", $repositoryName, "\n"; continue;
//TODO: take /src/$classPath.php directly from module
$
source
=
"
https://github.com/Codeception/
$
repositoryName
/tree/master/src/
$
classPath
.php
"
;
$
documentationFile
=
'
docs/modules/
'
.
$
moduleName
.
'
.md
'
;
$
sourceMessage
=
'
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="
'
.
$
source
.
'
">Help us to improve documentation. Edit module reference</a></div>
'
;
$
this
->
generateDocumentationForClass
(
$
className
,
$
documentationFile
,
$
sourceMessage
);
$
this
->
postProcessModuleDocFile
(
$
documentationFile
,
$
moduleName
,
$
source
);
}
//Page of old module displays content of new module
$
this
->
taskFilesystemStack
()->
symlink
(
'
Mezzio.md
'
,
'
docs/modules/ZendExpressive.md
'
)->
run
();
$
this
->
taskFilesystemStack
()->
symlink
(
'
Laravel.md
'
,
'
docs/modules/Laravel5.md
'
)->
run
();
$
this
->
taskFilesystemStack
()->
symlink
(
'
Laminas.md
'
,
'
docs/modules/ZF2.md
'
)->
run
();
// Don't update old Phalcon modules
$
this
->
taskGitStack
()
->
stopOnFail
()
->
checkout
(
'
-- docs/modules/Phalcon.md docs/modules/Phalcon4.md
'
)
->
run
();
}
private
function
postProcessModuleDocFile
(
$
documentationFile
,
$
name
,
$
source
)
{
$
contents
=
file_get_contents
(
$
documentationFile
);
$
contents
=
str_replace
(
'
##
'
,
'
###
'
,
$
contents
);
$
buttons
= [
'
source
'
=>
$
source
,
];
$
buttonHtml
=
"\n\n"
.
'
<div class="btn-group" role="group" style="float: right" aria-label="...">
'
;
$
releasesUrl
=
"
https://github.com/Codeception/module-
$
name
/releases
"
;
$
buttonHtml
.=
'
<a class="btn btn-default" href="
'
.
$
releasesUrl
.
'
">Releases</a>
'
;
foreach
(
$
buttons
as
$
link
=>
$
url
) {
if
(
$
link
==
'
source
'
) {
$
link
=
"
<strong>
$
link
</strong>
"
;
}
$
buttonHtml
.=
'
<a class="btn btn-default" href="
'
.
$
url
.
'
">
'
.
$
link
.
'
</a>
'
;
}
$
buttonHtml
.=
'
</div>
'
.
"\n\n"
;
$
contents
=
$
this
->
postProcessStandardElements
(
$
name
,
$
buttonHtml
.
$
contents
);
file_put_contents
(
$
documentationFile
,
$
contents
);
}
public
function
buildDocsUtils
()
{
$
this
->
say
(
"
Util Classes
"
);
$
utils
= [
'
Autoload
'
=>
null
,
'
Fixtures
'
=>
null
,
'
Locator
'
=>
'
lib-web
'
,
'
XmlBuilder
'
=>
'
lib-xml
'
,
'
JsonType
'
=>
'
module-rest
'
,
'
HttpCode
'
=>
'
lib-innerbrowser
'
,
];
foreach
(
$
utils
as
$
utilName
=>
$
repositoryName
) {
$
className
=
'
\Codeception\Util
\\'
.
$
utilName
;
try
{
$
documentationFile
=
'
docs/reference/
'
.
$
utilName
.
'
.md
'
;
$
this
->
documentApiClass
(
$
documentationFile
,
$
className
,
false
,
$
repositoryName
);
$
this
->
postProcessFile
(
$
utilName
,
$
documentationFile
);
}
catch
(
\
Exception
$
err
) {
}
}
}
public
function
buildDocsCommands
()
{
$
this
->
say
(
"
Commands
"
);
$
path
=
__DIR__
.
'
/vendor/codeception/codeception/src/Codeception/Command
'
;
$
commands
= Finder::
create
()->
files
()->
name
(
'
*.php
'
)->
depth
(
0
)->
in
(
$
path
);
$
documentationFile
=
'
docs/reference/Commands.md
'
;
$
commandGenerator
=
$
this
->
taskGenDoc
(
$
documentationFile
);
foreach
(
$
commands
as
$
command
) {
$
commandName
=
basename
(
substr
(
$
command
,
0
, -
4
));
$
className
=
'
\Codeception\Command
\\'
.
$
commandName
;
$
commandGenerator
->
docClass
(
$
className
);
}
$
commandGenerator
->
prepend
(
"
# Console Commands
\n"
)
->
processClassSignature
(
function
(
$
r
,
$
text
) {
return
"
##
"
.
$
r
->
getShortName
();
})
->
filterMethods
(
function
(
ReflectionMethod
$
r
) {
return
false
;
})
->
run
();
$
this
->
postProcessFile
(
'
Commands
'
,
$
documentationFile
);
}
public
function
buildDocsStub
()
{
$
this
->
say
(
"
Stub Classes
"
);
$
stubFile
=
'
docs/reference/Stub.md
'
;
$
this
->
taskGenDoc
(
$
stubFile
)
->
docClass
(
'
Codeception\Stub
'
)
->
filterMethods
(
function
(
\
ReflectionMethod
$
method
) {
if
(
$
method
->
isConstructor
()
or
$
method
->
isDestructor
()) {
return
false
;
}
if
(!
$
method
->
isPublic
()) {
return
false
;
}
if
(
strpos
(
$
method
->
name
,
'
_
'
) ===
0
) {
return
false
;
}
return
true
;
})
->
processMethodDocBlock
(
function
(
\
ReflectionMethod
$
m
,
$
doc
) {
$
doc
=
str_replace
(
array
(
'
@since
'
),
array
(
'
* available since version
'
),
$
doc
);
$
doc
=
str_replace
(
array
(
'
@
'
,
"\n
@
"
),
array
(
"
*
"
,
"\n
*
"
),
$
doc
);
return
$
doc
;
}
)
->
processProperty
(
false
)
->
run
();
$
mocksDocumentation
=
<<<EOF
# Mocks
Declare mocks inside `Codeception\Test\Unit` class.
If you want to use mocks outside it, check the reference for [Codeception/Stub](https://github.com/Codeception/Stub) library.
EOF
;
$
mockFile
=
'
docs/reference/Mock.md
'
;
$
this
->
taskGenDoc
(
$
mockFile
)
->
docClass
(
'
Codeception\Test\Feature\Stub
'
)
->
docClass
(
'
Codeception\Stub\Expected
'
)
->
processClassDocBlock
(
false
)
->
processClassSignature
(
false
)
->
prepend
(
$
mocksDocumentation
)
->
filterMethods
(
function
(
\
ReflectionMethod
$
method
) {
if
(
$
method
->
isConstructor
()
or
$
method
->
isDestructor
()) {
return
false
;
}
if
(!
$
method
->
isPublic
()) {
return
false
;
}
if
(
strpos
(
$
method
->
name
,
'
_
'
) ===
0
) {
return
false
;
}
if
(
strpos
(
$
method
->
name
,
'
stub
'
) ===
0
) {
return
false
;
}
return
true
;
})
->
run
();
$
this
->
postProcessFile
(
'
Stub
'
,
$
stubFile
);
$
this
->
postProcessFile
(
'
Mock
'
,
$
mockFile
);
}
public
function
buildDocsApi
()
{
$
this
->
say
(
"
API Classes
"
);
$
apiClasses
= [
'
\Codeception\Module
'
,
'
\Codeception\InitTemplate
'
];
foreach
(
$
apiClasses
as
$
apiClass
) {
$
name
= (
new
ReflectionClass
(
$
apiClass
))->
getShortName
();
$
documentationFile
=
'
docs/reference/
'
.
$
name
.
'
.md
'
;
$
this
->
documentApiClass
(
$
documentationFile
,
$
apiClass
,
true
);
$
this
->
postProcessFile
(
$
name
,
$
documentationFile
);
}
}
public
function
buildDocsExtensions
()
{
$
this
->
say
(
'
Extensions
'
);
$
path
=
__DIR__
.
'
/vendor/codeception/codeception/ext
'
;
$
extensions
= Finder::
create
()->
files
()->
sortByName
()->
name
(
'
*.php
'
)->
in
(
$
path
);
$
extGenerator
=
$
this
->
taskGenDoc
(
'
_includes/extensions.md
'
);
foreach
(
$
extensions
as
$
extension
) {
$
extensionName
=
basename
(
substr
(
$
extension
,
0
, -
4
));
$
className
=
'
\Codeception\Extension
\\'
.
$
extensionName
;
$
extGenerator
->
docClass
(
$
className
);
}
$
extGenerator
->
prepend
(
"
# Official Extensions
\n"
)
->
processClassSignature
(
function
(
ReflectionClass
$
r
,
$
text
) {
$
name
=
$
r
->
getShortName
();
return
"
##
$
name
\n\n
[See Source](
"
.
self
::
REPO_BLOB_URL
.
"
/
"
.
self
::
BRANCH_MAIN
.
"
/ext/
$
name
.php)
"
;
})
->
filterMethods
(
function
(
ReflectionMethod
$
r
) {
return
false
;
})
->
filterProperties
(
function
(
$
r
) {
return
false
;
})
->
run
();
}
protected
function
documentApiClass
(
$
file
,
$
className
,
$
all
=
false
,
$
repositoryName
=
null
)
{
if
(
$
repositoryName
===
null
) {
$
repositoryUrl
=
self
::
REPO_BLOB_URL
.
"
/
"
.
self
::BRANCH_5x;
}
else
{
$
repositoryUrl
=
'
https://github.com/Codeception/
'
.
$
repositoryName
.
'
/blob/master
'
;
}
$
uri
=
str_replace
(
'\\'
,
'
/
'
,
$
className
);
$
source
=
$
repositoryUrl
.
"
/src
$
uri
.php
"
;
$
this
->
taskGenDoc
(
$
file
)
->
docClass
(
$
className
)
->
filterMethods
(
function
(
ReflectionMethod
$
r
)
use
(
$
all
,
$
className
) {
return
$
all
||
$
r
->
isPublic
();
})
->
append
(
'
<p> </p><div class="alert alert-warning">Reference is taken from the source code.
'
.
'
<a href="
'
.
$
source
.
'
">Help us to improve documentation. Edit module reference</a></div>
'
)
->
processPropertySignature
(
function
(
$
r
) {
return
"\n
#### $
"
.
$
r
->
name
.
"\n\n"
;
})
->
processPropertyDocBlock
(
function
(
$
r
,
$
text
) {
$
modifiers
=
implode
(
'
'
, \Reflection::
getModifierNames
(
$
r
->
getModifiers
()));
$
text
=
'
*
'
.
$
modifiers
.
'
* **$
'
.
$
r
->
name
.
"
**
\n"
.
$
text
;
$
text
=
preg_replace
(
"
~@(.*?)\s(.*)~
"
,
'
type `$2`
'
,
$
text
);
return
$
text
;
})
->
processClassDocBlock
(
function
(
ReflectionClass
$
r
,
$
text
) {
return
$
text
.
"\n"
;
}
)
->
processMethodSignature
(
function
(
$
r
,
$
text
) {
return
"
####
{
$
r
->
name
}
()
\n\n"
.
ltrim
(
$
text
,
'
#
'
);
})
->
processMethodDocBlock
(
function
(
ReflectionMethod
$
r
,
$
text
)
use
(
$
file
,
$
source
) {
//$file = str_replace(__DIR__, '', $r->getFileName());
//$source = self::REPO_BLOB_URL."/".self::STABLE_BRANCH. $file;
$
line
=
$
r
->
getStartLine
();
$
text
=
preg_replace
(
"
~^\s?@(.*?)\s~m
"
,
'
* `$1` $2
'
,
$
text
);
$
text
.=
"\n
[See source](
$
source
#L
$
line
)
"
;
return
"\n"
.
$
text
.
"\n"
;
}
)
->
reorderMethods
(
'
ksort
'
)
->
run
();
}
public
function
changelog
() {
$
this
->
say
(
'
building changelog
'
);
$
this
->
taskWriteToFile
(
'
changelog.markdown
'
)
->
line
(
'
---
'
)
->
line
(
'
layout: page
'
)
->
line
(
'
title: Codeception Changelog
'
)
->
line
(
'
---
'
)
->
line
(
''
)
->
line
(
'
<div class="alert alert-warning">Download specific version at <a href="/builds">builds page</a></div>
'
)
->
line
(
''
)
->
line
(
'
# Changelog
'
)
->
line
(
''
)
->
line
(
$
this
->
processChangelog
())
->
run
();
}
protected
function
oldProcessChangelog
()
{
$
sortByVersionDesc
=
function
(
\
SplFileInfo
$
a
,
\
SplFileInfo
$
b
) {
$
pattern
=
'
/^CHANGELOG-(\d+\.(?:x|\d+)).md$/
'
;
if
(
preg_match
(
$
pattern
,
$
a
->
getBasename
(),
$
matches1
) &&
preg_match
(
$
pattern
,
$
b
->
getBasename
(),
$
matches2
)) {
return
version_compare
(
$
matches1
[
1
],
$
matches2
[
1
]) * -
1
;
}
return
0
;
};
$
changelogFiles
= Finder::
create
()->
name
(
'
CHANGELOG-*.md
'
)->
in
(
'
vendor/codeception/codeception
'
)->
depth
(
0
)->
sort
(
$
sortByVersionDesc
);
$
changelog
=
"\n"
;
foreach
(
$
changelogFiles
as
$
file
) {
$
changelog
.=
trim
(
$
file
->
getContents
(),
"\r\n"
) .
"\n\n"
;
}
//user
$
changelog
=
preg_replace
(
'
~\s@([\w-]+)~
'
,
'
**[$1](https://github.com/$1)**
'
,
$
changelog
);
//issue
$
changelog
=
preg_replace
(
'
~#(\d+)~
'
,
'
[#$1](https://github.com/Codeception/Codeception/issues/$1)
'
,
$
changelog
);
//module
$
changelog
=
preg_replace
(
'
~\s\[(\w+)\]\s~
'
,
'
**[$1]**
'
,
$
changelog
);
return
$
changelog
;
}
/**
* @param $name
* @param $contents
* @return mixed|string|string[]|null
*/
private
function
postProcessStandardElements
(
$
name
,
$
contents
)
{
$
highlight_languages
=
implode
(
'
|
'
, [
'
php
'
,
'
html
'
,
'
bash
'
,
'
yaml
'
,
'
json
'
,
'
xml
'
,
'
sql
'
,
'
gherkin
'
]);
$
contents
=
preg_replace
(
"
~```\s?(
$
highlight_languages
)\b(.*?)```~ms
"
,
"
{% highlight $1 %}
\n
$2
\n
{% endhighlight %}
"
,
$
contents
);
$
contents
=
str_replace
(
'
{% highlight %}
'
,
'
{% highlight yaml %}
'
,
$
contents
);
$
contents
=
preg_replace
(
"
~```\s?(.*?)```~ms
"
,
"
{% highlight yaml %}
\n
$1
\n
{% endhighlight %}
"
,
$
contents
);
// set default language in order not to leave unparsed code inside '```'
$
title
=
$
name
;
$
contents
=
"
---
\n
layout: doc
\n
title:
"
. (
$
title
!=
""
?
$
title
.
"
-
"
:
""
)
.
"
Codeception - Documentation
\n
---
\n\n"
.
$
contents
;
return
$
contents
;
}
/**
* @param $pageName
* @param $documentationFile
*/
private
function
postProcessFile
(
$
pageName
,
$
documentationFile
)
{
$
contents
=
$
this
->
postProcessStandardElements
(
$
pageName
,
file_get_contents
(
$
documentationFile
));
file_put_contents
(
$
documentationFile
,
$
contents
);
}
public
function
buildPhar80
()
{
$
version
=
self
::BRANCH_5x .
'
.
'
.
date
(
'
Ymd
'
);
$
releaseDir
=
"
releases/
$
version
"
;
$
this
->
stopOnFail
();
$
this
->
taskFilesystemStack
()->
mkdir
(
'
build/80
'
)->
run
();
$
this
->
setCodeceptionVersionTo
(
'
^
'
.
self
::BRANCH_5x);
$
this
->
setPlatformVersionTo
(
'
8.0.2
'
);
$
buildFile
=
'
build/80/codecept.phar
'
;
$
this
->
buildPhar
(
$
buildFile
);
$
this
->
updateVersionFile
(
$
buildFile
,
'
php80/codecept.version
'
);
$
versionedFile
=
"
$
releaseDir
/codecept.phar
"
;
$
this
->
taskFilesystemStack
()
->
stopOnFail
()
->
mkdir
(
$
releaseDir
)
->
copy
(
$
buildFile
,
$
versionedFile
)
->
remove
(
'
php80/codecept.phar
'
)
->
symlink
(
"
../
$
versionedFile
"
,
'
php80/codecept.phar
'
)
->
run
();
}
public
function
buildPhar72
()
{
$
version
=
self
::BRANCH_4x .
'
.
'
.
date
(
'
Ymd
'
);
$
releaseDir
=
"
releases/
$
version
"
;
$
this
->
stopOnFail
();
$
this
->
taskFilesystemStack
()->
mkdir
(
'
build/72
'
)->
run
();
$
this
->
setCodeceptionVersionTo
(
'
^4.1
'
);
$
this
->
setPlatformVersionTo
(
'
7.2.0
'
);
$
this
->
requireHoaConsole
();
$
buildFile
=
'
build/72/codecept.phar
'
;
$
this
->
buildPhar
(
$
buildFile
);
$
this
->
updateVersionFile
(
$
buildFile
,
'
codecept.version
'
);
$
versionedFile
=
"
$
releaseDir
/codecept.phar
"
;
$
this
->
taskFilesystemStack
()
->
stopOnFail
()
->
mkdir
(
$
releaseDir
)
->
copy
(
$
buildFile
,
$
versionedFile
)
->
remove
(
'
codecept.phar
'
)
->
symlink
(
$
versionedFile
,
'
codecept.phar
'
)
->
run
();
}
public
function
buildPhar56
()
{
$
version
=
self
::BRANCH_4x .
'
.
'
.
date
(
'
Ymd
'
);
$
releaseDir
=
"
releases/
$
version
"
;
$
this
->
stopOnFail
();
$
this
->
taskFilesystemStack
()->
mkdir
(
'
build/56
'
)->
run
();
$
this
->
setCodeceptionVersionTo
(
'
^4.1
'
);
$
this
->
setPlatformVersionTo
(
'
5.6.4
'
);
$
this
->
requireHoaConsole
();
//filenames must be different, because Phar refuses to build second file with the same name
$
buildFile
=
'
build/56/codecept.phar
'
;
$
this
->
buildPhar
(
$
buildFile
);
$
this
->
updateVersionFile
(
$
buildFile
,
'
php56/codecept.version
'
);
$
versionedFile
=
"
$
releaseDir
/php56/codecept.phar
"
;
$
this
->
taskFilesystemStack
()
->
stopOnFail
()
->
mkdir
(
"
$
releaseDir
/php56
"
)
->
copy
(
$
buildFile
,
$
versionedFile
)
->
remove
(
'
php56/codecept.phar
'
)
->
symlink
(
"
../
$
versionedFile
"
,
'
php56/codecept.phar
'
)
->
run
();
}
private
function
requireHoaConsole
():
void
{
$
this
->
taskComposerRequire
()
->
dependency
(
'
hoa/console
'
)
->
workingDir
(
'
package
'
)
->
run
();
}
public
function
release
()
{
$
version
=
self
::BRANCH_4x .
'
.
'
.
date
(
'
Ymd
'
);
$
releaseDir
=
"
releases/
$
version
"
;
$
this
->
updateBuildsPage
();
$
this
->
taskGitStack
()
->
stopOnFail
()
->
checkout
(
'
-- package/composer.json
'
)
->
add
(
'
builds.markdown
'
)
->
add
(
'
codecept.phar
'
)
->
add
(
'
codecept.version
'
)
->
add
(
'
php56/codecept.phar
'
)
->
add
(
'
php56/codecept.version
'
)
->
add
(
$
releaseDir
)
->
run
();
}
public
function
release80
()
{
$
version
=
self
::BRANCH_5x .
'
.
'
.
date
(
'
Ymd
'
);
$
releaseDir
=
"
releases/
$
version
"
;
$
this
->
updateBuildsPage
();
$
this
->
taskGitStack
()
->
stopOnFail
()
->
checkout
(
'
-- package/composer.json
'
)
->
add
(
'
builds.markdown
'
)
->
add
(
'
php80/codecept.phar
'
)
->
add
(
'
php80/codecept.version
'
)
->
add
(
$
releaseDir
)
->
run
();
}
private
function
setPlatformVersionTo
(
$
version
)
{
$
this
->
taskComposerConfig
()->
workingDir
(
'
package
'
)->
set
(
'
platform.php
'
,
$
version
)->
run
();
$
this
->
taskComposerUpdate
()->
preferDist
()->
optimizeAutoloader
()->
workingDir
(
'
package
'
)->
run
();
}
private
function
setCodeceptionVersionTo
(
$
version
)
{
$
this
->
taskComposerRequire
()
->
dependency
(
'
codeception/codeception
'
,
$
version
)
->
workingDir
(
'
package
'
)
->
run
();
}
/**
* @desc creates codecept.phar
* @throws Exception
*/
public
function
buildPhar
(
$
targetFile
)
{
$
this
->
packPhar
(
$
targetFile
);
$
dir
=
dirname
(
$
targetFile
);
//the file must be named codecept.phar to be executable
$
this
->
taskFilesystemStack
()->
copy
(
$
targetFile
,
$
dir
.
'
/codecept.phar
'
)->
run
();
$
code
=
$
this
->
taskExec
(
'
php codecept.phar
'
)->
dir
(
$
dir
)->
run
()->
getExitCode
();
if
(
$
code
!==
0
) {
throw
new
Exception
(
"
There was problem compiling phar
"
);
}
}
private
function
packPhar
(
$
pharFileName
)
{
$
pharTask
=
$
this
->
taskPackPhar
(
$
pharFileName
)
->
compress
()
->
stub
(
'
package/stub.php
'
);
$
finder
= Finder::
create
()->
files
()
->
ignoreVCS
(
true
)
->
name
(
'
*.php
'
)
->
name
(
'
*.php8
'
)
->
name
(
'
*.css
'
)
->
name
(
'
*.png
'
)
->
name
(
'
*.js
'
)
->
name
(
'
*.css
'
)
->
name
(
'
*.eot
'
)
->
name
(
'
*.svg
'
)
->
name
(
'
*.ttf
'
)
->
name
(
'
*.wof
'
)
->
name
(
'
*.woff
'
)
->
name
(
'
*.woff2
'
)
->
name
(
'
*.png
'
)
->
name
(
'
*.tpl
'
)
->
name
(
'
*.tpl.dist
'
)
->
name
(
'
*.html.dist
'
)
->
exclude
(
'
Tests
'
)
->
exclude
(
'
tests
'
)
->
exclude
(
'
benchmark
'
)
->
exclude
(
'
demo
'
)
->
in
(
'
package/vendor
'
);
foreach
(
$
finder
as
$
file
) {
$
relativePathname
=
$
file
->
getRelativePathname
();
if
(
strpos
(
$
relativePathname
,
'
codeception/
'
) ===
0
) {
//don't remove whitespace from Codeception files
$
pharTask
->
addFile
(
'
vendor/
'
.
$
relativePathname
,
$
file
->
getRealPath
());
}
else
{
$
pharTask
->
addStripped
(
'
vendor/
'
.
$
relativePathname
,
$
file
->
getRealPath
());
}
}
$
pharTask
->
run
();
}
public
function
processChangelog
()
{
$
client
=
new
\
Github
\
Client
();
$
token
=
getenv
(
'
GH_PAT
'
);
if
(
$
token
) {
$
client
->
authenticate
(
getenv
(
'
GH_PAT
'
),
null
, \
Github
\Client::
AUTH_ACCESS_TOKEN
);
}
$
allReleases
= [];
$
repositories
=
$
client
->
repos
()->
org
(
'
Codeception
'
, [
'
per_page
'
=>
100
]);
foreach
(
$
repositories
as
$
repository
) {
$
repositoryName
=
$
repository
[
'
name
'
];
if
(
$
repositoryName
!==
'
Codeception
'
&& !
str_starts_with
(
$
repositoryName
,
'
module-
'
) && !
str_starts_with
(
$
repositoryName
,
'
lib-
'
)) {
continue
;
}
$
this
->
say
(
$
repositoryName
);
if
(
$
repository
[
'
disabled
'
] ||
$
repository
[
'
archived
'
]) {
continue
;
}
try
{
$
releases
=
$
client
->
repo
()->
releases
()->
all
(
'
codeception
'
,
$
repositoryName
);
foreach
(
$
releases
as
$
k
=>
$
release
) {
$
releases
[
$
k
][
'
repo
'
] =
$
repositoryName
;
}
$
allReleases
=
array_merge
(
$
allReleases
,
$
releases
);
}
catch
(
\
Exception
$
err
) {
// $this->say("Repository not available " . $repository['name']);
// $this->say($err->getMessage());
}
}
usort
(
$
allReleases
,
function
(
$
r1
,
$
r2
) {
return
-(
strtotime
(
$
r1
[
'
published_at
'
]) <=>
strtotime
(
$
r2
[
'
published_at
'
]));
});
$
changelog
=
""
;
foreach
(
$
allReleases
as
$
release
) {
$
repo
=
$
release
[
'
repo
'
] ??
'
Codeception
'
;
$
changelog
.=
sprintf
(
"\n\n
### %s %s: %s
\n\n"
,
$
repo
,
$
release
[
'
tag_name
'
],
$
release
[
'
name
'
]);
$
changelog
.=
sprintf
(
"
Released by [ %s](%s) on %s
"
,
$
release
[
'
author
'
][
'
avatar_url
'
] .
'
&s=16
'
,
$
release
[
'
author
'
][
'
login
'
],
$
release
[
'
author
'
][
'
html_url
'
],
date_format
(
date_create
(
$
release
[
'
published_at
'
]),
"
Y/m/d H:i:s
"
)
);
$
changelog
.=
"
/ [Repository](https://github.com/Codeception/
$
repo
)
"
;
$
changelog
.=
"
/ [Releases](https://github.com/Codeception/
$
repo
/releases)
\n\n"
;
$
body
=
$
release
[
'
body
'
];
//user
$
body
=
preg_replace
(
'
~\s@([\w-]+)~
'
,
'
**[$1](https://github.com/$1)**
'
,
$
body
);
//issue
$
body
=
preg_replace
(
'
~#(\d+)~
'
,
"
[#$1](https://github.com/Codeception/
$
repo
/issues/$1)
"
,
$
body
);
$
changelog
.=
"\n\n
$
body
\n"
;
}
return
$
changelog
;
}
public
function
updateBuildsPage
()
{
$
sortByVersion
=
function
(
\
SplFileInfo
$
a
,
\
SplFileInfo
$
b
) {
return
version_compare
(
$
a
->
getBaseName
(),
$
b
->
getBaseName
());
};
$
releases
=
array_reverse
(
iterator_to_array
(Finder::
create
()->
depth
(
0
)->
directories
()->
sort
(
$
sortByVersion
)->
in
(
'
releases
'
))
);
$
branch
=
null
;
$
releaseFile
=
$
this
->
taskWriteToFile
(
'
builds.markdown
'
)
->
line
(
'
---
'
)
->
line
(
'
layout: page
'
)
->
line
(
'
title: Codeception Builds
'
)
->
line
(
'
---
'
)
->
line
(
''
);
foreach
(
$
releases
as
$
release
) {
$
releaseName
=
$
release
->
getBasename
();
$
downloadUrl
=
"
https://codeception.com/releases/
$
releaseName
/codecept.phar
"
;
list
(
$
major
,
$
minor
) =
explode
(
'
.
'
,
$
releaseName
);
if
(
"
$
major
.
$
minor
"
!=
$
branch
) {
$
branch
=
"
$
major
.
$
minor
"
;
$
releaseFile
->
line
(
"\n
##
$
branch
"
);
if
(
$
major
<
2
) {
$
releaseFile
->
line
(
"
*Requires: PHP 5.3 and higher + CURL*
\n"
);
}
elseif
(
$
major
==
2
&&
$
minor
<
4
) {
$
releaseFile
->
line
(
"
*Requires: PHP 5.4 and higher + CURL*
\n"
);
}
elseif
(
$
major
<
5
) {
$
releaseFile
->
line
(
"
*Requires: PHP 5.6 and higher + CURL*
\n"
);
}
else
{
$
releaseFile
->
line
(
"
*Requires: PHP 8.0 and higher + CURL*
\n"
);
}
$
releaseFile
->
line
(
"
* **[Download Latest
$
branch
Release](
$
downloadUrl
)**
"
);
}
if
(
file_exists
(
"
releases/
$
releaseName
/php54/codecept.phar
"
)) {
$
downloadUrl2
=
"
https://codeception.com/releases/
$
releaseName
/php54/codecept.phar
"
;
if
(
version_compare
(
$
releaseName
,
'
2.4.0
'
,
'
>=
'
)) {
$
versionLine
=
"
* [
$
releaseName
for PHP 7](
$
downloadUrl
)
"
;
$
versionLine
.=
"
, [for PHP 5.6](
$
downloadUrl2
)
"
;
}
elseif
(
version_compare
(
$
releaseName
,
'
2.3.0
'
,
'
>=
'
)) {
$
versionLine
=
"
* [
$
releaseName
for PHP 7](
$
downloadUrl
)
"
;
$
versionLine
.=
"
, [for PHP 5.4 - 5.6](
$
downloadUrl2
)
"
;
}
else
{
$
versionLine
=
"
* [
$
releaseName
for PHP 5.6+](
$
downloadUrl
)
"
;
$
versionLine
.=
"
, [for PHP 5.4 or 5.5](
$
downloadUrl2
)
"
;
}
}
elseif
(
file_exists
(
"
releases/
$
releaseName
/php56/codecept.phar
"
)) {
$
versionLine
=
"
* [
$
releaseName
for PHP 7.2+](
$
downloadUrl
)
"
;
$
downloadUrl2
=
"
https://codeception.com/releases/
$
releaseName
/php56/codecept.phar
"
;
$
versionLine
.=
"
, [for PHP 5.6 - 7.1](
$
downloadUrl2
)
"
;
}
else
{
$
versionLine
=
"
* [
$
releaseName
](
$
downloadUrl
)
"
;
}
$
releaseFile
->
line
(
$
versionLine
);
}
$
releaseFile
->
run
();
}
/**
* @param $pharFile
* @param $versionFile
*/
private
function
updateVersionFile
(
$
pharFile
,
$
versionFile
)
{
$
hash
=
sha1_file
(
$
pharFile
);
if
(
$
hash
===
false
) {
throw
new
Exception
(
'
Failed to write hash to file:
'
.
$
versionFile
);
}
$
this
->
taskWriteToFile
(
$
versionFile
)->
text
(
$
hash
)->
run
();
}
}
Back
|
FazBrowse Home
|
New Git URL