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

Protect: Add TypeScript Support #38146

Merged
merged 6 commits into from
Jul 9, 2024
Merged

Protect: Add TypeScript Support #38146

merged 6 commits into from
Jul 9, 2024

Conversation

nateweller
Copy link
Contributor

@nateweller nateweller commented Jul 1, 2024

Proposed changes:

  • Adds typescript as a development dependency
  • Adds tsconfig.json
    • Based off of existing projects' configurations, i.e. Boost

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

N/A

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  • Check out this branch
  • Run jetpack build plugins/protect
  • Ensure the plugin runs without regression.
@nateweller nateweller added [Status] In Progress [Type] Janitorial [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. labels Jul 1, 2024
@nateweller nateweller requested review from a team July 1, 2024 19:10
@nateweller nateweller self-assigned this Jul 1, 2024
Copy link
Contributor

github-actions bot commented Jul 1, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Protect plugin:

  • Next scheduled release: August 6, 2024.
  • Scheduled code freeze: July 29, 2024.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

github-actions bot commented Jul 1, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the add/protect-ts branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack add/protect-ts
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/protect-ts
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2
@anomiex
Copy link
Contributor

anomiex commented Jul 1, 2024

Looks fairly reasonable. It might be nice to use the same version of typescript as the rest of the monorepo to avoid confusion though. We could have Renovate update the typescript in rest of the monorepo if necessary.

Includes an alias to support "absolute" imports, i.e. `import Foo from 'protect/components/foo'

Personally I've always found that sort of thing more confusing than helpful. Without knowing about the special configuration, that looks like it's a use of https://www.npmjs.com/package/protect. And once you start using it, you'll probably have to configure Webpack to know about it, and maybe Storybook, etc.

@nateweller
Copy link
Contributor Author

Thanks for checking this out @anomiex!

  • Removed the alias. Perhaps using a root alias like "$" or "@" would cause less confusion, but I just opted to leave it out for now.
  • Changed the TS version to match the rest of the monorepo projects.
@nateweller nateweller marked this pull request as ready for review July 1, 2024 19:34
@nateweller nateweller added [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Status] Needs Team Review and removed [Status] In Progress labels Jul 1, 2024
@nateweller nateweller force-pushed the add/protect-ts branch 4 times, most recently from 0b769f4 to 417e03a Compare July 8, 2024 20:34
bhoop
bhoop previously approved these changes Jul 9, 2024
Copy link
Contributor

@bhoop bhoop left a comment

Choose a reason for hiding this comment

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

👍 , assuming the timeout errors aren't anything to worry about? (I'm not sure why this change would cause them)

@nateweller
Copy link
Contributor Author

Timeouts are unrelated, but the required lock file test is failing now:

diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4d08c2e..c3995b3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -4070,7 +4070,7 @@ importers:
         version: 7.2.0
       '@wordpress/components':
         specifier: 28.2.0
-        version: 28.2.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+        version: 28.2.0(@types/react@18.3.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
       '@wordpress/data':
         specifier: 10.2.0
         version: 10.2.0(react@18.3.1)
---
Error: pnpm-lock.yaml is not up to date!
You can probably fix this by running `pnpm install` in the appropriate directory.
---

This may be due to introducing @types/react to the Protect plugin. The new lock file looks like I would expect it to be, but I bet @anomiex may know better? 😄

Rebased trunk and ran jetpack install -r as well as pnpm install to be safe. No lock file changes came from either of those actions.

@anomiex
Copy link
Contributor

anomiex commented Jul 9, 2024

Looks like this was one of those cases where a normal pnpm install was ok with it, but running pnpm install --resolution-only to force it to re-check stuff decided to make that change.

@nateweller nateweller merged commit bb3d41f into trunk Jul 9, 2024
72 of 73 checks passed
@nateweller nateweller deleted the add/protect-ts branch July 9, 2024 19:56
@github-actions github-actions bot removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Status] Needs Team Review labels Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs [Package] Abtest [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Type] Janitorial
3 participants