mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 07:44:48 -05:00
feat: Print deprecation message for npm packages (#24992)
This commit adds ability to print deprecation notices for npm packages that have been marked as deprecated. Closes #24013
This commit is contained in:
parent
5168700be6
commit
0704454755
9 changed files with 70 additions and 0 deletions
|
@ -515,6 +515,15 @@ async fn sync_resolution_with_fs(
|
|||
.add(package.clone(), package_path);
|
||||
}
|
||||
|
||||
if let Some(deprecated) = &package.deprecated {
|
||||
log::info!(
|
||||
"{} {:?} is deprecated: {}",
|
||||
crate::colors::yellow("Warning"),
|
||||
package.id,
|
||||
crate::colors::gray(deprecated),
|
||||
);
|
||||
}
|
||||
|
||||
// finally stop showing the progress bar
|
||||
drop(pb_guard); // explicit for clarity
|
||||
Ok::<_, AnyError>(())
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export declare function setValue(val: number): void;
|
||||
export declare function getValue(): number;
|
||||
export declare const url: string;
|
|
@ -0,0 +1,11 @@
|
|||
let value = 0;
|
||||
|
||||
export function setValue(newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
|
||||
export function getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
export const url = import.meta.url;
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@denotest/deprecated-package",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "main.mjs",
|
||||
"types": "main.d.mts",
|
||||
"deprecated": "Deprecated version"
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"tempDir": true,
|
||||
"envs": {
|
||||
"DENO_FUTURE": "1"
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"args": "install npm:@denotest/deprecated-package",
|
||||
"output": "install.out"
|
||||
},
|
||||
{
|
||||
// make sure the dep got cached
|
||||
"args": "run --cached-only main.js",
|
||||
"exitCode": 0,
|
||||
"output": ""
|
||||
},
|
||||
{
|
||||
"args": [
|
||||
"eval",
|
||||
"console.log(Deno.readTextFileSync('package.json').trim())"
|
||||
],
|
||||
"output": "package.json.out"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
Add npm:@denotest/deprecated-package@1.0.0
|
||||
Download http://localhost:4260/@denotest/deprecated-package
|
||||
Download http://localhost:4260/@denotest/deprecated-package/1.0.0.tgz
|
||||
Initialize @denotest/deprecated-package@1.0.0
|
||||
Warning @denotest/deprecated-package@1.0.0 is deprecated: Deprecated version
|
2
tests/specs/install/install_deprecated_package/main.js
Normal file
2
tests/specs/install/install_deprecated_package/main.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
import { setValue } from "@denotest/deprecated-package";
|
||||
setValue(5);
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"dependencies": {}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"dependencies": { "@denotest/deprecated-package": "^1.0.0" }
|
||||
}
|
Loading…
Reference in a new issue