Skip to content

Commit

Permalink
chore: improve module
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Nov 27, 2023
1 parent 6d8c593 commit 9b75133
Show file tree
Hide file tree
Showing 20 changed files with 88 additions and 44 deletions.
16 changes: 16 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,
extends: [
'@nuxt/eslint-config'
],
rules: {
// Global
semi: ['error', 'never'],
quotes: ['error', 'single'],
'quote-props': ['error', 'as-needed'],
// Vue
'vue/multi-word-component-names': 0,
'vue/max-attributes-per-line': 'off',
'vue/no-v-html': 0
}
}
9 changes: 0 additions & 9 deletions .eslintrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Prepare
run: pnpm run dev:prepare

- name: Lint
run: pnpm run lint

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Prepare
run: pnpm run dev:prepare

- name: Lint
run: pnpm run lint

Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
shamefully-hoist=true
auto-install-peers=true
strict-peer-dependencies=false
1 change: 1 addition & 0 deletions .nuxtrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
typescript.includeWorkspace=true
typescript.strict=false
1 change: 1 addition & 0 deletions docs/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default defineNuxtConfig({
css: ['@/assets/css/main.css'],
extends: ['@nuxt-themes/docus'],
modules: ['nuxt-plausible'],
// @ts-ignore
plausible: {
domain: 'strapi.nuxtjs.org'
}
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "MIT",
"exports": {
".": {
"types": "./dist/types.d.ts",
"import": "./dist/module.mjs",
"require": "./dist/module.cjs"
}
Expand All @@ -16,12 +17,13 @@
"dist"
],
"scripts": {
"build": "nuxt-module-build",
"dev": "nuxi dev example",
"lint": "eslint --ext .js,.ts,.vue .",
"typecheck": "nuxi typecheck",
"build": "nuxt-module-build build",
"prepack": "pnpm build",
"prepare": "nuxi prepare example",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
"lint": "eslint .",
"typecheck": "vue-tsc --noEmit",
"release": "pnpm lint && standard-version && git push --follow-tags"
},
"dependencies": {
Expand All @@ -32,6 +34,7 @@
"ufo": "^1.3.2"
},
"devDependencies": {
"@types/node": "^20.9.3",
"@nuxt/devtools": "^1.0.3",
"@nuxt/eslint-config": "^0.2.0",
"@nuxt/module-builder": "^0.5.4",
Expand Down
File renamed without changes.
8 changes: 2 additions & 6 deletions example/nuxt.config.ts → playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

export default defineNuxtConfig({
modules: [
'../src/module',
'@nuxt/devtools'
'../src/module'
],
// example of separate client/server URLs
// runtimeConfig: {
Expand All @@ -17,7 +15,5 @@ export default defineNuxtConfig({
// To enable the devtools, read https://strapi.nuxtjs.org/devtools
// devtools: true
},
typescript: {
includeWorkspace: true
}
devtools: { enabled: true }
})
12 changes: 12 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"nuxt": "latest"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const router = useRouter()
onMounted(async () => {
try {
await authenticateProvider(route.params.provider as StrapiAuthProvider, route.query.access_token as string)
} catch (e) {}
} catch (e) {
console.error(e)
}
router.push('/')
})
Expand Down
4 changes: 3 additions & 1 deletion example/pages/index.vue → playground/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ const onSubmit = async () => {
try {
await login(form)
} catch (e) {}
} catch (e) {
console.error(e)
}
loading.value = false
}
Expand Down
File renamed without changes.
41 changes: 23 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/runtime/composables-v3/useStrapi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Strapi3RequestParams } from '../types/v3'
// eslint-disable-next-line import/named
// @ts-ignore
import { useStrapi3 } from '#imports'

interface StrapiV3Client<T> {
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/composables-v4/useStrapi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Strapi4ResponseSingle, Strapi4RequestParams, Strapi4ResponseMany } from '../types/v4'
// eslint-disable-next-line import/named
// @ts-ignore
import { useStrapi4 } from '#imports'

interface StrapiV4Client<T> {
Expand All @@ -11,5 +11,6 @@ interface StrapiV4Client<T> {
}

export const useStrapi = <T>(): StrapiV4Client<T> => {
// @ts-ignore
return useStrapi4()
}
2 changes: 2 additions & 0 deletions src/runtime/composables/useStrapiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const useStrapiClient = () => {
}

try {
// @ts-ignore
return await $fetch<T>(url, {
retry: 0,
baseURL,
Expand All @@ -62,6 +63,7 @@ export const useStrapiClient = () => {
}
})
} catch (err: any) {
// @ts-ignore
const e: Strapi4Error | Strapi3Error = err.data || defaultErrors(err)[version]

nuxt.hooks.callHook('strapi:error' as any, e)
Expand Down
1 change: 1 addition & 0 deletions src/runtime/composables/useStrapiToken.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { useCookie, useNuxtApp, useRuntimeConfig } from '#imports'

export const useStrapiToken = () => {
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"extends": "./example/.nuxt/tsconfig.json"
"extends": "./.nuxt/tsconfig.json",
"exclude": [
"dist",
"playground",
"docs"
]
}

0 comments on commit 9b75133

Please sign in to comment.