1
1
import * as program from 'commander' ;
2
- import * as didYouMean from 'didyoumean ' ;
2
+ import * as leven from 'leven ' ;
3
3
4
4
import { packageCommand , ls } from './package' ;
5
5
import { publish , unpublish } from './publish' ;
6
6
import { show } from './show' ;
7
7
import { search } from './search' ;
8
8
import { listPublishers , createPublisher , deletePublisher , loginPublisher , logoutPublisher } from './store' ;
9
9
import { getLatestVersion } from './npm' ;
10
- import { CancellationToken , isCancelledError , log } from './util' ;
10
+ import { CancellationToken , log } from './util' ;
11
11
import * as semver from 'semver' ;
12
12
import { isatty } from 'tty' ;
13
13
const pkg = require ( '../package.json' ) ;
14
14
15
- function fatal < T > ( message : any , ...args : any [ ] ) : void {
15
+ function fatal ( message : any , ...args : any [ ] ) : void {
16
16
if ( message instanceof Error ) {
17
17
message = message . message ;
18
18
@@ -63,7 +63,8 @@ module.exports = function (argv: string[]): void {
63
63
. description ( 'Lists all the files that will be published' )
64
64
. option ( '--yarn' , 'Use yarn instead of npm' )
65
65
. 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 ) ) ) ;
67
68
68
69
program
69
70
. command ( 'package' )
@@ -72,25 +73,29 @@ module.exports = function (argv: string[]): void {
72
73
. option ( '--baseContentUrl [url]' , 'Prepend all relative links in README.md with this url.' )
73
74
. option ( '--baseImagesUrl [url]' , 'Prepend all relative image links in README.md with this url.' )
74
75
. 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 } ) ) ) ;
76
79
77
80
program
78
81
. command ( 'publish [<version>]' )
79
82
. description ( 'Publishes an extension' )
80
- . option ( '-p, --pat <token>' , 'Personal Access Token' )
83
+ . option ( '-p, --pat <token>' , 'Personal Access Token' , process . env [ 'VSCE_PAT' ] )
81
84
. option ( '-m, --message <commit message>' , 'Commit message used when calling `npm version`.' )
82
85
. option ( '--packagePath [path]' , 'Publish the VSIX package located at the specified path.' )
83
86
. option ( '--baseContentUrl [url]' , 'Prepend all relative links in README.md with this url.' )
84
87
. option ( '--baseImagesUrl [url]' , 'Prepend all relative image links in README.md with this url.' )
85
88
. option ( '--yarn' , 'Use yarn instead of npm while packing extension files' )
86
89
. 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 } ) ) ) ;
88
92
89
93
program
90
94
. command ( 'unpublish [<extensionid>]' )
91
95
. description ( 'Unpublishes an extension. Example extension id: microsoft.csharp.' )
92
96
. 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 } ) ) ) ;
94
99
95
100
program
96
101
. command ( 'ls-publishers' )
@@ -133,7 +138,8 @@ module.exports = function (argv: string[]): void {
133
138
. command ( '*' , '' , { noHelp : true } )
134
139
. action ( ( cmd : string ) => {
135
140
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 ) ;
137
143
138
144
help = `${ help }
139
145
Unknown command '${ cmd } '` ;
0 commit comments