Skip to content

Commit 39276a3

Browse files
authored
docs: New docs. (#781)
1 parent 36de9f1 commit 39276a3

File tree

141 files changed

+2746
-2859
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2746
-2859
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ jobs:
250250
- name: Create release body
251251
run: |
252252
if [[ "${{ inputs.npm_tag }}" == "latest" ]]; then
253-
INSTALL_BASH="curl -fsSL https://viteplus.dev/install.sh | bash"
254-
INSTALL_PS1="irm https://viteplus.dev/install.ps1 | iex"
253+
INSTALL_BASH="curl -fsSL https://vite.plus | bash"
254+
INSTALL_PS1="irm https://vite.plus/ps1 | iex"
255255
else
256-
INSTALL_BASH="curl -fsSL https://viteplus.dev/install.sh | VITE_PLUS_VERSION=${{ env.VERSION }} bash"
257-
INSTALL_PS1="\\\$env:VITE_PLUS_VERSION=\\\"${{ env.VERSION }}\\\"; irm https://viteplus.dev/install.ps1 | iex"
256+
INSTALL_BASH="curl -fsSL https://vite.plus | VITE_PLUS_VERSION=${{ env.VERSION }} bash"
257+
INSTALL_PS1="\\\$env:VITE_PLUS_VERSION=\\\"${{ env.VERSION }}\\\"; irm https://vite.plus/ps1 | iex"
258258
fi
259259
cat > ./RELEASE_BODY.md <<EOF
260260
## vite-plus v${{ env.VERSION }}
@@ -307,6 +307,6 @@ jobs:
307307
• vite-plus@${{ env.VERSION }}
308308
309309
**Install:**
310-
• macOS/Linux: `curl -fsSL https://viteplus.dev/install.sh | bash`
311-
• Windows: `irm https://viteplus.dev/install.ps1 | iex`
310+
• macOS/Linux: `curl -fsSL https://vite.plus | bash`
311+
• Windows: `irm https://vite.plus/ps1 | iex`
312312
embed-url: https://github.com/${{ github.repository }}/releases/tag/v${{ env.VERSION }}

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["oxc.oxc-vscode"]
2+
"recommendations": ["VoidZero.vite-plus-extension-pack"]
33
}

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@
1717
"typescript.preferences.importModuleSpecifierEnding": "js",
1818
"typescript.reportStyleChecksAsWarnings": false,
1919
"typescript.updateImportsOnFileMove.enabled": "always",
20-
"typescript.tsdk": "node_modules/typescript/lib",
2120
"typescript.experimental.useTsgo": true
2221
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Install Vite+ globally as `vp`:
3131
For Linux or macOS:
3232

3333
```bash
34-
curl -fsSL https://viteplus.dev/install.sh | bash
34+
curl -fsSL https://vite.plus | bash
3535
```
3636

3737
For Windows:
@@ -140,6 +140,7 @@ Vite+ automatically wraps your package manager (pnpm, npm, or Yarn) based on `pa
140140
#### Maintain
141141

142142
- **upgrade** - Update `vp` itself to the latest version
143+
- **implode** - Remove `vp` and all related data
143144

144145
### Scaffolding your first Vite+ project
145146

crates/vite_global_cli/src/help.rs

Lines changed: 92 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct HelpDoc {
1010
pub usage: &'static str,
1111
pub summary: Vec<&'static str>,
1212
pub sections: Vec<HelpSection>,
13+
pub documentation_url: Option<&'static str>,
1314
}
1415

1516
#[derive(Clone, Debug)]
@@ -29,6 +30,7 @@ struct OwnedHelpDoc {
2930
usage: String,
3031
summary: Vec<String>,
3132
sections: Vec<OwnedHelpSection>,
33+
documentation_url: Option<String>,
3234
}
3335

3436
#[derive(Clone, Debug)]
@@ -55,6 +57,33 @@ fn section_lines(title: &'static str, lines: Vec<&'static str>) -> HelpSection {
5557
HelpSection::Lines { title, lines }
5658
}
5759

60+
fn documentation_url_for_command_path(command_path: &[&str]) -> Option<&'static str> {
61+
match command_path {
62+
[] => Some("https://viteplus.dev/guide/"),
63+
["create"] => Some("https://viteplus.dev/guide/create"),
64+
["migrate"] => Some("https://viteplus.dev/guide/migrate"),
65+
["config"] | ["staged"] => Some("https://viteplus.dev/guide/commit-hooks"),
66+
[
67+
"install" | "add" | "remove" | "update" | "dedupe" | "outdated" | "list" | "ls" | "why"
68+
| "info" | "view" | "show" | "link" | "unlink" | "pm",
69+
..,
70+
] => Some("https://viteplus.dev/guide/install"),
71+
["dev"] => Some("https://viteplus.dev/guide/dev"),
72+
["check"] => Some("https://viteplus.dev/guide/check"),
73+
["lint"] => Some("https://viteplus.dev/guide/lint"),
74+
["fmt"] => Some("https://viteplus.dev/guide/fmt"),
75+
["test"] => Some("https://viteplus.dev/guide/test"),
76+
["run"] => Some("https://viteplus.dev/guide/run"),
77+
["exec" | "dlx"] => Some("https://viteplus.dev/guide/vpx"),
78+
["cache"] => Some("https://viteplus.dev/guide/cache"),
79+
["build" | "preview"] => Some("https://viteplus.dev/guide/build"),
80+
["pack"] => Some("https://viteplus.dev/guide/pack"),
81+
["env", ..] => Some("https://viteplus.dev/guide/env"),
82+
["upgrade"] => Some("https://viteplus.dev/guide/upgrade"),
83+
_ => None,
84+
}
85+
}
86+
5887
pub fn render_heading(title: &str) -> String {
5988
let heading = format!("{title}:");
6089
if !should_style_help() {
@@ -73,21 +102,12 @@ fn render_usage_value(usage: &str) -> String {
73102
}
74103

75104
fn should_accent_heading(title: &str) -> bool {
76-
matches!(
77-
title,
78-
"Start"
79-
| "Develop"
80-
| "Execute"
81-
| "Build"
82-
| "Manage Dependencies"
83-
| "Maintain"
84-
| "Setup"
85-
| "Manage"
86-
| "Inspect"
87-
| "Examples"
88-
| "Options"
89-
| "Related Commands"
90-
)
105+
title != "Usage"
106+
}
107+
108+
fn write_documentation_footer(output: &mut String, documentation_url: &str) {
109+
let _ = writeln!(output);
110+
let _ = writeln!(output, "{} {documentation_url}", render_heading("Documentation"));
91111
}
92112

93113
pub fn should_style_help() -> bool {
@@ -189,6 +209,10 @@ pub fn render_help_doc(doc: &HelpDoc) -> String {
189209
}
190210
}
191211

212+
if let Some(documentation_url) = doc.documentation_url {
213+
write_documentation_footer(&mut output, documentation_url);
214+
}
215+
192216
output
193217
}
194218

@@ -222,6 +246,10 @@ fn render_owned_help_doc(doc: &OwnedHelpDoc) -> String {
222246
}
223247
}
224248

249+
if let Some(documentation_url) = &doc.documentation_url {
250+
write_documentation_footer(&mut output, documentation_url);
251+
}
252+
225253
output
226254
}
227255

@@ -386,7 +414,7 @@ fn parse_clap_help_to_doc(raw_help: &str) -> Option<OwnedHelpDoc> {
386414
}
387415
}
388416

389-
Some(OwnedHelpDoc { usage, summary, sections })
417+
Some(OwnedHelpDoc { usage, summary, sections, documentation_url: None })
390418
}
391419

392420
pub fn top_level_help_doc() -> HelpDoc {
@@ -459,6 +487,7 @@ pub fn top_level_help_doc() -> HelpDoc {
459487
],
460488
),
461489
],
490+
documentation_url: documentation_url_for_command_path(&[]),
462491
}
463492
}
464493

@@ -546,6 +575,7 @@ fn env_help_doc() -> HelpDoc {
546575
],
547576
),
548577
],
578+
documentation_url: documentation_url_for_command_path(&["env"]),
549579
}
550580
}
551581

@@ -577,6 +607,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
577607
vec![" vp dev", " vp dev --open", " vp dev --host localhost --port 5173"],
578608
),
579609
],
610+
documentation_url: documentation_url_for_command_path(&["dev"]),
580611
}),
581612
"build" => Some(HelpDoc {
582613
usage: "vp build [ROOT] [OPTIONS]",
@@ -604,6 +635,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
604635
vec![" vp build", " vp build --watch", " vp build --sourcemap"],
605636
),
606637
],
638+
documentation_url: documentation_url_for_command_path(&["build"]),
607639
}),
608640
"preview" => Some(HelpDoc {
609641
usage: "vp preview [ROOT] [OPTIONS]",
@@ -628,6 +660,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
628660
),
629661
section_lines("Examples", vec![" vp preview", " vp preview --port 4173"]),
630662
],
663+
documentation_url: documentation_url_for_command_path(&["preview"]),
631664
}),
632665
"test" => Some(HelpDoc {
633666
usage: "vp test [COMMAND] [FILTERS] [OPTIONS]",
@@ -666,6 +699,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
666699
],
667700
),
668701
],
702+
documentation_url: documentation_url_for_command_path(&["test"]),
669703
}),
670704
"lint" => Some(HelpDoc {
671705
usage: "vp lint [PATH]... [OPTIONS]",
@@ -692,6 +726,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
692726
],
693727
),
694728
],
729+
documentation_url: documentation_url_for_command_path(&["lint"]),
695730
}),
696731
"fmt" => Some(HelpDoc {
697732
usage: "vp fmt [PATH]... [OPTIONS]",
@@ -714,6 +749,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
714749
vec![" vp fmt", " vp fmt src --check", " vp fmt . --write"],
715750
),
716751
],
752+
documentation_url: documentation_url_for_command_path(&["fmt"]),
717753
}),
718754
"check" => Some(HelpDoc {
719755
usage: "vp check [OPTIONS] [PATHS]...",
@@ -737,6 +773,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
737773
],
738774
),
739775
],
776+
documentation_url: documentation_url_for_command_path(&["check"]),
740777
}),
741778
"pack" => Some(HelpDoc {
742779
usage: "vp pack [...FILES] [OPTIONS]",
@@ -759,6 +796,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
759796
vec![" vp pack", " vp pack src/index.ts --dts", " vp pack --watch"],
760797
),
761798
],
799+
documentation_url: documentation_url_for_command_path(&["pack"]),
762800
}),
763801
"run" => Some(HelpDoc {
764802
usage: "vp run [OPTIONS] [TASK_SPECIFIER] [ADDITIONAL_ARGS]...",
@@ -809,6 +847,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
809847
],
810848
),
811849
],
850+
documentation_url: documentation_url_for_command_path(&["run"]),
812851
}),
813852
"exec" => Some(HelpDoc {
814853
usage: "vp exec [OPTIONS] [COMMAND]...",
@@ -862,6 +901,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
862901
],
863902
),
864903
],
904+
documentation_url: documentation_url_for_command_path(&["exec"]),
865905
}),
866906
"cache" => Some(HelpDoc {
867907
usage: "vp cache <COMMAND>",
@@ -870,6 +910,7 @@ fn delegated_help_doc(command: &str) -> Option<HelpDoc> {
870910
section_rows("Commands", vec![row("clean", "Clean up all the cache")]),
871911
section_rows("Options", vec![row("-h, --help", "Print help")]),
872912
],
913+
documentation_url: documentation_url_for_command_path(&["cache"]),
873914
}),
874915
_ => None,
875916
}
@@ -1010,6 +1051,11 @@ pub fn print_unified_clap_help_for_path(command_path: &[&str]) -> bool {
10101051
let Some(doc) = parse_clap_help_to_doc(&raw_help) else {
10111052
return false;
10121053
};
1054+
let doc = OwnedHelpDoc {
1055+
documentation_url: documentation_url_for_command_path(command_path)
1056+
.map(ToString::to_string),
1057+
..doc
1058+
};
10131059

10141060
println!("{}", vite_shared::header::vite_plus_header());
10151061
println!();
@@ -1020,8 +1066,8 @@ pub fn print_unified_clap_help_for_path(command_path: &[&str]) -> bool {
10201066
#[cfg(test)]
10211067
mod tests {
10221068
use super::{
1023-
has_help_flag_before_terminator, parse_clap_help_to_doc, parse_rows, split_comment_suffix,
1024-
strip_ansi,
1069+
HelpDoc, documentation_url_for_command_path, has_help_flag_before_terminator,
1070+
parse_clap_help_to_doc, parse_rows, render_help_doc, split_comment_suffix, strip_ansi,
10251071
};
10261072

10271073
#[test]
@@ -1110,4 +1156,32 @@ Options:
11101156
fn split_comment_suffix_returns_none_without_comment() {
11111157
assert!(split_comment_suffix(" vp env list").is_none());
11121158
}
1159+
1160+
#[test]
1161+
fn docs_url_is_mapped_for_grouped_commands() {
1162+
assert_eq!(
1163+
documentation_url_for_command_path(&["add"]),
1164+
Some("https://viteplus.dev/guide/install")
1165+
);
1166+
assert_eq!(
1167+
documentation_url_for_command_path(&["env", "list"]),
1168+
Some("https://viteplus.dev/guide/env")
1169+
);
1170+
assert_eq!(
1171+
documentation_url_for_command_path(&["config"]),
1172+
Some("https://viteplus.dev/guide/commit-hooks")
1173+
);
1174+
}
1175+
1176+
#[test]
1177+
fn render_help_doc_appends_documentation_footer() {
1178+
let output = render_help_doc(&HelpDoc {
1179+
usage: "vp demo",
1180+
summary: vec![],
1181+
sections: vec![],
1182+
documentation_url: Some("https://viteplus.dev/guide/demo"),
1183+
});
1184+
1185+
assert!(output.contains("Documentation: https://viteplus.dev/guide/demo"));
1186+
}
11131187
}

0 commit comments

Comments
 (0)