1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00

remove --unstable flag from CLI features (#10190)

This commit is contained in:
Bartek Iwańczuk 2021-04-27 12:44:36 +02:00 committed by GitHub
parent 83770e898e
commit baf7092ea2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 112 deletions

View file

@ -482,12 +482,12 @@ fn compile_subcommand<'a, 'b>() -> App<'a, 'b> {
.takes_value(true) .takes_value(true)
.possible_values(&["x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-apple-darwin", "aarch64-apple-darwin"]) .possible_values(&["x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-apple-darwin", "aarch64-apple-darwin"])
) )
.about("Compile the script into a self contained executable") .about("UNSTABLE: Compile the script into a self contained executable")
.long_about( .long_about(
"Compiles the given script into a self contained executable. "UNSTABLE: Compiles the given script into a self contained executable.
deno compile --unstable -A https://deno.land/std/http/file_server.ts deno compile -A https://deno.land/std/http/file_server.ts
deno compile --unstable --output /usr/local/bin/color_util https://deno.land/std/examples/colors.ts deno compile --output /usr/local/bin/color_util https://deno.land/std/examples/colors.ts
Any flags passed which affect runtime behavior, such as '--unstable', Any flags passed which affect runtime behavior, such as '--unstable',
'--allow-*', '--v8-flags', etc. are encoded into the output executable and used '--allow-*', '--v8-flags', etc. are encoded into the output executable and used
@ -751,7 +751,7 @@ Ignore formatting a file by adding an ignore comment at the top of the file:
.takes_value(true) .takes_value(true)
.use_delimiter(true) .use_delimiter(true)
.require_equals(true) .require_equals(true)
.help("Ignore formatting particular source files. Use with --unstable"), .help("Ignore formatting particular source files"),
) )
.arg( .arg(
Arg::with_name("files") Arg::with_name("files")
@ -795,7 +795,7 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
.arg( .arg(
Arg::with_name("json") Arg::with_name("json")
.long("json") .long("json")
.help("Outputs the information in JSON format") .help("UNSTABLE: Outputs the information in JSON format")
.takes_value(false), .takes_value(false),
) )
} }
@ -873,25 +873,25 @@ https://deno.land/manual/getting_started/setup_your_environment#editors-and-ides
fn lint_subcommand<'a, 'b>() -> App<'a, 'b> { fn lint_subcommand<'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name("lint") SubCommand::with_name("lint")
.about("Lint source files") .about("UNSTABLE: Lint source files")
.long_about( .long_about(
"Lint JavaScript/TypeScript source code. "UNSTABLE: Lint JavaScript/TypeScript source code.
deno lint --unstable deno lint
deno lint --unstable myfile1.ts myfile2.js deno lint myfile1.ts myfile2.js
Print result as JSON: Print result as JSON:
deno lint --unstable --json deno lint --json
Read from stdin: Read from stdin:
cat file.ts | deno lint --unstable - cat file.ts | deno lint -
cat file.ts | deno lint --unstable --json - cat file.ts | deno lint --json -
List available rules: List available rules:
deno lint --unstable --rules deno lint --rules
Ignore diagnostics on the next line by preceding it with an ignore comment and Ignore diagnostics on the next line by preceding it with an ignore comment and
rule name: rule name:
@ -914,7 +914,6 @@ Ignore linting a file by adding an ignore comment at the top of the file:
.arg( .arg(
Arg::with_name("ignore") Arg::with_name("ignore")
.long("ignore") .long("ignore")
.requires("unstable")
.takes_value(true) .takes_value(true)
.use_delimiter(true) .use_delimiter(true)
.require_equals(true) .require_equals(true)
@ -982,8 +981,7 @@ fn test_subcommand<'a, 'b>() -> App<'a, 'b> {
Arg::with_name("no-run") Arg::with_name("no-run")
.long("no-run") .long("no-run")
.help("Cache test modules, but don't run tests") .help("Cache test modules, but don't run tests")
.takes_value(false) .takes_value(false),
.requires("unstable"),
) )
.arg( .arg(
Arg::with_name("fail-fast") Arg::with_name("fail-fast")
@ -1010,10 +1008,9 @@ fn test_subcommand<'a, 'b>() -> App<'a, 'b> {
.long("coverage") .long("coverage")
.require_equals(true) .require_equals(true)
.takes_value(true) .takes_value(true)
.requires("unstable")
.conflicts_with("inspect") .conflicts_with("inspect")
.conflicts_with("inspect-brk") .conflicts_with("inspect-brk")
.help("Collect coverage profile data"), .help("UNSTABLE: Collect coverage profile data"),
) )
.arg( .arg(
Arg::with_name("files") Arg::with_name("files")
@ -1333,11 +1330,10 @@ fn seed_arg<'a, 'b>() -> Arg<'a, 'b> {
fn watch_arg<'a, 'b>() -> Arg<'a, 'b> { fn watch_arg<'a, 'b>() -> Arg<'a, 'b> {
Arg::with_name("watch") Arg::with_name("watch")
.requires("unstable")
.long("watch") .long("watch")
.help("Watch for file changes and restart process automatically") .help("UNSTABLE: Watch for file changes and restart process automatically")
.long_help( .long_help(
"Watch for file changes and restart process automatically. "UNSTABLE: Watch for file changes and restart process automatically.
Only local files from entry point module graph are watched.", Only local files from entry point module graph are watched.",
) )
} }
@ -2010,13 +2006,7 @@ mod tests {
#[test] #[test]
fn run_watch() { fn run_watch() {
let r = flags_from_vec(svec![ let r = flags_from_vec(svec!["deno", "run", "--watch", "script.ts"]);
"deno",
"run",
"--unstable",
"--watch",
"script.ts"
]);
let flags = r.unwrap(); let flags = r.unwrap();
assert_eq!( assert_eq!(
flags, flags,
@ -2025,7 +2015,6 @@ mod tests {
script: "script.ts".to_string(), script: "script.ts".to_string(),
}, },
watch: true, watch: true,
unstable: true,
..Flags::default() ..Flags::default()
} }
); );
@ -2228,7 +2217,7 @@ mod tests {
} }
); );
let r = flags_from_vec(svec!["deno", "fmt", "--watch", "--unstable"]); let r = flags_from_vec(svec!["deno", "fmt", "--watch"]);
assert_eq!( assert_eq!(
r.unwrap(), r.unwrap(),
Flags { Flags {
@ -2239,7 +2228,6 @@ mod tests {
ext: "ts".to_string(), ext: "ts".to_string(),
}, },
watch: true, watch: true,
unstable: true,
..Flags::default() ..Flags::default()
} }
); );
@ -2249,7 +2237,6 @@ mod tests {
"fmt", "fmt",
"--check", "--check",
"--watch", "--watch",
"--unstable",
"foo.ts", "foo.ts",
"--ignore=bar.js" "--ignore=bar.js"
]); ]);
@ -2263,7 +2250,6 @@ mod tests {
ext: "ts".to_string(), ext: "ts".to_string(),
}, },
watch: true, watch: true,
unstable: true,
..Flags::default() ..Flags::default()
} }
); );
@ -2283,13 +2269,7 @@ mod tests {
#[test] #[test]
fn lint() { fn lint() {
let r = flags_from_vec(svec![ let r = flags_from_vec(svec!["deno", "lint", "script_1.ts", "script_2.ts"]);
"deno",
"lint",
"--unstable",
"script_1.ts",
"script_2.ts"
]);
assert_eq!( assert_eq!(
r.unwrap(), r.unwrap(),
Flags { Flags {
@ -2302,17 +2282,12 @@ mod tests {
json: false, json: false,
ignore: vec![], ignore: vec![],
}, },
unstable: true,
..Flags::default() ..Flags::default()
} }
); );
let r = flags_from_vec(svec![ let r =
"deno", flags_from_vec(svec!["deno", "lint", "--ignore=script_1.ts,script_2.ts"]);
"lint",
"--unstable",
"--ignore=script_1.ts,script_2.ts"
]);
assert_eq!( assert_eq!(
r.unwrap(), r.unwrap(),
Flags { Flags {
@ -2325,12 +2300,11 @@ mod tests {
PathBuf::from("script_2.ts") PathBuf::from("script_2.ts")
], ],
}, },
unstable: true,
..Flags::default() ..Flags::default()
} }
); );
let r = flags_from_vec(svec!["deno", "lint", "--unstable", "--rules"]); let r = flags_from_vec(svec!["deno", "lint", "--rules"]);
assert_eq!( assert_eq!(
r.unwrap(), r.unwrap(),
Flags { Flags {
@ -2340,18 +2314,11 @@ mod tests {
json: false, json: false,
ignore: vec![], ignore: vec![],
}, },
unstable: true,
..Flags::default() ..Flags::default()
} }
); );
let r = flags_from_vec(svec![ let r = flags_from_vec(svec!["deno", "lint", "--json", "script_1.ts"]);
"deno",
"lint",
"--unstable",
"--json",
"script_1.ts"
]);
assert_eq!( assert_eq!(
r.unwrap(), r.unwrap(),
Flags { Flags {
@ -2361,7 +2328,6 @@ mod tests {
json: true, json: true,
ignore: vec![], ignore: vec![],
}, },
unstable: true,
..Flags::default() ..Flags::default()
} }
); );
@ -2894,13 +2860,7 @@ mod tests {
#[test] #[test]
fn bundle_watch() { fn bundle_watch() {
let r = flags_from_vec(svec![ let r = flags_from_vec(svec!["deno", "bundle", "--watch", "source.ts"]);
"deno",
"bundle",
"--watch",
"--unstable",
"source.ts"
]);
assert_eq!( assert_eq!(
r.unwrap(), r.unwrap(),
Flags { Flags {
@ -2909,7 +2869,6 @@ mod tests {
out_file: None, out_file: None,
}, },
watch: true, watch: true,
unstable: true,
..Flags::default() ..Flags::default()
} }
) )

View file

@ -44,7 +44,6 @@ use crate::flags::Flags;
use crate::fmt_errors::PrettyJsError; use crate::fmt_errors::PrettyJsError;
use crate::media_type::MediaType; use crate::media_type::MediaType;
use crate::module_loader::CliModuleLoader; use crate::module_loader::CliModuleLoader;
use crate::program_state::exit_unstable;
use crate::program_state::ProgramState; use crate::program_state::ProgramState;
use crate::source_maps::apply_source_map; use crate::source_maps::apply_source_map;
use crate::specifier_handler::FetchHandler; use crate::specifier_handler::FetchHandler;
@ -320,10 +319,6 @@ async fn compile_command(
args: Vec<String>, args: Vec<String>,
target: Option<String>, target: Option<String>,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
if !flags.unstable {
exit_unstable("compile");
}
let debug = flags.log_level == Some(log::Level::Debug); let debug = flags.log_level == Some(log::Level::Debug);
let run_flags = let run_flags =
@ -382,9 +377,6 @@ async fn info_command(
maybe_specifier: Option<String>, maybe_specifier: Option<String>,
json: bool, json: bool,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
if json && !flags.unstable {
exit_unstable("--json");
}
let program_state = ProgramState::build(flags).await?; let program_state = ProgramState::build(flags).await?;
if let Some(specifier) = maybe_specifier { if let Some(specifier) = maybe_specifier {
let specifier = resolve_url_or_path(&specifier)?; let specifier = resolve_url_or_path(&specifier)?;
@ -441,16 +433,12 @@ async fn lsp_command() -> Result<(), AnyError> {
} }
async fn lint_command( async fn lint_command(
flags: Flags, _flags: Flags,
files: Vec<PathBuf>, files: Vec<PathBuf>,
list_rules: bool, list_rules: bool,
ignore: Vec<PathBuf>, ignore: Vec<PathBuf>,
json: bool, json: bool,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
if !flags.unstable {
exit_unstable("lint");
}
if list_rules { if list_rules {
tools::lint::print_rules_list(json); tools::lint::print_rules_list(json);
return Ok(()); return Ok(());
@ -898,10 +886,6 @@ async fn coverage_command(
exclude: Vec<String>, exclude: Vec<String>,
lcov: bool, lcov: bool,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
if !flags.unstable {
exit_unstable("coverage");
}
if files.is_empty() { if files.is_empty() {
println!("No matching coverage profiles found"); println!("No matching coverage profiles found");
std::process::exit(1); std::process::exit(1);

View file

@ -34,14 +34,6 @@ use std::fs::read;
use std::sync::Arc; use std::sync::Arc;
use std::sync::Mutex; use std::sync::Mutex;
pub fn exit_unstable(api_name: &str) {
eprintln!(
"Unstable API '{}'. The --unstable flag must be provided.",
api_name
);
std::process::exit(70);
}
/// This structure represents state of single "deno" program. /// This structure represents state of single "deno" program.
/// ///
/// It is shared by all created workers (thus V8 isolates). /// It is shared by all created workers (thus V8 isolates).

View file

@ -94,11 +94,8 @@ watcher. When Deno starts up with this flag it watches the entrypoint, and all
local files the entrypoint statically imports. Whenever one of these files is local files the entrypoint statically imports. Whenever one of these files is
changed on disk, the program will automatically be restarted. changed on disk, the program will automatically be restarted.
**Note: file watcher is a new feature and still unstable thus it requires
`--unstable` flag**
``` ```
deno run --watch --unstable main.ts deno run --watch main.ts
``` ```
### Integrity flags ### Integrity flags

View file

@ -254,13 +254,13 @@ formats by the `deno coverage` tool.
git clone https://github.com/oakserver/oak && cd oak git clone https://github.com/oakserver/oak && cd oak
# Collect your coverage profile with deno test --coverage=<output_directory> # Collect your coverage profile with deno test --coverage=<output_directory>
deno test --coverage=cov_profile --unstable deno test --coverage=cov_profile
# From this you can get a pretty printed diff of uncovered lines # From this you can get a pretty printed diff of uncovered lines
deno coverage --unstable cov_profile deno coverage cov_profile
# Or generate an lcov report # Or generate an lcov report
deno coverage --unstable cov_profile --lcov > cov_profile.lcov deno coverage cov_profile --lcov > cov_profile.lcov
# Which can then be further processed by tools like genhtml # Which can then be further processed by tools like genhtml
genhtml -o cov_profile/html cov_profile.lcov genhtml -o cov_profile/html cov_profile.lcov

View file

@ -1,13 +1,10 @@
## Compiling Executables ## Compiling Executables
> Since the compile functionality is relatively new, the `--unstable` flag has
> to be set in order for the command to work.
`deno compile [--output <OUT>] <SRC>` will compile the script into a `deno compile [--output <OUT>] <SRC>` will compile the script into a
self-contained executable. self-contained executable.
``` ```
> deno compile --unstable https://deno.land/std/examples/welcome.ts > deno compile https://deno.land/std/examples/welcome.ts
``` ```
If you omit the `OUT` parameter, the name of the executable file will be If you omit the `OUT` parameter, the name of the executable file will be
@ -20,14 +17,14 @@ execute the script must be specified at compilation time. This includes
permission flags. permission flags.
``` ```
> deno compile --unstable --allow-read --allow-net https://deno.land/std/http/file_server.ts > deno compile --allow-read --allow-net https://deno.land/std/http/file_server.ts
``` ```
[Script arguments](../getting_started/command_line_interface.md#script-arguments) [Script arguments](../getting_started/command_line_interface.md#script-arguments)
can be partially embedded. can be partially embedded.
``` ```
> deno compile --unstable --allow-read --allow-net https://deno.land/std/http/file_server.ts -p 8080 > deno compile --allow-read --allow-net https://deno.land/std/http/file_server.ts -p 8080
> ./file_server --help > ./file_server --help
``` ```

View file

@ -2,18 +2,15 @@
Deno ships with a built in code linter for JavaScript and TypeScript. Deno ships with a built in code linter for JavaScript and TypeScript.
**Note: linter is a new feature and still unstable thus it requires `--unstable`
flag**
```shell ```shell
# lint all JS/TS files in the current directory and subdirectories # lint all JS/TS files in the current directory and subdirectories
deno lint --unstable deno lint
# lint specific files # lint specific files
deno lint --unstable myfile1.ts myfile2.ts deno lint myfile1.ts myfile2.ts
# print result as JSON # print result as JSON
deno lint --unstable --json deno lint --json
# read from stdin # read from stdin
cat file.ts | deno lint --unstable - cat file.ts | deno lint -
``` ```
For more detail, run `deno lint --help`. For more detail, run `deno lint --help`.