forked from tuthur9A/core-talent-assessment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
talent-assessment
69 lines (63 loc) · 2.7 KB
/
talent-assessment
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
#!/usr/bin/env php
<?php
const SRC_DIR = 'app/';
const SRC_ZIP_DIR = 'app.dist.zip';
const RESULT_ZIP_DIR = 'result.zip';
if ($argv[1] === 'start') {
print_r("
__ __ _ _ _____ _ _ _ _
\ \ / /___ __ _ | | ___ | |_ |_ _|__ _ | | ___ _ __ | |_ / \ ___ ___ ___ ___ ___ _ __ ___ ___ _ __ | |___
\ \ /\ / // _ \ / _` || | / _ \ | __| | | / _` || | / _ \| \'_ \ | __| / _ \ / __|/ __| / _ \/ __|/ __|| \'_ ` _ \ / _ \| \'_ \ | __|
\ V V /| __/| (_| || || (_) || |_ | || (_| || || __/| | | || |_ / ___ \ \__ \\__ \| __/\__ \\__ \| | | | | || __/| | | || |_
\_/\_/ \___| \__, ||_| \___/ \__| |_| \__,_||_| \___||_| |_| \__| /_/ \_\|___/|___/ \___||___/|___/|_| |_| |_| \___||_| |_| \__|
|___/
\n");
exec('php composer.phar install');
$zip = new ZipArchive;
if ($zip->open(SRC_ZIP_DIR) === true) {
$zip->extractTo(SRC_DIR);
$zip->close();
exec('php composer.phar install');
$date = new \DateTime();
$date = $date->format('Y/m/d H:i:s');
exec("echo $date > info.md");
exec('git add .');
exec('git commit -m "Started talent assessment"');
exec("git push origin master");
print_r("\nGood luck!\n\n");
} else {
print_r("Error occurred, please contact us!\n");
}
}
if ($argv[1] === 'finish') {
$confirmation = trim(readline("This will submit your test results, are you sure? Type 'yes' to confirm :"));
if (trim($confirmation) === 'yes') {
// Gzip app with password
$zip = new ZipArchive;
if ($zip->open(RESULT_ZIP_DIR, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(SRC_DIR),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if (!$file->isDir()) {
$filePath = $file->getRealPath();
$zip->addFile($filePath, basename($file));
}
}
$zip->close();
exec('git add .');
exec('git commit -m "Finished talent assessment"');
exec("git push origin master");
} else {
print_r("Error occurred, please contact us!\n");
}
}
}
if ($argv[1] === 'unzip') {
$zip = new ZipArchive;
if ($zip->open(RESULT_ZIP_DIR) === true) {
$zip->extractTo(SRC_DIR);
$zip->close();
}
}