1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

fix(publish): support deno.jsonc file (#21948)

This commit is contained in:
Bartek Iwańczuk 2024-01-15 16:07:57 +01:00 committed by GitHub
parent bc8d00c880
commit 72ecfe0419
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 11 deletions

View file

@ -71,6 +71,16 @@ itest!(successful {
temp_cwd: true,
});
itest!(config_file_jsonc {
args: "publish --token 'sadfasdf'",
output: "publish/deno_jsonc.out",
cwd: Some("publish/deno_jsonc"),
copy_temp_dir: Some("publish/deno_jsonc"),
envs: env_vars_for_registry(),
http_server: true,
temp_cwd: true,
});
itest!(workspace_all {
args: "publish --token 'sadfasdf'",
output: "publish/workspace.out",

View file

@ -0,0 +1,6 @@
Checking fast check type graph for errors...
Ensuring type checks...
Check file:///[WILDCARD]/publish/deno_jsonc/mod.ts
Publishing @foo/bar@1.0.0 ...
Successfully published @foo/bar@1.0.0
Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details

View file

@ -0,0 +1,11 @@
{
// It's .jsonc file so it can have comments
"name": "@foo/bar",
"version": "1.0.0",
"exports": {
".": "./mod.ts"
},
"imports": {
"@std/http": "./std_http.ts"
}
}

View file

@ -0,0 +1,5 @@
import http from "@std/http";
export function foobar(): { fileServer(): void } {
return http.fileServer;
}

View file

@ -0,0 +1,6 @@
// temp until we get jsr:@std/http in the test server
export default {
fileServer() {
console.log("Hi");
},
};

View file

@ -1 +1 @@
error: Failed to read deno.json file at [WILDCARD]missing_deno_json[WILDCARD]
error: Couldn't find a deno.json or a deno.jsonc configuration file in [WILDCARD]

View file

@ -819,18 +819,22 @@ pub async fn publish(
});
let directory_path = cli_factory.cli_options().initial_cwd();
// TODO: doesn't handle jsonc
let deno_json_path = directory_path.join("deno.json");
let deno_json = ConfigFile::read(&deno_json_path).with_context(|| {
format!(
"Failed to read deno.json file at {}",
deno_json_path.display()
)
})?;
let cli_options = cli_factory.cli_options();
let Some(config_file) = cli_options.maybe_config_file() else {
bail!(
"Couldn't find a deno.json or a deno.jsonc configuration file in {}.",
directory_path.display()
);
};
let (publish_order_graph, prepared_package_by_name) =
prepare_packages_for_publishing(&cli_factory, deno_json, import_map)
.await?;
prepare_packages_for_publishing(
&cli_factory,
config_file.clone(),
import_map,
)
.await?;
if prepared_package_by_name.is_empty() {
bail!("No packages to publish");