Skip to content

Commit 6adca53

Browse files
committed
Merge branch 'master' into pr/396
2 parents 8455460 + a4cca08 commit 6adca53

22 files changed

+749
-481
lines changed

.vscode/tasks.json

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
{
2-
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
33
// for the documentation about the tasks.json format
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "compile",
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": [
10+
"$tsc-watch"
11+
],
812
"group": {
913
"kind": "build",
1014
"isDefault": true
1115
},
12-
"command": "npm",
13-
"presentation": {
14-
"reveal": "silent"
15-
},
16-
"args": [
17-
"run",
18-
"compile",
19-
"--loglevel",
20-
"silent"
21-
],
22-
"problemMatcher": [],
16+
"isBackground": true
17+
},
18+
{
19+
"type": "npm",
20+
"script": "test"
2321
}
2422
]
2523
}

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
- [Node.js](https://nodejs.org/en/) at least `8.x.x`
1010

11+
## Usage
12+
13+
`vsce` is meant to be mainly used as a command line tool. It can also be used a library since it exposes a small [API](https://github.com/microsoft/vscode-vsce/blob/master/src/api.ts).
14+
15+
> **Warning:** When using vsce as a library be sure to sanitize any user input used in API calls, as a security measurement.
16+
1117
## Development
1218

1319
First clone this repository, then:

package.json

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vsce",
3-
"version": "1.68.0",
3+
"version": "1.76.1",
44
"description": "VSCode Extension Manager",
55
"repository": {
66
"type": "git",
@@ -40,10 +40,10 @@
4040
"cheerio": "^1.0.0-rc.1",
4141
"commander": "^2.8.1",
4242
"denodeify": "^1.2.1",
43-
"didyoumean": "^1.2.1",
4443
"glob": "^7.0.6",
45-
"lodash": "^4.17.10",
46-
"markdown-it": "^8.3.1",
44+
"leven": "^3.1.0",
45+
"lodash": "^4.17.15",
46+
"markdown-it": "^10.0.0",
4747
"mime": "^1.3.4",
4848
"minimatch": "^3.0.3",
4949
"osenv": "^0.1.3",
@@ -59,22 +59,27 @@
5959
"devDependencies": {
6060
"@types/cheerio": "^0.22.1",
6161
"@types/denodeify": "^1.2.31",
62-
"@types/didyoumean": "^1.2.0",
6362
"@types/glob": "^7.1.1",
6463
"@types/lodash": "^4.14.123",
6564
"@types/markdown-it": "0.0.2",
6665
"@types/mime": "^1",
6766
"@types/minimatch": "^3.0.3",
68-
"@types/mocha": "^5.2.6",
67+
"@types/mocha": "^7.0.2",
6968
"@types/node": "^8",
7069
"@types/read": "^0.0.28",
7170
"@types/semver": "^6.0.0",
7271
"@types/tmp": "^0.1.0",
7372
"@types/xml2js": "^0.4.4",
74-
"concurrently": "^4.1.0",
75-
"mocha": "^5.2.0",
73+
"concurrently": "^5.1.0",
74+
"mocha": "^7.1.1",
7675
"source-map-support": "^0.4.2",
7776
"typescript": "^3.4.3",
7877
"xml2js": "^0.4.12"
78+
},
79+
"mocha": {
80+
"require": [
81+
"source-map-support/register"
82+
],
83+
"spec": "out/test"
7984
}
8085
}

src/api.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ export interface IListFilesOptions {
9090
* no dependencies will be included.
9191
*/
9292
packagedDependencies?: string[];
93+
94+
/**
95+
* The location of an alternative .vscodeignore file to be used.
96+
* The `.vscodeignore` file located at the root of the project will be taken
97+
* instead, if none is specified.
98+
*/
99+
ignoreFile?: string;
93100
}
94101

95102
export interface IPublishVSIXOptions {
@@ -135,7 +142,7 @@ export function publish(options: IPublishOptions = {}): Promise<any> {
135142
* Lists the files included in the extension's package.
136143
*/
137144
export function listFiles(options: IListFilesOptions = {}): Promise<string[]> {
138-
return _listFiles(options.cwd, options.packageManager === PackageManager.Yarn, options.packagedDependencies);
145+
return _listFiles(options.cwd, options.packageManager === PackageManager.Yarn, options.packagedDependencies, options.ignoreFile);
139146
}
140147

141148
/**

src/main.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import * as program from 'commander';
2-
import * as didYouMean from 'didyoumean';
2+
import * as leven from 'leven';
33

44
import { packageCommand, ls } from './package';
55
import { publish, unpublish } from './publish';
66
import { show } from './show';
77
import { search } from './search';
88
import { listPublishers, createPublisher, deletePublisher, loginPublisher, logoutPublisher } from './store';
99
import { getLatestVersion } from './npm';
10-
import { CancellationToken, isCancelledError, log } from './util';
10+
import { CancellationToken, log } from './util';
1111
import * as semver from 'semver';
1212
import { isatty } from 'tty';
1313
const pkg = require('../package.json');
1414

15-
function fatal<T>(message: any, ...args: any[]): void {
15+
function fatal(message: any, ...args: any[]): void {
1616
if (message instanceof Error) {
1717
message = message.message;
1818

@@ -63,7 +63,8 @@ module.exports = function (argv: string[]): void {
6363
.description('Lists all the files that will be published')
6464
.option('--yarn', 'Use yarn instead of npm')
6565
.option('--packagedDependencies <path>', 'Select packages that should be published only (includes dependencies)', (val, all) => all ? all.concat(val) : [val], undefined)
66-
.action(({ yarn, packagedDependencies }) => main(ls(undefined, yarn, packagedDependencies)));
66+
.option('--ignoreFile [path]', 'Indicate alternative .vscodeignore')
67+
.action(({ yarn, packagedDependencies, ignoreFile }) => main(ls(undefined, yarn, packagedDependencies, ignoreFile)));
6768

6869
program
6970
.command('package')
@@ -72,25 +73,29 @@ module.exports = function (argv: string[]): void {
7273
.option('--baseContentUrl [url]', 'Prepend all relative links in README.md with this url.')
7374
.option('--baseImagesUrl [url]', 'Prepend all relative image links in README.md with this url.')
7475
.option('--yarn', 'Use yarn instead of npm')
75-
.action(({ out, baseContentUrl, baseImagesUrl, yarn }) => main(packageCommand({ packagePath: out, baseContentUrl, baseImagesUrl, useYarn: yarn })));
76+
.option('--ignoreFile [path]', 'Indicate alternative .vscodeignore')
77+
.option('--noGitHubIssueLinking', 'Prevent automatic expansion of GitHub-style issue syntax into links')
78+
.action(({ out, baseContentUrl, baseImagesUrl, yarn, ignoreFile, noGitHubIssueLinking }) => main(packageCommand({ packagePath: out, baseContentUrl, baseImagesUrl, useYarn: yarn, ignoreFile, expandGitHubIssueLinks: noGitHubIssueLinking })));
7679

7780
program
7881
.command('publish [<version>]')
7982
.description('Publishes an extension')
80-
.option('-p, --pat <token>', 'Personal Access Token')
83+
.option('-p, --pat <token>', 'Personal Access Token', process.env['VSCE_PAT'])
8184
.option('-m, --message <commit message>', 'Commit message used when calling `npm version`.')
8285
.option('--packagePath [path]', 'Publish the VSIX package located at the specified path.')
8386
.option('--baseContentUrl [url]', 'Prepend all relative links in README.md with this url.')
8487
.option('--baseImagesUrl [url]', 'Prepend all relative image links in README.md with this url.')
8588
.option('--yarn', 'Use yarn instead of npm while packing extension files')
8689
.option('--noVerify')
87-
.action((version, { pat, message, packagePath, baseContentUrl, baseImagesUrl, yarn, noVerify }) => main(publish({ pat, commitMessage: message, version, packagePath, baseContentUrl, baseImagesUrl, useYarn: yarn, noVerify })));
90+
.option('--ignoreFile [path]', 'Indicate alternative .vscodeignore')
91+
.action((version, { pat, message, packagePath, baseContentUrl, baseImagesUrl, yarn, noVerify, ignoreFile }) => main(publish({ pat, commitMessage: message, version, packagePath, baseContentUrl, baseImagesUrl, useYarn: yarn, noVerify, ignoreFile })));
8892

8993
program
9094
.command('unpublish [<extensionid>]')
9195
.description('Unpublishes an extension. Example extension id: microsoft.csharp.')
9296
.option('-p, --pat <token>', 'Personal Access Token')
93-
.action((id, { pat }) => main(unpublish({ id, pat })));
97+
.option('-f, --force', 'Forces Unpublished Extension')
98+
.action((id, { pat, force }) => main(unpublish({ id, pat, force })));
9499

95100
program
96101
.command('ls-publishers')
@@ -133,7 +138,8 @@ module.exports = function (argv: string[]): void {
133138
.command('*', '', { noHelp: true })
134139
.action((cmd: string) => {
135140
program.help(help => {
136-
const suggestion = didYouMean(cmd, program.commands.map(c => c._name));
141+
const availableCommands = program.commands.map(c => c._name);
142+
const suggestion = availableCommands.find(c => leven(c, cmd) < c.length * 0.4);
137143

138144
help = `${help}
139145
Unknown command '${cmd}'`;

src/manifest.ts

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface Manifest {
4242
_testing?: string;
4343
enableProposedApi?: boolean;
4444
qna?: 'marketplace' | string | false;
45+
extensionKind?: string[];
4546

4647
// optional (npm)
4748
author?: string | Person;

src/npm.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as fs from 'fs';
33
import * as cp from 'child_process';
44
import * as parseSemver from 'parse-semver';
55
import * as _ from 'lodash';
6-
import { CancellationToken, log } from './util';
6+
import { CancellationToken } from './util';
77

88
interface IOptions {
99
cwd?: string;
@@ -54,7 +54,7 @@ function checkNPM(cancellationToken?: CancellationToken): Promise<void> {
5454

5555
function getNpmDependencies(cwd: string): Promise<string[]> {
5656
return checkNPM()
57-
.then(() => exec('npm list --production --parseable --depth=99999', { cwd, maxBuffer: 5000 * 1024 }))
57+
.then(() => exec('npm list --production --parseable --depth=99999 --loglevel=error', { cwd, maxBuffer: 5000 * 1024 }))
5858
.then(({ stdout }) => stdout
5959
.split(/[\r\n]/)
6060
.filter(dir => path.isAbsolute(dir)));

0 commit comments

Comments
 (0)