Skip to content

Commit 9398a3f

Browse files
authored
Merge pull request #458 from PowerShell/daviwil/new-dev-setup
First phase of streamlined development setup
2 parents 3d9319b + d731c70 commit 9398a3f

File tree

10 files changed

+166
-91
lines changed

10 files changed

+166
-91
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"stopOnEntry": false,
1111
"sourceMaps": true,
1212
"outDir": "${workspaceRoot}/out",
13-
"preLaunchTask": "compile"
13+
"preLaunchTask": "Build"
1414
},
1515
{
1616
"name": "Attach",

.vscode/settings.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
// Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened.
4-
"editor.tabSize": 4,
5-
6-
// Controls if the editor will insert spaces for tabs. Accepted values: "auto", true, false. If set to "auto", the value will be guessed when a file is opened.
7-
"editor.insertSpaces": true,
8-
9-
// When enabled, will trim trailing whitespace when you save a file.
3+
"editor.tabSize": 4,
4+
"editor.insertSpaces": true,
105
"files.trimTrailingWhitespace": true,
116

127
// Lock the TypeScript SDK path to the version we use

.vscode/tasks.json

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,38 @@
1-
// Available variables which can be used inside of strings.
2-
// ${workspaceRoot}: the root folder of the team
3-
// ${file}: the current opened file
4-
// ${fileBasename}: the current opened file's basename
5-
// ${fileDirname}: the current opened file's dirname
6-
// ${fileExtname}: the current opened file's extension
7-
// ${cwd}: the current working directory of the spawned process
8-
9-
// A task runner that calls a custom npm script that compiles the extension.
101
{
11-
"version": "0.1.0",
12-
13-
// we want to run npm
14-
"command": "npm",
15-
16-
// the command is a shell script
17-
"isShellCommand": true,
2+
"version": "0.1.0",
3+
4+
"windows": {
5+
"command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
6+
"args": [ "-NoProfile", "-ExecutionPolicy", "Bypass" ]
7+
},
8+
"linux": {
9+
"command": "/usr/bin/powershell",
10+
"args": [ "-NoProfile" ]
11+
},
12+
"osx": {
13+
"command": "/usr/local/bin/powershell",
14+
"args": [ "-NoProfile" ]
15+
},
16+
17+
"isShellCommand": true,
18+
"showOutput": "always",
1819

1920
"tasks": [
2021
{
21-
"taskName": "install",
22-
"showOutput": "always"
22+
"taskName": "Install",
23+
"suppressTaskName": true,
24+
"args": [ "Invoke-Build Restore" ]
2325
},
2426
{
25-
"taskName": "compile",
26-
"isBuildCommand": true,
27+
"taskName": "Clean",
2728
"suppressTaskName": true,
28-
29-
// show the output window only if unrecognized errors occur.
30-
"showOutput": "silent",
31-
32-
// we run the custom script "compile" as defined in package.json
33-
"args": ["run", "compile"],
34-
35-
// use the standard tsc problem matcher to find compile problems in the output.
36-
"problemMatcher": "$tsc"
29+
"args": [ "Invoke-Build Clean" ]
3730
},
3831
{
39-
"taskName": "compile-watch",
32+
"taskName": "Build",
4033
"suppressTaskName": true,
41-
42-
// show the output window only if unrecognized errors occur.
43-
"showOutput": "silent",
44-
45-
// we run the custom script "compile-watch" as defined in package.json
46-
"args": ["run", "compile-watch"],
47-
48-
// The tsc compiler is started in watching mode
49-
"isWatching": true,
50-
51-
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
52-
"problemMatcher": "$tsc-watch"
34+
"isBuildCommand": true,
35+
"args": [ "Invoke-Build Build" ]
5336
}
5437
]
5538
}

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vscode/**
2+
vscode-powershell.build.ps1
23
typings/**
34
**/*.ts
45
.gitignore

appveyor.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '0.9.0.{build}'
2+
image: Visual Studio 2017 RC
3+
clone_depth: 10
4+
skip_tags: true
5+
6+
branches:
7+
only:
8+
- master
9+
- develop
10+
11+
install:
12+
- git clone https://github.com/PowerShell/PowerShellEditorServices.git ../PowerShellEditorServices
13+
- ps: Install-Product node '6.9.2'
14+
- ps: |
15+
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null
16+
Install-Module InvokeBuild -RequiredVersion 3.2.1 -Scope CurrentUser -Force | Out-Null
17+
18+
build_script:
19+
- ps: Invoke-Build Build
20+
21+
# The build script takes care of the tests
22+
test: off

docs/development.md

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,43 @@
1-
# Working with the PowerShell extension code
1+
# Development Instructions for the PowerShell Extension
22

3-
## Building the code
3+
## Development Setup
44

5-
1. Install [Node.js](https://nodejs.org/en/) 4.4.1 or higher.
5+
You'll need to clone two repositories and set up your development environment
6+
to before you can proceed.
67

7-
2. Install the package dependencies by running one of the following commands:
8+
### 1. [Fork and clone](https://help.github.com/articles/fork-a-repo/) the [vscode-powershell repository](https://github.com/PowerShell/vscode-powershell)
89

9-
```
10-
# From a PowerShell prompt
11-
npm install
10+
### 2. [Fork and clone](https://help.github.com/articles/fork-a-repo/) the [PowerShell Editor Services repository](https://github.com/PowerShell/PowerShellEditorServices)
1211

13-
# Or from Visual Studio Code
14-
Press Ctrl+P and type "task install"
15-
```
12+
### 3. Follow the [development instructions](https://github.com/PowerShell/PowerShellEditorServices#development) for PowerShell Editor Services
1613

17-
3. Compile the code by running one of the following commands:
14+
### 4. Install [Visual Studio Code Insiders Release](https://code.visualstudio.com/insiders)
1815

19-
```
20-
# From a PowerShell prompt
21-
npm run compile
16+
### 5. Install [Node.js](https://nodejs.org/en/) 6.0.0 or higher.
2217

23-
# Or from Visual Studio Code
24-
Press Ctrl+P and type "task compile"
25-
```
26-
This will compile the TypeScript files in the project to JavaScript files.
18+
## Building the Code
2719

28-
OR
20+
#### From Visual Studio Code:
2921

30-
You can compile the files and then have the TypeScript compiler watch for changes to
31-
the source files and automatically recompile those files when changes are saved.
32-
To do this, run one of the following commands:
22+
Press <kbd>Ctrl+P</kbd> and type `task build`
3323

34-
```
35-
# From a PowerShell prompt
36-
npm run compile-watch
24+
This will compile the TypeScript files in the project to JavaScript files.
3725

38-
# Or from Visual Studio Code
39-
Press Ctrl+P and type "task compile-watch"
40-
```
26+
#### From a command prompt:
4127

42-
## Running the compiled code
28+
```
29+
Invoke-Build Build
30+
```
4331

44-
1. From a PowerShell prompt, run the following command:
32+
## Launching the extension
4533

46-
```
47-
code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
48-
```
34+
#### From Visual Studio Code:
4935

50-
2. If you allow the compiler to continue watching for file changes, you can use
51-
the `Reload Window` command found in the command palette `(Ctrl+Shift+P)`
52-
so that the new source files are loaded.
36+
To debug the extension, press <kbd>F5</kbd>. To run the extension without debugging,
37+
press <kbd>Ctrl+F5</kbd> or <kbd>Cmd+F5</kbd> on macOS.
38+
39+
#### From a command prompt:
40+
41+
```
42+
code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
43+
```

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@
323323
},
324324
"powershell.developer.bundledModulesPath": {
325325
"type": "string",
326-
"default": "../modules/",
327326
"description": "Specifies the path to the folder containing modules that are bundled with the PowerShell extension (i.e. PowerShell Editor Services, PowerShell Script Analyzer, Plaster)"
328327
},
329328
"powershell.developer.editorServicesLogLevel": {

src/session.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ export class SessionManager {
7272
private languageServerClient: LanguageClient = undefined;
7373
private sessionSettings: Settings.ISettings = undefined;
7474

75+
// When in development mode, VS Code's session ID is a fake
76+
// value of "someValue.machineId". Use that to detect dev
77+
// mode for now until Microsoft/vscode#10272 gets implemented.
78+
private readonly inDevelopmentMode =
79+
vscode.env.sessionId === "someValue.sessionId";
80+
7581
constructor(
7682
private requiredEditorServicesVersion: string,
7783
private log: Logger,
@@ -100,9 +106,24 @@ export class SessionManager {
100106
if (this.sessionConfiguration.type === SessionType.UsePath ||
101107
this.sessionConfiguration.type === SessionType.UseBuiltIn) {
102108

103-
var bundledModulesPath = this.sessionSettings.developer.bundledModulesPath;
104-
if (!path.isAbsolute(bundledModulesPath)) {
105-
bundledModulesPath = path.resolve(__dirname, bundledModulesPath);
109+
var bundledModulesPath = path.resolve(__dirname, "../modules");
110+
111+
if (this.inDevelopmentMode) {
112+
var devBundledModulesPath =
113+
// this.sessionSettings.developer.bundledModulesPath ||
114+
path.resolve(
115+
__dirname,
116+
this.sessionSettings.developer.bundledModulesPath ||
117+
"../../PowerShellEditorServices/module");
118+
119+
// Make sure the module's bin path exists
120+
if (fs.existsSync(path.join(devBundledModulesPath, "PowerShellEditorServices/bin"))) {
121+
bundledModulesPath = devBundledModulesPath;
122+
}
123+
else {
124+
this.log.write(
125+
`\nWARNING: In development mode but PowerShellEditorServices dev module path cannot be found (or has not been built yet): ${devBundledModulesPath}\n`);
126+
}
106127
}
107128

108129
var startArgs =

src/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function load(myPluginId: string): ISettings {
4242

4343
let defaultDeveloperSettings: IDeveloperSettings = {
4444
powerShellExePath: undefined,
45-
bundledModulesPath: "../modules/",
45+
bundledModulesPath: undefined,
4646
editorServicesLogLevel: "Normal",
4747
editorServicesWaitForDebugger: false,
4848
powerShellExeIsWindowsDevBuild: false

vscode-powershell.build.ps1

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#
2+
# Copyright (c) Microsoft. All rights reserved.
3+
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
4+
#
5+
6+
param(
7+
[string]$EditorServicesRepoPath = $null
8+
)
9+
10+
#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"}
11+
12+
task ResolveEditorServicesPath -Before Clean, Build {
13+
$script:psesRepoPath = `
14+
if ($EditorServicesRepoPath) {
15+
$EditorServicesRepoPath
16+
}
17+
else {
18+
"$PSScriptRoot/../PowerShellEditorServices/"
19+
}
20+
21+
if (!(Test-Path $script:psesRepoPath)) {
22+
# Clear the path so that it won't be used
23+
Write-Host "`n### WARNING: The PowerShellEditorServices repo cannot be found at path $script:psesRepoPath`n" -ForegroundColor Yellow
24+
$script:psesRepoPath = $null
25+
}
26+
else {
27+
$script:psesRepoPath = Resolve-Path $script:psesRepoPath
28+
$script:psesBuildScriptPath = Resolve-Path "$script:psesRepoPath/PowerShellEditorServices.build.ps1"
29+
}
30+
}
31+
32+
task Restore -If { "Restore" -in $BuildTask -or !(Test-Path "./node_modules") } -Before Build {
33+
Write-Host "`n### Restoring vscode-powershell dependencies`n" -ForegroundColor Green
34+
35+
# When in a CI build use the --loglevel=error parameter so that
36+
# package install warnings don't cause PowerShell to throw up
37+
$logLevelParam = if ($env:AppVeyor) { "--loglevel=error" } else { "" }
38+
exec { & npm install $logLevelParam }
39+
}
40+
41+
task Clean {
42+
if ($script:psesBuildScriptPath) {
43+
Write-Host "`n### Cleaning PowerShellEditorServices`n" -ForegroundColor Green
44+
Invoke-Build Clean $script:psesBuildScriptPath
45+
}
46+
47+
Write-Host "`n### Cleaning vscode-powershell`n" -ForegroundColor Green
48+
Remove-Item .\out -Recurse -Force -ErrorAction Ignore
49+
}
50+
51+
task Build {
52+
53+
# If the PSES codebase is co-located, build it first
54+
if ($script:psesBuildScriptPath) {
55+
Write-Host "`n### Building PowerShellEditorServices`n" -ForegroundColor Green
56+
Invoke-Build BuildHost $script:psesBuildScriptPath
57+
}
58+
59+
Write-Host "`n### Building vscode-powershell" -ForegroundColor Green
60+
exec { & npm run compile }
61+
}
62+
63+
task . Clean, Build

0 commit comments

Comments
 (0)