Skip to content

Commit 0563813

Browse files
committed
Updated build scripts to build command-line version into an npm module.
1 parent 5e83a19 commit 0563813

15 files changed

+136
-16
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ node_modules
55
.npm
66

77
# Output files
8+
dist
89
server/out/
910
client/out/
1011
client/server/

.npmignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.vscode
2+
/client
3+
/docs
4+
/node_modules
5+
/server
6+
.gitignore
7+
*.md
8+
settings.json
9+

client/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Pyright",
44
"description": "VS Code language support and type checking for Python",
55
"version": "1.0.1",
6-
"licensce": "MIT",
6+
"license": "MIT",
77
"author": {
88
"name": "Microsoft Corporation"
99
},

index.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env node
2+
3+
// Stash the base directory into a global variable.
4+
global.__rootDirectory = __dirname + '/dist/';
5+
6+
require('./dist/pyright')

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
{
22
"name": "pyright",
33
"displayName": "Pyright",
4-
"description": "VS Code language support and type checking for Python",
4+
"description": "Type checker for the Python language",
55
"version": "1.0.1",
6+
"license": "MIT",
7+
"author": {
8+
"name": "Microsoft Corporation"
9+
},
10+
"publisher": "Microsoft Corporation",
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/Microsoft/pyright"
14+
},
615
"scripts": {
716
"postinstall": "cd server && npm install && cd ../client && npm install && cd ..",
817
"build": "npm run build:client && npm run build:server",
918
"build:client": "cd client && npm run build && cd ..",
1019
"build:server": "cd server && npm run build && cd ..",
1120
"build:analyzer": "cd server && npm run build:analyzer && cd ..",
21+
"build:pyright": "cd server && npm run build:pyright && cd ..",
1222
"package": "npm run build && cd client && npx vsce package && cd .."
1323
},
1424
"devDependencies": {
1525
"@types/mocha": "^5.2.5",
1626
"@types/node": "^11.10.5",
1727
"typescript": "^3.2.2"
18-
}
28+
},
29+
"main": "index.js"
1930
}

server/copyTypeshedFallback.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env node
2+
3+
// This script helps build the command-line version of pyright
4+
// by copying the typeshed-fallback directory to the dist directory.
5+
6+
var fsExtra = require('fs-extra');
7+
8+
// Clean the dist directory
9+
fsExtra.emptyDirSync('../dist');
10+
11+
fsExtra.mkdirSync('../dist/typeshed-fallback');
12+
fsExtra.copySync('../client/typeshed-fallback', '../dist/typeshed-fallback');
13+

server/package-lock.json

+36-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
22
"name": "pyright",
33
"displayName": "pyright",
4-
"description": "Linter and type checker for the Python language",
4+
"description": "Type checker for the Python language",
55
"version": "1.0.1",
66
"license": "MIT",
77
"scripts": {
88
"start": "npm run start:analyzer && npm run start:server",
99
"start:analyzer": "npm i && npm run build:analyzer",
1010
"start:server": "npm i && npm run build:server",
11-
"build": "npm run build:server && npm run build:analyzer",
11+
"build": "npm run build:server && npm run build:analyzer && npm run build:pyright",
1212
"build:analyzer": "npm run tslint && tsc",
13-
"build:server": "npm run installServer && webpack",
13+
"build:server": "npm run installServer && webpack --config webpack.config-server.js",
1414
"installServer": "node ./customInstallServerIntoExtension.js ../client ./package.json ./tsconfig.json ./package-lock.json",
15+
"build:pyright": "node ./copyTypeshedFallback.js && npm run tslint && webpack --config webpack.config-pyright.js",
1516
"watch": "tsc --watch",
1617
"tslint": "tslint --project tsconfig.json --fix",
1718
"test": "jest"
@@ -24,8 +25,10 @@
2425
},
2526
"devDependencies": {
2627
"@types/command-line-args": "^5.0.0",
28+
"@types/fs-extra": "^5.0.5",
2729
"@types/jest": "^24.0.9",
2830
"@types/node": "^11.10.5",
31+
"fs-extra": "^7.0.1",
2932
"jest": "^24.1.0",
3033
"ts-jest": "^24.0.0",
3134
"tslint": "^5.13.1",

server/src/analyzer/importResolver.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class ImportResolver {
143143
} else {
144144
// Assume that the 'typeshed-fallback' directory is up one level
145145
// from this javascript file.
146-
const moduleDirectory = (global as any).__basedir;
146+
const moduleDirectory = (global as any).__rootDirectory;
147147
if (moduleDirectory) {
148148
typeshedPath = combinePaths(getDirectoryPath(moduleDirectory), 'typeshed-fallback');
149149
}

server/src/pyright.ts

-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ import { combinePaths, normalizePath } from './common/pathUtils';
2323

2424
const toolName = 'pyright';
2525

26-
// Stash the base directory into a global variable.
27-
(global as any).__basedir = __dirname;
28-
2926
enum ExitStatus {
3027
Success = 0,
3128
DiagnosticsPresent_OutputsSkipped = 1,

server/src/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface Settings {
2626
}
2727

2828
// Stash the base directory into a global variable.
29-
(global as any).__basedir = __dirname;
29+
(global as any).__rootDirectory = __dirname;
3030

3131
// Create a connection for the server. The connection uses Node's IPC as a transport
3232
let _connection: IConnection = createConnection(new IPCMessageReader(process), new IPCMessageWriter(process));

server/webpack.config-pyright.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* webpack.config-pyright.js
3+
* Copyright: Microsoft 2018
4+
*
5+
* Configuration for webpack to bundle the javascript into a single file
6+
* for the pyright command-line tool.
7+
*/
8+
9+
const path = require('path');
10+
11+
module.exports = {
12+
entry: './src/pyright.ts',
13+
mode: 'development',
14+
target: 'node',
15+
output: {
16+
filename: 'pyright.js',
17+
path: path.resolve(__dirname, '../dist')
18+
},
19+
20+
resolve: {
21+
modules: [
22+
path.resolve(__dirname, '.'),
23+
'node_modules'
24+
],
25+
// Add '.ts' and '.tsx' as resolvable extensions.
26+
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js']
27+
},
28+
29+
module: {
30+
rules: [
31+
{
32+
test: /\.tsx?$/,
33+
loader: 'ts-loader',
34+
options: {
35+
configFile: 'tsconfig.json'
36+
}
37+
}
38+
]
39+
},
40+
41+
node: {
42+
fs: 'empty'
43+
}
44+
};

server/webpack.config.js server/webpack.config-server.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/**
2-
* webpack.config.js
2+
* webpack.config-server.js
33
* Copyright: Microsoft 2018
44
*
5-
* Configuration for webpack to bundle the javascript into a single file.
5+
* Configuration for webpack to bundle the javascript into a single file
6+
* for the VS Code Extension language server.
67
*/
78

89
const path = require('path');

0 commit comments

Comments
 (0)