mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
feat(config/jsr): add license field (#25056)
1. Adds a new "license" field. 1. Adds this field by default when doing `deno init --lib`
This commit is contained in:
parent
105d27bc7d
commit
57cd2951f1
9 changed files with 24 additions and 15 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1360,9 +1360,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_config"
|
name = "deno_config"
|
||||||
version = "0.28.0"
|
version = "0.29.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc1f3c577bf7fdbb449cb99c2560309364c71cc3dcc7af94387ef8810b089173"
|
checksum = "4bc5aa53d1c3a3d0b9fd218e3f30f1080312f811b60e1866b88ec9f665447c4e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"deno_package_json",
|
"deno_package_json",
|
||||||
|
|
|
@ -65,7 +65,7 @@ winres.workspace = true
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
||||||
deno_cache_dir = { workspace = true }
|
deno_cache_dir = { workspace = true }
|
||||||
deno_config = { version = "=0.28.0", features = ["workspace", "sync"] }
|
deno_config = { version = "=0.29.0", features = ["workspace", "sync"] }
|
||||||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||||
deno_doc = { version = "0.146.0", features = ["html", "syntect"] }
|
deno_doc = { version = "0.146.0", features = ["html", "syntect"] }
|
||||||
deno_emit = "=0.44.0"
|
deno_emit = "=0.44.0"
|
||||||
|
|
|
@ -546,6 +546,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"license": {
|
||||||
|
"description": "The SPDX license identifier if this is a JSR package. Specify this or add a license file to the package.",
|
||||||
|
"type": ["string"]
|
||||||
|
},
|
||||||
"lock": {
|
"lock": {
|
||||||
"description": "Whether to use a lock file or the path to use for the lock file. Can be overridden by CLI arguments.",
|
"description": "Whether to use a lock file or the path to use for the lock file. Can be overridden by CLI arguments.",
|
||||||
"type": ["string", "boolean"],
|
"type": ["string", "boolean"],
|
||||||
|
|
|
@ -138,6 +138,7 @@ Deno.test(function addTest() {
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"dev": "deno test --watch mod.ts"
|
"dev": "deno test --watch mod.ts"
|
||||||
},
|
},
|
||||||
|
"license": "MIT",
|
||||||
"imports": {
|
"imports": {
|
||||||
"@std/assert": "jsr:@std/assert@1"
|
"@std/assert": "jsr:@std/assert@1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -120,8 +120,7 @@ pub enum PublishDiagnostic {
|
||||||
},
|
},
|
||||||
SyntaxError(ParseDiagnostic),
|
SyntaxError(ParseDiagnostic),
|
||||||
MissingLicense {
|
MissingLicense {
|
||||||
/// This only exists because diagnostics require a location.
|
config_specifier: Url,
|
||||||
expected_path: PathBuf,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +213,7 @@ impl Diagnostic for PublishDiagnostic {
|
||||||
MissingConstraint { specifier, .. } => Cow::Owned(format!("specifier '{}' is missing a version constraint", specifier)),
|
MissingConstraint { specifier, .. } => Cow::Owned(format!("specifier '{}' is missing a version constraint", specifier)),
|
||||||
BannedTripleSlashDirectives { .. } => Cow::Borrowed("triple slash directives that modify globals are not allowed"),
|
BannedTripleSlashDirectives { .. } => Cow::Borrowed("triple slash directives that modify globals are not allowed"),
|
||||||
SyntaxError(diagnostic) => diagnostic.message(),
|
SyntaxError(diagnostic) => diagnostic.message(),
|
||||||
MissingLicense { .. } => Cow::Borrowed("missing license file"),
|
MissingLicense { .. } => Cow::Borrowed("missing license field or file"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,8 +281,8 @@ impl Diagnostic for PublishDiagnostic {
|
||||||
text_info: Cow::Borrowed(text_info),
|
text_info: Cow::Borrowed(text_info),
|
||||||
},
|
},
|
||||||
SyntaxError(diagnostic) => diagnostic.location(),
|
SyntaxError(diagnostic) => diagnostic.location(),
|
||||||
MissingLicense { expected_path } => DiagnosticLocation::Path {
|
MissingLicense { config_specifier } => DiagnosticLocation::Module {
|
||||||
path: expected_path.clone(),
|
specifier: Cow::Borrowed(config_specifier),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +399,7 @@ impl Diagnostic for PublishDiagnostic {
|
||||||
),
|
),
|
||||||
SyntaxError(diagnostic) => diagnostic.hint(),
|
SyntaxError(diagnostic) => diagnostic.hint(),
|
||||||
MissingLicense { .. } => Some(
|
MissingLicense { .. } => Some(
|
||||||
Cow::Borrowed("add a LICENSE file to the package and ensure it is not ignored from being published"),
|
Cow::Borrowed("add a \"license\" field. Alternatively, add a LICENSE file to the package and ensure it is not ignored from being published"),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,6 +449,8 @@ impl PublishPreparer {
|
||||||
let cli_options = self.cli_options.clone();
|
let cli_options = self.cli_options.clone();
|
||||||
let source_cache = self.source_cache.clone();
|
let source_cache = self.source_cache.clone();
|
||||||
let config_path = config_path.clone();
|
let config_path = config_path.clone();
|
||||||
|
let config_url = deno_json.specifier.clone();
|
||||||
|
let has_license_field = package.license.is_some();
|
||||||
move || {
|
move || {
|
||||||
let root_specifier =
|
let root_specifier =
|
||||||
ModuleSpecifier::from_directory_path(&root_dir).unwrap();
|
ModuleSpecifier::from_directory_path(&root_dir).unwrap();
|
||||||
|
@ -467,7 +469,9 @@ impl PublishPreparer {
|
||||||
&diagnostics_collector,
|
&diagnostics_collector,
|
||||||
);
|
);
|
||||||
|
|
||||||
if !has_license_file(publish_paths.iter().map(|p| &p.specifier)) {
|
if !has_license_field
|
||||||
|
&& !has_license_file(publish_paths.iter().map(|p| &p.specifier))
|
||||||
|
{
|
||||||
if let Some(license_path) =
|
if let Some(license_path) =
|
||||||
resolve_license_file(&root_dir, cli_options.workspace())
|
resolve_license_file(&root_dir, cli_options.workspace())
|
||||||
{
|
{
|
||||||
|
@ -483,7 +487,7 @@ impl PublishPreparer {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
diagnostics_collector.push(PublishDiagnostic::MissingLicense {
|
diagnostics_collector.push(PublishDiagnostic::MissingLicense {
|
||||||
expected_path: root_dir.join("LICENSE"),
|
config_specifier: config_url,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./mod.js"
|
".": "./mod.js"
|
||||||
}
|
},
|
||||||
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
Check file:///[WILDLINE]/missing_license/mod.ts
|
Check file:///[WILDLINE]/missing_license/mod.ts
|
||||||
Checking for slow types in the public API...
|
Checking for slow types in the public API...
|
||||||
Check file:///[WILDLINE]/missing_license/mod.ts
|
Check file:///[WILDLINE]/missing_license/mod.ts
|
||||||
error[missing-license]: missing license file
|
error[missing-license]: missing license field or file
|
||||||
--> [WILDLINE]LICENSE
|
--> [WILDLINE]deno.json
|
||||||
= hint: add a LICENSE file to the package and ensure it is not ignored from being published
|
= hint: add a "license" field. Alternatively, add a LICENSE file to the package and ensure it is not ignored from being published
|
||||||
|
|
||||||
docs: https://jsr.io/go/missing-license
|
docs: https://jsr.io/go/missing-license
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue