fix: prefixed plugin package name (#4811)

Summary:
When distributing plugin over Marketplace. Currently there is an issue with downloading a plugin to `tmp` folder if the plugin `packageName` starts with `company-prefix/flipper-plugin-name`. It would throw `ENONET` error while trying to stream the response data into `tmp` folder.

## Changelog

- add support for prefixed plugin package names (`shopify/flipper-plugin-name`,...)

Pull Request resolved: https://github.com/facebook/flipper/pull/4811

Test Plan: - Try install a plugin from Marketplace which has `/` in the plugin `package.json` `name`.

Reviewed By: lblasa

Differential Revision: D46679195

Pulled By: passy

fbshipit-source-id: f330896dae9da7cbe101b1c6d7ed07667fb7ae0a
This commit is contained in:
Lukas Kurucz
2023-06-13 03:53:18 -07:00
committed by Facebook GitHub Bot
parent 0db4e99aff
commit 279a9e6b52

View File

@@ -27,6 +27,7 @@ import {
getInstalledPluginDetails, getInstalledPluginDetails,
getInstalledPlugins, getInstalledPlugins,
getPluginVersionInstallationDir, getPluginVersionInstallationDir,
getPluginDirNameFromPackageName,
installPluginFromFile, installPluginFromFile,
removePlugins, removePlugins,
getUpdatablePlugins, getUpdatablePlugins,
@@ -129,7 +130,10 @@ export class PluginManager {
`Downloading plugin "${title}" v${version} from "${downloadUrl}" to "${installationDir}".`, `Downloading plugin "${title}" v${version} from "${downloadUrl}" to "${installationDir}".`,
); );
const tmpDir = await getTempDirName(); const tmpDir = await getTempDirName();
const tmpFile = path.join(tmpDir, `${name}-${version}.tgz`); const tmpFile = path.join(
tmpDir,
`${getPluginDirNameFromPackageName(name)}-${version}.tgz`,
);
try { try {
const cancelationSource = axios.CancelToken.source(); const cancelationSource = axios.CancelToken.source();
if (await fs.pathExists(installationDir)) { if (await fs.pathExists(installationDir)) {