Skip to content

Commit 88c1c8d

Browse files
authored
[VSC-1576] Add .gitignore when creating projects (#1578)
* feat: Add .gitignore when creating projects * fix: Add ignore for show examples method * Refactor implementation Added the code inside copyFromSrcProject * Fix: Delete leftovers
1 parent 6481af5 commit 88c1c8d

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

src/newProject/newProjectPanel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Logger } from "../logger/logger";
1717
import { OutputChannel } from "../logger/outputChannel";
1818
import { INewProjectArgs } from "./newProjectInit";
1919
import { IComponent } from "../espIdf/idfComponent/IdfComponent";
20-
import { copy, ensureDir, readFile, writeJSON } from "fs-extra";
20+
import { copy, ensureDir, readFile, writeFile, writeJSON } from "fs-extra";
2121
import * as utils from "../utils";
2222
import { IExample } from "../examples/Example";
2323
import { setCurrentSettingsInTemplate } from "./utils";

src/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ export async function createVscodeFolder(curWorkspaceFsPath: vscode.Uri) {
261261
await setCCppPropertiesJsonCompilerPath(curWorkspaceFsPath);
262262
}
263263

264+
export async function createGitignoreFile(destinationDir: vscode.Uri) {
265+
const gitignoreSrcPath = path.join(templateDir, ".gitignore");
266+
const gitignoreDestPath = path.join(destinationDir.fsPath, ".gitignore");
267+
const gitignoreExists = await pathExists(gitignoreSrcPath);
268+
if (gitignoreExists) {
269+
await copy(gitignoreSrcPath, gitignoreDestPath);
270+
}
271+
}
272+
264273
export async function setCCppPropertiesJsonCompilerPath(
265274
curWorkspaceFsPath: vscode.Uri
266275
) {
@@ -405,6 +414,7 @@ export async function copyFromSrcProject(
405414
await copy(srcDirPath, destinationDir.fsPath);
406415
await createVscodeFolder(destinationDir);
407416
await createDevContainer(destinationDir.fsPath);
417+
await createGitignoreFile(destinationDir);
408418
}
409419

410420
export function getVariableFromCMakeLists(workspacePath: string, key: string) {

templates/.gitignore

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# macOS
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
6+
# Directory metadata
7+
.directory
8+
9+
# Temporary files
10+
*~
11+
*.swp
12+
*.swo
13+
*.bak
14+
*.tmp
15+
16+
# Log files
17+
*.log
18+
19+
# Build artifacts and directories
20+
**/build/
21+
build/
22+
*.o
23+
*.a
24+
*.out
25+
*.exe # For any host-side utilities compiled on Windows
26+
27+
# ESP-IDF specific build outputs
28+
*.bin
29+
*.elf
30+
*.map
31+
flasher_args.json # Generated in build directory
32+
sdkconfig.old
33+
sdkconfig
34+
35+
# ESP-IDF dependencies
36+
# For older versions or manual component management
37+
/components/.idf/
38+
**/components/.idf/
39+
# For modern ESP-IDF component manager
40+
managed_components/
41+
# If ESP-IDF tools are installed/referenced locally to the project
42+
.espressif/
43+
44+
# CMake generated files
45+
CMakeCache.txt
46+
CMakeFiles/
47+
cmake_install.cmake
48+
install_manifest.txt
49+
CTestTestfile.cmake
50+
51+
# Python environment files
52+
*.pyc
53+
*.pyo
54+
*.pyd
55+
__pycache__/
56+
*.egg-info/
57+
dist/
58+
59+
# Virtual environment folders
60+
venv/
61+
.venv/
62+
env/
63+
64+
# Language Servers
65+
.clangd/
66+
.ccls-cache/
67+
compile_commands.json
68+
69+
# Windows specific
70+
Thumbs.db
71+
ehthumbs.db
72+
Desktop.ini
73+
74+
# User-specific configuration files
75+
*.user
76+
*.workspace # General workspace files, can be from various tools
77+
*.suo # Visual Studio Solution User Options
78+
*.sln.docstates # Visual Studio

0 commit comments

Comments
 (0)