Skip to content

Commit 8346942

Browse files
authored
Feature/improve azure function (#4)
Installation scripts improved. Fix issue about the Azure Function Application. Complete missing documentation.
1 parent 8f985b6 commit 8346942

File tree

11 files changed

+44
-209
lines changed

11 files changed

+44
-209
lines changed

.devcontainer/install/03-generate-file-vscode-extensions-json.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ echo -e "${BLUE}#############################################################${E
1313
mkdir -p $SOURCE_PATH
1414
mkdir -p "$WORKSPACE_PATH/.vscode"
1515

16+
echo -e "\n${GREEN}> Generate file '.vscode/extensions.json'.${ENDCOLOR}\n"
17+
1618
if [ -f "$WORKSPACE_PATH/.vscode/extensions.json" ]; then
17-
echo -e "\n${YELLOW}Nothing to do because file is already existing.\n${ENDCOLOR}"
19+
echo -e "${YELLOW}Nothing to do because file is already existing.\n${ENDCOLOR}"
1820
else
1921

20-
echo -e "\n${GREEN}> Generate file '.vscode/extensions.json'.${ENDCOLOR}\n"
21-
2222
# Create initial file.
2323
merged_content=$(echo '{"recommendations": []}' | jq '.')
2424

@@ -30,14 +30,6 @@ else
3030
merged_content=$(echo "$merged_content" | jq ".recommendations += $content")
3131
fi
3232

33-
# Add extensions specifically for the default formatter.
34-
defaultFormatter=$(jq -r '.customizations.vscode.settings."editor.defaultFormatter"' $WORKSPACE_PATH/.devcontainer/devcontainer.json);
35-
36-
if [ "$defaultFormatter" == "ms-python.autopep8" ] || [ "$defaultFormatter" == "ms-python.black-formatter" ] || [ "$defaultFormatter" == "eeyore.yapf" ]; then
37-
content="[\"$defaultFormatter\"]"
38-
merged_content=$(echo "$merged_content" | jq ".recommendations += $content")
39-
fi
40-
4133
# Add other extensions.
4234
if [ -f "$WORKSPACE_PATH/.devcontainer/templates/default/config/extensions.json" ]; then
4335
content=$(cat $WORKSPACE_PATH/.devcontainer/templates/default/config/extensions.json)
@@ -51,3 +43,16 @@ else
5143
echo -e "Done.\n"
5244

5345
fi
46+
47+
# Add extensions specifically for the default formatter in 'devcontainer.json' file.
48+
defaultFormatter=$(jq -r '.customizations.vscode.settings."editor.defaultFormatter"' $WORKSPACE_PATH/.devcontainer/devcontainer.json);
49+
50+
if [ "$defaultFormatter" == "ms-python.autopep8" ] || [ "$defaultFormatter" == "ms-python.black-formatter" ] || [ "$defaultFormatter" == "eeyore.yapf" ]; then
51+
exist=`cat $WORKSPACE_PATH/.devcontainer/devcontainer.json | jq ".customizations.vscode.extensions | contains([\"$defaultFormatter\"])"`
52+
if [ $exist == 'false' ]; then
53+
echo -e "${GREEN}> Update file '.devcontainer/devcontainer.json'.${ENDCOLOR}\n"
54+
cat $WORKSPACE_PATH/.devcontainer/devcontainer.json | jq ".customizations.vscode.extensions += [\"$defaultFormatter\"]" > /tmp/devcontainer.json
55+
mv /tmp/devcontainer.json $WORKSPACE_PATH/.devcontainer/devcontainer.json
56+
echo -e "Done.\n"
57+
fi
58+
fi

.devcontainer/install/27-install-requirements-app-python.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/bin/bash
22

3-
# ignored: azure-function-python
43
# ignored: poetry-dependency-manager
54

65
. "$WORKSPACE_PATH/tools/color.sh"
76

87
echo -e "\n${BLUE}#############################################################${ENDCOLOR}"
98
echo -e "${BLUE}##### #####${ENDCOLOR}"
10-
echo -e "${BLUE}##### Install requirements.txt (app-python version) #####${ENDCOLOR}"
9+
echo -e "${BLUE}##### Install requirements.txt #####${ENDCOLOR}"
1110
echo -e "${BLUE}##### #####${ENDCOLOR}"
1211
echo -e "${BLUE}#############################################################${ENDCOLOR}"
1312

.devcontainer/install/27-install-requirements-azure-function-python.sh

Lines changed: 0 additions & 159 deletions
This file was deleted.

.devcontainer/install/85-extension-installation.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if [ "$defaultFormatter" == "ms-python.autopep8" ] || [ "$defaultFormatter" == "
4545

4646
quantity=(`code --list-extensions --show-versions 2>/dev/null | grep "$defaultFormatter" | wc -l`)
4747

48-
if [ "$quantity" == "0" ]; then
48+
if [ "$quantity" == "-1" ]; then
4949

5050
echo -e "\n${RED}The extension has not been automatically installed.${ENDCOLOR}"
5151
echo -e "\n${BLUE}To install the extension manually, you can in the sidebar on the left, in the 'extension' menu (ctrl+shift+x) search for the extension from its extension id which is:${ENDCOLOR} '$defaultFormatter'\n"
@@ -67,12 +67,12 @@ if [ "$defaultFormatter" == "ms-python.autopep8" ] || [ "$defaultFormatter" == "
6767

6868
quantity=(`code --list-extensions --show-versions 2>/dev/null | grep "$defaultFormatter_id" | wc -l`)
6969

70-
if [ "$quantity" == "0" ]; then
70+
if [ "$quantity" == "-1" ]; then
7171
echo -e "${RED}The extension seems not to be installed. Please check again!${ENDCOLOR}"
7272
echo -e "${RED}Failure to adhere to a common code formatting tool in a Python project can lead to style inconsistencies, merge conflicts, and reduced team productivity.${ENDCOLOR}\n"
7373
echo -e "${RED}Despite this anomaly, the container installation processus will continue.${ENDCOLOR}"
74-
else
75-
echo -e "Done. Extension is installed."
74+
# else
75+
# echo -e "Done. Extension is installed."
7676
fi
7777

7878
fi

.devcontainer/install/86-fix-mypy-extension.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ ORIGINAL_FILE_1="$HOME/.vscode-server/extensions/ms-python.mypy-type-checker-202
1414
ORIGINAL_FILE_2="$HOME/.vscode-server/extensions/ms-python.mypy-type-checker-2023.6.0/bundled/tool/lsp_server.py"
1515

1616
if [ -f "$ORIGINAL_FILE_1" ]; then
17-
$ORIGINAL_FILE=$ORIGINAL_FILE_1
17+
ORIGINAL_FILE=$ORIGINAL_FILE_1
1818
fi
1919

2020
if [ -f "$ORIGINAL_FILE_2" ]; then
21-
$ORIGINAL_FILE=$ORIGINAL_FILE_2
21+
ORIGINAL_FILE=$ORIGINAL_FILE_2
2222
fi
2323

2424
if [ -f "$ORIGINAL_FILE" ]; then

.devcontainer/install/__65-generate-file-vscode-launch-json.sh__

Lines changed: 0 additions & 23 deletions
This file was deleted.

.devcontainer/templates/app-python/config/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"name": "Execute module '{project_name}'",
4-
"type": "python",
4+
"type": "debugpy",
55
"request": "launch",
66
"module": "{project_name}"
77
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
[
2-
"ms-azuretools.vscode-azurefunctions",
3-
"ms-python.python"
4-
]
1+
[]

.devcontainer/templates/azure-function-python/config/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"name": "Attach to Python Functions: {project_name}",
4-
"type": "python",
4+
"type": "debugpy",
55
"request": "attach",
66
"port": 9091,
77
"preLaunchTask": "Azure Function - Start: {project_name}",

.devcontainer/templates/default/config/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"name": "Python: File",
4-
"type": "python",
4+
"type": "debugpy",
55
"request": "launch",
66
"program": "${file}",
77
"console": "integratedTerminal",

0 commit comments

Comments
 (0)