diff --git a/types/architect/architect-tests.ts b/types/architect/architect-tests.ts new file mode 100644 index 0000000000..7c53c8b170 --- /dev/null +++ b/types/architect/architect-tests.ts @@ -0,0 +1,21 @@ +import * as architect from 'architect'; + +architect.loadConfig('./fake-path', (err, config) => { + if (err) throw err; + const myApp = architect.createApp(config, (err, app) => { + if (err) throw err; + console.log('App ready'); + }); + + myApp.on('service', (name, service) => { + console.log('Service registered %s', name); + }); + + myApp.on('plugin', (plugin) => { + console.log('Plugin registered', plugin); + }); + + myApp.on('ready', (app) => { + console.log('All plugins loaded'); + }); +}); diff --git a/types/architect/index.d.ts b/types/architect/index.d.ts new file mode 100644 index 0000000000..8fe988a5af --- /dev/null +++ b/types/architect/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for architect 0.1 +// Project: https://github.com/c9/architect#readme +// Definitions by: Ivan Lopez +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { EventEmitter } from "events"; + +export type Config = any; +export type Service = any; +export type Plugin = any; + +export function loadConfig(configPath: string, callback?: (err: Error, config: Config) => void): void; +export function createApp(config: Config, callback?: (err: Error, app: Architect) => void): Architect; + +export interface Architect extends EventEmitter { + on(event: "service", listener: (name: string, service: Service, plugin: Plugin) => void): this; + on(event: "plugin", listener: (plugin: Plugin) => void): this; + on(event: "ready", listener: (app: Architect) => void): this; + on(event: "error", listener: (error: Error) => void): this; + getService(name: string): any; +} diff --git a/types/architect/tsconfig.json b/types/architect/tsconfig.json new file mode 100644 index 0000000000..3878723cd1 --- /dev/null +++ b/types/architect/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "architect-tests.ts" + ] +} diff --git a/types/architect/tslint.json b/types/architect/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/architect/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }