Skip to content

Conversation

@JPeer264
Copy link
Member

(closes #2617)

This PR migrates all JavaScript files in the lib/ directory to native TypeScript, removing the need for JSDoc type annotations and improving type safety.

Main Changes

  • Converted all .js files to .ts with proper TypeScript syntax
  • Changed module system from CommonJS to ES6 modules for better TypeScript interoperability
  • Updated exports to use ES6 export syntax instead of module.exports
  • All types are now exported as named exports for better type inference and IDE support
  • OptionsSchema is now a union to satisfy SOURCEMAPS_OPTIONS, as this one didn't had the required param
  • The exports of lib/releases/options has changed its name

Breaking Changes

Module Exports

  • Before: module.exports = SentryCli; (CommonJS)
  • After: export class SentryCli { ... } (ES6 named export)

We could have maintained backwards compatibility with export = SentryCli;. The only problem were the types which needed to be exported as well. With ES6 named exports, we can now export all types alongside the class.

Internal Improvements

Simplified Release constructor

  • Before: new Releases({ ...this.options, configFile }) - configFile was merged into options
  • After: new Releases(this.options, configFile) - two separate parameters

With 2 parameters it's easier to maintain and makes the separation of concerns clearer.

@JPeer264 JPeer264 self-assigned this Nov 26, 2025
@JPeer264 JPeer264 requested review from a team as code owners November 26, 2025 16:02
@JPeer264 JPeer264 requested review from nicohrubec and removed request for a team November 26, 2025 16:02
@JPeer264 JPeer264 added the v3.0 Breaking changes to include in version 3.0.0 of Sentry CLI label Nov 26, 2025
@JPeer264 JPeer264 changed the title feat: move javascript files to native typescript feat: Move javascript files to native typescript Nov 26, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 5d03c1d

@JPeer264 JPeer264 force-pushed the jp/move-to-native-typescript branch from 15c05f5 to a8e7f1f Compare November 26, 2025 16:33
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: rejectOnError always rejects after resolving

When live is 'rejectOnError' and the command succeeds with exit code 0, the code resolves with 'success (live mode)' but then immediately continues to execute the reject statement because there's no return or else. This causes the promise to be settled twice and creates incorrect behavior where successful commands trigger rejection logic.

lib/helper.ts#L342-L348

sentry-cli/lib/helper.ts

Lines 342 to 348 in a8e7f1f

pid.on('exit', (exitCode) => {
if (live === 'rejectOnError') {
if (exitCode === 0) {
resolve('success (live mode)');
}
reject(new Error(`Command ${args.join(' ')} failed with exit code ${exitCode}`));
}

Fix in Cursor Fix in Web


* @param options More options to pass to the CLI
*/
constructor(configFile, options) {
constructor(public configFile: string | null, public options: SentryCliOptions) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: SentryCli constructor breaks backwards compatibility

The constructor declares both configFile and options as required parameters without default values, but existing code calls new SentryCli() with no arguments. The original JavaScript version allowed both parameters to be optional. This breaks backwards compatibility beyond just the import syntax change documented in the CHANGELOG.

Fix in Cursor Fix in Web


- Drop support for Node.js <18. The minimum required Node.js version is now 18.0.0 ([#2985](https://github.com/getsentry/sentry-cli/issues/2985)).
- The JavaScript wrapper now uses named exports instead of default exports ([#2989](https://github.com/getsentry/sentry-cli/pull/2989))
. You need to update your imports:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: CHANGELOG contains syntax error

Line 13 contains a stray period . on its own line, appearing to be an accidental character left after editing. This creates malformed markdown in the CHANGELOG.

Fix in Cursor Fix in Web

@JPeer264 JPeer264 force-pushed the jp/move-to-native-typescript branch from a8e7f1f to d5414fc Compare November 26, 2025 16:45
* @param {OptionsSchema} [schema] An options schema required by the command.
* @param {object} [options] An options object according to the schema.
* @returns {string[]} An arguments array that can be passed via command line.
* @param command The literal name of the command.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Undefined paramName used in non-boolean types

When OptionsSchema entries have only invertedParam without param, the paramName variable becomes undefined. For non-boolean types like string or number, line 237 concatenates undefined into the arguments array, creating invalid command-line arguments. This case needs proper handling to skip entries without a param for non-boolean types.

Fix in Cursor Fix in Web

* @returns A promise that resolves when the release has been created.
*/
async new(release, options) {
async new(release: string, options: { projects?: string[] }): Promise<string> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Required options parameter breaks backward compatibility

The new method requires the options parameter, but tests call it without arguments like releases.new('my-version'). The SentryCliReleases interface defines options as optional, and getProjectFlagsFromOptions accepts undefined with default parameter = {}. The parameter needs to be optional to match the interface and maintain backward compatibility.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v3.0 Breaking changes to include in version 3.0.0 of Sentry CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants