Files
electron/script/release/find-github-release.mts
T
Samuel AttardandClaude 8d424eb34d build: run the TypeScript scripts under script/ with plain node (#54168)
ts-node was used as a CLI for a handful of TypeScript scripts under
script/. Those now rely on the type stripping built into Node.js instead:

- script/gen-filenames, check-patch-diff, run-clang-tidy and the release
  helpers (find-github-release, upload-to-github, github-token, types)
  are renamed to .mts and invoked with `node`. They use
  import.meta.dirname and explicit .mts / .js specifiers, and
  tsconfig.script.json moves to nodenext with verbatimModuleSyntax so
  tsc checks them the way Node runs them.
- The documented minimum Node.js for building goes from 22.12 to 22.18,
  the first 22.x release with type stripping on by default.
- script/codesign/gen-trust.ts and its trust.xml template are deleted;
  nothing has invoked them since generate-identity.sh switched to a
  user-scoped keychain in #50058.
- oxfmt, oxlint, lint-staged and .gitattributes learn about .mts.

ts-node itself stays for now because the spec runner still loads specs
through its require hook.

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-21 13:09:47 -07:00

50 lines
1.1 KiB
TypeScript

import { Octokit } from '@octokit/rest';
import { createGitHubTokenStrategy } from './github-token.mts';
import { ELECTRON_ORG, ELECTRON_REPO, type ElectronReleaseRepo, NIGHTLY_REPO } from './types.mts';
if (process.argv.length < 3) {
console.log('Usage: find-release version');
process.exit(1);
}
const version = process.argv[2];
const targetRepo = findRepo();
const octokit = new Octokit({
authStrategy: createGitHubTokenStrategy(targetRepo)
});
function findRepo(): ElectronReleaseRepo {
return version.indexOf('nightly') > 0 ? NIGHTLY_REPO : ELECTRON_REPO;
}
async function findRelease() {
const releases = await octokit.repos.listReleases({
owner: ELECTRON_ORG,
repo: targetRepo
});
const targetRelease = releases.data.find((release) => release.tag_name === version);
let returnObject = {};
if (targetRelease) {
returnObject = {
id: targetRelease.id,
draft: targetRelease.draft,
exists: true
};
} else {
returnObject = {
exists: false,
draft: false
};
}
console.log(JSON.stringify(returnObject));
}
findRelease().catch((err) => {
console.error(err);
process.exit(1);
});