Skip to content

Commit

Permalink
Initial Notebook UI Mode in VS Code Insiders (#2789)
Browse files Browse the repository at this point in the history
* initial changes

* add activation event

* add block comment support

* add saveMarkdownCellsAs setting

* set metadata in new cells on save

* actually work across files

* updated API with metadata

* refactor based on option and new Kernel type

* add github action and proposed

* add pwsh

* remove old

* trigger PR

* add log

* force cron to trigger

* time

* time

* time

* better titles

* powershell comments

* remove not needed comments

* use githubrunnumber

* use run_id

* Update Notebook dts (#3)

Co-authored-by: TylerLeonhardt <[email protected]>

* better check for registering

* Update Notebook dts (#4)

Co-authored-by: TylerLeonhardt <[email protected]>

* rob's feedback

* Add a few tests

* added save test

* move to utils.sleep

* fix regex

* add logger

* Codacy part 1

* Codacy part 2

* Update Notebook dts (#5)

Co-authored-by: TylerLeonhardt <[email protected]>

* move GitHub Action to use master

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: TylerLeonhardt <[email protected]>
Co-authored-by: Tyler Leonhardt (POWERSHELL) <[email protected]>
  • Loading branch information
4 people authored Jul 14, 2020
1 parent 56800c0 commit 93243a9
Show file tree
Hide file tree
Showing 23 changed files with 1,355 additions and 22 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/updateNotebookApi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: "Update Notebook API"

on:
push:
pull_request:
schedule:
- cron: 0 22 * * *

jobs:
Update-Notebook-Api:

runs-on: ubuntu-latest
defaults:
run:
shell: pwsh

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Setup Node.js environment
uses: actions/[email protected]

- name: Rename proposed dts to old
run: Move-Item ./vscode.proposed.d.ts ./old.vscode.proposed.d.ts

- name: npm install
run: npm install

- name: Get latest proposed dts
run: npm run download-api

- name: Generate new dts and compare it with the old one
run: |
# This will contain the content of our new file
$fullFile = [System.Collections.Generic.List[string]]@()
$dts = Get-Content ./vscode.proposed.d.ts
# First add everything up to the declare statement
$index = 0
while ($dts[$index] -notmatch "declare module 'vscode' {") {
$fullFile += $dts[$index]
$index++
}
# Add the declare statement
$fullFile += $dts[$index]
# Find the Notebook region start index
for ( $i = $index; $i -lt $dts.Length; $i++) {
if($dts[$i] -match '//#region @rebornix: Notebook') {
$index = $i
break
}
}
# Add everything until the endregion to the new file
while ($dts[$index] -notmatch "//#endregion") {
$fullFile += $dts[$index]
$index++
}
# Add the endregion line and ending brace line
$fullFile += $dts[$index]
$fullFile += '}'
# Overwrite the file with the new content
$fullFile | Set-Content ./vscode.proposed.d.ts
# Get the old and new files' raw text
$oldFile = Get-Content ./old.vscode.proposed.d.ts -Raw
$newFile = Get-Content ./vscode.proposed.d.ts -Raw
# Compare them and log if they are different
if($oldFile -ne $newFile) {
Write-Host "New changes detected!"
}
# Remove the old file so it doesn't get picked up by tsc
Remove-Item ./old.vscode.proposed.d.ts -Force
- name: Compile the TypeScript to check for errors
run: npm run compile

- name: Create Pull Request
if: github.event_name == 'schedule'
id: cpr
uses: peter-evans/create-pull-request@v2
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
commit-message: "Update Notebook dts"
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
title: "Update Notebook dts"
assignees: TylerLeonhardt
reviewers: TylerLeonhardt
base: master
draft: false
branch: powershell-notebook-patch-${{ github.run_id }}
labels: Created_by_Action
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ npm-debug.log
.vscode-test/
*.DS_Store
test-results.xml
vscode.d.ts
6 changes: 5 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--enable-proposed-api", "ms-vscode.powershell-preview",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/testRunner.js" ],
"--extensionTestsPath=${workspaceFolder}/out/test/testRunner.js",
"${workspaceFolder}/test"
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "Build"
}
Expand Down
76 changes: 70 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 64 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"publisher": "ms-vscode",
"description": "(Preview) Develop PowerShell scripts in Visual Studio Code!",
"engines": {
"vscode": "^1.43.0"
"vscode": "^1.44.0"
},
"license": "SEE LICENSE IN LICENSE.txt",
"homepage": "https://github.com/PowerShell/vscode-powershell/blob/master/README.md",
Expand All @@ -26,6 +26,7 @@
"url": "https://github.com/PowerShell/vscode-powershell.git"
},
"main": "./out/src/main",
"enableProposedApi": true,
"activationEvents": [
"onDebugInitialConfigurations",
"onDebugResolve:PowerShell",
Expand All @@ -43,7 +44,8 @@
"onCommand:PowerShell.RegisterExternalExtension",
"onCommand:PowerShell.UnregisterExternalExtension",
"onCommand:PowerShell.GetPowerShellVersionDetails",
"onView:PowerShellCommands"
"onView:PowerShellCommands",
"onNotebookEditor:PowerShellNotebookMode"
],
"dependencies": {
"node-fetch": "^2.6.0",
Expand All @@ -56,13 +58,13 @@
"@types/glob": "^7.1.3",
"@types/mocha": "~7.0.2",
"@types/mock-fs": "~4.10.0",
"@types/node": "~12.12.39",
"@types/node": "~14.0.22",
"@types/node-fetch": "~2.5.7",
"@types/rewire": "~2.5.28",
"@types/semver": "~7.3.1",
"@types/sinon": "~9.0.4",
"@types/uuid": "^8.0.0",
"@types/vscode": "1.43.0",
"@types/vscode": "1.44.0",
"mocha": "~5.2.0",
"mocha-junit-reporter": "~2.0.0",
"mocha-multi-reporters": "~1.1.7",
Expand All @@ -72,15 +74,17 @@
"tslint": "~6.1.2",
"typescript": "~3.9.6",
"vsce": "~1.77.0",
"vscode-test": "~1.4.0"
"vscode-test": "~1.4.0",
"vscode-dts": "~0.3.1"
},
"extensionDependencies": [
"vscode.powershell"
],
"scripts": {
"compile": "tsc -v && tsc -p ./ && tslint -p ./",
"compile-watch": "tsc -watch -p ./",
"test": "node ./out/test/runTests.js"
"test": "node ./out/test/runTests.js",
"download-api": "vscode-dts dev"
},
"contributes": {
"breakpoints": [
Expand All @@ -106,6 +110,18 @@
}
]
},
"notebookProvider": [
{
"viewType": "PowerShellNotebookMode",
"displayName": "Powershell Notebook",
"selector": [
{
"filenamePattern": "*.ps1"
}
],
"priority": "option"
}
],
"keybindings": [
{
"command": "PowerShell.ShowHelp",
Expand Down Expand Up @@ -201,6 +217,24 @@
"dark": "resources/dark/play.svg"
}
},
{
"command": "PowerShell.ShowNotebookMode",
"title": "(Preview) Show Notebook Mode",
"category": "PowerShell",
"icon": {
"light": "resources/light/book.svg",
"dark": "resources/dark/book.svg"
}
},
{
"command": "PowerShell.HideNotebookMode",
"title": "Show Text Editor",
"category": "PowerShell",
"icon": {
"light": "resources/light/file-code.svg",
"dark": "resources/dark/file-code.svg"
}
},
{
"command": "PowerShell.RestartSession",
"title": "Restart Current Session",
Expand Down Expand Up @@ -376,6 +410,16 @@
"when": "editorLangId == powershell && config.powershell.buttons.showRunButtons",
"command": "PowerShell.RunSelection",
"group": "navigation@101"
},
{
"when": "editorLangId == powershell && config.powershell.notebooks.showToggleButton",
"command": "PowerShell.ShowNotebookMode",
"group": "navigation@102"
},
{
"when": "resourceLangId == powershell && notebookEditorFocused",
"command": "PowerShell.HideNotebookMode",
"group": "navigation@102"
}
],
"editor/title/context": [
Expand Down Expand Up @@ -881,6 +925,20 @@
"type": "boolean",
"default": false,
"description": "Show buttons in the editor titlebar for moving the panel around."
},
"powershell.notebooks.showToggleButton": {
"type": "boolean",
"default": false,
"description": "Controls whether we show or hide the buttons to toggle Notebook mode in the top right."
},
"powershell.notebooks.saveMarkdownCellsAs": {
"type": "string",
"enum": [
"BlockComment",
"LineComment"
],
"default": "BlockComment",
"description": "Controls what new markdown cells in Notebook Mode get saved as in the PowerShell file."
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions resources/dark/book.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/dark/file-code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/light/book.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/light/file-code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 93243a9

Please sign in to comment.