Skip to content

Commit

Permalink
Move project
Browse files Browse the repository at this point in the history
  • Loading branch information
alimozdemir committed Nov 7, 2024
1 parent 53f4d0b commit f4196f8
Show file tree
Hide file tree
Showing 79 changed files with 12,270 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
release:
types: [published]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x

- run: yarn install

- run: yarn run package

- name: Publish
run: yarn run deploy
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

.DS_Store
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.gotoLocation.multipleDefinitions": "goto"
}
7 changes: 7 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Exclude the playground folder
playground/

# You can also exclude other files and folders if needed
node_modules/
.vscode/
test/
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Change Log

All notable changes to the "vscode-nuxt-dx-tools" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [1.0.0]

- Initial release

## [1.1.0]

- Nitro API support
- Two new configurations
- nuxtDxTools.api.hover.enable [true/false]
- nuxtDxTools.api.functions [$fetch, useFetch]
- README updated

## [1.1.1]

- fix: Uri.file

## [1.1.2]

- fix: windows path

## [1.2.0]

- re-publish extenion under a new name
135 changes: 135 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<p align="center">
<img src="assets/icon.png" alt="Nuxt DX Tools Icon" width="200"/>
</p>

# Nuxt DX Tools

A VSCode extension designed to enhance the developer experience for Nuxt projects by providing tools for auto-locating and navigating to auto-imported components, functions, routes and more.

## Motivation

The goal is to enhance the developer experience for Nuxt projects, making developers more productive and efficient.

## Features

- **Auto-locate and navigate to auto-imported components and functions in Nuxt projects:**
- Instead of navigating to `.nuxt/components.d.ts`, it will find the actual component for you.
- Supports built-in components such as `Head`, `Script`, and `NuxtLoadingIndicator`.

- **Auto-locate custom definitions like custom plugins:**
- For example, if you have an `index.d.ts` file for your own definitions:

```typescript
import type { IDialogPlugin } from "./types/DialogPlugin";

declare module '#app' {
interface NuxtApp {
$dialog: IDialogPlugin,
}
}

export {}
```

- And you're using it like this:

```typescript
const { $dialog } = useNuxtApp();
```

- This extension will help you find the definition for `$dialog` as well.

- **Auto-locate server apis:**
- By default, Nitro provides excellent support for APIs, including IntelliSense and configuration based on API definitions. This extension enhances your development experience by helping you quickly locate and navigate to the corresponding API files.

- Supported logics
- `$fetch` and `useFetch` are supported
- For custom fetches (created by $fetch.create) see [Settings](#settings)
- Method: `index.{method}.ts`
- Parameters: `[id].ts`
- `**` wildcards (e.g. `[...slug].ts`, `[...].ts`)

## Configuration

We recommend to set `editor.gotoLocation.multipleDefinitions` to `goto` for better experience. By this, it will automatically navigate to the file.

<p align="center">
<img src="assets/prompt.png" alt="" />
</p>

### Settings

```json
"configuration": {
"title": "Nuxt DX Tools",
"properties": {
"nuxtDxTools.api.hover.enable": {
"type": "boolean",
"default": true,
"description": "Enable/disable hover on nitro APIs extension."
},
"nuxtDxTools.api.functions": {
"type": "array",
"default": ["$fetch", "useFetch"],
"description": "List of functions to be considered as nitro APIs."
}
}
}
```

## Examples

- **Auto-locate server apis:**
- These are all supported syntaxes, once you hover you will be able to see the first 3 lines of the API file

```typescript
$fetch('/api/myapi');
useFetch('/api/myapi')
$fetch('/api/change', {
method: 'POST',
body: JSON.stringify({ name: 'test' }),
})
$fetch('/api/change', {
method: 'GET',
body: JSON.stringify({ name: 'test' }),
})
$fetch('/api/change')
const id = 1;
$fetch(`/api/blog/` + id)
$fetch('/api/blog/' + id)
$fetch("/api/blog/" + id)
$fetch(`/api/blog/${id}`)
$fetch(`/api/blog/${id}/my-slug`)
$fetch("/api/blog/" + id + '/new')
$fetch("/api/blog/" + id + '/' + id)
useFetch('/api/blog/' + id + '/my-blog-slug/and-more')
```
<p align="center">
Hover
<img src="assets/api-hover.png" alt="" />
</p>

<p align="center">
Peek
<img src="assets/api-peek-goto.png" alt="" />
</p>


## Improvements

- This extension can also support standalone nitro projects where just the backend.
- Nuxt Layout support
- Nuxt Middleware support
Binary file added assets/api-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/api-peek-goto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/prompt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const esbuild = require("esbuild");

const production = process.argv.includes('--production');
const watch = process.argv.includes('--watch');

/**
* @type {import('esbuild').Plugin}
*/
const esbuildProblemMatcherPlugin = {
name: 'esbuild-problem-matcher',

setup(build) {
build.onStart(() => {
console.log('[watch] build started');
});
build.onEnd((result) => {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
console.error(` ${location.file}:${location.line}:${location.column}:`);
});
console.log('[watch] build finished');
});
},
};

async function main() {
const ctx = await esbuild.context({
entryPoints: [
'src/extension.ts'
],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
outfile: 'dist/extension.js',
external: ['vscode'],
logLevel: 'silent',
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin,
],
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

main().catch(e => {
console.error(e);
process.exit(1);
});
28 changes: 28 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";

export default [{
files: ["**/*.ts"],
}, {
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2022,
sourceType: "module",
},

rules: {
"@typescript-eslint/naming-convention": ["warn", {
selector: "import",
format: ["camelCase", "PascalCase"],
}],

curly: "warn",
eqeqeq: "warn",
"no-throw-literal": "warn",
semi: "warn",
},
}];
82 changes: 82 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"publisher": "alimozdemir",
"name": "vscode-nuxt-dx-tools",
"displayName": "Nuxt DX Tools",
"description": "A VSCode extension designed to enhance the developer experience for Nuxt projects by providing tools for auto-locating and navigating to auto-imported components, functions, routes and more.",
"version": "1.2.0",
"homepage": "https://github.com/alimozdemir/vscode-nuxt-dx-tools#readme",
"repository": {
"type": "git",
"url": "https://github.com/alimozdemir/vscode-nuxt-dx-tools"
},
"engines": {
"vscode": "^1.93.0"
},
"keywords": [
"nuxt",
"vue",
"nitro",
"peek",
"definition",
"goto"
],
"categories": [
"Other"
],
"activationEvents": [
"onLanguage:javascript",
"onLanguage:typescript",
"onLanguage:javascriptreact",
"onLanguage:typescriptreact",
"onLanguage:vue"
],
"main": "./dist/extension.js",
"icon": "assets/icon.png",
"contributes": {
"configuration": {
"title": "Nuxt DX Tools",
"properties": {
"nuxtDxTools.api.hover.enable": {
"type": "boolean",
"default": true,
"description": "Enable/disable hover on nitro APIs extension."
},
"nuxtDxTools.api.functions": {
"type": "array",
"default": ["$fetch", "useFetch"],
"description": "List of functions to be considered as nitro APIs."
}
}
}
},
"scripts": {
"vscode:prepublish": "yarn run package",
"compile": "yarn run check-types && yarn run lint && node esbuild.js",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"package": "yarn run check-types && yarn run lint && node esbuild.js --production",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "yarn run compile-tests && yarn run compile && yarn run lint",
"check-types": "tsc --noEmit",
"lint": "eslint src",
"test": "vscode-test",
"deploy": "vsce publish --yarn"
},
"devDependencies": {
"@types/mocha": "^10.0.9",
"@types/node": "20.x",
"@types/vscode": "^1.93.0",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.7.0",
"@vscode/test-cli": "^0.0.10",
"@vscode/test-electron": "^2.4.1",
"@vscode/vsce": "^3.2.1",
"esbuild": "^0.24.0",
"eslint": "^9.13.0",
"npm-run-all": "^4.1.5",
"typescript": "^5.6.3"
},
"packageManager": "yarn@1.22.21"
}
4 changes: 4 additions & 0 deletions playground/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.gotoLocation.multipleDeclarations": "peek",
"editor.gotoLocation.multipleDefinitions": "goto"
}
Loading

0 comments on commit f4196f8

Please sign in to comment.