mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
BREAKING: Rename 'deno fetch' subcommand to 'deno cache' (#4656)
This commit is contained in:
parent
62726430be
commit
caff550b6c
6 changed files with 47 additions and 47 deletions
48
cli/flags.rs
48
cli/flags.rs
|
@ -41,7 +41,7 @@ pub enum DenoSubcommand {
|
|||
code: String,
|
||||
as_typescript: bool,
|
||||
},
|
||||
Fetch {
|
||||
Cache {
|
||||
files: Vec<String>,
|
||||
},
|
||||
Fmt {
|
||||
|
@ -247,8 +247,8 @@ pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> {
|
|||
fmt_parse(&mut flags, m);
|
||||
} else if let Some(m) = matches.subcommand_matches("types") {
|
||||
types_parse(&mut flags, m);
|
||||
} else if let Some(m) = matches.subcommand_matches("fetch") {
|
||||
fetch_parse(&mut flags, m);
|
||||
} else if let Some(m) = matches.subcommand_matches("cache") {
|
||||
cache_parse(&mut flags, m);
|
||||
} else if let Some(m) = matches.subcommand_matches("info") {
|
||||
info_parse(&mut flags, m);
|
||||
} else if let Some(m) = matches.subcommand_matches("eval") {
|
||||
|
@ -311,7 +311,7 @@ If the flag is set, restrict these messages to errors.",
|
|||
.subcommand(bundle_subcommand())
|
||||
.subcommand(completions_subcommand())
|
||||
.subcommand(eval_subcommand())
|
||||
.subcommand(fetch_subcommand())
|
||||
.subcommand(cache_subcommand())
|
||||
.subcommand(fmt_subcommand())
|
||||
.subcommand(info_subcommand())
|
||||
.subcommand(install_subcommand())
|
||||
|
@ -447,7 +447,7 @@ fn info_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
};
|
||||
}
|
||||
|
||||
fn fetch_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
||||
fn cache_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
||||
reload_arg_parse(flags, matches);
|
||||
lock_args_parse(flags, matches);
|
||||
importmap_arg_parse(flags, matches);
|
||||
|
@ -459,7 +459,7 @@ fn fetch_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
.unwrap()
|
||||
.map(String::from)
|
||||
.collect();
|
||||
flags.subcommand = DenoSubcommand::Fetch { files };
|
||||
flags.subcommand = DenoSubcommand::Cache { files };
|
||||
}
|
||||
|
||||
fn lock_args_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
||||
|
@ -746,8 +746,8 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
|
|||
.arg(ca_file_arg())
|
||||
}
|
||||
|
||||
fn fetch_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||
SubCommand::with_name("fetch")
|
||||
fn cache_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||
SubCommand::with_name("cache")
|
||||
.arg(reload_arg())
|
||||
.arg(lock_arg())
|
||||
.arg(lock_write_arg())
|
||||
|
@ -761,13 +761,13 @@ fn fetch_subcommand<'a, 'b>() -> App<'a, 'b> {
|
|||
.min_values(1),
|
||||
)
|
||||
.arg(ca_file_arg())
|
||||
.about("Fetch the dependencies")
|
||||
.about("Cache the dependencies")
|
||||
.long_about(
|
||||
"Fetch and compile remote dependencies recursively.
|
||||
"Cache and compile remote dependencies recursively.
|
||||
|
||||
Download and compile a module with all of its static dependencies and save them
|
||||
in the local cache, without running any code:
|
||||
deno fetch https://deno.land/std/http/file_server.ts
|
||||
deno cache https://deno.land/std/http/file_server.ts
|
||||
|
||||
Future runs of this module will trigger no downloads or compilation unless
|
||||
--reload is specified.",
|
||||
|
@ -1300,7 +1300,7 @@ fn arg_hacks(mut args: Vec<String>) -> Vec<String> {
|
|||
"completions",
|
||||
"doc",
|
||||
"eval",
|
||||
"fetch",
|
||||
"cache",
|
||||
"fmt",
|
||||
"test",
|
||||
"info",
|
||||
|
@ -1612,12 +1612,12 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn fetch() {
|
||||
let r = flags_from_vec_safe(svec!["deno", "fetch", "script.ts"]);
|
||||
fn cache() {
|
||||
let r = flags_from_vec_safe(svec!["deno", "cache", "script.ts"]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
subcommand: DenoSubcommand::Fetch {
|
||||
subcommand: DenoSubcommand::Cache {
|
||||
files: svec!["script.ts"],
|
||||
},
|
||||
..Flags::default()
|
||||
|
@ -1938,17 +1938,17 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn fetch_importmap() {
|
||||
fn cache_importmap() {
|
||||
let r = flags_from_vec_safe(svec![
|
||||
"deno",
|
||||
"fetch",
|
||||
"cache",
|
||||
"--importmap=importmap.json",
|
||||
"script.ts"
|
||||
]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
subcommand: DenoSubcommand::Fetch {
|
||||
subcommand: DenoSubcommand::Cache {
|
||||
files: svec!["script.ts"],
|
||||
},
|
||||
import_map_path: Some("importmap.json".to_owned()),
|
||||
|
@ -1958,13 +1958,13 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn fetch_multiple() {
|
||||
fn cache_multiple() {
|
||||
let r =
|
||||
flags_from_vec_safe(svec!["deno", "fetch", "script.ts", "script_two.ts"]);
|
||||
flags_from_vec_safe(svec!["deno", "cache", "script.ts", "script_two.ts"]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
subcommand: DenoSubcommand::Fetch {
|
||||
subcommand: DenoSubcommand::Cache {
|
||||
files: svec!["script.ts", "script_two.ts"],
|
||||
},
|
||||
..Flags::default()
|
||||
|
@ -2417,10 +2417,10 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn fetch_with_cafile() {
|
||||
fn cache_with_cafile() {
|
||||
let r = flags_from_vec_safe(svec![
|
||||
"deno",
|
||||
"fetch",
|
||||
"cache",
|
||||
"--cert",
|
||||
"example.crt",
|
||||
"script.ts",
|
||||
|
@ -2429,7 +2429,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
subcommand: DenoSubcommand::Fetch {
|
||||
subcommand: DenoSubcommand::Cache {
|
||||
files: svec!["script.ts", "script_two.ts"],
|
||||
},
|
||||
ca_file: Some("example.crt".to_owned()),
|
||||
|
|
|
@ -282,7 +282,7 @@ async fn install_command(
|
|||
.map_err(ErrBox::from)
|
||||
}
|
||||
|
||||
async fn fetch_command(flags: Flags, files: Vec<String>) -> Result<(), ErrBox> {
|
||||
async fn cache_command(flags: Flags, files: Vec<String>) -> Result<(), ErrBox> {
|
||||
let main_module =
|
||||
ModuleSpecifier::resolve_url_or_path("./__$deno$fetch.ts").unwrap();
|
||||
let global_state = GlobalState::new(flags)?;
|
||||
|
@ -531,8 +531,8 @@ pub fn main() {
|
|||
code,
|
||||
as_typescript,
|
||||
} => eval_command(flags, code, as_typescript).boxed_local(),
|
||||
DenoSubcommand::Fetch { files } => {
|
||||
fetch_command(flags, files).boxed_local()
|
||||
DenoSubcommand::Cache { files } => {
|
||||
cache_command(flags, files).boxed_local()
|
||||
}
|
||||
DenoSubcommand::Fmt { check, files } => {
|
||||
async move { fmt::format(files, check) }.boxed_local()
|
||||
|
|
|
@ -41,7 +41,7 @@ async function testModuleDownload(): Promise<void> {
|
|||
cmd: [
|
||||
Deno.execPath(),
|
||||
"--reload",
|
||||
"fetch",
|
||||
"cache",
|
||||
"http://localhost:4545/std/examples/colors.ts",
|
||||
],
|
||||
stdout: "piped",
|
||||
|
|
|
@ -96,7 +96,7 @@ fn fetch_test() {
|
|||
let output = Command::new(deno_exe_path())
|
||||
.env("DENO_DIR", deno_dir.path())
|
||||
.current_dir(util::root_path())
|
||||
.arg("fetch")
|
||||
.arg("cache")
|
||||
.arg(module_url.to_string())
|
||||
.output()
|
||||
.expect("Failed to spawn script");
|
||||
|
@ -1031,12 +1031,12 @@ itest_ignore!(_035_cached_only_flag {
|
|||
|
||||
itest!(_036_import_map_fetch {
|
||||
args:
|
||||
"fetch --reload --importmap=importmaps/import_map.json importmaps/test.ts",
|
||||
"cache --reload --importmap=importmaps/import_map.json importmaps/test.ts",
|
||||
output: "036_import_map_fetch.out",
|
||||
});
|
||||
|
||||
itest!(_037_fetch_multiple {
|
||||
args: "fetch --reload fetch/test.ts fetch/other.ts",
|
||||
args: "cache --reload fetch/test.ts fetch/other.ts",
|
||||
check_stderr: true,
|
||||
http_server: true,
|
||||
output: "037_fetch_multiple.out",
|
||||
|
@ -1591,7 +1591,7 @@ fn cafile_fetch() {
|
|||
let output = Command::new(deno_exe_path())
|
||||
.env("DENO_DIR", deno_dir.path())
|
||||
.current_dir(util::root_path())
|
||||
.arg("fetch")
|
||||
.arg("cache")
|
||||
.arg("--cert")
|
||||
.arg(cafile)
|
||||
.arg(module_url.to_string())
|
||||
|
|
|
@ -7,7 +7,7 @@ const fetchProc = Deno.run({
|
|||
stderr: "null",
|
||||
cmd: [
|
||||
Deno.execPath(),
|
||||
"fetch",
|
||||
"cache",
|
||||
"--reload",
|
||||
"--lock=lock_write_fetch.json",
|
||||
"--lock-write",
|
||||
|
@ -23,7 +23,7 @@ const fetchCheckProc = Deno.run({
|
|||
stderr: "null",
|
||||
cmd: [
|
||||
Deno.execPath(),
|
||||
"fetch",
|
||||
"cache",
|
||||
"--lock=lock_write_fetch.json",
|
||||
"https_import.ts",
|
||||
],
|
||||
|
|
|
@ -1036,19 +1036,19 @@ three methods in the `Deno` namespace that provide this access.
|
|||
|
||||
### `Deno.compile()`
|
||||
|
||||
This works similar to `deno fetch` in that it can fetch code, compile it, but
|
||||
not run it. It takes up to three arguments, the `rootName`, optionally
|
||||
`sources`, and optionally `options`. The `rootName` is the root module which
|
||||
will be used to generate the resulting program. This is like the module name you
|
||||
would pass on the command line in `deno --reload run example.ts`. The `sources`
|
||||
is a hash where the key is the fully qualified module name, and the value is the
|
||||
text source of the module. If `sources` is passed, Deno will resolve all the
|
||||
modules from within that hash and not attempt to resolve them outside of Deno.
|
||||
If `sources` are not provided, Deno will resolve modules as if the root module
|
||||
had been passed on the command line. Deno will also cache any of these
|
||||
resources. The `options` argument is a set of options of type
|
||||
`Deno.CompilerOptions`, which is a subset of the TypeScript compiler options
|
||||
containing the ones supported by Deno.
|
||||
This works similar to `deno cache` in that it can fetch and cache the code,
|
||||
compile it, but not run it. It takes up to three arguments, the `rootName`,
|
||||
optionally `sources`, and optionally `options`. The `rootName` is the root
|
||||
module which will be used to generate the resulting program. This is like the
|
||||
module name you would pass on the command line in
|
||||
`deno --reload run example.ts`. The `sources` is a hash where the key is the
|
||||
fully qualified module name, and the value is the text source of the module. If
|
||||
`sources` is passed, Deno will resolve all the modules from within that hash and
|
||||
not attempt to resolve them outside of Deno. If `sources` are not provided, Deno
|
||||
will resolve modules as if the root module had been passed on the command line.
|
||||
Deno will also cache any of these resources. The `options` argument is a set of
|
||||
options of type `Deno.CompilerOptions`, which is a subset of the TypeScript
|
||||
compiler options containing the ones supported by Deno.
|
||||
|
||||
The method resolves with a tuple. The first argument contains any diagnostics
|
||||
(syntax or type errors) related to the code. The second argument is a map where
|
||||
|
|
Loading…
Add table
Reference in a new issue