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

πŸ“¦ refactor(library): migrate entry point of all modules to lib/index.js #126

Merged
merged 9 commits into from
Apr 27, 2020
Merged

πŸ“¦ refactor(library): migrate entry point of all modules to lib/index.js #126

merged 9 commits into from
Apr 27, 2020

Conversation

oscard0m
Copy link
Member

@oscard0m oscard0m commented Apr 22, 2020

πŸ“ Summary

  • Change entry point for all modules to lib/index.js
  • Keep retrocompatibility but warn the user about a future deprecation

β›± Motivation and Context

#113

@gr2m
Copy link
Contributor

gr2m commented Apr 22, 2020

When I run the tests, I only see one message

src/verify/index.js is deprecated. Use lib/index.js instead.

I'd expect to log messages for all the module imports?

Also the message should clarify that it's about the require statement, maybe something like this?

const verify = require('@octokit/webhooks/verify') is deprecated. Use const { verify } = require('@octokit/webhooks') instead

The tests should test for dedeprecations. I'd make a separate test/integration/deprecations-test.ts file which only does the now deprecated import. You can use simple-mock to test that the correct message was logged. Once that is all working, you can adapt the existing tests in the other files to remove the deprecation messages by using the new import

@oscard0m
Copy link
Member Author

When I run the tests, I only see one message

src/verify/index.js is deprecated. Use lib/index.js instead.

I'd expect to log messages for all the module imports?

Let me take a look

Also the message should clarify that it's about the require statement, maybe something like this?

const verify = require('@octokit/webhooks/verify') is deprecated. Use const { verify } = require('@octokit/webhooks') instead

I like it. Sounds good to me to clarify the named export way we are migrating to.

The tests should test for dedeprecations. I'd make a separate test/integration/deprecations-test.ts file which only does the now deprecated import. You can use simple-mock to test that the correct message was logged. Once that is all working, you can adapt the existing tests in the other files to remove the deprecation messages by using the new import

πŸ‘Œ To add deprecations-tests (.js for the moment I guess)
πŸ‘Œ To adapt existing smoke-test to use new imports

@oscard0m
Copy link
Member Author

oscard0m commented Apr 23, 2020

πŸš‘ Applied major fix (the previous changes were completely wrong)
β˜‘οΈ Applied improvement on deprecation message
β˜‘οΈ Adapted test/integration/smoke-test.js to use new exposed entries
β˜‘οΈ Created test/integration/deprecation-test to assure there is retrocompatibility


⚠️ It seems that tap is hidding under the carpet the depreation warnings:

npx tap test/integration/deprecation-test.js
image

πŸ†š

node test/integration/deprecation-test.js
image

Also tested manually creating dummy js files and running them with node. i.e.:

const verify = require("./src/verify");
verify("1234", {}, "randomSignature")

image


I've been researching a way to make tap output the deprecation warning message but I did not find a way. Do you know a way maybe?

Thanks @gr2m

@gr2m
Copy link
Contributor

gr2m commented Apr 26, 2020

You do a great job splitting up your work in meaningful commits, makes it a joy to review your changes πŸ‘

I've been researching a way to make tap output the deprecation warning message but I did not find a way. Do you know a way maybe?

I would mock process.emitWarning the way we currently do here:

simple.mock(console, "warn").callFn(function () {});

The function simple.mock returns a mock object, which you can use for asserts, e.g.

const mock =   simple.mock(process, "emitWarning").callFn(function () {});
// ...
t.equals(mock.callCount, 1)

I think that should work 😁

@oscard0m
Copy link
Member Author

You do a great job splitting up your work in meaningful commits, makes it a joy to review your changes πŸ‘

Thanks for the compliment @gr2m 😍

I've been researching a way to make tap output the deprecation warning message but I did not find a way. Do you know a way maybe?

I would mock process.emitWarning the way we currently do here:

simple.mock(console, "warn").callFn(function () {});

The function simple.mock returns a mock object, which you can use for asserts, e.g.

const mock =   simple.mock(process, "emitWarning").callFn(function () {});
// ...
t.equals(mock.callCount, 1)

I think that should work 😁

Let me give it a try!

@oscard0m
Copy link
Member Author

oscard0m commented Apr 27, 2020

Let me give it a try!

It works! @gr2m πŸ€“ 🍾

Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

great work πŸ‘ I've tested it against latest probot and it still all works

@gr2m gr2m merged commit d6fb7cf into octokit:master Apr 27, 2020
@github-actions
Copy link
Contributor

πŸŽ‰ This PR is included in version 7.3.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

@oscard0m
Copy link
Member Author

great work πŸ‘ I've tested it against latest probot and it still all works

Thanks once again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants