Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: install tauri-cli using cargo #242

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/cargo-tauri-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-vscode": patch
---

Install `cargo tauri` if not installed.
12 changes: 9 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function runTauriInit(): void {
let onInstall = () => {};
if (__isVueCliApp(projectPath)) {
installCommand = 'vue add tauri';
} else {
} else if (__isNodeProject(projectPath)) {
installCommand = __usePnpm(projectPath)
? 'pnpm add -D @tauri-apps/cli'
: __useYarn(projectPath)
Expand All @@ -185,6 +185,8 @@ function runTauriInit(): void {
noOutputWindow: true,
});
};
} else {
installCommand = 'cargo install tauri-cli';
}

const [command, ...args] = installCommand.split(' ');
Expand All @@ -196,7 +198,7 @@ function runTauriInit(): void {
() => {
const paths = __getNpmProjectsPaths();
return paths.filter((p) => {
return !fs.existsSync(path.join(p, 'src-tauri'));
return fs.existsSync(path.join(p, 'src-tauri'));
});
}
);
Expand Down Expand Up @@ -225,6 +227,10 @@ function __isVueCliApp(cwd: string): boolean {
return '@vue/cli-service' in (packageJson?.devDependencies ?? {});
}

function __isNodeProject(cwd: string): boolean {
return existsSync(join(cwd, 'package.json'));
}

interface PackageJson {
dependencies: {
[name: string]: any;
Expand Down Expand Up @@ -418,7 +424,7 @@ function __getPackageManagerCommand(projectPath: string): string | null {

if (!m) {
vscode.window.showErrorMessage(
"Couldn't detect package manager for current project."
"Couldn't detect package manager for current project. Try running Tauri: Init Command"
);
}

Expand Down
Loading