Commit graph

178 commits

Author SHA1 Message Date
Bartek Iwańczuk
bf07604113
feat: Add "deno jupyter" subcommand (#20337)
This commit adds "deno jupyter" subcommand which
provides a Deno kernel for Jupyter notebooks.

The implementation is mostly based on Deno's REPL and
reuses large parts of it (though there's some clean up that
needs to happen in follow up PRs). Not all functionality of
Jupyter kernel is implemented and some message type
are still not implemented (eg. "inspect_request") but
the kernel is fully working and provides all the capatibilities
that the Deno REPL has; including TypeScript transpilation
and npm packages support.

Closes https://github.com/denoland/deno/issues/13016

---------

Co-authored-by: Adam Powers <apowers@ato.ms>
Co-authored-by: Kyle Kelley <rgbkrk@gmail.com>
2023-09-16 02:42:09 +02:00
Matt Mastracci
947865c054
feat(cli): allow --log-level=trace for additional deep debugging (#20426)
This allows us to opt in to extremely detailed tracing from dependency
libraries, like so:

```
cargo run --features tracing/log,tracing/max_level_trace -- test --log-level=trace -A --unstable ./cli/tests/unit/serve_test.ts 
```

It will not impact normal operation as it requires the
`tracing/max_level_trace` and `tracing/log` to be active.

Note that tracing is already a dependency -- this just makes it a direct
dep of cli so we can access its features more easily.
2023-09-09 12:03:19 -06:00
David Sherret
9cac5601b8
fix(compile): support providing flags as args (#20422)
Closes #20413
2023-09-08 17:14:59 +00:00
Nayeem Rahman
17276a1df9
fix: empty include in config file excludes all (#20404) 2023-09-08 15:04:45 +01:00
Nayeem Rahman
e1fb48524d
Reland "feat(lsp): enable via config file detection (#20334)" (#20349) 2023-09-01 21:13:13 +01:00
Matt Mastracci
d104a09f79
chore(core): bump and trim deps (#20265)
Skipping for a later follow-up:

 - base64: #20266
 - notify
 - indexmap (will require follow-up in upstream projects)
2023-08-26 07:10:42 -06:00
Valentin Anger
a526cff0a9
feat(cli/tools): add TAP test reporter (#14390) (#20073)
This PR adds a test reporter for the [Test Anything
Protocol](https://testanything.org).

It makes the following implementation decisions:
- No TODO pragma, as there is no such marker in `Deno.test`
- SKIP pragma for `ignore`d tests
- Test steps are treated as TAP14 subtests
  - Support for this in consumers seems spotty
- Some consumers will incorrectly interpret these markers, resulting in
unexpected output
- Considering the lack of support, and to avoid implementation
complexity,
subtests are at most one level deep (all test steps are in the same
subtest)
- To accommodate consumers that use comments to indicate test-suites
(unspecced)
  - The test module path is output as a comment
  - This is disabled for `--parallel` testing
- Failure diagnostics are output as JSON, which is also valid YAML
- The structure is not specified, so the format roughly follows the spec
example:
  ```
  ---
  message: "Failed with error 'hostname peebles.example.com not found'"
  severity: fail
  found:
    hostname: 'peebles.example.com'
    address: ~
  wanted:
    hostname: 'peebles.example.com'
    address: '85.193.201.85'
  at:
    file: test/dns-resolve.c
    line: 142
  ...
  ```
2023-08-26 01:19:23 +02:00
Matt Mastracci
8bb4e10881
fix(ext/tls): upgrade webpki version (#20285)
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-25 23:40:25 +02:00
Bartek Iwańczuk
f9beb92818
refactor: use "deno_config" crate (#20260)
Moved the configuration file to https://github.com/denoland/deno_config
as we will have to use it in other projects.
2023-08-24 11:21:34 +02:00
David Sherret
5834d282d4
refactor: upgrade deno_ast 0.28 and deno_semver 0.4 (#20193) 2023-08-21 09:53:52 +00:00
Kira
ca9ba87d99
fix(cli) error gracefully when script arg is not present and --v8-flags is present in deno run (#20145)
Fix #20022, fix #19627 (duplicate)

#17333 upgraded clap from version 3.1 to version 4. clap version 3.2.0
(intentionally) broke a behavior that deno was relying on to make `deno
run --v8-flags=--help` work without specifying a file, see
clap-rs/clap#3793. The workaround was to make the script argument
required _unless_ `--v8-flags` is present. This broke the expectation
that all successfully parsed `run` commands have the script argument
set, leading to the panic on
`matches.remove_many::<String>("script_arg").unwrap()`.

Clap, as far as I was able to find out, does not currently offer a neat
solution to this problem. This PR adds logic to create and return a
custom clap error when a parsed run command does not have the script
argument.

I added an appropriate test.
2023-08-13 04:04:17 +02:00
Yusuke Tanaka
f2e30a6f79
refactor(cli): move snapshot_from_lockfile function to deno_npm (#20024)
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-08 10:07:29 -07:00
David Sherret
b9b0386948
feat(unstable): rename deno_modules to vendor (#20065)
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-06 21:56:56 -04:00
Asher Gomez
6fb7e8d93b
feat(permissions): add "--deny-*" flags (#19070)
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-03 13:19:19 +02:00
Bartek Iwańczuk
db287e216d
refactor: use '--reporter' and '--junit-path' flags for 'deno test' (#20031)
This commit adds "--reporter" and "--junit-path" flags to "deno test"
subcommand instead of using "--dot" and "--junit" flags.
2023-08-02 22:05:34 -04:00
Bartek Iwańczuk
029bdf0cd5
feat(cli): Add dot test reporter (#19804)
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-02 18:38:10 +02:00
David Sherret
1cefa831fd
feat(unstable): optional deno_modules directory (#19977)
Closes #15633
2023-08-02 00:49:09 +00:00
David Sherret
cfdef0c380
chore: remove println in DenoCompileBinaryWriter (#19976) 2023-07-29 14:06:47 +02:00
JasperVanEsveld
0ec4feaee7
feat(compile): Add --no-terminal to compile command (#17991) 2023-07-28 18:46:26 +03:00
David Sherret
02d6bbff2c
fix: error on invalid & unsupported jsx compiler options (#19954) 2023-07-27 12:15:39 -04:00
Cooper Benson
0e4d6d41ad
feat(cli): Adding JUnit test reports (#19747)
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-07-27 00:12:35 +02:00
David Sherret
cf16df00d9
fix(check): should bust check cache when json module or npm resolution changes (#19941)
A small part of #19928.
2023-07-26 17:23:07 -04:00
Bartek Iwańczuk
88885d9c2b
fix(lint): allow to use --rules with --rules-tags (#19754) 2023-07-25 17:24:06 -04:00
David Sherret
306b51d772
fix(vendor): do not panic vendoring with jsxImportSource and no jsx files (#19837)
Closes #19833
2023-07-14 18:10:42 -04:00
Matt Mastracci
8465bd0037
chore: update to Rust 1.71 (#19822) 2023-07-13 15:16:24 -06:00
David Sherret
2e7bcb422d
fix(vendor): support import mapped jsxImportSource (#19724)
Closes #16108
2023-07-05 12:43:22 -04:00
nasa
d82b5f3bec
fix(cli): Fix the bug where the command description is not displayed. (#19604) 2023-06-28 02:57:20 +02:00
David Sherret
fa63fd4610
refactor(flags): move watch flags into subcommand structs (#19516)
Moves the watch setting out of the `Flags` struct and into the
individual subcommands
2023-06-15 13:09:37 -04:00
David Sherret
84c793275b
fix: reload config files on watcher restarts (#19487)
Closes #19468
2023-06-14 22:29:19 +00:00
David Sherret
015ea60d25
fix(lsp): don't pre-load documents matched in the config file's "exclude" (#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-13 15:48:53 -04:00
Leo Kettmeir
e1be2bb80d
chore: update clap (#19467)
Also switches to use defer for all subcommands besides run.
2023-06-12 13:54:04 +02:00
David Sherret
7f15126f23
chore(tests): test_util - Add PathRef (#19450)
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-10 11:09:45 -04:00
David Sherret
5df735d3da
fix(config): do not canonicalize config file path before loading (#19436)
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-06-09 08:56:11 -04:00
David Sherret
55f0150854
refactor(compile): store the npm snapshot in the eszip (#19343) 2023-06-08 11:48:29 -04:00
David Sherret
da9db887e3
refactor: helpers methods on TypeCheckMode (#19393) 2023-06-07 10:09:10 -04:00
David Sherret
2ebd61ee1b
fix(compile): handle when DENO_DIR is readonly (#19257)
Closes #19253
2023-05-25 14:27:45 -04:00
David Sherret
91ca9904b5
refactor: upgrade to deno_npm 0.6 (#19244) 2023-05-24 16:23:10 -04:00
Bartek Iwańczuk
3d865949c2
fix: better error message for malformed glob (#19225)
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-23 17:35:12 +00:00
Bartek Iwańczuk
5874fc3d0a
feat: add support for globs in the config file and CLI arguments for files (#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-23 03:39:59 +02:00
David Sherret
bb37dfb5b7
feat(lsp): support lockfile and node_modules directory (#19203)
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-22 21:28:36 -04:00
David Sherret
cc406c8360
feat(vendor): support for npm specifiers (#19186)
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
2023-05-19 22:39:27 +00:00
David Sherret
680ae31db8
feat(cli): add nodeModulesDir option to config file (#19095)
This adds an option to disable or enable using a local `node_modules`
directory as a project wide setting.

https://github.com/denoland/manual/pull/659

Closes #17930
2023-05-18 18:10:44 -04:00
scarf
a45f7f237b
feat(cli): top-level exclude field in deno.json (#17778) 2023-05-18 16:55:10 -04:00
David Sherret
41f618a1df
fix(npm): improved optional dependency support (#19135)
Note: If the package information has already been cached, then this
requires running with `--reload` or for the registry information to be
fetched some other way (ex. the cache busting).

Closes #15544

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-05-17 17:38:50 -04:00
David Sherret
28aa489de9
feat(compile): unstable npm and node specifier support (#19005)
This is the initial support for npm and node specifiers in `deno
compile`. The npm packages are included in the binary and read from it via
a virtual file system. This also supports the `--node-modules-dir` flag,
dependencies specified in a package.json, and npm binary commands (ex.
`deno compile --unstable npm:cowsay`)

Closes #16632
2023-05-10 20:06:59 -04:00
David Sherret
913176313b
perf: lazily create RootCertStore (#18938) 2023-05-01 16:42:05 -04:00
David Sherret
9efed4c7a3
refactor(cli): remove ProcState - add CliFactory (#18900)
This removes `ProcState` and replaces it with a new `CliFactory` which
initializes our "service structs" on demand. This isn't a performance
improvement at the moment for `deno run`, but might unlock performance
improvements in the future.
2023-05-01 14:35:23 -04:00
David Sherret
94a148cdb6
refactor(cli): use CliMainWorker in standalone (#18880)
Uses `CliMainWorker` in all the cli code.
2023-05-01 08:59:38 -04:00
David Sherret
742cc3111c
refactor(cli): extract out ProcState from CliMainWorker (#18867) 2023-04-27 10:05:20 -04:00
scarf
90a5ef5e34
feat(cli): flatten deno.json configuaration (#17799) 2023-04-26 23:02:36 -04:00