Commit graph

311 commits

Author SHA1 Message Date
Asher Gomez d2b5254c33
chore: update std to 0.208.0 (#21318)
Re-attempt at #21284. I was more thorough this time.

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-12-02 03:20:06 +01:00
John Spurlock eae82b34d4
Update doc for deno fmt --no-semicolons arg. (#21414)
Include default, like other bools.

---------

Signed-off-by: John Spurlock <47259736+johnspurlock-skymethod@users.noreply.github.com>
2023-12-01 16:26:06 +00:00
Jakub Jirutka ae327d0a83
build(cli): allow to build without upgrade feature (#19910)
The self-upgrade feature is undesirable when deno is installed from
(Linux) distribution repository - using a system package manager. This
change will allow package maintainers to build deno with the "upgrade"
subcommand and background check disabled.

When the user runs `deno upgrade <args>` and the upgrade feature is
disabled, it will exit with error message explaining that this deno
binary was built without the upgrade feature.

Note: This patch is already used in the Alpine Linux’s
[deno](https://pkgs.alpinelinux.org/packages?name=deno) package.
2023-11-29 18:52:25 +00:00
scarf 2b7e145e56
feat(fmt): support formatting code blocks in Jupyter notebooks (#21310) 2023-11-27 10:32:12 -05:00
David Sherret a4ec7dfae0
feat(unstable): --unstable-unsafe-proto (#21313)
Closes https://github.com/denoland/deno/issues/21276
2023-11-25 11:41:21 -05:00
Divy Srivastava 89424f8e4a
perf: move "cli/js/40_testing.js" out of main snapshot (#21212)
Closes https://github.com/denoland/deno/issues/21136

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-11-25 04:46:16 +01:00
Luca Casonato 85fd8a7f22
fix: correct flag in tar & upload (#21327) 2023-11-24 14:05:47 +01:00
Bartek Iwańczuk 585cf2de89
feat(unstable): tar up directory with deno.json (#21228)
Co-authored-by: David Sherret <dsherret@gmail.com>
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-11-23 23:38:07 +00:00
citrusmunch 08f5db5c62
docs(cli/args/flags.rs): Update dead link for run example (#21277)
The `deno run` example in the help output uses
https://deno.land/std/examples/welcome.ts which no longer exists.

Replacing with https://examples.deno.land/hello-world.ts

Signed-off-by: citrusmunch <citrusmunch@users.noreply.github.com>
2023-11-20 23:59:13 +01:00
Bartek Iwańczuk 9534e6e113
feat(unstable): Workspaces support (#20410)
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-17 01:28:38 +00:00
Divy Srivastava ab0c637425
perf: move jupyter esm out of main snapshot (#21163)
Towards https://github.com/denoland/deno/issues/21136
2023-11-14 22:06:00 +01:00
David Sherret 6e1f3aa013
fix(install): should work with non-existent relative root (#21161)
Closes #21160
2023-11-13 09:44:01 -05:00
Divy Srivastava 9f4a45561f
perf: snapshot runtime ops (#21127)
Closes https://github.com/denoland/deno/issues/21135

~1ms startup time improvement

---------

Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2023-11-11 17:01:48 +00:00
Matt Mastracci 68607b593f
perf(cli): strace mode for ops (undocumented) (#21131)
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-10 10:41:24 -07:00
David Sherret 9201198efd
fix(node): inspect ancestor directories when resolving cjs re-exports during 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-07 09:56:06 -05:00
Matt Mastracci 485fade0b6
chore: migrate to new deno_core and metrics (#21057)
- 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-05 14:27:36 -07:00
Bartek Iwańczuk ee1e9a6434
fix(doc): require source files if --html or --lint used (#21072)
Fixes https://github.com/denoland/deno/issues/21067
Fixes https://github.com/denoland/deno/issues/21070
2023-11-03 17:06:18 +00:00
David Sherret 58d543a480
fix(repl): jsxImportSource was not working (#21049)
I made some fixes in deno_ast to make this possible and we forgot to
update this.
2023-11-01 23:04:54 +00:00
Bartek Iwańczuk 24c3c96958
feat: granular --unstable-* flags (#20968)
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-01 23:15:08 +01:00
Bartek Iwańczuk 587f2e0800
feat: precompile JSX (#20962)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2023-11-01 20:30:23 +00:00
Bartek Iwańczuk 8ea2d926a9
feat: deno doc --html (#21015)
This commit adds static documentation site generate to "deno doc"
subcommand.

Example:
```
$ deno doc --html --name="My library" ./mod.ts
# outputs to ./docs/

$ deno doc --html --name="My library" --output=./documentation/ ./mod.ts ./file2.js
# outputs to ./documentation/

$ deno doc --html --name="My library" ./**/mod.ts
# generate docs for all files with "mod.ts" name
```

Closes https://github.com/denoland/deno/issues/8233
2023-11-01 15:25:05 +00:00
Asher Gomez f8f4e77632
feat(unstable): deno run --env (#20300)
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-11-01 15:21:13 +00:00
David Sherret d1ef561dbf
feat: deno doc --lint (#21032)
Adds a new `--lint` flag to `deno doc` that surfaces three kinds of
diagnostics:

1. Diagnostic for non-exported type referenced in an exported type.
* Why? People often forget to export types from a module in TypeScript.
To supress this diagnostic, add an `@internal` jsdoc tag to the internal
type.
1. Diagnostic for missing return type or missing property type on a
**public** type.
* Why? Otherwise `deno doc` will not display good documentation. Adding
explicit types also helps with type checking performance.
1. Diagnostic for missing jsdoc on a **public** type.
* Why? Everything should be documented. This diagnostic can be supressed
by adding a jsdoc comment description.

If the lint passes, `deno doc` generates documentation as usual.

For example, checking for deno doc diagnostics on the CI:

```shellsession
$ deno doc --lint mod.ts second_entrypoint.ts > /dev/null
```

This feature is incredibly useful for library authors.

## Why not include this in `deno lint`?

1. The command needs the documenation output in order to figure out the
diagnostics.
1. `deno lint` doesn't understand where the entrypoints are. That's
critical for the diagnostics to be useful.
1. It's much more performant to do this while generating documentation.
1. There is precedence in rustdoc (ex. `#![warn(missing_docs)]`).

## Why not `--check`?

It is confusing with `deno run --check`, since that means to run type
checking (and confusing with `deno check --docs`).

## Output Future Improvement

The output is not ideal atm, but it's fine for a first pass. We will
improve it in the future.

Closes https://github.com/denoland/deno_lint/pull/972
Closes https://github.com/denoland/deno_lint/issues/970
Closes https://github.com/denoland/deno/issues/19356
2023-10-31 18:19:42 -04:00
Divy Srivastava ba6bd444b6
perf: use deno_native_certs crate (#18072)
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-31 12:55:46 +01:00
Bartek Iwańczuk 1713df1352
feat: deno run --unstable-hmr (#20876)
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-31 01:25:58 +01:00
Bartek Iwańczuk 48c5c3a3fb
feat(doc): support multiple file entry (#21018)
This commit adds support for multiple entry points to `deno doc`.

Unfortunately to achieve that, I had to change the semantics of the
command to explicitly require `--filter` parameter for filtering
symbols, instead of treating second free argument as the filter argument.

`deno doc --builtin` is still supported, but cannot be mixed with
actual entrypoints.
2023-10-30 23:58:57 +01:00
Bartek Iwańczuk e6ff84c9f9
chore: Remove 'UNSTABLE:' from 'deno compile' help (#21003)
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-10-28 01:54:52 +00:00
David Sherret be97170a19
feat(unstable): ability to npm install then deno run main.ts (#20967)
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-25 14:39:00 -04:00
David Sherret 59a5fe530f
refactor: upgrade to deno_ast 0.31 and deno_graph 0.59 (#20965) 2023-10-24 21:43:19 +00:00
Yoshiya Hinosawa fb73eb1e9d
feat(unstable): allow bare specifier for builtin node module (#20728)
closes #20566
2023-10-20 13:02:08 +09:00
Jesper van den Ende be7e2bd8c1
fix(cli): Support using both --watch and --inspect at the same time (#20660)
Fixes #20525
2023-10-06 23:33:14 +02:00
David Sherret 1ff525e25b
refactor(node): combine node resolution code for resolving a package subpath from external code (#20791)
We had two methods that did the same functionality.
2023-10-04 23:05:12 -04:00
David Sherret 148694eb35
refactor(npm): make NpmCache, CliNpmRegistryApi, and NpmResolution internal to npm::managed (#20764) 2023-10-02 17:53:55 -04:00
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
Kevin Whinnery a16ad526e9
docs: Improve inline docs for permissions (deno run --help) (#18757)
Hey there! I took a crack at improving these embedded docs [as requested
here](https://github.com/denoland/deno/issues/18685). These should
accurately reflect the functionality of the permission-related flags for
`deno run`.

### Highlights
* Adds human-readable argument string in the format [prescribed in the
docs](https://docs.rs/clap/latest/clap/struct.Arg.html#method.value_name)
* Keeps text description terse, but includes a relevant copy/pasteable
docs link
* Includes example argument usage/formatting
2023-04-27 02:49:59 +02:00
David Sherret 55a9977c62
refactor(compile): remove usage of ProcState and CliOptions (#18855) 2023-04-26 13:07:15 -04:00
David Sherret efa7c19890
refactor: upgrade to deno_npm 0.3.0 (#18671)
This allows us to specify the `@types/node` version constraint in the
CLI instead of in deno_npm.
2023-04-13 10:47:45 -04:00
Geert-Jan Zwiers aaebd6eb42
chore(docs): clarify what subcommands do not type-check by default (#18520)
The CLI docs suggested that all deno subcommands no longer type-check by
default. This is only the case for some subcommands, and this PR
clarifies the CLI docs in this regard.
2023-04-13 03:42:28 +02:00
David Sherret 17e4782140
fix(npm): eagerly reload package information when version from lockfile not found locally (#18673)
Closes #18624
2023-04-12 18:04:45 -04:00
David Sherret 0e3f62d444
fix(npm): cache bust npm specifiers more aggressively (#18636)
Part 1: #18622 
Part 2: This PR

Closes #16901

---------

Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-04-12 08:36:11 -04:00
David Sherret 5c7f76c570
fix(npm): reload an npm package's dependency's information when version not found (#18622)
This reloads an npm package's dependency's information when a
version/version req/tag is not found.

This PR applies only to dependencies of npm packages. It does NOT yet
cause npm specifiers to have their dependency information cache busted.
That requires a different solution, but this should help cache bust in
more scenarios.

Part of #16901, but doesn't close it yet
2023-04-06 21:41:19 -04:00
David Sherret d07aa4a072
refactor(npm): use deno_npm and deno_semver (#18602) 2023-04-06 18:46:44 -04:00
David Sherret e0429e2ad6
fix(repl): improve package.json support (#18497)
1. Fixes a cosmetic issue in the repl where it would display lsp warning
messages.
2. Lazily loads dependencies from the package.json on use.
3. Supports using bare specifiers from package.json in the REPL.

Closes #17929
Closes #18494
2023-03-30 10:43:16 -04:00
Bartek Iwańczuk 101abf3541
refactor(cli): remove Lazy<String> and fix help outputs (#18462)
This `Lazy<String>` calls were showing up on flamegraph and there's
really no point in using them.
2023-03-27 18:28:41 +02:00
Geert-Jan Zwiers a29d88b43b
feat(bench): add --no-run flag (#18433) 2023-03-26 14:55:58 +00:00
Leo Kettmeir 33362b88c3
chore: upgrade clap to v4 (#17333) 2023-03-26 06:06:18 +02:00
Bartek Iwańczuk 275dee60e7
refactor: make version and user_agent &'static str (#18400)
These caused a bunch of unnecessary allocations on each startup.
2023-03-23 23:27:58 +01:00
Cre3per eb25e50edb
fix(cli): restore deno run - to handle stdin as typescript (#18391)
Bug reported here shortly after merging `--ext` changes
https://github.com/denoland/deno/pull/17172#issuecomment-1480898098

Also found a missing `--check` in integration tests for `--ext` that
would have missed a bug if there was one.

Fixes #18392
2023-03-23 12:45:43 -04:00
Cre3per fd0658fb42
feat(cli): --ext parameter for run, compile, and bundle (#17172)
Adds `--ext` to `deno run`, closes #5088

Additionally

- Adds `--ext` to `deno compile` and `deno bundle`
2023-03-22 10:15:53 -04:00
Matt Mastracci a561cc28cd
chore(cli) Use with_context(|| format!(...)) rather than context(format!(...)) to avoid allocations in non-error path (#18332) 2023-03-21 12:13:32 -06:00
David Sherret 2fcf1f14cf
feat: TypeScript 5.0.2 (except decorators) (#18294)
This upgrades TypeScript to 5.0.2, but does not have ES decorator
support because swc does not support that yet.
2023-03-21 15:46:40 +00:00
Andreu Botella b64ec79268
feat(compile): Enable multiple roots for a standalone module graph (#17663)
This change will enable dynamic imports and web workers to use modules
not reachable from the main module, by passing a list of extra side
module roots as options to `deno compile`. 

This can be done by specifying "--include" flag that accepts a file path or a
URL. This flag can be specified multiple times, to include several modules.
The modules specified with "--include" flag, will be added to the produced
"eszip".
2023-03-19 00:43:07 +01:00
Leo Kettmeir 35196eab27
BREAKING(unstable): remove WebGPU (#18094)
This PR _**temporarily**_ removes WebGPU (which has behind the
`--unstable` flag in Deno), due to performance complications due to its
presence.

It will be brought back in the future; as a point of reference, Chrome
will ship WebGPU to stable on 26/04/2023.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-03-17 00:29:32 +01:00
Nick Hanley 1a3c2e2f1d
feat(repl): add DENO_REPL_HISTORY to change history file path (#18047) 2023-03-17 01:22:24 +09:00
David Sherret ca51f4f6c0
fix(npm): "not implemented scheme" message should properly show the scheme (#18209) 2023-03-15 15:23:30 -04:00
Bartek Iwańczuk 6f308b3af0
test: fix flaky resolve_import_map_flags_take_precedence test (#18182)
Trying to fix https://github.com/denoland/deno/issues/18180
2023-03-14 13:37:15 +02:00
Bartek Iwańczuk 48ede89f1f
refactor(core): resolve_url_or_path and resolve_url_or_path_deprecated (#18170)
This commit changes current "deno_core::resolve_url_or_path" API to
"resolve_url_or_path_deprecated" and adds new "resolve_url_or_path"
API that requires to explicitly pass the directory from which paths
should be resolved to. 

Some of the call sites were updated to use the new API, the reminder
of them will be updated in a follow up PR.

Towards landing https://github.com/denoland/deno/pull/15454
2023-03-14 01:12:09 +00:00
David Sherret a35c8e6588
fix(info/doc): add missing --no-lock and --lock flags (#18166)
Closes #18159
2023-03-13 17:04:00 -04:00
David Sherret bcb6ee9d08
refactor(npm): push npm struct creation to a higher level (#18139)
This has been bothering me for a while and it became more painful while
working on #18136 because injecting the shared progress bar became very
verbose. Basically we should move the creation of all these npm structs
up to a higher level.

This is a stepping stone for a future refactor where we can improve how
we create all our structs.
2023-03-12 23:32:59 -04:00
David Sherret 8db853514c
fix(check): regression where config "types" entries caused type checking errors (#18124)
Closes #18117
Closes #18121 (this is just over 10ms faster in a directory one up from
the root folder)

cc @nayeemrmn
2023-03-11 11:43:45 -05:00
Bartek Iwańczuk bb07e230d1
chore: update Rust to 1.68.0 (#18102) 2023-03-09 19:18:00 +00:00
Caleb Cox 0e3affcd5b
fix(cli): add space after period in --v8-flags (#18063)
Add space between period and "Any" in `--v8-flags` help text.
2023-03-07 17:07:28 +01:00
David Sherret 84bafd11d5
fix: lazily surface errors in package.json deps parsing (#17974)
Closes #17941
2023-03-03 18:27:05 -04:00
David Sherret b5b331e31a
fix(npm): skip analyzing more specifiers in package.json (#17938) 2023-02-25 02:16:26 +00:00
David Sherret 5683daf1aa
fix: ignore workspace specifiers in package.json (#17934)
Part of #17916
2023-02-24 19:27:50 -05:00
David Sherret a27d0885f4
feat: add DENO_NO_PACKAGE_JSON env var (#17926)
Depends on #17924

Part of #17916
2023-02-24 19:23:07 +00:00
David Sherret 7ad64283a1
fix(npm): package.json auto-discovery should respect --no-config and --no-npm (#17924)
Part of #17916
2023-02-24 13:51:21 -05:00
David Sherret 6233c0aff0
fix(npm): support bare specifiers in package.json having a path (#17903)
For example `import * as test from "package/path.js"`
2023-02-23 17:33:23 +00:00
David Sherret 344317ec50
feat(npm): support bare specifiers from package.json in more subcommands and language server (#17891) 2023-02-23 10:58:10 -05:00
David Sherret b15f9e60a0
feat(task): support scripts in package.json (#17887)
This is a super basic initial implementation. We don't create a
`node_modules/.bin` folder at the moment and add it to the PATH like we
should which is necessary to make command name resolution in the
subprocess work properly (ex. you run a script that launches another
script that then tries to launch an "npx command"... this won't work
atm).

Closes #17492
2023-02-22 22:45:35 -05:00
David Sherret ddc350780d
fix(npm): resolve node_modules dir relative to package.json instead of cwd (#17885) 2023-02-22 20:16:16 -05:00
David Sherret 3479bc7661
fix(npm): improve peer dependency resolution (#17835)
This PR fixes peer dependency resolution to only resolve peers based on
the current graph traversal path. Previously, it would resolve a peers
by looking at a graph node's ancestors, which is not correct because
graph nodes are shared by different resolutions.

It also stores more information about peer dependency resolution in the
lockfile.
2023-02-21 12:03:48 -05:00
Bartek Iwańczuk 4d1a14ca7f
feat: auto-discover package.json for npm dependencies (#17272)
This commits adds auto-discovery of "package.json" file when running
"deno run" and "deno task" subcommands. In case of "deno run" the
"package.json" is being looked up starting from the directory of the
script that is being run, stopping early if "deno.json(c)" file is found
(ie. FS tree won't be traversed "up" from "deno.json").

When "package.json" is discovered the "--node-modules-dir" flag is
implied, leading to creation of local "node_modules/" directory - we
did that, because most tools relying on "package.json" will expect
"node_modules/" directory to be present (eg. Vite). Additionally 
"dependencies" and "devDependencies" specified in the "package.json"
are downloaded on startup. 

This is a stepping stone to supporting bare specifier imports, but
the actual integration will be done in a follow up commit.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2023-02-20 19:14:06 +01:00
Geert-Jan Zwiers ff2e66aa38
chore(cli/test): stabilize coverage, doc, shuffle flags (#17661)
This PR removes the `UNSTABLE` mentions from the CLI docs for `deno test
--coverage/doc/shuffle`.
2023-02-16 00:50:30 +01:00
Bartek Iwańczuk 0f1349bca8
feat: Deprecate 'deno bundle' subcommand (#17695)
This commit adds a deprecation warning when using "deno bundle"
subcommand and removes it from the output of "deno help".
2023-02-14 02:13:44 +01:00
Serhiy Barhamon fc843d035c
feat(bench): Add JSON reporter for "deno bench" subcommand (#17595) 2023-02-12 17:40:45 +00:00
aryan02420 bbcb144a6d
fix(fmt): make fmt options CLI args less verbose (#17550)
Make deno fmt options CLI args less verbose #17546
2023-02-11 19:39:56 +02:00
David Sherret b3e88e0681
refactor: deno_graph 0.43 upgrade (#17692) 2023-02-09 22:00:23 -05:00
Leo Kettmeir 84a96110cd
refactor: rename deno specifiers to internal (#17655) 2023-02-05 17:49:20 +01:00
David Sherret fe11df09b1
fix(lsp): update document dependencies on configuration change (#17556) 2023-01-28 10:18:32 -05:00
David Sherret f5840bdcd3
chore: upgrade to Rust 1.67 (#17548)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-27 10:43:16 -05:00
David Sherret 34c14dbf99
fix: support import map specified as data uri (#17531) 2023-01-25 16:51:04 -05:00
Bartek Iwańczuk c6c8c91a6e
feat: embed import map in the config file (#17478)
This commit changes handling of config file to enable
specifying "imports" and "scopes" objects effectively making
the configuration file an import map.

"imports" and "scopes" take precedence over "importMap" configuration,
but have lower priority than "--importmap" CLI flag.

Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-01-25 21:13:40 +01:00
David Sherret b5b4887c4a
feat(fmt): make semi-colon option a boolean (#17527) 2023-01-25 15:06:00 -05:00
Leo Kettmeir f3711f28f4
feat(cli): add DENO_V8_FLAGS env var (#17313)
Closes #5669
2023-01-25 05:03:03 +01:00
Bartek Iwańczuk e1c51f3c0d
feat(fmt): add ability to configure semicolons (#17292)
Allows to change behavior of `deno fmt` to use "ASI" setting for
semicolons instead of always prefering them, this is done
by "--options-semi=asi" flag or `"semi": "asi"` setting
in the config file.
2023-01-24 21:07:00 +01:00
Leo Kettmeir 0204071e30
feat: log detection of config file (#17338)
Closes #14578
2023-01-24 15:41:22 +01:00
Bartek Iwańczuk bf237c6241
refactor: Move lockfile to a separate crate (#17503)
Moves the lockfile implementation to a separate crate so other projects
like Deploy can use it as well.
2023-01-23 23:41:02 +01:00
Andreu Botella 69ec45eac7
refactor(cli): Integrate standalone mode cert handling into Flags (#17419)
The way the standalone mode handles the `--cert` flag is different to
all other modes. This is because `--cert` takes a path to the
certificate file, which is directly added to the root cert store; except
for compile mode, where its byte contents are stored in the standalone
metadata, and they are added to the root cert store after the
`ProcState` is created.

This change instead changes `Flags::ca_file` (an `Option<String>`) into
`Flags::ca_data`, which can represent a `String` file path or a
`Vec<u8>` with the certificate contents. That way, standalone mode can
create a `ProcState` whose root cert store alreay contains the
certificate.

This change also adds a tests for certificates in standalone mode, since
there weren't any before.

This refactor will help with implementing web workers in standalone mode
in the future.
2023-01-18 01:18:24 +01:00
Divy Srivastava d5634164cb
chore: use rustfmt imports_granularity option (#17421)
Closes https://github.com/denoland/deno/issues/2699
Closes https://github.com/denoland/deno/issues/2347

Uses unstable rustfmt features. Since dprint invokes `rustfmt` we do not
need to switch the cargo toolchain to nightly. Do we care about
formatting stability of our codebase across Rust versions? (I don't)
2023-01-14 23:18:58 -05:00
Yiyu Lin fd85f840cd
refactor: clean up unwrap and clone (#17282)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-01-15 09:36:46 +05:30
David Sherret 01e02d3123
refactor: create enum for --builtin doc flag (#17423) 2023-01-14 12:39:56 -05:00
Geert-Jan Zwiers 6557642fc8
refactor(coverage): use FileFlags struct (#17388) 2023-01-13 16:56:29 -05:00
Geert-Jan Zwiers fa175d8cda
fix(cli/args): update value_name of inspect args to resolve broken completions (#17287)
This PR updates the name used in `clap::Arg::value_name` for the
`--inspect*` flags from `HOST:PORT` to `HOST_AND_PORT` because the
former causes an arguments error when using shell completions in the
`zsh` shell.
2023-01-09 13:29:43 +01:00
Geert-Jan Zwiers 84ef26ac9b
refactor(cli/tools): move flag and config logic to CliOptions (#17008)
Co-authored-by: David Sherret <dsherret@gmail.com>
2023-01-07 15:22:09 -05:00
David Sherret 7db729a42d
fix(npm): support old packages and registries with no integrity, but with a sha1sum (#17289)
Closes #17281
2023-01-06 11:36:12 -05:00
Doni Rubiagatra 39cbaa6d34
fix(cli): uninstall command accept short flags (#17259) 2023-01-06 02:09:39 +00:00
Yiyu Lin 896dd56b7a
refactor(cli,core,ext,rt): remove some unnecessary clone or malloc (#17274) 2023-01-05 14:29:50 -05:00
Geert-Jan Zwiers 4e6b78cb43
refactor(cli): clean up clones (#17268) 2023-01-05 12:33:09 -05:00
David Sherret 10e4b2e140
chore: update copyright year to 2023 (#17247)
Yearly tradition of creating extra noise in git.
2023-01-02 21:00:42 +00:00
David Sherret 8165cded14
fix: ignore local lockfile for deno install and uninstall (#17145)
Closes #17116
2022-12-20 12:00:57 -05:00