1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -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:
HasanAlrimawi 2024-08-20 20:53:53 +03:00 committed by GitHub
parent 5168700be6
commit 0704454755
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 70 additions and 0 deletions

View file

@ -515,6 +515,15 @@ async fn sync_resolution_with_fs(
.add(package.clone(), package_path); .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 // finally stop showing the progress bar
drop(pb_guard); // explicit for clarity drop(pb_guard); // explicit for clarity
Ok::<_, AnyError>(()) Ok::<_, AnyError>(())

View file

@ -0,0 +1,3 @@
export declare function setValue(val: number): void;
export declare function getValue(): number;
export declare const url: string;

View file

@ -0,0 +1,11 @@
let value = 0;
export function setValue(newValue) {
value = newValue;
}
export function getValue() {
return value;
}
export const url = import.meta.url;

View file

@ -0,0 +1,9 @@
{
"name": "@denotest/deprecated-package",
"version": "1.0.0",
"type": "module",
"main": "main.mjs",
"types": "main.d.mts",
"deprecated": "Deprecated version"
}

View file

@ -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"
}
]
}

View file

@ -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

View file

@ -0,0 +1,2 @@
import { setValue } from "@denotest/deprecated-package";
setValue(5);

View file

@ -0,0 +1,3 @@
{
"dependencies": {}
}

View file

@ -0,0 +1,3 @@
{
"dependencies": { "@denotest/deprecated-package": "^1.0.0" }
}