From a76c06b914463c0d9f608a12ae51245a61e1b2e6 Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Thu, 20 Aug 2020 22:22:01 +0000 Subject: [PATCH] Add devcontainer support Removed disabling extensions when debugging because it disables the remote extensions needed for debugging in a devcontainer. --- .devcontainer/Dockerfile | 55 +++++++++++++++++++++++++++++++++ .devcontainer/bin/init.sh | 40 ++++++++++++++++++++++++ .devcontainer/devcontainer.json | 21 +++++++++++++ .editorconfig | 31 +++++++++++++++++++ .vscode/extensions.json | 9 ++++-- .vscode/launch.json | 3 +- CONTRIBUTING.md | 38 +++++++++++++++++++++++ 7 files changed, 192 insertions(+), 5 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/bin/init.sh create mode 100644 .devcontainer/devcontainer.json create mode 100644 .editorconfig create mode 100644 CONTRIBUTING.md diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..f776989 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,55 @@ +# The MIT License (MIT) +# +# Copyright (c) Heath Stewart +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12 + +ARG DISPLAY=":1" +ARG USERNAME="node" + +ENV DISPLAY="${DISPLAY}" \ + EDITOR="nano" \ + LANG="en_US.UTF-8" \ + VISUAL="nano" + +RUN apt-get update \ + && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y --no-install-recommends \ + libasound2 \ + libgtk-3-0 \ + libnss3 \ + libsecret-1-dev \ + libxss1 \ + x11-utils \ + x11-xserver-utils \ + xvfb \ + # + # Clean up + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* + +COPY bin/init.sh /usr/local/share/ + +RUN chmod +x /usr/local/share/init.sh + +ENTRYPOINT ["/usr/local/share/init.sh"] +CMD ["sleep", "infinity"] diff --git a/.devcontainer/bin/init.sh b/.devcontainer/bin/init.sh new file mode 100644 index 0000000..0f9f358 --- /dev/null +++ b/.devcontainer/bin/init.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# The MIT License (MIT) +# +# Copyright (c) Heath Stewart +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +log() { + echo -e "[$(date) $@" +} + +# Start Xvfb in the background for testing. +if ! pidof Xvfb > /dev/null; then + log "Starting Xvfb" + /usr/bin/Xvfb ${DISPLAY:-:1} -ac >> /tmp/Xvfb.out 2>&1 & + disown -ar + log "Xvfb started" +else + log "Xvfb is already running" +fi + +log "Executing: $@" +"$@" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..9e1cf95 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,21 @@ +{ + "name": "VSCode - Extension Development", + "build": { + "dockerfile": "Dockerfile" + }, + "overrideCommand": false, + "runArgs": [ + "--init", + "--security-opt", "seccomp=unconfined" + ], + "remoteUser": "node", + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "extensions": [ + "dbaeumer.vscode-eslint", + "editorconfig.editorconfig", + "github.vscode-pull-request-github", + "ms-vscode.vscode-typescript-tslint-plugin" + ] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..142fe1c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,31 @@ +# The MIT License (MIT) +# +# Copyright (c) Heath Stewart +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +root = true + +[*] +indent_size = 4 +indent_style = space +insert_final_newline = true + +[*.json] +indent_size = 2 diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 161ad1e..ef386f9 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,8 @@ { "recommendations": [ - "ms-vscode.vscode-typescript-tslint-plugin" - ] -} \ No newline at end of file + "dbaeumer.vscode-eslint", + "editorconfig.editorconfig", + "github.vscode-pull-request-github", + "ms-vscode.vscode-typescript-tslint-plugin" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json index 83ae210..b4bd966 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,6 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": [ - "--disable-extensions", "--extensionDevelopmentPath=${workspaceRoot}" ], "stopOnEntry": false, @@ -34,4 +33,4 @@ "preLaunchTask": "npm: compile" } ] -} \ No newline at end of file +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f7823f3 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,38 @@ +# Contributing + +Contributions are welcome. + +All active development should target the `develop` branch. This is the configured default, but please make sure that all pull requests target `develop`. + +Backward compatibility of the user experience (UX) is important. This exstension was designed to be fast and simple - built right into users' workflow unlike the original "Insert GUID" that shipped with Visual Studio I sought to improve and replace. So any changes to bindings or menu order should be avoided unless the user has to opt into new behavior through, for example, changing settings to non-default values. + +Recommendations from .editorconfig and linting results should be respected, though there are few. + +Be sure to add an entry to the [CHANGELOG.md](CHANGELOG.md)! For bug fixes, please link to the original issue. + +## Prerequisites + +* [Node.js 12](https://nodejs.org) +* (Recommended) [VSCode](https://code.visualstudio.com) + +## Building + +NPM should install everything required to build and test on Windows and macOS. Linux requires running X11 to test and debug, though you're welcome to open this project in a [devcontainer](https://code.visualstudio.com/docs/remote/containers) that will start the X virtual framebuffer (Xvfb) automatically. + +1. Install dependencies: + ```bash + npm i + ``` +2. Build: + ```bash + npm run compile + ``` +3. Run tests: + ```bash + npm run test + ``` + You can run and debug tests in VSCode by running **Launch Tests** in the **Run** (formerly **Debug**) view. + +## Versioning + +Versioning is done manually in the `develop` branch prior to a release by updating the package version in [package.json](package.json). Previously it was done automatically, but often times would skip a significant range of patch versions, which seems odd.