Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bug report info command #164

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions .github/ISSUE_TEMPLATE/issue.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,17 @@ body:
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: dropdown
id: version
attributes:
label: Version
description: What version of our software are you running?
options:
- 1.0.2 (Default)
- 1.0.3 (Edge)
validations:
required: true
- type: textarea
id: bug-env
validations:
required: true
attributes:
label: Environment
description: You can use `npx nuxi info` to fill this section
description: |
You can use the `Nuxtr: Bug Report Info` command in the VSCode Command Palette to fill this section.
To open the Command Palette, press `Ctrl + Shift + P` (or `⌘ + Shift + P` on macOS).
placeholder: Environment
validations:
required: true

- type: textarea
id: bug-description
attributes:
Expand All @@ -33,6 +26,7 @@ body:
placeholder: Bug description
validations:
required: true

- type: textarea
id: bug-steps-to-reproduce
attributes:
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"typescript.tsc.autoDetect": "off",
"editor.formatOnSave": true,
"eslint.useFlatConfig": true
"eslint.useFlatConfig": true,
"cSpell.words": [
"Nuxi"
]
}
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@
"command": "nuxtr.errorLayout",
"when": "nuxtr.isNuxtProject"
},
{
"command": "nuxtr.generateBugInfoReport",
"when": "nuxtr.isNuxtProject"
},
{
"command": "nuxtr.managePackageVersion",
"when": "false"
Expand Down Expand Up @@ -969,6 +973,11 @@
"command": "nuxtr.createProject",
"title": "Create new Nuxt Project",
"category": "Nuxtr"
},
{
"command": "nuxtr.generateBugInfoReport",
"title": "Bug Report Info",
"category": "Nuxtr"
}
],
"keybindings": [],
Expand Down
40 changes: 40 additions & 0 deletions src/commands/bugReport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { env, extensions, version, window } from 'vscode';
import { detectPackageManagerByName, getNuxtVersion, getPackageManagerVersion } from '../utils';

export async function generateBugInfoReport() {
const nuxtr = extensions.getExtension('nuxtr.nuxtr-vscode');

const operatingSystem = process.platform;
const vscodeVersion = version;
const nuxtrVersion = nuxtr?.packageJSON.version;
const nuxtVersion = await getNuxtVersion();
const pm = detectPackageManagerByName();
const packageManager = pm?.name || 'Unknown';

if (!pm) {
window.showErrorMessage('No package manager found');
return;
}

const pmVersion = await getPackageManagerVersion(pm?.name);

const reportLines = [
`- Operating System: \`${operatingSystem}\``,
`- VSCode Version: \`${vscodeVersion}\``,
`- Nuxtr Version: \`${nuxtrVersion}\``,
`- Nuxt Version: \`${nuxtVersion}\``,
`- Package Manager: \`${packageManager}@${pmVersion}\``
];

const bugReportInfo = reportLines.join('\n');

env.clipboard.writeText(bugReportInfo);

const prompt = window.showInformationMessage('Bug report info copied to clipboard', 'Copy again');

prompt.then((answer) => {
if (answer === 'Copy again') {
env.clipboard.writeText(bugReportInfo);
}
});
}
29 changes: 15 additions & 14 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { managePackageVersion, upgradePackage } from '../utils/dependency'
import { openSettings } from '../utils/navigation'
import { configureCSS } from './CSS'
import { createComponent, directCreateComponent } from './Component'
import { createPage, directCreatePage } from './Page'
import { createComposable, directCreateComposable } from './Composable'
import { directToggleDevTools, nuxtConfigWatcher } from './Devtools'
import { createEmptyFileTemplate, createFileFromTemplate, createLayoutTemplate, createPageTemplate } from './FileTemplates'
import { installDependencies } from './InstallDependencies'
import { createLayout, directCreateLayout } from './Layout'
import { createPlugin, directCreatePlugin } from './Plugin'
import { configureLinters } from './Linters'
import { createMiddleware, directCreateMiddleware } from './Middleware'
import { createNitroAPI, createNitroMiddleware, createNitroPlugin, createNitroRoute, createNitroUtil, directCreateNitroAPI, directCreateNitroRoute } from './Nitro'
import { appConfig, errorLayout, nuxtIgnore, nuxtRC, projectStructure } from './Structure'
import { openDocumentation, openModules } from './externalLinks'
import { nuxtAnalyze, nuxtBuild, nuxtCleanUp, nuxtDev, nuxtGenerate, nuxtInfo, nuxtModule, showCLICommands } from './Nuxi'
import { createPage, directCreatePage } from './Page'
import { createPlugin, directCreatePlugin } from './Plugin'
import { createProject } from './Project'
import { createStore, directCreateStore } from './Store'
import { installDependencies } from './InstallDependencies'
import { openSettings } from '../utils/navigation'
import { managePackageVersion, upgradePackage } from '../utils/dependency'
import { configureCSS } from './CSS'
import { configureLinters } from './Linters'
import { appConfig, errorLayout, nuxtIgnore, nuxtRC, projectStructure } from './Structure'
import { configurePug } from './Templates'
import { createEmptyFileTemplate, createFileFromTemplate, createLayoutTemplate, createPageTemplate } from './FileTemplates'
import { directToggleDevTools, nuxtConfigWatcher } from './Devtools'
import { createUtil, directCreateUtil } from './Util'
import { createProject } from './Project'

import { generateBugInfoReport } from './bugReport'
import { openDocumentation, openModules } from './externalLinks'

const commands = {
createComponent,
Expand Down Expand Up @@ -73,7 +73,8 @@ const commands = {
createFileFromTemplate,
createEmptyFileTemplate,
directToggleDevTools,
nuxtConfigWatcher
nuxtConfigWatcher,
generateBugInfoReport
}

export default commands
11 changes: 6 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ExtensionContext, Uri, commands, window } from 'vscode';
import nuxtrCommands from './commands'
import { ModulesView } from './sideBar'
import codelens from './codelens';
import nuxtrCommands from './commands';
import { activateIntellisense } from './intellisense';
import { ModulesView } from './sideBar';
import { activateStatusBarIcons, statusBars } from './statusBar';
import { logger, updateDependencies } from './utils';
import codelens from './codelens'
import { activateStatusBarIcons, statusBars } from './statusBar'
import { activateIntellisense } from './intellisense'
import { filesWatcher } from './watchers';

const extensionCommands = [
Expand Down Expand Up @@ -58,6 +58,7 @@ const extensionCommands = [
{ command: 'nuxtr.directCreateNitroRoute', function: (filePath: Uri) => nuxtrCommands.directCreateNitroRoute(filePath.path) },
{ command: 'nuxtr.directCreateStore', function: (filePath: Uri) => nuxtrCommands.directCreateStore(filePath.path) },
{ command: 'nuxtr.directCreateUtil', function: (filePath: Uri) => nuxtrCommands.directCreateUtil(filePath.path) },
{ command: 'nuxtr.generateBugInfoReport', function: nuxtrCommands.generateBugInfoReport }
];

export const publicCommands = [
Expand Down
8 changes: 4 additions & 4 deletions src/sideBar/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as vscode from 'vscode'
import { capitalize } from 'string-ts'
import { existsSync, readFileSync, readdirSync, unlinkSync } from 'node:fs'
import { exec } from 'node:child_process'
import { destr } from "destr"
import { exec } from 'node:child_process'
import { existsSync, readFileSync, readdirSync, unlinkSync } from 'node:fs'
import { capitalize } from 'string-ts'
import * as vscode from 'vscode'

import {
detectPackageManagerByName,
Expand Down
27 changes: 19 additions & 8 deletions src/utils/dependency.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { destr } from "destr";
import { exec } from 'node:child_process';
import { existsSync, readFileSync, readdirSync } from 'node:fs';
import { readPackageJSON } from 'pkg-types';
import { ProgressLocation, QuickPickItem, QuickPickOptions, StatusBarItem, commands, window } from 'vscode';
import { existsSync, readFileSync, readdirSync } from 'node:fs'
import { exec } from 'node:child_process'
import { destr } from "destr"
import { readPackageJSON } from 'pkg-types'
import { nuxtrConfiguration, projectRootDirectory, runCommand } from './global'
import { installDependencies } from '../commands/InstallDependencies'
import pm from '../content/pm'
import { newTerminal } from '.'
import { newTerminal } from '.';
import { installDependencies } from '../commands/InstallDependencies';
import pm from '../content/pm';
import { nuxtrConfiguration, projectRootDirectory, runCommand } from './global';


const items: QuickPickItem[] = pm.map((item) => {
Expand Down Expand Up @@ -142,6 +142,17 @@ export const detectPackageManagerByName = () => {
return undefined
}

export function getPackageManagerVersion(packageManager: string): Promise<string> {
return new Promise((resolve, reject) => {
exec(`${packageManager} --version`, (error, stdout) => {
if (error) {
return reject(`Error fetching version for ${packageManager}: ${error.message}`);
}
resolve(stdout.trim());
});
});
}

export const getInstallationCommand = async (packageName: string, devFlag: boolean) => {
const packageManager = detectPackageManagerByName()

Expand Down
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export {
getProjectDependencies,
getProjectScripts,
detectPackageManagerByName,
getPackageManagerVersion,
getInstallationCommand,
getOutdatedPackages,
dependenciesUpdatesHandler,
Expand Down