From 6ad824f73a951649989d9d1182ad6c9386dca07b Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Sat, 3 Jun 2023 22:32:41 +0300 Subject: [PATCH 1/5] feat: Update `defineEmits` to Vue 3.3 syntax (#43) * Remove no-payload snippets #40 * Update emit syntax #40 --- README.md | 2 -- snippets/vue/vue-script.code-snippets | 20 ++------------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d16aace..5debe71 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,7 @@ These snippets were made to speed up Vue 3 development. With it you can write bo | `vonbeforeunmount` | onBeforeUnmount hook | | `vdefineprops` | Define props | | `vdefineemits` | Define emits | -| `vdefineemits-nopayload` | Define emits with no payload | | `vsingleemit` | Single emit for defineEmits | -| `vsingleemit-nopayload` | Single emit for defineEmits with no payload | ### CSS diff --git a/snippets/vue/vue-script.code-snippets b/snippets/vue/vue-script.code-snippets index cb5fb62..602ab31 100644 --- a/snippets/vue/vue-script.code-snippets +++ b/snippets/vue/vue-script.code-snippets @@ -111,32 +111,16 @@ "prefix": "vdefineemits", "body": [ "defineEmits<{", - "\t(e: '${1:eventName}', ${2:payloadName}: ${3:payloadType}): void", + "\t${1:eventName}: [${2}]", "}>()" ], "description": "Vue defineEmits" }, - "Vue Define Emits - No Payload": { - "prefix": "vdefineemits-nopayload", - "body": [ - "defineEmits<{", - "\t(e: '${1:eventName}'): void", - "}>()" - ], - "description": "Vue defineEmits with no payload" - }, "Vue Single Emit": { "prefix": "vsingleemit", "body": [ - "(e: '${1:eventName}', ${2:payloadName}: ${3:payloadType}): void", + "${1:eventName}: [${2}]", ], "description": "Vue single emit for defineEmits" }, - "Vue Single Emit - No Payload": { - "prefix": "vsingleemit-nopayload", - "body": [ - "(e: '${1:eventName}'): void", - ], - "description": "Vue single emit for defineEmits with no payload" - }, } \ No newline at end of file From 2cd2b15166dc81863ca8e30bbd311a21f478501d Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Tue, 6 Jun 2023 21:08:28 +0300 Subject: [PATCH 2/5] feat: Add `Vitest` snippets (#44) * Fix issue in vue-script * Vitest snippets #23 * Vitest vue snippets #23 * Vitest Nuxt Snippets #23 --- README.md | 61 ++++++++---- package.json | 24 +++++ snippets/vitest/nuxt.code-snippets | 49 ++++++++++ snippets/vitest/vitest.code-snippets | 131 ++++++++++++++++++++++++++ snippets/vitest/vue.code-snippets | 22 +++++ snippets/vue/vue-script.code-snippets | 4 +- 6 files changed, 272 insertions(+), 19 deletions(-) create mode 100644 snippets/vitest/nuxt.code-snippets create mode 100644 snippets/vitest/vitest.code-snippets create mode 100644 snippets/vitest/vue.code-snippets diff --git a/README.md b/README.md index 5debe71..94d8b77 100644 --- a/README.md +++ b/README.md @@ -59,23 +59,23 @@ These snippets were made to speed up Vue 3 development. With it you can write bo ### Script -| Snippet | Purpose | -| ------------------------ | ------------------------------------------- | -| `vref` | Vue `ref` | -| `vreactive` | Vue `reactive` | -| `vcomputed` | Vue `computed` | -| `vwatch` | Watcher | -| `vwatcheffect` | Watch Effect | -| `vonmounted` | onMounted hook | -| `vonbeforemount` | onBeforeMount hook | -| `vonbeforeupdate` | onBeforeUpdate hook | -| `vonupdated` | onUpdated hook | -| `vonerrorcaptured` | onErrorCaptured hook | -| `vonunmounted` | onUnmounted hook | -| `vonbeforeunmount` | onBeforeUnmount hook | -| `vdefineprops` | Define props | -| `vdefineemits` | Define emits | -| `vsingleemit` | Single emit for defineEmits | +| Snippet | Purpose | +| ------------------ | --------------------------- | +| `vref` | Vue `ref` | +| `vreactive` | Vue `reactive` | +| `vcomputed` | Vue `computed` | +| `vwatch` | Watcher | +| `vwatcheffect` | Watch Effect | +| `vonmounted` | onMounted hook | +| `vonbeforemount` | onBeforeMount hook | +| `vonbeforeupdate` | onBeforeUpdate hook | +| `vonupdated` | onUpdated hook | +| `vonerrorcaptured` | onErrorCaptured hook | +| `vonunmounted` | onUnmounted hook | +| `vonbeforeunmount` | onBeforeUnmount hook | +| `vdefineprops` | Define props | +| `vdefineemits` | Define emits | +| `vsingleemit` | Single emit for defineEmits | ### CSS @@ -151,6 +151,33 @@ These snippets were made to speed up Vue 3 development. With it you can write bo | `hcontrols-text` | Histoire controls - Text | | `hcontrols-textarea` | Histoire controls - Textarea | +### Vitest + +| Snippet | Purpose | +| ------------------------- | ------------------------------ | +| `viconfig` | Vitest config for Vue 3 | +| `viconfig-nuxt` | Vitest config for Nuxt 3 | +| `videscribe` | Vitest Describe | +| `videscribe-concurrent` | Vitest Describe - Concurrent | +| `viit` | Vitest It | +| `viit-concurrent` | Vitest It - Concurrent | +| `viit-async` | Vitest It - Async | +| `viit-async-concurrent` | Vitest It - Async Concurrent | +| `viit-todo` | Vitest It - Todo | +| `vitest` | Vitest Test | +| `vitest-concurrent` | Vitest Test - Concurrent | +| `vitest-async` | Vitest Test - Async | +| `vitest-async-concurrent` | Vitest Test - Async Concurrent | +| `vitest-todo` | Vitest Test - Todo | +| `visnapshot` | Vitest Match Snapshot | +| `visnapshot-inline` | Vitest Match Snapshot - Inline | +| `vimount` | Vue Test Utils `mount` | +| `vicomponent` | Vue Test Utils Component | +| `vimount-suspended` | nuxt-vitest `mountSuspended` | +| `vimocknuxtimport` | nuxt-vitest `mockNuxtImport` | +| `vimockcomponent` | nuxt-vitest `mockComponent` | +| `viregisterendpoint` | nuxt-vitest `registerEndpoint` | + ## Contributing This is an open source project open to anyone. Contributors are welcome on [GitHub](https://github.com/exer7um/vue3-vscode-snippets). diff --git a/package.json b/package.json index 45301c8..9e31698 100644 --- a/package.json +++ b/package.json @@ -118,6 +118,30 @@ { "language": "typescript", "path": "./snippets/histoire/histoire-script.code-snippets" + }, + { + "language": "javascript", + "path": "./snippets/vitest/vitest.code-snippets" + }, + { + "language": "typescript", + "path": "./snippets/vitest/vitest.code-snippets" + }, + { + "language": "javascript", + "path": "./snippets/vitest/vue.code-snippets" + }, + { + "language": "typescript", + "path": "./snippets/vitest/vue.code-snippets" + }, + { + "language": "javascript", + "path": "./snippets/vitest/nuxt.code-snippets" + }, + { + "language": "typescript", + "path": "./snippets/vitest/nuxt.code-snippets" } ] } diff --git a/snippets/vitest/nuxt.code-snippets b/snippets/vitest/nuxt.code-snippets new file mode 100644 index 0000000..b3f26a4 --- /dev/null +++ b/snippets/vitest/nuxt.code-snippets @@ -0,0 +1,49 @@ +{ + "Vitest Config - Nuxt 3": { + "prefix": "viconfig-nuxt", + "body": [ + "import { defineVitestConfig } from 'nuxt-vitest/config'", + "", + "export default defineVitestConfig({", + "\ttest: {", + "\t\tenvironment: 'nuxt'", + "\t}", + "})" + ], + "description": "Vitest config for Nuxt 3" + }, + "Vitest Nuxt Mount Suspended": { + "prefix": "vimount-suspended", + "body": [ + "const wrapper = await mountSuspended(${0})", + ], + "description": "nuxt-vitest mountSuspended" + }, + "Vitest Nuxt Mock Import": { + "prefix": "vimocknuxtimport", + "body": [ + "mockNuxtImport('${1:functionName}', () => {", + "\treturn () => {", + "\t\treturn { ${0} }", + "\t}", + "})" + ], + "description": "nuxt-vitest mockNuxtImport" + }, + "Vitest Nuxt Mock Component": { + "prefix": "vimockcomponent", + "body": [ + "mockComponent('${0}')", + ], + "description": "nuxt-vitest mockComponent" + }, + "Vitest Nuxt Register Endpoint": { + "prefix": "viregisterendpoint", + "body": [ + "registerEndpoint('/${1:endpoint}/', () => {", + "\t{0}", + "})" + ], + "description": "nuxt-vitest registerEndpoint" + }, +} diff --git a/snippets/vitest/vitest.code-snippets b/snippets/vitest/vitest.code-snippets new file mode 100644 index 0000000..ce6944c --- /dev/null +++ b/snippets/vitest/vitest.code-snippets @@ -0,0 +1,131 @@ +{ + "Vitest Config - Vue 3": { + "prefix": "viconfig", + "body": [ + "import { defineConfig } from 'vitest/config'", + "", + "export default defineConfig({", + "\t${0}", + "})" + ], + "description": "Vitest config for Vue 3" + }, + "Vitest Describe": { + "prefix": "videscribe", + "body": [ + "describe('${1:name}'), () => {", + "\t${0}", + "}" + ], + "description": "Vitest Describe" + }, + "Vitest Describe - Concurrent": { + "prefix": "videscribe-concurrent", + "body": [ + "describe.concurrent('${1:name}'), () => {", + "\t${0}", + "}" + ], + "description": "Vitest Describe Concurrent" + }, + "Vitest It": { + "prefix": "viit", + "body": [ + "it('${1:name}'), () => {", + "\t${0}", + "}" + ], + "description": "Vitest It" + }, + "Vitest It - Concurrent": { + "prefix": "viit-concurrent", + "body": [ + "it.concurrent('${1:name}'), () => {", + "\t${0}", + "}" + ], + "description": "Vitest It Concurrent" + }, + "Vitest It - Async": { + "prefix": "viit-async", + "body": [ + "it('${1:name}'), async () => {", + "\t${0}", + "}" + ], + "description": "Vitest It Async" + }, + "Vitest It - Async Concurrent": { + "prefix": "viit-async-concurrent", + "body": [ + "it.concurrent('${1:name}'), async () => {", + "\t${0}", + "}" + ], + "description": "Vitest It Async Concurrent" + }, + "Vitest It - Todo": { + "prefix": "viit-todo", + "body": [ + "it.todo('${1:name}')" + ], + "description": "Vitest It Todo" + }, + "Vitest Test": { + "prefix": "vitest", + "body": [ + "test('${1:name}'), () => {", + "\t${0}", + "}" + ], + "description": "Vitest Test" + }, + "Vitest Test - Concurrent": { + "prefix": "vitest-concurrent", + "body": [ + "test.concurrent('${1:name}'), () => {", + "\t${0}", + "}" + ], + "description": "Vitest Test Concurrent" + }, + "Vitest Test - Async": { + "prefix": "vitest-async", + "body": [ + "test('${1:name}'), async () => {", + "\t${0}", + "}" + ], + "description": "Vitest Test Async" + }, + "Vitest Test - Async Concurrent": { + "prefix": "vitest-async-concurrent", + "body": [ + "test.concurrent('${1:name}'), async () => {", + "\t${0}", + "}" + ], + "description": "Vitest Test Async Concurrent" + }, + "Vitest Test - Todo": { + "prefix": "vitest-todo", + "body": [ + "test.todo('${1:name}')" + ], + "description": "Vitest Test Todo" + }, + "Vitest Match Snapshot": { + "prefix": "visnapshot", + "body": [ + "expect(${0}).toMatchSnapshot()" + ], + "description": "Vitest Match Snapshot" + }, + "Vitest Match Snapshot - Inline": { + "prefix": "visnapshot-inline", + "body": [ + "expect(${0}).toMatchInlineSnapshot()" + ], + "description": "Vitest Match Inline Snapshot" + }, +} diff --git a/snippets/vitest/vue.code-snippets b/snippets/vitest/vue.code-snippets new file mode 100644 index 0000000..ea6ec08 --- /dev/null +++ b/snippets/vitest/vue.code-snippets @@ -0,0 +1,22 @@ +{ + "Vitest Vue Mount": { + "prefix": "vimount", + "body": [ + "const wrapper = mount(${0})", + ], + "description": "Vue Test Utils Mount" + }, + "Vitest Test Component": { + "prefix": "vicomponent", + "body": [ + "{", + "\ttemplate: '${0}'", + "\t\tdata() {", + "\t\t\treturn {", + "\t\t${2:variable}", + "\t}", + "}" + ], + "description": "Vue Test Utils Component" + } +} diff --git a/snippets/vue/vue-script.code-snippets b/snippets/vue/vue-script.code-snippets index 602ab31..f9ef317 100644 --- a/snippets/vue/vue-script.code-snippets +++ b/snippets/vue/vue-script.code-snippets @@ -111,7 +111,7 @@ "prefix": "vdefineemits", "body": [ "defineEmits<{", - "\t${1:eventName}: [${2}]", + "\t${1:eventName}: [${0}]", "}>()" ], "description": "Vue defineEmits" @@ -119,7 +119,7 @@ "Vue Single Emit": { "prefix": "vsingleemit", "body": [ - "${1:eventName}: [${2}]", + "${1:eventName}: [${0}]", ], "description": "Vue single emit for defineEmits" }, From fb4cfc714b7e5cb68ecbaa41cc9a4a1cf17bcf93 Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Tue, 6 Jun 2023 21:19:52 +0300 Subject: [PATCH 3/5] feat: Add Vue 3.3 snippets (#45) * Fix vitest in readme * Vue 3.3 snippets #41 --- README.md | 26 +++++++++++++++----- snippets/vue/vue-script.code-snippets | 34 ++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 94d8b77..ff2e2f0 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ These snippets were made to speed up Vue 3 development. With it you can write bo | `vdefineprops` | Define props | | `vdefineemits` | Define emits | | `vsingleemit` | Single emit for defineEmits | +| `vdefineslots` | Define slots | +| `vsingleslot` | Single slot for defineSlots | +| `vdefineoptions` | Define Options | +| `vdefinemodel` | Define Model | ### CSS @@ -171,12 +175,22 @@ These snippets were made to speed up Vue 3 development. With it you can write bo | `vitest-todo` | Vitest Test - Todo | | `visnapshot` | Vitest Match Snapshot | | `visnapshot-inline` | Vitest Match Snapshot - Inline | -| `vimount` | Vue Test Utils `mount` | -| `vicomponent` | Vue Test Utils Component | -| `vimount-suspended` | nuxt-vitest `mountSuspended` | -| `vimocknuxtimport` | nuxt-vitest `mockNuxtImport` | -| `vimockcomponent` | nuxt-vitest `mockComponent` | -| `viregisterendpoint` | nuxt-vitest `registerEndpoint` | + +### Vitest Vue + +| Snippet | Purpose | +| ------------- | ------------------------ | +| `vimount` | Vue Test Utils `mount` | +| `vicomponent` | Vue Test Utils Component | + +### Vitest Nuxt + +| Snippet | Purpose | +| -------------------- | ------------------------------ | +| `vimount-suspended` | nuxt-vitest `mountSuspended` | +| `vimocknuxtimport` | nuxt-vitest `mockNuxtImport` | +| `vimockcomponent` | nuxt-vitest `mockComponent` | +| `viregisterendpoint` | nuxt-vitest `registerEndpoint` | ## Contributing diff --git a/snippets/vue/vue-script.code-snippets b/snippets/vue/vue-script.code-snippets index f9ef317..f9e6325 100644 --- a/snippets/vue/vue-script.code-snippets +++ b/snippets/vue/vue-script.code-snippets @@ -123,4 +123,36 @@ ], "description": "Vue single emit for defineEmits" }, -} \ No newline at end of file + "Vue Define Slots": { + "prefix": "vdefineslots", + "body": [ + "defineSlots<{", + "\tdefault: (props: { ${0} }) => any", + "}>()" + ], + "description": "Vue defineSlots" + }, + "Vue Single Slot": { + "prefix": "vsingleslot", + "body": [ + "\t${1:slotName}: (props: { ${0} }) => any", + ], + "description": "Vue single slot for defineSlots" + }, + "Vue Define Options": { + "prefix": "vdefineoptions", + "body": [ + "defineOptions({", + "\t${0}", + "})" + ], + "description": "Vue defineOptions" + }, + "Vue Define Model": { + "prefix": "vdefinemodel", + "body": [ + "const modelValue = defineModel()", + ], + "description": "Vue defineModel" + }, +} From 5af7c5ab8e4a47b082a7da07fbaac825525dd1f6 Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Tue, 6 Jun 2023 22:08:01 +0300 Subject: [PATCH 4/5] chore: New release flow (#46) Release action #42 --- .github/workflows/release.yml | 39 +++++++++++++++++++++++++++++++++++ changelog.config.json | 5 +++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 changelog.config.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a27566b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: "Release version" + required: true + type: string + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup NodeJS + uses: actions/setup-node@v3 + + - name: Configure Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: Generate Changelog and GH Release + run: | + npx changelogen@latest --release --push -r ${{ inputs.version }} + npx changelogen@latest gh release --token ${{ secrets.GITHUB_TOKEN }} + + - name: Release VS Code Package + env: + VSCE_PAT: ${{ secrets.VSCE_PAT }} + run: | + npx @vscode/vsce@latest publish diff --git a/changelog.config.json b/changelog.config.json new file mode 100644 index 0000000..d1a1dbf --- /dev/null +++ b/changelog.config.json @@ -0,0 +1,5 @@ +{ + "templates": { + "commitMessage": "release: `v{{newVersion}}`" + } +} From 3775a9869d3c557a6a68c84dcd515f6ba83f97f3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 6 Jun 2023 19:08:40 +0000 Subject: [PATCH 5/5] release: `v0.4.0` --- CHANGELOG.md | 19 +++++++++++++++++++ package.json | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b88ea4..aebfff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,25 @@ All notable changes to the "vue3-vscode-snippets" extension will be documented in this file. +## v0.4.0 + +[compare changes](https://github.com/ExEr7um/vue3-vscode-snippets/compare/v0.3.1...v0.4.0) + + +### 🚀 Enhancements + + - Update `defineEmits` to Vue 3.3 syntax ([#43](https://github.com/ExEr7um/vue3-vscode-snippets/pull/43)) + - Add `Vitest` snippets ([#44](https://github.com/ExEr7um/vue3-vscode-snippets/pull/44)) + - Add Vue 3.3 snippets ([#45](https://github.com/ExEr7um/vue3-vscode-snippets/pull/45)) + +### 🏡 Chore + + - New release flow ([#46](https://github.com/ExEr7um/vue3-vscode-snippets/pull/46)) + +### ❤️ Contributors + +- Vasily Kuzin ([@ExEr7um](http://github.com/ExEr7um)) + ## `v0.3.1` ### Fixed diff --git a/package.json b/package.json index 9e31698..dcb15d3 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Vue 3 VS Code Snippets", "description": "Vue 3 snippets for VS Code", "icon": "images/vue-logo.png", - "version": "0.3.1", + "version": "0.4.0", "publisher": "exer7um", "repository": { "type": "git", @@ -145,4 +145,4 @@ } ] } -} +} \ No newline at end of file