Commit graph

81 commits

Author SHA1 Message Date
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
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 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
Łukasz Czerniawski 5403e4f06b
chore(cli): move away from PathBuf in clap (#22036) 2024-03-14 23:53:46 +00:00
David Sherret ad6b00a2bf
chore: enable clippy unused_async rule (#22834) 2024-03-11 23:48:00 -04:00
Bartek Iwańczuk cfb57b1855
fix(install): forward granular --unstable-* flags (#22164)
Closes https://github.com/denoland/deno/issues/22154
2024-02-01 09:16:37 +05:30
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
David Sherret 7e72f3af61
chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
Leo Kettmeir 61a4e88e38
fix(cli/installer): percent decode name (#21392) 2023-12-02 14:33:22 +01:00
Bolat Azamat 7687ec87e6
fix(cli): Allow executable name start with digit (#21214) 2023-11-15 09:17:09 -07:00
David Sherret 6e1f3aa013
fix(install): should work with non-existent relative root (#21161)
Closes #21160
2023-11-13 09:44:01 -05: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
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 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 136dce67ce
refactor: break up ProcState (#18707)
1. Breaks up functionality within `ProcState` into several other structs
to break out the responsibilities (`ProcState` is only a data struct
now).
2. Moves towards being able to inject dependencies more easily and have
functionality only require what it needs.
3. Exposes `Arc<T>` around the "service structs" instead of it being
embedded within them. The idea behind embedding them was to reduce the
verbosity of needing to pass around `Arc<...>`, but I don't think it was
exactly working and as we move more of these structs to be more
injectable I don't think the extra verbosity will be a big deal.
2023-04-14 16:22:33 -04:00
Yiyu Lin d790ea7d53
refactor(cli,ext,ops): cleanup regex with lazy-regex (#17296)
- bump deps: the newest `lazy-regex` need newer `oncecell` and
`regex`
- reduce `unwrap`
- remove dep `lazy_static`
- make more regex cached

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-13 03:08:01 +02:00
David Sherret 9c255b2843
refactor: ProcState::build -> ProcState::from_flags (#18672) 2023-04-12 14:54:28 -04:00
David Sherret d07aa4a072
refactor(npm): use deno_npm and deno_semver (#18602) 2023-04-06 18:46:44 -04: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 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
David Sherret c4b9a91e27
refactor: use deno_graph's semver and npm structs (#17791) 2023-02-15 13:20:40 -05:00
Kamil Ogórek 5778e1196e
feat(install): follow redirects for urls with no path (#17449)
This change makes absolute urls, that contain no path like `deno install
https://my-cli.io` to follow redirects and extract the name from it.

It allows modifies `test_util` server listener on port `4550`
(`REDIRECT_ABSOLUTE_PORT`) to allow for specifying `redirect_to` query
param, that fill use that value for it's next redirect.

Fixes https://github.com/denoland/deno/issues/17409
2023-02-10 10:11:11 -05:00
David Sherret 8b35229da3
fix(install): tsconfig.json -> deno.json for config file suffix (#17573)
Closes #17571
2023-01-28 14:51:11 -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
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
David Sherret 2be1282be4
fix(install): should always include --no-config in shim unless --config is specified (#17300)
Closes #17294
2023-01-08 09:03:55 -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
linbingquan f46df3e359
chore: update to Rust 1.66.0 (#17078) 2022-12-17 23:20:15 +01:00
David Sherret 058610b458
fix(install): use a hidden file for the lockfile and config (#17084)
Closes #17083
2022-12-16 22:24:06 +01:00
David Sherret 653aebfa1a
fix: respect the --quiet flag in more cases (#16998) 2022-12-09 10:54:24 -05:00
David Sherret 6541a0a9fd
refactor: cleanup main.rs (#16996)
1. Extracts out some code from main.rs
2. Inlines all the `x_command` functions in main.rs
2022-12-09 09:40:48 -05:00
David Sherret 91443bbc0b
fix(compile): ensure import map is used when specified in deno config file (#16990)
Closes #14246
2022-12-08 11:50:09 -05:00
David Sherret 2d4c46c975
refactor: create util folder, move nap_sym to napi/sym, move http_cache to cache folder (#16857) 2022-11-28 17:28:54 -05:00
David Sherret 4b07c7b159
fix(install): deno install -f should overwrite lockfile from previous installation (#16744) 2022-11-21 14:24:51 -05:00
David Sherret d6fd171394
fix(install): support npm specifiers (#16634)
Supports npm specifiers for `deno install`. This will by default always
use a lockfile (which is generated on first run) unless `--no-lock` is
specified.
2022-11-14 22:40:05 -05:00
Yusuke Tanaka 2c96f64fa7
fix(cli): skip removing the latter part if @ appears at the beginning (#16244)
This commit prevents panics that `deno compile` command ran into under certain
conditions from occurring. Such conditions are as follows.

- the target file name begins with `@`, OR
- the stem part of the target file name is equal to one of
["main", "index", "mod", "index"] && the parent directory name starts with `@`

Fixes #16243
2022-10-12 11:32:52 +09:00
Bartek Iwańczuk 4a250b2f25
feat: add --no-npm flag to disable npm: imports (#15673)
This commit adds "--no-npm" flag, it's similar to "--no-remote"
flag. This flag makes Deno error out if "npm:" specifier is encountered.
2022-09-07 15:33:51 +02:00
Bartek Iwańczuk e324151520
BREAKING(unstable): remove --compat mode (#15678)
This commit removes "compat" mode. We shipped support for "npm:" specifier
support in v1.25 and that is preferred way to interact with Node code that we
will iterate and improve upon.
2022-09-03 18:19:30 +02:00
David Sherret e1c90963fb
refactor: create args folder (#14982) 2022-06-27 16:54:09 -04:00
Bartek Iwańczuk 4a0a412d7c
feat: no type-check by default (#14691)
This commit changes default default behavior of type checking
for several subcommands.

Instead of type checking and reporting type errors only for local
files, the type checking is skipped entirely. Type checking can
still be enabled using the "--check" flag.

Following subcomands are affected:
- deno cache
- deno install
- deno eval
- deno run
2022-06-13 23:13:16 +02:00
Bartek Iwańczuk 9a85a95c43
feat: subcommands type-check only local files by default (#14623)
This commit changes default mode of type-checking to "local" 
and adds "--check" flag to following subcommands:
- deno bench
- deno bundle
- deno cache
- deno compile
- deno eval
- deno install
- deno test
2022-05-17 23:53:42 +02:00
Bartek Iwańczuk 939a070c8c
feat: add --no-config flag (#14555)
This flag disables loading of configuration file, ie. it will not be
automatically discovered and loaded. Of course this flag conflicts
with "--config" flag and they cannot be used together.
2022-05-13 17:40:50 +02:00
Bartek Iwańczuk 8ae17026cb
feat: Add "deno check" subcommand for type checking (#14072)
This commit adds new "deno check" subcommand.
Currently it is an alias for "deno cache" with the difference that remote
modules don't emit TS diagnostics by default.

Prints warning for "deno run" subcommand if "--check" flag is not present
and there's no "--no-check" flag. Adds "DENO_FUTURE_CHECK" env
variable that allows to opt into new behavior now.
2022-04-11 01:12:51 +02:00
Valentin Anger b8d66a683a
fix(cli/install): preserve compat flag (#14223) 2022-04-06 16:54:12 -04:00
David Sherret 1c37ac3352
chore(tests): use custom temp dir creation for the tests (#14153) 2022-04-01 11:15:37 -04:00
Bartek Iwańczuk 381d565acf
refactor(flags): rename CheckFlag to TypecheckMode (#14111) 2022-03-29 03:48:29 +02:00
David Sherret e46b5f738d
fix(tests): do not use global env vars in install tests (#14078) 2022-03-22 13:37:15 -04:00