-
-
Notifications
You must be signed in to change notification settings - Fork 236
feat: Move javascript files to native typescript #2989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: szokeasaurusrex/debugId
Are you sure you want to change the base?
Conversation
|
15c05f5 to
a8e7f1f
Compare
There was a problem hiding this 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
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}`)); | |
| } |
| * @param options More options to pass to the CLI | ||
| */ | ||
| constructor(configFile, options) { | ||
| constructor(public configFile: string | null, public options: SentryCliOptions) { |
There was a problem hiding this comment.
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.
a9f9165 to
a809a5c
Compare
a8e7f1f to
d5414fc
Compare
| * @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. |
There was a problem hiding this comment.
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.
andreiborza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM although I think we should rethink breaking the default export if avoidable. It makes migration slightly more annoying for little benefit to the user and I'm not sure it's worth the change, but your call.
Yes it is a change that the user has to do. The problem however, is that with Just for the record those are the 3 options we have (maybe I miss someone):
For point 2, we could theoretically add |
| * @param options More options to pass to the CLI | ||
| */ | ||
| constructor(configFile, options) { | ||
| constructor(public configFile: string | null, public options: SentryCliOptions) { | ||
| if (typeof configFile === 'string') { | ||
| this.configFile = configFile; | ||
| } | ||
| this.options = options || { silent: false }; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right... fair enough then. I was thinking about our main repo, but totally different build system. I guess with that LGTM!
We just need to make sure we migrate all our repos correctly, few I can think of off of the top of my head:
szokeasaurusrex
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only briefly checked this since @andreiborza already approved, but lgtm!
| type: 'boolean', | ||
| }, | ||
| }; | ||
| } satisfies OptionsSchema; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] please fix the missing newline
| } satisfies OptionsSchema; | |
| } satisfies OptionsSchema; | |
I should probably enable pre-commit to auto fix these
a809a5c to
3877b10
Compare
3877b10 to
7dce072
Compare
|
@JPeer264 is this PR ready to be added to my stack? I can take care of merging conflicts |
|
yes it is ready |
f1119df to
36bbead
Compare
36bbead to
60bb5c0
Compare
| constructor(public configFile: string | null, public options: SentryCliOptions) { | ||
| if (typeof configFile === 'string') { | ||
| this.configFile = configFile; | ||
| } | ||
| this.options = options || { silent: false }; | ||
| this.releases = new Releases({ ...this.options, configFile }); | ||
| this.releases = new Releases(this.options, configFile); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| async function execute( | ||
| args: string[], | ||
| live: boolean, | ||
| silent: boolean, | ||
| configFile: string | undefined, | ||
| config: SentryCliOptions = {} | ||
| ): Promise<string> { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
60bb5c0 to
c7f20b7
Compare
c7f20b7 to
d0453c4
Compare
a7bea4b to
5387d79
Compare
5387d79 to
51ded13
Compare
d0453c4 to
2c953fe
Compare
| * @param options More options to pass to the CLI | ||
| */ | ||
| constructor(configFile, options) { | ||
| constructor(public configFile: string | null, public options: SentryCliOptions) { | ||
| if (typeof configFile === 'string') { | ||
| this.configFile = configFile; | ||
| } | ||
| this.options = options || { silent: false }; | ||
| this.releases = new Releases({ ...this.options, configFile }); | ||
| this.releases = new Releases(this.options, configFile); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
(closes #2617) (closes [CLI-142](https://linear.app/getsentry/issue/CLI-142/use-typescript-to-generate-type-declarations)) 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.
51ded13 to
f23b920
Compare
2c953fe to
98e6185
Compare
f23b920 to
ab53dc2
Compare
98e6185 to
6b32ed2
Compare
ab53dc2 to
acf0e03
Compare
6b32ed2 to
3679dc2
Compare
(closes #2617) (closes [CLI-142](https://linear.app/getsentry/issue/CLI-142/use-typescript-to-generate-type-declarations)) 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.
acf0e03 to
ee866b7
Compare
3679dc2 to
0f60c1c
Compare
(closes #2617)
(closes CLI-142)
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
.jsfiles to.tswith proper TypeScript syntaxexportsyntax instead ofmodule.exportsOptionsSchemais now a union to satisfySOURCEMAPS_OPTIONS, as this one didn't had the requiredparamlib/releases/optionshas changed its nameBreaking Changes
Module Exports
module.exports = SentryCli;(CommonJS)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
Releaseconstructornew Releases({ ...this.options, configFile })- configFile was merged into optionsnew Releases(this.options, configFile)- two separate parametersWith 2 parameters it's easier to maintain and makes the separation of concerns clearer.