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

feat(publish): error on missing license file (#25011)

Closes https://github.com/denoland/deno/issues/24676
This commit is contained in:
David Sherret 2024-08-12 19:51:58 -04:00 committed by GitHub
parent 631e175498
commit 39a21fd78e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 9 deletions

View file

@ -172,8 +172,7 @@ impl Diagnostic for PublishDiagnostic {
MissingConstraint { .. } => DiagnosticLevel::Error, MissingConstraint { .. } => DiagnosticLevel::Error,
BannedTripleSlashDirectives { .. } => DiagnosticLevel::Error, BannedTripleSlashDirectives { .. } => DiagnosticLevel::Error,
SyntaxError { .. } => DiagnosticLevel::Error, SyntaxError { .. } => DiagnosticLevel::Error,
// todo(#24676): make this an error in Deno 1.46 MissingLicense { .. } => DiagnosticLevel::Error,
MissingLicense { .. } => DiagnosticLevel::Warning,
} }
} }

View file

@ -22,6 +22,7 @@ fn publish_non_exported_files_using_import_map() {
"@denotest/add": "jsr:@denotest/add@1" "@denotest/add": "jsr:@denotest/add@1"
} }
})); }));
temp_dir.join("LICENSE").write("");
// file not in the graph // file not in the graph
let other_ts = temp_dir.join("_other.ts"); let other_ts = temp_dir.join("_other.ts");
other_ts other_ts
@ -52,6 +53,7 @@ fn publish_warning_not_in_graph() {
"version": "1.0.0", "version": "1.0.0",
"exports": "./mod.ts", "exports": "./mod.ts",
})); }));
temp_dir.join("LICENSE").write("");
// file not in the graph that uses a non-analyzable dynamic import (cause a diagnostic) // file not in the graph that uses a non-analyzable dynamic import (cause a diagnostic)
let other_ts = temp_dir.join("_other.ts"); let other_ts = temp_dir.join("_other.ts");
other_ts other_ts
@ -92,6 +94,7 @@ fn ignores_gitignore() {
"version": "1.0.0", "version": "1.0.0",
"exports": "./main.ts" "exports": "./main.ts"
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join("main.ts").write("import './sub_dir/b.ts';"); temp_dir.join("main.ts").write("import './sub_dir/b.ts';");
@ -151,6 +154,7 @@ fn ignores_directories() {
sub_dir.join("sub_included.ts").write(""); sub_dir.join("sub_included.ts").write("");
temp_dir.join("main_included.ts").write(""); temp_dir.join("main_included.ts").write("");
temp_dir.join("LICENSE").write("");
let output = context let output = context
.new_command() .new_command()
@ -185,6 +189,7 @@ fn not_include_gitignored_file_unless_exact_match_in_include() {
] ]
} }
})); }));
temp_dir.join("LICENSE").write("");
temp_dir temp_dir
.join(".gitignore") .join(".gitignore")
@ -217,7 +222,7 @@ fn not_include_gitignored_file_unless_exact_match_in_include() {
} }
#[test] #[test]
fn gitignore_everything_exlcuded_override() { fn gitignore_everything_excluded_override() {
let context = publish_context_builder().build(); let context = publish_context_builder().build();
let temp_dir = context.temp_dir().path(); let temp_dir = context.temp_dir().path();
@ -232,6 +237,7 @@ fn gitignore_everything_exlcuded_override() {
"exclude": ["!**"] "exclude": ["!**"]
} }
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join("root_main.ts").write(""); temp_dir.join("root_main.ts").write("");
let sub_dir = temp_dir.join("sub"); let sub_dir = temp_dir.join("sub");
@ -257,6 +263,7 @@ fn includes_directories_with_gitignore_when_unexcluded() {
"exclude": [ "!ignored.ts" ] "exclude": [ "!ignored.ts" ]
} }
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join(".gitignore").write("ignored.ts"); temp_dir.join(".gitignore").write("ignored.ts");
temp_dir.join("main.ts").write(""); temp_dir.join("main.ts").write("");
@ -284,6 +291,7 @@ fn includes_unexcluded_sub_dir() {
] ]
} }
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join("included1.ts").write(""); temp_dir.join("included1.ts").write("");
temp_dir.join("ignored/unexcluded").create_dir_all(); temp_dir.join("ignored/unexcluded").create_dir_all();
@ -310,6 +318,7 @@ fn includes_directories() {
"include": [ "deno.json", "main.ts" ] "include": [ "deno.json", "main.ts" ]
} }
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join("main.ts").write(""); temp_dir.join("main.ts").write("");
temp_dir.join("ignored.ts").write(""); temp_dir.join("ignored.ts").write("");
@ -335,6 +344,7 @@ fn not_includes_gitignored_dotenv() {
"version": "1.0.0", "version": "1.0.0",
"exports": "./main.ts", "exports": "./main.ts",
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join("main.ts").write(""); temp_dir.join("main.ts").write("");
temp_dir.join(".env").write("FOO=BAR"); temp_dir.join(".env").write("FOO=BAR");
@ -356,6 +366,7 @@ fn not_includes_vendor_dir_only_when_vendor_true() {
"version": "1.0.0", "version": "1.0.0",
"exports": "./main.ts", "exports": "./main.ts",
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join("main.ts").write(""); temp_dir.join("main.ts").write("");
let vendor_folder = temp_dir.join("vendor"); let vendor_folder = temp_dir.join("vendor");
@ -396,9 +407,9 @@ fn allow_dirty() {
"version": "1.0.0", "version": "1.0.0",
"exports": "./main.ts", "exports": "./main.ts",
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join("main.ts").write(""); temp_dir.join("main.ts").write("");
temp_dir.join("LICENSE").write("");
let cmd = Command::new("git") let cmd = Command::new("git")
.arg("init") .arg("init")
@ -447,6 +458,7 @@ fn allow_dirty_not_in_repo() {
"version": "1.0.0", "version": "1.0.0",
"exports": "./main.ts", "exports": "./main.ts",
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join("main.ts").write(""); temp_dir.join("main.ts").write("");
// At this point there are untracked files, but we're not in Git repo, // At this point there are untracked files, but we're not in Git repo,
@ -472,6 +484,7 @@ fn allow_dirty_dry_run() {
"version": "1.0.0", "version": "1.0.0",
"exports": "./main.ts", "exports": "./main.ts",
})); }));
temp_dir.join("LICENSE").write("");
temp_dir.join("main.ts").write(""); temp_dir.join("main.ts").write("");

View file

@ -1,4 +1,5 @@
{ {
"args": "publish --token 'sadfasdf'", "args": "publish --token 'sadfasdf'",
"output": "mod.out" "output": "mod.out",
"exitCode": 1
} }

View file

@ -1,12 +1,10 @@
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
warning[missing-license]: missing license file error[missing-license]: missing license file
--> [WILDLINE]LICENSE --> [WILDLINE]LICENSE
= hint: add a LICENSE file to the package and ensure it is not ignored from being published = hint: 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
Publishing @scope/pkg@1.0.0 ... error: Found 1 problem
Successfully published @scope/pkg@1.0.0
Visit http://127.0.0.1:4250/@scope/pkg@1.0.0 for details