Skip to content

Commit 9b75133

Browse files
committed
chore: improve module
1 parent 6d8c593 commit 9b75133

File tree

20 files changed

+88
-44
lines changed

20 files changed

+88
-44
lines changed

.eslintrc.cjs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'@nuxt/eslint-config'
5+
],
6+
rules: {
7+
// Global
8+
semi: ['error', 'never'],
9+
quotes: ['error', 'single'],
10+
'quote-props': ['error', 'as-needed'],
11+
// Vue
12+
'vue/multi-word-component-names': 0,
13+
'vue/max-attributes-per-line': 'off',
14+
'vue/no-v-html': 0
15+
}
16+
}

.eslintrc.js

-9
This file was deleted.

.github/workflows/ci-dev.yml

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ jobs:
4949
- name: Install dependencies
5050
run: pnpm install
5151

52+
- name: Prepare
53+
run: pnpm run dev:prepare
54+
5255
- name: Lint
5356
run: pnpm run lint
5457

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ jobs:
4949
- name: Install dependencies
5050
run: pnpm install
5151

52+
- name: Prepare
53+
run: pnpm run dev:prepare
54+
5255
- name: Lint
5356
run: pnpm run lint
5457

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
shamefully-hoist=true
2-
auto-install-peers=true
2+
strict-peer-dependencies=false

.nuxtrc

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
typescript.includeWorkspace=true
2+
typescript.strict=false

docs/nuxt.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default defineNuxtConfig({
22
css: ['@/assets/css/main.css'],
33
extends: ['@nuxt-themes/docus'],
44
modules: ['nuxt-plausible'],
5+
// @ts-ignore
56
plausible: {
67
domain: 'strapi.nuxtjs.org'
78
}

package.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"license": "MIT",
77
"exports": {
88
".": {
9+
"types": "./dist/types.d.ts",
910
"import": "./dist/module.mjs",
1011
"require": "./dist/module.cjs"
1112
}
@@ -16,12 +17,13 @@
1617
"dist"
1718
],
1819
"scripts": {
19-
"build": "nuxt-module-build",
20-
"dev": "nuxi dev example",
21-
"lint": "eslint --ext .js,.ts,.vue .",
22-
"typecheck": "nuxi typecheck",
20+
"build": "nuxt-module-build build",
2321
"prepack": "pnpm build",
24-
"prepare": "nuxi prepare example",
22+
"dev": "nuxi dev playground",
23+
"dev:build": "nuxi build playground",
24+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
25+
"lint": "eslint .",
26+
"typecheck": "vue-tsc --noEmit",
2527
"release": "pnpm lint && standard-version && git push --follow-tags"
2628
},
2729
"dependencies": {
@@ -32,6 +34,7 @@
3234
"ufo": "^1.3.2"
3335
},
3436
"devDependencies": {
37+
"@types/node": "^20.9.3",
3538
"@nuxt/devtools": "^1.0.3",
3639
"@nuxt/eslint-config": "^0.2.0",
3740
"@nuxt/module-builder": "^0.5.4",

example/app.vue playground/app.vue

File renamed without changes.

example/nuxt.config.ts playground/nuxt.config.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
21
export default defineNuxtConfig({
32
modules: [
4-
'../src/module',
5-
'@nuxt/devtools'
3+
'../src/module'
64
],
75
// example of separate client/server URLs
86
// runtimeConfig: {
@@ -17,7 +15,5 @@ export default defineNuxtConfig({
1715
// To enable the devtools, read https://strapi.nuxtjs.org/devtools
1816
// devtools: true
1917
},
20-
typescript: {
21-
includeWorkspace: true
22-
}
18+
devtools: { enabled: true }
2319
})

playground/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"build": "nuxt build",
5+
"dev": "nuxt dev",
6+
"generate": "nuxt generate",
7+
"preview": "nuxt preview"
8+
},
9+
"devDependencies": {
10+
"nuxt": "latest"
11+
}
12+
}

example/pages/auth/[provider]/callback.vue playground/pages/auth/[provider]/callback.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ const router = useRouter()
1212
onMounted(async () => {
1313
try {
1414
await authenticateProvider(route.params.provider as StrapiAuthProvider, route.query.access_token as string)
15-
} catch (e) {}
15+
} catch (e) {
16+
console.error(e)
17+
}
1618
1719
router.push('/')
1820
})

example/pages/index.vue playground/pages/index.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ const onSubmit = async () => {
4444
4545
try {
4646
await login(form)
47-
} catch (e) {}
47+
} catch (e) {
48+
console.error(e)
49+
}
4850
4951
loading.value = false
5052
}
File renamed without changes.

pnpm-lock.yaml

+23-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/composables-v3/useStrapi.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Strapi3RequestParams } from '../types/v3'
2-
// eslint-disable-next-line import/named
2+
// @ts-ignore
33
import { useStrapi3 } from '#imports'
44

55
interface StrapiV3Client<T> {

src/runtime/composables-v4/useStrapi.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Strapi4ResponseSingle, Strapi4RequestParams, Strapi4ResponseMany } from '../types/v4'
2-
// eslint-disable-next-line import/named
2+
// @ts-ignore
33
import { useStrapi4 } from '#imports'
44

55
interface StrapiV4Client<T> {
@@ -11,5 +11,6 @@ interface StrapiV4Client<T> {
1111
}
1212

1313
export const useStrapi = <T>(): StrapiV4Client<T> => {
14+
// @ts-ignore
1415
return useStrapi4()
1516
}

src/runtime/composables/useStrapiClient.ts

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const useStrapiClient = () => {
5252
}
5353

5454
try {
55+
// @ts-ignore
5556
return await $fetch<T>(url, {
5657
retry: 0,
5758
baseURL,
@@ -62,6 +63,7 @@ export const useStrapiClient = () => {
6263
}
6364
})
6465
} catch (err: any) {
66+
// @ts-ignore
6567
const e: Strapi4Error | Strapi3Error = err.data || defaultErrors(err)[version]
6668

6769
nuxt.hooks.callHook('strapi:error' as any, e)

src/runtime/composables/useStrapiToken.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
import { useCookie, useNuxtApp, useRuntimeConfig } from '#imports'
23

34
export const useStrapiToken = () => {

tsconfig.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"extends": "./example/.nuxt/tsconfig.json"
2+
"extends": "./.nuxt/tsconfig.json",
3+
"exclude": [
4+
"dist",
5+
"playground",
6+
"docs"
7+
]
38
}

0 commit comments

Comments
 (0)