Skip to content
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

feat: typescript rewrite #560

Merged
merged 21 commits into from
Aug 9, 2022
Merged

feat: typescript rewrite #560

merged 21 commits into from
Aug 9, 2022

Conversation

erunion
Copy link
Member

@erunion erunion commented Aug 9, 2022

🧰 Changes

After marinating on #558 over the weekend I decided that it'd be best for the codebase if we finally migrated it over to TypeScript before making any ESM decisions.

  • Completely refactored the entire codebase into TypeScript.
  • Created a new base Command class that every command extends from.
  • Blew up command tests into their own files for each command (i.e. versions.test.ts is now versions/index.test.ts, versions/create.test.ts, etc`)
  • Some other refactors I'm sure I'm missing.

🐛 Known Issues

  • The main index.test.ts test is failing.
  • There's some funk with the typings.d.ts file. Might need to move those into the tsconfig.json sink config I have set up. I had a lot of problems with typings.d.ts files over in api too.
  • [ ]~~ After running npm run build and then ./bin/rdme no commands show up. I think this is because the way the help tool work is that it looks at src/cmds, which doesn't exist in the dist/ directory. There was a similar problem in feat: refactoring the codebase to be ESM #558 around this dynamic command setup and it might be worth replacing it with a src/cmds/index.ts file that loads and exports every available command.~~
  • I tried replacing the common if no key throw an error flow in each command by moving that into the Command.run() super but strangely promises that would get rejected from super.run() would immediately throw an uncaught promise exception. I'm not sure why, but figuring this out would remove a handful of boilerplate from every command that requires auth.

🧬 QA & Testing

  • Do all tests pass?
  • Do all commands still work?

@erunion erunion added enhancement New feature or request refactor Issues about tackling technical debt labels Aug 9, 2022
Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

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

very excited about this! some interim comments/questions

__tests__/index.test.ts Outdated Show resolved Hide resolved
src/.sink.d.ts Show resolved Hide resolved
src/lib/fetch.ts Outdated Show resolved Hide resolved
@@ -20,7 +20,7 @@ module.exports = async function getCategories(key, selectedVersion) {
}),
})
.then(res => {
totalCount = Math.ceil(res.headers.get('x-total-count') / 20);
totalCount = Math.ceil(parseInt(res.headers.get('x-total-count'), 10) / 20);
Copy link
Member

Choose a reason for hiding this comment

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

woooooof

Comment on lines 136 to 137
* @param {String} folderToSearch path to directory
* @returns {String[]} array of files
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if we need these types I wrote in the JSDocs now 😅

erunion and others added 7 commits August 9, 2022 10:24
Saw the following error:

```
jest-haste-map: Haste module naming collision: rdme
  The following files share their name; please adjust your hasteImpl:
    * <rootDir>/dist/package.json
    * <rootDir>/package.json
```

this is a fix for that, stolen from here: jestjs/jest#8114 (comment)
/**
* Because our command classes have a `run` method that might not always call `this` we need to
* explicitly exclude `run` from this rule.
*/
"class-methods-use-this": ["error", { "exceptMethods": ["run"] }],

"import/order": ["error", {
Copy link
Member

Choose a reason for hiding this comment

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

hell yeah

@kanadgupta kanadgupta marked this pull request as ready for review August 9, 2022 21:20
Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

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

🥹

@erunion erunion merged commit 5ed97cc into main Aug 9, 2022
@erunion erunion deleted the feat/typescript-rewrite branch August 9, 2022 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Issues about tackling technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants