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

add vue template #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3,302 changes: 1,807 additions & 1,495 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

33 changes: 19 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ const cwd = process.cwd();
const FRAMEWORKS: Framework[] = [
{ name: "vite", display: "⚡Vite + React", color: blue },
{ name: "next", display: "▲ Next.js", color: blue },
{
name: "sveltekit",
display: "⚡Vite + SvelteKit",
color: blue,
},
{ name: "sveltekit", display: "⚡Vite + SvelteKit", color: blue },
{ name: "vue", display: "⚡Vite + Vue 3", color: blue },
];
const TEMPLATES = FRAMEWORKS.map((f) => f.name);
const TARGETOS = [
Expand Down Expand Up @@ -179,14 +176,20 @@ async function init() {

// Copy template files
const templateFiles = fs.readdirSync(templateDir);
for (const file of templateFiles.filter(
(f) => f !== "package.json" || "tauri.conf.json" || "Cargo.toml"
)) {
writeToFile(file);
if (selectedTemplate === "vue") {
for (const file of templateFiles) {
writeToFile(file);
}
} else {
for (const file of templateFiles.filter(
(f) => f !== "package.json" || "tauri.conf.json" || "Cargo.toml"
)) {
writeToFile(file);
}
}

// Copy .shared files
if (selectedTemplate !== "sveltekit") {
if (selectedTemplate !== "sveltekit" && selectedTemplate !== "vue") {
const sharedFiles = fs.readdirSync(sharedDir);
for (const file of sharedFiles) {
const sourcePath = path.join(sharedDir, file);
Expand All @@ -208,8 +211,9 @@ async function init() {
"utf-8"
)
);
tauriConf.tauri.windows[0].title = packageName || getProjectName();
tauriConf.package.productName = packageName || getProjectName();

tauriConf.app.windows[0].title = packageName || getProjectName();
tauriConf.productName = packageName || getProjectName();
writeToFile(
"/src-tauri/tauri.conf.json",
JSON.stringify(tauriConf, null, 2) + "\n"
Expand All @@ -221,8 +225,9 @@ async function init() {
/name\s*=\s*"tauri-ui"/,
`name = "${packageName || getProjectName()}"`
);
writeToFile("/src-tauri/Cargo.toml", updatedCargoTomlContent);

if (selectedTemplate !== "vue") {
writeToFile("/src-tauri/Cargo.toml", updatedCargoTomlContent);
}
const releaseYml = path.join(sharedDir, ".github/workflows/release.yml");
const releaseYmlContent = fs.readFileSync(releaseYml, "utf-8");
const modifiedReleaseYmlContent = releaseYmlContent.replace(
Expand Down
108 changes: 108 additions & 0 deletions templates/vue/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: release
on:
workflow_dispatch:
push:
tags:
- '*'
jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-20.04
outputs:
release_id: ${{ steps.create-release.outputs.result }}

steps:
- uses: actions/checkout@v3
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: get version
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: create release
id: create-release
uses: actions/github-script@v6
with:
script: |
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${process.env.PACKAGE_VERSION}`,
name: `v${process.env.PACKAGE_VERSION}`,
body: '*This release was generated automatically using GitHub Actions.*',
draft: true,
prerelease: false
})
return data.id

build-tauri:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.platform }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: v2 -> v2/target

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache-dependency-path: v2/package-lock.json

- name: Install apt dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt install -y --no-install-recommends libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf

- name: Install pnpm
run: npm install -g pnpm

- name: Install frontend dependencies
run: pnpm install

- name: Build the app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}

publish-release:
permissions:
contents: write
runs-on: ubuntu-20.04
needs: [create-release, build-tauri]

steps:
- name: publish release
id: publish-release
uses: actions/github-script@v6
env:
release_id: ${{ needs.create-release.outputs.release_id }}
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
draft: false,
prerelease: false
})
27 changes: 27 additions & 0 deletions templates/vue/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?


typed-router.d.ts
7 changes: 7 additions & 0 deletions templates/vue/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"Vue.volar",
"tauri-apps.tauri-vscode",
"rust-lang.rust-analyzer"
]
}
16 changes: 16 additions & 0 deletions templates/vue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Tauri + Vue + TypeScript

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

## Recommended IDE Setup

- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)

## Type Support For `.vue` Imports in TS

Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:

1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.

You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
Binary file added templates/vue/app-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading