Skip to content

Conversation

@sirtimid
Copy link
Contributor

@sirtimid sirtimid commented Sep 5, 2024

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

@sirtimid sirtimid requested a review from a team as a code owner September 5, 2024 20:20
"module": "./dist/index.mjs",
"files": [
"dist"
"dist/"
Copy link
Contributor Author

@sirtimid sirtimid Sep 5, 2024

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/"
Copy link
Contributor Author

@sirtimid sirtimid Sep 5, 2024

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

Copy link
Contributor Author

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

Comment on lines +14 to +21
// 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'];
Copy link
Contributor Author

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

Comment on lines +249 to +255
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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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(
Copy link
Contributor Author

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

Copy link
Member

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.

Comment on lines +303 to +306
if (!isPrivate) {
// All non-root packages must have a valid README.md file.
await expectReadme(workspace, workspaceBasename);
}
Copy link
Contributor Author

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

Copy link
Member

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 😢 )

@rekmarks rekmarks self-requested a review September 5, 2024 20:45
Copy link
Member

@rekmarks rekmarks left a 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(
Copy link
Member

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.

Comment on lines +303 to +306
if (!isPrivate) {
// All non-root packages must have a valid README.md file.
await expectReadme(workspace, workspaceBasename);
}
Copy link
Member

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 😢 )

rekmarks and others added 3 commits September 6, 2024 10:52
This is a half-finished attempt to enable `// @ts-check` in
`yarn.config.js`. See review for more details.
@sirtimid sirtimid requested a review from rekmarks September 6, 2024 10:01
@sirtimid
Copy link
Contributor Author

sirtimid commented Sep 6, 2024

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.

@rekmarks ok, all fixed. Remember to yarn install so you won't have the lodash error.

rekmarks
rekmarks previously approved these changes Sep 6, 2024
Copy link
Member

@rekmarks rekmarks left a 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.

@sirtimid
Copy link
Contributor Author

sirtimid commented Sep 6, 2024

@sirtimid the // @ts-expect-error I had for lodash 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

@socket-security
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@types/lodash@4.17.7 None 0 867 kB types

View full report↗︎

@sirtimid sirtimid merged commit 4e4d6f8 into main Sep 6, 2024
@sirtimid sirtimid deleted the sirtimid/prolog-to-javascript-constraints branch September 6, 2024 18:18
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.

monorepo: Migrate constraints from Prolog to JavaScript

3 participants