Skip to content

Commit

Permalink
v0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-uk committed Sep 23, 2019
1 parent 675057a commit 6f5fc8d
Show file tree
Hide file tree
Showing 10 changed files with 869 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ src/**
.vscode/**
.gitignore
tsconfig.json
tslint.json
tslint.json
testfiles/**
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.6
- Fix for SKU evaluation error (exp.trim)
- Nicer error messages

## 0.0.5
- Snap to grid added
- Telemetry tracking added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This extension displays a graphical preview of Azure Resource Manager (ARM) temp
# Usage
- Open a ARM template JSON file, and ensure it is active/focused
- Click the eye symbol in the top right of the editor tab bar
- ![toolbar](assets/readme/icon.png)
- Or:
- Open the VS Code command pallet with `Ctrl+Shift+P` or `⇧⌘P` on a mac
- Start typing `ARM Viewer`
Expand Down
20 changes: 20 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@ body{
}

#error {
display: none;
font-size: 120%;
margin: 0 auto;
margin-top: 50%;
border: 2px solid var(--vscode-button-background);
box-shadow: 0 0 35px rgba(0, 0, 0, 0.7);
}

#errortitle {
background-color: var(--vscode-selection-background);
font-weight: bold;
font-size: 150%;
padding: 8px;
}

#errormsg {
font-size: 120%;
color: var(--vscode-errorForeground);
font-family: var(--vscode-editor-font-family);
white-space: pre-wrap;
word-break: break-all;
word-wrap: break-word;
padding: 10px;
}

button {
Expand Down
Binary file added assets/readme/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "armview",
"displayName": "ARM Template Viewer",
"description": "Graphically display ARM templates in an interactive map view",
"version": "0.0.5",
"version": "0.0.6",
"icon": "assets/img/icons/main.png",
"publisher": "bencoleman",
"author": {
Expand Down
14 changes: 10 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ function refreshView() {
// Initialise the contents of the webview - called at startup
//
function getWebviewContent() {
let wsname = "undefined";
if(vscode.workspace.name) wsname = vscode.workspace.name;
// Send telemetry for activation
let wsname: string = vscode.workspace.name || "unknown";
reporter.sendTelemetryEvent('activated', {'workspace': wsname});

if(!panel)
Expand Down Expand Up @@ -208,7 +208,12 @@ function getWebviewContent() {
<title>ARM Viewer</title>
</head>
<body>
<div id="error"></div>
<div id="error">
<div id="errortitle">⚠️ Parser Error</div>
<div id="errormsg">
</div>
</div>
<div id="buttons">
<button onclick="toggleLabels()">LABELS</button>
<button onclick="cy.fit()">FIT</button>
Expand All @@ -226,6 +231,7 @@ function getWebviewContent() {
</div>
<script>
// Message handler in webview, messages are sent by extension
window.addEventListener('message', event => {
const message = event.data;
Expand All @@ -237,7 +243,7 @@ function getWebviewContent() {
}
if(message.command == 'error') {
document.getElementById('error').innerHTML = message.payload
document.getElementById('errormsg').innerHTML = message.payload
document.getElementById('error').style.display = "block"
document.getElementById('mainview').style.display = "none"
document.getElementById('buttons').style.display = "none"
Expand Down
7 changes: 6 additions & 1 deletion src/lib/arm-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import * as utils from './utils'
import * as path from 'path';
import TelemetryReporter from 'vscode-extension-telemetry';
import { ESPIPE } from 'constants';
const jsonlint = require('jsonlint');

class ARMParser {
Expand Down Expand Up @@ -43,7 +44,7 @@ class ARMParser {

// Some simple ARM validation
if(!this.template.resources || !this.template.$schema) {
this.error = `That's valid JSON, but I don't think that's a valid ARM template`;
this.error = `File doesn't appear to be an ARM template, but is valid JSON`;
return;
}

Expand Down Expand Up @@ -298,6 +299,10 @@ class ARMParser {
// Main ARM expression parser, attempts to evaluate and resolve ARM expressions into strings
//
private _evalExpression(exp: string): any {
// Catch some rare errors where non-strings are parsed
if(typeof exp != "string")
return exp;

exp = exp.trim();

// catch special cases, with referenced properties, e.g. resourceGroup().location
Expand Down
Loading

0 comments on commit 6f5fc8d

Please sign in to comment.