Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmwyant committed Nov 14, 2020
2 parents 35f40bf + bfedeb8 commit e2ad548
Show file tree
Hide file tree
Showing 28 changed files with 1,718 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: scottmwyant
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
77 changes: 77 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CD
on:
create:
tag:
- v\d+\.\d+\.\d+(\.[\w\d-]+)?
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VSCE_PAT: ${{secrets.VSCE_PAT}}

jobs:

deploy:
runs-on: ubuntu-latest
steps:

- name: Checkout source code
uses: actions/checkout@v2

# Make sure the version number in the tag matches the version in package.json
- name: match-tag-to-package-version
uses: geritol/[email protected] # https://github.com/geritol/match-tag-to-package-version
env:
TAG_PREFIX: refs/tags/v

# Parse the version number from the new tag
- name: Get version
id: semver
uses: LykkeBusiness/[email protected]
with:
tag: ${{ github.ref }}

# Update the 'latest' tag
- name: Tag latest
uses: richardsimko/update-tag@v1
with:
tag_name: latest

# Install deps, compile, and pack into .vsix
- name: Build
run: |
npm install
npx tsc --project src
npm install --no-save vsce
npx vsce --version
npx vsce package --out ./gcode.vsix
# Read the changelog entry corresponding to the new version number
- name: Read entry from changelog
uses: mindsers/changelog-reader-action@v2 # https://github.com/mindsers/changelog-reader-action
id: changelog_reader
with:
version: ${{ steps.semver.outputs.prefixed }}

# Create a new release on GitHub
- name: Create a release
uses: actions/create-release@v1 # https://github.com/actions/create-release/
id: create_release
with:
tag_name: ${{ steps.semver.outputs.prefixed }}
release_name: Release ${{ steps.semver.outputs.prefixed }}
body: ${{ steps.changelog_reader.outputs.changes }}
draft: false
prerelease: false

# Upload the vsix to the release
- name: Attach vsix
uses: actions/upload-release-asset@v1 # https://github.com/actions/upload-release-asset
id: upload-release-asset
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./gcode.vsix
asset_name: gcode-${{ steps.semver.outputs.prefixed }}.vsix
asset_content_type: application/vsix

# Publish the .vsix to the marketplace
- name: Publish to marketplace
run: npx vsce publish --packagePath gcode.vsix
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# References for .gitignore files
https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# Ignore node packages
node_modules/

# Ignore compiled javascript files
out/
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extensions",
"${workspaceRoot}/.vscode/sample.nc"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
27 changes: 27 additions & 0 deletions .vscode/sample.nc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@


N1 (MAR-09-2017-8:23:59AM)
N2 G00 G17 G40 G90 G90 G94
N100 G53 Z0
N101 T20 (TA1955 : DRILL SPADE CTT 21/32 X 3.2 132POINT)
N102 M6
N103 T15
N104 (DRILL-MT-HOLES)
N105 S3735 M03
N106 M12
N107 G90 G54
N108 G00 X24. Y-9.
N109 G43 H20 Z4.1
Z4.
G98 G81 X24. Y-9. Z-0.291 R1.25 F45.
X12. Y-9.
X0. Y-9.
X-12. Y-9.
X-24. Y-9.
X-24 Y9.
X-12 Y9.
X0. Y9.
X12. Y9.
X24. Y9.
G80
M05
13 changes: 13 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "compile",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
8 changes: 8 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Top level files
.gitignore

# Top level folders
.vscode/**
src/**
.github/**
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Change Log

All notable changes will be documented in this file.

Contributors: This document uses style guidelines from [Keep A Changelog](http://keepachangelog.com/).

## [v0.1.0] - 2020-11-13

Merge dev branch into master. This is the initial release. Previous version numbers were simply used to test the GitHub Actions continuous deployment workflow. Since this is the intial release, I won't go into much detail here, I'll just list the featuers and put the details the project's README.

#### Added

- Adaptive Syntax Highlighting
- Show Definition On Hover
- Line Numbering Commands
- Toggle Comment Command

### Changed

- The CD workflow has been merged into the dev branch. The workflow is now triggered by new tag being pushed. The release created by the workflow will be published (no longer be left as a draft).

- Updated package.json. The extension is now flagged as a "preview". I don't intend to keep this flag for long. Added keys to quiet complaints from `npm` and `vsce`.

## [v0.0.3] - 2020-11-06

### Changed

- CI workflow will now publish to the marketplace.

## [v0.0.2] - 2020-11-04

### Changed

- CI workflow is now triggered by a push to the `CI` branch. This is for testing the publishing workflow.

## [v0.0.1] - 2020-11-04

### Added

- GitHub actions workflow to automate publishing to the marketplace.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Scott Wyant

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.
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<br/><p align="center"><img src="https://user-images.githubusercontent.com/29161635/93551441-de870a00-f93b-11ea-82a3-48c360d2f732.png" alt="icon" width="200px"></p><br/>

# [G-Code for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=vscode-gcode.gcode)

**The premier Visual Studio Code extension for G-Code**

<br>

<!--Badges from https://shields.io-->
![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/vscode-gcode.gcode) ![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/vscode-gcode.gcode?color=%23f5f5f5&logo=installs) ![Visual Studio Marketplace Rating](https://img.shields.io/visual-studio-marketplace/r/vscode-gcode.gcode)

## ✨ Features

### Adaptive Syntax Highlighting

**<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> `>G-Code: Adapt to current theme`**

<p align="center"><img src="https://user-images.githubusercontent.com/29161635/96535493-f49c2900-125f-11eb-9e03-b395d231b82d.gif" alt="icon" height="400px" width="500px"></p>

CAD/CAM packages typically show the X-axis in red, the Y-axis in green, and the Z-Axis in blue. The G-Code extension follows that pattern. The adaptive syntax feature allows you to choose any of the supproted themes and get that familiar colorization. G-Code supports all of the themes that ship with VS Code, plus the [GitHub theme](https://marketplace.visualstudio.com/items?itemName=GitHub.github-vscode-theme) and [OneDark-Pro](https://marketplace.visualstudio.com/items?itemName=zhuangtongfa.Material-theme).

- When VS Code starts and the extension activates, it will check the active theme and if the extension's syntax highlighting isn't already tailored to that theme, you will be prompted to allow the extension to rewrite the files that style the code.

- Should you miss the prompt, you can use the `G-Code: Adapt to current theme` command to force the extension to adapt to the theme you're using (as long as it's supported).


### On-Hover Definitions

<p align="center"><img src="https://user-images.githubusercontent.com/29161635/98761008-7cc6a780-23a2-11eb-819c-2f8287e03320.gif" alt="icon" height="400px" width="500px"></p>

You no longer need to memorize dozens of obscure G and M codes! The G-Code extension includes a mechanism for you to *provide your own definitions* for any number of codes. Definitions can even be provided *inline* with the code.

#### Using VS Code settings

Share definitions across multiple programs using VS Code's settings files. Take a look at [VS Code Docs - User and Workspace Settings](https://code.visualstudio.com/docs/getstarted/settings) if you're not familiar VS Code configuration.

You need to add a `gcode.definitions` key to your settings.json file (user settings, workspace settings, or both). Here's an example of what it might look like:

```json
"gcode.definitions": {
"G90": "Positioning, absolute (modal)",
"G91": "Positioning, relative (modal)",
"M8": "Coolant On, External to Spindle",
"M9": "Coolant Off",
"M51": "Coolant On, Internal to Spindle",
}
```

#### Using inline definitions

An inline definition is a comment in your code that matches the following format. An inline definition has a `code` and a `meaning` seperated by `:` or `=`. There may be whitespace on either side of the seperator. The text on the right side of the seperator will show up as hover text in that file. See some examples of inline definitions below.

Note that after you add inline definitions to a file, they won't show up in a hover until you activate the file agian. Either close that file and re-open it, or activate another file then switch back. This prevents the extension from needing to continuously scan your file for definitions.

Examples of inline definitions:

```
(G4:DWELL)
(G4: THIS IS A DWELL)
(G4 = DWELL, USE P TO SPECIFY TIME)
```

#### A word on leading zeros

When providing definitions, regardless of which method you use, don't use leading zeros. Provide a definition for `G1` not `G01`. When you hover over a code like `G01` the extension ignores the leading zero and returns a definition for `G1`.

### Line Numbering

**<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> `>G-Code: Line Numbers (Add/Update)`**

**<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> `>G-Code: Line Numbers (Remove)`**

<p align="center"><img src="https://user-images.githubusercontent.com/29161635/99023619-f392aa80-2532-11eb-8328-2f594652a3c4.gif" alt="icon" height="400px" width="500px"></p>

Addding, updating, or removing line numbers are not tasks you should ever need to do manually. A robust G-Code editor should make this easy as possible so you can focus on more important things. The G-Code extension provides commands to carry out these tasks on the active file. Don't forget that you can map commands to a keyboard shortcut of your choice. See [Key Bindings for Visual Studio Code](https://code.visualstudio.com/docs/getstarted/keybindings).

### Toggle Comments

**<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> `>G-Code: Toggle Comment`**

<p align="center"><img src="https://user-images.githubusercontent.com/29161635/99023050-cf829980-2531-11eb-92be-b4516f3b4e95.gif" alt="icon" height="400px" width="500px"></p>

VS Code ships with the ability to toggle comments. The built-in feature works by modifying one or more characters at the beginning of each selected line. Since it only affects the beginning of the line, it doesn't work for G-Code comments that need to be (in parentheses). The G-Code extension provides a command that will toggle parenthesis at the start and end of each selected line.

## 📓 Release Notes

Documentation pertaining to a specific release can be found under [releases](https://github.com/scottmwyant/vscode-gcode/releases), or in the project's [changelog](./CHANGELOG.md).

## 💻 Developers

### VS Code Token Styles

Early on I realized I needed a way to see how each VS Code theme styles the various language tokens. My approach was to get data for each theme by using the `Developer: Generate Color Theme From Current Settings` command then use that data to render HTML. Since that work may be intersting outside of this project, I chose to save it in [this gist](https://gist.github.com/scottmwyant/2dc64ff4315ba9e2c374fb329b399820).

### Automated Deployment

Maintainers, here's how to publish the extension to the marketplace:

1. Put the new version number in [package.json](./package.json). The version number must be higher than the version shown in the [marketplace](https://marketplace.visualstudio.com/items?itemName=vscode-gcode.gcode). Reference [semver.org](https://semver.org/).
2. Create an entry in the [changelog](./changelog.md). Reference [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
3. Push a new tag with the version number. The tag must start with a 'v', like this: `v1.2.3`.

As long as these requirements are met, the CD workflow should go smoothly. A release will be created, and the new version of the extension will be published to the marketplace (see [./github/workflows](./.github/workflows)).
Loading

0 comments on commit e2ad548

Please sign in to comment.