Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dennykorsukewitz committed Feb 5, 2024
1 parent e6a24fd commit 9126404
Show file tree
Hide file tree
Showing 17 changed files with 236 additions and 140 deletions.
45 changes: 25 additions & 20 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
{
"env": {
"browser": false,
"commonjs": true,
"es6": true,
"node": true,
"mocha": true
},
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"constructor-super": "warn",
"valid-typeof": "warn"
}
}
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "import",
"format": [ "camelCase", "PascalCase" ]
}
],
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": [
"out",
"dist",
"**/*.d.ts"
]
}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
.env
coverage
node_modules
.vscode-test/**
.vscode-test*
out/
dist/
**/*.map
**/*test.js
**/*test.js.map
package-lock.json
.vscode/settings.json
*.vsix
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// for the documentation about the extensions.json format
{
"recommendations": [
"dbaeumer.vscode-eslint"
"dbaeumer.vscode-eslint",
"ms-vscode.extension-test-runner"
]
}
34 changes: 28 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// A launch configuration that launches the extension inside a new window
// 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
Expand All @@ -11,16 +11,38 @@
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: compile"
},
{
"name": "Run Extension Tests",
"name": "Run Web Extension",
"type": "extensionHost",
"debugWebWorkerHost": true,
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/test/suite/index"
]
"--extensionDevelopmentKind=web"
],
"outFiles": [
"${workspaceFolder}/out/web/**/*.js"
],
"preLaunchTask": "npm: compile-web"
},
{
"name": "Run Tests",
"type": "node-terminal",
"request": "launch",
"command": "npm run test",
},
{
"name": "Debug Current Test File",
"type": "node-terminal",
"request": "launch",
"command": "npm run test -- ${fileBasenameNoExtension}",
"cwd": "${fileDirname}"
}
]
}
}
27 changes: 15 additions & 12 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
.vscode/**
.vscode-test/**
test/**
.gitignore
.yarnrc
vsc-extension-quickstart.md
**/jsconfig.json
**/*.map
**/.eslintrc.json

.env
.github
.vscode
.vscode-test*
coverage
node_modules
out/
src/
dist/test
.gitignore
.eslintrc.json
**/*test.js
**/*test.js.map
tsconfig.json
package-lock.json
*.vsix
TODO.md
snippets/_Test_/**
*.ts
TODO.md
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to the "AddFolderToWorkspace" extension will be documented in this file.

## [2.0.0]

### Refactoring

- Changed source language to TypeScript.
- Added esbuild to get Browser Editor support.
- Refactored code.
- Added UnitTests workflow.
-
## [1.2.1]

### Maintenance
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

| Status |
| ------ |
| [![GitHub commits since tagged version](https://img.shields.io/github/commits-since/dennykorsukewitz/VSCode-AddFolderToWorkspace/1.2.1/dev)](https://github.com/dennykorsukewitz/VSCode-AddFolderToWorkspace/compare/1.2.1...dev) ![GitHub Workflow Lint](https://github.com/dennykorsukewitz/VSCode-AddFolderToWorkspace/actions/workflows/lint.yml/badge.svg?branch=dev&style=flat&label=Lint) ![GitHub Workflow Pages](https://github.com/dennykorsukewitz/VSCode-AddFolderToWorkspace/actions/workflows/pages.yml/badge.svg?branch=dev&style=flat&label=GitHub%20Pages) |
| [![GitHub commits since tagged version](https://img.shields.io/github/commits-since/dennykorsukewitz/VSCode-AddFolderToWorkspace/2.0.0/dev)](https://github.com/dennykorsukewitz/VSCode-AddFolderToWorkspace/compare/2.0.0...dev) ![GitHub Workflow Lint](https://github.com/dennykorsukewitz/VSCode-AddFolderToWorkspace/actions/workflows/lint.yml/badge.svg?branch=dev&style=flat&label=Lint) ![GitHub Workflow Pages](https://github.com/dennykorsukewitz/VSCode-AddFolderToWorkspace/actions/workflows/pages.yml/badge.svg?branch=dev&style=flat&label=GitHub%20Pages) |

## Feature

Expand Down
14 changes: 6 additions & 8 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# [1.2.1]
# [2.0.0]

## Maintenance
## Refactoring

- Added additional check if vscode.workspace.workspaceFolders exists.
- Saves the new manually entered directory globally.

## Recursive Workspaces (only first level)

- Added new setting `addFolderToWorkspace.recursiveWorkspaces` to use recursive Workspaces (only first level).
- Changed source language to TypeScript.
- Added esbuild to get Browser Editor support.
- Refactored code.
- Added UnitTests workflow.
13 changes: 0 additions & 13 deletions jsconfig.json

This file was deleted.

48 changes: 28 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,41 @@
"Other"
],
"engines": {
"vscode": "^1.74.0"
"vscode": "^1.85.0"
},
"activationEvents": [
"onCommand:addFolderToWorkspace",
"onCommand:removeFolderFromWorkspace"
],
"main": "./src/extension",
"activationEvents": [],
"main": "./dist/extension.js",
"browser": "./dist/extension.js",
"scripts": {
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"test": "node ./test/runTest.js"
},
"devDependencies": {
"@types/mocha": "^10.0.1",
"@types/node": "16.x",
"@types/vscode": "^1.74.0",
"@vscode/test-electron": "^2.2.0",
"eslint": "^8.28.0",
"mocha": "^10.1.0",
"typescript": "^4.9.3"
"vscode:prepublish": "npm run esbuild-base -- --minify",
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node",
"esbuild": "npm run esbuild-base -- --sourcemap",
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch",
"watch": "tsc -watch -p ./",
"compile": "tsc -p ./",
"compile-web": "npm run esbuild-base -- --sourcemap",
"lint": "eslint src --ext ts",
"lint-fix": "eslint src --ext ts --fix",
"pretest": "rm -Rf .vscode-test && npm run compile && npm run lint",
"test": "node ./dist/test/runTest.js",
"open-in-browser": "npm run compile-web && npx @vscode/test-web --extensionDevelopmentPath=."
},
"dependencies": {
"glob": "^8.1.0",
"path": "^0.12.7"
},
"vsce": {
"dependencies": true
"devDependencies": {
"@types/glob": "^8.1.0",
"@types/mocha": "^10.0.1",
"@types/node": "^18.19.14",
"@types/vscode": "^1.85.0",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.20.0",
"esbuild": "^0.20.0",
"eslint": "^8.56.0",
"mocha": "^10.2.0",
"typescript": "^5.3.3",
"vscode-test": "^1.6.1"
},
"contributes": {
"commands": [
Expand Down
16 changes: 6 additions & 10 deletions src/extension.js → src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
const fs = require('fs');
import * as vscode from 'vscode';

/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
export function activate(context: vscode.ExtensionContext) {

// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
Expand All @@ -19,7 +18,7 @@ function activate(context) {
initRemoveFolderFromWorkspace(context);
}

function initAddFolderToWorkspace(context) {
function initAddFolderToWorkspace(context: vscode.ExtensionContext) {

const addFolderToWorkspaceId = 'addFolderToWorkspace';
context.subscriptions.push(vscode.commands.registerCommand(addFolderToWorkspaceId, async () => {
Expand All @@ -38,6 +37,8 @@ function initAddFolderToWorkspace(context) {
return;
}



// Add all stored workspaces / directories.
workspaceDirectories = config.workspaces || [];

Expand Down Expand Up @@ -197,9 +198,4 @@ function updateWorkspaceAndWait(start, deleteCount, workspaceFoldersToAdd) {
}

// This method is called when your extension is deactivated.
function deactivate() { }

module.exports = {
activate,
deactivate
}
export function deactivate() { }
23 changes: 23 additions & 0 deletions src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as path from 'path';

import { runTests } from '@vscode/test-electron';

async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');

// The path to the extension test script
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');

// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}

main();
Loading

0 comments on commit 9126404

Please sign in to comment.