Updated build scripts to build command-line version into an npm module.

This commit is contained in:
Eric Traut 2019-03-24 02:58:01 -07:00
parent 5e83a19a04
commit 0563813b9e
15 changed files with 136 additions and 16 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@ node_modules
.npm
# Output files
dist
server/out/
client/out/
client/server/

9
.npmignore Normal file
View File

@ -0,0 +1,9 @@
/.vscode
/client
/docs
/node_modules
/server
.gitignore
*.md
settings.json

View File

@ -1,6 +1,6 @@
{
"name": "pyright",
"version": "1.0.0",
"version": "1.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -3,7 +3,7 @@
"displayName": "Pyright",
"description": "VS Code language support and type checking for Python",
"version": "1.0.1",
"licensce": "MIT",
"license": "MIT",
"author": {
"name": "Microsoft Corporation"
},

6
index.js Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env node
// Stash the base directory into a global variable.
global.__rootDirectory = __dirname + '/dist/';
require('./dist/pyright')

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "pyright",
"version": "1.0.0",
"version": "1.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,19 +1,30 @@
{
"name": "pyright",
"displayName": "Pyright",
"description": "VS Code language support and type checking for Python",
"description": "Type checker for the Python language",
"version": "1.0.1",
"license": "MIT",
"author": {
"name": "Microsoft Corporation"
},
"publisher": "Microsoft Corporation",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/pyright"
},
"scripts": {
"postinstall": "cd server && npm install && cd ../client && npm install && cd ..",
"build": "npm run build:client && npm run build:server",
"build:client": "cd client && npm run build && cd ..",
"build:server": "cd server && npm run build && cd ..",
"build:analyzer": "cd server && npm run build:analyzer && cd ..",
"build:pyright": "cd server && npm run build:pyright && cd ..",
"package": "npm run build && cd client && npx vsce package && cd .."
},
"devDependencies": {
"@types/mocha": "^5.2.5",
"@types/node": "^11.10.5",
"typescript": "^3.2.2"
}
},
"main": "index.js"
}

View File

@ -0,0 +1,13 @@
#!/usr/bin/env node
// This script helps build the command-line version of pyright
// by copying the typeshed-fallback directory to the dist directory.
var fsExtra = require('fs-extra');
// Clean the dist directory
fsExtra.emptyDirSync('../dist');
fsExtra.mkdirSync('../dist/typeshed-fallback');
fsExtra.copySync('../client/typeshed-fallback', '../dist/typeshed-fallback');

View File

@ -1,6 +1,6 @@
{
"name": "pyright",
"version": "1.0.0",
"version": "1.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -173,6 +173,15 @@
"integrity": "sha512-4eOPXyn5DmP64MCMF8ePDvdlvlzt2a+F8ZaVjqmh2yFCpGjc1kI3kGnCFYX9SCsGTjQcWIyVZ86IHCEyjy/MNg==",
"dev": true
},
"@types/fs-extra": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.5.tgz",
"integrity": "sha512-w7iqhDH9mN8eLClQOYTkhdYUOSpp25eXxfc6VbFOGtzxW34JcvctH2bKjj4jD4++z4R5iO5D+pg48W2e03I65A==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/jest": {
"version": "24.0.9",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.9.tgz",
@ -2219,6 +2228,17 @@
"readable-stream": "^2.0.0"
}
},
"fs-extra": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"fs-write-stream-atomic": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz",
@ -4002,6 +4022,15 @@
}
}
},
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6"
}
},
"jsprim": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
@ -6298,6 +6327,12 @@
"imurmurhash": "^0.1.4"
}
},
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true
},
"unset-value": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz",

View File

@ -1,17 +1,18 @@
{
"name": "pyright",
"displayName": "pyright",
"description": "Linter and type checker for the Python language",
"description": "Type checker for the Python language",
"version": "1.0.1",
"license": "MIT",
"scripts": {
"start": "npm run start:analyzer && npm run start:server",
"start:analyzer": "npm i && npm run build:analyzer",
"start:server": "npm i && npm run build:server",
"build": "npm run build:server && npm run build:analyzer",
"build": "npm run build:server && npm run build:analyzer && npm run build:pyright",
"build:analyzer": "npm run tslint && tsc",
"build:server": "npm run installServer && webpack",
"build:server": "npm run installServer && webpack --config webpack.config-server.js",
"installServer": "node ./customInstallServerIntoExtension.js ../client ./package.json ./tsconfig.json ./package-lock.json",
"build:pyright": "node ./copyTypeshedFallback.js && npm run tslint && webpack --config webpack.config-pyright.js",
"watch": "tsc --watch",
"tslint": "tslint --project tsconfig.json --fix",
"test": "jest"
@ -24,8 +25,10 @@
},
"devDependencies": {
"@types/command-line-args": "^5.0.0",
"@types/fs-extra": "^5.0.5",
"@types/jest": "^24.0.9",
"@types/node": "^11.10.5",
"fs-extra": "^7.0.1",
"jest": "^24.1.0",
"ts-jest": "^24.0.0",
"tslint": "^5.13.1",

View File

@ -143,7 +143,7 @@ export class ImportResolver {
} else {
// Assume that the 'typeshed-fallback' directory is up one level
// from this javascript file.
const moduleDirectory = (global as any).__basedir;
const moduleDirectory = (global as any).__rootDirectory;
if (moduleDirectory) {
typeshedPath = combinePaths(getDirectoryPath(moduleDirectory), 'typeshed-fallback');
}

View File

@ -23,9 +23,6 @@ import { combinePaths, normalizePath } from './common/pathUtils';
const toolName = 'pyright';
// Stash the base directory into a global variable.
(global as any).__basedir = __dirname;
enum ExitStatus {
Success = 0,
DiagnosticsPresent_OutputsSkipped = 1,

View File

@ -26,7 +26,7 @@ interface Settings {
}
// Stash the base directory into a global variable.
(global as any).__basedir = __dirname;
(global as any).__rootDirectory = __dirname;
// Create a connection for the server. The connection uses Node's IPC as a transport
let _connection: IConnection = createConnection(new IPCMessageReader(process), new IPCMessageWriter(process));

View File

@ -0,0 +1,44 @@
/**
* webpack.config-pyright.js
* Copyright: Microsoft 2018
*
* Configuration for webpack to bundle the javascript into a single file
* for the pyright command-line tool.
*/
const path = require('path');
module.exports = {
entry: './src/pyright.ts',
mode: 'development',
target: 'node',
output: {
filename: 'pyright.js',
path: path.resolve(__dirname, '../dist')
},
resolve: {
modules: [
path.resolve(__dirname, '.'),
'node_modules'
],
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js']
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
configFile: 'tsconfig.json'
}
}
]
},
node: {
fs: 'empty'
}
};

View File

@ -1,8 +1,9 @@
/**
* webpack.config.js
* webpack.config-server.js
* Copyright: Microsoft 2018
*
* Configuration for webpack to bundle the javascript into a single file.
* Configuration for webpack to bundle the javascript into a single file
* for the VS Code Extension language server.
*/
const path = require('path');