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

#9430: extracting first util lib #9491

Merged
merged 3 commits into from
Nov 12, 2024
Merged

#9430: extracting first util lib #9491

merged 3 commits into from
Nov 12, 2024

Conversation

fungairino
Copy link
Collaborator

@fungairino fungairino commented Nov 11, 2024

What does this PR do?

  • Part of Slice 2: Add nx initial config and commands #9430
  • As part of the monorepo trailblazing, this PR sets up the first extracted utils library, extracting some debugging util that isn't used anywhere else (namely pixiebrix-app) and doesn't have any other dependencies
    • This will make it easier for us to properly set up nx and catch any potential issues.
  • Initial set up with some duplicated jest and tsconfig
    • Follow-up will extract common base configuration to the root, and add linting

Discussion

  • For ease of starting this out, this new utils library is build-less, but we will likely want to move towards each library project producing its compiled js so we can take advantage of nx's build and caching mechanisms. I will look into this in the next set of changes alongside creating a root common ts config.

Checklist

  • Added jest or playwright tests and/or storybook stories

For more information on our expectations for the PR process, see the
code review principles doc

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.72%. Comparing base (8318d74) to head (51897a6).
Report is 487 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9491      +/-   ##
==========================================
+ Coverage   74.24%   75.72%   +1.47%     
==========================================
  Files        1332     1406      +74     
  Lines       40817    42439    +1622     
  Branches     7634     7816     +182     
==========================================
+ Hits        30306    32135    +1829     
+ Misses      10511    10304     -207     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Nov 11, 2024

Playwright test results

passed  154 passed
skipped  2 skipped

Details

report  Open report ↗︎
stats  156 tests across 51 suites
duration  10 minutes, 59 seconds
commit  51897a6
info  For more information on how to debug and view this report, see our readme

Skipped tests

chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
msedge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options

@@ -178,6 +185,42 @@ describe("Add/Remove Bricks", () => {
).toBeArrayOfSize(initialBricks.length + 1);
});

test("Add Brick - bad pipeline path error", async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added this test just to ensure there was no regression with this existing debug util code.

@@ -28,7 +28,7 @@ type InvalidPathInformation = {
* @param path period separated path
*/
export function getInvalidPath(
value: UnknownObject,
value: Record<string, unknown>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

UnknownObject comes from a global type def, which we might eventually want to move to the root as well.

Copy link
Contributor

@twschiller twschiller Nov 11, 2024

Choose a reason for hiding this comment

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

We might also consider using typefest's UnknownRecord instead: https://github.com/sindresorhus/type-fest/blob/main/source/unknown-record.d.ts. There's is maybe technically more accurate — ours only supports string keys vs. strings/symbols/numbers: https://www.totaltypescript.com/concepts/propertykey-type

Although, ours is helpful for distinguishing against mistaken Array uses

Comment on lines -30 to -34
"engine-strict": true,
"engines": {
"node": "20.12.0",
"npm": "10.5.0"
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved to the root package.json

@fungairino fungairino marked this pull request as ready for review November 11, 2024 21:11
"compilerOptions": {
"sourceMap": true,
"module": "esnext",
"target": "es2023",
Copy link
Contributor

@twschiller twschiller Nov 11, 2024

Choose a reason for hiding this comment

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

Should we consider defining a config these can extend from? E.g., in some libraries we might be able to enforce stricter rules (e.g., noUnusedParameters)

Update: I see you already mentioned the duplication in the PR description

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think we should define a base tsconfig. That's the follow-up I mentioned in the PR description

@twschiller twschiller added this to the 2.2.0 milestone Nov 11, 2024
Copy link

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

@twschiller twschiller changed the title extracting first util lib #9430: extracting first util lib Nov 12, 2024
@@ -28,7 +28,7 @@ type InvalidPathInformation = {
* @param path period separated path
*/
export function getInvalidPath(
Copy link
Contributor

@twschiller twschiller Nov 12, 2024

Choose a reason for hiding this comment

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

NIT: as an aside, given this method uses Formik's getIn vs. lodash's (I'm not sure if there are any differences?) we might consider moving it to a formikDebugUtils module or similar in the future

Or, if there are no differences in getIn implementation, we might consider dropping the Formik dependency from this library in favor of lodash

@fungairino fungairino merged commit 0b061cc into main Nov 12, 2024
46 checks passed
@fungairino fungairino deleted the extracting-first-util-lib branch November 12, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants