diff --git a/src/add.ts b/src/add.ts index b90ef0b..3c1b937 100644 --- a/src/add.ts +++ b/src/add.ts @@ -3,6 +3,12 @@ import { getPackageJson } from './utils'; import * as Messages from './messages'; import { runCommand } from './run-command'; +/** + * Add packages to the project using yarn add command + * + * @param arg path to the file where command orignated + * @returns void + */ export async function yarnAddPackages(arg: Uri) { const packageJson: string = await getPackageJson(arg); @@ -11,14 +17,33 @@ export async function yarnAddPackages(arg: Uri) { runCommand(['add'], packageJson); } +/** + * Add packages to the project using yarn add command + * + * @param arg path to the file where command orignated + * @returns void + */ export function yarnAddPackage(arg: Uri) { return _addPackage(false, arg); } +/** + * Add packages to the project using yarn add command + * with --dev option + * @param arg path to the file where command orignated + * @returns void + */ export function yarnAddPackageDev(arg: Uri) { return _addPackage(true, arg); } +/** + * Add packages to the project using yarn add command with --dev option + * + * @param dev boolean + * @param arg path to the file where command orignated + * @returns void + */ const _addPackage = async function (dev: boolean, arg: Uri) { const packageJson: string = await getPackageJson(arg); diff --git a/src/extension.ts b/src/extension.ts index 3cd7de0..6e6a9ac 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -11,6 +11,11 @@ import { yarnRawCommand } from './raw'; import yarnTerminate from './terminate'; import { yarnOutdated } from './outdated'; +/** + * Activate the extension and register all commands and events + * + * @param context ExtensionContext + */ export const activate = function (context: ExtensionContext) { const disposables = [ Commands.registerCommand('yarn-script.installPackages', yarnInstallPackages), @@ -33,6 +38,11 @@ export const activate = function (context: ExtensionContext) { context.subscriptions.push(...disposables, outputChannel); }; +/** + * Deactivate the extension + * @returns void + * @export deactivate + */ export function deactivate() { if (terminal) { terminal.dispose(); diff --git a/src/init.ts b/src/init.ts index 6e47ca9..f65739f 100644 --- a/src/init.ts +++ b/src/init.ts @@ -4,6 +4,11 @@ import { workspace as Workspace, window as Window } from 'vscode'; import * as Messages from './messages'; import { packageExists, pickPackageJson } from './utils'; +/** + * Initialize a new package.json file + * + * @returns void + */ export default async function () { const packageJson = await pickPackageJson(); diff --git a/src/install.ts b/src/install.ts index 37ee398..328a09f 100644 --- a/src/install.ts +++ b/src/install.ts @@ -2,6 +2,12 @@ import { getPackageJson } from './utils'; import { Uri } from 'vscode'; import { runCommand } from './run-command'; +/** + * Install packages to the project using yarn install command + * + * @param arg path to the file where command orignated + * @returns void + */ export async function yarnInstallPackages(arg: Uri) { const packageJson: string = await getPackageJson(arg); diff --git a/src/outdated.ts b/src/outdated.ts index ded238b..f13ce51 100644 --- a/src/outdated.ts +++ b/src/outdated.ts @@ -2,6 +2,12 @@ import { getPackageJson } from './utils'; import { Uri } from 'vscode'; import { runCommand } from './run-command'; +/** + * Run yarn outdated command + * + * @param arg path to the file where command orignated + * @returns void + */ export async function yarnOutdated(arg: Uri) { const packageJson: string = await getPackageJson(arg); diff --git a/src/publish.ts b/src/publish.ts index 7808f42..af6ea94 100644 --- a/src/publish.ts +++ b/src/publish.ts @@ -3,6 +3,12 @@ import { getPackageJson } from './utils'; import * as Messages from './messages'; import { runCommand } from './run-command'; +/** + * Publish package to the registry using yarn publish command + * + * @param arg path to the file where command orignated + * @returns void + */ export async function yarnPublish(arg: Uri) { const cmd: string = 'publish'; const packageJson: string = await getPackageJson(arg); diff --git a/src/raw.ts b/src/raw.ts index 8ea1d9b..5d20cb7 100644 --- a/src/raw.ts +++ b/src/raw.ts @@ -3,6 +3,11 @@ import { packageExists, pickPackageJson } from './utils'; import * as Messages from './messages'; import { runCommand } from './run-command'; +/** + * Run yarn command + * + * @returns void + */ export async function yarnRawCommand() { const packageJson = await pickPackageJson(); if (!packageExists(packageJson)) { diff --git a/src/remove.ts b/src/remove.ts index f36d8c7..4f369b6 100644 --- a/src/remove.ts +++ b/src/remove.ts @@ -3,6 +3,12 @@ import { getPackageJson } from './utils'; import * as Messages from './messages'; import { runCommand } from './run-command'; +/** + * Remove packages from the project using yarn remove command + * + * @param arg path to the file where command orignated + * @returns void + */ export async function yarnRemovePackage(arg: Uri) { const packageJson: string = await getPackageJson(arg); diff --git a/src/run-command.ts b/src/run-command.ts index 50ac04a..8ccc216 100644 --- a/src/run-command.ts +++ b/src/run-command.ts @@ -64,6 +64,12 @@ function runCommandInIntegratedTerminal(args: string[], cwd: string): void { terminal.sendText(cmd_args.join(' ')); } +/** + * Run command in output window + * + * @param args command arguments + * @param cwd current working directory + */ function runCommandInOutputWindow(args: string[], cwd: string) { const cmd = getYarnBin() + ' ' + args.join(' '); diff --git a/src/run.ts b/src/run.ts index f2959f8..65b48fa 100644 --- a/src/run.ts +++ b/src/run.ts @@ -9,6 +9,12 @@ let lastScript: { script: string; }; +/** + * Read scripts from package.json file + * + * @param arg path to the file where command orignated + * @returns void + */ export async function yarnRunScript(arg: Uri) { const packageJson: string = await getPackageJson(arg); @@ -32,6 +38,12 @@ export async function yarnRunScript(arg: Uri) { }); } +/** + * Read scripts from package.json file + * + * @param arg path to the file where command orignated + * @returns void + */ export async function yarnTest(arg: Uri) { const packageJson: string = await getPackageJson(arg); diff --git a/src/terminate.ts b/src/terminate.ts index 5cb755e..fea49b8 100644 --- a/src/terminate.ts +++ b/src/terminate.ts @@ -2,6 +2,9 @@ import { childs, terminate } from './run-command'; import { useTerminal } from './utils'; import { window as Window, QuickPickItem } from 'vscode'; +/** + * Item for quick pick menu + */ class Item implements QuickPickItem { constructor(public label: string, public description: string, @@ -9,6 +12,9 @@ class Item implements QuickPickItem { } } +/** + * Read scripts from package.json file and return them as an object + */ export default function () { if (useTerminal()) { Window.showInformationMessage('Killing is only supported when the setting "runInTerminal" is "false"'); diff --git a/src/utils.ts b/src/utils.ts index d39bdbf..182b6f7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,6 +8,11 @@ interface PackageJsonRoot { name: string; } +/** + * Read scripts from package.json file and return them as an object + * + * @returns object + */ export async function pickPackageJson(): Promise> { // if active text editor is a package.json turn the path for it const editor = Window.activeTextEditor;