Skip to content

Commit

Permalink
feat: initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBibby committed Jul 14, 2022
1 parent f170871 commit 99be279
Show file tree
Hide file tree
Showing 16 changed files with 260 additions and 25 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.16.0
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore artifacts:
out
dist
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"printWidth": 140
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
35 changes: 35 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "tasks: watch-tests"
}
]
}
23 changes: 23 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"out": false,
"dist": false,
"**/node_modules": false
},
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"explorer.excludeGitIgnore": false,
"typescript.tsdk": "node_modules/typescript/lib",
"files.insertFinalNewline": true,
}
43 changes: 43 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": [
"$ts-webpack-watch",
"$tslint-webpack-watch"
],
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": [
"npm: watch",
"npm: watch-tests"
],
"problemMatcher": []
}
]
}
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ src/**
.prettierrc.json
.prettierignore*
webpack.config.js
jest.config.js
jest.config.js
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

All notable changes to the "Hide Git Ignored" VSCode extension will be documented in this file:

#### v0.0.1 (July 01 2022)
#### v0.0.1 (July 14 2022)

- Initial release
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# vscode-hide-git-ignored README

[![](https://vsmarketplacebadge.apphb.com/version/chrisbibby.hide-git-ignored.svg)](https://marketplace.visualstudio.com/items?itemName=chrisbibby.hide-git-ignored)
[![](https://vsmarketplacebadge.apphb.com/installs/chrisbibby.hide-git-ignored.svg)](https://marketplace.visualstudio.com/items?itemName=chrisbibby.hide-git-ignored)
[![](https://vsmarketplacebadge.apphb.com/rating/chrisbibby.hide-git-ignored.svg)](https://marketplace.visualstudio.com/items?itemName=chrisbibby.hide-git-ignored&ssr=false#review-details)

# Hide Git Ignored README

This VSCode extension adds additional functionality to the .gitignore setting added to VSCode [v1.68](https://code.visualstudio.com/updates/v1_68#_hide-files-in-explorer-based-on-gitignore) (May 2022) which provided the option of hiding of files that are excluded in a `.gitignore` file from the explorer view.


## Features
- Context menu to show / hide
- Status bar to indicate current setting
- Shortcut key to toggle setting

## How to use

| Action | Windows / Linux | macOS | Command Palette |
| --------------------------------- | --------------- | ----------------- | ---------------------- |
| Show files excluded in .gitignore | `ctrl-shift-i` | `command-shift-i` | Show Git Ignored files |
| Hide files excluded in .gitignore | `ctrl-shift-i` | `command-shift-i` | Hide Git Ignored files |
Binary file added images/hideGitIgnored128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions images/hideGitIgnored24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 29 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "hide-git-ignored",
"displayName": "Hide Git Ignored",
"description": "Show/Hide git ignored files within the Explorer view",
"icon": "images/hideGitIgnored128.png",
"version": "0.0.1",
"license": "MIT",
"keywords": [
Expand All @@ -11,11 +12,12 @@
"show",
"hide",
"file",
"explorer"
"explorer",
"status bar"
],
"galleryBanner": {
"color": "#000000",
"theme": "dark"
"color": "#ffffff",
"theme": "light"
},
"publisher": "chrisbibby",
"author": {
Expand All @@ -40,13 +42,33 @@
"contributes": {
"commands": [
{
"command": "hide-git-ignored.toggle",
"title": "Show/Hide Git Ignored Files"
"command": "hide-git-ignored.hide",
"title": "Hide Git Ignored Files",
"when": "!hide-git-ignored:isGitIgnoredExcluded && hide-git-ignored:isGitIgnoredFound"
},
{
"command": "hide-git-ignored.show",
"title": "Show Git Ignored Files",
"when": "hide-git-ignored:isGitIgnoredExcluded && hide-git-ignored:isGitIgnoredFound"
}
],
"menus": {
"explorer/context": [
{
"command": "hide-git-ignored.show",
"group": "1_copypath@998",
"when": "hide-git-ignored:isGitIgnoredExcluded && hide-git-ignored:isGitIgnoredFound"
},
{
"command": "hide-git-ignored.hide",
"group": "1_copypath@997",
"when": "!hide-git-ignored:isGitIgnoredExcluded && hide-git-ignored:isGitIgnoredFound"
}
]
},
"keybindings": [
{
"command": "hide-git-ignored.toggle",
"command": "hide-git-ignored.show",
"key": "shift+ctrl+i",
"mac": "shift+cmd+i"
}
Expand Down Expand Up @@ -76,4 +98,4 @@
"webpack": "^5.72.1",
"webpack-cli": "^4.9.2"
}
}
}
24 changes: 18 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ import * as vscode from 'vscode';

const FIND_FILE_PATTERN = '**/.gitignore';
const FILE_WATCHER_PATTERN = '**/.gitignore';
const SHOW_HIDE_COMMAND = 'hide-git-ignored.toggle';
const HIDE_COMMAND = 'hide-git-ignored.hide';
const SHOW_COMMAND = 'hide-git-ignored.show';
const EXCLUDE_GIT_IGNORE = 'explorer.excludeGitIgnore';
const fileWatcher = vscode.workspace.createFileSystemWatcher(FILE_WATCHER_PATTERN, false, true, false);

let statusBarItem: vscode.StatusBarItem;

async function hasGitIgnoreFile(): Promise<boolean> {
return (await vscode.workspace.findFiles(FIND_FILE_PATTERN)).length > 0;
const gitIgnoreFound = (await vscode.workspace.findFiles(FIND_FILE_PATTERN)).length > 0;
return gitIgnoreFound;
}

async function hideGitIgnored() {
const target = vscode.ConfigurationTarget.Workspace;
const configuration = vscode.workspace.getConfiguration();
const currentSettings = configuration.get(EXCLUDE_GIT_IGNORE);
configuration.update(EXCLUDE_GIT_IGNORE, !currentSettings, target);
vscode.commands.executeCommand('setContext', 'hide-git-ignored:isGitIgnoredExcluded', !currentSettings);


await hasGitIgnoreFile() ? updateStatusBar(!currentSettings) : false;
}
Expand All @@ -33,32 +37,40 @@ function updateStatusBar(excluded: boolean | undefined): void {

const enableCommand = async () => {
await hasGitIgnoreFile() ? statusBarItem.show() : statusBarItem.hide();
vscode.commands.executeCommand('setContext', 'hide-git-ignored:isGitIgnoredFound', await hasGitIgnoreFile());
};

function isGitIgnoredExcluded(): boolean | undefined {
return vscode.workspace.getConfiguration().get(EXCLUDE_GIT_IGNORE);
}

const disposable = vscode.commands.registerCommand(SHOW_HIDE_COMMAND, async () => {
const hideCommand = vscode.commands.registerCommand(HIDE_COMMAND, async () => {
await hideGitIgnored();
});

const showCommand = vscode.commands.registerCommand(SHOW_COMMAND, async () => {
await hideGitIgnored();
});


export async function activate(context: vscode.ExtensionContext) {
statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 1);

fileWatcher.onDidCreate(async () => enableCommand());
fileWatcher.onDidDelete(async () => enableCommand());
enableCommand();

(statusBarItem.command = SHOW_HIDE_COMMAND),
(statusBarItem.command = HIDE_COMMAND),
async () => {
hideGitIgnored();
};

updateStatusBar(isGitIgnoredExcluded());
enableCommand();


context.subscriptions.push(statusBarItem);
context.subscriptions.push(disposable);
context.subscriptions.push(hideCommand);
context.subscriptions.push(showCommand);
}

export function deactivate() {
Expand Down
20 changes: 13 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"moduleResolution": "node",
"target": "es2020",
"outDir": "out",
"lib": [
"ES2020"
],
"sourceMap": true,
"rootDir": "src",
"strict": true /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
}
"strict": true,
"noImplicitReturns": true,
"resolveJsonModule": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true
},
"exclude": [
"node_modules",
".vscode-test"
]
}
Loading

0 comments on commit 99be279

Please sign in to comment.