From b84dafb5ec9652feecfc6182a5a90bb1b4e3b2c5 Mon Sep 17 00:00:00 2001 From: omniomi Date: Thu, 3 May 2018 13:55:44 -0600 Subject: [PATCH 1/9] Add issue template. --- ISSUE_TEMPLATE.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 ISSUE_TEMPLATE.md diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..f184e96 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,38 @@ + + +### Environment + +- Editor and Version (VS Code, Atom, Sublime): +- Your primary theme: + +### Issue Description + + + +#### Screenshots + + + +### Expected Behavior + + + +### Code Samples + + + +```PowerShell + + +``` From dd118959c6826f2f7d70ae6d27c08c7619a1a667 Mon Sep 17 00:00:00 2001 From: omniomi Date: Thu, 3 May 2018 16:08:52 -0600 Subject: [PATCH 2/9] build tools --- .gitignore | 3 ++ README.md | 43 ++++++++++++++++++++++++++++ tools/package.json | 10 +++++++ tools/scripts/build-grammar.js | 51 ++++++++++++++++++++++++++++++++++ tools/vscode.ps1 | 21 ++++++++++++++ 5 files changed, 128 insertions(+) create mode 100644 .gitignore create mode 100644 tools/package.json create mode 100644 tools/scripts/build-grammar.js create mode 100644 tools/vscode.ps1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8cc668c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +syntaxes/ +tools/node_modules/ +tools/package-lock.json \ No newline at end of file diff --git a/README.md b/README.md index bab6c15..2cf140d 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,49 @@ both VS Code and Sublime Text. There are a number of existing issues with the g that we need to track down and fix. Please see [issue #1](https://github.com/PowerShell/EditorSyntax/issues/1) for more details. +## Build and Import (VS Code) + +### Prerequisites + +- Python, >=2.7 (version 3 is not supported) +- Node.JS, >= 8.9.1 + +### Build + +1. Navigate via command line to the ./tools/` directory and install dependencies: + + ``` + npm install + ``` + +2. Run the `build-grammar` script to generate the json file. + + ``` + npm run build-grammar + ``` + +3. The .json file will be output to `./syntaxes/` at the root of the directory. You can use the vscode.ps1 script to load it or do it manually. + + **Install - script** + + ```PowerShell + PS tools> .\vscode.ps1 -InstallSyntax + ``` + + **Revert - script** + + ```PowerShell + PS tools> .\vscode.ps1 -RevertSyntax + ``` + + **Install - manually** + + 1. Locate the VS Code installation directory and navigate to to `resources/app/extensions/powershell/syntaxes` + + 2. Rename `powershell.tmLanguage.json` to `powershell.tmLanguage.json_default` + + 3. Copy `powershell.tmLanguage.json` from `./syntaxes/` within this project folder to where you just renamed the file under VS Code's path. + ## Contributing We would love to have community contributions to this project to make PowerShell syntax diff --git a/tools/package.json b/tools/package.json new file mode 100644 index 0000000..88f8efc --- /dev/null +++ b/tools/package.json @@ -0,0 +1,10 @@ +{ + "name": "EditorSyntax", + "version": "1.0.0", + "dependencies": { + "fast-plist": "0.1.2" + }, + "scripts": { + "build-grammar": "node ./scripts/build-grammar.js ../PowerShellSyntax.tmLanguage ../syntaxes/powershell.tmLanguage.json" + } +} diff --git a/tools/scripts/build-grammar.js b/tools/scripts/build-grammar.js new file mode 100644 index 0000000..a2baa2f --- /dev/null +++ b/tools/scripts/build-grammar.js @@ -0,0 +1,51 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Modified for PowerShell\EditorSyntax from MicroSoft\vscode (update-grammar.js) + * This script generates the JSON file using the same tools as vscode's build. + *--------------------------------------------------------------------------------------------*/ + + 'use strict'; + +var path = require('path'); +var fs = require('fs'); +var plist = require('fast-plist'); + +exports.update = function (tmlPath, dest) { + + var content = fs.readFileSync(tmlPath).toString(); + + var grammar; + grammar = plist.parse(content); + + let result = { + information_for_contributors: [ + 'This file has been converted from source and may not be in line with the official build.', + 'The current master branch for this syntax can be found here: https://github.com/PowerShell/EditorSyntax', + 'If you want to provide a fix or improvement, please create a pull request against the original repository.' + ] + }; + + result.version = require('child_process') + .execSync('git rev-parse HEAD') + .toString().trim() + + let keys = ['name', 'scopeName', 'comment', 'injections', 'patterns', 'repository']; + for (let key of keys) { + if (grammar.hasOwnProperty(key)) { + result[key] = grammar[key]; + } + } + + var dirname = path.dirname(dest); + if (!fs.existsSync(dirname)) { + fs.mkdirSync(dirname); + } + + fs.writeFileSync(dest, JSON.stringify(result, null, '\t')); +}; + +if (path.basename(process.argv[1]) === 'build-grammar.js') { + exports.update(process.argv[2], process.argv[3]); +} \ No newline at end of file diff --git a/tools/vscode.ps1 b/tools/vscode.ps1 new file mode 100644 index 0000000..a039e40 --- /dev/null +++ b/tools/vscode.ps1 @@ -0,0 +1,21 @@ +[cmdletbinding(DefaultParameterSetName='Install')] +param( + [Parameter(ParameterSetName='Install')] + [switch]$InstallSyntax, + + [Parameter(ParameterSetName='Revert')] + [switch]$RevertSyntax +) + +$SyntaxPath = Join-Path $PSScriptRoot "..\syntaxes\powershell.tmLanguage.json" + +if ($InstallSyntax) { + if (-not(Test-Path $SyntaxPath)) { + throw "No syntax to install. Please follow the build steps in the README.md" + } + +} elseif ($RevertSyntax) { + +} else { + throw "Please use either -InstallSyntax or -RevertSyntax" +} \ No newline at end of file From 72e163d05c33aa0d6c4a6fe73ed31c395e4835a9 Mon Sep 17 00:00:00 2001 From: omniomi Date: Thu, 3 May 2018 17:25:07 -0600 Subject: [PATCH 3/9] rework tools. --- README.md | 18 +++--------------- tools/vscode.ps1 | 21 --------------------- 2 files changed, 3 insertions(+), 36 deletions(-) delete mode 100644 tools/vscode.ps1 diff --git a/README.md b/README.md index 2cf140d..e0dabe0 100644 --- a/README.md +++ b/README.md @@ -43,21 +43,7 @@ for more details. npm run build-grammar ``` -3. The .json file will be output to `./syntaxes/` at the root of the directory. You can use the vscode.ps1 script to load it or do it manually. - - **Install - script** - - ```PowerShell - PS tools> .\vscode.ps1 -InstallSyntax - ``` - - **Revert - script** - - ```PowerShell - PS tools> .\vscode.ps1 -RevertSyntax - ``` - - **Install - manually** +3. The .json file will be output to `./syntaxes/` at the root of the directory. You will need to copy it to VS Code manually. 1. Locate the VS Code installation directory and navigate to to `resources/app/extensions/powershell/syntaxes` @@ -65,6 +51,8 @@ for more details. 3. Copy `powershell.tmLanguage.json` from `./syntaxes/` within this project folder to where you just renamed the file under VS Code's path. +4. If VS Code is already running you will need to run "Reload Window" from the command pallete. + ## Contributing We would love to have community contributions to this project to make PowerShell syntax diff --git a/tools/vscode.ps1 b/tools/vscode.ps1 deleted file mode 100644 index a039e40..0000000 --- a/tools/vscode.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -[cmdletbinding(DefaultParameterSetName='Install')] -param( - [Parameter(ParameterSetName='Install')] - [switch]$InstallSyntax, - - [Parameter(ParameterSetName='Revert')] - [switch]$RevertSyntax -) - -$SyntaxPath = Join-Path $PSScriptRoot "..\syntaxes\powershell.tmLanguage.json" - -if ($InstallSyntax) { - if (-not(Test-Path $SyntaxPath)) { - throw "No syntax to install. Please follow the build steps in the README.md" - } - -} elseif ($RevertSyntax) { - -} else { - throw "Please use either -InstallSyntax or -RevertSyntax" -} \ No newline at end of file From 6449670187c07f5ad3ee90ba9b072c1ebbc4ba53 Mon Sep 17 00:00:00 2001 From: omniomi Date: Thu, 3 May 2018 17:25:58 -0600 Subject: [PATCH 4/9] correct prereqs. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index e0dabe0..14c2ba1 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ for more details. ### Prerequisites -- Python, >=2.7 (version 3 is not supported) - Node.JS, >= 8.9.1 ### Build From 134d78525d259bdef69c816f566191f6d098750b Mon Sep 17 00:00:00 2001 From: omniomi Date: Thu, 3 May 2018 20:20:53 -0600 Subject: [PATCH 5/9] fix npm warnings. --- tools/package.json | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/package.json b/tools/package.json index 88f8efc..a824bb4 100644 --- a/tools/package.json +++ b/tools/package.json @@ -1,10 +1,16 @@ { - "name": "EditorSyntax", - "version": "1.0.0", - "dependencies": { - "fast-plist": "0.1.2" - }, - "scripts": { - "build-grammar": "node ./scripts/build-grammar.js ../PowerShellSyntax.tmLanguage ../syntaxes/powershell.tmLanguage.json" - } -} + "name": "editorsyntax", + "license" : "MIT", + "description": "PowerShell language syntax", + "repository": { + "type": "git", + "url": "https://github.com/PowerShell/EditorSyntax.git" + }, + "version": "1.0.0", + "dependencies": { + "fast-plist": "0.1.2" + }, + "scripts": { + "build-grammar": "node ./scripts/build-grammar.js ../PowerShellSyntax.tmLanguage ../syntaxes/powershell.tmLanguage.json" + } +} \ No newline at end of file From 9127a4a1049c6b009521a2e61539dfbe98ed7d50 Mon Sep 17 00:00:00 2001 From: omniomi Date: Thu, 3 May 2018 20:26:06 -0600 Subject: [PATCH 6/9] add console logging. --- tools/scripts/build-grammar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/scripts/build-grammar.js b/tools/scripts/build-grammar.js index a2baa2f..349571d 100644 --- a/tools/scripts/build-grammar.js +++ b/tools/scripts/build-grammar.js @@ -13,12 +13,14 @@ var fs = require('fs'); var plist = require('fast-plist'); exports.update = function (tmlPath, dest) { - + console.log('... Reading source file.'); var content = fs.readFileSync(tmlPath).toString(); + console.log('... Parsing content.'); var grammar; grammar = plist.parse(content); + console.log('... Building contents.'); let result = { information_for_contributors: [ 'This file has been converted from source and may not be in line with the official build.', @@ -40,12 +42,15 @@ exports.update = function (tmlPath, dest) { var dirname = path.dirname(dest); if (!fs.existsSync(dirname)) { + console.log('... Creating directory: ' + dirname); fs.mkdirSync(dirname); } fs.writeFileSync(dest, JSON.stringify(result, null, '\t')); + console.log('[Finished] File written to: ' + dest); }; if (path.basename(process.argv[1]) === 'build-grammar.js') { + console.log('[Starting] Converting ' + process.argv[2] + ' to json.'); exports.update(process.argv[2], process.argv[3]); } \ No newline at end of file From 59e478277656bc26d315dbcd6bd0e099f5a01ed6 Mon Sep 17 00:00:00 2001 From: omniomi Date: Thu, 3 May 2018 20:26:51 -0600 Subject: [PATCH 7/9] tweak wording. --- tools/scripts/build-grammar.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/scripts/build-grammar.js b/tools/scripts/build-grammar.js index 349571d..614a8a7 100644 --- a/tools/scripts/build-grammar.js +++ b/tools/scripts/build-grammar.js @@ -1,5 +1,4 @@ /*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * * Modified for PowerShell\EditorSyntax from MicroSoft\vscode (update-grammar.js) From f76340a5289428d1880ce62013dfc5924439cd51 Mon Sep 17 00:00:00 2001 From: omniomi Date: Thu, 3 May 2018 20:29:01 -0600 Subject: [PATCH 8/9] tweak wording of readme. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 14c2ba1..b7fc145 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ for more details. ### Build -1. Navigate via command line to the ./tools/` directory and install dependencies: +1. Navigate via command line to the `./tools/` directory and install dependencies: ``` npm install @@ -42,13 +42,13 @@ for more details. npm run build-grammar ``` -3. The .json file will be output to `./syntaxes/` at the root of the directory. You will need to copy it to VS Code manually. +3. The .json file will be generated in `./syntaxes/` at the root of the project. You will need to copy it in to VS Code manually. 1. Locate the VS Code installation directory and navigate to to `resources/app/extensions/powershell/syntaxes` 2. Rename `powershell.tmLanguage.json` to `powershell.tmLanguage.json_default` - 3. Copy `powershell.tmLanguage.json` from `./syntaxes/` within this project folder to where you just renamed the file under VS Code's path. + 3. Copy `powershell.tmLanguage.json` from `./syntaxes/` within the project folder to where you just renamed the file under VS Code's path. 4. If VS Code is already running you will need to run "Reload Window" from the command pallete. From 8d9889b968a9f36383615280a7ff9cd95762b89c Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 May 2018 08:01:06 -0600 Subject: [PATCH 9/9] Trademark capitalization --- tools/scripts/build-grammar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/scripts/build-grammar.js b/tools/scripts/build-grammar.js index 614a8a7..e422a20 100644 --- a/tools/scripts/build-grammar.js +++ b/tools/scripts/build-grammar.js @@ -1,7 +1,7 @@ /*--------------------------------------------------------------------------------------------- * Licensed under the MIT License. See License.txt in the project root for license information. * - * Modified for PowerShell\EditorSyntax from MicroSoft\vscode (update-grammar.js) + * Modified for PowerShell\EditorSyntax from Microsoft\vscode (update-grammar.js) * This script generates the JSON file using the same tools as vscode's build. *--------------------------------------------------------------------------------------------*/ @@ -52,4 +52,4 @@ exports.update = function (tmlPath, dest) { if (path.basename(process.argv[1]) === 'build-grammar.js') { console.log('[Starting] Converting ' + process.argv[2] + ' to json.'); exports.update(process.argv[2], process.argv[3]); -} \ No newline at end of file +}