Skip to content

Commit

Permalink
BREAKING: remove deno vendor (#25343)
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua authored Sep 3, 2024
1 parent 2533d68 commit 5f08d63
Show file tree
Hide file tree
Showing 26 changed files with 33 additions and 4,393 deletions.
128 changes: 5 additions & 123 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,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 @@ -463,7 +456,7 @@ pub enum DenoSubcommand {
Test(TestFlags),
Types,
Upgrade(UpgradeFlags),
Vendor(VendorFlags),
Vendor,
Publish(PublishFlags),
Help(HelpFlags),
}
Expand Down Expand Up @@ -3008,58 +3001,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 @@ -4751,24 +4700,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 @@ -9671,57 +9604,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 @@ -1217,11 +1217,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 @@ -1230,21 +1225,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 @@ -283,9 +283,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 @@ -19,4 +19,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

0 comments on commit 5f08d63

Please sign in to comment.