new script for updating supporting packages
This commit is contained in:
parent
907c50097d
commit
56fac545ce
|
@ -1 +1,2 @@
|
||||||
node_modules
|
node_modules
|
||||||
|
electron-src
|
||||||
|
|
|
@ -3,3 +3,7 @@
|
||||||
## Generating Fixtures
|
## Generating Fixtures
|
||||||
|
|
||||||
`node _scripts/gen-fixture.js /path/to/filename.zip`
|
`node _scripts/gen-fixture.js /path/to/filename.zip`
|
||||||
|
|
||||||
|
## Generating versions.json
|
||||||
|
|
||||||
|
`php _scripts/gen_versions.php`
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
const VERSION_EXCLUDE = ['nightly', 'beta', 'alpha'];
|
||||||
|
const SUPPORTED_MAJOR_VERSIONS = [12, 13, 14, 15, 16];
|
||||||
|
|
||||||
|
function get_versions() {
|
||||||
|
`rm -rf electron-src`;
|
||||||
|
`git clone https://github.com/electron/electron.git electron-src`;
|
||||||
|
chdir("electron-src");
|
||||||
|
|
||||||
|
$versions = [];
|
||||||
|
foreach(explode("\n", shell_exec("git tag -l")) as $version) {
|
||||||
|
foreach(VERSION_EXCLUDE as $needle) {
|
||||||
|
if (stripos($version, $needle) !== false) {
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Atom shell was renamed to electron in this release (17th April 2015)
|
||||||
|
if (version_compare($version, 'v0.24.0', '<')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$versions[] = $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir("..");
|
||||||
|
`rm -rf electron-src`;
|
||||||
|
|
||||||
|
return $versions;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_major_version($version) : int {
|
||||||
|
$r = explode('.', $version);
|
||||||
|
return intval($r[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_supported_versions($versions = []) {
|
||||||
|
$result = [];
|
||||||
|
$versions = array_map(function($v) {
|
||||||
|
return substr($v, 1);
|
||||||
|
}, $versions);
|
||||||
|
|
||||||
|
foreach(SUPPORTED_MAJOR_VERSIONS as $major) {
|
||||||
|
$result[$major] = '0.0.0';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($versions as $version) {
|
||||||
|
$major = get_major_version($version);
|
||||||
|
if (in_array($major, SUPPORTED_MAJOR_VERSIONS)) {
|
||||||
|
if (version_compare($version, $result["$major"], '>')) {
|
||||||
|
$result["$major"] = "v$version";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_values($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
function json_data() {
|
||||||
|
$versions = get_versions();
|
||||||
|
usort($versions, 'version_compare');
|
||||||
|
$supported = get_supported_versions($versions);
|
||||||
|
return [
|
||||||
|
'supported' => $supported,
|
||||||
|
'all' => $versions
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents('src/versions.json', json_encode(json_data(), JSON_PRETTY_PRINT));
|
|
@ -7,7 +7,8 @@
|
||||||
"which-electron": "src/index.js"
|
"which-electron": "src/index.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "kuta tests/*.js"
|
"test": "kuta tests/*.js",
|
||||||
|
"release": "npm update && php _scripts/gen_versions.php && git add src/versions.json package-lock.json && git commit -m 'new release' && npm version patch"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
Loading…
Reference in New Issue