Skip to content
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

refactor: switch to commonjs-fork of node-fetch #91

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions dist/src/PluginInfo.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PackageJsonInfo } from './PackageInfo';
export interface IPluginInfo {
readonly mainFile: string;
readonly location: string;
Expand All @@ -6,4 +7,7 @@ export interface IPluginInfo {
readonly dependencies: {
[name: string]: string;
};
readonly dependencyDetails?: {
[name: string]: PackageJsonInfo | undefined;
};
}
24 changes: 24 additions & 0 deletions dist/src/PluginManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type NodeJSGlobal = typeof global;
export interface PluginManagerOptions {
cwd: string;
pluginsPath: string;
versionsPath?: string;
sandbox: PluginSandbox;
npmRegistryUrl: string;
npmRegistryConfig: NpmRegistryConfig;
Expand All @@ -35,6 +36,7 @@ export interface InstallFromPathOptions {
}
export declare class PluginManager {
readonly options: PluginManagerOptions;
private versionManager;
private readonly vm;
private readonly installedPlugins;
private readonly npmRegistry;
Expand Down Expand Up @@ -87,6 +89,7 @@ export declare class PluginManager {
private installFromBitbucketLockFree;
private installFromCodeLockFree;
private installDependencies;
private linkDependencyToPlugin;
private unloadDependents;
private unloadWithDependents;
private isModuleAvailableFromHost;
Expand All @@ -100,10 +103,31 @@ export declare class PluginManager {
private load;
private unload;
private addPlugin;
/**
* Unlink a plugin from the specified version of package.
*
* @param plugin A plugin information to unlink
*/
private unlinkModule;
/**
* Link a plugin to the specified version of package.
*
* @param plugin A plugin information to link
* @returns A plugin information linked
*/
private linkModule;
private deleteAndUnloadPlugin;
private syncLock;
private syncUnlock;
private shouldIgnore;
private createPluginInfo;
/**
* Create a plugin information from the specified location.
*
* @param location A location of the plugin
* @param withDependencies If true, dependencies are also loaded
* @returns
*/
private createPluginInfoFromPath;
}
export {};
229 changes: 190 additions & 39 deletions dist/src/PluginManager.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/PluginManager.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/src/PluginVm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export declare class PluginVm {
private sandboxRequire;
private isCoreModule;
private isPlugin;
private hasDependency;
private tryResolveAsFile;
private tryResolveAsDirectory;
private getPluginSandbox;
Expand Down
32 changes: 31 additions & 1 deletion dist/src/PluginVm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/src/PluginVm.js.map

Large diffs are not rendered by default.

128 changes: 128 additions & 0 deletions dist/src/VersionManager.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { IPluginInfo } from "./PluginInfo";
import { PackageJsonInfo, PackageInfo } from "./PackageInfo";
export interface VersionManagerOptions {
cwd: string;
rootPath: string;
}
export declare const DefaultMainFile = "index.js";
/**
* A class to manage the versions of the downloaded packages.
*/
export declare class VersionManager {
readonly options: VersionManagerOptions;
constructor(options?: Partial<VersionManagerOptions>);
/**
* Ensure the root path exists.
*/
ensureRootPath(): Promise<void>;
/**
* Get the location for the specified package name and version.
*
* @param packageInfo A package information to get the location
* @returns A location for the specified package name and version
*/
getPath(packageInfo: PackageInfo): string;
/**
* Resolve the path for the specified package name and version.
*
* @param name A package name to resolve
* @param version A package version to resolve
* @returns
*/
resolvePath(name: string, version: string): Promise<string | undefined>;
/**
* Download a package using a downloader.
* Downloaded files are stored in the rootPath as directory named as `name@version`.
*
* @param downloader A downloader object that implements the download method
* @param registryInfo A package info to download
* @returns A information for the downloaded package
*/
download(downloader: {
download: (destinationDirectory: string, registryInfo: PackageJsonInfo) => Promise<string>;
}, registryInfo: PackageJsonInfo): Promise<PackageJsonInfo>;
/**
* Uninstall packages which are not used by other packages.
*
* @param installedPlugins A list of the installed packages.
* @returns A list of the uninstalled packages.
*/
uninstallOrphans(installedPlugins: Array<IPluginInfo>): Promise<IPluginInfo[]>;
/**
* Unload a version of a plugin if it is not used by any other plugin
*
* @param pluginInfo A plugin information to uninstall
* @returns true if the version was unloaded, false if it was used by another plugin
*/
uninstallOrphan(pluginInfo: IPluginInfo): Promise<boolean>;
/**
* Create a plugin information for the specified version.
*
* @param name A package name
* @param version A package version
* @param withDependencies A flag to load dependency packages
* @returns A plugin information for the specified version
*/
createVersionInfo(name: string, version: string, withDependencies?: boolean): Promise<IPluginInfo>;
/**
* Create a plugin information for the specified path.
*
* @param location A path to the package directory
* @param withDependencies A flag to load dependency packages
* @returns A plugin information for the specified path
*/
createVersionInfoFromPath(location: string, withDependencies?: boolean): Promise<IPluginInfo>;
/**
* Check whether the filename is satisfied with the specified package name and version.
*
* @param filename A filename to check
* @param name A package name to check
* @param version A package version to check
* @returns true if the filename is satisfied with the specified package name and version, otherwise false
*/
private checkModuleFilenameSatisfied;
/**
* Get the package information from the package directory.
*
* @param location A path to the package directory
* @returns A package information for the package directory
*/
private readPackageJsonFromPath;
/**
* List package directories in the specified base directory.
*
* @param baseDir A base directory to list
* @param scope A scope for packages
* @returns A list of the package directories
*/
private listVersionDirs;
/**
* Check whether the package is used by other packages.
*
* @param packageInfo A package information to check
* @param baseDir A base directory to check. If not specified, the rootPath is used.
* @returns true if the package is used by other packages, otherwise false
*/
private checkVersionUsedInDir;
/**
* Check whether the package is used by the specified package.
*
* @param packageInfo A package information to check
* @param packageDir A package directory to check
* @returns true if the package is used by the specified package, otherwise false
*/
private checkVersionUsedFromPackage;
/**
* Uninstall all of the orphaned packages.
*
* @param installedPlugins A list of the installed packages
* @returns A list of the uninstalled packages
*/
private uninstallOrphansLockFree;
/**
* Remove the specified version.
*
* @param pluginInfo A plugin information to remove
*/
private removeVersion;
}
Loading