Просмотр исходного кода

Added devcontainer support for development ease

Tim Laing 2 лет назад
Родитель
Сommit
4a9ff2b8cb
3 измененных файлов с 86 добавлено и 19 удалено
  1. 75 0
      .devcontainer/devcontainer.json
  2. 6 2
      .vscode/settings.json
  3. 5 17
      .vscode/tasks.json

+ 75 - 0
.devcontainer/devcontainer.json

@@ -0,0 +1,75 @@
+{
+	"name": "Tuya Local Dev",
+	"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
+	"postCreateCommand": "pip3 install --user -r requirements.txt",
+	"containerEnv": {
+		"DEVCONTAINER": "1"
+	},
+	"appPort": [
+		"8123:8123"
+	],
+	"forwardPorts": [
+		8123
+	],
+	"portsAttributes": {
+		"8123": {
+			"label": "Home Assistant"
+		},
+		"0-8122": {
+			"label": "Auto-Forwarded - Other",
+			"onAutoForward": "ignore"
+		},
+		"8124-999999": {
+			"label": "Auto-Forwarded - Other",
+			"onAutoForward": "ignore"
+		}
+	},
+	"customizations": {
+		"vscode": {
+			"extensions": [
+				"ms-python.vscode-pylance",
+				"visualstudioexptteam.vscodeintellicode",
+				"redhat.vscode-yaml",
+				"esbenp.prettier-vscode",
+				"GitHub.vscode-pull-request-github",
+				"ms-python.pylint",
+				"ms-python.black-formatter",
+				"ms-python.isort",
+				"ms-python.python",
+				"ryanluker.vscode-coverage-gutters"
+			],
+			"settings": {
+				"python.linting.enabled": true,
+				"python.linting.pylintEnabled": true,
+				"python.formatting.provider": "black",
+				"python.testing.pytestArgs": [
+					"--no-cov"
+				],
+				"editor.formatOnPaste": false,
+				"editor.formatOnSave": true,
+				"editor.formatOnType": true,
+				"files.eol": "\n",
+				"editor.tabSize": 4,
+				"files.trimTrailingWhitespace": true,
+				"terminal.integrated.profiles.linux": {
+					"zsh": {
+						"path": "/usr/bin/zsh"
+					}
+				},
+				"terminal.integrated.defaultProfile.linux": "zsh",
+				"yaml.customTags": [
+					"!input scalar",
+					"!secret scalar",
+					"!include_dir_named scalar",
+					"!include_dir_list scalar",
+					"!include_dir_merge_list scalar",
+					"!include_dir_merge_named scalar"
+				]
+			}
+		}
+	},
+	"remoteUser": "vscode",
+	"features": {
+		"rust": "latest"
+	}
+}

+ 6 - 2
.vscode/settings.json

@@ -6,5 +6,9 @@
   "files.trimTrailingWhitespace": true,
   "python.linting.pylintEnabled": true,
   "python.linting.enabled": true,
-  "python.formatting.provider": "black"
-}
+  "python.formatting.provider": "black",
+  "black-formatter.importStrategy": "fromEnvironment",
+  "python.testing.pytestEnabled": true,
+  "pylint.importStrategy": "fromEnvironment",
+  "python.linting.lintOnSave": true,
+}

+ 5 - 17
.vscode/tasks.json

@@ -4,31 +4,19 @@
     {
       "label": "Install requirements",
       "type": "shell",
-      "command": "pip3 install -r requirements-first.txt;pip3 install -r requirements-dev.txt",
+      "command": "pip3 install -r requirements.txt;pip3 install -r requirements-dev.txt",
       "problemMatcher": []
     },
     {
       "label": "Run Home Assistant on port 8123",
       "type": "shell",
-      "command": "pkill hass;container start",
-      "problemMatcher": []
-    },
-    {
-      "label": "Run Home Assistant configuration against /config",
-      "type": "shell",
-      "command": "container check",
+      "command": "python -m homeassistant",
       "problemMatcher": []
     },
     {
       "label": "Upgrade Home Assistant to latest dev",
       "type": "shell",
-      "command": "container install",
-      "problemMatcher": []
-    },
-    {
-      "label": "Install a specific version of Home Assistant",
-      "type": "shell",
-      "command": "container set-version",
+      "command": "pip install -U home-assistant",
       "problemMatcher": []
     },
     {
@@ -40,8 +28,8 @@
     {
       "label": "Reformat code",
       "type": "shell",
-      "command": "isort --recursive . &&  black .",
+      "command": "isort . &&  black .",
       "problemMatcher": []
     }
   ]
-}
+}