Skip to content

Commit

Permalink
Add devcontainer support
Browse files Browse the repository at this point in the history
Removed disabling extensions when debugging because it disables the remote extensions needed for debugging in a devcontainer.
  • Loading branch information
heaths committed Aug 20, 2020
1 parent aad10d8 commit a76c06b
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 5 deletions.
55 changes: 55 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
40 changes: 40 additions & 0 deletions .devcontainer/bin/init.sh
Original file line number Diff line number Diff line change
@@ -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: $@"
"$@"
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"recommendations": [
"ms-vscode.vscode-typescript-tslint-plugin"
]
}
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"github.vscode-pull-request-github",
"ms-vscode.vscode-typescript-tslint-plugin"
]
}
3 changes: 1 addition & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceRoot}"
],
"stopOnEntry": false,
Expand All @@ -34,4 +33,4 @@
"preLaunchTask": "npm: compile"
}
]
}
}
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit a76c06b

Please sign in to comment.