Skip to content

Commit 9e24ea3

Browse files
authored
feat: Update default settings + add messages + misc (#1)
1 parent a9023e4 commit 9e24ea3

File tree

8 files changed

+49
-14
lines changed

8 files changed

+49
-14
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ node_modules
1212
!.yarn/releases
1313
!.yarn/sdks
1414
!.yarn/versions
15+
16+
# other
17+
.DS_Store

.vscode/launch.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"name": "Run Extension",
66
"type": "extensionHost",
77
"request": "launch",
8-
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
8+
"args": [
9+
"--disable-extensions",
10+
"--extensionDevelopmentPath=${workspaceFolder}"
11+
],
912
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
1013
"preLaunchTask": "${defaultBuildTask}"
1114
}

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,29 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/), and this
66

77
## [Unreleased]
88

9+
## [0.1.0] - 2024-02-26
10+
11+
### Added
12+
13+
- Error message when no tsconfig files found
14+
- Confirmation message after command
15+
- Shields in `README.md`
16+
17+
### Fixed
18+
19+
- Usage GIF quality
20+
- Banner centering in `README.md`
21+
22+
### Changed
23+
24+
- Default value for `swap-tsconfig.exclude` and `swap-tsconfig.include`
25+
926
## [0.0.1] - 2024-02-25
1027

1128
### Added
1229

1330
- Swap Tsconfig extension with command `swap-tsconfig` and settings `swap-tsconfig.exclude` and `swap-tsconfig.include`
1431

15-
[unreleased]: https://github.com/harrydowning/swap-tsconfig/compare/v0.0.1...HEAD
32+
[unreleased]: https://github.com/harrydowning/swap-tsconfig/compare/v0.1.0...HEAD
33+
[0.1.0]: https://github.com/harrydowning/swap-tsconfig/releases/tag/v0.0.1...v0.1.0
1634
[0.0.1]: https://github.com/harrydowning/swap-tsconfig/releases/tag/v0.0.1

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# ![Swap Tsconfig](https://raw.githubusercontent.com/harrydowning/swap-tsconfig/main/assets/banner.png)
1+
<h1 style="text-align: center;">
2+
<img src="https://raw.githubusercontent.com/harrydowning/swap-tsconfig/main/assets/banner.png" alt="Swap Tsconfig">
3+
</h1>
24

3-
<!-- ![GitHub License](https://img.shields.io/github/license/harrydowning/swap-tsconfig)
5+
![GitHub License](https://img.shields.io/github/license/harrydowning/swap-tsconfig)
46
![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/harrydowning.swap-tsconfig)
5-
![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/harrydowning.swap-tsconfig) -->
7+
![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/harrydowning.swap-tsconfig)
68

79
## Overview
810

assets/usage.gif

1.96 MB
Loading

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "swap-tsconfig",
33
"displayName": "Swap Tsconfig",
4-
"version": "0.0.1",
4+
"version": "0.1.0",
55
"description": "Command to swap between multiple Typescript configuration files",
66
"categories": [
77
"Other"
@@ -46,7 +46,7 @@
4646
"type": "string"
4747
},
4848
"default": [
49-
"node_modules/**"
49+
"**/node_modules/**"
5050
],
5151
"description": "Glob patterns used for ignoring tsconfig files"
5252
},
@@ -56,7 +56,7 @@
5656
"type": "string"
5757
},
5858
"default": [
59-
"**/tsconfig*.json"
59+
"**/*tsconfig*.json"
6060
],
6161
"description": "Glob patterns used for finding tsconfig files"
6262
}

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const swapTsconfig = commandWrapper(async () => {
3939
}
4040

4141
workspaceState.currentTsconfigFile = selectedTsconfigFile;
42+
vscode.window.showInformationMessage(`${selectedTsconfigFile} now active.`);
4243
});
4344

4445
export const activate = (context: vscode.ExtensionContext) => {

src/utils.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const commandWrapper = (command: () => Promise<void> | void) => {
1515
if (error instanceof ExtensionError) {
1616
vscode.window.showErrorMessage(error.message);
1717
} else if (error instanceof Error) {
18-
vscode.window.showErrorMessage("An error has occurred");
18+
vscode.window.showErrorMessage("An error has occurred.");
1919
console.error(error);
2020
}
2121
}
@@ -33,7 +33,7 @@ export const getWorkspaceFolder = async () => {
3333
const workspaceFolders = vscode.workspace.workspaceFolders;
3434

3535
if (!workspaceFolders) {
36-
throw new FatalExtensionError("Open a workspace to swap tsconfig");
36+
throw new FatalExtensionError("Open a workspace to swap tsconfig.");
3737
} else if (workspaceFolders.length === 1) {
3838
return workspaceFolders[0];
3939
} else {
@@ -44,11 +44,19 @@ export const getWorkspaceFolder = async () => {
4444

4545
export const getTsconfigFiles = (path: string) => {
4646
const getPatternPath = (pattern: string) => posix.join(path, pattern);
47-
const config = vscode.workspace.getConfiguration("swap-tsconfig");
48-
const include = config.include.map(getPatternPath);
49-
const exclude = config.exclude.map(getPatternPath);
47+
const settings = vscode.workspace.getConfiguration("swap-tsconfig");
48+
const include = settings.include.map(getPatternPath);
49+
const exclude = settings.exclude.map(getPatternPath);
5050

51-
return globSync(include, { ignore: exclude })
51+
const tsconfigFiles = globSync(include, { ignore: exclude })
5252
.map((tsconfigFile) => posix.relative(path, tsconfigFile))
5353
.sort((a, b) => a.length - b.length);
54+
55+
if (!tsconfigFiles.length) {
56+
throw new FatalExtensionError(
57+
"No tsconfig files found. Ensure the 'exclude' and 'include' settings for this extension are correctly configured.",
58+
);
59+
}
60+
61+
return tsconfigFiles;
5462
};

0 commit comments

Comments
 (0)