From ee373b10745c1324ebc30d6c302ccc10cc6d6786 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Sat, 14 Jan 2017 21:13:18 +0100 Subject: [PATCH 1/8] Add definitions for shipit, shipit-utils and express-rate-limit. --- .../express-rate-limit-tests.ts | 25 ++++++++ express-rate-limit/index.d.ts | 37 +++++++++++ express-rate-limit/tsconfig.json | 20 ++++++ shipit-utils/index.d.ts | 22 +++++++ shipit-utils/shipit-utils-tests.ts | 11 ++++ shipit-utils/tsconfig.json | 20 ++++++ shipit/index.d.ts | 61 +++++++++++++++++++ shipit/shipit-cli-tests.ts | 50 +++++++++++++++ shipit/tsconfig.json | 20 ++++++ 9 files changed, 266 insertions(+) create mode 100644 express-rate-limit/express-rate-limit-tests.ts create mode 100644 express-rate-limit/index.d.ts create mode 100644 express-rate-limit/tsconfig.json create mode 100644 shipit-utils/index.d.ts create mode 100644 shipit-utils/shipit-utils-tests.ts create mode 100644 shipit-utils/tsconfig.json create mode 100644 shipit/index.d.ts create mode 100644 shipit/shipit-cli-tests.ts create mode 100644 shipit/tsconfig.json diff --git a/express-rate-limit/express-rate-limit-tests.ts b/express-rate-limit/express-rate-limit-tests.ts new file mode 100644 index 0000000000..761a6d23f8 --- /dev/null +++ b/express-rate-limit/express-rate-limit-tests.ts @@ -0,0 +1,25 @@ +import RateLimit = require("express-rate-limit"); + +var apiLimiter = new RateLimit({ + windowMs: 15 * 60 * 1000, // 15 minutes + max: 100, + delayMs: 0 // disabled +}); + +var createAccountLimiter = new RateLimit({ + windowMs: 60 * 60 * 1000, // 1 hour window + delayAfter: 1, // begin slowing down responses after the first request + delayMs: 3 * 1000, // slow down subsequent responses by 3 seconds per request + max: 5, // start blocking after 5 requests + message: "Too many accounts created from this IP, please try again after an hour" +}); + +class SomeStore implements RateLimit.Store { + incr(key: string, cb: RateLimit.StoreIncrementCallback) { } + resetAll() { } + resetKey(key: string) { }; +}; + +var limiterWithStore = new RateLimit({ + store: new SomeStore() +}); diff --git a/express-rate-limit/index.d.ts b/express-rate-limit/index.d.ts new file mode 100644 index 0000000000..57eb003694 --- /dev/null +++ b/express-rate-limit/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for express-rate-limit 2.6.0 +// Project: https://github.com/nfriedly/express-rate-limit +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import express = require("express"); + +declare namespace RateLimit { + type StoreIncrementCallback = (err?: {}, hits?: number) => void; + + export interface Store { + incr: (key: string, cb: StoreIncrementCallback) => void; + resetAll: () => void; + resetKey: (key: string) => void; + } + + export interface Options { + delayAfter?: number; + delayMs?: number; + headers?: boolean; + keyGenerator?: Function; + max?: number; + message?: string; + statusCode?: number; + store?: Store; + windowMs?: number; + } +} + +interface RateLimitStatic { + new(options: RateLimit.Options): express.RequestHandler; +} + +declare var RateLimit: RateLimitStatic; +export = RateLimit; diff --git a/express-rate-limit/tsconfig.json b/express-rate-limit/tsconfig.json new file mode 100644 index 0000000000..560edfef9d --- /dev/null +++ b/express-rate-limit/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-rate-limit-tests.ts" + ] +} diff --git a/shipit-utils/index.d.ts b/shipit-utils/index.d.ts new file mode 100644 index 0000000000..a66b681c37 --- /dev/null +++ b/shipit-utils/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for shipit-utils 1.4.0 +// Project: https://github.com/shipitjs/shipit-utils +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "shipit-utils" { + import shipit = require("shipit-cli"); + + type GruntOrShipit = typeof shipit | {}; + + export function equalValues(value: any[]): void; + + export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; + export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; + + export function registerTask(gruntOrShipit: GruntOrShipit, name: string, task: Function): typeof shipit; + export function registerTask(gruntOrShipit: GruntOrShipit, name: string, dependencies: string[]): typeof shipit; + + export function runTask(gruntOrShipit: {}): void; +} diff --git a/shipit-utils/shipit-utils-tests.ts b/shipit-utils/shipit-utils-tests.ts new file mode 100644 index 0000000000..15f0d5547b --- /dev/null +++ b/shipit-utils/shipit-utils-tests.ts @@ -0,0 +1,11 @@ +import shipit = require("shipit-cli"); +import utils = require("shipit-utils"); + +var originalShipit = utils.getShipit(shipit); + +var task = () => { + return shipit.local("sleep 10s"); +}; + +utils.registerTask(originalShipit, "myTask", task); +utils.registerTask(originalShipit, "myTask", ["some", "other", "tasks"]); diff --git a/shipit-utils/tsconfig.json b/shipit-utils/tsconfig.json new file mode 100644 index 0000000000..fa4b1ce3b6 --- /dev/null +++ b/shipit-utils/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shipit-utils-tests.ts" + ] +} diff --git a/shipit/index.d.ts b/shipit/index.d.ts new file mode 100644 index 0000000000..e0a528a2f2 --- /dev/null +++ b/shipit/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for shipit 1.5.1 +// Project: https://github.com/shipitjs/shipit +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "shipit-cli" { + import shipit = require("shipit-cli"); + + import * as fs from "fs"; + import * as child_process from "child_process"; + + type LocalOrRemoteCommand = (command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void) => PromiseLike; + type TaskExecution = (name: string, depsOrFn: string[] | Function, fn: Function) => any; + + export interface Options { + environment: string; + stderr: fs.WriteStream; + stdout: fs.WriteStream; + } + + export interface ShipitLocal { + child: child_process.ChildProcess; + stderr: fs.WriteStream; + stdout: fs.WriteStream; + } + + export interface Tasks { + [name: string]: Task; + } + + export interface Task { + blocking: boolean; + dep: string[]; + fn: Function; + name: string; + } + + export function blTask(name: string, depsOrFn: string[] | Function, fn?: Function): any; + export function emit(name: string): any; + export function initConfig(config: {}): typeof shipit; + export function local(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + export function log(log: any): void; + export function log(...log: any[]): void; + export function on(name: string, callback: Function): any; + export function remote(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + export function remoteCopy(src: string, dest: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + export function start(tasks: string): typeof shipit; + export function start(tasks: string[]): typeof shipit; + export function start(...tasks: string[]): typeof shipit; + export function task(name: string, depsOrFn: string[] | Function, fn?: Function): typeof shipit; + + export var config: {}; + export var domain: any; + export var doneCallback: any; + export var environment: string; + export var seq: any[]; + export var tasks: Tasks; + export var isRunning: boolean; +} diff --git a/shipit/shipit-cli-tests.ts b/shipit/shipit-cli-tests.ts new file mode 100644 index 0000000000..50dff54978 --- /dev/null +++ b/shipit/shipit-cli-tests.ts @@ -0,0 +1,50 @@ +import shipit = require("shipit-cli"); + +shipit.initConfig({ + default: { + workspace: "/tmp/github-monitor", + deployTo: "/tmp/deploy_to", + repositoryUrl: "https://github.com/user/repo.git", + ignores: [".git", "node_modules"], + rsync: ["--del"], + keepReleases: 2, + key: "/path/to/key", + shallowClone: true + }, + staging: { + servers: "user@myserver.com" + } +}); + +shipit.task("build", () => { + shipit.emit("built"); +}); + +shipit.on("built", () => { + shipit.start("start-server"); +}); + +shipit.task("pwd", () => { + return shipit.remote("pwd"); +}); + +shipit.blTask("pwd", () => { + return shipit.remote("pwd"); +}); + +shipit.start("task"); +shipit.start("task1", "task2"); +shipit.start(["task1", "task2"]); + +shipit.local("ls -lah", {cwd: "/tmp/deploy/workspace"}).then((res: any) => { + console.log(res.stdout); + console.log(res.stderr); +}); + +shipit.remote("ls -lah").then((res: any) => { + console.log(res[0].stdout); + console.log(res[0].stderr); +}); + +shipit.remoteCopy("/tmp/workspace", "/opt/web/myapp").then(() => {}); +shipit.log("hello %s", "world"); diff --git a/shipit/tsconfig.json b/shipit/tsconfig.json new file mode 100644 index 0000000000..da7bec35d8 --- /dev/null +++ b/shipit/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shipit-cli-tests.ts" + ] +} From d4044f0ce56b80c6ed0403ff17305678a85423b2 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Sat, 14 Jan 2017 21:18:20 +0100 Subject: [PATCH 2/8] Fix definition header for shipit-cli. --- shipit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shipit/index.d.ts b/shipit/index.d.ts index e0a528a2f2..ab44d7abd8 100644 --- a/shipit/index.d.ts +++ b/shipit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for shipit 1.5.1 +// Type definitions for shipit-cli 1.5.1 // Project: https://github.com/shipitjs/shipit // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 6c7cd1ed7b83005c26891581f6cffb54eafa63d7 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Sat, 14 Jan 2017 21:19:11 +0100 Subject: [PATCH 3/8] Rename "shipit-cli-tests" to "shipit-tests". --- shipit/{shipit-cli-tests.ts => shipit-tests.ts} | 0 shipit/tsconfig.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename shipit/{shipit-cli-tests.ts => shipit-tests.ts} (100%) diff --git a/shipit/shipit-cli-tests.ts b/shipit/shipit-tests.ts similarity index 100% rename from shipit/shipit-cli-tests.ts rename to shipit/shipit-tests.ts diff --git a/shipit/tsconfig.json b/shipit/tsconfig.json index da7bec35d8..254ac2d9a5 100644 --- a/shipit/tsconfig.json +++ b/shipit/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "shipit-cli-tests.ts" + "shipit-tests.ts" ] } From 9f396a35febe9d229c876d8cbeca26627594a604 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Wed, 18 Jan 2017 17:09:27 +0100 Subject: [PATCH 4/8] Add "tslint.json" file. Replace "major.minor.build" by "major.minor". --- express-rate-limit/index.d.ts | 2 +- express-rate-limit/tsconfig.json | 38 +++++++++++++++++--------------- express-rate-limit/tslint.json | 1 + shipit-utils/index.d.ts | 2 +- shipit-utils/tsconfig.json | 38 +++++++++++++++++--------------- shipit-utils/tslint.json | 1 + shipit/index.d.ts | 2 +- shipit/tsconfig.json | 38 +++++++++++++++++--------------- shipit/tslint.json | 1 + 9 files changed, 66 insertions(+), 57 deletions(-) create mode 100644 express-rate-limit/tslint.json create mode 100644 shipit-utils/tslint.json create mode 100644 shipit/tslint.json diff --git a/express-rate-limit/index.d.ts b/express-rate-limit/index.d.ts index 57eb003694..07cb5853a5 100644 --- a/express-rate-limit/index.d.ts +++ b/express-rate-limit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for express-rate-limit 2.6.0 +// Type definitions for express-rate-limit 2.6 // Project: https://github.com/nfriedly/express-rate-limit // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/express-rate-limit/tsconfig.json b/express-rate-limit/tsconfig.json index 560edfef9d..ca3c32c3bb 100644 --- a/express-rate-limit/tsconfig.json +++ b/express-rate-limit/tsconfig.json @@ -1,20 +1,22 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "express-rate-limit-tests.ts" - ] + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-rate-limit-tests.ts" + ] } diff --git a/express-rate-limit/tslint.json b/express-rate-limit/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/express-rate-limit/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/shipit-utils/index.d.ts b/shipit-utils/index.d.ts index a66b681c37..63df44974f 100644 --- a/shipit-utils/index.d.ts +++ b/shipit-utils/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for shipit-utils 1.4.0 +// Type definitions for shipit-utils 1.4 // Project: https://github.com/shipitjs/shipit-utils // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/shipit-utils/tsconfig.json b/shipit-utils/tsconfig.json index fa4b1ce3b6..d2fdb45d17 100644 --- a/shipit-utils/tsconfig.json +++ b/shipit-utils/tsconfig.json @@ -1,20 +1,22 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "shipit-utils-tests.ts" - ] + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shipit-utils-tests.ts" + ] } diff --git a/shipit-utils/tslint.json b/shipit-utils/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/shipit-utils/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/shipit/index.d.ts b/shipit/index.d.ts index ab44d7abd8..7b153ae197 100644 --- a/shipit/index.d.ts +++ b/shipit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for shipit-cli 1.5.1 +// Type definitions for shipit-cli 1.5 // Project: https://github.com/shipitjs/shipit // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/shipit/tsconfig.json b/shipit/tsconfig.json index 254ac2d9a5..17049e7271 100644 --- a/shipit/tsconfig.json +++ b/shipit/tsconfig.json @@ -1,20 +1,22 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "shipit-tests.ts" - ] + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shipit-tests.ts" + ] } diff --git a/shipit/tslint.json b/shipit/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/shipit/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 1764c825a30f370341214a5305636697921d3979 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Fri, 27 Jan 2017 18:23:12 +0100 Subject: [PATCH 5/8] Fix errors. Rename "shipit" to "shipit-cli". --- express-rate-limit/index.d.ts | 6 ++--- {shipit => shipit-cli}/index.d.ts | 24 +++++++++---------- .../shipit-cli-tests.ts | 0 {shipit => shipit-cli}/tsconfig.json | 2 +- {shipit => shipit-cli}/tslint.json | 0 shipit-utils/index.d.ts | 3 +-- 6 files changed, 17 insertions(+), 18 deletions(-) rename {shipit => shipit-cli}/index.d.ts (77%) rename shipit/shipit-tests.ts => shipit-cli/shipit-cli-tests.ts (100%) rename {shipit => shipit-cli}/tsconfig.json (93%) rename {shipit => shipit-cli}/tslint.json (100%) diff --git a/express-rate-limit/index.d.ts b/express-rate-limit/index.d.ts index 07cb5853a5..38ef8f8b29 100644 --- a/express-rate-limit/index.d.ts +++ b/express-rate-limit/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import express = require("express"); declare namespace RateLimit { @@ -19,10 +17,12 @@ declare namespace RateLimit { export interface Options { delayAfter?: number; delayMs?: number; + handlers?: () => any; headers?: boolean; - keyGenerator?: Function; + keyGenerator?: () => string; max?: number; message?: string; + skip?: () => boolean; statusCode?: number; store?: Store; windowMs?: number; diff --git a/shipit/index.d.ts b/shipit-cli/index.d.ts similarity index 77% rename from shipit/index.d.ts rename to shipit-cli/index.d.ts index 7b153ae197..d438300df3 100644 --- a/shipit/index.d.ts +++ b/shipit-cli/index.d.ts @@ -5,14 +5,13 @@ /// -declare module "shipit-cli" { - import shipit = require("shipit-cli"); - - import * as fs from "fs"; - import * as child_process from "child_process"; +import * as fs from "fs"; +import * as child_process from "child_process"; +declare module shipit { type LocalOrRemoteCommand = (command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void) => PromiseLike; - type TaskExecution = (name: string, depsOrFn: string[] | Function, fn: Function) => any; + type TaskExecution = (name: string, depsOrFn: string[] | Function, fn: () => void) => any; + type EmptyCallback = () => void; export interface Options { environment: string; @@ -33,23 +32,22 @@ declare module "shipit-cli" { export interface Task { blocking: boolean; dep: string[]; - fn: Function; + fn: () => void; name: string; } - export function blTask(name: string, depsOrFn: string[] | Function, fn?: Function): any; + export function blTask(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): any; export function emit(name: string): any; export function initConfig(config: {}): typeof shipit; export function local(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; export function log(log: any): void; export function log(...log: any[]): void; - export function on(name: string, callback: Function): any; + export function on(name: string, callback: (e: any) => void): any; export function remote(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; export function remoteCopy(src: string, dest: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; - export function start(tasks: string): typeof shipit; - export function start(tasks: string[]): typeof shipit; + export function start(tasks: string | string[]): typeof shipit; export function start(...tasks: string[]): typeof shipit; - export function task(name: string, depsOrFn: string[] | Function, fn?: Function): typeof shipit; + export function task(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): typeof shipit; export var config: {}; export var domain: any; @@ -59,3 +57,5 @@ declare module "shipit-cli" { export var tasks: Tasks; export var isRunning: boolean; } + +export = shipit; diff --git a/shipit/shipit-tests.ts b/shipit-cli/shipit-cli-tests.ts similarity index 100% rename from shipit/shipit-tests.ts rename to shipit-cli/shipit-cli-tests.ts diff --git a/shipit/tsconfig.json b/shipit-cli/tsconfig.json similarity index 93% rename from shipit/tsconfig.json rename to shipit-cli/tsconfig.json index 17049e7271..dccd637a84 100644 --- a/shipit/tsconfig.json +++ b/shipit-cli/tsconfig.json @@ -17,6 +17,6 @@ }, "files": [ "index.d.ts", - "shipit-tests.ts" + "shipit-cli-tests.ts" ] } diff --git a/shipit/tslint.json b/shipit-cli/tslint.json similarity index 100% rename from shipit/tslint.json rename to shipit-cli/tslint.json diff --git a/shipit-utils/index.d.ts b/shipit-utils/index.d.ts index 63df44974f..28f13a3fc5 100644 --- a/shipit-utils/index.d.ts +++ b/shipit-utils/index.d.ts @@ -15,8 +15,7 @@ declare module "shipit-utils" { export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; - export function registerTask(gruntOrShipit: GruntOrShipit, name: string, task: Function): typeof shipit; - export function registerTask(gruntOrShipit: GruntOrShipit, name: string, dependencies: string[]): typeof shipit; + export function registerTask(gruntOrShipit: GruntOrShipit, name: string, dependenciesOrTask: string[]|Function): typeof shipit; export function runTask(gruntOrShipit: {}): void; } From 11b98355561d791446e98120a664da9c824801a2 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Fri, 27 Jan 2017 18:51:58 +0100 Subject: [PATCH 6/8] Fix errors. --- shipit-cli/index.d.ts | 61 ------------------- shipit-utils/index.d.ts | 2 +- shipit/index.d.ts | 61 +++++++++++++++++++ .../shipit-tests.ts | 2 +- {shipit-cli => shipit}/tsconfig.json | 2 +- {shipit-cli => shipit}/tslint.json | 0 6 files changed, 64 insertions(+), 64 deletions(-) delete mode 100644 shipit-cli/index.d.ts create mode 100644 shipit/index.d.ts rename shipit-cli/shipit-cli-tests.ts => shipit/shipit-tests.ts (96%) rename {shipit-cli => shipit}/tsconfig.json (93%) rename {shipit-cli => shipit}/tslint.json (100%) diff --git a/shipit-cli/index.d.ts b/shipit-cli/index.d.ts deleted file mode 100644 index d438300df3..0000000000 --- a/shipit-cli/index.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -// Type definitions for shipit-cli 1.5 -// Project: https://github.com/shipitjs/shipit -// Definitions by: Cyril Schumacher -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -import * as fs from "fs"; -import * as child_process from "child_process"; - -declare module shipit { - type LocalOrRemoteCommand = (command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void) => PromiseLike; - type TaskExecution = (name: string, depsOrFn: string[] | Function, fn: () => void) => any; - type EmptyCallback = () => void; - - export interface Options { - environment: string; - stderr: fs.WriteStream; - stdout: fs.WriteStream; - } - - export interface ShipitLocal { - child: child_process.ChildProcess; - stderr: fs.WriteStream; - stdout: fs.WriteStream; - } - - export interface Tasks { - [name: string]: Task; - } - - export interface Task { - blocking: boolean; - dep: string[]; - fn: () => void; - name: string; - } - - export function blTask(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): any; - export function emit(name: string): any; - export function initConfig(config: {}): typeof shipit; - export function local(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; - export function log(log: any): void; - export function log(...log: any[]): void; - export function on(name: string, callback: (e: any) => void): any; - export function remote(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; - export function remoteCopy(src: string, dest: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; - export function start(tasks: string | string[]): typeof shipit; - export function start(...tasks: string[]): typeof shipit; - export function task(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): typeof shipit; - - export var config: {}; - export var domain: any; - export var doneCallback: any; - export var environment: string; - export var seq: any[]; - export var tasks: Tasks; - export var isRunning: boolean; -} - -export = shipit; diff --git a/shipit-utils/index.d.ts b/shipit-utils/index.d.ts index 28f13a3fc5..28a00c2aad 100644 --- a/shipit-utils/index.d.ts +++ b/shipit-utils/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +/// declare module "shipit-utils" { import shipit = require("shipit-cli"); diff --git a/shipit/index.d.ts b/shipit/index.d.ts new file mode 100644 index 0000000000..f0c00d8d2d --- /dev/null +++ b/shipit/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for shipit-cli 1.5 +// Project: https://github.com/shipitjs/shipit +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as fs from "fs"; +import * as child_process from "child_process"; + +declare namespace shipit { + type LocalOrRemoteCommand = (command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void) => PromiseLike; + type EmptyCallback = () => void; + type TaskExecution = (name: string, depsOrFn: string[] | EmptyCallback, fn: () => void) => any; + + interface Options { + environment: string; + stderr: fs.WriteStream; + stdout: fs.WriteStream; + } + + interface ShipitLocal { + child: child_process.ChildProcess; + stderr: fs.WriteStream; + stdout: fs.WriteStream; + } + + interface Tasks { + [name: string]: Task; + } + + interface Task { + blocking: boolean; + dep: string[]; + fn: () => void; + name: string; + } + + function blTask(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): any; + function emit(name: string): any; + function initConfig(config: {}): typeof shipit; + function local(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + function log(log: any): void; + function log(...log: any[]): void; + function on(name: string, callback: (e: any) => void): any; + function remote(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + function remoteCopy(src: string, dest: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + function start(tasks: string | string[]): typeof shipit; + function start(...tasks: string[]): typeof shipit; + function task(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): typeof shipit; + + var config: {}; + var domain: any; + var doneCallback: any; + var environment: string; + var seq: any[]; + var tasks: Tasks; + var isRunning: boolean; +} + +export = shipit; diff --git a/shipit-cli/shipit-cli-tests.ts b/shipit/shipit-tests.ts similarity index 96% rename from shipit-cli/shipit-cli-tests.ts rename to shipit/shipit-tests.ts index 50dff54978..a256f87e07 100644 --- a/shipit-cli/shipit-cli-tests.ts +++ b/shipit/shipit-tests.ts @@ -1,4 +1,4 @@ -import shipit = require("shipit-cli"); +import shipit = require("shipit"); shipit.initConfig({ default: { diff --git a/shipit-cli/tsconfig.json b/shipit/tsconfig.json similarity index 93% rename from shipit-cli/tsconfig.json rename to shipit/tsconfig.json index dccd637a84..17049e7271 100644 --- a/shipit-cli/tsconfig.json +++ b/shipit/tsconfig.json @@ -17,6 +17,6 @@ }, "files": [ "index.d.ts", - "shipit-cli-tests.ts" + "shipit-tests.ts" ] } diff --git a/shipit-cli/tslint.json b/shipit/tslint.json similarity index 100% rename from shipit-cli/tslint.json rename to shipit/tslint.json From 3ba808f9cea9c4f18e915b15d581dbc5ae9294b2 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Fri, 27 Jan 2017 18:52:20 +0100 Subject: [PATCH 7/8] Fix errors. --- shipit-utils/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shipit-utils/index.d.ts b/shipit-utils/index.d.ts index 28a00c2aad..fa29e53609 100644 --- a/shipit-utils/index.d.ts +++ b/shipit-utils/index.d.ts @@ -3,10 +3,10 @@ // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +/// declare module "shipit-utils" { - import shipit = require("shipit-cli"); + import shipit = require("shipit"); type GruntOrShipit = typeof shipit | {}; From 3757f74794a0ec0ca01a89088001bdaef0a658a5 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Fri, 27 Jan 2017 19:09:38 +0100 Subject: [PATCH 8/8] Fix tslint errors. --- shipit-utils/index.d.ts | 22 ++++++---------- shipit-utils/shipit-utils-tests.ts | 2 +- shipit/index.d.ts | 40 ++++++++++++++++-------------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/shipit-utils/index.d.ts b/shipit-utils/index.d.ts index fa29e53609..aec379f5f2 100644 --- a/shipit-utils/index.d.ts +++ b/shipit-utils/index.d.ts @@ -3,19 +3,13 @@ // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import shipit = require("shipit"); -declare module "shipit-utils" { - import shipit = require("shipit"); +type GruntOrShipit = typeof shipit | {}; +type EmptyCallback = () => void; - type GruntOrShipit = typeof shipit | {}; - - export function equalValues(value: any[]): void; - - export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; - export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; - - export function registerTask(gruntOrShipit: GruntOrShipit, name: string, dependenciesOrTask: string[]|Function): typeof shipit; - - export function runTask(gruntOrShipit: {}): void; -} +export function equalValues(value: any[]): void; +export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; +export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; +export function registerTask(gruntOrShipit: GruntOrShipit, name: string, dependenciesOrTask: string[] | EmptyCallback): typeof shipit; +export function runTask(gruntOrShipit: {}): void; diff --git a/shipit-utils/shipit-utils-tests.ts b/shipit-utils/shipit-utils-tests.ts index 15f0d5547b..81cb741054 100644 --- a/shipit-utils/shipit-utils-tests.ts +++ b/shipit-utils/shipit-utils-tests.ts @@ -1,4 +1,4 @@ -import shipit = require("shipit-cli"); +import shipit = require("shipit"); import utils = require("shipit-utils"); var originalShipit = utils.getShipit(shipit); diff --git a/shipit/index.d.ts b/shipit/index.d.ts index f0c00d8d2d..8c614f1627 100644 --- a/shipit/index.d.ts +++ b/shipit/index.d.ts @@ -36,26 +36,28 @@ declare namespace shipit { name: string; } - function blTask(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): any; - function emit(name: string): any; - function initConfig(config: {}): typeof shipit; - function local(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; - function log(log: any): void; - function log(...log: any[]): void; - function on(name: string, callback: (e: any) => void): any; - function remote(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; - function remoteCopy(src: string, dest: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; - function start(tasks: string | string[]): typeof shipit; - function start(...tasks: string[]): typeof shipit; - function task(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): typeof shipit; + export function blTask(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): any; + export function emit(name: string): any; + export function initConfig(config: {}): typeof shipit; + export function local(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + export function log(log: any): void; + export function log(...log: any[]): void; + export function on(name: string, callback: (e: any) => void): any; + export function remote(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + export function remoteCopy(src: string, dest: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + export function start(tasks: string | string[]): typeof shipit; + export function start(...tasks: string[]): typeof shipit; + export function task(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): typeof shipit; - var config: {}; - var domain: any; - var doneCallback: any; - var environment: string; - var seq: any[]; - var tasks: Tasks; - var isRunning: boolean; + export var config: {}; + export var domain: any; + export var doneCallback: any; + export var environment: string; + export var seq: any[]; + export var tasks: Tasks; + export var isRunning: boolean; } +//tslint:disable-next-line:export-just-namespace export = shipit; +export as namespace shipit;