Skip to content

Commit 9d872ab

Browse files
authored
feat(cli): detect SvelteKit and Vite (#5742)
1 parent b6027b2 commit 9d872ab

File tree

3 files changed

+41
-25
lines changed

3 files changed

+41
-25
lines changed

.changes/add-frameworks.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Detect SvelteKit and Vite for the init and info commands.

tooling/cli/Cargo.lock

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/cli/src/helpers/framework.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use std::fmt;
77
#[derive(Debug, Clone)]
88
pub enum Framework {
99
Svelte,
10+
SvelteKit,
1011
Angular,
1112
React,
1213
Nextjs,
13-
1414
Gatsby,
1515
Nuxt,
1616
Quasar,
@@ -22,6 +22,7 @@ impl Framework {
2222
pub fn dev_path(&self) -> String {
2323
match self {
2424
Self::Svelte => "http://localhost:8080",
25+
Self::SvelteKit => "http://localhost:5173",
2526
Self::Angular => "http://localhost:4200",
2627
Self::React => "http://localhost:3000",
2728
Self::Nextjs => "http://localhost:3000",
@@ -37,6 +38,7 @@ impl Framework {
3738
pub fn dist_dir(&self) -> String {
3839
match self {
3940
Self::Svelte => "../public",
41+
Self::SvelteKit => "../build",
4042
Self::Angular => "../dist",
4143
Self::React => "../build",
4244
Self::Nextjs => "../out",
@@ -54,6 +56,7 @@ impl fmt::Display for Framework {
5456
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5557
match self {
5658
Self::Svelte => write!(f, "Svelte"),
59+
Self::SvelteKit => write!(f, "SvelteKit"),
5760
Self::Angular => write!(f, "Angular"),
5861
Self::React => write!(f, "React"),
5962
Self::Nextjs => write!(f, "React (Next.js)"),
@@ -70,30 +73,37 @@ impl fmt::Display for Framework {
7073
pub enum Bundler {
7174
Webpack,
7275
Rollup,
76+
Vite,
7377
}
7478

7579
impl fmt::Display for Bundler {
7680
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7781
match self {
7882
Self::Webpack => write!(f, "Webpack"),
7983
Self::Rollup => write!(f, "Rollup"),
84+
Self::Vite => write!(f, "Vite"),
8085
}
8186
}
8287
}
8388

8489
pub fn infer_from_package_json(package_json: &str) -> (Option<Framework>, Option<Bundler>) {
8590
let framework_map = [
86-
("svelte", Framework::Svelte, None),
91+
("svelte", Framework::Svelte, Some(Bundler::Rollup)),
92+
("@sveltejs/kit", Framework::SvelteKit, Some(Bundler::Vite)),
8793
("@angular", Framework::Angular, Some(Bundler::Webpack)),
8894
(r#""next""#, Framework::Nextjs, Some(Bundler::Webpack)),
8995
("gatsby", Framework::Gatsby, Some(Bundler::Webpack)),
9096
("react", Framework::React, None),
9197
("nuxt", Framework::Nuxt, Some(Bundler::Webpack)),
9298
("quasar", Framework::Quasar, Some(Bundler::Webpack)),
9399
("@vue/cli", Framework::VueCli, Some(Bundler::Webpack)),
94-
("vue", Framework::Vue, None),
100+
("vue", Framework::Vue, Some(Bundler::Vite)),
101+
];
102+
let bundler_map = [
103+
("webpack", Bundler::Webpack),
104+
("rollup", Bundler::Rollup),
105+
("vite", Bundler::Vite),
95106
];
96-
let bundler_map = [("webpack", Bundler::Webpack), ("rollup", Bundler::Rollup)];
97107

98108
let (framework, framework_bundler) = framework_map
99109
.iter()

0 commit comments

Comments
 (0)