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

BREAKING: remove deno vendor #25343

Merged
merged 4 commits into from
Sep 3, 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
128 changes: 5 additions & 123 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,6 @@ pub struct UpgradeFlags {
pub version_or_hash_or_channel: Option<String>,
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct VendorFlags {
pub specifiers: Vec<String>,
pub output_path: Option<String>,
pub force: bool,
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PublishFlags {
pub token: Option<String>,
Expand Down Expand Up @@ -470,7 +463,7 @@ pub enum DenoSubcommand {
Test(TestFlags),
Types,
Upgrade(UpgradeFlags),
Vendor(VendorFlags),
Vendor,
Publish(PublishFlags),
Help(HelpFlags),
}
Expand Down Expand Up @@ -3084,58 +3077,14 @@ update to a different location, use the --output flag:
})
}

// TODO(bartlomieju): this subcommand is now deprecated, remove it in Deno 2.
fn vendor_subcommand() -> Command {
command("vendor",
"⚠️ Warning: `deno vendor` is deprecated and will be removed in Deno 2.0.
Add `\"vendor\": true` to your `deno.json` or use the `--vendor` flag instead.

Vendor remote modules into a local directory.
"⚠️ `deno vendor` was removed in Deno 2.

Analyzes the provided modules along with their dependencies, downloads
remote modules to the output directory, and produces an import map that
maps remote specifiers to the downloaded files.
deno vendor main.ts
deno run --import-map vendor/import_map.json main.ts

Remote modules and multiple modules may also be specified:
deno vendor main.ts test.deps.ts jsr:@std/path",
See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations",
UnstableArgsConfig::ResolutionOnly
)
.hide(true)
.defer(|cmd| cmd
.arg(
Arg::new("specifiers")
.num_args(1..)
.action(ArgAction::Append)
.required_unless_present("help"),
)
.arg(
Arg::new("output")
.long("output")
.help("The directory to output the vendored modules to")
.value_parser(value_parser!(String))
.value_hint(ValueHint::DirPath),
)
.arg(
Arg::new("force")
.long("force")
.short('f')
.help(
"Forcefully overwrite conflicting files in existing output directory",
)
.action(ArgAction::SetTrue),
)
.arg(no_config_arg())
.arg(config_arg())
.arg(import_map_arg())
.arg(lock_arg())
.arg(node_modules_dir_arg())
.arg(vendor_arg())
.arg(reload_arg())
.arg(ca_file_arg())
.arg(unsafely_ignore_certificate_errors_arg())
)
}

fn publish_subcommand() -> Command {
Expand Down Expand Up @@ -4957,24 +4906,8 @@ fn upgrade_parse(flags: &mut Flags, matches: &mut ArgMatches) {
});
}

fn vendor_parse(flags: &mut Flags, matches: &mut ArgMatches) {
unstable_args_parse(flags, matches, UnstableArgsConfig::ResolutionOnly);
ca_file_arg_parse(flags, matches);
unsafely_ignore_certificate_errors_parse(flags, matches);
config_args_parse(flags, matches);
import_map_arg_parse(flags, matches);
lock_arg_parse(flags, matches);
node_modules_and_vendor_dir_arg_parse(flags, matches);
reload_arg_parse(flags, matches);

flags.subcommand = DenoSubcommand::Vendor(VendorFlags {
specifiers: matches
.remove_many::<String>("specifiers")
.map(|p| p.collect())
.unwrap_or_default(),
output_path: matches.remove_one::<String>("output"),
force: matches.get_flag("force"),
});
fn vendor_parse(flags: &mut Flags, _matches: &mut ArgMatches) {
flags.subcommand = DenoSubcommand::Vendor
}

fn publish_parse(flags: &mut Flags, matches: &mut ArgMatches) {
Expand Down Expand Up @@ -10104,57 +10037,6 @@ mod tests {
assert!(&error_message.contains("--watch[=<FILES>...]"));
}

#[test]
fn vendor_minimal() {
let r = flags_from_vec(svec!["deno", "vendor", "mod.ts",]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Vendor(VendorFlags {
specifiers: svec!["mod.ts"],
force: false,
output_path: None,
}),
..Flags::default()
}
);
}

#[test]
fn vendor_all() {
let r = flags_from_vec(svec![
"deno",
"vendor",
"--config",
"deno.json",
"--import-map",
"import_map.json",
"--lock",
"lock.json",
"--force",
"--output",
"out_dir",
"--reload",
"mod.ts",
"deps.test.ts",
]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Vendor(VendorFlags {
specifiers: svec!["mod.ts", "deps.test.ts"],
force: true,
output_path: Some(String::from("out_dir")),
}),
config_flag: ConfigFlag::Path("deno.json".to_owned()),
import_map_path: Some("import_map.json".to_string()),
lock: Some(String::from("lock.json")),
reload: true,
..Flags::default()
}
);
}

#[test]
fn task_subcommand() {
let r = flags_from_vec(svec!["deno", "task", "build", "hello", "world",]);
Expand Down
20 changes: 0 additions & 20 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,11 +1220,6 @@ impl CliOptions {
NPM_PROCESS_STATE.is_some()
}

/// Overrides the import map specifier to use.
pub fn set_import_map_specifier(&mut self, path: Option<ModuleSpecifier>) {
self.overrides.import_map_specifier = Some(path);
}

pub fn has_node_modules_dir(&self) -> bool {
self.maybe_node_modules_folder.is_some()
}
Expand All @@ -1233,21 +1228,6 @@ impl CliOptions {
self.maybe_node_modules_folder.as_ref()
}

pub fn with_node_modules_dir_path(&self, path: PathBuf) -> Self {
Self {
flags: self.flags.clone(),
initial_cwd: self.initial_cwd.clone(),
maybe_node_modules_folder: Some(path),
npmrc: self.npmrc.clone(),
maybe_lockfile: self.maybe_lockfile.clone(),
start_dir: self.start_dir.clone(),
overrides: self.overrides.clone(),
disable_deprecated_api_warning: self.disable_deprecated_api_warning,
verbose_deprecated_api_warning: self.verbose_deprecated_api_warning,
deno_dir_provider: self.deno_dir_provider.clone(),
}
}

pub fn node_modules_dir(
&self,
) -> Result<Option<NodeModulesDirMode>, AnyError> {
Expand Down
4 changes: 1 addition & 3 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,7 @@ async fn run_subcommand(flags: Arc<Flags>) -> Result<i32, AnyError> {
"This deno was built without the \"upgrade\" feature. Please upgrade using the installation method originally used to install Deno.",
1,
),
DenoSubcommand::Vendor(vendor_flags) => spawn_subcommand(async {
tools::vendor::vendor(flags, vendor_flags).await
}),
DenoSubcommand::Vendor => exit_with_message("⚠️ `deno vendor` was removed in Deno 2.\n\nSee the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations", 1),
DenoSubcommand::Publish(publish_flags) => spawn_subcommand(async {
tools::registry::publish(flags, publish_flags).await
}),
Expand Down
1 change: 0 additions & 1 deletion cli/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ pub mod serve;
pub mod task;
pub mod test;
pub mod upgrade;
pub mod vendor;
113 changes: 0 additions & 113 deletions cli/tools/vendor/analyze.rs

This file was deleted.

Loading