Skip to content

Commit f38f6e5

Browse files
author
Kartik Raj
authored
Add npm project for Python API (#21631)
For microsoft#20949
1 parent ea76858 commit f38f6e5

30 files changed

+728
-102
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pythonExtensionApi/out/
2+
13
# The following files were grandfathered out of eslint. They can be removed as time permits.
24

35
src/test/analysisEngineTest.ts

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ cucumber-report.json
2323
port.txt
2424
precommit.hook
2525
pythonFiles/lib/**
26+
pythonFiles/get_pip.py
2627
debug_coverage*/**
2728
languageServer/**
2829
languageServer.*/**

build/azure-pipelines/pipeline.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
###############################################################################################
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
###############################################################################################
5+
name: $(Date:yyyyMMdd)$(Rev:.r)
6+
7+
pr: none
8+
9+
resources:
10+
repositories:
11+
- repository: templates
12+
type: github
13+
name: microsoft/vscode-engineering
14+
ref: main
15+
endpoint: Monaco
16+
17+
parameters:
18+
- name: quality
19+
displayName: Quality
20+
type: string
21+
default: latest
22+
values:
23+
- latest
24+
- next
25+
- name: publishPythonApi
26+
displayName: 🚀 Publish pythonExtensionApi
27+
type: boolean
28+
default: false
29+
30+
extends:
31+
template: azure-pipelines/npm-package/pipeline.yml@templates
32+
parameters:
33+
npmPackages:
34+
- name: pythonExtensionApi
35+
testPlatforms:
36+
- name: Linux
37+
nodeVersions:
38+
- 16.17.1
39+
- name: MacOS
40+
nodeVersions:
41+
- 16.17.1
42+
- name: Windows
43+
nodeVersions:
44+
- 16.17.1
45+
testSteps:
46+
- template: /build/azure-pipelines/templates/test-steps.yml@self
47+
parameters:
48+
package: pythonExtensionApi
49+
buildSteps:
50+
- template: /build/azure-pipelines/templates/pack-steps.yml@self
51+
parameters:
52+
package: pythonExtensionApi
53+
ghTagPrefix: release/pythonExtensionApi/
54+
tag: ${{ parameters.quality }}
55+
publishPackage: ${{ parameters.publishPythonApi }}
56+
workingDirectory: $(Build.SourcesDirectory)/pythonExtensionApi
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
###############################################################################################
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
###############################################################################################
5+
parameters:
6+
- name: package
7+
8+
steps:
9+
- script: npm install --root-only
10+
workingDirectory: $(Build.SourcesDirectory)
11+
displayName: Install root dependencies
12+
- script: npm install
13+
workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }}
14+
displayName: Install package dependencies
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
###############################################################################################
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
###############################################################################################
5+
parameters:
6+
- name: package
7+
type: string
8+
- name: script
9+
type: string
10+
default: 'all:publish'
11+
12+
steps:
13+
- script: npm install --root-only
14+
workingDirectory: $(Build.SourcesDirectory)
15+
displayName: Install root dependencies
16+
- bash: |
17+
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
18+
echo ">>> Started xvfb"
19+
displayName: Start xvfb
20+
condition: eq(variables['Agent.OS'], 'Linux')
21+
- script: npm run ${{ parameters.script }}
22+
workingDirectory: $(Build.SourcesDirectory)/${{ parameters.package }}
23+
displayName: Verify package

build/fail.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
process.exitCode = 1;

gulpfile.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const tsProject = ts.createProject('./tsconfig.json', { typescript });
2727

2828
const isCI = process.env.TRAVIS === 'true' || process.env.TF_BUILD !== undefined;
2929

30-
gulp.task('compile', (done) => {
30+
gulp.task('compileCore', (done) => {
3131
let failed = false;
3232
tsProject
3333
.src()
@@ -39,6 +39,22 @@ gulp.task('compile', (done) => {
3939
.on('finish', () => (failed ? done(new Error('TypeScript compilation errors')) : done()));
4040
});
4141

42+
const apiTsProject = ts.createProject('./pythonExtensionApi/tsconfig.json', { typescript });
43+
44+
gulp.task('compileApi', (done) => {
45+
let failed = false;
46+
apiTsProject
47+
.src()
48+
.pipe(apiTsProject())
49+
.on('error', () => {
50+
failed = true;
51+
})
52+
.js.pipe(gulp.dest('./pythonExtensionApi/out'))
53+
.on('finish', () => (failed ? done(new Error('TypeScript compilation errors')) : done()));
54+
});
55+
56+
gulp.task('compile', gulp.series('compileCore', 'compileApi'));
57+
4258
gulp.task('precommit', (done) => run({ exitOnError: true, mode: 'staged' }, done));
4359

4460
gulp.task('output:clean', () => del(['coverage']));

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,8 +2064,8 @@
20642064
"testSmoke": "cross-env INSTALL_JUPYTER_EXTENSION=true \"node ./out/test/smokeTest.js\"",
20652065
"testInsiders": "cross-env VSC_PYTHON_CI_TEST_VSC_CHANNEL=insiders INSTALL_PYLANCE_EXTENSION=true TEST_FILES_SUFFIX=insiders.test CODE_TESTS_WORKSPACE=src/testMultiRootWkspc/smokeTests \"node ./out/test/standardTest.js\"",
20662066
"lint-staged": "node gulpfile.js",
2067-
"lint": "eslint --ext .ts,.js src build",
2068-
"lint-fix": "eslint --fix --ext .ts,.js src build gulpfile.js",
2067+
"lint": "eslint --ext .ts,.js src build pythonExtensionApi",
2068+
"lint-fix": "eslint --fix --ext .ts,.js src build pythonExtensionApi gulpfile.js",
20692069
"format-check": "prettier --check 'src/**/*.ts' 'build/**/*.js' '.github/**/*.yml' gulpfile.js",
20702070
"format-fix": "prettier --write 'src/**/*.ts' 'build/**/*.js' '.github/**/*.yml' gulpfile.js",
20712071
"clean": "gulp clean",

pythonExtensionApi/.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
example/**
2+
dist/
3+
out/**/*.map
4+
out/**/*.tsbuildInfo
5+
src/
6+
.eslintrc*
7+
.eslintignore
8+
tsconfig*.json

pythonExtensionApi/LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation. All rights reserved.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)