Skip to content

[Blueprints] Ensure plugins and themes are installed in subfolders when using url references in the installPlugin/Theme step #2128

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

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Ensure a zip name
  • Loading branch information
bgrgicak committed Jan 14, 2025
commit 354d3b842ceb355e30f2a0a22e67bcc4a4bd0bb7
14 changes: 11 additions & 3 deletions packages/playground/blueprints/src/lib/steps/install-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,23 @@ export async function installAsset(
targetPath,
zipFile,
ifAlreadyInstalled = 'overwrite',
targetFolderName = ''
targetFolderName = '',
}: InstallAssetOptions
): Promise<{
assetFolderPath: string;
assetFolderName: string;
}> {
// Extract to temporary folder so we can find asset folder name
const zipFileName = zipFile.name;
const assetNameGuess = zipFileName.replace(/\.zip$/, '');
let assetNameGuess = zipFileName.replace(/\.zip$/, '');
/**
* Some resource types like GitDirectoryReference and UrlReference
* don't have a name, so we need to generate a random name to ensure
* the asset folder name exists.
*/
if (!zipFileName) {
assetNameGuess = `${randomString(32, '')}`;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Technically this could break if the path already exists, but I wasn't sure if checking the path would overcomplicate the implementation.

}

const wpContent = joinPaths(await playground.documentRoot, 'wp-content');
const tmpDir = joinPaths(wpContent, randomString());
Expand Down Expand Up @@ -88,7 +96,7 @@ export async function installAsset(
}

// If a specific slug was requested be used, use that.
if ( targetFolderName && targetFolderName.length ) {
if (targetFolderName && targetFolderName.length) {
assetFolderName = targetFolderName;
}

Expand Down
Loading