Files
ant-design__ant-design-cli/scripts/check-sync-needed.ts
afc163 6b3418edcc fix: sync workflow never detects new antd versions (#83)
* fix: sync workflow never detects new antd versions

The check-version step compared local data/v6.json against
@ant-design/cli on npm — which is always true since CLI publishes
at the synced version, causing the workflow to skip every run.

Replace with a script that compares the antd npm latest version
against local data, and also covers the recovery scenario where
data was pushed but npm publish failed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: sync workflow never detects new antd versions

The check-version step compared local data/v6.json against
@ant-design/cli on npm — which is always true since CLI publishes
at the synced version, causing the workflow to skip every run.

Replace with a script that compares the antd npm latest version
against local data, and also covers the recovery scenario where
data was pushed but npm publish failed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-17 18:51:15 +08:00

41 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
/**
* Check whether sync.yml needs to run.
*
* Outputs (via GITHUB_OUTPUT):
* needs_sync — antd has a new version not in local data
* needs_publish — CLI for the synced version hasn't been published yet (recovery scenario)
*/
import { execSync } from 'node:child_process';
import fs from 'node:fs';
const latestAntd = execSync('npm view antd version', { encoding: 'utf8' }).trim();
const syncedVersion: string = JSON.parse(fs.readFileSync('data/v6.json', 'utf8')).version;
console.log(`Latest antd on npm: ${latestAntd}`);
console.log(`Local synced version: ${syncedVersion}`);
const needsSync = latestAntd !== syncedVersion;
const alreadyPublished = !needsSync && (() => {
try {
execSync(`npm view "@ant-design/cli@${syncedVersion}" version`, { stdio: 'pipe' });
return true;
} catch {
return false;
}
})();
const needsPublish = needsSync || !alreadyPublished;
const outputFile = process.env.GITHUB_OUTPUT;
if (outputFile) {
fs.appendFileSync(outputFile, `needs_sync=${needsSync}\n`);
fs.appendFileSync(outputFile, `needs_publish=${needsPublish}\n`);
}
if (!needsSync && !needsPublish) {
console.log('Data up to date and CLI published, nothing to do');
}
console.log(`needs_sync=${needsSync}, needs_publish=${needsPublish}`);