-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoboFile.php
More file actions
76 lines (63 loc) · 2.59 KB
/
RoboFile.php
File metadata and controls
76 lines (63 loc) · 2.59 KB
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
<?php
use Symfony\Component\Finder\Finder;
/**
* This is project's console commands configuration for Robo task runner.
*
* @see https://robo.li/
*/
class RoboFile extends \Robo\Tasks {
public function test() {
$workspace_dir = 'tests/integration/workspace';
$composer_json = 'tests/integration/composer.site.json';
$collection = $this->collectionBuilder();
// 1. Clean workspace directory
$collection->taskFilesystemStack()
->remove($workspace_dir . '/.gitignore')
->run();
$collection->taskCleanDir([$workspace_dir])->run();
// 2. Install base SimpleID
$collection->taskComposerCreateProject()
->source('simpleid/simpleid:dev-master')
->target($workspace_dir)
->noDev()
->run();
// 3. Update composer.json to add local repository
$collection->taskFilesystemStack()
->copy($composer_json, $workspace_dir . '/composer.site.json')
->run();
// 4. Update minimum-stability in root composer.json
$collection->addCode(function() use ($workspace_dir) {
$root_composer_json = $workspace_dir . '/composer.json';
$root_composer = json_decode(file_get_contents($root_composer_json), true);
$root_composer['minimum-stability'] = 'dev';
$root_composer['prefer-stable'] = true;
file_put_contents($root_composer_json, json_encode($root_composer));
});
// 5. Try installing the test module
$collection->taskComposerUpdate()
->workingDir($workspace_dir)
->noDev()
->run();
// 6. See if module exists in the right location
$collection->addCode(function() use ($workspace_dir) {
$expected_file = $workspace_dir . '/www/site/test/src/TestModule/TestModule.php';
if (!file_exists($expected_file)) return 1;
});
return $collection->run();
}
public function update_copyright() {
$current_year = strftime("%Y");
$finder = new Finder();
$finder->in(['src'])->name('*.php');
foreach($finder as $file) {
$this->taskReplaceInFile($file)
->regex('/Copyright \(C\) Kelvin Mo (\d{4})-(\d{4})(\R)/m')
->to('Copyright (C) Kelvin Mo $1-'. $current_year . '$3')
->run();
$this->taskReplaceInFile($file)
->regex('/Copyright \(C\) Kelvin Mo (\d{4})(\R)/m')
->to('Copyright (C) Kelvin Mo $1-'. $current_year . '$2')
->run();
}
}
}