mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
fix(publish): support deno.jsonc file (#21948)
This commit is contained in:
parent
bc8d00c880
commit
72ecfe0419
7 changed files with 53 additions and 11 deletions
|
@ -71,6 +71,16 @@ itest!(successful {
|
||||||
temp_cwd: true,
|
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 {
|
itest!(workspace_all {
|
||||||
args: "publish --token 'sadfasdf'",
|
args: "publish --token 'sadfasdf'",
|
||||||
output: "publish/workspace.out",
|
output: "publish/workspace.out",
|
||||||
|
|
6
cli/tests/testdata/publish/deno_jsonc.out
vendored
Normal file
6
cli/tests/testdata/publish/deno_jsonc.out
vendored
Normal 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
|
11
cli/tests/testdata/publish/deno_jsonc/deno.jsonc
vendored
Normal file
11
cli/tests/testdata/publish/deno_jsonc/deno.jsonc
vendored
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
5
cli/tests/testdata/publish/deno_jsonc/mod.ts
vendored
Normal file
5
cli/tests/testdata/publish/deno_jsonc/mod.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import http from "@std/http";
|
||||||
|
|
||||||
|
export function foobar(): { fileServer(): void } {
|
||||||
|
return http.fileServer;
|
||||||
|
}
|
6
cli/tests/testdata/publish/deno_jsonc/std_http.ts
vendored
Normal file
6
cli/tests/testdata/publish/deno_jsonc/std_http.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// temp until we get jsr:@std/http in the test server
|
||||||
|
export default {
|
||||||
|
fileServer() {
|
||||||
|
console.log("Hi");
|
||||||
|
},
|
||||||
|
};
|
|
@ -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]
|
|
@ -819,17 +819,21 @@ pub async fn publish(
|
||||||
});
|
});
|
||||||
|
|
||||||
let directory_path = cli_factory.cli_options().initial_cwd();
|
let directory_path = cli_factory.cli_options().initial_cwd();
|
||||||
// TODO: doesn't handle jsonc
|
|
||||||
let deno_json_path = directory_path.join("deno.json");
|
let cli_options = cli_factory.cli_options();
|
||||||
let deno_json = ConfigFile::read(&deno_json_path).with_context(|| {
|
let Some(config_file) = cli_options.maybe_config_file() else {
|
||||||
format!(
|
bail!(
|
||||||
"Failed to read deno.json file at {}",
|
"Couldn't find a deno.json or a deno.jsonc configuration file in {}.",
|
||||||
deno_json_path.display()
|
directory_path.display()
|
||||||
)
|
);
|
||||||
})?;
|
};
|
||||||
|
|
||||||
let (publish_order_graph, prepared_package_by_name) =
|
let (publish_order_graph, prepared_package_by_name) =
|
||||||
prepare_packages_for_publishing(&cli_factory, deno_json, import_map)
|
prepare_packages_for_publishing(
|
||||||
|
&cli_factory,
|
||||||
|
config_file.clone(),
|
||||||
|
import_map,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if prepared_package_by_name.is_empty() {
|
if prepared_package_by_name.is_empty() {
|
||||||
|
|
Loading…
Reference in a new issue