Adding gulp and tslint infrastructure

This commit is contained in:
Jimmy Thomson 2016-01-25 11:26:25 -08:00
Родитель 9cf5eef212
Коммит 8ba55f4cea
20 изменённых файлов: 18335 добавлений и 77 удалений

6
.vscode/launch.json поставляемый
Просмотреть файл

@ -10,7 +10,8 @@
"--extensionDevelopmentPath=${workspaceRoot}" "--extensionDevelopmentPath=${workspaceRoot}"
], ],
"sourceMaps": true, "sourceMaps": true,
"outDir": "./out" "outDir": "./out",
"preLaunchTask": "build"
}, },
{ {
"name": "mock-debug server", "name": "mock-debug server",
@ -41,7 +42,8 @@
"--colors" "--colors"
], ],
"sourceMaps": true, "sourceMaps": true,
"outDir": "./out/" "outDir": "./out/",
"preLaunchTask": "build"
} }
] ]
} }

2
.vscode/settings.json поставляемый
Просмотреть файл

@ -3,6 +3,6 @@
"javascript.validate.enable": false, "javascript.validate.enable": false,
"files.trimTrailingWhitespace": true, "files.trimTrailingWhitespace": true,
"eslint.enable": false, "eslint.enable": false,
"editor.insertSpaces": false, "editor.insertSpaces": true,
"editor.tabSize": 4 "editor.tabSize": 4
} }

40
.vscode/tasks.json поставляемый
Просмотреть файл

@ -1,19 +1,25 @@
{ {
"version": "0.1.0", "version": "0.1.0",
"command": "gulp",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript "isShellCommand": true,
"command": "tsc", "tasks": [
{
// The command is a shell script "taskName": "watch",
"isShellCommand": true, "args": [],
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur. "isWatching": true,
"showOutput": "silent", "problemMatcher": [
"$tsc"
// Tell the tsc compiler to use the tsconfig.json from the open folder. ]
"args": ["-p", "."], },
{
// use the standard tsc problem matcher to find compile problems "taskName": "build",
// in the output. "args": [],
"problemMatcher": "$tsc" "isBuildCommand": true,
"isWatching": false,
"problemMatcher": [
"$tsc"
]
}
]
} }

57
gulpfile.js Normal file
Просмотреть файл

@ -0,0 +1,57 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
var child_process = require('child_process');
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var sourcemaps = require('gulp-sourcemaps');
var ts = require('gulp-typescript');
var log = require('gulp-util').log;
var os = require('os');
var path = require('path');
var Q = require('q');
var sources = [
'src',
'typings',
].map(function(tsFolder) { return tsFolder + '/**/*.ts'; })
.concat(['test/*.ts']);
gulp.task('build', function () {
var tsProject = ts.createProject('src/tsconfig.json');
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: 'file:///' + __dirname }))
.pipe(gulp.dest('out'));
});
gulp.task('watch', ['build'], function(cb) {
log('Watching build sources...');
return gulp.watch(sources, ['build']);
});
gulp.task('default', ['build']);
var lintSources = [
'src',
].map(function(tsFolder) { return tsFolder + '/**/*.ts'; });
var tslint = require('gulp-tslint');
gulp.task('tslint', function(){
return gulp.src(lintSources, { base: '.' })
.pipe(tslint())
.pipe(tslint.report('verbose'));
});
function test() {
throw new Error('No tests yet');
}
gulp.task('build-test', ['build'], test);
gulp.task('test', test);
gulp.task('watch-build-test', ['build', 'build-test'], function() {
return gulp.watch(sources, ['build', 'build-test']);
});

Просмотреть файл

@ -44,10 +44,11 @@
], ],
"debuggers": [ "debuggers": [
{ {
"type": "node", "type": "reactnative",
"enableBreakpointsFor": { "enableBreakpointsFor": {
"languageIds": [ "languageIds": [
"javascript", "javascript",
"javascriptreact",
"typescript", "typescript",
"typescriptreact" "typescriptreact"
] ]
@ -56,21 +57,13 @@
"initialConfigurations": [ "initialConfigurations": [
{ {
"program": "out/launch-react-native.js", "program": "${workspaceRoot}/.vscode/launch-react-native.js",
"name": "Run on Android", "name": "Run on Android",
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"platform": "node", "platform": "node",
"target": "device", "target": "device",
"sourceMaps": true "sourceMaps": true
},
{
"name": "Run on iOS",
"type": "node",
"request": "launch",
"platform": "node",
"target": "device",
"sourceMaps": true
} }
] ]
} }
@ -81,9 +74,9 @@
}, },
"dependencies": { "dependencies": {
"ios-sim": "^5.0.6", "ios-sim": "^5.0.6",
"lodash": "~4.0.0",
"plist-with-patches": "^0.5.1",
"q": "^1.4.1", "q": "^1.4.1",
"react-native": "^0.18.0",
"request": "^2.67.0",
"shelljs": "^0.5.3", "shelljs": "^0.5.3",
"vscode": "^0.10.7", "vscode": "^0.10.7",
"websocket": "^1.0.22" "websocket": "^1.0.22"
@ -97,11 +90,8 @@
"gulp-util": "^3.0.5", "gulp-util": "^3.0.5",
"mocha": "^2.3.3", "mocha": "^2.3.3",
"mockery": "^1.4.0", "mockery": "^1.4.0",
"rimraf": "^2.5.0",
"should": "^4.6.5", "should": "^4.6.5",
"sinon": "^1.17.2", "sinon": "^1.17.2",
"tslint": "^2.5.1", "tslint": "^2.5.1"
"typescript": "^1.6.2",
"vscode": "0.10.x"
} }
} }

Просмотреть файл

Просмотреть файл

@ -9,14 +9,15 @@ export function activate(context: vscode.ExtensionContext): void {
// check if package.json of user project has dependency on react-native // check if package.json of user project has dependency on react-native
// TODO: Change to a foreach if this implementation is appropriate
// Register react native commands // Register react native commands
context.subscriptions.push(vscode.commands.registerCommand('reactNative.runAndroid', context.subscriptions.push(vscode.commands.registerCommand('reactNative.runAndroid',
() => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, "runAndroid"))); () => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, 'runAndroid')));
context.subscriptions.push(vscode.commands.registerCommand('reactNative.runIos', context.subscriptions.push(vscode.commands.registerCommand('reactNative.runIos',
() => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, "runIos"))); () => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, 'runIos')));
context.subscriptions.push(vscode.commands.registerCommand('reactNative.startPackager', context.subscriptions.push(vscode.commands.registerCommand('reactNative.startPackager',
() => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, "startPackager"))); () => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, 'startPackager')));
context.subscriptions.push(vscode.commands.registerCommand('reactNative.stopPackager', context.subscriptions.push(vscode.commands.registerCommand('reactNative.stopPackager',
() => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, "stopPackager"))); () => ReactNativeCommandHelper.executeReactNativeCommand(vscode.workspace.rootPath, 'stopPackager')));
} }

Просмотреть файл

@ -1,13 +1,13 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "module": "commonjs",
"module": "commonjs", "noImplicitAny": false,
"moduleResolution": "node", "removeComments": false,
"sourceMap": true, "target": "es5",
"inlineSources": false, "sourceMap": true,
"outDir": "../out", "outDir": "out"
"noImplicitAny": false, },
"removeComments": false, "exclude": [
"preserveConstEnums": true "node_modules"
} ]
} }

16
src/typings/form-data/form-data.d.ts поставляемый Executable file
Просмотреть файл

@ -0,0 +1,16 @@
// Type definitions for form-data
// Project: https://github.com/felixge/node-form-data
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/form-data.d.ts
declare module "form-data" {
export class FormData {
append(key: string, value: any, options?: any): FormData;
getHeaders(): Object;
// TODO expand pipe
pipe(to: any): any;
submit(params: string|Object, callback: (error: any, response: any) => void): any;
}
}

16622
src/typings/lodash/lodash.d.ts поставляемый Executable file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

2
src/typings/node/node.d.ts поставляемый
Просмотреть файл

@ -1 +1 @@
/// <reference path="../../node_modules/vscode/typings/node.d.ts" /> /// <reference path="../../../node_modules/vscode/typings/node.d.ts" />

21
src/typings/plist-with-patches/plist-with-patches.d.ts поставляемый Executable file
Просмотреть файл

@ -0,0 +1,21 @@
/**
*******************************************************
* *
* Copyright (C) Microsoft. All rights reserved. *
* *
*******************************************************
*/
// Barebones typing for plist-with-patches, added as-needed
declare module "plist-with-patches" {
export function parseFileSync(filename: string): any;
/**
* generate an XML plist string from the input object
*
* @param object obj the object to convert
* @return string converted plist
*/
export function build(obj: any): string;
}

252
src/typings/request/request.d.ts поставляемый Executable file
Просмотреть файл

@ -0,0 +1,252 @@
// Type definitions for request
// Project: https://github.com/mikeal/request
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>, Joe Skeen <http://github.com/joeskeen>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts
/// <reference path="../node/node.d.ts" />
/// <reference path="../form-data/form-data.d.ts" />
declare module 'request' {
import stream = require('stream');
import http = require('http');
import FormData = require('form-data');
import url = require('url');
import fs = require('fs');
namespace request {
export interface RequestAPI<TRequest extends Request,
TOptions extends CoreOptions,
TUriUrlOptions> {
defaults(options: TOptions): RequestAPI<TRequest, TOptions, RequiredUriUrl>;
defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>;
(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
(uri: string, callback?: RequestCallback): TRequest;
(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
get(uri: string, callback?: RequestCallback): TRequest;
get(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
post(uri: string, callback?: RequestCallback): TRequest;
post(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
put(uri: string, callback?: RequestCallback): TRequest;
put(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
head(uri: string, callback?: RequestCallback): TRequest;
head(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
patch(uri: string, callback?: RequestCallback): TRequest;
patch(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
del(uri: string, callback?: RequestCallback): TRequest;
del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
forever(agentOptions: any, optionsArg: any): TRequest;
jar(): CookieJar;
cookie(str: string): Cookie;
initParams: any;
debug: boolean;
}
interface DefaultUriUrlRequestApi<TRequest extends Request,
TOptions extends CoreOptions,
TUriUrlOptions> extends RequestAPI<TRequest, TOptions, TUriUrlOptions> {
defaults(options: TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>;
(): TRequest;
get(): TRequest;
post(): TRequest;
put(): TRequest;
head(): TRequest;
patch(): TRequest;
del(): TRequest;
}
interface CoreOptions {
baseUrl?: string;
callback?: (error: any, response: http.IncomingMessage, body: any) => void;
jar?: any; // CookieJar
formData?: any; // Object
form?: any; // Object or string
auth?: AuthOptions;
oauth?: OAuthOptions;
aws?: AWSOptions;
hawk?: HawkOptions;
qs?: any;
json?: any;
multipart?: RequestPart[] | Multipart;
agentOptions?: any;
agentClass?: any;
forever?: any;
host?: string;
port?: number;
method?: string;
headers?: Headers;
body?: any;
followRedirect?: boolean | ((response: http.IncomingMessage) => boolean);
followAllRedirects?: boolean;
maxRedirects?: number;
encoding?: string;
pool?: any;
timeout?: number;
proxy?: any;
strictSSL?: boolean;
gzip?: boolean;
preambleCRLF?: boolean;
postambleCRLF?: boolean;
key?: Buffer;
cert?: Buffer;
passphrase?: string;
ca?: Buffer;
har?: HttpArchiveRequest;
useQuerystring?: boolean;
}
interface UriOptions {
uri: string;
}
interface UrlOptions {
url: string;
}
export type RequiredUriUrl = UriOptions | UrlOptions;
interface OptionalUriUrl {
uri?: string;
url?: string;
}
export type Options = RequiredUriUrl & CoreOptions;
export interface RequestCallback {
(error: any, response: http.IncomingMessage, body: any): void;
}
export interface HttpArchiveRequest {
url?: string;
method?: string;
headers?: NameValuePair[];
postData?: {
mimeType?: string;
params?: NameValuePair[];
}
}
export interface NameValuePair {
name: string;
value: string;
}
export interface Multipart {
chunked?: boolean;
data?: {
'content-type'?: string,
body: string
}[];
}
export interface RequestPart {
headers?: Headers;
body: any;
}
export interface Request extends stream.Stream {
readable: boolean;
writable: boolean;
getAgent(): http.Agent;
//start(): void;
//abort(): void;
pipeDest(dest: any): void;
setHeader(name: string, value: string, clobber?: boolean): Request;
setHeaders(headers: Headers): Request;
qs(q: Object, clobber?: boolean): Request;
form(): FormData.FormData;
form(form: any): Request;
multipart(multipart: RequestPart[]): Request;
json(val: any): Request;
aws(opts: AWSOptions, now?: boolean): Request;
auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request;
oauth(oauth: OAuthOptions): Request;
jar(jar: CookieJar): Request;
on(event: string, listener: Function): Request;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding: string, cb?: Function): boolean;
write(str: string, encoding?: string, fd?: string): boolean;
end(): void;
end(chunk: Buffer, cb?: Function): void;
end(chunk: string, cb?: Function): void;
end(chunk: string, encoding: string, cb?: Function): void;
pause(): void;
resume(): void;
abort(): void;
destroy(): void;
toJSON(): Object;
}
export interface Headers {
[key: string]: any;
}
export interface AuthOptions {
user?: string;
username?: string;
pass?: string;
password?: string;
sendImmediately?: boolean;
bearer?: string;
}
export interface OAuthOptions {
callback?: string;
consumer_key?: string;
consumer_secret?: string;
token?: string;
token_secret?: string;
verifier?: string;
}
export interface HawkOptions {
credentials: any;
}
export interface AWSOptions {
secret: string;
bucket?: string;
}
export interface CookieJar {
setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void
getCookieString(uri: string | url.Url): string
getCookies(uri: string | url.Url): Cookie[]
}
export interface CookieValue {
name: string;
value: any;
httpOnly: boolean;
}
export interface Cookie extends Array<CookieValue> {
constructor(name: string, req: Request): void;
str: string;
expires: Date;
path: string;
toString(): string;
}
}
var request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>;
export = request;
}

536
src/typings/shelljs/shelljs.d.ts поставляемый Executable file
Просмотреть файл

@ -0,0 +1,536 @@
// Type definitions for ShellJS v0.3.0
// Project: http://shelljs.org
// Definitions by: Niklas Mollenhauer <https://github.com/nikeee>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../node/node.d.ts"/>
declare module "shelljs"
{
import child = require("child_process");
/**
* Changes to directory dir for the duration of the script
* @param {string} dir Directory to change in.
*/
export function cd(dir: string): void;
/**
* Returns the current directory.
* @return {string} The current directory.
*/
export function pwd(): string;
/**
* Returns array of files in the given path, or in current directory if no path provided.
* @param {string[]} ...paths Paths to search.
* @return {string[]} An array of files in the given path(s).
*/
export function ls(...paths: string[]): string[];
/**
* Returns array of files in the given path, or in current directory if no path provided.
* @param {string} options Available options: -R (recursive), -A (all files, include files beginning with ., except for . and ..)
* @param {string[]} ...paths Paths to search.
* @return {string[]} An array of files in the given path(s).
*/
export function ls(options: string, ...paths: string[]): string[];
/**
* Returns array of files in the given path, or in current directory if no path provided.
* @param {string[]} paths Paths to search.
* @return {string[]} An array of files in the given path(s).
*/
export function ls(paths: string[]): string[];
/**
* Returns array of files in the given path, or in current directory if no path provided.
* @param {string} options Available options: -R (recursive), -A (all files, include files beginning with ., except for . and ..)
* @param {string[]} paths Paths to search.
* @return {string[]} An array of files in the given path(s).
*/
export function ls(options: string, paths: string[]): string[];
/**
* Returns array of all files (however deep) in the given paths.
* @param {string[]} ...path The path(s) to search.
* @return {string[]} An array of all files (however deep) in the given path(s).
*/
export function find(...path: string[]): string[];
/**
* Returns array of all files (however deep) in the given paths.
* @param {string[]} path The path(s) to search.
* @return {string[]} An array of all files (however deep) in the given path(s).
*/
export function find(path: string[]): string[];
/**
* Copies files. The wildcard * is accepted.
* @param {string} source The source.
* @param {string} dest The destination.
*/
export function cp(source: string, dest: string): void;
/**
* Copies files. The wildcard * is accepted.
* @param {string[]} source The source.
* @param {string} dest The destination.
*/
export function cp(source: string[], dest: string): void;
/**
* Copies files. The wildcard * is accepted.
* @param {string} options Available options: -f (force), -r, -R (recursive)
* @param {strin]} source The source.
* @param {string} dest The destination.
*/
export function cp(options: string, source: string, dest: string): void;
/**
* Copies files. The wildcard * is accepted.
* @param {string} options Available options: -f (force), -r, -R (recursive)
* @param {string[]} source The source.
* @param {string} dest The destination.
*/
export function cp(options: string, source: string[], dest: string): void;
/**
* Removes files. The wildcard * is accepted.
* @param {string[]} ...files Files to remove.
*/
export function rm(...files: string[]): void;
/**
* Removes files. The wildcard * is accepted.
* @param {string[]} files Files to remove.
*/
export function rm(files: string[]): void;
/**
* Removes files. The wildcard * is accepted.
* @param {string} options Available options: -f (force), -r, -R (recursive)
* @param {string[]} ...files Files to remove.
*/
export function rm(options: string, ...files: string[]): void;
/**
* Removes files. The wildcard * is accepted.
* @param {string} options Available options: -f (force), -r, -R (recursive)
* @param {string[]} ...files Files to remove.
*/
export function rm(options: string, files: string[]): void;
/**
* Moves files. The wildcard * is accepted.
* @param {string} source The source.
* @param {string} dest The destination.
*/
export function mv(source: string, dest: string): void;
/**
* Moves files. The wildcard * is accepted.
* @param {string[]} source The source.
* @param {string} dest The destination.
*/
export function mv(source: string[], dest: string): void;
/**
* Creates directories.
* @param {string[]} ...dir Directories to create.
*/
export function mkdir(...dir: string[]): void;
/**
* Creates directories.
* @param {string[]} dir Directories to create.
*/
export function mkdir(dir: string[]): void;
/**
* Creates directories.
* @param {string} options Available options: p (full paths, will create intermediate dirs if necessary)
* @param {string[]} ...dir The directories to create.
*/
export function mkdir(options: string, ...dir: string[]): void;
/**
* Creates directories.
* @param {string} options Available options: p (full paths, will create intermediate dirs if necessary)
* @param {string[]} dir The directories to create.
*/
export function mkdir(options: string, dir: string[]): void;
/**
* Evaluates expression using the available primaries and returns corresponding value.
* @param {string} option '-b': true if path is a block device; '-c': true if path is a character device; '-d': true if path is a directory; '-e': true if path exists; '-f': true if path is a regular file; '-L': true if path is a symboilc link; '-p': true if path is a pipe (FIFO); '-S': true if path is a socket
* @param {string} path The path.
* @return {boolean} See option parameter.
*/
export function test(option: string, path: string): boolean;
/**
* Returns a string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file). Wildcard * accepted.
* @param {string[]} ...files Files to use.
* @return {string} A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file).
*/
export function cat(...files: string[]): string;
/**
* Returns a string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file). Wildcard * accepted.
* @param {string[]} files Files to use.
* @return {string} A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file).
*/
export function cat(files: string[]): string;
// Does not work yet.
export interface String
{
/**
* Analogous to the redirection operator > in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc). Like Unix redirections, to() will overwrite any existing file!
* @param {string} file The file to use.
*/
to(file: string): void;
/**
* Analogous to the redirect-and-append operator >> in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc).
* @param {string} file The file to append to.
*/
toEnd(file: string): void;
}
/**
* Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement.
* @param {RegExp} searchRegex The regular expression to use for search.
* @param {string} replacement The replacement.
* @param {string} file The file to process.
* @return {string} The new string after replacement.
*/
export function sed(searchRegex: RegExp, replacement: string, file: string): string;
/**
* Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement.
* @param {string} searchRegex The regular expression to use for search.
* @param {string} replacement The replacement.
* @param {string} file The file to process.
* @return {string} The new string after replacement.
*/
export function sed(searchRegex: string, replacement: string, file: string): string;
/**
* Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement.
* @param {string} options Available options: -i (Replace contents of 'file' in-place. Note that no backups will be created!)
* @param {RegExp} searchRegex The regular expression to use for search.
* @param {string} replacement The replacement.
* @param {string} file The file to process.
* @return {string} The new string after replacement.
*/
export function sed(options: string, searchRegex: RegExp, replacement: string, file: string): string;
/**
* Reads an input string from file and performs a JavaScript replace() on the input using the given search regex and replacement string or function. Returns the new string after replacement.
* @param {string} options Available options: -i (Replace contents of 'file' in-place. Note that no backups will be created!)
* @param {string} searchRegex The regular expression to use for search.
* @param {string} replacement The replacement.
* @param {string} file The file to process.
* @return {string} The new string after replacement.
*/
export function sed(options: string, searchRegex: string, replacement: string, file: string): string;
/**
* Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted.
* @param {RegExp} regex_filter The regular expression to use.
* @param {string[]} ...files The files to process.
* @return {string} Returns a string containing all lines of the file that match the given regex_filter.
*/
export function grep(regex_filter: RegExp, ...files: string[]): string;
/**
* Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted.
* @param {RegExp} regex_filter The regular expression to use.
* @param {string[]} ...files The files to process.
* @return {string} Returns a string containing all lines of the file that match the given regex_filter.
*/
export function grep(regex_filter: RegExp, files: string[]): string;
/**
* Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted.
* @param {string} options Available options: -v (Inverse the sense of the regex and print the lines not matching the criteria.)
* @param {string} regex_filter The regular expression to use.
* @param {string[]} ...files The files to process.
* @return {string} Returns a string containing all lines of the file that match the given regex_filter.
*/
export function grep(options: string, regex_filter: string, ...files: string[]): string;
/**
* Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted.
* @param {string} options Available options: -v (Inverse the sense of the regex and print the lines not matching the criteria.)
* @param {string} regex_filter The regular expression to use.
* @param {string[]} files The files to process.
* @return {string} Returns a string containing all lines of the file that match the given regex_filter.
*/
export function grep(options: string, regex_filter: string, files: string[]): string;
/**
* Searches for command in the system's PATH. On Windows looks for .exe, .cmd, and .bat extensions.
* @param {string} command The command to search for.
* @return {string} Returns string containing the absolute path to the command.
*/
export function which(command: string): string;
/**
* Prints string to stdout, and returns string with additional utility methods like .to().
* @param {string[]} ...text The text to print.
* @return {string} Returns the string that was passed as argument.
*/
export function echo(...text: string[]): string;
/**
* Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
* @param {"+N"} dir Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
* @return {string[]} Returns an array of paths in the stack.
*/
export function pushd(dir: "+N"): string[];
/**
* Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
* @param {"-N"} dir Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
* @return {string[]} Returns an array of paths in the stack.
*/
export function pushd(dir: "-N"): string[];
/**
* Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
* @param {string} dir Makes the current working directory be the top of the stack, and then executes the equivalent of cd dir.
* @return {string[]} Returns an array of paths in the stack.
*/
export function pushd(dir: string): string[];
/**
* Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
* @param {string} options Available options: -n (Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated)
* @param {"+N"} dir Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
* @return {string[]} Returns an array of paths in the stack.
*/
export function pushd(options: string, dir: "+N"): string[];
/**
* Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
* @param {string} options Available options: -n (Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated)
* @param {"-N"} dir Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack.
* @return {string[]} Returns an array of paths in the stack.
*/
export function pushd(options: string, dir: "-N"): string[];
/**
* Save the current directory on the top of the directory stack and then cd to dir. With no arguments, pushd exchanges the top two directories. Returns an array of paths in the stack.
* @param {string} options Available options: -n (Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated)
* @param {string} dir Makes the current working directory be the top of the stack, and then executes the equivalent of cd dir.
* @return {string[]} Returns an array of paths in the stack.
*/
export function pushd(options: string, dir: string): string[];
/**
* When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
* @param {"+N"} dir Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero.
* @return {string[]} Returns an array of paths in the stack.
*/
export function popd(dir: "+N"): string[];
/**
* When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
* @return {string[]} Returns an array of paths in the stack.
*/
export function popd(): string[];
/**
* When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
* @param {"-N"} dir Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero.
* @return {string[]} Returns an array of paths in the stack.
*/
export function popd(dir: "-N"): string[];
/**
* When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
* @param {string} dir You can only use -N and +N.
* @return {string[]} Returns an array of paths in the stack.
*/
export function popd(dir: string): string[];
/**
* When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
* @param {string} options Available options: -n (Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated)
* @param {"+N"} dir Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero.
* @return {string[]} Returns an array of paths in the stack.
*/
export function popd(options: string, dir: "+N"): string[];
/**
* When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
* @param {string} options Available options: -n (Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated)
* @param {"-N"} dir Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero.
* @return {string[]} Returns an array of paths in the stack.
*/
export function popd(options: string, dir: "-N"): string[];
/**
* When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
* @param {string} options Available options: -n (Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated)
* @param {string} dir You can only use -N and +N.
* @return {string[]} Returns an array of paths in the stack.
*/
export function popd(options: string, dir: string): string[];
/**
* Clears the directory stack by deleting all of the elements.
* @param {"-c"} options Clears the directory stack by deleting all of the elements.
* @return {string[]} Returns an array of paths in the stack, or a single path if +N or -N was specified.
*/
export function dirs(options: "-c"): string[];
/**
* Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
* @param {"+N"} options Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero.
* @return {string[]} Returns an array of paths in the stack, or a single path if +N or -N was specified.
*/
export function dirs(options: "+N"): string;
/**
* Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
* @param {"-N"} options Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero.
* @return {string[]} Returns an array of paths in the stack, or a single path if +N or -N was specified.
*/
export function dirs(options: "-N"): string;
/**
* Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if +N or -N was specified.
* @param {string} options Available options: -c, -N, +N. You can only use those.
* @return {any} Returns an array of paths in the stack, or a single path if +N or -N was specified.
*/
export function dirs(options: string): any;
/**
* Links source to dest. Use -f to force the link, should dest already exist.
* @param {string} source The source.
* @param {string} dest The destination.
*/
export function ln(source: string, dest: string): void;
/**
* Links source to dest. Use -f to force the link, should dest already exist.
* @param {string} options Available options: s (symlink), f (force)
* @param {string} source The source.
* @param {string} dest The destination.
*/
export function ln(options: string, source: string, dest: string): void;
/**
* Exits the current process with the given exit code.
* @param {number} code The exit code.
*/
export function exit(code: number): void;
/**
* Object containing environment variables (both getter and setter). Shortcut to process.env.
*/
export var env: { [key: string]: string };
/**
* Executes the given command synchronously.
* @param {string} command The command to execute.
* @return {ExecOutputReturnValue} Returns an object containing the return code and output as string.
*/
export function exec(command: string): ExecOutputReturnValue;
/**
* Executes the given command synchronously.
* @param {string} command The command to execute.
* @param {ExecOptions} options Silence and synchronous options.
* @return {ExecOutputReturnValue | child.ChildProcess} Returns an object containing the return code and output as string, or if {async:true} was passed, a ChildProcess.
*/
export function exec(command: string, options: ExecOptions): ExecOutputReturnValue | child.ChildProcess;
/**
* Executes the given command synchronously.
* @param {string} command The command to execute.
* @param {ExecOptions} options Silence and synchronous options.
* @param {ExecCallback} callback Receives code and output asynchronously.
*/
export function exec(command: string, options: ExecOptions, callback: ExecCallback): child.ChildProcess;
/**
* Executes the given command synchronously.
* @param {string} command The command to execute.
* @param {ExecCallback} callback Receives code and output asynchronously.
*/
export function exec(command: string, callback: ExecCallback): child.ChildProcess;
export interface ExecCallback {
(code: number, output: string): any;
}
export interface ExecOptions {
silent?: boolean;
async?: boolean;
}
export interface ExecOutputReturnValue
{
code: number;
output: string;
}
/**
* Alters the permissions of a file or directory by either specifying the absolute permissions in octal form or expressing the changes in symbols. This command tries to mimic the POSIX behavior as much as possible. Notable exceptions:
* - In symbolic modes, 'a-r' and '-r' are identical. No consideration is given to the umask.
* - There is no "quiet" option since default behavior is to run silent.
* @param {number} octalMode The access mode. Octal.
* @param {string} file The file to use.
*/
export function chmod(octalMode: number, file: string): void;
/**
* Alters the permissions of a file or directory by either specifying the absolute permissions in octal form or expressing the changes in symbols. This command tries to mimic the POSIX behavior as much as possible. Notable exceptions:
* - In symbolic modes, 'a-r' and '-r' are identical. No consideration is given to the umask.
* - There is no "quiet" option since default behavior is to run silent.
* @param {string} mode The access mode. Can be an octal string or a symbolic mode string.
* @param {string} file The file to use.
*/
export function chmod(mode: string, file: string): void;
// Non-Unix commands
/**
* Searches and returns string containing a writeable, platform-dependent temporary directory. Follows Python's tempfile algorithm.
* @return {string} The temp file path.
*/
export function tempdir(): string;
/**
* Tests if error occurred in the last command.
* @return {string} Returns null if no error occurred, otherwise returns string explaining the error
*/
export function error(): string;
// Configuration
interface ShellConfig
{
/**
* Suppresses all command output if true, except for echo() calls. Default is false.
* @type {boolean}
*/
silent: boolean;
/**
* If true the script will die on errors. Default is false.
* @type {boolean}
*/
fatal: boolean;
}
/**
* The shelljs configuration.
* @type {ShellConfig}
*/
export var config: ShellConfig;
}

2
src/typings/vscode-typings.d.ts поставляемый
Просмотреть файл

@ -1 +1 @@
/// <reference path="../node_modules/vscode/typings/index.d.ts" /> /// <reference path="../../node_modules/vscode/typings/index.d.ts" />

658
src/typings/websocket/websocket.d.ts поставляемый Executable file
Просмотреть файл

@ -0,0 +1,658 @@
// Type definitions for websocket
// Project: https://github.com/Worlize/WebSocket-Node
// Definitions by: Paul Loyd <https://github.com/loyd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "websocket" {
import events = require('events');
import http = require('http');
import net = require('net');
import url = require('url');
export interface IStringified {
toString: (...args: any[]) => string;
}
export interface IConfig {
/**
* The maximum allowed received frame size in bytes.
* Single frame messages will also be limited to this maximum.
*/
maxReceivedFrameSize?: number;
/** The maximum allowed aggregate message size (for fragmented messages) in bytes */
maxReceivedMessageSize?: number;
/**
* Whether or not to fragment outgoing messages. If true, messages will be
* automatically fragmented into chunks of up to `fragmentationThreshold` bytes.
* @default true
*/
fragmentOutgoingMessages?: boolean;
/**
* The maximum size of a frame in bytes before it is automatically fragmented.
* @default 16KiB
*/
fragmentationThreshold?: number;
/**
* If true, fragmented messages will be automatically assembled and the full
* message will be emitted via a `message` event. If false, each frame will be
* emitted on the `connection` object via a `frame` event and the application
* will be responsible for aggregating multiple fragmented frames. Single-frame
* messages will emit a `message` event in addition to the `frame` event.
* @default true
*/
assembleFragments?: boolean;
/**
* The number of milliseconds to wait after sending a close frame for an
* `acknowledgement` to come back before giving up and just closing the socket.
* @default 5000
*/
closeTimeout?: number;
}
export interface IServerConfig extends IConfig {
/** The http server instance to attach to */
httpServer: http.Server;
/**
* The maximum allowed received frame size in bytes.
* Single frame messages will also be limited to this maximum.
* @default 64KiB
*/
maxReceivedFrameSize?: number;
/**
* The maximum allowed aggregate message size (for fragmented messages) in bytes.
* @default 1MiB
*/
maxReceivedMessageSize?: number;
/**
* If true, the server will automatically send a ping to all clients every
* `keepaliveInterval` milliseconds. Each client has an independent `keepalive`
* timer, which is reset when any data is received from that client.
* @default true
*/
keepalive?: boolean;
/**
* The interval in milliseconds to send `keepalive` pings to connected clients.
* @default 20000
*/
keepaliveInterval?: number;
/**
* If true, the server will consider any connection that has not received any
* data within the amount of time specified by `keepaliveGracePeriod` after a
* `keepalive` ping has been sent. Ignored if `keepalive` is false.
* @default true
*/
dropConnectionOnKeepaliveTimeout?: boolean;
/**
* The amount of time to wait after sending a `keepalive` ping before closing
* the connection if the connected peer does not respond. Ignored if `keepalive`
* or `dropConnectionOnKeepaliveTimeout` are false. The grace period timer is
* reset when any data is received from the client.
* @default 10000
*/
keepaliveGracePeriod?: number;
/**
* If this is true, websocket connections will be accepted regardless of the path
* and protocol specified by the client. The protocol accepted will be the first
* that was requested by the client.
* @default false
*/
autoAcceptConnections?: boolean;
/**
* The Nagle Algorithm makes more efficient use of network resources by introducing a
* small delay before sending small packets so that multiple messages can be batched
* together before going onto the wire. This however comes at the cost of latency.
* @default true
*/
disableNagleAlgorithm?: boolean;
}
export class server extends events.EventEmitter {
config: IServerConfig;
connections: connection[];
constructor(serverConfig?: IServerConfig);
/** Send binary message for each connection */
broadcast(data: Buffer): void;
/** Send UTF-8 message for each connection */
broadcast(data: IStringified): void;
/** Send binary message for each connection */
broadcastBytes(data: Buffer): void;
/** Send UTF-8 message for each connection */
broadcastUTF(data: IStringified): void;
/** Attach the `server` instance to a Node http.Server instance */
mount(serverConfig: IServerConfig): void;
/**
* Detach the `server` instance from the Node http.Server instance.
* All existing connections are left alone and will not be affected,
* but no new WebSocket connections will be accepted.
*/
unmount(): void;
/** Close all open WebSocket connections */
closeAllConnections(): void;
/** Close all open WebSocket connections and unmount the server */
shutDown(): void;
// Events
on(event: string, listener: () => void): server;
on(event: 'request', cb: (request: request) => void): server;
on(event: 'connect', cb: (connection: connection) => void): server;
on(event: 'close', cb: (connection: connection, reason: number, desc: string) => void): server;
addListener(event: string, listener: () => void): server;
addListener(event: 'request', cb: (request: request) => void): server;
addListener(event: 'connect', cb: (connection: connection) => void): server;
addListener(event: 'close', cb: (connection: connection, reason: number, desc: string) => void): server;
}
export interface ICookie {
name: string;
value: string;
path?: string;
domain?: string;
expires?: Date;
maxage?: number;
secure?: boolean;
httponly?: boolean;
}
export interface IExtension {
name: string;
value: string;
}
export class request extends events.EventEmitter {
/** A reference to the original Node HTTP request object */
httpRequest: http.ClientRequest;
/** This will include the port number if a non-standard port is used */
host: string;
/** A string containing the path that was requested by the client */
resource: string;
/** `Sec-WebSocket-Key` */
key: string;
/** Parsed resource, including the query string parameters */
resourceURL: url.Url;
/**
* Client's IP. If an `X-Forwarded-For` header is present, the value will be taken
* from that header to facilitate WebSocket servers that live behind a reverse-proxy
*/
remoteAddress: string;
/**
* If the client is a web browser, origin will be a string containing the URL
* of the page containing the script that opened the connection.
* If the client is not a web browser, origin may be `null` or "*".
*/
origin: string;
/** The version of the WebSocket protocol requested by the client */
webSocketVersion: number;
/** An array containing a list of extensions requested by the client */
requestedExtensions: any[];
cookies: ICookie[];
socket: net.Socket;
/**
* List of strings that indicate the subprotocols the client would like to speak.
* The server should select the best one that it can support from the list and
* pass it to the `accept` function when accepting the connection.
* Note that all the strings in the `requestedProtocols` array will have been
* converted to lower case.
*/
requestedProtocols: string[];
protocolFullCaseMap: {[key: string]: string};
constructor(socket: net.Socket, httpRequest: http.ClientRequest, config: IServerConfig);
/**
* After inspecting the `request` properties, call this function on the
* request object to accept the connection. If you don't have a particular subprotocol
* you wish to speak, you may pass `null` for the `acceptedProtocol` parameter.
*
* @param [acceptedProtocol] case-insensitive value that was requested by the client
*/
accept(acceptedProtocol?: string, allowedOrigin?: string, cookies?: ICookie[]): connection;
/**
* Reject connection.
* You may optionally pass in an HTTP Status code (such as 404) and a textual
* description that will be sent to the client in the form of an
* `X-WebSocket-Reject-Reason` header.
*/
reject(httpStatus?: number, reason?: string): void;
// Events
on(event: string, listener: () => void): request;
on(event: 'requestAccepted', cb: (connection: connection) => void): request;
on(event: 'requestRejected', cb: () => void): request;
addListener(event: string, listener: () => void): request;
addListener(event: 'requestAccepted', cb: (connection: connection) => void): request;
addListener(event: 'requestRejected', cb: () => void): request;
}
export interface IMessage {
type: string;
utf8Data?: string;
binaryData?: Buffer;
}
export interface IBufferList extends events.EventEmitter {
encoding: string;
length: number;
write(buf: Buffer): boolean;
end(buf: Buffer): void;
/**
* For each buffer, perform some action.
* If fn's result is a true value, cut out early.
*/
forEach(fn: (buf: Buffer) => boolean): void;
/** Create a single buffer out of all the chunks */
join(start: number, end: number): Buffer;
/** Join all the chunks to existing buffer */
joinInto(buf: Buffer, offset: number, start: number, end: number): Buffer;
/**
* Advance the buffer stream by `n` bytes.
* If `n` the aggregate advance offset passes the end of the buffer list,
* operations such as `take` will return empty strings until enough data is pushed.
*/
advance(n: number): IBufferList;
/**
* Take `n` bytes from the start of the buffers.
* If there are less than `n` bytes in all the buffers or `n` is undefined,
* returns the entire concatenated buffer string.
*/
take(n: number, encoding?: string): any;
take(encoding?: string): any;
// Events
on(event: string, listener: () => void): IBufferList;
on(event: 'advance', cb: (n: number) => void): IBufferList;
on(event: 'write', cb: (buf: Buffer) => void): IBufferList;
addListener(event: string, listener: () => void): IBufferList;
addListener(event: 'advance', cb: (n: number) => void): IBufferList;
addListener(event: 'write', cb: (buf: Buffer) => void): IBufferList;
}
class connection extends events.EventEmitter {
static CLOSE_REASON_NORMAL: number;
static CLOSE_REASON_GOING_AWAY: number;
static CLOSE_REASON_PROTOCOL_ERROR: number;
static CLOSE_REASON_UNPROCESSABLE_INPUT: number;
static CLOSE_REASON_RESERVED: number;
static CLOSE_REASON_NOT_PROVIDED: number;
static CLOSE_REASON_ABNORMAL: number;
static CLOSE_REASON_INVALID_DATA: number;
static CLOSE_REASON_POLICY_VIOLATION: number;
static CLOSE_REASON_MESSAGE_TOO_BIG: number;
static CLOSE_REASON_EXTENSION_REQUIRED: number;
/**
* After the connection is closed, contains a textual description of the reason for
* the connection closure, or `null` if the connection is still open.
*/
closeDescription: string;
/**
* After the connection is closed, contains the numeric close reason status code,
* or `-1` if the connection is still open.
*/
closeReasonCode: number;
/**
* The subprotocol that was chosen to be spoken on this connection. This field
* will have been converted to lower case.
*/
protocol: string;
config: IConfig;
socket: net.Socket;
maskOutgoingPackets: boolean;
maskBytes: Buffer;
frameHeader: Buffer;
bufferList: IBufferList;
currentFrame: frame;
fragmentationSize: number;
frameQueue: frame[];
state: string;
waitingForCloseResponse: boolean;
closeTimeout: number;
assembleFragments: number;
maxReceivedMessageSize: number;
outputPaused: boolean;
bytesWaitingToFlush: number;
socketHadError: boolean;
/** An array of extensions that were negotiated for this connection */
extensions: IExtension[];
/**
* The IP address of the remote peer as a string. In the case of a server,
* the `X-Forwarded-For` header will be respected and preferred for the purposes
* of populating this field. If you need to get to the actual remote IP address,
* `socket.remoteAddress` will provide it.
*/
remoteAddress: string;
/** The version of the WebSocket protocol requested by the client */
webSocketVersion: number;
/** Whether or not the connection is still connected. Read-only */
connected: boolean;
constructor(socket: net.Socket, extensions: IExtension[], protocol: string,
maskOutgoingPackets: boolean, config: IConfig);
/**
* Close the connection. A close frame will be sent to the remote peer indicating
* that we wish to close the connection, and we will then wait for up to
* `config.closeTimeout` milliseconds for an acknowledgment from the remote peer
* before terminating the underlying socket connection.
*/
close(): void;
/**
* Send a close frame to the remote peer and immediately close the socket without
* waiting for a response. This should generally be used only in error conditions.
*/
drop(reasonCode?: number, description?: string): void;
/**
* Immediately sends the specified string as a UTF-8 WebSocket message to the remote
* peer. If `config.fragmentOutgoingMessages` is true the message may be sent as
* multiple fragments if it exceeds `config.fragmentationThreshold` bytes.
*/
sendUTF(data: IStringified): void;
/**
* Immediately sends the specified Node Buffer object as a Binary WebSocket message
* to the remote peer. If config.fragmentOutgoingMessages is true the message may be
* sent as multiple fragments if it exceeds config.fragmentationThreshold bytes.
*/
sendBytes(buffer: Buffer): void;
/** Auto-detect the data type and send UTF-8 or Binary message */
send(data: Buffer): void;
send(data: IStringified): void;
/** Sends a ping frame. Ping frames must not exceed 125 bytes in length. */
ping(data: Buffer): void;
ping(data: IStringified): void;
/**
* Sends a pong frame. Pong frames may be sent unsolicited and such pong frames will
* trigger no action on the receiving peer. Pong frames sent in response to a ping
* frame must mirror the payload data of the ping frame exactly.
* The `connection` object handles this internally for you, so there should
* be no need to use this method to respond to pings.
* Pong frames must not exceed 125 bytes in length.
*/
pong(buffer: Buffer): void;
/**
* Serializes a `frame` object into binary data and immediately sends it to
* the remote peer. This is an advanced function, requiring you to manually compose
* your own `frame`. You should probably use sendUTF or sendBytes instead.
*/
sendFrame(frame: frame): void;
/** Set or reset the `keepalive` timer when data is received */
setKeepaliveTimer(): void;
setGracePeriodTimer(): void;
setCloseTimer(): void;
clearCloseTimer(): void;
processFrame(frame: frame): void;
fragmentAndSend(frame: frame, cb?: (err: Error) => void): void;
sendCloseFrame(reasonCode: number, reasonText: string, force: boolean): void;
sendCloseFrame(): void;
sendFrame(frame: frame, force: boolean, cb?: (msg: string) => void): void;
sendFrame(frame: frame, cb?: (msg: string) => void): void;
// Events
on(event: string, listener: () => void): connection;
on(event: 'message', cb: (data: IMessage) => void): connection;
on(event: 'frame', cb: (frame: frame) => void): connection;
on(event: 'close', cb: (code: number, desc: string) => void): connection;
on(event: 'error', cb: (err: Error) => void): connection;
addListener(event: string, listener: () => void): connection;
addListener(event: 'message', cb: (data: IMessage) => void): connection;
addListener(event: 'frame', cb: (frame: frame) => void): connection;
addListener(event: 'close', cb: (code: number, desc: string) => void): connection;
addListener(event: 'error', cb: (err: Error) => void): connection;
}
class frame {
/** Whether or not this is last frame in a fragmentation sequence */
fin: boolean;
/**
* Represents the RSV1 field in the framing. Setting this to true will result in
* a Protocol Error on the receiving peer.
*/
rsv1: boolean;
/**
* Represents the RSV1 field in the framing. Setting this to true will result in
* a Protocol Error on the receiving peer.
*/
rsv2: boolean;
/**
* Represents the RSV1 field in the framing. Setting this to true will result in
* a Protocol Error on the receiving peer.
*/
rsv3: boolean;
/**
* Whether or not this frame is (or should be) masked. For outgoing frames, when
* connected as a client, this flag is automatically forced to true by `connection`.
* Outgoing frames sent from the server-side of a connection are not masked.
*/
mask: number;
/**
* Identifies which kind of frame this is.
*
* Hex - Dec - Description
* 0x00 - 0 - Continuation
* 0x01 - 1 - Text Frame
* 0x02 - 2 - Binary Frame
* 0x08 - 8 - Close Frame
* 0x09 - 9 - Ping Frame
* 0x0A - 10 - Pong Frame
*/
opcode: number;
/**
* Identifies the length of the payload data on a received frame.
* When sending a frame, will be automatically calculated from `binaryPayload` object.
*/
length: number;
/**
* The binary payload data.
* Even text frames are sent with a Buffer providing the binary payload data.
*/
binaryPayload: Buffer;
maskBytes: Buffer;
frameHeader: Buffer;
config: IConfig;
maxReceivedFrameSize: number;
protocolError: boolean;
frameTooLarge: boolean;
invalidCloseFrameLength: boolean;
closeStatus: number;
addData(bufferList: IBufferList): boolean;
throwAwayPayload(bufferList: IBufferList): boolean;
toBuffer(nullMask: boolean): Buffer;
}
export interface IClientConfig extends IConfig {
/**
* Which version of the WebSocket protocol to use when making the connection.
* Currently supported values are 8 and 13. This option will be removed once the
* protocol is finalized by the IETF It is only available to ease the transition
* through the intermediate draft protocol versions. The only thing this affects
* the name of the Origin header.
* @default 13
*/
webSocketVersion?: number;
/**
* The maximum allowed received frame size in bytes.
* Single frame messages will also be limited to this maximum.
* @default 1MiB
*/
maxReceivedFrameSize?: number;
/**
* The maximum allowed aggregate message size (for fragmented messages) in bytes.
* @default 8MiB
*/
maxReceivedMessageSize?: number;
}
class client extends events.EventEmitter {
protocols: string[];
origin: string;
url: url.Url;
secure: boolean;
socket: net.Socket;
response: http.ClientResponse;
constructor(clientConfig?: IClientConfig);
/**
* Establish a connection. The remote server will select the best subprotocol that
* it supports and send that back when establishing the connection.
*
* @param [origin] can be used in user-agent scenarios to identify the page containing
* any scripting content that caused the connection to be requested.
* @param requestUrl should be a standard websocket url
*/
connect(requestUrl: url.Url, protocols?: string[], origin?: string, headers?: any[]): void;
connect(requestUrl: string, protocols?: string[], origin?: string, headers?: any[]): void;
connect(requestUrl: url.Url, protocols?: string, origin?: string, headers?: any[]): void;
connect(requestUrl: string, protocols?: string, origin?: string, headers?: any[]): void;
// Events
on(event: string, listener: () => void): client;
on(event: 'connect', cb: (connection: connection) => void): client;
on(event: 'connectFailed', cb: (err: Error) => void): client;
addListener(event: string, listener: () => void): client;
addListener(event: 'connect', cb: (connection: connection) => void): client;
addListener(event: 'connectFailed', cb: (err: Error) => void): client;
}
class routerRequest extends events.EventEmitter {
/** A reference to the original Node HTTP request object */
httpRequest: http.ClientRequest;
/** A string containing the path that was requested by the client */
resource: string;
/** Parsed resource, including the query string parameters */
resourceURL: url.Url;
/**
* Client's IP. If an `X-Forwarded-For` header is present, the value will be taken
* from that header to facilitate WebSocket servers that live behind a reverse-proxy
*/
remoteAddress: string;
/**
* If the client is a web browser, origin will be a string containing the URL
* of the page containing the script that opened the connection.
* If the client is not a web browser, origin may be `null` or "*".
*/
origin: string;
/** The version of the WebSocket protocol requested by the client */
webSocketVersion: number;
/** An array containing a list of extensions requested by the client */
requestedExtensions: any[];
cookies: ICookie[];
constructor(webSocketRequest: request, resolvedProtocol: string);
/**
* After inspecting the `request` properties, call this function on the
* request object to accept the connection. If you don't have a particular subprotocol
* you wish to speak, you may pass `null` for the `acceptedProtocol` parameter.
*
* @param [acceptedProtocol] case-insensitive value that was requested by the client
*/
accept(acceptedProtocol?: string, allowedOrigin?: string, cookies?: ICookie[]): connection;
/**
* Reject connection.
* You may optionally pass in an HTTP Status code (such as 404) and a textual
* description that will be sent to the client in the form of an
* `X-WebSocket-Reject-Reason` header.
*/
reject(httpStatus?: number, reason?: string): void;
// Events
on(event: string, listener: () => void): request;
on(event: 'requestAccepted', cb: (connection: connection) => void): request;
on(event: 'requestRejected', cb: () => void): request;
addListener(event: string, listener: () => void): request;
addListener(event: 'requestAccepted', cb: (connection: connection) => void): request;
addListener(event: 'requestRejected', cb: () => void): request;
}
interface IRouterConfig {
/*
* The WebSocketServer instance to attach to.
*/
server: server
}
class router extends events.EventEmitter {
constructor(config?: IRouterConfig);
/** Attach to WebSocket server */
attachServer(server: server): void;
/** Detach from WebSocket server */
detachServer(): void;
mount(path: string, cb: (request: routerRequest) => void): void;
mount(path: string, protocol: string, cb: (request: routerRequest) => void): void;
mount(path: RegExp, cb: (request: routerRequest) => void): void;
mount(path: RegExp, protocol: string, cb: (request: routerRequest) => void): void;
unmount(path: string, protocol?: string): void;
unmount(path: RegExp, protocol?: string): void;
}
export var version: string;
export var constants: {
DEBUG: boolean;
};
}

Просмотреть файл

@ -6,7 +6,7 @@ import * as os from 'os';
import {window} from 'vscode'; import {window} from 'vscode';
export class ReactNativeCommandHelper { export class ReactNativeCommandHelper {
private static CORDOVA_CMD_NAME = "react-native"; private static CORDOVA_CMD_NAME = 'react-native';
public static executeReactNativeCommand(projectRoot: string, command: string) { public static executeReactNativeCommand(projectRoot: string, command: string) {

Просмотреть файл

@ -1,14 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"removeComments": false,
"target": "ES5",
"sourceMap": true,
"outDir": "out"
},
"exclude": [
"node_modules",
"debugger/testapp/node_modules"
]
}

111
tslint.json Normal file
Просмотреть файл

@ -0,0 +1,111 @@
{
"rules": {
"align": [
true,
"parameters",
"statements"
],
"ban": false,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": false,
"forin": true,
"indent": [
true,
"spaces"
],
"jsdoc-format": true,
"label-position": true,
"label-undefined": true,
"max-line-length": [
false,
140
],
"member-access": true,
"member-ordering": [
true,
"variables-before-functions"
],
"no-any": false,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-inferrable-types": false,
"no-internal-module": false,
"no-keyword-named-variables": true,
"no-require-imports": false,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-switch-case-fall-through": false,
"no-trailing-whitespace": true,
"no-unreachable": true,
"no-unused-expression": true,
"no-unused-variable": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"no-var-requires": true,
"object-literal-sort-keys": true,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": true,
"switch-default": true,
"trailing-comma": [
true,
{
"multiline": "always",
"singleline": "never"
}
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}