2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-09-30 12:06:38 -04:00
|
|
|
|
|
|
|
mod common;
|
|
|
|
mod global;
|
|
|
|
mod local;
|
|
|
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
use deno_npm::NpmSystemInfo;
|
|
|
|
use deno_runtime::deno_fs::FileSystem;
|
|
|
|
|
2024-07-09 23:06:08 -04:00
|
|
|
use crate::args::LifecycleScriptsConfig;
|
2024-09-04 10:00:44 -04:00
|
|
|
use crate::args::NpmInstallDepsProvider;
|
2023-09-30 12:06:38 -04:00
|
|
|
use crate::util::progress_bar::ProgressBar;
|
|
|
|
|
|
|
|
pub use self::common::NpmPackageFsResolver;
|
2023-10-02 17:53:55 -04:00
|
|
|
|
2023-09-30 12:06:38 -04:00
|
|
|
use self::global::GlobalNpmPackageResolver;
|
|
|
|
use self::local::LocalNpmPackageResolver;
|
|
|
|
|
2023-10-02 17:53:55 -04:00
|
|
|
use super::cache::NpmCache;
|
2024-06-02 21:39:13 -04:00
|
|
|
use super::cache::TarballCache;
|
2023-10-02 17:53:55 -04:00
|
|
|
use super::resolution::NpmResolution;
|
2023-09-30 12:06:38 -04:00
|
|
|
|
2024-07-03 20:54:33 -04:00
|
|
|
#[allow(clippy::too_many_arguments)]
|
2023-09-30 12:06:38 -04:00
|
|
|
pub fn create_npm_fs_resolver(
|
|
|
|
fs: Arc<dyn FileSystem>,
|
2024-06-02 21:39:13 -04:00
|
|
|
npm_cache: Arc<NpmCache>,
|
2024-09-04 10:00:44 -04:00
|
|
|
npm_install_deps_provider: &Arc<NpmInstallDepsProvider>,
|
2023-09-30 12:06:38 -04:00
|
|
|
progress_bar: &ProgressBar,
|
|
|
|
resolution: Arc<NpmResolution>,
|
2024-06-03 17:17:08 -04:00
|
|
|
tarball_cache: Arc<TarballCache>,
|
2023-09-30 12:06:38 -04:00
|
|
|
maybe_node_modules_path: Option<PathBuf>,
|
|
|
|
system_info: NpmSystemInfo,
|
2024-07-09 23:06:08 -04:00
|
|
|
lifecycle_scripts: LifecycleScriptsConfig,
|
2023-09-30 12:06:38 -04:00
|
|
|
) -> Arc<dyn NpmPackageFsResolver> {
|
|
|
|
match maybe_node_modules_path {
|
|
|
|
Some(node_modules_folder) => Arc::new(LocalNpmPackageResolver::new(
|
2024-06-02 21:39:13 -04:00
|
|
|
npm_cache,
|
2023-09-30 12:06:38 -04:00
|
|
|
fs,
|
2024-09-04 10:00:44 -04:00
|
|
|
npm_install_deps_provider.clone(),
|
2023-09-30 12:06:38 -04:00
|
|
|
progress_bar.clone(),
|
|
|
|
resolution,
|
2024-06-02 21:39:13 -04:00
|
|
|
tarball_cache,
|
|
|
|
node_modules_folder,
|
2023-09-30 12:06:38 -04:00
|
|
|
system_info,
|
2024-07-09 23:06:08 -04:00
|
|
|
lifecycle_scripts,
|
2023-09-30 12:06:38 -04:00
|
|
|
)),
|
|
|
|
None => Arc::new(GlobalNpmPackageResolver::new(
|
2024-06-02 21:39:13 -04:00
|
|
|
npm_cache,
|
2023-09-30 12:06:38 -04:00
|
|
|
fs,
|
2024-06-02 21:39:13 -04:00
|
|
|
tarball_cache,
|
2023-09-30 12:06:38 -04:00
|
|
|
resolution,
|
|
|
|
system_info,
|
2024-09-24 15:23:57 -04:00
|
|
|
lifecycle_scripts,
|
2023-09-30 12:06:38 -04:00
|
|
|
)),
|
|
|
|
}
|
|
|
|
}
|