forked from frictionlessdata/tableschema-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-schema.php
25 lines (22 loc) · 888 Bytes
/
update-schema.php
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
<?php
function update()
{
$schemaUrl = 'http://specs.frictionlessdata.io/schemas/table-schema.json';
$base_filename = realpath(dirname(__FILE__))
.DIRECTORY_SEPARATOR.'src'
.DIRECTORY_SEPARATOR.'schemas'
.DIRECTORY_SEPARATOR;
$filename = $base_filename.'table-schema.json';
$old_schema = file_exists($filename) ? file_get_contents($filename) : 'FORCE UPDATE';
echo "downloading schema from {$schemaUrl}\n";
$new_schema = file_get_contents($schemaUrl);
if ($old_schema == $new_schema) {
echo "no update needed\n";
} else {
echo "schema changed - updating local file\n";
file_put_contents($filename, $new_schema);
file_put_contents($base_filename.'CHANGELOG', "\n\n".date('c')."\n* check the git diff and summarize the spec changes here\n* \n\n", FILE_APPEND);
}
return 0;
}
exit(update());