Skip to content

Commit 8163310

Browse files
committed
add vscode conf generation
1 parent b899bec commit 8163310

4 files changed

Lines changed: 35 additions & 18 deletions

File tree

example/.github/workflows/ci.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ jobs:
2020
with:
2121
python-version: "3.10"
2222

23-
- name: Set shfmt version environment variable
24-
run: echo "SHFMT_VERSION=v3.7.0" >> $GITHUB_ENV
25-
2623
- name: Cache pip dependencies
2724
uses: actions/cache@v3
2825
with:
@@ -35,18 +32,18 @@ jobs:
3532
uses: actions/cache@v3
3633
with:
3734
path: /usr/local/bin/shfmt
38-
key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
35+
# key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
36+
key: ${{ runner.os }}-shfmt-
3937
restore-keys: |
40-
${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
4138
${{ runner.os }}-shfmt-
4239
4340
- name: Cache Pre-Commit environments
4441
uses: actions/cache@v3
4542
with:
4643
path: ~/.cache/pre-commit
47-
key: ${{ runner.os }}-pc-${{ hashFiles('.pre-commit-config.yaml') }}
44+
# key: ${{ runner.os }}-pc-${{ hashFiles('.pre-commit-config.yaml') }}
45+
key: ${{ runner.os }}-pc-
4846
restore-keys: |
49-
${{ runner.os }}-pc-${{ hashFiles('.pre-commit-config.yaml') }}
5047
${{ runner.os }}-pc-
5148
5249
- name: Install dependencies
@@ -56,7 +53,7 @@ jobs:
5653
5754
- name: Install shfmt
5855
run: |
59-
SHFMT_VERSION=${{ env.SHFMT_VERSION }}
56+
SHFMT_VERSION="v3.7.0"
6057
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
6158
if [[ ! -f /usr/local/bin/shfmt ]]; then
6259
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"

example/.vscode/extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"ms-python.python",
4+
"ms-python.vscode-pylance",
5+
"ms-python.isort",
6+
"ms-python.black-formatter",
7+
"ms-python.flake8"
8+
]
9+
}

example/.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"[python]": {
3+
"editor.formatOnType": true,
4+
"editor.formatOnSave": true,
5+
"editor.defaultFormatter": "ms-python.black-formatter"
6+
},
7+
"flake8.args": ["--config=.cpa/flake8.cfg"],
8+
"files.insertFinalNewline": true
9+
}

src/python.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ pub fn setup_preset(mut preset: String, name: String, create: bool) {
6565
prefix = format!("./{}", name)
6666
}
6767

68+
// Create needed dirs
6869
let _ = fs::create_dir_all(format!("{}/.cpa", prefix));
70+
let _ = fs::create_dir_all(format!("{}/.vscode", prefix));
71+
let _ = fs::create_dir_all(format!("{}/.github/workflows", prefix));
6972

7073
// Render Github Actions CI
71-
let _ = fs::create_dir_all(format!("{}/.github/workflows", prefix));
7274
File::create(format!("{}/.github/workflows/ci.yaml", prefix))
7375
.and_then(|mut file| file.write_all(GHWorkflowCI {}.render().expect("Failed to render ci.yaml").as_bytes()))
74-
.expect("Failed to create or write to ci.yaml");
76+
.expect("Failed to write to ci.yaml");
7577

7678
// Render .vscode/settings.json
7779
File::create(format!("{}/.vscode/settings.json", prefix))
@@ -83,7 +85,7 @@ pub fn setup_preset(mut preset: String, name: String, create: bool) {
8385
.as_bytes(),
8486
)
8587
})
86-
.expect("Failed to create or write to .vscode/settings.json");
88+
.expect("Failed to write to .vscode/settings.json");
8789

8890
// Render .vscode/extensions.json
8991
File::create(format!("{}/.vscode/extensions.json", prefix))
@@ -95,22 +97,22 @@ pub fn setup_preset(mut preset: String, name: String, create: bool) {
9597
.as_bytes(),
9698
)
9799
})
98-
.expect("Failed to create or write to .vscode/extensions.json");
100+
.expect("Failed to write to .vscode/extensions.json");
99101

100102
// Render .gitignore
101103
File::create(format!("{}/.gitignore", prefix))
102104
.and_then(|mut file| file.write_all(GitIgnore {}.render().expect("Failed to render .gitignore").as_bytes()))
103-
.expect("Failed to create or write to .gitignore");
105+
.expect("Failed to write to .gitignore");
104106

105107
// Render Makefile
106108
File::create(format!("{}/Makefile", prefix))
107109
.and_then(|mut file| file.write_all(Makefile {}.render().expect("Failed to render Makefile").as_bytes()))
108-
.expect("Failed to create or write to Makefile");
110+
.expect("Failed to write to Makefile");
109111

110112
// Render Dockerfile
111113
File::create(format!("{}/Dockerfile", prefix))
112114
.and_then(|mut file| file.write_all(Dockerfile {}.render().expect("Failed to render Dockerfile").as_bytes()))
113-
.expect("Failed to create or write to Dockerfile");
115+
.expect("Failed to write to Dockerfile");
114116

115117
// Render main.py
116118
File::create(format!("{}/main.py", prefix))
@@ -127,17 +129,17 @@ pub fn setup_preset(mut preset: String, name: String, create: bool) {
127129
.as_bytes(),
128130
)
129131
})
130-
.expect("Failed to create or write to .pre-commit-config.yaml");
132+
.expect("Failed to write to .pre-commit-config.yaml");
131133

132134
// Render Flake8 conf
133135
File::create(format!("{}/.cpa/flake8.cfg", prefix))
134136
.and_then(|mut file| file.write_all(Flake8 {}.render().expect("Failed to render flake8.cfg").as_bytes()))
135-
.expect("Failed to create or write to flake8.cfg");
137+
.expect("Failed to write to flake8.cfg");
136138

137139
// Render Prettier conf
138140
File::create(format!("{}/.cpa/prettier.json", prefix))
139141
.and_then(|mut file| file.write_all(Prettier {}.render().expect("Failed to render prettier.json").as_bytes()))
140-
.expect("Failed to create or write to prettier.json");
142+
.expect("Failed to write to prettier.json");
141143

142144
// Render Poetry conf
143145
let re = Regex::new(r"python(3\.\d+|4\.\d+)").unwrap();

0 commit comments

Comments
 (0)