ts: noUnusedLocals, noUnusedParameters
This commit is contained in:
parent
56f916b4fc
commit
b044011b63
9 changed files with 34 additions and 56 deletions
|
@ -7,12 +7,12 @@ import { show } from './show';
|
||||||
import { search } from './search';
|
import { search } from './search';
|
||||||
import { listPublishers, createPublisher, deletePublisher, loginPublisher, logoutPublisher } from './store';
|
import { listPublishers, createPublisher, deletePublisher, loginPublisher, logoutPublisher } from './store';
|
||||||
import { getLatestVersion } from './npm';
|
import { getLatestVersion } from './npm';
|
||||||
import { CancellationToken, isCancelledError, log } from './util';
|
import { CancellationToken, log } from './util';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import { isatty } from 'tty';
|
import { isatty } from 'tty';
|
||||||
const pkg = require('../package.json');
|
const pkg = require('../package.json');
|
||||||
|
|
||||||
function fatal<T>(message: any, ...args: any[]): void {
|
function fatal(message: any, ...args: any[]): void {
|
||||||
if (message instanceof Error) {
|
if (message instanceof Error) {
|
||||||
message = message.message;
|
message = message.message;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as fs from 'fs';
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'child_process';
|
||||||
import * as parseSemver from 'parse-semver';
|
import * as parseSemver from 'parse-semver';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { CancellationToken, log } from './util';
|
import { CancellationToken } from './util';
|
||||||
|
|
||||||
interface IOptions {
|
interface IOptions {
|
||||||
cwd?: string;
|
cwd?: string;
|
||||||
|
|
|
@ -17,11 +17,6 @@ import * as urljoin from 'url-join';
|
||||||
import { validatePublisher, validateExtensionName, validateVersion, validateEngineCompatibility, validateVSCodeTypesCompatibility } from './validation';
|
import { validatePublisher, validateExtensionName, validateVersion, validateEngineCompatibility, validateVSCodeTypesCompatibility } from './validation';
|
||||||
import { getDependencies } from './npm';
|
import { getDependencies } from './npm';
|
||||||
|
|
||||||
interface IReadFile {
|
|
||||||
(filePath: string): Promise<Buffer>;
|
|
||||||
(filePath: string, encoding?: string): Promise<string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const readFile = denodeify<string, string, string>(fs.readFile);
|
const readFile = denodeify<string, string, string>(fs.readFile);
|
||||||
const unlink = denodeify<string, void>(fs.unlink as any);
|
const unlink = denodeify<string, void>(fs.unlink as any);
|
||||||
const stat = denodeify(fs.stat);
|
const stat = denodeify(fs.stat);
|
||||||
|
@ -472,7 +467,7 @@ export class MarkdownProcessor extends BaseProcessor {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('svg').each((_, svg) => {
|
$('svg').each(() => {
|
||||||
throw new Error(`SVG tags are not allowed in ${this.name}.`);
|
throw new Error(`SVG tags are not allowed in ${this.name}.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -761,7 +756,7 @@ export function readManifest(cwd = process.cwd(), nls = true): Promise<Manifest>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toVsixManifest(assets: IAsset[], vsix: any, options: IPackageOptions = {}): Promise<string> {
|
export function toVsixManifest(vsix: any): Promise<string> {
|
||||||
return readFile(vsixManifestTemplatePath, 'utf8')
|
return readFile(vsixManifestTemplatePath, 'utf8')
|
||||||
.then(vsixManifestTemplateStr => _.template(vsixManifestTemplateStr))
|
.then(vsixManifestTemplateStr => _.template(vsixManifestTemplateStr))
|
||||||
.then(vsixManifestTemplate => vsixManifestTemplate(vsix));
|
.then(vsixManifestTemplate => vsixManifestTemplate(vsix));
|
||||||
|
@ -853,7 +848,7 @@ function collectFiles(cwd: string, useYarn = false, dependencyEntryPoints?: stri
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function processFiles(processors: IProcessor[], files: IFile[], options: IPackageOptions = {}): Promise<IFile[]> {
|
export function processFiles(processors: IProcessor[], files: IFile[]): Promise<IFile[]> {
|
||||||
const processedFiles = files.map(file => util.chain(file, processors, (file, processor) => processor.onFile(file)));
|
const processedFiles = files.map(file => util.chain(file, processors, (file, processor) => processor.onFile(file)));
|
||||||
|
|
||||||
return Promise.all(processedFiles).then(files => {
|
return Promise.all(processedFiles).then(files => {
|
||||||
|
@ -861,7 +856,7 @@ export function processFiles(processors: IProcessor[], files: IFile[], options:
|
||||||
const assets = _.flatten(processors.map(p => p.assets));
|
const assets = _.flatten(processors.map(p => p.assets));
|
||||||
const vsix = processors.reduce((r, p) => ({ ...r, ...p.vsix }), { assets });
|
const vsix = processors.reduce((r, p) => ({ ...r, ...p.vsix }), { assets });
|
||||||
|
|
||||||
return Promise.all([toVsixManifest(assets, vsix, options), toContentTypes(files)]).then(result => {
|
return Promise.all([toVsixManifest(vsix), toContentTypes(files)]).then(result => {
|
||||||
return [
|
return [
|
||||||
{ path: 'extension.vsixmanifest', contents: new Buffer(result[0], 'utf8') },
|
{ path: 'extension.vsixmanifest', contents: new Buffer(result[0], 'utf8') },
|
||||||
{ path: '[Content_Types].xml', contents: new Buffer(result[1], 'utf8') },
|
{ path: '[Content_Types].xml', contents: new Buffer(result[1], 'utf8') },
|
||||||
|
@ -895,7 +890,7 @@ export function collect(manifest: Manifest, options: IPackageOptions = {}): Prom
|
||||||
return collectFiles(cwd, useYarn, packagedDependencies, ignoreFile).then(fileNames => {
|
return collectFiles(cwd, useYarn, packagedDependencies, ignoreFile).then(fileNames => {
|
||||||
const files = fileNames.map(f => ({ path: `extension/${f}`, localPath: path.join(cwd, f) }));
|
const files = fileNames.map(f => ({ path: `extension/${f}`, localPath: path.join(cwd, f) }));
|
||||||
|
|
||||||
return processFiles(processors, files, options);
|
return processFiles(processors, files);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,20 +915,16 @@ function getDefaultPackageName(manifest: Manifest): string {
|
||||||
return `${manifest.name}-${manifest.version}.vsix`;
|
return `${manifest.name}-${manifest.version}.vsix`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepublish(cwd: string, manifest: Manifest, useYarn: boolean = false): Promise<Manifest> {
|
async function prepublish(cwd: string, manifest: Manifest, useYarn: boolean = false): Promise<void> {
|
||||||
if (!manifest.scripts || !manifest.scripts['vscode:prepublish']) {
|
if (!manifest.scripts || !manifest.scripts['vscode:prepublish']) {
|
||||||
return Promise.resolve(manifest);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn(`Executing prepublish script '${useYarn ? 'yarn' : 'npm'} run vscode:prepublish'...`);
|
console.warn(`Executing prepublish script '${useYarn ? 'yarn' : 'npm'} run vscode:prepublish'...`);
|
||||||
|
|
||||||
return exec(`${useYarn ? 'yarn' : 'npm'} run vscode:prepublish`, { cwd, maxBuffer: 5000 * 1024 })
|
const { stdout, stderr } = await exec(`${useYarn ? 'yarn' : 'npm'} run vscode:prepublish`, { cwd, maxBuffer: 5000 * 1024 });
|
||||||
.then(({ stdout, stderr }) => {
|
process.stdout.write(stdout);
|
||||||
process.stdout.write(stdout);
|
process.stderr.write(stderr);
|
||||||
process.stderr.write(stderr);
|
|
||||||
return Promise.resolve(manifest);
|
|
||||||
})
|
|
||||||
.catch(err => Promise.reject(err.message));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPackagePath(cwd: string, manifest: Manifest, options: IPackageOptions = {}): Promise<string> {
|
async function getPackagePath(cwd: string, manifest: Manifest, options: IPackageOptions = {}): Promise<string> {
|
||||||
|
@ -957,8 +948,8 @@ async function getPackagePath(cwd: string, manifest: Manifest, options: IPackage
|
||||||
export async function pack(options: IPackageOptions = {}): Promise<IPackageResult> {
|
export async function pack(options: IPackageOptions = {}): Promise<IPackageResult> {
|
||||||
const cwd = options.cwd || process.cwd();
|
const cwd = options.cwd || process.cwd();
|
||||||
|
|
||||||
let manifest = await readManifest(cwd);
|
const manifest = await readManifest(cwd);
|
||||||
manifest = await prepublish(cwd, manifest, options.useYarn);
|
await prepublish(cwd, manifest, options.useYarn);
|
||||||
|
|
||||||
const files = await collect(manifest, options);
|
const files = await collect(manifest, options);
|
||||||
const jsFiles = files.filter(f => /\.js$/i.test(f.path));
|
const jsFiles = files.filter(f => /\.js$/i.test(f.path));
|
||||||
|
@ -996,7 +987,7 @@ export async function packageCommand(options: IPackageOptions = {}): Promise<any
|
||||||
*/
|
*/
|
||||||
export function listFiles(cwd = process.cwd(), useYarn = false, packagedDependencies?: string[], ignoreFile?: string): Promise<string[]> {
|
export function listFiles(cwd = process.cwd(), useYarn = false, packagedDependencies?: string[], ignoreFile?: string): Promise<string[]> {
|
||||||
return readManifest(cwd)
|
return readManifest(cwd)
|
||||||
.then(manifest => collectFiles(cwd, useYarn, packagedDependencies, ignoreFile));
|
.then(() => collectFiles(cwd, useYarn, packagedDependencies, ignoreFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1005,6 +996,6 @@ export function listFiles(cwd = process.cwd(), useYarn = false, packagedDependen
|
||||||
export function ls(cwd = process.cwd(), useYarn = false, packagedDependencies?: string[], ignoreFile?: string): Promise<void> {
|
export function ls(cwd = process.cwd(), useYarn = false, packagedDependencies?: string[], ignoreFile?: string): Promise<void> {
|
||||||
return readManifest(cwd)
|
return readManifest(cwd)
|
||||||
.then(manifest => prepublish(cwd, manifest, useYarn))
|
.then(manifest => prepublish(cwd, manifest, useYarn))
|
||||||
.then(manifest => collectFiles(cwd, useYarn, packagedDependencies, ignoreFile))
|
.then(() => collectFiles(cwd, useYarn, packagedDependencies, ignoreFile))
|
||||||
.then(files => files.forEach(f => console.log(`${f}`)));
|
.then(files => files.forEach(f => console.log(`${f}`)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
import { HttpClient, HttpClientResponse } from 'typed-rest-client/HttpClient';
|
import { HttpClient, HttpClientResponse } from 'typed-rest-client/HttpClient';
|
||||||
import {
|
import { PublishedExtension, ExtensionQueryFlags, FilterCriteria, ExtensionQueryFilterType, TypeInfo } from 'azure-devops-node-api/interfaces/GalleryInterfaces';
|
||||||
PublishedExtension, ExtensionQueryFlags, FilterCriteria, SortOrderType,
|
|
||||||
SortByType, ExtensionQueryFilterType, TypeInfo
|
|
||||||
} from 'azure-devops-node-api/interfaces/GalleryInterfaces';
|
|
||||||
import { IHeaders } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces';
|
import { IHeaders } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces';
|
||||||
import { ContractSerializer } from 'azure-devops-node-api/Serialization';
|
import { ContractSerializer } from 'azure-devops-node-api/Serialization';
|
||||||
|
|
||||||
export interface ExtensionQuery {
|
export interface ExtensionQuery {
|
||||||
pageNumber?: number;
|
readonly pageNumber?: number;
|
||||||
pageSize?: number;
|
readonly pageSize?: number;
|
||||||
sortBy?: SortByType;
|
readonly flags?: ExtensionQueryFlags[];
|
||||||
sortOrder?: SortOrderType;
|
readonly criteria?: FilterCriteria[];
|
||||||
flags?: ExtensionQueryFlags[];
|
readonly assetTypes?: string[];
|
||||||
criteria?: FilterCriteria[];
|
|
||||||
assetTypes?: string[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PublicGalleryAPI {
|
export class PublicGalleryAPI {
|
||||||
|
@ -29,8 +24,6 @@ export class PublicGalleryAPI {
|
||||||
async extensionQuery({
|
async extensionQuery({
|
||||||
pageNumber = 1,
|
pageNumber = 1,
|
||||||
pageSize = 1,
|
pageSize = 1,
|
||||||
sortBy = SortByType.Relevance,
|
|
||||||
sortOrder = SortOrderType.Default,
|
|
||||||
flags = [],
|
flags = [],
|
||||||
criteria = [],
|
criteria = [],
|
||||||
assetTypes = [],
|
assetTypes = [],
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { ExtensionQueryFlags, PublishedExtension, ExtensionQueryFilterType, PagingDirection, SortByType, SortOrderType } from 'azure-devops-node-api/interfaces/GalleryInterfaces';
|
import { ExtensionQueryFlags, PublishedExtension } from 'azure-devops-node-api/interfaces/GalleryInterfaces';
|
||||||
import { pack, readManifest, IPackage } from './package';
|
import { pack, readManifest, IPackage } from './package';
|
||||||
import * as tmp from 'tmp';
|
import * as tmp from 'tmp';
|
||||||
import { getPublisher } from './store';
|
import { getPublisher } from './store';
|
||||||
import { getGalleryAPI, read, getPublishedUrl, log } from './util';
|
import { getGalleryAPI, read, getPublishedUrl, log } from './util';
|
||||||
import { validatePublisher } from './validation';
|
|
||||||
import { Manifest } from './manifest';
|
import { Manifest } from './manifest';
|
||||||
import * as denodeify from 'denodeify';
|
import * as denodeify from 'denodeify';
|
||||||
import * as yauzl from 'yauzl';
|
import * as yauzl from 'yauzl';
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { tableView, wordTrim } from './viewutils';
|
||||||
|
|
||||||
const pageSize = 100;
|
const pageSize = 100;
|
||||||
|
|
||||||
export async function search(searchText: string, json: boolean = false, pageNumber: number = 1): Promise<any> {
|
export async function search(searchText: string, json: boolean = false): Promise<any> {
|
||||||
const flags = [];
|
const flags = [];
|
||||||
const api = getPublicGalleryAPI();
|
const api = getPublicGalleryAPI();
|
||||||
const results = await api.extensionQuery({
|
const results = await api.extensionQuery({
|
||||||
|
|
|
@ -71,7 +71,7 @@ function _toVsixManifest(manifest: Manifest, files: IFile[]): Promise<string> {
|
||||||
const assets = _.flatten(processors.map(p => p.assets));
|
const assets = _.flatten(processors.map(p => p.assets));
|
||||||
const vsix = processors.reduce((r, p) => ({ ...r, ...p.vsix }), { assets });
|
const vsix = processors.reduce((r, p) => ({ ...r, ...p.vsix }), { assets });
|
||||||
|
|
||||||
return toVsixManifest(assets, vsix);
|
return toVsixManifest(vsix);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,9 @@ const columns = process.stdout.columns ? process.stdout.columns : 80;
|
||||||
// unicode charset. For now we use fallback icons when on windows.
|
// unicode charset. For now we use fallback icons when on windows.
|
||||||
const useFallbackIcons = process.platform === 'win32';
|
const useFallbackIcons = process.platform === 'win32';
|
||||||
|
|
||||||
export const icons = useFallbackIcons?
|
export const icons = useFallbackIcons
|
||||||
{
|
? { download: '\u{2193}', star: '\u{2665}', emptyStar: '\u{2022}', }
|
||||||
download: '\u{2193}',
|
: { download: '\u{2913}', star: '\u{2605}', emptyStar: '\u{2606}', };
|
||||||
star: '\u{2665}',
|
|
||||||
emptyStar: '\u{2022}',
|
|
||||||
} : {
|
|
||||||
download: '\u{2913}',
|
|
||||||
star: '\u{2605}',
|
|
||||||
emptyStar: '\u{2606}',
|
|
||||||
};
|
|
||||||
|
|
||||||
export function formatDate(date) { return date.toLocaleString(fixedLocale, format.date); }
|
export function formatDate(date) { return date.toLocaleString(fixedLocale, format.date); }
|
||||||
export function formatTime(date) { return date.toLocaleString(fixedLocale, format.time); }
|
export function formatTime(date) { return date.toLocaleString(fixedLocale, format.time); }
|
||||||
|
@ -53,11 +46,11 @@ export function wordWrap(text: string, width: number = columns): string {
|
||||||
return text
|
return text
|
||||||
.replace(/^\s+/, '')
|
.replace(/^\s+/, '')
|
||||||
.split('')
|
.split('')
|
||||||
.reduce(([out, buffer, pos], ch, i) => {
|
.reduce(([out, buffer, pos], ch) => {
|
||||||
const nl = pos === maxWidth ? `\n${indent}` : '';
|
const nl = pos === maxWidth ? `\n${indent}` : '';
|
||||||
const newPos: number = nl ? 0 : +pos + 1;
|
const newPos: number = nl ? 0 : +pos + 1;
|
||||||
return / |-|,|\./.test(ch) ?
|
return / |-|,|\./.test(ch) ?
|
||||||
[`${out}${buffer}${ch}${nl}`, '', newPos] : [`${out}${nl}`, buffer+ch, newPos];
|
[`${out}${buffer}${ch}${nl}`, '', newPos] : [`${out}${nl}`, buffer + ch, newPos];
|
||||||
}, [indent, '', 0])
|
}, [indent, '', 0])
|
||||||
.slice(0, 2)
|
.slice(0, 2)
|
||||||
.join('');
|
.join('');
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
"target": "es2015",
|
"target": "es2015",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"outDir": "out"
|
"outDir": "out",
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src"
|
"src"
|
||||||
|
|
Loading…
Add table
Reference in a new issue