Skip to content

Commit fa93356

Browse files
committed
temp work
1 parent c174eff commit fa93356

File tree

11 files changed

+227
-1
lines changed

11 files changed

+227
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ typings/
6464
out/
6565
**.vsix
6666
test/**/*.json
67+
!test/ref/**
6768
test/azure-quickstart-templates-master/**
6869
test/master.zip
6970
test/arm/**

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## 0.2.1
1+
## 0.2.2
2+
- Bug fixes
3+
- Removed animation
4+
5+
- ## 0.2.1
26
- Bug fixes
37

48
## 0.2.0

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
},
9191
"dependencies": {
9292
"axios": "^0.19.0",
93+
"jsonc-parser": "^2.1.1",
9394
"jsonlint": "^1.6.3",
9495
"strip-bom": "^3.0.0",
9596
"strip-json-comments": "^3.0.1",

test.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const jsc = require('jsonc-parser');
2+
const fs = require('fs');
3+
4+
let template = fs.readFileSync('./test/ref/jsontest.json', {encoding: 'utf8'});
5+
6+
7+
let regex = /(".*?")/gims
8+
let matches = template.match(regex)
9+
if(matches) {
10+
for(match of matches) {
11+
let bad = match.includes('\n')
12+
if(bad) console.log("M="+match);
13+
}
14+
}
15+
16+
17+
18+
19+
20+
let scanner = jsc.createScanner(template, true);
21+
22+
// var kind;
23+
// while ((kind = scanner.scan()) !== 17) {
24+
// if(scanner.getTokenError()) {
25+
// console.log(scanner.getTokenOffset(), scanner.getTokenError(), scanner.getTokenValue());
26+
// }
27+
// }
28+
29+
let err =[]
30+
let res = jsc.parse(template, err)
31+
32+
//console.log(template);
33+
34+
for(let i = 0; i < err.length; i++) {
35+
let e = err[i];
36+
if(e.error == 12) {
37+
//console.log(e.error, e.length, template.charAt(e.offset), template.substr(e.offset, e.length))
38+
39+
// let start = e.offset
40+
// let ni = i+1;
41+
// for(ni; ni < err.length; ni++) {
42+
// let ne = err[ni];
43+
// if(ne.error == 12) {
44+
// console.log("ERRR! "+ni);
45+
// i = ni;
46+
// break;
47+
// }
48+
// }
49+
}
50+
//console.log(e.error, e.length, template.charAt(e.offset), template.substr(e.offset, e.length))
51+
}

test/ref/basic.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"webParam": {
6+
"defaultValue": "web3",
7+
"type": "string"
8+
}
9+
},
10+
"variables": {
11+
"prefix": "web"
12+
},
13+
"resources": [
14+
{
15+
"name": "web1",
16+
"type": "microsoft.web/sites"
17+
},
18+
{
19+
"name": "web2",
20+
"type": "microsoft.web/sites",
21+
"dependsOn": [
22+
"web1"
23+
]
24+
},
25+
{
26+
"name": "web3",
27+
"type": "microsoft.web/sites",
28+
"dependsOn": [
29+
"[concat(variables('prefix'), '2')]"
30+
]
31+
},
32+
{
33+
"name": "web4",
34+
"type": "microsoft.web/sites",
35+
"dependsOn": [
36+
"[resourceId('Microsoft.Web/sites', parameters('webParam'))]",
37+
// Incorrect link, should NOT link to web1 or anything
38+
"[resourceId('Microsoft.Web/sites', '')]",
39+
"[resourceId('Microsoft.Web/sites', 'web2')]"
40+
]
41+
}
42+
]
43+
}

test/ref/empty.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {},
5+
"variables": {},
6+
"resources": [],
7+
"outputs": {}
8+
}

test/ref/jsontest.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "ghost snake
4+
lemon
5+
hat stuff",
6+
7+
/* "parameters": {}, */
8+
9+
"variables": {
10+
"foo": "this is a long
11+
12+
13+
14+
15+
string of words"
16+
},
17+
18+
// This is a comment
19+
"resources": [
20+
21+
]
22+
}

test/ref/t.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"resources": [
5+
{
6+
"type": "Microsoft.Storage/storageAccounts",
7+
"apiVersion": "2019-04-01",
8+
"name": "bc53535353",
9+
"location": "[resourceGroup().location]",
10+
"kind": "StorageV2",
11+
"sku": {
12+
"name": "Standard_LRS"
13+
},
14+
"tags": {
15+
"cheese": "goat
16+
hat
17+
cat lemon
18+
blah 123"
19+
}
20+
}
21+
]
22+
23+
}

test/ref/t.parameters.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
}
6+
}

test/ref/vars-params.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"simpleParam": {
6+
"defaultValue": "A simple name",
7+
"type": "string"
8+
}
9+
},
10+
"variables": {
11+
"simpleVar": "A simple var",
12+
"refVar": "[concat('Cheese_', variables('simpleVar'))]",
13+
"objVar": {
14+
"someProp": {
15+
"name": "Lou Reed",
16+
"nameList": [
17+
"Bowie",
18+
"Zappa",
19+
"Waters"
20+
]
21+
}
22+
},
23+
"arrayVar": [
24+
"Osbourne",
25+
"Iommi",
26+
"Butler",
27+
"Ward"
28+
]
29+
},
30+
"resources": [
31+
{
32+
// Name should be: "A simple var_A simple name"
33+
"name": "[concat(variables('simpleVar'), '_', parameters('simpleParam'))]",
34+
"type": "microsoft.compute/disks"
35+
},
36+
{
37+
// Name should be: "Cheese_A simple var"
38+
"name": "[variables('refVar')]",
39+
"type": "microsoft.compute/disks"
40+
},
41+
{
42+
// Name should be: "Lou Reed"
43+
"name": "[variables('objVar').someProp.name]",
44+
"type": "microsoft.compute/disks"
45+
},
46+
{
47+
// Name should be: "Zappa"
48+
"name": "[variables('objVar').someProp.nameList[1]]",
49+
"type": "microsoft.compute/disks"
50+
},
51+
{
52+
// Name should be: "Waters"
53+
"name": "[variables('objVar')['someProp'].nameList[2]]",
54+
"type": "microsoft.compute/disks"
55+
},
56+
{
57+
// Name should be: "Iommi"
58+
"name": "[variables('arrayVar')[1]]",
59+
"type": "microsoft.compute/disks"
60+
}
61+
]
62+
}

0 commit comments

Comments
 (0)