Skip to content

[rush-lib] support users to provide their own assets file for init subspace #5134

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jzhang026
Copy link
Contributor

Summary

support users to provide their own assets file when init subspace beside using the default one provided by Rush Engine

Details

How it was tested

Impacted documentation

updated schema template of subspace as well

libraries/rush-lib/assets/rush-init/common/config/rush/subspaces.json

… a new subspace beside the default rush-init/assets folder
@jzhang026 jzhang026 force-pushed the chore/support-users-to-provide-their-own-assets-file-for-init-subspace branch from c2f952e to a8edb30 Compare February 25, 2025 07:43
/**
* the starting assets folder relative to rush.json location you want to use when init a subspace
*/
// "subspaceInitAssetsFolder": "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this design, it seems that a given monorepo can have at most one set of custom file templates to use with rush init-subspace. Therefore, why do we need to configure its location?

We could instead designate a standard location, e.g. common/config-templates/rush-init-subspace. Then everyone will know that is where to find it, without having to read subspaces.json to find the particular location for a particular repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks! I’ll update it accordingly.

Copy link
Member

@iclanton iclanton Feb 26, 2025

Choose a reason for hiding this comment

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

Or maybe common/templates/config. We could eventually have other kinds of templates (project templates?)

if (userDefinedAssetsFolder) {
// if user provided their own assets file for subspace initiation
// we just copy and overwrite the default files
await copyTemplateFileAsync(userDefinedAssetsFolder, destinationPath, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This approach seems like it will (1) try to copy a file that doesn't exist and (2) print a notice like Overwriting: .pnpmfile.js when really it is just overwriting its own file that it wrote on line 79.

Both issues could be avoided using FileSystem.existsAsync().

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, userDefinedAssetsFolder is the path of a directory. Shouldn't copyTemplateFileAsync() receive a file path?

Please fill out the How it was tested PR notes 😸

…their-own-assets-file-for-init-subspace_2025-02-25-07-23.json

Co-authored-by: Pete Gonzalez <[email protected]>
@iclanton iclanton moved this from Needs triage to In Progress in Bug Triage Mar 3, 2025
@jzhang026 jzhang026 force-pushed the chore/support-users-to-provide-their-own-assets-file-for-init-subspace branch from 5b78458 to ccbaf8b Compare March 7, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants