Skip to content

Commit

Permalink
feat: add tanstack vue query
Browse files Browse the repository at this point in the history
  • Loading branch information
selemondev committed Mar 10, 2024
1 parent 6e00e75 commit a2ad6b9
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 77 deletions.
7 changes: 1 addition & 6 deletions src/compile/common/frameQuestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,12 @@ export function getFilterFile() {
fs.remove(`${options.dest}/src/components/__tests__`);
}


if (!options.usePrettier) {
fs.remove(`${options.dest}/.prettierrc.js`)
}

if (!options.usePinia) {
fs.remove(`${options.dest}/src/stores`)
}

if (!options.useEslint) {
fs.remove(`${options.dest}/.eslintrc.js`)
fs.remove(`${options.dest}/.eslintrc.cjs`)
}
return true
}
Expand Down
8 changes: 3 additions & 5 deletions src/core/questions/vue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import createQuestion from '../../../utils/question';
async function getVueProperty() {
const Eslint = packageJsonMap.get('eslintJsVue');
const EslintTs = packageJsonMap.get('eslintTsPlugin');
const Prettier = packageJsonMap.get('prettier');
const Vitest = packageJsonMap.get('vitest');
const TanStackVueQuery = packageJsonMap.get('tanStackVueQuery');
const Router = packageJsonMap.get('router');
const Pinia = packageJsonMap.get('pinia');
const Tailwind = packageJsonMap.get('tailwind');
Expand All @@ -25,16 +25,14 @@ async function getVueProperty() {

options.constantProDeps = packageJsonMap.get('constantProDeps')

options.EslintWithPrettierScript = packageJsonMap.get('eslintWithPrettier')

options.Eslint = options.useTypeScript ? EslintTs : Eslint

options.Prettier = Prettier

options.Vitest = Vitest

options.Router = Router

options.TanStackVueQuery = TanStackVueQuery

options.Pinia = Pinia

options.Tailwind = Tailwind;
Expand Down
13 changes: 7 additions & 6 deletions src/core/questions/vue/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,26 @@ const prompt = [
},

{
name: 'useVitest',
name: 'useTanStackVueQuery',
type: () => 'toggle',
message: 'Add Vitest for unit testing?',
message: 'Add TanStack Vue Query for server state management?',
initial: false,
active: 'Yes',
inactive: 'No'
},

{
name: 'useEslint',
name: 'useVitest',
type: () => 'toggle',
message: 'Add ESLint for code quality?',
message: 'Add Vitest for unit testing?',
initial: false,
active: 'Yes',
inactive: 'No'
},
{
name: 'usePrettier',
name: 'useEslint',
type: () => 'toggle',
message: 'Add Prettier for code formatting?',
message: 'Add ESLint for code quality?',
initial: false,
active: 'Yes',
inactive: 'No'
Expand Down
4 changes: 0 additions & 4 deletions src/core/utils/vue/ejsMapConstant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ const lintMap = new Map([
'EslintScript',
'"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",'
],
[
'PrettierScript',
'"prettier": "prettier --write ./**/*.{html,vue,ts,js,json,md}",'
],

[
'VitestScript',
Expand Down
7 changes: 3 additions & 4 deletions src/core/utils/vue/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Options {
Pinia?: string
Eslint?: string
Vitest?: string
Prettier?: string
TanStackVueQuery?: string
name?: string
version?: string
src?: string
Expand All @@ -16,17 +16,16 @@ interface Options {
package?: 'bun' | 'pnpm' | 'npm' | 'yarn' | 'none'
useEslint?: boolean
useEslintTs?: boolean
usePrettier?: boolean
useRouter?: boolean
useVueQuery?: boolean
useTailwind?: boolean
useTypeScript?: boolean
useJavaScript?: boolean
useTanStackVueQuery?: string
useVitest?: string
useGitInit?: boolean
usePinia?: boolean
EslintScript?: string
PrettierScript?: string
EslintWithPrettierScript?: string
constantDevDeps?: string
constantProDeps?: string
}
Expand Down
31 changes: 13 additions & 18 deletions src/deps/vue/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ const pinia = {
env: 'pro'
}

const prettier = {
name: 'prettier',
version: '^3.1.1',
stableVersion: '^3.1.1',
env: 'dev'
}

const eslintJsVue = {
name: ['eslint-plugin-vue', 'eslint'],
version: ["^9.17.0", "^8.49.0"],
Expand Down Expand Up @@ -49,19 +42,12 @@ const tailwind = {
env: ['dev', 'dev', 'dev']
}

const eslintWithPrettier = {
name: ['eslint-config-prettier', 'eslint-plugin-prettier'],
version: ['^9.1.0', '^5.0.1'],
stableVersion: ['^8.5.0', '^4.2.1'],
env: 'dev'
};

const typescript = {
name: [
'typescript', 'vue-tsc', '@tsconfig/node20', "@vue/tsconfig", "npm-run-all2", '@types/node'
],
version: ['^5.3.3', '^1.8.25', "^20.1.2", "^0.5.1", "^6.1.1", "^20.11.10"],
stableVersion: ['^5.3.3', '^1.8.25', "^20.1.2", "^0.5.1", "^6.1.1", "^20.11.10"],
version: ['~5.3.0', '^1.8.25', "^20.1.2", "^0.5.1", "^6.1.1", "^20.11.10"],
stableVersion: ['~5.3.0', '^1.8.25', "^20.1.2", "^0.5.1", "^6.1.1", "^20.11.10"],
dev: ['dev', 'dev', 'dev', 'dev', 'dev', 'dev', 'dev', 'dev']
}

Expand All @@ -72,6 +58,16 @@ const javascript = {
dev: []
};

const tanStackVueQuery = {
name: [
"@tanstack/vue-query",
"@tanstack/vue-query-devtools"
],
version: ["^5.25.0", "^5.25.0"],
stableVersion: ["^5.25.0", "^5.25.0"],
dev: ['pro', 'pro']
}

const vitest = {
name: ['vitest', 'jsdom', "@vue/test-utils"],
version: ["^1.2.2", "^24.0.0", "^2.4.4"],
Expand All @@ -94,14 +90,13 @@ const constantProDeps = {
export {
constantDevDeps,
constantProDeps,
eslintWithPrettier,
tailwind,
eslintTsPlugin,
javascript,
typescript,
vitest,
tanStackVueQuery,
eslintJsVue,
prettier,
pinia,
router
}
12 changes: 3 additions & 9 deletions template/vue-js/package.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<% if (useVitest) { -%>
<%- VitestScript %>
<% } -%>
<% if (usePrettier) { -%>
<%- PrettierScript %>
<% } -%>
<% if (useTypeScript) { -%>
<%- TypeScriptScript %>
<% } -%>
Expand All @@ -28,6 +25,9 @@
<% if (usePinia) { -%>
<%- Pinia %>
<% } -%>
<% if (useTanStackVueQuery) { -%>
<%- TanStackVueQuery %>
<% } -%>
},
"devDependencies": {
<% if (useTypeScript) { -%>
Expand All @@ -36,15 +36,9 @@
<% if (useEslint) { -%>
<%- Eslint %>
<% } -%>
<% if (usePrettier) { -%>
<%- Prettier %>
<% } -%>
<% if (useTailwind) { -%>
<%- Tailwind %>
<% } -%>
<% if (usePrettier && useEslint) { -%>
<%- EslintWithPrettierScript %>
<% } -%>
<% if (useJavaScript) { -%>
<%- JavaScript %>
<% } -%>
Expand Down
7 changes: 7 additions & 0 deletions template/vue-js/src/App.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
-%>
import HomeView from '@/views/HomeView.vue'
<% } -%>
<% if (useTanStackVueQuery) {
-%>
import { VueQueryDevtools } from '@tanstack/vue-query-devtools'
<% } -%>
</script>
<% } -%>

Expand All @@ -24,6 +28,9 @@
<% if (useRouter) { -%>
<RouterView />
<% } -%>
<% if (useTanStackVueQuery) { -%>
<VueQueryDevtools />
<% } -%>
</template>

<style>
Expand Down
6 changes: 6 additions & 0 deletions template/vue-js/src/main.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { createApp } from 'vue'
<% if (!useTailwind ) { -%>
import './assets/css/base.css'
<% } -%>
<% if (useTanStackVueQuery) { -%>
import { VueQueryPlugin } from '@tanstack/vue-query'
<% } -%>
import App from './App.vue'
<% if ( usePinia ) { -%>
import { createPinia } from 'pinia';
Expand All @@ -20,4 +23,7 @@ import App from './App.vue'
<% if (useRouter) { -%>
app.use(router)
<% } -%>
<% if (useTanStackVueQuery) { -%>
app.use(VueQueryPlugin)
<% } -%>
app.mount('#app')
12 changes: 3 additions & 9 deletions template/vue-ts/package.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<% if (useVitest) { -%>
<%- VitestScript %>
<% } -%>
<% if (usePrettier) { -%>
<%- PrettierScript %>
<% } -%>
<% if (useTypeScript) { -%>
<%- TypeScriptScript %>
<% } -%>
Expand All @@ -28,6 +25,9 @@
<% if (usePinia) { -%>
<%- Pinia %>
<% } -%>
<% if (useTanStackVueQuery) { -%>
<%- TanStackVueQuery %>
<% } -%>
},
"devDependencies": {
<%- constantDevDeps %>
Expand All @@ -37,15 +37,9 @@
<% if (useEslint) { -%>
<%- Eslint %>
<% } -%>
<% if (usePrettier) { -%>
<%- Prettier %>
<% } -%>
<% if (useTailwind) { -%>
<%- Tailwind %>
<% } -%>
<% if (usePrettier && useEslint) { -%>
<%- EslintWithPrettierScript %>
<% } -%>
<% if (useJavaScript) { -%>
<%- JavaScript %>
<% } -%>
Expand Down
7 changes: 7 additions & 0 deletions template/vue-ts/src/App.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
-%>
import HomeView from '@/views/HomeView.vue'
<% } -%>
<% if (useTanStackVueQuery) {
-%>
import { VueQueryDevtools } from '@tanstack/vue-query-devtools'
<% } -%>
</script>
<% } -%>

Expand All @@ -24,6 +28,9 @@
<% if (useRouter) { -%>
<RouterView />
<% } -%>
<% if (useTanStackVueQuery) { -%>
<VueQueryDevtools />
<% } -%>
</template>

<style>
Expand Down
38 changes: 22 additions & 16 deletions template/vue-ts/src/main.ejs
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import { createApp } from 'vue'
<% if ( useTailwind ) { -%>
import './assets/css/tailwind.css'
<% } -%>
<% if (!useTailwind ) { -%>
import './assets/css/base.css'
<% } -%>
import App from './App.vue'
<% if ( usePinia ) { -%>
import { createPinia } from 'pinia';
<% } -%>
<% if (useRouter) { -%>
import router from "./router";
<% if (!useTailwind ) { -%>
import './assets/css/base.css'
<% } -%>
const app = createApp(App)
<% if ( usePinia ) { -%>
app.use(createPinia())
<% if (useTanStackVueQuery) { -%>
import { VueQueryPlugin } from '@tanstack/vue-query'
<% } -%>

<% if (useRouter) { -%>
app.use(router)
import App from './App.vue'
<% if ( usePinia ) { -%>
import { createPinia } from 'pinia';
<% } -%>
app.mount('#app')
<% if (useRouter) { -%>
import router from "./router";
<% } -%>
const app = createApp(App)
<% if ( usePinia ) { -%>
app.use(createPinia())
<% } -%>

<% if (useRouter) { -%>
app.use(router)
<% } -%>
<% if (useTanStackVueQuery) { -%>
app.use(VueQueryPlugin)
<% } -%>
app.mount('#app')

0 comments on commit a2ad6b9

Please sign in to comment.