Skip to content

Commit

Permalink
chore: nuxi init -t module
Browse files Browse the repository at this point in the history
  • Loading branch information
DrJume committed Aug 23, 2023
1 parent 6b98d10 commit 777dd22
Show file tree
Hide file tree
Showing 20 changed files with 299 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": ["@nuxt/eslint-config"]
}
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Dependencies
node_modules

# Logs
*.log*

# Temp directories
.temp
.tmp
.cache

# Yarn
**/.yarn/cache
**/.yarn/*state*

# Generated dirs
dist

# Nuxt
.nuxt
.output
.data
.vercel_build_output
.build-*
.netlify

# Env
.env

# Testing
reports
coverage
*.lcov
.nyc_output

# VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Intellij idea
*.iml
.idea

# OSX
.DS_Store
.AppleDouble
.LSOverride
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
2 changes: 2 additions & 0 deletions .nuxtrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports.autoImport=false
typescript.includeWorkspace=true
87 changes: 85 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,85 @@
# nuxt-sentry
Nuxt 3 module for Sentry
# Nuxt Sentry

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
[![Nuxt][nuxt-src]][nuxt-href]

Nuxt 3 module for Sentry.

- [ Release Notes](/CHANGELOG.md)
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/@falcondev-it/nuxt-sentry?file=playground%2Fapp.vue) -->
<!-- - [📖 &nbsp;Documentation](https://example.com) -->

## Features

<!-- Highlight some of the features your module provide here -->
-&nbsp;Foo
- 🚠 &nbsp;Bar
- 🌲 &nbsp;Baz

## Quick Setup

1. Add `@falcondev-it/nuxt-sentry` dependency to your project

```bash
# Using pnpm
pnpm add -D @falcondev-it/nuxt-sentry

# Using yarn
yarn add --dev @falcondev-it/nuxt-sentry

# Using npm
npm install --save-dev @falcondev-it/nuxt-sentry
```

2. Add `@falcondev-it/nuxt-sentry` to the `modules` section of `nuxt.config.ts`

```js
export default defineNuxtConfig({
modules: [
'@falcondev-it/nuxt-sentry'
]
})
```

That's it! You can now use Nuxt Sentry in your Nuxt app ✨

## Development

```bash
# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release
```

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/@falcondev-it/nuxt-sentry/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/@falcondev-it/nuxt-sentry

[npm-downloads-src]: https://img.shields.io/npm/dm/@falcondev-it/nuxt-sentry.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-downloads-href]: https://npmjs.com/package/@falcondev-it/nuxt-sentry

[license-src]: https://img.shields.io/npm/l/@falcondev-it/nuxt-sentry.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/@falcondev-it/nuxt-sentry

[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
[nuxt-href]: https://nuxt.com
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@falcondev-it/nuxt-sentry",
"version": "0.1.0",
"description": "Nuxt 3 module for Sentry",
"repository": "https://github.com/falcondev-it/nuxt-sentry",
"license": "MIT",
"type": "module",
"exports": {
".": {
"types": "./dist/types.d.ts",
"import": "./dist/module.mjs",
"require": "./dist/module.cjs"
}
},
"main": "./dist/module.cjs",
"types": "./dist/types.d.ts",
"files": [
"dist"
],
"scripts": {
"prepack": "nuxt-module-build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
"lint": "eslint .",
"test": "vitest run",
"test:watch": "vitest watch"
},
"dependencies": {
"@nuxt/kit": "^3.6.5"
},
"devDependencies": {
"@types/node": "^18.17.3",
"@nuxt/devtools": "latest",
"@nuxt/eslint-config": "^0.1.1",
"@nuxt/module-builder": "^0.4.0",
"@nuxt/schema": "^3.6.5",
"@nuxt/test-utils": "^3.6.5",
"changelogen": "^0.5.4",
"eslint": "^8.46.0",
"nuxt": "^3.6.5",
"vitest": "^0.34.1"
}
}
8 changes: 8 additions & 0 deletions playground/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<div>
Nuxt module playground!
</div>
</template>

<script setup>
</script>
5 changes: 5 additions & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default defineNuxtConfig({
modules: ['../src/module'],
myModule: {},
devtools: { enabled: true }
})
13 changes: 13 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"private": true,
"name": "@falcondev-it/nuxt-sentry-playground",
"type": "module",
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build",
"generate": "nuxi generate"
},
"devDependencies": {
"nuxt": "latest"
}
}
3 changes: 3 additions & 0 deletions playground/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}
3 changes: 3 additions & 0 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
19 changes: 19 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineNuxtModule, addPlugin, createResolver } from "@nuxt/kit";

// Module options TypeScript interface definition
export interface ModuleOptions {}

export default defineNuxtModule<ModuleOptions>({
meta: {
name: "@falcondev-it/nuxt-sentry",
configKey: "myModule",
},
// Default configuration options of the Nuxt module
defaults: {},
setup(options, nuxt) {
const resolver = createResolver(import.meta.url);

// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
addPlugin(resolver.resolve("./runtime/plugin"));
},
});
5 changes: 5 additions & 0 deletions src/runtime/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineNuxtPlugin } from "#app";

export default defineNuxtPlugin((nuxtApp) => {
console.log("Plugin injected by @falcondev-it/nuxt-sentry!");
});
15 changes: 15 additions & 0 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { describe, it, expect } from 'vitest'
import { fileURLToPath } from 'node:url'
import { setup, $fetch } from '@nuxt/test-utils'

describe('ssr', async () => {
await setup({
rootDir: fileURLToPath(new URL('./fixtures/basic', import.meta.url)),
})

it('renders the index page', async () => {
// Get response to a server-rendered page with `$fetch`.
const html = await $fetch('/')
expect(html).toContain('<div>basic</div>')
})
})
6 changes: 6 additions & 0 deletions test/fixtures/basic/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<div>basic</div>
</template>

<script setup>
</script>
7 changes: 7 additions & 0 deletions test/fixtures/basic/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import MyModule from '../../../src/module'

export default defineNuxtConfig({
modules: [
MyModule
]
})
5 changes: 5 additions & 0 deletions test/fixtures/basic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"private": true,
"name": "basic",
"type": "module"
}
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./playground/.nuxt/tsconfig.json"
}

0 comments on commit 777dd22

Please sign in to comment.