6.7.0 - Alpha6 - Scrapers 工具的更新机制由 "锚点更新" 替换为 "结构化更新"
This commit is contained in:
@@ -1,39 +1,36 @@
|
||||
// scrape-android-studio-agp_version_maps.mjs
|
||||
// scrape-and-inject-android-studio-agp-version-map.mjs
|
||||
|
||||
import { compareVersionStrings } from './utils/versioning.mjs';
|
||||
import { fetchStudioAgpTable } from './fetch-and-parse-android-studio-agp-compatibility-table.mjs';
|
||||
import { readPropertiesSync } from './utils/properties.mjs';
|
||||
import { updateAnchoredMapInFile } from './utils/anchors.mjs';
|
||||
import { updateGradleMapData } from './utils/update-helper.mjs';
|
||||
|
||||
const props = readPropertiesSync();
|
||||
|
||||
const version = {
|
||||
MIN_IDE: props['MIN_SUPPORTED_ANDROID_STUDIO_IDE_VERSION'],
|
||||
MIN_AGP: props['MIN_SUPPORTED_ANDROID_STUDIO_AGP_VERSION'],
|
||||
MIN_IDE: props.get('MIN_SUPPORTED_ANDROID_STUDIO_IDE_VERSION'),
|
||||
MIN_AGP: props.get('MIN_SUPPORTED_ANDROID_STUDIO_AGP_VERSION'),
|
||||
};
|
||||
|
||||
(async function main() {
|
||||
const agpTable = await fetchStudioAgpTable();
|
||||
/** @type {{ [targetStudioVersion: string]: string }} */
|
||||
const agpMap = {};
|
||||
const map = new Map();
|
||||
|
||||
for (const { studioVersion, agpRange } of agpTable) {
|
||||
const targetStudioVersion = studioVersion.match(/\d{2,}\.\d+\.\d+/)?.[0];
|
||||
if (!targetStudioVersion) continue;
|
||||
|
||||
const [ _, targetAgpVersion ] = agpRange.split('-');
|
||||
if (!(targetStudioVersion in agpMap) || compareVersionStrings(agpMap[targetStudioVersion], targetAgpVersion) > 0) {
|
||||
agpMap[targetStudioVersion] = targetAgpVersion;
|
||||
if (!map.has(targetStudioVersion) || compareVersionStrings(map.get(targetStudioVersion), targetAgpVersion) > 0) {
|
||||
map.set(targetStudioVersion, targetAgpVersion);
|
||||
}
|
||||
if (compareVersionStrings(targetStudioVersion, version.MIN_IDE) <= 0) break;
|
||||
if (compareVersionStrings(targetAgpVersion, version.MIN_AGP) <= 0) break;
|
||||
}
|
||||
|
||||
await updateAnchoredMapInFile('../settings.gradle.kts', {
|
||||
anchorTag: 'ANDROID_STUDIO_AGP_VERSION_MAP',
|
||||
mapName: 'agpVersionMap',
|
||||
lines: Object.entries(agpMap).map(([ studioVer, agpVer ]) => `"${studioVer}" to "${agpVer}",`),
|
||||
updatedLabel: 'AGP version map',
|
||||
await updateGradleMapData('android-studio-agp-compat', map, {
|
||||
label: 'Android Studio and AGP compatibility map',
|
||||
sort: 'key.descending.as.version',
|
||||
});
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
|
||||
Reference in New Issue
Block a user