diff --git a/.github/ISSUE_TEMPLATE/issue.yaml b/.github/ISSUE_TEMPLATE/issue.yaml index 9d06ace..ef349cb 100644 --- a/.github/ISSUE_TEMPLATE/issue.yaml +++ b/.github/ISSUE_TEMPLATE/issue.yaml @@ -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: @@ -33,6 +26,7 @@ body: placeholder: Bug description validations: required: true + - type: textarea id: bug-steps-to-reproduce attributes: diff --git a/.vscode/settings.json b/.vscode/settings.json index d668ae1..5e162f9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,8 @@ { "typescript.tsc.autoDetect": "off", "editor.formatOnSave": true, - "eslint.useFlatConfig": true + "eslint.useFlatConfig": true, + "cSpell.words": [ + "Nuxi" + ] } \ No newline at end of file diff --git a/package.json b/package.json index 107847e..fa95ddc 100644 --- a/package.json +++ b/package.json @@ -263,6 +263,10 @@ "command": "nuxtr.errorLayout", "when": "nuxtr.isNuxtProject" }, + { + "command": "nuxtr.generateBugInfoReport", + "when": "nuxtr.isNuxtProject" + }, { "command": "nuxtr.managePackageVersion", "when": "false" @@ -969,6 +973,11 @@ "command": "nuxtr.createProject", "title": "Create new Nuxt Project", "category": "Nuxtr" + }, + { + "command": "nuxtr.generateBugInfoReport", + "title": "Bug Report Info", + "category": "Nuxtr" } ], "keybindings": [], diff --git a/src/commands/bugReport.ts b/src/commands/bugReport.ts new file mode 100644 index 0000000..8857386 --- /dev/null +++ b/src/commands/bugReport.ts @@ -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); + } + }); +} diff --git a/src/commands/index.ts b/src/commands/index.ts index f64df04..63c624a 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -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, @@ -73,7 +73,8 @@ const commands = { createFileFromTemplate, createEmptyFileTemplate, directToggleDevTools, - nuxtConfigWatcher + nuxtConfigWatcher, + generateBugInfoReport } export default commands diff --git a/src/extension.ts b/src/extension.ts index 87b3042..6ca91f0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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 = [ @@ -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 = [ diff --git a/src/sideBar/index.ts b/src/sideBar/index.ts index 3c9fe37..45ecba9 100644 --- a/src/sideBar/index.ts +++ b/src/sideBar/index.ts @@ -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, diff --git a/src/utils/dependency.ts b/src/utils/dependency.ts index 95dec9e..82d83ec 100644 --- a/src/utils/dependency.ts +++ b/src/utils/dependency.ts @@ -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) => { @@ -142,6 +142,17 @@ export const detectPackageManagerByName = () => { return undefined } +export function getPackageManagerVersion(packageManager: string): Promise { + 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() diff --git a/src/utils/index.ts b/src/utils/index.ts index 8fbe775..0a996f8 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -26,6 +26,7 @@ export { getProjectDependencies, getProjectScripts, detectPackageManagerByName, + getPackageManagerVersion, getInstallationCommand, getOutdatedPackages, dependenciesUpdatesHandler,