Skip to content

Commit

Permalink
fix(publish): unfurling should always be done with the package json (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored and zebreus committed Jul 8, 2024
1 parent acc4125 commit 5db81f6
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 83 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.

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
36 changes: 18 additions & 18 deletions cli/standalone/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 18,7 @@ use std::process::Command;
use deno_ast::ModuleSpecifier;
use deno_config::workspace::PackageJsonDepResolution;
use deno_config::workspace::Workspace;
use deno_config::workspace::WorkspaceResolver;
use deno_core::anyhow::bail;
use deno_core::anyhow::Context;
use deno_core::error::AnyError;
Expand Down Expand Up @@ -376,6 377,7 @@ pub struct DenoCompileBinaryWriter<'a> {
file_fetcher: &'a FileFetcher,
http_client_provider: &'a HttpClientProvider,
npm_resolver: &'a dyn CliNpmResolver,
workspace_resolver: &'a WorkspaceResolver,
npm_system_info: NpmSystemInfo,
}

Expand All @@ -386,13 388,15 @@ impl<'a> DenoCompileBinaryWriter<'a> {
file_fetcher: &'a FileFetcher,
http_client_provider: &'a HttpClientProvider,
npm_resolver: &'a dyn CliNpmResolver,
workspace_resolver: &'a WorkspaceResolver,
npm_system_info: NpmSystemInfo,
) -> Self {
Self {
deno_dir,
file_fetcher,
http_client_provider,
npm_resolver,
workspace_resolver,
npm_system_info,
}
}
Expand All @@ -419,17 423,15 @@ impl<'a> DenoCompileBinaryWriter<'a> {
}
set_windows_binary_to_gui(&mut original_binary)?;
}
self
.write_standalone_binary(
writer,
original_binary,
eszip,
root_dir_url,
entrypoint,
cli_options,
compile_flags,
)
.await
self.write_standalone_binary(
writer,
original_binary,
eszip,
root_dir_url,
entrypoint,
cli_options,
compile_flags,
)
}

async fn get_base_binary(
Expand Down Expand Up @@ -512,7 514,7 @@ impl<'a> DenoCompileBinaryWriter<'a> {
/// This functions creates a standalone deno binary by appending a bundle
/// and magic trailer to the currently executing binary.
#[allow(clippy::too_many_arguments)]
async fn write_standalone_binary(
fn write_standalone_binary(
&self,
writer: &mut impl Write,
original_bin: Vec<u8>,
Expand All @@ -530,9 532,6 @@ impl<'a> DenoCompileBinaryWriter<'a> {
Some(CaData::Bytes(bytes)) => Some(bytes.clone()),
None => None,
};
let workspace_resolver = cli_options
.create_workspace_resolver(self.file_fetcher)
.await?;
let root_path = root_dir_url.inner().to_file_path().unwrap();
let (npm_vfs, npm_files, node_modules) = match self.npm_resolver.as_inner()
{
Expand Down Expand Up @@ -599,7 598,7 @@ impl<'a> DenoCompileBinaryWriter<'a> {
ca_data,
entrypoint_key: root_dir_url.specifier_key(entrypoint).into_owned(),
workspace_resolver: SerializedWorkspaceResolver {
import_map: workspace_resolver.maybe_import_map().map(|i| {
import_map: self.workspace_resolver.maybe_import_map().map(|i| {
SerializedWorkspaceResolverImportMap {
specifier: if i.base_url().scheme() == "file" {
root_dir_url.specifier_key(i.base_url()).into_owned()
Expand All @@ -610,7 609,8 @@ impl<'a> DenoCompileBinaryWriter<'a> {
json: i.to_json(),
}
}),
package_jsons: workspace_resolver
package_jsons: self
.workspace_resolver
.package_jsons()
.map(|pkg_json| {
(
Expand All @@ -621,7 621,7 @@ impl<'a> DenoCompileBinaryWriter<'a> {
)
})
.collect(),
pkg_json_resolution: workspace_resolver.pkg_json_dep_resolution(),
pkg_json_resolution: self.workspace_resolver.pkg_json_dep_resolution(),
},
node_modules,
disable_deprecated_api_warning: cli_options
Expand Down
Loading

0 comments on commit 5db81f6

Please sign in to comment.