mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat(install): change 'Add ...' message (#24949)
Changes messages printed by `deno add` from `Add @oak/oak - jsr:@oak/oak^16.1.0` to `Add jsr:@oak/oak16.1.0`.
This commit is contained in:
parent
e7be763690
commit
c94d1b10f8
4 changed files with 16 additions and 13 deletions
|
@ -267,10 +267,10 @@ pub async fn add(
|
||||||
let is_npm = config_file.is_npm();
|
let is_npm = config_file.is_npm();
|
||||||
for selected_package in selected_packages {
|
for selected_package in selected_packages {
|
||||||
log::info!(
|
log::info!(
|
||||||
"Add {} - {}@{}",
|
"Add {}{}{}",
|
||||||
crate::colors::green(&selected_package.import_name),
|
crate::colors::green(&selected_package.package_name),
|
||||||
selected_package.package_name,
|
crate::colors::gray("@"),
|
||||||
selected_package.version_req
|
selected_package.selected_version
|
||||||
);
|
);
|
||||||
|
|
||||||
if is_npm {
|
if is_npm {
|
||||||
|
@ -323,6 +323,7 @@ struct SelectedPackage {
|
||||||
import_name: String,
|
import_name: String,
|
||||||
package_name: String,
|
package_name: String,
|
||||||
version_req: String,
|
version_req: String,
|
||||||
|
selected_version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PackageAndVersion {
|
enum PackageAndVersion {
|
||||||
|
@ -350,6 +351,7 @@ async fn find_package_and_select_version_for_req(
|
||||||
import_name: add_package_req.alias,
|
import_name: add_package_req.alias,
|
||||||
package_name: jsr_prefixed_name,
|
package_name: jsr_prefixed_name,
|
||||||
version_req: format!("{}{}", range_symbol, &nv.version),
|
version_req: format!("{}{}", range_symbol, &nv.version),
|
||||||
|
selected_version: nv.version.to_string(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
AddPackageReqValue::Npm(req) => {
|
AddPackageReqValue::Npm(req) => {
|
||||||
|
@ -366,6 +368,7 @@ async fn find_package_and_select_version_for_req(
|
||||||
import_name: add_package_req.alias,
|
import_name: add_package_req.alias,
|
||||||
package_name: npm_prefixed_name,
|
package_name: npm_prefixed_name,
|
||||||
version_req: format!("{}{}", range_symbol, &nv.version),
|
version_req: format!("{}{}", range_symbol, &nv.version),
|
||||||
|
selected_version: nv.version.to_string(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ fn add_basic() {
|
||||||
let output = context.new_command().args("add @denotest/add").run();
|
let output = context.new_command().args("add @denotest/add").run();
|
||||||
output.assert_exit_code(0);
|
output.assert_exit_code(0);
|
||||||
let output = output.combined_output();
|
let output = output.combined_output();
|
||||||
assert_contains!(output, "Add @denotest/add");
|
assert_contains!(output, "Add jsr:@denotest/add");
|
||||||
temp_dir.join("deno.json").assert_matches_json(json!({
|
temp_dir.join("deno.json").assert_matches_json(json!({
|
||||||
"name": "@foo/bar",
|
"name": "@foo/bar",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
@ -38,7 +38,7 @@ fn add_basic_no_deno_json() {
|
||||||
let output = context.new_command().args("add @denotest/add").run();
|
let output = context.new_command().args("add @denotest/add").run();
|
||||||
output.assert_exit_code(0);
|
output.assert_exit_code(0);
|
||||||
let output = output.combined_output();
|
let output = output.combined_output();
|
||||||
assert_contains!(output, "Add @denotest/add");
|
assert_contains!(output, "Add jsr:@denotest/add");
|
||||||
// Don't use `assert_matches_json` to ensure the file is properly formatted.
|
// Don't use `assert_matches_json` to ensure the file is properly formatted.
|
||||||
let expected = r#"{
|
let expected = r#"{
|
||||||
"imports": {
|
"imports": {
|
||||||
|
@ -58,7 +58,7 @@ fn add_basic_with_empty_deno_json() {
|
||||||
let output = context.new_command().args("add @denotest/add").run();
|
let output = context.new_command().args("add @denotest/add").run();
|
||||||
output.assert_exit_code(0);
|
output.assert_exit_code(0);
|
||||||
let output = output.combined_output();
|
let output = output.combined_output();
|
||||||
assert_contains!(output, "Add @denotest/add");
|
assert_contains!(output, "Add jsr:@denotest/add");
|
||||||
temp_dir
|
temp_dir
|
||||||
.path()
|
.path()
|
||||||
.join("deno.json")
|
.join("deno.json")
|
||||||
|
@ -77,7 +77,7 @@ fn add_version_contraint() {
|
||||||
let output = context.new_command().args("add @denotest/add@1").run();
|
let output = context.new_command().args("add @denotest/add@1").run();
|
||||||
output.assert_exit_code(0);
|
output.assert_exit_code(0);
|
||||||
let output = output.combined_output();
|
let output = output.combined_output();
|
||||||
assert_contains!(output, "Add @denotest/add");
|
assert_contains!(output, "Add jsr:@denotest/add");
|
||||||
temp_dir.join("deno.json").assert_matches_json(json!({
|
temp_dir.join("deno.json").assert_matches_json(json!({
|
||||||
"imports": {
|
"imports": {
|
||||||
"@denotest/add": "jsr:@denotest/add@^1.0.0"
|
"@denotest/add": "jsr:@denotest/add@^1.0.0"
|
||||||
|
@ -93,7 +93,7 @@ fn add_tilde() {
|
||||||
let output = context.new_command().args("add @denotest/add@~1").run();
|
let output = context.new_command().args("add @denotest/add@~1").run();
|
||||||
output.assert_exit_code(0);
|
output.assert_exit_code(0);
|
||||||
let output = output.combined_output();
|
let output = output.combined_output();
|
||||||
assert_contains!(output, "Add @denotest/add");
|
assert_contains!(output, "Add jsr:@denotest/add");
|
||||||
temp_dir.join("deno.json").assert_matches_json(json!({
|
temp_dir.join("deno.json").assert_matches_json(json!({
|
||||||
"imports": {
|
"imports": {
|
||||||
"@denotest/add": "jsr:@denotest/add@~1.0.0"
|
"@denotest/add": "jsr:@denotest/add@~1.0.0"
|
||||||
|
@ -118,7 +118,7 @@ fn add_multiple() {
|
||||||
.run();
|
.run();
|
||||||
output.assert_exit_code(0);
|
output.assert_exit_code(0);
|
||||||
let output = output.combined_output();
|
let output = output.combined_output();
|
||||||
assert_contains!(output, "Add @denotest/add");
|
assert_contains!(output, "Add jsr:@denotest/add");
|
||||||
temp_dir.join("deno.json").assert_matches_json(json!({
|
temp_dir.join("deno.json").assert_matches_json(json!({
|
||||||
"name": "@foo/bar",
|
"name": "@foo/bar",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
@ -138,7 +138,7 @@ fn add_npm() {
|
||||||
let output = context.new_command().args("add npm:chalk@4.1").run();
|
let output = context.new_command().args("add npm:chalk@4.1").run();
|
||||||
output.assert_exit_code(0);
|
output.assert_exit_code(0);
|
||||||
let output = output.combined_output();
|
let output = output.combined_output();
|
||||||
assert_contains!(output, "Add chalk");
|
assert_contains!(output, "Add npm:chalk");
|
||||||
temp_dir.join("deno.json").assert_matches_json(json!({
|
temp_dir.join("deno.json").assert_matches_json(json!({
|
||||||
"imports": {
|
"imports": {
|
||||||
"chalk": "npm:chalk@^4.1.2"
|
"chalk": "npm:chalk@^4.1.2"
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Add @denotest/esm-basic - npm:@denotest/esm-basic@^1.0.0
|
Add npm:@denotest/esm-basic@1.0.0
|
||||||
Download http://localhost:4260/@denotest/esm-basic
|
Download http://localhost:4260/@denotest/esm-basic
|
||||||
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
|
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Add @denotest/esm-basic - npm:@denotest/esm-basic@^1.0.0
|
Add npm:@denotest/esm-basic@1.0.0
|
||||||
Download http://localhost:4260/@denotest/esm-basic
|
Download http://localhost:4260/@denotest/esm-basic
|
||||||
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
|
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
|
||||||
Initialize @denotest/esm-basic@1.0.0
|
Initialize @denotest/esm-basic@1.0.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue