summaryrefslogtreecommitdiff
path: root/cli/args/mod.rs
AgeCommit message (Collapse)Author
2024-01-08perf: skip expanding exclude globs (#21817)David Sherret
We were calling `expand_glob` on our excludes, which is very expensive and unnecessary because we can pattern match while traversing instead. 1. Doesn't expand "exclude" globs. Instead pattern matches while walking the directory. 2. Splits up the "include" into base paths and applicable file patterns. This causes less pattern matching to occur because we're only pattern matching on patterns that might match and not ones in completely unrelated directories.
2024-01-03fix(cli): respect `exclude` option for `deno check` command (#21779)nokazn
This PR fixes #21658. - `check` subcommand sees `exclude` option in `deno.json`. When some paths passed with `check` command listed in `exclude`, they are ignored. - When some files are listed in `exclude` and imported indirectly among module graph, they are checked.
2024-01-01chore: update to Rust 1.75 (#21731)林炳权
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
2023-12-19fix(node): child_process IPC on Windows (#21597)Divy Srivastava
This PR implements the child_process IPC pipe between parent and child. The implementation uses Windows named pipes created by parent and passes the inheritable file handle to the child. I've also replace parts of the initial implementation which passed the raw parent fd to JS with resource ids instead. This way no file handle is exposed to the JS land (both parent and child). `IpcJsonStreamResource` can stream upto 800MB/s of JSON data on Win 11 AMD Ryzen 7 16GB (without `memchr` vectorization)
2023-12-17fix(jupyter): Deno.test() panic (#21606)Bartek Iwańczuk
Fixes https://github.com/denoland/deno/issues/21594 I verified locally that this fixes the problem. I'm working on testing harness for Jupyter kernel to catch regressions like this and will add it in a follow up PR.
2023-12-15refactor: update reg url (#21595)Bartek Iwańczuk
2023-12-15refactor: check if scope and package exist before publish (#21575)Bartek Iwańczuk
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
2023-12-13fix: implement child_process IPC (#21490)Divy Srivastava
This PR implements the Node child_process IPC functionality in Deno on Unix systems. For `fd > 2` a duplex unix pipe is set up between the parent and child processes. Currently implements data passing via the channel in the JSON serialization format.
2023-12-12refactor: better handling for registry urls (#21545)Bartek Iwańczuk
2023-12-07feat(unstable): ability to resolve specifiers with no extension, specifiers ↵David Sherret
for a directory, and TS files from JS extensions (#21464) Adds an `--unstable-sloppy-imports` flag which supports the following for `file:` specifiers: * Allows writing `./mod` in a specifier to do extension probing. - ex. `import { Example } from "./example"` instead of `import { Example } from "./example.ts"` * Allows writing `./routes` to do directory extension probing for files like `./routes/index.ts` * Allows writing `./mod.js` for *mod.ts* files. This functionality is **NOT RECOMMENDED** for general use with Deno: 1. It's not as optimal for perf: https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-2/ 1. It makes tooling in the ecosystem more complex in order to have to understand this. 1. The "Deno way" is to be explicit about what you're doing. It's better in the long run. 1. It doesn't work if published to the Deno registry because doing stuff like extension probing with remote specifiers would be incredibly slow. This is instead only recommended to help with migrating existing projects to Deno. For example, it's very useful for getting CJS projects written with import/export declaration working in Deno without modifying module specifiers and for supporting TS ESM projects written with `./mod.js` specifiers. This feature will output warnings to guide the user towards correcting their specifiers. Additionally, quick fixes are provided in the LSP to update these specifiers:
2023-12-06fix(task): handle node_modules/.bin directory with byonm (#21386)David Sherret
A bit hacky, but it works. Essentially, this will check for all the scripts in the node_modules/.bin directory then force them to run with Deno via deno_task_shell.
2023-11-17feat(unstable): Workspaces support (#20410)Bartek Iwańczuk
This commit adds unstable workspace support. This is extremely bare-bones and minimal first-pass at this. With this change `deno.json` supports specifying `workspaces` key, that accepts a list of subdirectories. Each workspace can have its own import map. It's required to specify a `"name"` and `"version"` properties in the configuration file for the workspace: ```jsonc // deno.json { "workspaces": [ "a", "b" }, "imports": { "express": "npm:express@5" } } ``` ``` jsonc // a/deno.json { "name": "a", "version": "1.0.2", "imports": { "kleur": "npm:kleur" } } ``` ```jsonc // b/deno.json { "name": "b", "version": "0.51.0", "imports": { "chalk": "npm:chalk" } } ``` `--unstable-workspaces` flag is required to use this feature: ``` $ deno run --unstable-workspaces mod.ts ``` --------- Co-authored-by: David Sherret <dsherret@gmail.com>
2023-11-10perf(cli): strace mode for ops (undocumented) (#21131)Matt Mastracci
Example usage: ``` # Trace every op except op_*tick* cargo run -- run --unstable -A --strace-ops=-tick '/Users/matt/Documents/github/deno/deno/ext/websocket/autobahn/autobahn_server.js # Trace any op matching op_*http* cargo run -- run --unstable -A --strace-ops=http ... ``` Example output: ``` [ 11.478] op_ws_get_buffer : Dispatched Slow [ 11.478] op_ws_get_buffer : Completed Slow [ 11.478] op_ws_send_binary : Dispatched Fast [ 11.478] op_ws_send_binary : Completed Fast [ 11.478] op_ws_next_event : Dispatched Async [ 11.478] op_try_close : Dispatched Fast [ 11.478] op_try_close : Completed Fast [ 11.478] op_timer_handle : Dispatched Fast [ 11.478] op_timer_handle : Completed Fast [ 11.478] op_sleep : Dispatched Asyn ```
2023-11-07fix(node): inspect ancestor directories when resolving cjs re-exports during ↵David Sherret
analysis (#21104) If a CJS re-export can't be resolved, it will check the ancestor directories, which is more similar to what `require` does at runtime.
2023-11-05chore: migrate to new deno_core and metrics (#21057)Matt Mastracci
- Uses the new OpMetrics system for sync and async calls - Partial revert of #21048 as we moved Array.fromAsync upstream to deno_core
2023-11-01fix(repl): jsxImportSource was not working (#21049)David Sherret
I made some fixes in deno_ast to make this possible and we forgot to update this.
2023-11-01feat: granular --unstable-* flags (#20968)Bartek Iwańczuk
This commit adds granular `--unstable-*` flags: - "--unstable-broadcast-channel" - "--unstable-ffi" - "--unstable-fs" - "--unstable-http" - "--unstable-kv" - "--unstable-net" - "--unstable-worker-options" - "--unstable-cron" These flags are meant to replace a "catch-all" flag - "--unstable", that gives a binary control whether unstable features are enabled or not. The downside of this flag that allowing eg. Deno KV API also enables the FFI API (though the latter is still gated with a permission). These flags can also be specified in `deno.json` file under `unstable` key. Currently, "--unstable" flag works the same way - I will open a follow up PR that will print a warning when using "--unstable" and suggest to use concrete "--unstable-*" flag instead. We plan to phase out "--unstable" completely in Deno 2.
2023-11-01feat: precompile JSX (#20962)Bartek Iwańczuk
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2023-11-01feat(unstable): `deno run --env` (#20300)Asher Gomez
This change adds the `--env=[FILE]` flag to the `run`, `compile`, `eval`, `install` and `repl` subcommands. Environment variables set in the CLI overwrite those defined in the `.env` file.
2023-10-31perf: use deno_native_certs crate (#18072)Divy Srivastava
Fixes #18071 Replace `rustls_native_certs` which links to Security framework. https://github.com/denoland/deno_native_certs uses dlopen to lazy load when needed.
2023-10-31feat: deno run --unstable-hmr (#20876)Bartek Iwańczuk
This commit adds `--unstable-hmr` flag, that enabled Hot Module Replacement. This flag works like `--watch` and accepts the same arguments. If HMR is not possible the process will be restarted instead. Currently HMR is only supported in `deno run` subcommand. Upon HMR a `CustomEvent("hmr")` will be dispatched that contains information which file was changed in its `details` property. --------- Co-authored-by: Valentin Anger <syrupthinker@gryphno.de> Co-authored-by: David Sherret <dsherret@gmail.com>
2023-10-25feat(unstable): ability to `npm install` then `deno run main.ts` (#20967)David Sherret
This PR adds a new unstable "bring your own node_modules" (BYONM) functionality currently behind a `--unstable-byonm` flag (`"unstable": ["byonm"]` in a deno.json). This enables users to run a separate install command (ex. `npm install`, `pnpm install`) then run `deno run main.ts` and Deno will respect the layout of the node_modules directory as setup by the separate install command. It also works with npm/yarn/pnpm workspaces. For this PR, the behaviour is opted into by specifying `--unstable-byonm`/`"unstable": ["byonm"]`, but in the future we may make this the default behaviour as outlined in https://github.com/denoland/deno/issues/18967#issuecomment-1761248941 This is an extremely rough initial implementation. Errors are terrible in this and the LSP requires frequent restarts. Improvements will be done in follow up PRs.
2023-10-24refactor: upgrade to deno_ast 0.31 and deno_graph 0.59 (#20965)David Sherret
2023-10-20feat(unstable): allow bare specifier for builtin node module (#20728)Yoshiya Hinosawa
closes #20566
2023-10-02refactor(npm): make `NpmCache`, `CliNpmRegistryApi`, and `NpmResolution` ↵David Sherret
internal to `npm::managed` (#20764)
2023-09-08fix: empty include in config file excludes all (#20404)Nayeem Rahman
2023-09-01Reland "feat(lsp): enable via config file detection (#20334)" (#20349)Nayeem Rahman
2023-08-26chore(core): bump and trim deps (#20265)Matt Mastracci
Skipping for a later follow-up: - base64: #20266 - notify - indexmap (will require follow-up in upstream projects)
2023-08-25fix(ext/tls): upgrade webpki version (#20285)Matt Mastracci
This removes a webpki version that was showing up as vulnerable to https://github.com/briansmith/webpki/issues/69. Needed to upgrade `reqwest` as part of this.
2023-08-24refactor: use "deno_config" crate (#20260)Bartek Iwańczuk
Moved the configuration file to https://github.com/denoland/deno_config as we will have to use it in other projects.
2023-08-21refactor: upgrade deno_ast 0.28 and deno_semver 0.4 (#20193)David Sherret
2023-08-08refactor(cli): move `snapshot_from_lockfile` function to `deno_npm` (#20024)Yusuke Tanaka
This commit moves `snapshot_from_lockfile` function to [deno_npm crate](https://github.com/denoland/deno_npm). This allows this function to be called outside Deno CLI (in particular, Deno Deploy).
2023-08-06feat(unstable): rename `deno_modules` to `vendor` (#20065)David Sherret
Renames the unstable `deno_modules` directory and corresponding settings to `vendor` after feedback. Also causes the vendoring of the `node_modules` directory which can be disabled via `--node-modules-dir=false` or `"nodeModulesDir": false`.
2023-08-03feat(permissions): add "--deny-*" flags (#19070)Asher Gomez
This commit adds new "--deny-*" permission flags. These are complimentary to "--allow-*" flags. These flags can be used to restrict access to certain resources, even if they were granted using "--allow-*" flags or the "--allow-all" ("-A") flag. Eg. specifying "--allow-read --deny-read" will result in a permission error, while "--allow-read --deny-read=/etc" will allow read access to all FS but the "/etc" directory. Runtime permissions APIs ("Deno.permissions") were adjusted as well, mainly by adding, a new "PermissionStatus.partial" field. This field denotes that while permission might be granted to requested resource, it's only partial (ie. a "--deny-*" flag was specified that excludes some of the requested resources). Eg. specifying "--allow-read=foo/ --deny-read=foo/bar" and then querying for permissions like "Deno.permissions.query({ name: "read", path: "foo/" })" will return "PermissionStatus { state: "granted", onchange: null, partial: true }", denoting that some of the subpaths don't have read access. Closes #18804. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2023-08-02refactor: use '--reporter' and '--junit-path' flags for 'deno test' (#20031)Bartek Iwańczuk
This commit adds "--reporter" and "--junit-path" flags to "deno test" subcommand instead of using "--dot" and "--junit" flags.
2023-08-02feat(cli): Add dot test reporter (#19804)Bartek Iwańczuk
This commit adds a "dot" reporter to "deno test" subcommand, that can be activated using "--dot" flag. It provides a concise output using: - "." for passing test - "," for ignored test - "!" for failing test User output is silenced and not printed to the console. In non-TTY environments each result is printed on a separate line.
2023-08-02feat(unstable): optional `deno_modules` directory (#19977)David Sherret
Closes #15633
2023-07-27fix: error on invalid & unsupported jsx compiler options (#19954)David Sherret
2023-07-27feat(cli): Adding JUnit test reports (#19747)Cooper Benson
This commit makes the following changes - Created a `CompoundTestReporter` to allow us to use multiple reporters - Implements `JUnitTestReporter` which writes JUnit XML to a path - Added a CLI flag/option `--junit` that enables JUnit reporting. By default this writes the report to `stdout` (and disables pretty reporting). If a path is provided, it will write the JUnit report to that file while the pretty reporter writes to stdout like normal Output of `deno -- test --allow-all --unstable --location=http://js-unit-tests/foo/bar --junit cli/tests/unit/testing_test.ts ` ```xml <?xml version="1.0" encoding="UTF-8"?> <testsuites name="deno test" tests="7" failures="0" errors="0" time="0.176"> <testsuite name="file:///Users/cooper/deno/deno/cli/tests/unit/testing_test.ts" tests="7" disabled="0" errors="0" failures="0"> <testcase name="testWrongOverloads" time="0.012"> </testcase> <testcase name="nameOfTestCaseCantBeEmpty" time="0.009"> </testcase> <testcase name="invalidStepArguments" time="0.008"> </testcase> <testcase name="nameOnTextContext" time="0.029"> <properties> <property name="step[passed]" value="step ... nested step"/> <property name="step[passed]" value="step"/> </properties> </testcase> <testcase name="originOnTextContext" time="0.030"> <properties> <property name="step[passed]" value="step ... nested step"/> <property name="step[passed]" value="step"/> </properties> </testcase> <testcase name="parentOnTextContext" time="0.030"> <properties> <property name="step[passed]" value="step ... nested step"/> <property name="step[passed]" value="step"/> </properties> </testcase> <testcase name="explicit undefined for boolean options" time="0.009"> </testcase> </testsuite> </testsuites> ```
2023-06-15refactor(flags): move watch flags into subcommand structs (#19516)David Sherret
Moves the watch setting out of the `Flags` struct and into the individual subcommands
2023-06-14fix: reload config files on watcher restarts (#19487)David Sherret
Closes #19468
2023-06-13fix(lsp): don't pre-load documents matched in the config file's "exclude" ↵David Sherret
(#19431) This prevents documents specified in a deno.json's "exclude" from being pre-loaded by the lsp. For example, someone may have something like: ```jsonc // deno.json { "exclude": [ "dist" // build directory ] } ```
2023-06-10chore(tests): test_util - Add `PathRef` (#19450)David Sherret
This adds a new `PathRef` struct to test_util for making it easier to work with paths in test code. I'm going to expand on this more in the future.
2023-06-09fix(config): do not canonicalize config file path before loading (#19436)David Sherret
I'm unsure why we canonicalize the config file path when loading and the canonicalization is causing issues in #19431 because everything in the lsp is not canonicalized except the config file (actually, the config file is only canonicalized when auto-discovered and not whens pecified). We also don't canonicalize module paths when loading them. Canonicalization was added in https://github.com/denoland/deno/pull/7621
2023-05-25fix(compile): handle when DENO_DIR is readonly (#19257)David Sherret
Closes #19253
2023-05-23fix: better error message for malformed glob (#19225)Bartek Iwańczuk
Before: ``` $ cargo run -- test "foo/*******/bar.ts" error: Pattern syntax error near position 6: wildcards are either regular `*` or recursive `**` ``` After: ``` $ cargo run -- test "foo/*******/bar.ts" error: Failed to expand glob: "foo/*******/bar.ts" Caused by: Pattern syntax error near position 6: wildcards are either regular `*` or recursive `**` ``` --------- Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2023-05-23feat: add support for globs in the config file and CLI arguments for files ↵Bartek Iwańczuk
(#19102) Follow up to https://github.com/denoland/deno/pull/19084. This commit adds support for globs in the configuration file as well as CLI arguments for files. With this change users can now use glob syntax for "include" and "exclude" fields, like so: ```json { "lint": { "include": [ "directory/test*.ts", "other_dir/" ], "exclude": [ "other_dir/foo*.ts", "nested/nested2/*" ] }, "test": { "include": [ "data/test*.ts", "nested/", "tests/test[1-9].ts" ], "exclude": [ "nested/foo?.ts", "nested/nested2/*" ] } } ``` Or in CLI args like so: ``` // notice quotes here; these values will be passed to Deno verbatim // and deno will perform glob expansion $ deno fmt --ignore="data/*.ts" $ deno lint "data/**/*.ts" ``` Closes https://github.com/denoland/deno/issues/17971 Closes https://github.com/denoland/deno/issues/6365
2023-05-22feat(lsp): support lockfile and node_modules directory (#19203)David Sherret
This adds support for the lockfile and node_modules directory to the lsp. In the case of the node_modules directory, it is only enabled when explicitly opted into via `"nodeModulesDir": true` in the configuration file. This is to reduce the language server automatically modifying the node_modules directory when the user doesn't want it to. Closes #16510 Closes #16373
2023-05-19feat(vendor): support for npm specifiers (#19186)David Sherret
We never properly added support for this. This fixes vendoring when it has npm or node specifiers. Vendoring occurs by adding a `"nodeModulesDir": true` property to deno.json then it uses a local node_modules directory. This can be opted out by setting `"nodeModulesDir": false` or running with `--node-modules-dir=false`. Closes #18090 Closes #17210 Closes #17619 Closes #16778