-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add Bicep support #3027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: add Bicep support #3027
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ef67057
feat: add Bicep support
johnnyreilly 2112629
remove comment
johnnyreilly 49b1190
fix tests
johnnyreilly dd49236
Update components/prism-bicep.js
johnnyreilly b78a914
missing null
johnnyreilly 03924ad
update min
johnnyreilly 534a8b8
simplify regex
johnnyreilly 7cdf5a0
Update components/prism-bicep.js
johnnyreilly 7806225
fix
johnnyreilly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // based loosely upon: https://github.com/Azure/bicep/blob/main/src/textmate/bicep.tmlanguage | ||
| Prism.languages.bicep = { | ||
| 'comment': [ | ||
| { | ||
| // multiline comments eg /* ASDF */ | ||
| pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, | ||
| lookbehind: true, | ||
| greedy: true | ||
| }, | ||
| { | ||
| // singleline comments eg // ASDF | ||
| pattern: /(^|[^\\:])\/\/.*/, | ||
| lookbehind: true, | ||
| greedy: true | ||
| } | ||
| ], | ||
| 'string': { | ||
| // this doesn't handle string interpolalation or multiline strings as yet | ||
| pattern: /'(?:\\.|[^'\\\r\n])*'/, | ||
| greedy: true | ||
| }, | ||
| 'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i, | ||
| 'boolean': /\b(?:true|false)\b/, | ||
| 'keyword': /\b(?:targetScope|resource|module|param|var|output|for|in|if|existing|null)\b/, // https://github.com/Azure/bicep/blob/114a3251b4e6e30082a58729f19a8cc4e374ffa6/src/textmate/bicep.tmlanguage#L184 | ||
| 'function': /\b(?:array|concat|contains|createArray|empty|first|intersection|last|length|max|min|range|skip|take|union)(?:\$|\b)/, // https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-array | ||
| 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/, | ||
| 'punctuation': /[{}[\];(),.:]/, | ||
| 'decorator': /@\w+\b/ | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <h2>Variable assignment</h2> | ||
| <pre><code>var foo = 'bar'</code></pre> | ||
|
|
||
| <h2>Operators</h2> | ||
| <pre><code>(1 + 2 * 3)/4 >= 3 && 4 < 5 || 6 > 7</code></pre> | ||
|
|
||
| <h2>Keywords</h2> | ||
| <pre><code>resource appServicePlan 'Microsoft.Web/serverfarms@2020-09-01' existing = = if (diagnosticsEnabled) { | ||
| name: logAnalyticsWsName | ||
| } | ||
| module cosmosDb './cosmosdb.bicep' = { | ||
| name: 'cosmosDbDeploy' | ||
| } | ||
| param env string | ||
| var oneNumber = 123 | ||
| output databaseName string = cosmosdbDatabaseName | ||
| for item in cosmosdbAllowedIpAddresses: { | ||
| ipAddressOrRange: item | ||
| }</code></pre> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| true | ||
| false | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["boolean", "true"], | ||
| ["boolean", "false"] | ||
| ] | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| Checks for booleans. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| @secure() | ||
| param demoPassword string | ||
| @allowed([ | ||
| 'one' | ||
| 'two' | ||
| ]) | ||
| param demoEnum string | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["decorator", "@secure"], ["punctuation", "("], ["punctuation", ")"], | ||
| ["keyword", "param"], " demoPassword string\r\n", | ||
| ["decorator", "@allowed"], ["punctuation", "("], ["punctuation", "["], | ||
| ["string", "'one'"], | ||
| ["string", "'two'"], | ||
| ["punctuation", "]"], ["punctuation", ")"], | ||
| ["keyword", "param"], " demoEnum string" | ||
| ] | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| Checks for functions. Also checks for unicode characters in identifiers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| array | ||
| concat | ||
| contains | ||
| createArray | ||
| empty | ||
| first | ||
| intersection | ||
| last | ||
| length | ||
| max | ||
| min | ||
| range | ||
| skip | ||
| take | ||
| union | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["function", "array"], | ||
| ["function", "concat"], | ||
| ["function", "contains"], | ||
| ["function", "createArray"], | ||
| ["function", "empty"], | ||
| ["function", "first"], | ||
| ["function", "intersection"], | ||
| ["function", "last"], | ||
| ["function", "length"], | ||
| ["function", "max"], | ||
| ["function", "min"], | ||
| ["function", "range"], | ||
| ["function", "skip"], | ||
| ["function", "take"], | ||
| ["function", "union"] | ||
| ] | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| Checks for functions. Based upon https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| targetScope | ||
| resource appServicePlan 'Microsoft.Web/serverfarms@2020-09-01' existing = = if (diagnosticsEnabled) { | ||
| name: logAnalyticsWsName | ||
| } | ||
| module cosmosDb './cosmosdb.bicep' = { | ||
| name: 'cosmosDbDeploy' | ||
| } | ||
| param env string | ||
| var oneNumber = 123 | ||
| output databaseName string = cosmosdbDatabaseName | ||
| for item in cosmosdbAllowedIpAddresses: { | ||
| ipAddressOrRange: item | ||
| } | ||
| if | ||
| null | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["keyword", "targetScope"], | ||
|
|
||
| ["keyword", "resource"], | ||
| " appServicePlan ", | ||
| ["string", "'Microsoft.Web/serverfarms@2020-09-01'"], | ||
| ["keyword", "existing"], | ||
| ["operator", "="], | ||
| ["operator", "="], | ||
| ["keyword", "if"], | ||
| ["punctuation", "("], | ||
| "diagnosticsEnabled", | ||
| ["punctuation", ")"], | ||
| ["punctuation", "{"], | ||
|
|
||
| "\r\n name", | ||
| ["operator", ":"], | ||
| " logAnalyticsWsName\r\n", | ||
|
|
||
| ["punctuation", "}"], | ||
|
|
||
| ["keyword", "module"], | ||
| " cosmosDb ", | ||
| ["string", "'./cosmosdb.bicep'"], | ||
| ["operator", "="], | ||
| ["punctuation", "{"], | ||
|
|
||
| "\r\n name", | ||
| ["operator", ":"], | ||
| ["string", "'cosmosDbDeploy'"], | ||
|
|
||
| ["punctuation", "}"], | ||
|
|
||
| ["keyword", "param"], | ||
| " env string\r\n", | ||
|
|
||
| ["keyword", "var"], | ||
| " oneNumber ", | ||
| ["operator", "="], | ||
| ["number", "123"], | ||
|
|
||
| ["keyword", "output"], | ||
| " databaseName string ", | ||
| ["operator", "="], | ||
| " cosmosdbDatabaseName\r\n", | ||
|
|
||
| ["keyword", "for"], | ||
| " item ", | ||
| ["keyword", "in"], | ||
| " cosmosdbAllowedIpAddresses", | ||
| ["operator", ":"], | ||
| ["punctuation", "{"], | ||
|
|
||
| "\r\n\tipAddressOrRange", | ||
| ["operator", ":"], | ||
| " item\r\n", | ||
|
|
||
| ["punctuation", "}"], | ||
|
|
||
| ["keyword", "if"], | ||
|
|
||
| ["keyword", "null"] | ||
| ] | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| Checks for all keywords. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| 42 | ||
| 3.14159 | ||
| 4e10 | ||
| 3.2E+6 | ||
| 2.1e-10 | ||
| 0b1101 | ||
| 0o571 | ||
| 0xbabe | ||
| 0xBABE | ||
|
|
||
| NaN | ||
| Infinity | ||
|
|
||
| 123n | ||
| 0x123n | ||
|
|
||
| 1_000_000_000_000 | ||
| 1_000_000.220_720 | ||
| 0b0101_0110_0011_1000 | ||
| 0o12_34_56 | ||
| 0x40_76_38_6A_73 | ||
| 4_642_473_943_484_686_707n | ||
| 0.000_001 | ||
| 1e10_000 | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["number", "42"], | ||
| ["number", "3.14159"], | ||
| ["number", "4e10"], | ||
| ["number", "3.2E+6"], | ||
| ["number", "2.1e-10"], | ||
| ["number", "0"], "b1101\r\n", | ||
| ["number", "0"], "o571\r\n", | ||
| ["number", "0"], "xbabe\r\n", | ||
| ["number", "0"], "xBABE\r\n\r\nNaN\r\nInfinity\r\n\r\n", | ||
|
|
||
| ["number", "123"], "n\r\n", | ||
| ["number", "0"], "x123n\r\n\r\n", | ||
|
|
||
| ["number", "1"], | ||
| "_000_000_000_000\r\n", | ||
|
|
||
| ["number", "1"], | ||
| "_000_000", | ||
| ["punctuation", "."], | ||
| ["number", "220"], | ||
| "_720\r\n", | ||
|
|
||
| ["number", "0"], | ||
| "b0101_0110_0011_1000\r\n", | ||
|
|
||
| ["number", "0"], | ||
| "o12_34_56\r\n", | ||
|
|
||
| ["number", "0"], | ||
| "x40_76_38_6A_73\r\n", | ||
|
|
||
| ["number", "4"], | ||
| "_642_473_943_484_686_707n\r\n", | ||
|
|
||
| ["number", "0.000"], | ||
| "_001\r\n", | ||
|
|
||
| ["number", "1e10"], | ||
| "_000" | ||
| ] | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| Checks for decimal numbers, binary numbers, octal numbers, hexadecimal numbers. | ||
| Also checks for keywords representing numbers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| - -- -= | ||
| + ++ += | ||
| < <= << <<= | ||
| > >= >> >>= >>> >>>= | ||
| = == === => | ||
| ! != !== | ||
| & && &= &&= | ||
| | || |= ||= | ||
| * ** *= **= | ||
| / /= ~ | ||
| ^ ^= % %= | ||
| ? : ... | ||
| ?? ?. ??= | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["operator", "-"], ["operator", "--"], ["operator", "-="], | ||
| ["operator", "+"], ["operator", "++"], ["operator", "+="], | ||
| ["operator", "<"], ["operator", "<="], ["operator", "<<"], ["operator", "<<="], | ||
| ["operator", ">"], ["operator", ">="], ["operator", ">>"], ["operator", ">>="], ["operator", ">>>"], ["operator", ">>>="], | ||
| ["operator", "="], ["operator", "=="], ["operator", "==="], ["operator", "=>"], | ||
| ["operator", "!"], ["operator", "!="], ["operator", "!=="], | ||
| ["operator", "&"], ["operator", "&&"], ["operator", "&="], ["operator", "&&="], | ||
| ["operator", "|"], ["operator", "||"], ["operator", "|="], ["operator", "||="], | ||
| ["operator", "*"], ["operator", "**"], ["operator", "*="], ["operator", "**="], | ||
| ["operator", "/"], ["operator", "/="], ["operator", "~"], | ||
| ["operator", "^"], ["operator", "^="], ["operator", "%"], ["operator", "%="], | ||
| ["operator", "?"], ["operator", ":"], ["operator", "..."], | ||
| ["operator", "??"], ["operator", "?."], ["operator", "??="] | ||
| ] | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| Checks for all operators. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| 'Microsoft.Web/sites/config@2020-12-01' | ||
| 'https://${frontDoorName}.azurefd.net/.auth/login/aad/callback' | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["string", "'Microsoft.Web/sites/config@2020-12-01'"], | ||
| ["string", "'https://${frontDoorName}.azurefd.net/.auth/login/aad/callback'"] | ||
| ] | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| Checks for strings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| var oneString = 'abc' | ||
| var oneNumber = 123 | ||
| var numbers = [ | ||
| 123 | ||
| ] | ||
| var oneObject = { | ||
| abc: 123 | ||
| } | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| [ | ||
| ["keyword", "var"], " oneString ", ["operator", "="], ["string", "'abc'"], | ||
| ["keyword", "var"], " oneNumber ", ["operator", "="], ["number", "123"], | ||
| ["keyword", "var"], " numbers ", ["operator", "="], ["punctuation", "["], | ||
| ["number", "123"], | ||
| ["punctuation", "]"], | ||
| ["keyword", "var"], " oneObject ", ["operator", "="], ["punctuation", "{"], | ||
| "\r\n\tabc", ["operator", ":"], ["number", "123"], | ||
| ["punctuation", "}"] | ||
| ] | ||
|
|
||
| ---------------------------------------------------- | ||
|
|
||
| Checks for vars. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.