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

1122 commits

Author SHA1 Message Date
Bartek Iwańczuk
09a7cc4723
refactor(fmt): rewrite HTML syntax error handling (#25892) 2024-09-26 20:44:36 -04:00
David Sherret
7cccb7422b
fix(info): move "version" field to top of json output (#25890) 2024-09-26 15:57:12 -04:00
Nathan Whitaker
543c687c34
feat(install): warn repeatedly about not-run lifecycle scripts on explicit installs (#25878)
Currently we only warn once. With this PR, we continue to warn about
not-run scripts on explicit `deno install` (or cache). For `run` (or
other subcommands) we only warn the once, as we do currently.
2024-09-26 17:13:33 +00:00
Nathan Whitaker
13c53d9727
fix(installl): make bin entries executable even if not put in node_modules/.bin (#25873)
Fixes https://github.com/denoland/deno/issues/25862.

npm only makes bin entries executable if they get linked into `.bin`, as
we did before this PR. So this PR actually deviates from npm, because
it's the only reasonable way to fix this that I can think of.

---

The reason this was broken in moment is the following:

Moment has dependencies on two typescript versions: 1.8 and 3.1

If you have two packages with conflicting bin entries (i.e. two
typescript versions which both have a bin entry `tsc`), in npm it is
non-deterministic and undefined which one will end up in `.bin`.

npm, due to implementation differences, chooses to put typescript 1.8
into the `.bin` directory, and so `node_modules/typescript/bin/tsc` ends
up getting marked executable. We, however, choose typescript 3.2, and so
we end up making `node_modules/typescript3/bin/tsc` executable.

As part of its tests, moment executes `node_modules/typescript/bin/tsc`.
Because we didn't make it executable, this fails.

Since the conflict resolution is undefined in npm, instead of trying to
match it, I think it makes more sense to just make bin entries
executable even if they aren't chosen in the case of a conflict.
2024-09-26 09:36:25 -07:00
David Sherret
7437f9d944
fix(doc): surface graph errors as warnings (#25888) 2024-09-26 12:31:03 -04:00
Bartek Iwańczuk
5504acea67
feat: add --allow-import flag (#25469)
This replaces `--allow-net` for import permissions and makes the
security sandbox stricter by also checking permissions for statically
analyzable imports.

By default, this has a value of
`--allow-import=deno.land:443,jsr.io:443,esm.sh:443,raw.githubusercontent.com:443,gist.githubusercontent.com:443`,
but that can be overridden by providing a different set of hosts.

Additionally, when no value is provided, import permissions are inferred
from the CLI arguments so the following works because
`fresh.deno.dev:443` will be added to the list of allowed imports:

```ts
deno run -A -r https://fresh.deno.dev
```

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2024-09-26 01:50:54 +00:00
Mohammad Sulaiman
c232ecc6af
chore: deprecate npm itests (#25804) 2024-09-25 18:46:18 +00:00
David Sherret
8cdb309ffd
fix(check): properly surface dependency errors in types file of js file (#25860)
We weren't surfacing dependency errors in types files of js files.
2024-09-25 09:04:57 -04:00
Nathan Whitaker
5c40b47629
fix(add/install): default to "latest" tag for npm packages in deno add npm:pkg (#25858)
Fixes #25813.

I initially tried doing this in `deno_semver`, where it's a cleaner
change, but that caused breakage in deno in places where we don't expect
a tag (see https://github.com/denoland/deno/issues/25857).

This does not fix wildcard requirements failing to choose pre-release
versions. That's a little more involved and I'll do a separate PR.
2024-09-25 01:10:01 +00:00
Bartek Iwańczuk
6c26c1ed96
feat(fmt): better error on malfored HTML files (#25853)
Improves syntax errors for HTML formatter.

`broken.html`

```html
<div class=container > content 
```

```
$ deno fmt broken.html
Error formatting: /Users/ib/dev/deno/tests/specs/fmt/html/broken.html
   syntax error 'expect close tag' at line 3, column 0
Checked 1 file
```

```
$ ./target/debug/deno fmt broken.html
Error formatting: /Users/ib/dev/deno/tests/specs/fmt/html/broken.html
   Syntax error (expect close tag) at file:///Users/ib/dev/deno/tests/specs/fmt/html/broken.html:3:0

Checked 1 file
```
2024-09-25 01:00:16 +00:00
David Sherret
c4f7b2ac00
fix(check): ignore noImplicitOverrides in remote modules (#25854) 2024-09-24 20:49:44 -04:00
Bartek Iwańczuk
a4f59c7761
test: disable 'test-child-process-ipc-next-tick.js' Node compat test (#25856)
This test is super flaky recently.

See https://github.com/denoland/deno/issues/25855 for more details.
2024-09-25 01:44:34 +02:00
Nathan Whitaker
36ebc03f17
fix(cli): Warn on not-run lifecycle scripts with global cache (#25786)
Refactors the lifecycle scripts code to extract out the common
functionality and then uses that to provide a warning in the global
resolver.

While ideally we would still support them with the global cache, for now
a warning is at least better than the status quo (where people are
unaware why their packages aren't working).
2024-09-24 19:23:57 +00:00
Leo Kettmeir
5a1943cd95
fix: better error for Deno.UnsafeWindowSurface, correct HttpClient name, cleanup unused code (#25833) 2024-09-24 07:04:52 -07:00
Bartek Iwańczuk
3242550f5f
fix(fmt): --check was broken for CSS, YAML and HTML (#25848)
`deno fmt --check` was broken for CSS, YAML and HTML files.

Before this PR, formatting any of these file types would return a
string, even though the contract in `cli/tools/fmt.rs` is to only return a
string if the formatting changed. This causes wrong flagging of these files
as being badly formatted even though diffs showed nothing (because
they were in fact formatted properly).

Closes https://github.com/denoland/deno/issues/25840
2024-09-24 15:54:48 +02:00
Nathan Whitaker
1e261c9756
fix: Update deno_npm to fix deno install with crossws (#25837)
Partially addresses https://github.com/denoland/deno/issues/25648.

This allows packages that use `crossws` to be installed with `deno
install`. `crossws` specifies an optional peer dependency on
`uWebSockets`, but `uWebSockets` is not on npm (it is used with `git:`
or `github:` specifiers). Previously we would error on this, now we
don't error on non-existent optional peer dependencies.
2024-09-24 02:12:48 +00:00
Bartek Iwańczuk
74e294c8c1
refactor: reenable more tests after DENO_FUTURE migration (#25752)
Rewrites and reenables following tests:
- `task::task_both_package_json_selected`
2024-09-24 03:33:03 +02:00
David Sherret
e1c8d2755e
BREAKING: remove support for remote import maps in deno.json (#25836)
This is for security reasons for the time being for Deno 2. Details to
follow post Deno 2.0 release.

Remote import maps seem incredibly rare (only 2 usages on GitHub from
what I can tell), so we'll add this back with more permissions if
there's enough demand for it:
https://github.com/search?type=code&q=%2F%22importMap%22%3A+%22http%2F

In the meantime, use the `--import-map` flag and `"deno.importMap"`
config in the LSP for remote import maps.
2024-09-23 18:46:50 +00:00
Óscar Otero
1287739ddf
feat(fmt): support vto and njk extensions (#25831)
Fixes #25802

markup_fmt plugin supports some HTML-like formats like Angular, Jinja,
Twig, Nunjucks or Vento, that are not supported by `deno fmt`. This PR
adds support for the extensions `njk` (Nunjucks) and `vto` (Vento).
Angular doesn't have a custom extension (it uses `html` afaik) and Jinja
and Twig are template engines written in Python and PHP respectively so
it doesn't make sense to be supported by Deno.
2024-09-23 14:27:58 -04:00
Bartek Iwańczuk
a7ac89935b
feat(fmt): stabilize CSS, HTML and YAML formatters (#25753)
This commits stabilizes CSS, HTML and YAML formatters
in `deno fmt`.

It is no longer required to use either of these flags:
- `--unstable-css`
- `--unstable-html`
- `--unstable-yaml`
Or these `unstable` options in the config file:
- `fmt-css`
- `fmt-html`
- `html-yaml`
2024-09-23 18:01:04 +02:00
Satya Rohith
cab3363026
tests: update specs::cache::package_json (#25827)
Towards https://github.com/denoland/deno/issues/25241
2024-09-23 20:17:43 +05:30
Divy Srivastava
bfdca5bc7a
feat(ext/crypto): import and export p521 keys (#25789)
Towards https://github.com/denoland/deno/issues/13449
2024-09-23 19:40:36 +05:30
Satya Rohith
b1550842d9
tests: enable auto_discovered tests of run/no_deno_json (#25821)
Towards https://github.com/denoland/deno/issues/25241
2024-09-23 15:37:35 +02:00
Bartek Iwańczuk
08d3f17110
feat: make 'globalThis.location' a configurable property (#25812)
This commit changes `globalThis.location` property to be configurable
so that packages wanting to override it (or delete it) work properly.

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

This change makes reproduction from
https://github.com/denoland/deno/issues/23882#issuecomment-2340783437
pass properly.
2024-09-23 14:18:07 +02:00
carles escrig royo
8f32a1577e
fix(ext/web): don't ignore capture in EventTarget.removeEventListener (#25788) 2024-09-23 11:19:59 +02:00
Bartek Iwańczuk
ef3e4a8f74
feat: Show hints when using window global (#25805)
This commit adds better handling for terminal errors when
`window` global is used. This global is removed in Deno 2,
and while we have lints to help with that, an information and
hints are helpful to guide users to working code.

Ref https://github.com/denoland/deno/issues/25797
2024-09-23 00:05:42 +02:00
Divy Srivastava
0cb00a6e89
BREAKING(webgpu/unstable): move width and height options to UnsafeWindowSurface constructor (#24200)
Fixes https://github.com/denoland/deno/issues/23508

`width` and `height` are required to configure the wgpu surface because
Deno is headless and depends on user to create a window. The options
were non-standard extension of `GPUCanvasConfiguration#configure`.

This PR adds a required options parameter with the `width` and `height`
options to `Deno.UnsafeWindowSurface` constructor.

```typescript
// Old, non-standard extension of GPUCanvasConfiguration
const surface = new Deno.UnsafeWindowSurface("x11", displayHandle, windowHandle);

const context  = surface.getContext();
context.configure({ width: 600, height: 800, /* ... */ });
```

```typescript
// New
const surface = new Deno.UnsafeWindowSurface({
  system: "x11",
  windowHandle,
  displayHandle,
  width: 600,
  height: 800,
});

const context  = surface.getContext();
context.configure({ /* ... */ });
```
2024-09-22 09:10:54 +05:30
Nathan Whitaker
9be8dce0c7
fix(node): Include "node" condition during CJS re-export analysis (#25785)
Fixes #25777.

We were missing the "node" condition, so we were resolving to the wrong
conditional export, causing our analysis to be incorrect.
2024-09-21 16:10:38 -07:00
carles escrig royo
88a469e823
perf(ext/web): optimize performance.measure() (#25774)
This PR optimizes the case when `performance.measure()` needs to find
the startMark by name. It is a simple change on `findMostRecent` fn to
avoiding copying and reversing the complete entries list.

Adds minor missing tests for:
- `clearMarks()`, general
- `clearMeasures()`, general
- `measure()`, case when the startMarks name exists more than once

### Benchmarks

#### main

```
    CPU | AMD Ryzen 7 PRO 6850U with Radeon Graphics
Runtime | Deno 2.0.0-rc.4 (x86_64-unknown-linux-gnu)

benchmark              time/iter (avg)        iter/s      (min … max)           p75      p99     p995
---------------------- ----------------------------- --------------------- --------------------------
worst case measure()            2.1 ms         486.9 (  1.7 ms …   2.4 ms)   2.2 ms   2.4 ms   2.4 ms
```

#### this PR

```
    CPU | AMD Ryzen 7 PRO 6850U with Radeon Graphics
Runtime | Deno 2.0.0-rc.4 (x86_64-unknown-linux-gnu)

benchmark              time/iter (avg)        iter/s      (min … max)           p75      p99     p995
---------------------- ----------------------------- --------------------- --------------------------
worst case measure()          966.3 µs         1,035 (876.9 µs …   1.1 ms)   1.0 ms   1.1 ms   1.1 ms
```

```ts
Deno.bench("worst case measure()", (b) => {
  performance.mark('start');

  for (let i = 0; i < 1e5; i += 1) {
    performance.mark(crypto.randomUUID());
  }

  b.start();

  performance.measure('total', 'start');

  b.end();

  performance.clearMarks();
  performance.clearMeasures();
});
```
2024-09-20 16:24:59 -07:00
Satya Rohith
94bdebe399
refactor(tests): migrate npm itests to specs (#25764)
Towards https://github.com/denoland/deno/issues/25241
2024-09-20 22:38:32 +02:00
Divy Srivastava
92fc702cec
fix(ext/crypto): ensure EC public keys are exported uncompressed (#25766)
Fixes https://github.com/denoland/deno/issues/18050
2024-09-20 20:59:05 +05:30
Bartek Iwańczuk
471a15ecff
test: make specs::test::doc_success less flaky (#25765)
Missed this line in https://github.com/denoland/deno/pull/25726
2024-09-20 13:14:02 +00:00
Divy Srivastava
a92ebd95a1
fix(ext/crypto): reject empty usages in SubtleCrypto#importKey (#25759)
Fixes https://github.com/denoland/deno/issues/19051
2024-09-20 18:02:28 +05:30
Yoshiya Hinosawa
66fb81ea85
fix(coverage): ignore urls from doc testing (#25736) 2024-09-20 15:04:22 +09:00
snek
a01dce3a25
fix: cjs resolution cases (#25739)
Fixes cjs modules being loaded as esm.
2024-09-19 21:10:34 -07:00
Nathan Whitaker
f1ba266613
fix(node): Don't error out if we fail to statically analyze CJS re-export (#25748)
Fixes rsbuild running in deno.

You can look at the test to see what was failing, the gist is that we
were trying to statically analyze the re-exports of a CJS script, and if
we couldn't find the source for the re-exported file we would fail.

Instead, we should just treat these as if they were too dynamic to
analyze, and let it fail (or succeed) at runtime. This aligns with
node's behavior.
2024-09-19 18:37:36 -07:00
Divy Srivastava
e97f00f6f6
fix(ext/node): support x509 certificates in createPublicKey (#25731)
Fixes https://github.com/denoland/deno/issues/25681
2024-09-19 19:12:23 +05:30
Bartek Iwańczuk
d7aafda243
test: make specs::test::doc_success less flaky (#25726)
On Windows some of these steps were taking more than 1s
2024-09-19 13:47:52 +02:00
Leo Kettmeir
bb45446fa7
fix: don't include extensionless files in file collection for lint & fmt by default (#25721)
When using the `ext` flag, it will still attempt formatting them with
the provided extension
2024-09-19 11:25:48 +02:00
Ian Bull
d420829908
refactor(ext/kv): align error messages (#25500)
Towards https://github.com/denoland/deno/issues/25269
2024-09-19 13:20:09 +05:30
Ian Bull
3035cdddb8
refactor(ext/webidl): align error messages (#25625)
Towards https://github.com/denoland/deno/issues/25269
2024-09-19 13:03:32 +05:30
Ian Bull
486cb18fc5
refactor(ext/webgpu): align error messages (#25719)
Aligns the error messages in the ext/webgpu folder to be in-line with
the Deno style guide.

https://github.com/denoland/deno/issues/25269
2024-09-19 09:14:54 +02:00
Yoshiya Hinosawa
f460188e58
fix(ext/node): don't throw error for unsupported signal binding on windows (#25699) 2024-09-19 12:22:01 +09:00
Ian Bull
282c4c262d
refactor(ext): align error messages (#25496)
Aligns the error messages in the ext/http and a few messages in the
ext/fetch folder to be in-line with the Deno style guide.

This change-set also removes some unnecessary checks in the 00_serve.ts.
These options were recently removed, so it doesn't make sense to check
for them anymore.

https://github.com/denoland/deno/issues/25269
2024-09-18 18:19:45 -07:00
Asher Gomez
5057f58145
feat: suggest deno install --entrypoint instead of deno cache (#25228)
Hides `deno cache` from `--help` output.

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-09-18 19:55:50 +00:00
Leo Kettmeir
a1d0a427e8
feat: default to TS for file extension and support ext flag in more scenarios (#25472)
Closes #11220
Currently does lint, fmt, and repl
2024-09-18 21:15:13 +02:00
Luca Casonato
7a41a93997
fix(ext/http): gracefully handle Response.error responses (#25712)
Fixes #14371
2024-09-18 21:14:40 +02:00
Luca Casonato
ab1e391e1d
feat(ext/node): add rootCertificates to node:tls (#25707)
Closes https://github.com/denoland/deno/issues/25604

Signed-off-by: Satya Rohith <me@satyarohith.com>
Co-authored-by: Satya Rohith <me@satyarohith.com>
2024-09-18 21:14:26 +02:00
Bartek Iwańczuk
5b14c71daf
feat: improve warnings for deprecations and lifecycle script for npm packages (#25694)
This commit improves warning messages for deprecated npm packages
and packages that rely on lifecycle script.
2024-09-18 19:04:25 +00:00
Divy Srivastava
fd860260ad
feat(lint): add no-process-global lint rule (#25709)
Closes https://github.com/denoland/deno/issues/25679
2024-09-18 20:50:42 +02:00