Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

Предыдущая версия справа и слева Предыдущая версия
Следующая версия
Предыдущая версия
development:vscode [2024/11/18 13:52] – [Отладка / Расширения] mirocowdevelopment:vscode [2026/01/31 05:33] (текущий) 192.168.1.1
Строка 21: Строка 21:
   * [[https://www.npmjs.com/package/vscode-languageclient?activeTab=code|vscode-languageclient]], [[https://www.npmjs.com/package/vscode-languageserver?activeTab=code|vscode-languageserver]]   * [[https://www.npmjs.com/package/vscode-languageclient?activeTab=code|vscode-languageclient]], [[https://www.npmjs.com/package/vscode-languageserver?activeTab=code|vscode-languageserver]]
   * https://www.sonarsource.com/knowledge/languages/php/   * https://www.sonarsource.com/knowledge/languages/php/
 +  * [[https://github.com/microsoft/vscode-languageserver-node.git|VSCode Language Server - Node]]
  
 ===== Отладка / Расширения ===== ===== Отладка / Расширения =====
  
-  * https://github.com/Microsoft/vscode-languageserver-node +==== PHP ==== 
-  https://github.com/SonarSource/sonarlint-vscode + 
-  * [[https://code.visualstudio.com/api/language-extensions/language-server-extension-guide|Language Server Extension Guide]+<code json> 
-  [[https://learn.microsoft.com/ru-ru/visualstudio/extensibility/anatomy-of-a-vsix-package?view=vs-2022|Анатомия пакета VSIX]] +
-  [[https://video2.skills-academy.com/ru-ru/visualstudio/extensibility/getting-started-with-the-vsix-project-template?view=vs-2022|Начало работы с шаблоном проекта VSIX]] +    // Use IntelliSense to learn about possible attributes. 
-  * https://github.com/spagettikod/vsix +    // Hover to view descriptions of existing attributes. 
-  * [[https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#headerPart|Language Server Protocol Specification 3.17]]+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 
 +    "version": "0.2.0", 
 +    "configurations": [ 
 + 
 +        { 
 +            "name""Listen for Xdebug", 
 +            "type": "php", 
 +            "request": "launch", 
 +            "port": 9000, 
 +            "pathMappings":
 +                "/var/www/api": "${workspaceFolder}" 
 +            } 
 +        }, 
 +        { 
 +            "name": "Launch currently open script", 
 +            "type": "php", 
 +            "request": "launch", 
 +            "program": "${file}", 
 +            "cwd": "${fileDirname}", 
 +            "port": 0, 
 +            "runtimeArgs":
 +                "-dxdebug.start_with_request=yes" 
 +            ], 
 +            "env":
 +                "XDEBUG_MODE": "debug,develop", 
 +                "XDEBUG_CONFIG": "client_port=${port}" 
 +            } 
 +        }, 
 +        { 
 +            "name": "Launch Built-in web server", 
 +            "type": "php", 
 +            "request": "launch", 
 +            "runtimeArgs":
 +                "-dxdebug.mode=debug", 
 +                "-dxdebug.start_with_request=yes", 
 +                "-S", 
 +                "localhost:0" 
 +            ], 
 +            "program": "", 
 +            "cwd": "${workspaceRoot}", 
 +            "port": 9003, 
 +            "serverReadyAction":
 +                "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", 
 +                "uriFormat": "http://localhost:%s", 
 +                "action": "openExternally" 
 +            } 
 +        } 
 +    ] 
 +
 +</code> 
 + 
 +==== Chrome Extension ==== 
 + 
 +<code json> 
 +</code> 
 + 
 +==== Electron ==== 
 + 
 +<code json> 
 +
 +    "version": "0.2.0", 
 +    "configurations":
 +         
 +        { 
 +            "name": "Attach electron: Renderer Process", 
 +            "type": "chrome", 
 +            "request": "attach", 
 +            "port": 9223, 
 +            "webRoot": "${workspaceFolder}/packages/insomnia", 
 +            "timeout": 30000, 
 +            "presentation":
 +                "hidden": false, 
 +                "group": "Insomnia", 
 +                "order":
 +            }, 
 +        }, 
 + 
 +        { 
 +            "name": "Launch electron: main", 
 +            "type": "node", 
 +            "request": "launch", 
 +            "protocol": "inspector", 
 +            "sourceMaps": true, 
 +            "presentation":
 +                "hidden": false, 
 +                "group": "Insomnia", 
 +                "order":
 +            }, 
 +            "cwd": "${workspaceFolder}/packages/insomnia", 
 +            "runtimeExecutable": "${workspaceFolder}/packages/insomnia/node_modules/.bin/electron", 
 +            "runtimeArgs": ["--remote-debugging-port=9222", "."], 
 +            "outputCapture": "std", 
 +            "windows":
 +                "type": "node", 
 +                "request": "launch", 
 +                "name": "Electron: main", 
 +                "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd" 
 +            }, 
 +            "env":
 +                "NODE_ENV": "development", 
 +                "ELECTRON_IS_DEV": "1" 
 +            } 
 +        }, 
 + 
 +        { 
 +            "name": "Launch electron: renderer", 
 +            "type": "pwa-chrome", 
 +            "request": "attach", 
 +            "presentation":
 +                "hidden": false, 
 +                "group": "Insomnia", 
 +                "order":
 +            }, 
 +            "port": 9222, 
 +            "webRoot": "${workspaceFolder}/packages/insomnia/src", 
 +            "timeout": 60000 
 +        }, 
 + 
 +    ]
 +    "inputs":
 +        { 
 +            "id": "insoCommandArgs", 
 +            "description": "Add an additional argument to inso", 
 +            "type": "promptString" 
 +        }, 
 +        { 
 +            "id": "insoCommand", 
 +            "description": "Pick an inso command to run", 
 +            "type": "pickString", 
 +            "options":
 +                { 
 +                    "value": "run test" 
 +                }, 
 +                { 
 +                    "value": "lint spec" 
 +                }, 
 +                { 
 +                    "value": "export spec" 
 +                }, 
 +                { 
 +                    "value": "script" 
 +                }, 
 +                { 
 +                    "value": "help" 
 +                } 
 +            
 +        } 
 +    ], 
 + 
 +    "compounds": [ 
 +    { 
 +        "name": "Launch Insomnia", 
 +        "presentation":
 +        "hidden": false, 
 +        "group": "Insomnia", 
 +        "order": 10 
 +        }, 
 +        "stopAll": true, 
 +        "preLaunchTask": "Insomnia: Compile (Watch)", 
 +        "configurations": [ 
 +            "Launch electronmain", 
 +            "Launch electron: renderer" 
 +        ] 
 +    } 
 +    ] 
 +
 +</code> 
 + 
 +==== Golang ==== 
 + 
 +<code Dockerfile> 
 +# Base stage for shared environment 
 +FROM golang:1.24-alpine AS base 
 +WORKDIR /app 
 +RUN apk add --no-cache git 
 + 
 +# Builder stage for production 
 +FROM base AS builder 
 +COPY go.mod go.sum ./ 
 +RUN go mod download 
 +COPY . . 
 +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /app/proxy . 
 + 
 +# Debug builder stage for delve and debug binary 
 +FROM base AS debug-builder 
 +RUN go install github.com/go-delve/delve/cmd/dlv@latest 
 +COPY go.mod go.sum ./ 
 +RUN go mod download 
 +COPY . . 
 +# Build with optimizations disabled for better debugging 
 +RUN CGO_ENABLED=0 GOOS=linux go build -gcflags="all=--l" -o /app/proxy . 
 + 
 +# Debug stage 
 +FROM alpine:latest AS debug 
 +RUN apk add --no-cache ca-certificates libc6-compat 
 +WORKDIR /app 
 +COPY --from=debug-builder /go/bin/dlv /usr/local/bin/dlv 
 +COPY --from=debug-builder /app/proxy /app/proxy 
 +EXPOSE 8080 40000 
 +# Run delve in headless mode 
 +CMD ["/usr/local/bin/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/app/proxy"
 +</code> 
 + 
 +<code yaml> 
 +services: 
 + 
 +  proxy-debug: 
 +    build: 
 +      context: . 
 +      target: debug 
 +    environment: 
 +      - GEMINI_API_KEY=${GEMINI_API_KEY} 
 +      - LISTEN_ADDR=:8080 
 +    ports: 
 +      - "${PORT:-8080}:8080" 
 +      - "40000:40000" 
 +    security_opt: 
 +      - "seccomp:unconfined" # Required for Delve/ptrace 
 +    cap_add: 
 +      SYS_PTRACE 
 +    restart: "no" 
 +</code> 
 + 
 +<code bash> 
 +$ docker compose up proxy-debug 
 +</code> 
 + 
 +<code json> 
 +
 +    "version": "0.2.0", 
 +    "configurations":
 +        { 
 +            "name": "Connect to Docker Debug", 
 +            "type": "go", 
 +            "request": "attach", 
 +            "mode": "remote", 
 +            "port": 40000, 
 +            "host": "127.0.0.1", 
 +            "showLog": true, 
 +            "dlvFlags": ["--check-go-version=false"], 
 +            "substitutePath":
 +                { 
 +                    "from": "${workspaceFolder}", 
 +                    "to": "/app" 
 +                } 
 +            ] 
 +        } 
 +    ] 
 +
 +</code> 
 + 
 +==== Python ==== 
 + 
 +<code json> 
 +
 +    "version": "0.2.0", 
 +    "configurations":
 +        { 
 +            "name": "Python: Remote Attach (Docker)", 
 +            "type": "python", 
 +            "request": "attach", 
 +            "connect":
 +                "host": "localhost", 
 +                "port": 5678 
 +            }, 
 +            "pathMappings":
 +                { 
 +                    "localRoot": "${workspaceFolder}/app", 
 +                    "remoteRoot": "/app" 
 +                } 
 +            ], 
 +            "justMyCode": true, 
 +            "django": false 
 +        }, 
 +        { 
 +            "name": "Python: FastAPI (Local)", 
 +            "type": "python", 
 +            "request": "launch", 
 +            "module": "uvicorn", 
 +            "args":
 +                "app.main:app", 
 +                "--reload", 
 +                "--host", 
 +                "0.0.0.0", 
 +                "--port", 
 +                "5000" 
 +            ]
 +            "jinja": true, 
 +            "justMyCode": true 
 +        } 
 +    ] 
 +
 +</code>