Skip to content

Commit 043febf

Browse files
author
Ovidiu Barabula
committed
chore(typescript): update types
1 parent 9c32b6f commit 043febf

File tree

11 files changed

+172
-37
lines changed

11 files changed

+172
-37
lines changed

types/config-wizard/index.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ export interface QuestionnaireAnswers {
1717
}
1818
export declare type QuestionnaireSubscriber = (defaults: Config, questionnaire: ConfigQuestionnaire) => Promise<boolean | Error>;
1919
export interface IConfigWizard {
20-
getQuestionnaires?(): Questionnaires;
21-
startQuestionnaire?(namespace: string): Promise<Config>;
22-
validateQuestionnaire?(questionnaire: ConfigQuestionnaire): boolean;
23-
isConfigured?(pluginName: string, defaults: Config): Promise<boolean>;
24-
getConfiguration?(namespace: string, defaults: Config): Promise<Config>;
25-
setConfiguration?(namespace: string, config: Config): Promise<boolean | Error>;
2620
addQuestionnaire(...items: ConfigQuestionnaire[]): boolean;
2721
getSubscriber(): QuestionnaireSubscriber;
2822
start(): Config;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export declare type PackageManager = 'yarn' | 'npm';
2+
export declare type PackageManagersList = PackageManager[] | string[];
3+
export interface NodeDependencies {
4+
[key: string]: string;
5+
}
6+
export interface DependenciesManifest {
7+
[key: string]: any;
8+
devDependencies?: NodeDependencies;
9+
dependencies?: NodeDependencies;
10+
}
11+
export interface DependenciesInstallerOptions {
12+
logChannel?: string;
13+
managers?: PackageManagersList;
14+
}
15+
export interface DependenciesInstallerDefaults {
16+
logChannel: string;
17+
managers: PackageManagersList;
18+
}
19+
export interface DependenciesInstaller {
20+
add(manifest: DependenciesManifest): Promise<void>;
21+
run(): Promise<void>;
22+
}
23+
export declare const ERRORS: {
24+
CWD_INVALID: string;
25+
DEPENDENCY_ALREADY_ADDED: string;
26+
DEPENDENCY_VERSION_MISMATCH: string;
27+
MANAGERS_REQUIRED: string;
28+
MANIFEST_INVALID: string;
29+
NO_MANAGERS: string;
30+
};
31+
/**
32+
* Dependencies Installer
33+
* @param cwd Current working directory path
34+
* @param options Options object
35+
*/
36+
export declare function Installer(cwd?: string, options?: DependenciesInstallerOptions): Promise<DependenciesInstaller>;
37+
declare const _default: Readonly<{
38+
getInstance: (cwd: string, options?: DependenciesInstallerOptions | undefined) => Promise<DependenciesInstaller>;
39+
}>;
40+
export default _default;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { DependenciesManifest } from './dependencies-installer';
2+
export declare type DependenciesSubscriber = (manifest: DependenciesManifest, name: string) => void;
3+
export interface DependenceisManifests {
4+
[key: string]: DependenciesManifest;
5+
}
6+
export interface DependenciesManager {
7+
getSubscriber(): DependenciesSubscriber;
8+
install(): Promise<void>;
9+
}
10+
/**
11+
* DependenciesManager constructor
12+
* The manager will act as a middle-man to delay the (taxing) Dependencies Installer instatiation
13+
*/
14+
export declare function DependenciesManager(): DependenciesManager;
15+
declare const _default: DependenciesManager;
16+
export default _default;

types/plugin-manager/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { IConfigWizard, QuestionnaireSubscriber } from '../config-wizard';
2+
import { DependenciesManager, DependenciesSubscriber } from '../dependencies-manager';
23
import { TaskManager, TaskSubscriber } from '../task-manager';
34
import { InstallableObject } from './installable';
45
export interface Plugin {
@@ -8,19 +9,18 @@ export interface Plugin {
89
}
910
export interface PluginManager {
1011
use(...plugin: Array<string | Plugin | InstallableObject>): Promise<void>;
11-
loadPlugin?(name: string): any;
12-
parsePlugins?(plugins: PluginsArray): Promise<Plugin[]>;
1312
}
1413
export declare type PluginsArray = Array<string | Plugin | InstallableObject>;
15-
export declare type PluginSubscribers = TaskSubscriber | QuestionnaireSubscriber;
14+
export declare type PluginSubscribers = TaskSubscriber | QuestionnaireSubscriber | DependenciesSubscriber;
1615
export declare const ERRORS: {
1716
NO_CONFIG_WIZARD: string;
17+
NO_DEPS_MANAGER: string;
1818
NO_TASK_MANAGER: string;
1919
PLUGIN_NAME_SHOULD_BE_STRING: string;
2020
PLUGIN_NOT_FOUND: string;
2121
};
2222
/**
2323
* PluginManager constructor
2424
*/
25-
declare function PluginManager(taskManager: TaskManager, configWizard: IConfigWizard): PluginManager;
25+
declare function PluginManager(taskManager: TaskManager, configWizard: IConfigWizard, depsManager: DependenciesManager): PluginManager;
2626
export default PluginManager;

types/plugin-manager/installable.d.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { Config, IConfigManager } from '../config-manager';
22
import { ConfigQuestionnaire } from '../config-wizard';
3+
import { DependenciesManifest } from '../dependencies-manager/dependencies-installer';
34
import { ILogger } from '../util/logger';
4-
import { AnyFunction } from '../util/utility-functions';
5+
import { AnyFunction, AnyObject } from '../util/utility-functions';
56
import { Plugin } from './index';
67
import { WorkingPaths } from './paths';
78
export interface InstallableObject {
89
taskFn: AnyFunction;
910
hook: string;
1011
name: string;
12+
dependencies?: DependenciesManifest;
1113
description?: string;
1214
configDefaults?: Config;
1315
configQuestionnaire?: ConfigQuestionnaire;
@@ -30,9 +32,7 @@ export declare const ERRORS: {
3032
* Check if object is an installable Plugin
3133
* @param object Plugin object to be tested
3234
*/
33-
export declare function isInstallable(object: {
34-
[key: string]: any;
35-
}): boolean | void;
35+
export declare function isInstallable(object: AnyObject): boolean | void;
3636
/**
3737
* Create utilities provider (e.g. logger, config proxy, paths, etc.)
3838
* @param name Plugin name
@@ -46,12 +46,13 @@ export declare function getUtilitiesProvider(name: string): Promise<PluginProvid
4646
export declare function provideUtilities(taskFn: AnyFunction, name: string): Promise<AnyFunction>;
4747
/**
4848
* Installable plugin factory
49-
* @param { configDefaults } Configuration defaults object
50-
* @param { configQuestionnaire } Configuration questionnaire object
51-
* @param { description } Task description
52-
* @param { hook } Task registration hook
53-
* @param { name } Task name
54-
* @param { taskFn } Function to be called when running the task
49+
* @param configDefaults Configuration defaults object
50+
* @param configQuestionnaire Configuration questionnaire object
51+
* @param dependencies Dependencies manifest object
52+
* @param description Task description
53+
* @param hook Task registration hook
54+
* @param name Task name
55+
* @param taskFn Function to be called when running the task
5556
*/
5657
declare function Installable(plugin: Plugin | InstallableObject): Plugin;
5758
export default Installable;

types/task-manager/index.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ export interface TaskSubscriber {
77
export interface TaskManager {
88
run(hook: string): Promise<boolean>;
99
getSubscribers(): TaskSubscriber;
10-
subscribe?(task: string, hook: string): boolean;
11-
hasTasks?(hook: string): boolean;
12-
getTasks?(): Tasks;
13-
getHooks?(): string[];
1410
}
1511
export interface TaskManagerOptions {
1612
[key: string]: any;

types/tasks/index.d.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Name: index.ts
3+
* Description: Import all tasks and export as single tasks array
4+
* Author: Ovidiu Barabula <lectii2008@gmail.com>
5+
* @since 1.1.0
6+
*/
7+
import { PluginProvider } from '../plugin-manager/installable';
8+
declare const tasks: ({
9+
configDefaults: {
10+
buildDir: string;
11+
plugins: never[];
12+
sourceDir: string;
13+
};
14+
configQuestionnaire: {
15+
namespace: string;
16+
questions: ({
17+
default: string;
18+
message: string;
19+
name: string;
20+
type: string;
21+
choices?: undefined;
22+
} | {
23+
choices: string[];
24+
message: string;
25+
name: string;
26+
type: string;
27+
default?: undefined;
28+
})[];
29+
};
30+
description: string;
31+
hook: string;
32+
name: string;
33+
taskFn: (done: (...args: any[]) => any, { config, logger }: PluginProvider) => Promise<any>;
34+
} | {
35+
description: string;
36+
hook: string;
37+
name: string;
38+
taskFn: (done: (...args: any[]) => any, { config, logger }: PluginProvider) => Promise<void>;
39+
})[];
40+
export default tasks;

types/tasks/task-init-project.d.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { PluginProvider } from '../plugin-manager/installable';
22
import { AnyFunction } from '../util/utility-functions';
3-
declare const configDefaults: {
4-
buildDir: string;
5-
plugins: never[];
6-
sourceDir: string;
7-
};
83
declare const taskExport: {
94
configDefaults: {
105
buildDir: string;
@@ -30,13 +25,6 @@ declare const taskExport: {
3025
description: string;
3126
hook: string;
3227
name: string;
33-
taskFn: typeof taskFn;
28+
taskFn: (done: AnyFunction, { config, logger }: PluginProvider) => Promise<any>;
3429
};
35-
/**
36-
* Task main function
37-
* @param done Gulp async callback
38-
* @param pluginProvider Assortment of tools for plugins and tasks (e.g. logger, config manager, etc.)
39-
*/
40-
declare function taskFn(done: AnyFunction, {config, logger}: PluginProvider): Promise<any>;
41-
export { taskFn, configDefaults };
4230
export default taskExport;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { PluginProvider } from '../plugin-manager/installable';
2+
import { AnyFunction } from '../util/utility-functions';
3+
declare const taskExport: {
4+
description: string;
5+
hook: string;
6+
name: string;
7+
taskFn: (done: AnyFunction, { config, logger }: PluginProvider) => Promise<void>;
8+
};
9+
export default taskExport;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export declare type PackageManager = 'yarn' | 'npm';
2+
export declare type PackageManagersList = PackageManager[] | string[];
3+
export interface NodeDependencies {
4+
[key: string]: string;
5+
}
6+
export interface DependenciesManifest {
7+
[key: string]: any;
8+
devDependencies?: NodeDependencies;
9+
dependencies?: NodeDependencies;
10+
}
11+
export interface DependenciesInstallerOptions {
12+
logChannel?: string;
13+
managers?: PackageManagersList;
14+
}
15+
export interface DependenciesInstallerDefaults {
16+
logChannel: string;
17+
managers: PackageManagersList;
18+
}
19+
export interface DependenciesInstaller {
20+
add(manifest: DependenciesManifest): Promise<void>;
21+
run(): Promise<void>;
22+
}
23+
export declare const ERRORS: {
24+
CWD_INVALID: string;
25+
DEPENDENCY_ALREADY_ADDED: string;
26+
DEPENDENCY_VERSION_MISMATCH: string;
27+
MANAGERS_REQUIRED: string;
28+
MANIFEST_INVALID: string;
29+
NO_MANAGERS: string;
30+
};
31+
/**
32+
* Dependencies Installer
33+
* @param cwd Current working directory path
34+
* @param options Options object
35+
*/
36+
export declare function Installer(cwd?: string, options?: DependenciesInstallerOptions): Promise<DependenciesInstaller>;
37+
declare const _default: Readonly<{
38+
getInstance: (cwd: string, options?: DependenciesInstallerOptions | undefined) => Promise<DependenciesInstaller>;
39+
}>;
40+
export default _default;

0 commit comments

Comments
 (0)