Skip to content

Commit c3f30ef

Browse files
Update project structure and add new features for JetTreeMark
1 parent d023d10 commit c3f30ef

File tree

19 files changed

+141
-45
lines changed

19 files changed

+141
-45
lines changed

.idea/dictionaries/project.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# JetTreeMark for VS Code
22

33
![Build](https://github.com/HichemTab-tech/JetTreeMark-vscode/actions/workflows/ci.yml/badge.svg)
4-
[![Version](https://img.shields.io/badge/version-0.0.3-blue.svg)](https://github.com/HichemTab-tech/JetTreeMark-vscode/releases) [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/HichemTab-tech/JetTreeMark-vscode/blob/master/LICENSE)
4+
[![Version](https://img.shields.io/badge/version-0.0.4-blue.svg)](https://github.com/HichemTab-tech/JetTreeMark-vscode/releases) [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/HichemTab-tech/JetTreeMark-vscode/blob/master/LICENSE)
55

66
---
77

@@ -94,8 +94,14 @@ vsce package
9494

9595
1. **Right-click** on any folder in the Explorer.
9696
2. Select **“Show Tree View”** from the context menu.
97+
98+
![How to use the JetTreeMark plugin from folder context menu](https://github.com/HichemTab-tech/JetTreeMark-vscode/meta/screenshot-1.png "Screenshot -JetTreeMark in context menu-")
99+
97100
3. The **JetTreeMark** view opens in the Activity Bar.
98101
4. Use the **tri-state checkboxes** to include/exclude items.
102+
103+
![How to use the JetTreeMark plugin to exclude nodes from the tree view result](https://github.com/HichemTab-tech/JetTreeMark-vscode/meta/screenshot-2.png "Screenshot - filter nodes from tree results -")
104+
99105
5. Click **“Copy Selected Structure”** at the top to copy your markdown tree.
100106

101107
---

meta/screenshot-1.png

39.8 KB
Loading

meta/screenshot-2.png

33.8 KB
Loading

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
"name": "jettreemark",
33
"displayName": "JetTreeMark",
44
"description": "JetTreeMark is a VS Code plugin that generates a markdown-compatible structure tree for selected files and folders",
5-
"version": "0.0.3",
5+
"version": "0.0.4",
66
"publisher": "HichemTab-tech",
7-
"repository": "https://github.com/HichemTab-tech/JetTreeMark-vscode",
7+
"homepage": "https://github.com/HichemTab-tech/JetTreeMark-vscode",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/HichemTab-tech/JetTreeMark-vscode"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/HichemTab-tech/JetTreeMark-vscode/issues"
14+
},
815
"icon": "pluginIcon.png",
916
"engines": {
1017
"vscode": "^1.99.0"
@@ -79,5 +86,8 @@
7986
"typescript": "^5.8.2",
8087
"webpack": "^5.98.0",
8188
"webpack-cli": "^6.0.1"
82-
}
89+
},
90+
"files": [
91+
"webview-ui-dist/**"
92+
]
8393
}

src/JetTreeMarkViewProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ export class JetTreeMarkViewProvider implements vscode.WebviewViewProvider {
1616
webviewView.webview.options = {
1717
enableScripts: true,
1818
localResourceRoots: [
19-
vscode.Uri.joinPath(this.extensionUri, 'src', 'webview-ui-dist')
19+
vscode.Uri.joinPath(this.extensionUri, 'webview-ui-dist')
2020
]
2121
};
2222

2323
// Load the built HTML
24-
const folder = path.join(this.extensionUri.fsPath, 'src', 'webview-ui-dist');
24+
const folder = path.join(this.extensionUri.fsPath, 'webview-ui-dist');
2525
let html = fs.readFileSync(path.join(folder, 'index.html'), 'utf8');
2626

2727
// 1) compute the folder URI for assets
2828
const baseUri = webviewView.webview.asWebviewUri(
29-
vscode.Uri.joinPath(this.extensionUri, 'src', 'webview-ui-dist')
29+
vscode.Uri.joinPath(this.extensionUri, 'webview-ui-dist')
3030
) + '/';
3131

3232
// 2) inject the <base> so that all "./…" references resolve correctly

src/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as fs from 'fs';
33
import * as path from 'path';
44
import { JetTreeMarkViewProvider } from './JetTreeMarkViewProvider';
55

6+
// noinspection JSUnusedGlobalSymbols
67
export function activate(ctx: vscode.ExtensionContext) {
78
// Register the WebviewView (your “ToolWindow”)
89
const provider = new JetTreeMarkViewProvider(ctx.extensionUri);
@@ -43,7 +44,7 @@ interface TreeNodeType {
4344
/**
4445
* Build a TreeNodeType *for* the directory itself, including its contents.
4546
*/
46-
function buildTreeNode(dir: string): TreeNodeType {
47+
export function buildTreeNode(dir: string): TreeNodeType {
4748
const name = path.basename(dir) || dir;
4849
const node: TreeNodeType = {
4950
id: dir,

src/test/extension.test.ts

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,66 @@
11
import * as assert from 'assert';
2-
3-
// You can import and use all API from the 'vscode' module
4-
// as well as import your extension to test it
52
import * as vscode from 'vscode';
6-
// import * as myExtension from '../../extension';
3+
import * as path from 'path';
4+
// Make sure you export buildTreeNode from your extension entrypoint
5+
import { buildTreeNode } from '../extension';
6+
import * as fs from 'fs';
7+
import * as os from "os";
8+
9+
suite('JetTreeMark-vscode Test Suite', () => {
10+
test('Extension is present in the registry', () => {
11+
const ext = vscode.extensions.getExtension('hichemtab-tech.jettreemark');
12+
assert.ok(ext, 'Extension not found');
13+
});
14+
15+
test('Extension activates successfully', async () => {
16+
const ext = vscode.extensions.getExtension('hichemtab-tech.jettreemark')!;
17+
await ext.activate();
18+
assert.strictEqual(ext.isActive, true, 'Extension failed to activate');
19+
});
20+
21+
test('buildTreeNode throws on missing folder', () => {
22+
assert.throws(
23+
() => buildTreeNode('/path/does/not/exist'),
24+
/ENOENT/,
25+
'Expected buildTreeNode to throw ENOENT for non-existent folder'
26+
);
27+
});
28+
29+
suite('JetTreeMark-vscode Test Suite (dynamic fixtures)', () => {
30+
let tmpDir: string;
31+
32+
suiteSetup(() => {
33+
// 1) Create a temp directory
34+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jtt-test-'));
35+
36+
// 2) Populate it: a.txt, and a subfolder with b.txt
37+
fs.writeFileSync(path.join(tmpDir, 'a.txt'), 'hello');
38+
const sub = path.join(tmpDir, 'subdir');
39+
fs.mkdirSync(sub);
40+
fs.writeFileSync(path.join(sub, 'b.txt'), 'world');
41+
});
42+
43+
suiteTeardown(() => {
44+
// Clean up after all tests
45+
fs.rmSync(tmpDir, { recursive: true, force: true });
46+
});
47+
48+
test('buildTreeNode returns correct shape for dynamic folder', () => {
49+
const root = buildTreeNode(tmpDir);
50+
assert.strictEqual(root.name, path.basename(tmpDir));
51+
assert.strictEqual(root.type, 'folder');
52+
assert.ok(Array.isArray(root.children));
753

8-
suite('Extension Test Suite', () => {
9-
vscode.window.showInformationMessage('Start all tests.');
54+
// Expect a.txt
55+
const fileNode = root.children!.find(n => n.name === 'a.txt');
56+
assert.ok(fileNode, 'a.txt should exist');
57+
assert.strictEqual(fileNode!.type, 'file');
1058

11-
test('Sample test', () => {
12-
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
13-
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
59+
// Expect subdir/b.txt
60+
const subNode = root.children!.find(n => n.name === 'subdir');
61+
assert.ok(subNode && subNode.type === 'folder', 'subdir should exist');
62+
const bNode = subNode!.children!.find(n => n.name === 'b.txt');
63+
assert.ok(bNode && bNode.type === 'file', 'b.txt should exist in subdir');
64+
});
1465
});
15-
});
66+
});

src/webview-ui-dist/assets/index-CQH7BAVW.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/webview-ui-dist/assets/index-FgDeyH1r.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)