From edde9c6187ccf217d4e2a1c0d9e17607a3c8d19a Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Mon, 15 Jan 2024 13:39:15 +0000 Subject: [PATCH] feat: remove init workspace command (#1027) --- README.md | 13 ++++---- client/src/commands.ts | 32 ------------------ client/src/extension.ts | 4 --- client/src/initialize_project.ts | 56 -------------------------------- client/src/welcome.ts | 11 ++++--- package.json | 7 ---- 6 files changed, 13 insertions(+), 110 deletions(-) delete mode 100644 client/src/initialize_project.ts diff --git a/README.md b/README.md index e3bf66c4..98119579 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Studio Code, powered by the Deno language server. 3. Ensure `deno` is available in the environment path, or set its path via the `deno.path` setting in VSCode. 4. Open the VS Code command palette with `Ctrl+Shift+P`, and run the _Deno: - Initialize Workspace Configuration_ command. + Enable_ command. We recognize that not every TypeScript/JavaScript project that you might work on in VSCode uses Deno — therefore, by default, this extension will only apply the @@ -70,9 +70,9 @@ The extension provides several commands: > provide a quick fix to fetch and cache those dependencies, which invokes > this command for you. -- _Deno: Initialize Workspace Configuration_ - will enabled Deno on the current - workspace and allow you to choose to enable linting and Deno _unstable_ API - options. +- _Deno: Enable_ - will enabled Deno on the current workspace. Alternatively + you can create a `deno.json` or `deno.jsonc` file at the root of your + workspace. - _Deno: Language Server Status_ - displays a page of information about the status of the Deno Language Server. Useful when submitting a bug about the extension or the language server. @@ -215,8 +215,9 @@ extension has the following configuration options: [ImportCompletions](./docs/ImportCompletions.md) for more information.) - `deno.testing.args`: Arguments to use when running tests via the Test Explorer. Defaults to `[ \"--allow-all\" ]`. -- `deno.unstable`: Controls if code will be type checked with Deno's unstable - APIs. This is the equivalent to using `--unstable` on the command line. +- `deno.unstable`: Controls if code will be executed with Deno's unstable APIs. + Affects execution which is triggered through the extension, such as test code + lenses. This is the equivalent to using `--unstable` on the command line. _boolean, default `false`_ ## Compatibility diff --git a/client/src/commands.ts b/client/src/commands.ts index 921ce497..0aa9c88b 100644 --- a/client/src/commands.ts +++ b/client/src/commands.ts @@ -10,7 +10,6 @@ import { LANGUAGE_CLIENT_NAME, SERVER_SEMVER, } from "./constants"; -import { pickInitWorkspace } from "./initialize_project"; import { cache as cacheReq, reloadImportRegistries as reloadImportRegistriesReq, @@ -98,37 +97,6 @@ export function cacheActiveDocument( }; } -export function initializeWorkspace( - _context: vscode.ExtensionContext, - _extensionContext: DenoExtensionContext, -): Callback { - return async () => { - try { - const settings = await pickInitWorkspace(); - const config = vscode.workspace.getConfiguration(EXTENSION_NS); - await config.update("enable", true); - - const lintInspect = config.inspect("lint"); - assert(lintInspect); - const unstableInspect = config.inspect("unstable"); - assert(unstableInspect); - - await config.update("lint", settings.lint); - await config.update("unstable", settings.unstable); - - await vscode.window.showInformationMessage( - "Deno is now setup in this workspace.", - ); - } catch (error) { - vscode.window.showErrorMessage( - `Deno project initialization failed: ${ - (error as Error).message ?? error - }`, - ); - } - }; -} - export function reloadImportRegistries( _context: vscode.ExtensionContext, extensionContext: DenoExtensionContext, diff --git a/client/src/extension.ts b/client/src/extension.ts index 38ce386a..084505f7 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -447,10 +447,6 @@ export async function activate( "deno.client.cacheActiveDocument", commands.cacheActiveDocument, ); - registerCommand( - "deno.client.initializeWorkspace", - commands.initializeWorkspace, - ); registerCommand("deno.client.restart", commands.startLanguageServer); registerCommand("deno.client.info", commands.info); registerCommand("deno.client.status", commands.status); diff --git a/client/src/initialize_project.ts b/client/src/initialize_project.ts deleted file mode 100644 index 410ce329..00000000 --- a/client/src/initialize_project.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -import { MultiStepInput } from "./multi_step_input"; - -const quickPickYesNo = [ - { label: "Yes" }, - { label: "No" }, -]; - -export interface InitWorkspaceSettings { - lint: boolean; - unstable: boolean; -} - -export function pickInitWorkspace() { - interface State extends InitWorkspaceSettings { - title: string; - step: number; - totalSteps: number; - } - - const title = "Initialize Project"; - - async function pickLint(input: MultiStepInput, state: Partial) { - const pick = await input.showQuickPick({ - title, - step: 1, - totalSteps: 2, - placeholder: "Enable Deno linting?", - items: quickPickYesNo, - shouldResume: () => Promise.resolve(false), - }); - state.lint = pick.label === "Yes" ? true : false; - return (input: MultiStepInput) => pickUnstable(input, state); - } - - async function pickUnstable(input: MultiStepInput, state: Partial) { - const pick = await input.showQuickPick({ - title, - step: 2, - totalSteps: 2, - placeholder: "Enable Deno unstable APIs?", - items: quickPickYesNo, - shouldResume: () => Promise.resolve(false), - }); - state.unstable = pick.label === "Yes" ? true : false; - } - - async function collectInputs() { - const state: Partial = {}; - await MultiStepInput.run((input) => pickLint(input, state)); - return state as InitWorkspaceSettings; - } - - return collectInputs(); -} diff --git a/client/src/welcome.ts b/client/src/welcome.ts index d30640a4..73e4af84 100644 --- a/client/src/welcome.ts +++ b/client/src/welcome.ts @@ -47,8 +47,8 @@ export class WelcomePanel { ); return; } - case "init": { - vscode.commands.executeCommand("deno.client.initializeWorkspace"); + case "enable": { + vscode.commands.executeCommand("deno.client.enable"); return; } } @@ -123,9 +123,10 @@ export class WelcomePanel {

The extension does not assume it applies to all workspaces you use - with VSCode. You can enable Deno in a workspace by running the - Deno: - Initialize Workspace Configuration command. + with VSCode. You can enable Deno in a workspace by creating a + deno.json or deno.jsonc at the root, or + by running the Deno: Enable command.

You can also enable or disable it in the diff --git a/package.json b/package.json index 599f7629..b067891c 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "onDebugResolve:javascript", "onDebugResolve:javascriptreact", "onCommand:deno.client.welcome", - "onCommand:deno.client.initializeWorkspace", "onCommand:deno.client.enable", "onCommand:deno.client.disable", "onCommand:deno.reloadImportRegistries", @@ -88,12 +87,6 @@ "description": "Cache the active workspace document and its dependencies.", "enablement": "deno:lspReady" }, - { - "command": "deno.client.initializeWorkspace", - "title": "Initialize Workspace Configuration", - "category": "Deno", - "description": "Initialize the workspace configuration for Deno." - }, { "command": "deno.reloadImportRegistries", "title": "Reload Import Registries Cache",