Skip to content

[core] Re-use latest code infra scripts from core repo #1662

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

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

brijeshb42
Copy link
Contributor

@brijeshb42 brijeshb42 commented Apr 1, 2025

Removed all the local code wherever possible and used scripts from the core repo.

Sorry, something went wrong.

@brijeshb42 brijeshb42 added core Infrastructure work going on behind the scenes scope: code-infra Specific to the code-infra product labels Apr 1, 2025
@brijeshb42 brijeshb42 force-pushed the code-infra-core branch 7 times, most recently from f4f8757 to b1f0f5e Compare April 2, 2025 06:24
Copy link

netlify bot commented Apr 2, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f4f8757
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/67ecd7f1f2d3cc0008dc4c73
😎 Deploy Preview https://deploy-preview-1662--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 2, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 51ffb33
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/680a0a51b2d952000807b671
😎 Deploy Preview https://deploy-preview-1662--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brijeshb42 brijeshb42 force-pushed the code-infra-core branch 4 times, most recently from d73ca0c to eb0c574 Compare April 2, 2025 15:05
@brijeshb42 brijeshb42 marked this pull request as ready for review April 2, 2025 15:10
@brijeshb42 brijeshb42 requested review from Janpot and a team and removed request for colmtuite, atomiks, michaldudak and Janpot April 2, 2025 15:10
@brijeshb42 brijeshb42 force-pushed the code-infra-core branch 2 times, most recently from fd5c639 to 68de990 Compare April 2, 2025 18:22
console.error(error);
process.exit(1);
});
import '@mui/monorepo/scripts/testBuiltTypes.mjs';
Copy link
Member

@Janpot Janpot Apr 3, 2025

Choose a reason for hiding this comment

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

Can keep it for now, but looking at the script, I assume this is unnecessary if your declarations are built from typescript files.

Actually, it's looking for mui-* segments in the paths, which would never occur in the base ui repo.

Copy link
Contributor Author

@brijeshb42 brijeshb42 Apr 3, 2025

Choose a reason for hiding this comment

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

Actually, it's looking for mui-* segments in the paths

True. I wonder if it was even working as intended.

@@ -37,7 +37,9 @@ async function main(version) {
return;
}

const packageJsonPath = path.resolve(getWorkspaceRoot(), 'package.json');
const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));
const workspaceRoot = path.resolve(currentDirectory, '..');
Copy link
Member

Choose a reason for hiding this comment

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

Can't this script just default to process.cwd() and add the script to root package.jsons scripts. Then it will always run with cwd of the root, regardless of whether it's executed from a subfolder.

Copy link
Member

Choose a reason for hiding this comment

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

My personal preference is not to include everything in package.json scripts to avoid cluttering them, especially if the script is only used by the CI.

@brijeshb42 brijeshb42 force-pushed the code-infra-core branch 2 times, most recently from 48e9447 to ad27d41 Compare April 3, 2025 08:59
@brijeshb42
Copy link
Contributor Author

brijeshb42 commented Apr 3, 2025

That makes this script more portable within and across projects.

By portable, you mean copy pastable to new repos in any directory, right ?

@Janpot
Copy link
Member

Janpot commented Apr 3, 2025

By portable, you mean copy pastable to new repos in any directory, right ?

No, I mean the location in the file system of the script makes no difference on whether it behaves correctly. So we can simply move it to a published package and make it available in the path with package.json bin and it'll still work. I don't think we should encourage copy/pasting these tools.

@brijeshb42
Copy link
Contributor Author

The way this particular script works right now, it'll need to be copy pasted unless we change that.
Rest can be used from an installable package.

@brijeshb42 brijeshb42 requested review from michaldudak and Janpot April 4, 2025 13:14
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 4, 2025
Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Great job. I can't reproduce any problem that would break the types validation functions. @michaldudak for a final approval.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 4, 2025
@brijeshb42 brijeshb42 force-pushed the code-infra-core branch 2 times, most recently from 65fdda6 to 8a21680 Compare April 7, 2025 07:47
@@ -37,7 +36,8 @@ async function main(version) {
return;
}

const packageJsonPath = path.resolve(getWorkspaceRoot(), 'package.json');
const workspaceRoot = process.cwd();
Copy link
Member

Choose a reason for hiding this comment

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

Now we're in a state where we must run the script from the root directory and don't have it added to npm scripts to enforce the correct working directory. My preference would be to leave the previous version, but if you and @Janpot like reading process.cwd and calling the script from npm, let's have it your way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't this script always have to run from the root directory anyways given it needs to modify root package.json
And the current invocation of script will remain as is even if it is added to package.json scripts.
Not sure I fully understand.

Copy link
Member

Choose a reason for hiding this comment

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

but if you and @Janpot like reading process.cwd and calling the script from npm, let's have it your way.

FYI: I don't really have some bizarre fetish to see process.cwd() 😄. My preference would be that we centralize this script instead of copying it over multiple repositories. In that scenario, the getWorkspaceRoot() as implemented in this repo would never work as it would exist in a different location relative to the workspace root (such as in the node_modules folder). Any CLI tool we use operates on the current working dir, or its parents. That's why I advocate for not writing our scripts in a way that its location in the file system matters. That way we make it easy for them to be distributed across the company.

Personally, for this script, I think it's a bit overkill to look for a root, but as always, code infra can only work when the project teams buy in to the idea. So if there is a strong desire for the functionality we can certainly add it back, but I believe the correct implementation should be to start from process.cwd() and progressively check parent folders for a pnpm-workspace.yaml file.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 11, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 24, 2025
Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

I couldn't find any issues with this. Thanks for your contribution!

@brijeshb42 brijeshb42 merged commit 85597f3 into mui:master Apr 24, 2025
22 checks passed
@brijeshb42 brijeshb42 deleted the code-infra-core branch April 24, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes scope: code-infra Specific to the code-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants