summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/integration/publish_tests.rs10
-rw-r--r--cli/tests/testdata/publish/deno_jsonc.out6
-rw-r--r--cli/tests/testdata/publish/deno_jsonc/deno.jsonc11
-rw-r--r--cli/tests/testdata/publish/deno_jsonc/mod.ts5
-rw-r--r--cli/tests/testdata/publish/deno_jsonc/std_http.ts6
-rw-r--r--cli/tests/testdata/publish/missing_deno_json.out2
-rw-r--r--cli/tools/registry/mod.rs24
7 files changed, 53 insertions, 11 deletions
diff --git a/cli/tests/integration/publish_tests.rs b/cli/tests/integration/publish_tests.rs
index a28736fac..e185065aa 100644
--- a/cli/tests/integration/publish_tests.rs
+++ b/cli/tests/integration/publish_tests.rs
@@ -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",
diff --git a/cli/tests/testdata/publish/deno_jsonc.out b/cli/tests/testdata/publish/deno_jsonc.out
new file mode 100644
index 000000000..2d5e4ffea
--- /dev/null
+++ b/cli/tests/testdata/publish/deno_jsonc.out
@@ -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
diff --git a/cli/tests/testdata/publish/deno_jsonc/deno.jsonc b/cli/tests/testdata/publish/deno_jsonc/deno.jsonc
new file mode 100644
index 000000000..4c9dfb08c
--- /dev/null
+++ b/cli/tests/testdata/publish/deno_jsonc/deno.jsonc
@@ -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"
+ }
+}
diff --git a/cli/tests/testdata/publish/deno_jsonc/mod.ts b/cli/tests/testdata/publish/deno_jsonc/mod.ts
new file mode 100644
index 000000000..4bb6da255
--- /dev/null
+++ b/cli/tests/testdata/publish/deno_jsonc/mod.ts
@@ -0,0 +1,5 @@
+import http from "@std/http";
+
+export function foobar(): { fileServer(): void } {
+ return http.fileServer;
+}
diff --git a/cli/tests/testdata/publish/deno_jsonc/std_http.ts b/cli/tests/testdata/publish/deno_jsonc/std_http.ts
new file mode 100644
index 000000000..9d57b36f3
--- /dev/null
+++ b/cli/tests/testdata/publish/deno_jsonc/std_http.ts
@@ -0,0 +1,6 @@
+// temp until we get jsr:@std/http in the test server
+export default {
+ fileServer() {
+ console.log("Hi");
+ },
+};
diff --git a/cli/tests/testdata/publish/missing_deno_json.out b/cli/tests/testdata/publish/missing_deno_json.out
index adaf33ea8..adb472c71 100644
--- a/cli/tests/testdata/publish/missing_deno_json.out
+++ b/cli/tests/testdata/publish/missing_deno_json.out
@@ -1 +1 @@
-error: Failed to read deno.json file at [WILDCARD]missing_deno_json[WILDCARD] \ No newline at end of file
+error: Couldn't find a deno.json or a deno.jsonc configuration file in [WILDCARD] \ No newline at end of file
diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs
index 2be90bf52..d635ccf55 100644
--- a/cli/tools/registry/mod.rs
+++ b/cli/tools/registry/mod.rs
@@ -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");