Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy committed Jul 5, 2024
1 parent a4eef85 commit ae3f6e7
Show file tree
Hide file tree
Showing 23 changed files with 281 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { stringify } from "jsr:@std/yaml@^0.221/stringify";
// Bump this number when you want to purge the cache.
// Note: the tools/release/01_bump_crate_versions.ts script will update this version
// automatically via regex, so ensure that this line maintains this format.
const cacheVersion = 1;
const cacheVersion = 2;

const ubuntuX86Runner = "ubuntu-22.04";
const ubuntuX86XlRunner = "ubuntu-22.04-xl";
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ jobs:
path: |-
~/.cargo/registry/index
~/.cargo/registry/cache
key: '1-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}'
restore-keys: '1-cargo-home-${{ matrix.os }}-${{ matrix.arch }}'
key: '2-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}'
restore-keys: '2-cargo-home-${{ matrix.os }}-${{ matrix.arch }}'
if: '!(matrix.skip)'
- name: Restore cache build output (PR)
uses: actions/cache/restore@v4
Expand All @@ -380,7 +380,7 @@ jobs:
!./target/*/*.zip
!./target/*/*.tar.gz
key: never_saved
restore-keys: '1-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-'
restore-keys: '2-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-'
- name: Apply and update mtime cache
if: '!(matrix.skip) && (!startsWith(github.ref, ''refs/tags/''))'
uses: ./.github/mtime_cache
Expand Down Expand Up @@ -669,7 +669,7 @@ jobs:
!./target/*/gn_out
!./target/*/*.zip
!./target/*/*.tar.gz
key: '1-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}'
key: '2-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}'
publish-canary:
name: publish canary
runs-on: ubuntu-22.04
Expand Down
35 changes: 18 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ pub struct Flags {
pub inspect_wait: Option<SocketAddr>,
pub inspect: Option<SocketAddr>,
pub location: Option<Url>,
// TODO(bartlomieju): deprecated, to be removed in Deno 2.
pub lock_write: bool,
pub lock: Option<String>,
pub log_level: Option<Level>,
Expand Down Expand Up @@ -3623,12 +3624,14 @@ If value is not provided, defaults to \"deno.lock\" in the current working direc
.value_hint(ValueHint::FilePath)
}

// TODO(bartlomieju): deprecated, to be removed in Deno 2.
fn lock_write_arg() -> Arg {
Arg::new("lock-write")
.action(ArgAction::SetTrue)
.long("lock-write")
.help("Force overwriting the lock file.")
.conflicts_with("no-lock")
.hide(true)
}

fn no_lock_arg() -> Arg {
Expand Down Expand Up @@ -4747,6 +4750,7 @@ fn check_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) {
fn lock_args_parse(flags: &mut Flags, matches: &mut ArgMatches) {
lock_arg_parse(flags, matches);
no_lock_arg_parse(flags, matches);
// TODO(bartlomieju): deprecated, to be removed in Deno 2.
if matches.get_flag("lock-write") {
flags.lock_write = true;
}
Expand Down
4 changes: 4 additions & 0 deletions cli/args/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ impl CliLockfile {
};

let lockfile = if flags.lock_write {
log::warn!(
"{} \"--lock-write\" flag is deprecated and will be removed in Deno 2.",
crate::colors::yellow("Warning")
);
CliLockfile::new(
Lockfile::new_empty(filename, true),
flags.frozen_lockfile,
Expand Down
8 changes: 2 additions & 6 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ impl CliOptions {
pub async fn create_workspace_resolver(
&self,
file_fetcher: &FileFetcher,
pkg_json_dep_resolution: PackageJsonDepResolution,
) -> Result<WorkspaceResolver, AnyError> {
let overrode_no_import_map = self
.overrides
Expand Down Expand Up @@ -1102,12 +1103,7 @@ impl CliOptions {
.workspace
.create_resolver(
CreateResolverOptions {
// todo(dsherret): this should be false for nodeModulesDir: true
pkg_json_dep_resolution: if self.use_byonm() {
PackageJsonDepResolution::Disabled
} else {
PackageJsonDepResolution::Enabled
},
pkg_json_dep_resolution,
specified_import_map: cli_arg_specified_import_map,
},
|specifier| {
Expand Down
12 changes: 11 additions & 1 deletion cli/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use std::collections::BTreeSet;
use std::path::PathBuf;

use deno_config::package_json::PackageJsonDepValue;
use deno_config::workspace::PackageJsonDepResolution;
use deno_config::workspace::WorkspaceResolver;
use deno_config::ConfigFile;
use deno_core::error::AnyError;
Expand Down Expand Up @@ -458,7 +459,15 @@ impl CliFactory {
.get_or_try_init_async(async {
let resolver = self
.options
.create_workspace_resolver(self.file_fetcher()?)
.create_workspace_resolver(
self.file_fetcher()?,
if self.options.use_byonm() {
PackageJsonDepResolution::Disabled
} else {
// todo(dsherret): this should be false for nodeModulesDir: true
PackageJsonDepResolution::Enabled
},
)
.await?;
if !resolver.diagnostics().is_empty() {
warn!(
Expand Down Expand Up @@ -759,6 +768,7 @@ impl CliFactory {
self.file_fetcher()?,
self.http_client_provider(),
self.npm_resolver().await?.as_ref(),
self.workspace_resolver().await?.as_ref(),
self.options.npm_system_info(),
))
}
Expand Down
48 changes: 47 additions & 1 deletion cli/js/40_jupyter.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,14 @@ async function formatInner(obj, raw) {
internals.jupyter = { formatInner };

function enableJupyter() {
const { op_jupyter_broadcast } = core.ops;
const { op_jupyter_broadcast, op_jupyter_input } = core.ops;

function input(
prompt,
password,
) {
return op_jupyter_input(prompt, password);
}

async function broadcast(
msgType,
Expand Down Expand Up @@ -412,6 +419,45 @@ function enableJupyter() {
return;
}

/**
* Prompt for user confirmation (in Jupyter Notebook context)
* Override confirm and prompt because they depend on a tty
* and in the Deno.jupyter environment that doesn't exist.
* @param {string} message - The message to display.
* @returns {Promise<boolean>} User confirmation.
*/
function confirm(message = "Confirm") {
const answer = input(`${message} [y/N] `, false);
return answer === "Y" || answer === "y";
}

/**
* Prompt for user input (in Jupyter Notebook context)
* @param {string} message - The message to display.
* @param {string} defaultValue - The value used if none is provided.
* @param {object} options Options
* @param {boolean} options.password Hide the output characters
* @returns {Promise<string>} The user input.
*/
function prompt(
message = "Prompt",
defaultValue = "",
{ password = false } = {},
) {
if (defaultValue != "") {
message += ` [${defaultValue}]`;
}
const answer = input(`${message}`, password);

if (answer === "") {
return defaultValue;
}

return answer;
}

globalThis.confirm = confirm;
globalThis.prompt = prompt;
globalThis.Deno.jupyter = {
broadcast,
display,
Expand Down
Loading

0 comments on commit ae3f6e7

Please sign in to comment.