1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
Commit graph

465 commits

Author SHA1 Message Date
Nathan Whitaker
04f9db5b22
fix(node): Fix --allow-scripts with no deno.json (#24533)
We would resolve the wrong package.json, resulting in an inability to
run CJS (or other node-mode) scripts
2024-07-15 12:11:09 -07:00
David Sherret
29186d7e59
fix(workspace): do not resolve to self for npm pkg depending on matching req (#24591)
Closes #24584
2024-07-15 15:08:51 -04:00
David Sherret
9510a8b7d1
fix(config): regression - should not discover npm workspace for nested deno.json not in workspace (#24559)
Closes #24554
2024-07-12 15:33:30 -04:00
David Sherret
8ee14bd56a
refactor: move importMap with imports/scopes diagnostic to deno_config (#24553) 2024-07-12 12:48:53 -04:00
David Sherret
ba63740e7f
chore: @netlify/edge-bundler workaround until Deno 2.0 (#24532)
Hack for a few months until Deno 2.0. See code for details
2024-07-11 17:43:46 +00:00
David Sherret
4d2d764816
feat(jsr): support publishing jsr packages in npm workspaces (#24507)
Supports publishing an npm workspace with a directory structure similar
to the following:

- workspace
  - package.json
  - package-a
    - package.json
    - jsr.json
  - package-b
    - package.json
    - jsr.json

deno_config PR: https://github.com/denoland/deno_config/pull/77

Closes https://github.com/denoland/deno/issues/23638
2024-07-10 14:46:09 -04:00
Bartek Iwańczuk
8b34c4d75b
fix: memory leak when transpiling (#24490)
This commit fixes memory leak described in
https://github.com/denoland/deno/issues/24380.

This is done by upgrading following crates:
- deno_ast
- deno_graph
- eszip
- dprint-plugin-typescript
- deno_lint
- deno_doc
- deno_emit
2024-07-10 13:51:55 +00:00
Nathan Whitaker
ce7dc2be92
feat(node): Support executing npm package lifecycle scripts (preinstall/install/postinstall) (#24487)
Adds support for running npm package lifecycle scripts, opted into via a
new `--allow-scripts` flag.

With this PR, when running `deno cache` (or `DENO_FUTURE=1 deno
install`) you can specify the `--allow-scripts=pkg1,pkg2` flag to run
lifecycle scripts attached to the given packages.

Note at the moment this only works when `nodeModulesDir` is true (using
the local resolver).

When a package with un-run lifecycle scripts is encountered, we emit a
warning suggesting things may not work and to try running lifecycle
scripts. Additionally, if a package script implicitly requires
`node-gyp` and it's not found on the system, we emit a warning.

Extra things in this PR:
- Extracted out bits of `task.rs` into a separate module for reuse
- Added a couple fields to `process.config` in order to support
`node-gyp` (it relies on a few variables being there)
- Drive by fix to downloading new npm packages to test registry

---

TODO:
- [x] validation for allow-scripts args (make sure it looks like an npm
package)
- [x] make allow-scripts matching smarter
- [ ] figure out what issues this closes

---
Review notes:
- This adds a bunch of deps to our test registry due to using
`node-gyp`, so it's pretty noisy
2024-07-10 03:06:08 +00:00
Asher Gomez
eb46296e97
feat: deprecate deno vendor (#22183)
This commit deprecates `deno vendor` subcommand in favor
of using `--vendor` flag or `"vendor": true` setting in the config file.

The subcommand is still available (until Deno 2) but is hidden from
the help output.

Closes #20584

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-07-10 03:18:10 +02:00
muddlebee
ff5163af05
feat(cli): deno init --lib (#22499)
Closes #22287

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
2024-07-09 21:13:34 -04:00
HasanAlrimawi
fb6348500f
feat(compile): support --env (#24166)
Supported the use of --env flag with the compile subcommand, so that the
generated executable/binary file can access the passed env file.
2024-07-09 21:33:41 +00:00
David Sherret
43d10a558b
fix: do not download compilerOptions -> types when not type checking (#24473)
Closes https://github.com/denoland/deno/issues/22738
2024-07-09 17:07:16 -04:00
HasanAlrimawi
c3b168f5a2
fix: add warning for invalid unstable feature use in deno.json/jsonc (#24120) 2024-07-09 01:50:47 +00:00
David Sherret
86010bec09
fix(workspace): better cli file argument handling (#24447)
Closes https://github.com/denoland/deno/issues/24422
2024-07-08 14:12:10 +00:00
Marvin Hagemeister
1e97f0f148
feat: add __tests__ to test file detection defaults (#24443)
The `jest` test runner popularized putting tests into a `__tests__`
folder. Whilst many have switched to going with a `.test` suffix in the
file name these days, there are still many jest projects that have
`__tests__`. By adding this to the default test detection logic it makes
`deno test` discover those out of the box.
2024-07-08 15:19:59 +02:00
Luca Casonato
74ac29bae6
fix(permissions): handle ipv6 addresses correctly (#24397)
Also don't panic on invalid domain names and addresses.

Extracted with cleanups up from #24080

Co-authored-by: Yazan AbdAl-Rahman <yazan.abdalrahman@exalt.ps>
2024-07-05 23:45:06 +01:00
David Sherret
80df9aec1d
refactor: move FileCollector to deno_config (#24433) 2024-07-05 17:53:09 -04:00
Bartek Iwańczuk
0bbfd6fb3d
feat: Deprecate --lock-write flag (#24436)
This commit deprecates `--lock-write` flag by removing it from
the help output and printing a warning message when it's used.

Users should use `--frozen=false` instead which was added
in https://github.com/denoland/deno/pull/24355.

Towards https://github.com/denoland/deno/issues/24167.
2024-07-05 04:38:12 +02:00
David Sherret
f396b3d1c8
fix(publish): unfurling should always be done with the package json (#24435)
Closes https://github.com/denoland/deno/issues/24430
2024-07-05 00:41:01 +00:00
David Sherret
147411e64b
feat: npm workspace and better Deno workspace support (#24334)
Adds much better support for the unstable Deno workspaces as well as
support for npm workspaces. npm workspaces is still lacking in that we
only install packages into the root node_modules folder. We'll make it
smarter over time in order for it to figure out when to add node_modules
folders within packages.

This includes a breaking change in config file resolution where we stop
searching for config files on the first found package.json unless it's
in a workspace. For the previous behaviour, the root deno.json needs to
be updated to be a workspace by adding `"workspace":
["./path-to-pkg-json-folder-goes-here"]`. See details in
https://github.com/denoland/deno_config/pull/66

Closes #24340
Closes #24159
Closes #24161
Closes #22020
Closes #18546
Closes #16106
Closes #24160
2024-07-04 00:54:33 +00:00
HasanAlrimawi
3324d7203e
fix(compile): prevent setting unstable feature twice (#24381)
Prevent panic when enabling a feature that is already enabled by
removing duplicate features.

Closes #22015

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-07-02 23:15:10 +00:00
Nathan Whitaker
c13b6d1413
feat(cli): Add --frozen flag to error out if lockfile is out of date (#24355)
Closes #18296.

Adds a `--frozen` (alias `--frozen-lockfile`) flag that errors out if
the lockfile is out of date. This is useful for running in CI (where an
out of date lockfile is usually a mistake) or to prevent accidental
changes in dependencies.

![Screenshot 2024-06-26 at 7 11
13 PM](https://github.com/denoland/deno/assets/17734409/538404b8-b422-4f05-89e8-4c9b1c248576)
2024-07-02 15:00:16 -07:00
Bartek Iwańczuk
8db420d552
chore: upgrade to reqwest 0.12.4 and rustls 0.22 (#24388)
Reland of https://github.com/denoland/deno/pull/24056 that doesn't
suffer from the problem that was discovered in
https://github.com/denoland/deno/pull/24261.

It uses upgraded `hyper` and `hyper-util` that fixed the previous
problem in https://github.com/hyperium/hyper/pull/3691.
2024-07-02 02:09:47 +02:00
Nathan Whitaker
bc8a0e6e68
refactor(cli): Create wrapper around deno_lockfile::Lockfile (#24366)
As suggested in
https://github.com/denoland/deno/pull/24355#discussion_r1657875422.

I wasn't able to hide the mutex stuff as much as I'd like (ended up just
adding an escape hatch `inner()` method that locks the inner mutex),
because you can't return references to the inner fields through a mutex.

This is mostly motivated by the frozen lockfile changes
2024-06-28 17:18:21 -07:00
Leo Kettmeir
ec9963570b
chore: update deno_doc (#24308) 2024-06-28 05:03:51 -07:00
Bartek Iwańczuk
2a2ff96be1
fix(ext/node): discover .npmrc in user's homedir (#24021)
This commit adds discovery of `.npmrc` files in user's homedir.

This is not a perfect fix as it doesn't merge multiple `.npmrc` files
together as per https://github.com/denoland/deno/issues/23954
but allows to fallback if no `.npmrc` file is discovered in the project
root.
2024-06-27 00:17:00 +02:00
David Sherret
0da01c0ca6
refactor: move PackageJson to deno_config (#24348) 2024-06-26 21:24:10 +00:00
Bartek Iwańczuk
b94707af7d
Revert "chore: upgrade to reqwest 0.12.4 and rustls 0.22 (#24056)" (#24262)
This reverts commit fb31eaa9ca.

Reverting because users reported spurious errors when downloading
dependencies - https://github.com/denoland/deno/issues/24260.

Closes https://github.com/denoland/deno/issues/24260
2024-06-19 16:09:17 +02:00
David Sherret
4ec9250c40
fix(npm): use more relaxed package.json version constraint parsing (#24202) 2024-06-13 18:29:27 -04:00
Bartek Iwańczuk
fb31eaa9ca
chore: upgrade to reqwest 0.12.4 and rustls 0.22 (#24056)
This commit updates Deno to use `reqwest` at 0.12.4
and `rustls` at 0.22. Other related crates were updated
as well to match versions accepted by `reqwest` and `rustls`.

Note: we are not using the latest available `rustls` yet,
but this upgrade was non-trivial already, so a bump to
0.23 for `rustls` will be done in a separate commit.

Closes #23370

---------

Signed-off-by: Ryan Dahl <ry@tinyclouds.org>
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-06-13 22:41:26 +02:00
David Sherret
386d5c8310
refactor: remove PermissionsContainer in deno_runtime (#24119)
Also removes permissions being passed in for node resolution. It was
completely useless because we only checked it for reading package.json
files, but Deno reading package.json files for resolution is perfectly
fine.

My guess is this is also a perf improvement because Deno is doing less
work.
2024-06-06 23:37:53 -04:00
David Sherret
566adb7c0a
fix(npm): use configured auth for tarball urls instead of scope auth (#24111)
Deno was using the scope auth for the tarball urls, which is not always
correct. We are going to do a release immediately for this issue.
2024-06-05 21:24:52 +00:00
David Sherret
7ed90a20d0
fix: better handling of npm resolution occurring on workers (#24094)
Closes https://github.com/denoland/deno/issues/24063
2024-06-05 17:04:16 +02:00
Andreas Kohn
92c881faa7
docs(console): More clearly indicate the contents of DENO_CERT (#24091)
The PEM file specified by DENO_CERT can contain multiple certificates
13924fdb1b/cli/args/mod.rs (L722-L742)

Signed-off-by: Andreas Kohn <andreas.kohn@gmail.com>
2024-06-04 11:50:50 -04:00
David Sherret
38ff9faff6
fix: retry writing lockfile on failure (#24052)
Ran into this running the deno_graph ecosystem tests where many
processes writing to the same path at the same time would cause an
error.
2024-05-31 23:25:08 -04:00
David Sherret
2d3b596cf5
feat: do not require DENO_FUTURE=1 for npmrc support (#24043) 2024-05-30 04:07:57 +00:00
Nayeem Rahman
556012320e
feat(lsp): support .npmrc (#24042)
Closes #24040
2024-05-30 03:16:15 +00:00
Luca Casonato
e084fe10a9
feat(lint): add no-boolean-literal-for-arguments rule and enable no-unused-vars for jsx files (#24034)
* https://github.com/denoland/deno_lint/pull/1271
* https://github.com/denoland/deno_lint/pull/1277

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-05-30 00:09:16 +00:00
David Sherret
a8923534ed
chore: set lockfile as having no content changes after write (#24023)
Slight perf regression when updating deno_lockfile in
https://github.com/denoland/deno/pull/23979
2024-05-28 23:40:40 -04:00
David Sherret
448fe67b7a
feat(vendor): support modifying remote files in vendor folder without checksum errors (#23979)
Includes:

* https://github.com/denoland/deno_graph/pull/486
* https://github.com/denoland/deno_graph/pull/488
* https://github.com/denoland/deno_lockfile/pull/25
* https://github.com/denoland/deno_lockfile/pull/22
* https://github.com/denoland/deno_graph/pull/483
* https://github.com/denoland/deno_graph/pull/470
2024-05-28 14:58:43 -04:00
Mike Mulchrone
dc5c799c39
fix(deno_task): more descriptive error message (#24001)
Signed-off-by: Mike Mulchrone <mikemulchrone987@gmail.com>
Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-05-28 13:33:08 +00:00
Asher Gomez
adbd564758
FUTURE(ext/ffi,ext/webgpu): stabilize FFI and WebGPU APIs (#24011)
Closes #23906
2024-05-28 11:37:43 +00:00
Bartek Iwańczuk
1667e28a15
FUTURE(ext/fs): stabilize file system APIs (#23968)
Closes https://github.com/denoland/deno/issues/23906

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-05-27 23:43:07 +00:00
Hasan-Alrimawi
e44c538f37
fix: --env flag confusing message on syntax error (#23915)
Enhanced warning message for --env flag with run and eval subcommands. 

The commit is specifically made to address issue #23674 by improving the
warning messages that appear when using the --env flag with run or eval
subcommands in the following scenarios:

1. Missing environment file.
2. Incorrect syntax in the environment file content.


**Changes made**

- Distinguishes between cases of missing environment file and wrong
syntax in the environment file content.
- Shows a concise warning message to convey the case/issue occurred.

**Code changes & enhancements**
- Implemented a match statement to handle different types of errors
received while getting and parsing the file content to display a concise
warning message, rather than simple error check and then displaying the
same warning message for whatever the type of error is.
- Updated the related existing tests to reflect the new warning
messages.
- Added two test cases to cover the wrong environment file content
syntax with both run and eval subcommands.

**Impact**
The use of --env flag with both run/eval would be more user-friendly as
it gives a precise description of what is not right when using
incorrectly.

If you could give it a look, @dsherret , I appreciate your feedback on
these changes.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-05-27 15:06:18 +02:00
Bartek Iwańczuk
959739f609
FUTURE: initial support for .npmrc file (#23560)
This commit adds initial support for ".npmrc" files.

Currently we only discover ".npmrc" files next to "package.json" files
and discovering these files in user home dir is left for a follow up.

This pass supports "_authToken" and "_auth" configuration
for providing authentication.

LSP support has been left for a follow up PR.

Towards https://github.com/denoland/deno/issues/16105
2024-05-23 23:26:23 +02:00
Nathan Whitaker
5de30c5323
fix(cli): Support deno.lock with only package.json present + fix DENO_FUTURE install interactions with lockfile (#23918)
Fixes #23571.

Previously, we required a `deno.json` to be present (or the `--lock`
flag) in order for us to resolve a `deno.lock` file. This meant that if
you were using deno in an npm-first project deno wouldn't use a
lockfile.

Additionally, while I was fixing that, I discovered there were a couple
bugs keeping the future `install` command from using a lockfile.

With this PR, `install` will actually resolve the lockfile (or create
one if not present), and update it if it's not up-to-date. This also
speeds up `deno install`, as we can use the lockfile to skip work during
npm resolution.
2024-05-23 12:31:05 -07:00
Asher Gomez
71375491d1
feat(cli/test): deno test --clean (#23519)
The result of the call is ignored as it throws even when the directory
does not exist.

Closes #23491
2024-05-23 03:04:12 +00:00
David Sherret
f5d0c4b1ea
feat: add lowercase -v version flag (#23750)
Ref https://github.com/denoland/deno/issues/5289
2024-05-23 00:20:20 +00:00
Satya Rohith
20cb0e8863
feat(serve): support --port 0 to use an open port (#23846)
Closes https://github.com/denoland/deno/issues/23845
2024-05-17 05:38:50 +00:00
Divy Srivastava
88983fb3eb
fix(node): seperate worker module cache (#23634)
Construct a new module graph container for workers instead of sharing it
with the main worker.

Fixes #17248
Fixes #23461

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2024-05-16 07:09:35 +00:00
David Sherret
4ddc85e1da
fix(emit): regression - keep comments in emit (#23815)
Closes https://github.com/denoland/deno/discussions/23814
2024-05-14 22:01:31 +00:00
David Sherret
47f7bed677
chore: enable clippy::print_stdout and clippy::print_stderr (#23732)
1. Generally we should prefer to use the `log` crate.
2. I very often accidentally commit `eprintln`s.

When we should use `println` or `eprintln`, it's not too bad to be a bit
more verbose and ignore the lint rule.
2024-05-08 22:45:06 -04:00
Bartek Iwańczuk
4e23a5b1fc
FUTURE: deno install changes (#23498)
This PR implements the changes we plan to make to `deno install` in deno
2.0.
- `deno install` without arguments caches dependencies from
`package.json` / `deno.json` and sets up the `node_modules` folder
- `deno install <pkg>` adds the package to the config file (either
`package.json` or `deno.json`), i.e. it aliases `deno add`
- `deno add` can also add deps to `package.json` (this is gated behind
`DENO_FUTURE` due to uncertainty around handling projects with both
`deno.json` and `package.json`)
- `deno install -g <bin>` installs a package as a globally available
binary (the same as `deno install <bin>` in 1.0)

---------

Co-authored-by: Nathan Whitaker <nathan@deno.com>
2024-05-08 12:34:46 -07:00
David Sherret
2dcbef2abb
fix(compile): relative permissions should be retained as relative (#23719)
Closes #23715
2024-05-06 19:21:58 -04:00
Luca Casonato
6cdf81db7c
feat(cli): add support for jsxImportSourceTypes (#23419)
Co-authored-by: David Sherret <dsherret@gmail.com>
2024-04-30 18:12:35 +00:00
Kenta Moriuchi
783533d2e3
FUTURE: remove import assertions support for JavaScript (#23541)
Ref #17944, https://github.com/swc-project/swc/issues/8893

TypeScript removes the `assert` keywords in the transpile, so this PR
only works for JavaScript files
2024-04-29 22:43:05 +02:00
David Sherret
4384a126bb
fix: handle specifying an import map in an ancestor dir of deno.json (#23602)
* https://github.com/denoland/deno_config/pull/51

Closes https://github.com/denoland/deno/issues/21440
2024-04-29 14:32:27 -04:00
Leo Kettmeir
5a7414e163
chore: update deno_doc (#23544) 2024-04-24 20:34:21 +00:00
Matt Mastracci
2f8825a935
feat: Add deno serve subcommand (#23511)
By default, `deno serve` will assign port 8000 (like `Deno.serve`).
Users may choose a different port using `--port`.

`deno serve /tmp/file.ts`

`server.ts`:
```ts
export default {
  fetch(req) {
    return new Response("hello world!\n");
  },
};
```
2024-04-24 19:45:49 +00:00
Nathan Whitaker
8a367d3cc3
fix(cli): Don't panic on invalid emit options (#23463)
Fixes #23456.
2024-04-23 08:50:50 -07:00
Bartek Iwańczuk
35220f0069
fix(workspace): provide workspace members as 'imports' in import map (#23492)
This commit changes the workspace support to provide all workspace
members to be available as imports based on their names and versions.

Closes https://github.com/denoland/deno/issues/23343
2024-04-23 17:21:06 +02:00
Marvin Hagemeister
9686a8803e
feat: add jsx precompile skip element option (#23457)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->
This PR wires up a new `jsxPrecompileSkipElements` option in
`compilerOptions` that can be used to exempt a list of elements from
being precompiled with the `precompile` JSX transform.
2024-04-22 17:07:36 +02:00
David Sherret
c497e766f1
refactor: move redirect handling into deno_graph (#23444) 2024-04-19 01:43:28 +00:00
Nayeem Rahman
8e77f091ad
perf(lsp): cleanup document dependencies (#23426) 2024-04-19 00:51:16 +00:00
Igor Zinkovsky
b3d7df5535
perf: v8 code cache (#23081)
This PR enables V8 code cache for ES modules and for `require` scripts
through `op_eval_context`. Code cache artifacts are transparently stored
and fetched using sqlite db and are passed to V8. `--no-code-cache` can
be used to disable.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-04-17 07:19:55 -07:00
Asher Gomez
534dd34f86
fix: add DENO_FUTURE to deno --help (#23368) 2024-04-17 02:58:48 +10:00
Bartek Iwańczuk
f358ae6278
fix(inspector): don't panic if port is not free (#22745)
Closes https://github.com/denoland/deno/issues/22113
Closes https://github.com/denoland/deno/issues/23177
Closes https://github.com/denoland/deno/issues/22883
Closes https://github.com/denoland/deno/issues/22377
2024-04-12 01:17:10 +02:00
David Sherret
ade0cd5e97
fix: upgrade deno_ast related crates (#23187)
Had to revert back swc due to
https://github.com/swc-project/swc/issues/8840

Fixes:

- https://github.com/denoland/deno_lint/pull/1262
- https://github.com/denoland/deno_doc/pull/538
- https://github.com/denoland/deno_doc/pull/537
- https://github.com/denoland/deno_graph/pull/430
- https://github.com/denoland/deno_graph/pull/425
- https://github.com/denoland/deno_graph/pull/432
2024-04-11 23:00:17 +00:00
Asher Gomez
c6f1107e9c
chore: update references to deno_std to use JSR (#23239)
There are more uses of `deno.land/std` in the codebase, but for URL
parsing purposes rather than network calls or documentation.
2024-04-10 17:26:35 -04:00
David Sherret
049e703331
FUTURE: override byonm with nodeModulesDir setting (#23222)
Makes the `"nodeModulesDir"` setting take precedence over byonm when
using `DENO_FUTURE`.
2024-04-05 10:34:51 -04:00
JOTSR
5dda32088a
fix(cli): update deno doc help to fit current usage (#23224) 2024-04-04 22:03:29 +00:00
Bartek Iwańczuk
de3f0b93f5
refactor(flags): prepare for deno install changes (#23217)
This commit adds enum to "InstallFlags" and "UninstallFlags" that will
allow to support both local and global (un)installation.

Currently the local variant is not used.

Towards https://github.com/denoland/deno/issues/23062
2024-04-04 14:40:54 +00:00
Bartek Iwańczuk
c0b7454175
FUTURE: enable BYONM by default (#23194)
When `DENO_FUTURE=1` env var is present, then BYONM
("bring your own node_modules") is enabled by default.
That means that is there's a `package.json` present, users
are expected to explicitly install dependencies from that file.

Towards https://github.com/denoland/deno/issues/23151
2024-04-03 00:43:03 +02:00
Łukasz Czerniawski
08d5d32dfc
feat: add --watch-exclude flag (#21935)
This PR introduces the ability to exclude certain paths from the file watcher
in Deno. This is particularly useful when running scripts in watch mode,
as it allows developers to prevent unnecessary restarts when changes are
made to files that do not affect the running script, or when executing
scripts that generate new files which results in an infinite restart
loop.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2024-03-27 22:47:46 +00:00
Bartek Iwańczuk
d31f2307ee
feat(install): require -g / --global flag (#23060)
In preparation for upcoming changes to `deno install` in Deno 2.

If `-g` or `--global` flag is not provided a warning will be emitted:
```
⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use `-g` or `--global` flag.
```

The same will happen for `deno uninstall` - unless `-g`/`--global` flag
is provided
a warning will be emitted.

Towards https://github.com/denoland/deno/issues/23062

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2024-03-27 23:45:57 +01:00
Nathan Whitaker
2dc37f411e
feat(task): Task description in the form of comments (#23101)
Closes #22786.

TLDR;
```jsonc
{
  "tasks": {
    // Some comment
    //
    // describing what the task does
    "dev": "deno run -A --watch main.ts"
  }
}
```
```bash
deno task
```
![Screenshot 2024-03-27 at 1 43
49 PM](https://github.com/denoland/deno/assets/17734409/7a14da8c-8e63-45ba-9bfb-590d250b56a9)
2024-03-27 14:14:27 -07:00
David Sherret
68fecc6de4
fix: less aggressive vendor folder ignoring (#23100)
This is slightly breaking as some users want the `vendor` folder
excluded and may not have that specified in their deno.json.

Closes #22833
2024-03-27 14:25:39 -04:00
Nayeem Rahman
3b61104e2a
refactor(lsp): unify config file data into ConfigTree (#23032) 2024-03-26 15:52:20 +00:00
Matt Mastracci
86cdf37033
perf(cli): use args_os (#23039)
Extracted from #22718
2024-03-22 14:03:56 -07:00
David Sherret
ffbcad3800
feat(lint): deno lint --fix and lsp quick fixes (#22615)
Adds a `--fix` option to deno lint. This currently doesn't work for
basically any rules, but we can add them over time to deno lint.
2024-03-21 14:18:59 -07:00
Bartek Iwańczuk
e45f433a16
chore: make DENO_FUTURE a singleton (#23009)
Just making sure we read this env var once per process.
2024-03-21 07:32:44 +05:30
Łukasz Czerniawski
5403e4f06b
chore(cli): move away from PathBuf in clap (#22036) 2024-03-14 23:53:46 +00:00
Matt Mastracci
eccdb0e99a
chore(permissions): add allow_all flag (#22890)
Unlocking a potential perf optimization at a later date -- carry the
`allow_all` flag into the permission container.
2024-03-13 16:07:24 +00:00
mimikun
8fdc376b4a
fix(publish): typo in --allow-dirty help text (#22799) 2024-03-08 18:03:32 +00:00
David Sherret
2dfc0aca7c
fix(publish): make include and exclude work (#22720)
1. Stops `deno publish` using some custom include/exclude behaviour from
other sub commands
2. Takes ancestor directories into account when resolving gitignore
3. Backards compatible change that adds ability to unexclude an exclude
by using a negated glob at a more specific level for all sub commands
(see https://github.com/denoland/deno_config/pull/44).
2024-03-07 20:16:32 -05:00
Bartek Iwańczuk
914b7495a8
fix(publish): reland error if there are uncommitted changes (#22613) (#22632)
Reverted in https://github.com/denoland/deno/pull/22625
2024-03-07 22:13:36 +01:00
Bartek Iwańczuk
f0ec4fe1b8
fix(publish): silence warnings for sloppy imports and node builtins with env var (#22760)
An undocumented "DENO_DISABLE_PEDANTIC_NODE_WARNINGS" env
var can be used to silence warnings for sloppy imports and node builtins
without `node:` prefix.
2024-03-07 14:59:57 +01:00
Nayeem Rahman
01bc2f530e
feat(unstable/pm): support npm packages in 'deno add' (#22715) 2024-03-06 13:24:15 +00:00
David Sherret
942dcbad84
refactor: move deno json functionality to args module (#22710) 2024-03-05 15:45:44 -05:00
Bartek Iwańczuk
fb31ae73e4
feat(unstable): deno add subcommand (#22520)
This commit adds "deno add" subcommand that has a basic support for
adding "jsr:" packages to "deno.json" file. 

This currently doesn't support "npm:" specifiers and specifying version
constraints.
2024-02-29 19:12:04 +00:00
Divy Srivastava
9ffc34c159
feat(publish): enable package provenance by default on github actions (#22635) 2024-02-29 21:48:47 +05:30
Nayeem Rahman
3a43568481
feat(lsp): jsr specifier completions (#22612) 2024-02-29 03:54:16 +00:00
Bartek Iwańczuk
c9b2139b1e
Revert "fix(publish): error if there are uncommitted changes (#22613)" (#22625)
This reverts commit c2c4e745a5.
2024-02-28 21:35:02 +00:00
Matt Mastracci
a3f982c1d5
chore(cli): rename --trace-ops to --trace-leaks (#22598)
As we add tracing to more types of runtime activity, `--trace-ops` is
less useful of a name. `--trace-leaks` better reflects that this feature
traces both ops and timers, and will eventually trace resource opening
as well.

This keeps `--trace-ops` as an alias for `--trace-leaks`, but prints a
warning to the console suggesting migration to `--trace-leaks`.

One test continues to use `--trace-ops` to test the deprecation warning.

---------

Signed-off-by: Matt Mastracci <matthew@mastracci.com>
2024-02-28 09:12:43 -07:00
Bartek Iwańczuk
c2c4e745a5
fix(publish): error if there are uncommitted changes (#22613)
Closes https://github.com/denoland/deno/issues/22330
2024-02-28 10:21:12 +01:00
Divy Srivastava
9b5d2f8c1b
feat(publish): provenance attestation (#22573)
Supply chain security for JSR.

```
$ deno publish --provenance

Successfully published @divy/test_provenance@0.0.3
Provenance transparency log available at https://search.sigstore.dev/?logIndex=73657418
```

0. Package has been published.
1. Fetches the version manifest and verifies it's matching with uploaded
files and exports.
2. Builds the attestation SLSA payload using Github actions env.
3. Creates an ephemeral key pair for signing the github token
(aud=sigstore) and DSSE pre authentication tag.
4. Requests a X.509 signing certificate from Fulcio using the challenge
and ephemeral public key PEM.
5. Prepares a DSSE envelop for Rekor to witness. Posts an intoto entry
to Rekor and gets back the transparency log index.
6. Builds the provenance bundle and posts it to JSR.
2024-02-28 07:58:02 +05:30
Bartek Iwańczuk
f1a691274e
feat(publish): discover jsr.json and jsr.jsonc files (#22587)
Closes https://github.com/denoland/deno/issues/22491
2024-02-27 08:27:21 +00:00
David Sherret
6567dc94a9
fix(lsp): import map expansion (#22553) 2024-02-24 00:21:09 -05:00
David Sherret
33fa49a100
chore: improve not implemented npm system info message (#22571) 2024-02-23 16:34:24 -05:00
tuhana
bcf2156dbf
fix(compile): add aarch64 linux to CliOptions::npm_system_info (#22567)
Follow-up for #22542.
2024-02-23 19:18:39 +01:00
Bartek Iwańczuk
619acce305
fix(compile): allow to compile for ARM linux (#22542)
Closes https://github.com/denoland/deno/issues/22527
2024-02-23 18:08:17 +00:00
Marvin Hagemeister
cddefecfff
feat: infer dependencies from package.json (#22563)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->
This PR enhances the `deno publish` command to infer dependencies from
`package.json` if present.
2024-02-23 15:56:49 +01:00
David Sherret
9166d8a4e9
feat(publish): type check on publish (#22506)
Supersedes #22501 and also fixes that issue.
2024-02-21 08:35:25 -05:00
David Sherret
f90889e5ee
perf(jsr): fast check cache and lazy fast check graph (#22485) 2024-02-20 21:29:57 +00:00
David Sherret
66424032a2
feat(unstable/lint): no-slow-types for JSR packages (#22430)
1. Renames zap/fast-check to instead be a `no-slow-types` lint rule.
1. This lint rule is automatically run when doing `deno lint` for
packages (deno.json files with a name, version, and exports field)
1. This lint rules still occurs on publish. It can be skipped by running
with `--no-slow-types`
2024-02-19 15:28:41 +00:00
Luca Casonato
15c64365a2
fix: write lockfile in deno info (#22272) 2024-02-19 13:02:40 +01:00
Divy Srivastava
b72f0be27c
chore: add DENO_FUTURE env var (#22318)
Closes https://github.com/denoland/deno/issues/22315

```
~> DENO_FUTURE=1 target/debug/deno

> globalThis.window
undefined
```
2024-02-15 04:50:17 +00:00
Nayeem Rahman
012a9d8aeb
chore: rename DENO_REGISTRY_URL to JSR_URL (#22414) 2024-02-14 18:30:44 +00:00
Leo Kettmeir
b5d122de32
feat(publish): allow passing config flag (#22416) 2024-02-14 17:13:07 +00:00
David Sherret
83d72e5c1c
refactor: extract out runtime::colors to deno_terminal::colors (#22324) 2024-02-07 11:25:14 -05:00
David Sherret
a284f50732
perf: remove duplicate env::current_dir call in package.json search (#22255)
Micro-optimization.
2024-02-04 00:11:12 -05:00
David Sherret
4b7c6049ef
refactor: load bytes in deno_graph (#22212)
Upgrades deno_graph to 0.64 where deno_graph is now responsible for
turning bytes into a string. This is in preparation for Wasm modules.
2024-02-01 03:15:22 +00:00
Bartek Iwańczuk
830d096b66
fix(publish): rename --no-fast-check to --no-zap (#22214)
Also prints an information about the flag when there are `zap` errors.
2024-02-01 02:16:52 +00:00
Bartek Iwańczuk
560390c93c
chore(publish): add --no-fast-check flag (#22203) 2024-01-31 16:10:31 +01:00
Bartek Iwańczuk
9e0495baa7
fix: make deprecation warnings less verbose (#22128)
This commit makes deprecation warnings less verbose by default.

Only a single warnings is issued per deprecated API use.

`DENO_VERBOSE_WARNINGS` env var can be provided to enable more detailed
logging for each use of API including a stack trace.

https://github.com/denoland/deno/assets/13602871/9c036c84-0044-4cb6-9c8e-deb641f43712
2024-01-26 16:41:16 +01:00
Bartek Iwańczuk
44f8b05f5b
feat: Expand 'imports' section of deno.json (#22087)
This commit adds automatic expansion of "imports" field in "deno.json"
file.

If "npm:" or "jsr:" imports are encountered we automatically try to add
a "directory" remapping.

Previously users had to specify entries for both `foo` and `foo/` to be
able to import like
`import { symbol1 } from "foo";` and `import { symbol2 } from
"foo/some_file.js"`:
```
{
  "imports": {
    "foo": "npm:@foo/bar",
    "foo/": "npm:/@foo/bar/",
}
```

With this change users can only add entry for `foo`:
```
{
  "imports": {
    "foo": "npm:@foo/bar",
}
```
The entry for `foo/` will be provided automatically.

Similarly if user provides "directory" remapping explicitly, we will not
overwrite it.
2024-01-24 23:44:06 +01:00
Bartek Iwańczuk
b66f5ed00e
feat: TC39 decorator proposal support (#22040)
This commit adds support for [TC39 Decorator
Proposal](https://github.com/tc39/proposal-decorators).

These decorators are only available in transpiled sources - ie.
non-JavaScript files (because of lack of support in V8).

This entails that "experimental TypeScript decorators" are not available
by default
and require to be configured, with a configuration like this:
```
{
  "compilerOptions": {
    "experimentalDecorators": true
  }
}
```


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

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: crowlkats <crowlkats@toaxl.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2024-01-24 18:46:23 +05:30
Asher Gomez
4c0b66baab
refactor: set removal version for deno bundle (#22062)
This change sets the removal version for the `deno bundle` sub-command
for Deno v2. The warnings appear when `deno bundle` is run and in the
`--help` menu.
2024-01-24 02:36:51 +01:00
Bartek Iwańczuk
cc05dc142d
chore: make deno --help more colorful (#21962)
This commit adds coloring to "--help" flag.

Before:
https://github.com/denoland/deno/assets/13602871/23753f95-3289-45bc-8a1e-842d0ccd92df

After:
https://github.com/denoland/deno/assets/13602871/91b035cc-f199-4cf4-a77c-f65b290b5e19
2024-01-23 19:56:50 +01:00
Asher Gomez
d1eed9896f
fix(BREAKING): remove dead --prompt flag (#22038)
It appears the `--prompt` flag has done nothing for some time. Perhaps,
since #13650. Classifying this as a dead functionality removal for this
reason.

Did this while working on #22021.
2024-01-23 17:40:49 +01:00
Asher Gomez
b0febea47f
refactor: set removal version for --ts/-T flags (#22039)
Towards #22021
2024-01-23 17:34:06 +01:00
Bartek Iwańczuk
e49973d96d
chore: update deno_ast and deno_graph (#22033)
This upgrade unblocks support for ES decorator proposal.

Co-authored-by: crowlkats <crowlkats@toaxl.com>
2024-01-23 11:25:44 +01:00
Asher Gomez
f2b0424df6
refactor: set removal version for --jobs flag (#22028)
For removal in Deno v2. I'm uncertain of the output format but used
#21452 as a guide.

Towards #22021
2024-01-23 02:19:12 +01:00
David Sherret
69d5f136ba
feat(lockfile): track JSR and npm dependencies in config file (#22004)
See overview in https://github.com/denoland/deno_lockfile/pull/13
2024-01-22 22:31:12 +01:00
Bartek Iwańczuk
d20c9e75d1
refactor: add "UnstableConfig" struct to cli/args/flags.rs (#21993)
This commit adds "UnstableConfig" struct which centralizes
handling of all "--unstable-*" flags.

Closes https://github.com/denoland/deno/issues/21920
2024-01-22 17:37:28 +00:00
Asher Gomez
b4990d1aa2
refactor: don't error when .env is not present (#21879)
Uses similar format to when the latest version of std is implicitly
being used.

Closes #21788
2024-01-22 00:27:14 +01:00
Bartek Iwańczuk
568337f3f4
fix: remove conditional unstable type-checking from other commands (#21991)
It appears I missed this in https://github.com/denoland/deno/pull/21825.
2024-01-21 22:47:46 +00:00
Bartek Iwańczuk
c62615bfe5
feat: Start warning on each use of a deprecated API (#21939)
This commit introduces deprecation warnings for "Deno.*" APIs.

This is gonna be quite noisy, but should tremendously help with user
code updates to ensure
smooth migration to Deno 2.0. The warning is printed at each unique call
site to help quickly
identify where code needs to be adjusted. There's some stack frame
filtering going on to
remove frames that are not useful to the user and would only cause
confusion.

The warning can be silenced using "--quiet" flag or
"DENO_NO_DEPRECATION_WARNINGS" env var.

"Deno.run()" API is now using this warning. Other deprecated APIs will
start warning
in follow up PRs.

Example:

```js
import { runEcho as runEcho2 } from "http://localhost:4545/run/warn_on_deprecated_api/mod.ts";

const p = Deno.run({
  cmd: [
    Deno.execPath(),
    "eval",
    "console.log('hello world')",
  ],
});
await p.status();
p.close();

async function runEcho() {
  const p = Deno.run({
    cmd: [
      Deno.execPath(),
      "eval",
      "console.log('hello world')",
    ],
  });
  await p.status();
  p.close();
}

await runEcho();
await runEcho();

for (let i = 0; i < 10; i++) {
  await runEcho();
}

await runEcho2();

```

```
$ deno run --allow-read foo.js
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
└ Stack trace:
  └─ at file:///Users/ib/dev/deno/foo.js:3:16

hello world
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
└ Stack trace:
  ├─ at runEcho (file:///Users/ib/dev/deno/foo.js:8:18)
  └─ at file:///Users/ib/dev/deno/foo.js:13:7

hello world
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
└ Stack trace:
  ├─ at runEcho (file:///Users/ib/dev/deno/foo.js:8:18)
  └─ at file:///Users/ib/dev/deno/foo.js:14:7

hello world
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
└ Stack trace:
  ├─ at runEcho (file:///Users/ib/dev/deno/foo.js:8:18)
  └─ at file:///Users/ib/dev/deno/foo.js:17:9

hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
Warning
├ Use of deprecated "Deno.run()" API.
│
├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then.
│
├ Suggestion: Use "Deno.Command()" API instead.
│
├ Suggestion: It appears this API is used by a remote dependency.
│             Try upgrading to the latest version of that dependency.
│
└ Stack trace:
  ├─ at runEcho (http://localhost:4545/run/warn_on_deprecated_api/mod.ts:2:18)
  └─ at file:///Users/ib/dev/deno/foo.js:20:7

hello world

```

Closes #21839
2024-01-18 23:30:49 +00:00
David Sherret
35c1652f56
fix(lsp): regression - formatting was broken on windows (#21972)
~~Waiting on: https://github.com/denoland/deno_config/pull/31~~

Closes #21971
Closes https://github.com/denoland/vscode_deno/issues/1029
2024-01-18 15:57:30 -05:00
David Sherret
4e72ca313a
refactor: use globbing from deno_config (#21925) 2024-01-15 19:15:39 -05:00
Bartek Iwańczuk
a918804ee0
feat(unstable): remove --unstable-workspaces flag (#21891)
The workspaces feature is still considered unstable and can change.
Requiring this flag hinders DX.
2024-01-14 21:58:06 +00:00
Bartek Iwańczuk
f45ceb2320
chore(publish): add --dry-run flag (#21895) 2024-01-11 21:17:03 +00:00
David Sherret
70ac06138c
feat(unstable): fast subset type checking of JSR dependencies (#21873) 2024-01-10 22:40:30 +00:00
Ryan Dahl
ea5c9a3383
chore: rename do-not-use-publish (#21854) 2024-01-08 20:07:36 +00:00
David Sherret
e212e1fc35
perf: skip expanding exclude globs (#21817)
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-08 17:18:42 +00:00
Jovi De Croock
7fbdc15f22
fix(cli): update import map url (#21824)
Fixes https://github.com/denoland/deno/issues/21822

This updates the import-maps help URL to the one mentioned in the issue
2024-01-06 11:55:28 +01:00
nokazn
a0b6872359
fix(cli): respect exclude option for deno check command (#21779)
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-03 20:43:17 -05:00
林炳权
96b581bdd2
chore: update to Rust 1.75 (#21731) 2024-01-01 23:22:48 +01:00
David Sherret
7e72f3af61
chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
Divy Srivastava
55fac9f5ea
fix(node): child_process IPC on Windows (#21597)
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-19 13:37:22 +01:00
Yoshiya Hinosawa
6b482d7392
feat(coverage): add default coverage include dir (#21625) 2023-12-18 19:48:45 +09:00
Bartek Iwańczuk
ceaa646a34
fix(jupyter): Deno.test() panic (#21606)
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-17 11:11:07 +01:00
Bartek Iwańczuk
cf1ba2f7e8
refactor: update reg url (#21595) 2023-12-15 14:14:28 +01:00
Bartek Iwańczuk
62e3f5060e
refactor: check if scope and package exist before publish (#21575)
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
2023-12-15 10:27:10 +00:00
Divy Srivastava
5a91a065b8
fix: implement child_process IPC (#21490)
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-13 11:14:16 +01:00
Bartek Iwańczuk
06c5f99a01
refactor: better handling for registry urls (#21545) 2023-12-12 23:45:20 +09:00
Yoshiya Hinosawa
93ea46b31d
fix(coverage): rename --pretty to --detailed (#21543) 2023-12-12 20:53:41 +09:00
Yoshiya Hinosawa
5ddf8732f0
feat(coverage): add summary reporter (#21535) 2023-12-12 12:42:57 +09:00
Leo Kettmeir
393abed387
feat: bring back WebGPU (#20812)
Signed-off-by: Leo Kettmeir <crowlkats@toaxl.com>
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-12-09 01:19:16 +01:00
Yoshiya Hinosawa
2b3daa690d
feat(test): add default to --coverage option (#21510) 2023-12-08 17:35:42 +09:00