-
Notifications
You must be signed in to change notification settings - Fork 7
chore: Migrate constraints from Prolog to JavaScript #47
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
Conversation
| "module": "./dist/index.mjs", | ||
| "files": [ | ||
| "dist" | ||
| "dist/" |
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.
changed this so we can apply the constrain to this package as well even though the package is private
| "types": "./dist/index.d.cts", | ||
| "files": [ | ||
| "dist" | ||
| "dist/" |
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.
changed this so we can apply the constrain to this package as well even though the package is private
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.
Click Load diff to see the file since it is big
| // Packages that do not have an entrypoint, types, or sideEffects | ||
| const entrypointExceptions = ['shims', 'streams']; | ||
| // Packages that do not have typedoc | ||
| const typedocExceptions = ['test-utils', 'extension']; | ||
| // Packages that do not have build or tests | ||
| const noBuildOrTests = ['test-utils']; | ||
| // Packages that do not export a `package.json` file | ||
| const noPackageJson = ['extension']; |
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.
We set the exceptions at the top so we can edit them easily
| expectValidVersionRanges(Yarn, workspace); | ||
|
|
||
| // Ensure dependency ranges are synchronized across the monorepo | ||
| expectSynchronizedRanges(Yarn, workspace); | ||
|
|
||
| // Ensure dependencies are not duplicated across dependency types | ||
| expectUniqueDependencyTypes(Yarn, workspace); |
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.
these weren't existent in the core example so if you want to check the code I wrote.
| // If one workspace package lists another workspace package within | ||
| // `peerDependencies`, the dependency range must satisfy the current | ||
| // version of that package. | ||
| expectUpToDateWorkspacePeerDependencies(Yarn, workspace); |
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.
this was in the core example but not in our constraints, I figured it is ok we leave it
yarn.config.cjs
Outdated
| // `dependencies`, and B is a controller package, then we need to ensure | ||
| // that B is also listed in A's `peerDependencies` and that the version | ||
| // range satisfies the current version of B. | ||
| expectControllerDependenciesListedAsPeerDependencies( |
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.
this also was in the MetaMask/core#4546 but not in our constraints
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.
"Controllers" are specific to the core monorepo, so we should delete both this call and the function itself.
| if (!isPrivate) { | ||
| // All non-root packages must have a valid README.md file. | ||
| await expectReadme(workspace, workspaceBasename); | ||
| } |
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.
this also was in the MetaMask/core#4546 but not in our constraints, we don't have any readme but it is ok to leave it here for when they are not private anymore
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.
Yeah I think this is okay. The body of the function is also okay, because eventually we will prefix all of these packages with @metamask/. For now we prefix them with @ocap/ just as a convenience. (That org name is also taken 😢 )
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.
Looks good! I left a couple of inline suggestions. In addition to those, I noticed that the /core version of the config file has type checking enabled. Our TypeScript configuration is quite different from theirs, so I decided to gauge how difficult it might be to enable. As it turns out, it shouldn't be bad at all! Therefore, I think we should do this too.
#48 contains the result of my experiment. The only problem remaining is a set of errors related to types that I believe are defined directly in the file, and therefore shouldn't be difficult to fix. Feel free to merge my branch or reimplement my changes.
yarn.config.cjs
Outdated
| // `dependencies`, and B is a controller package, then we need to ensure | ||
| // that B is also listed in A's `peerDependencies` and that the version | ||
| // range satisfies the current version of B. | ||
| expectControllerDependenciesListedAsPeerDependencies( |
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.
"Controllers" are specific to the core monorepo, so we should delete both this call and the function itself.
| if (!isPrivate) { | ||
| // All non-root packages must have a valid README.md file. | ||
| await expectReadme(workspace, workspaceBasename); | ||
| } |
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.
Yeah I think this is okay. The body of the function is also okay, because eventually we will prefix all of these packages with @metamask/. For now we prefix them with @ocap/ just as a convenience. (That org name is also taken 😢 )
This is a half-finished attempt to enable `// @ts-check` in `yarn.config.js`. See review for more details.
@rekmarks ok, all fixed. Remember to |
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.
@sirtimid the // @ts-expect-error I had for the lodash import was not due to a missed yarn install, but because lodash does not export a valid ESM module (error ts(2306)). Were you getting an error on the "expect error" directive on your end? If so, we could replace it with a // @ts-ignore since this is neither a source nor TS file, and we don't have to be that careful with the types.
Either way, LGTM, and I'll leave it to you whether to address the TS error.
@rekmarks Ah, I don't get the error because I have the @types/lodash locally and I removed it from deps since lint was complaining that it is unused. I don't want to change the tsconfig to allowJS so I ll just add the ignore |
|
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
Explanation
Migrated constrains. This PR was used as a base with various customizations to align with our constraints.
See comments for adjustments to the prolog constraints.
References
Fixes #17