mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
feat(publish): discover jsr.json and jsr.jsonc files (#22587)
Closes https://github.com/denoland/deno/issues/22491
This commit is contained in:
parent
d722de886b
commit
f1a691274e
11 changed files with 52 additions and 6 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1229,9 +1229,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_config"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc52f2cedd7f47b50fb67191f9cb1c5633b47017fb7da5b586278763110879e5"
|
||||
checksum = "ebbc05e20df2d5b8562205f9b0c296bc528e833b0de126d489781952e13d939f"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"glob",
|
||||
|
|
|
@ -64,7 +64,7 @@ winres.workspace = true
|
|||
[dependencies]
|
||||
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
||||
deno_cache_dir = { workspace = true }
|
||||
deno_config = "=0.11.0"
|
||||
deno_config = "=0.12.0"
|
||||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||
deno_doc = { version = "=0.113.1", features = ["html"] }
|
||||
deno_emit = "=0.38.2"
|
||||
|
|
|
@ -759,10 +759,17 @@ impl CliOptions {
|
|||
pub fn from_flags(flags: Flags) -> Result<Self, AnyError> {
|
||||
let initial_cwd =
|
||||
std::env::current_dir().with_context(|| "Failed getting cwd.")?;
|
||||
let additional_config_file_names =
|
||||
if matches!(flags.subcommand, DenoSubcommand::Publish(..)) {
|
||||
Some(vec!["jsr.json", "jsr.jsonc"])
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let maybe_config_file = ConfigFile::discover(
|
||||
&flags.config_flag,
|
||||
flags.config_path_args(&initial_cwd),
|
||||
&initial_cwd,
|
||||
additional_config_file_names,
|
||||
)?;
|
||||
|
||||
let mut maybe_package_json = None;
|
||||
|
|
|
@ -654,7 +654,8 @@ impl Inner {
|
|||
if let Some(root_uri) = self.config.root_uri() {
|
||||
let root_path = specifier_to_file_path(root_uri)?;
|
||||
let mut checked = std::collections::HashSet::new();
|
||||
let maybe_config = ConfigFile::discover_from(&root_path, &mut checked)?;
|
||||
let maybe_config =
|
||||
ConfigFile::discover_from(&root_path, &mut checked, None)?;
|
||||
Ok(maybe_config.map(|c| {
|
||||
lsp_log!(" Auto-resolved configuration file: \"{}\"", c.specifier);
|
||||
c
|
||||
|
|
|
@ -817,7 +817,7 @@ pub async fn publish(
|
|||
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 {}.",
|
||||
"Couldn't find a deno.json, deno.jsonc, jsr.json or jsr.jsonc configuration file in {}.",
|
||||
directory_path.display()
|
||||
);
|
||||
};
|
||||
|
|
|
@ -224,6 +224,14 @@ itest!(config_flag {
|
|||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(jsr_jsonc {
|
||||
args: "publish --token 'sadfasdf'",
|
||||
cwd: Some("publish/jsr_jsonc"),
|
||||
output: "publish/jsr_jsonc/mod.out",
|
||||
envs: env_vars_for_jsr_tests(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn ignores_gitignore() {
|
||||
let context = publish_context_builder().build();
|
||||
|
|
11
tests/testdata/publish/jsr_jsonc/jsr.jsonc
vendored
Normal file
11
tests/testdata/publish/jsr_jsonc/jsr.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"
|
||||
}
|
||||
}
|
6
tests/testdata/publish/jsr_jsonc/mod.out
vendored
Normal file
6
tests/testdata/publish/jsr_jsonc/mod.out
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
Check file:///[WILDCARD]/publish/jsr_jsonc/mod.ts
|
||||
Checking for slow types in the public API...
|
||||
Check file:///[WILDCARD]/publish/jsr_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
|
7
tests/testdata/publish/jsr_jsonc/mod.ts
vendored
Normal file
7
tests/testdata/publish/jsr_jsonc/mod.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
import http from "@std/http";
|
||||
|
||||
export function foobar(): { fileServer(): void } {
|
||||
return {
|
||||
fileServer: http.fileServer,
|
||||
};
|
||||
}
|
6
tests/testdata/publish/jsr_jsonc/std_http.ts
vendored
Normal file
6
tests/testdata/publish/jsr_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");
|
||||
},
|
||||
};
|
2
tests/testdata/publish/missing_deno_json.out
vendored
2
tests/testdata/publish/missing_deno_json.out
vendored
|
@ -1 +1 @@
|
|||
error: Couldn't find a deno.json or a deno.jsonc configuration file in [WILDCARD]
|
||||
error: Couldn't find a deno.json, deno.jsonc, jsr.json or jsr.jsonc configuration file in [WILDCARD]
|
Loading…
Reference in a new issue