@teambit/envs 1.0.226 → 1.0.227

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,320 +0,0 @@
1
- import { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';
2
- import { CLIMain } from '@teambit/cli';
3
- import { Component, ComponentMain } from '@teambit/component';
4
- import { GraphqlMain } from '@teambit/graphql';
5
- import { IssuesMain } from '@teambit/issues';
6
- import { Harmony, SlotRegistry } from '@teambit/harmony';
7
- import { Logger, LoggerMain } from '@teambit/logger';
8
- import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
9
- import { WorkerMain } from '@teambit/worker';
10
- import { ComponentID } from '@teambit/component-id';
11
- import { EnvService } from './services';
12
- import { Environment } from './environment';
13
- import { Runtime } from './runtime';
14
- import { EnvDefinition } from './env-definition';
15
- import { EnvServiceList } from './env-service-list';
16
- import { EnvPlugin } from './env.plugin';
17
- export type EnvsRegistry = SlotRegistry<Environment>;
18
- export type EnvsConfig = {
19
- env: string;
20
- options: EnvOptions;
21
- };
22
- type GetCalcEnvOptions = {
23
- skipWarnings?: boolean;
24
- };
25
- export type EnvOptions = {};
26
- export type EnvTransformer = (env: Environment) => Environment;
27
- export type ServicesRegistry = SlotRegistry<Array<EnvService<any>>>;
28
- export type RegularCompDescriptor = {
29
- id: string;
30
- icon?: string;
31
- type?: string;
32
- name?: string;
33
- description?: string;
34
- };
35
- export type EnvCompDescriptorProps = RegularCompDescriptor & {
36
- services?: {
37
- env: {
38
- id: string;
39
- icon: string;
40
- name?: string;
41
- description?: string;
42
- };
43
- services: Array<{
44
- id: string;
45
- name?: string;
46
- description?: string;
47
- data: any;
48
- }>;
49
- };
50
- };
51
- export type EnvCompDescriptor = EnvCompDescriptorProps & {
52
- self?: EnvCompDescriptorProps;
53
- };
54
- export type Descriptor = RegularCompDescriptor | EnvCompDescriptor;
55
- export declare const DEFAULT_ENV = "teambit.harmony/node";
56
- export declare class EnvsMain {
57
- /**
58
- * environments extension configuration.
59
- */
60
- readonly config: EnvsConfig;
61
- /**
62
- * harmony context.
63
- */
64
- private harmony;
65
- /**
66
- * slot for allowing extensions to register new environment.
67
- */
68
- private envSlot;
69
- private logger;
70
- private servicesRegistry;
71
- private componentMain;
72
- private loggerMain;
73
- private workerMain;
74
- /**
75
- * Envs that are failed to load
76
- */
77
- private failedToLoadEnvs;
78
- /**
79
- * Extensions that are failed to load
80
- * We use this as sometime when we couldn't load an extension we don't know if it's an env or not
81
- * We should ideally take it from the aspect loader aspect, but right now the aspect loader is using envs
82
- */
83
- private failedToLoadExt;
84
- /**
85
- * Ids of envs (not neccesrraly loaded successfully)
86
- */
87
- envIds: Set<string>;
88
- static runtime: import("@teambit/bit").RuntimeDefinition;
89
- private alreadyShownWarning;
90
- /**
91
- * icon of the extension.
92
- */
93
- icon(): string;
94
- constructor(
95
- /**
96
- * environments extension configuration.
97
- */
98
- config: EnvsConfig,
99
- /**
100
- * harmony context.
101
- */
102
- harmony: Harmony,
103
- /**
104
- * slot for allowing extensions to register new environment.
105
- */
106
- envSlot: EnvsRegistry, logger: Logger, servicesRegistry: ServicesRegistry, componentMain: ComponentMain, loggerMain: LoggerMain, workerMain: WorkerMain);
107
- /**
108
- * creates a new runtime environments for a set of components.
109
- */
110
- createEnvironment(components: Component[]): Promise<Runtime>;
111
- /**
112
- *
113
- * @param id
114
- */
115
- /**
116
- * This function adds an extension ID to a set of failed to load extensions.
117
- * This mostly used by the aspect loader to add such issues
118
- * Then it is used to hide different errors that are caused by the same issue.
119
- * @param {string} id - string - represents the unique identifier of an extension that failed to load.
120
- */
121
- addFailedToLoadEnvs(id: string): void;
122
- addFailedToLoadExt(id: string): void;
123
- resetFailedToLoadEnvs(): void;
124
- getFailedToLoadEnvs(): string[];
125
- /**
126
- * get the configured default env.
127
- */
128
- getDefaultEnv(): EnvDefinition;
129
- getCoreEnvsIds(): string[];
130
- /**
131
- * compose a new environment from a list of environment transformers.
132
- */
133
- compose(targetEnv: Environment, envTransformers: EnvTransformer[]): Environment;
134
- /**
135
- * create an env transformer which overrides specific env properties.
136
- */
137
- override(propsToOverride: Environment): EnvTransformer;
138
- /**
139
- * compose two environments into one.
140
- */
141
- merge<T extends Environment, S extends Environment>(targetEnv: Environment, sourceEnv: Environment): T & S;
142
- /**
143
- * This function checks if an environment manifest file exists in a given component or set of legacy files.
144
- * @param {Component} [envComponent] - A component object that represents an environment. It contains information about
145
- * the files and directories that make up the environment.
146
- * @param {SourceFile[]} [legacyFiles] - An optional array of SourceFile objects representing the files in the legacy
147
- * file system. If this parameter is not provided, the function will attempt to retrieve the files from the envComponent
148
- * parameter.
149
- * @returns a boolean value indicating whether an `env.jsonc` or `env.json` file exists in the `files` array of either
150
- * the `envComponent` object or the `legacyFiles` array. If neither `envComponent` nor `legacyFiles` are provided, the
151
- * function returns `undefined`.
152
- */
153
- hasEnvManifest(envComponent?: Component, legacyFiles?: SourceFile[]): boolean | undefined;
154
- getEnvManifest(envComponent?: Component, legacyFiles?: SourceFile[]): Object | undefined;
155
- hasEnvManifestById(envId: string, requesting: string): Promise<boolean | undefined>;
156
- getEnvData(component: Component): Descriptor;
157
- /**
158
- * Return the id of the env as configured in the envs data (without version by default)
159
- * The reason it's not contain version by default is that we want to take the version from the aspect defined on the component itself
160
- * As this version is stay up to date during tagging the env along with the component
161
- * @param component
162
- * @param ignoreVersion
163
- */
164
- private getEnvIdFromEnvsData;
165
- /**
166
- * get the env id of the given component.
167
- */
168
- getEnvId(component: Component): string;
169
- isUsingCoreEnv(component: Component): boolean;
170
- isCoreEnv(envId: string): boolean;
171
- /**
172
- * get the env of the given component.
173
- * In case you are asking for the env during on load you should use calculateEnv instead
174
- */
175
- getEnv(component: Component): EnvDefinition;
176
- /**
177
- * get the env component of the given component.
178
- */
179
- getEnvComponent(component: Component): Promise<Component>;
180
- /**
181
- * get the env component by the env id.
182
- */
183
- getEnvComponentByEnvId(envId: string, requesting?: string): Promise<Component>;
184
- /**
185
- * get the env of the given component.
186
- * This will try to use the regular getEnv but fallback to the calculate env (in case you are using it during on load)
187
- * This is safe to be used on onLoad as well
188
- */
189
- getOrCalculateEnv(component: Component): EnvDefinition;
190
- /**
191
- * get an environment Descriptor.
192
- */
193
- getDescriptor(component: Component): Descriptor | undefined;
194
- calcDescriptor(component: Component, opts?: GetCalcEnvOptions): Promise<Descriptor | undefined>;
195
- /**
196
- * Get env descriptor from the env itself if the component is an env
197
- * This will be empty for regular component, and will only contain data for env themself
198
- */
199
- private getEnvSelfDescriptor;
200
- /**
201
- * Get env descriptor from the env that a given component is using
202
- */
203
- private getComponentEnvDescriptor;
204
- private getEnvDescriptorFromEnvDef;
205
- resolveEnv(component: Component, id: string): ComponentID | undefined;
206
- /**
207
- * This used to calculate the actual env during the component load.
208
- * Do not use it to get the env (use getEnv instead)
209
- * This should be used only during on load
210
- */
211
- calculateEnvId(component: Component): Promise<ComponentID>;
212
- /**
213
- * This used to calculate the actual env during the component load.
214
- * Do not use it to get the env (use getEnv instead)
215
- * This should be used only during on load
216
- */
217
- calculateEnv(component: Component, opts?: GetCalcEnvOptions): EnvDefinition;
218
- /**
219
- * an env can be configured on a component in two ways:
220
- * 1) explicitly inside "teambit.envs/envs". `{ "teambit.envs/envs": { "env": "my-env" } }`
221
- * 2) the env aspect is set on the variant as any other aspect, e.g. `{ "my-env": {} }`
222
- *
223
- * this method returns #1 if exists, otherwise, #2.
224
- */
225
- getAllEnvsConfiguredOnComponent(component: Component): EnvDefinition[];
226
- /**
227
- * whether a component has an env configured (either by variant or .bitmap).
228
- */
229
- hasEnvConfigured(component: Component): boolean;
230
- getAllRegisteredEnvs(): string[];
231
- getEnvPlugin(): EnvPlugin;
232
- /**
233
- * an env can be configured on a component in two ways:
234
- * 1) explicitly inside "teambit.envs/envs". `{ "teambit.envs/envs": { "env": "my-env" } }`
235
- * 2) the env aspect is set on the variant as any other aspect, e.g. `{ "my-env": {} }`
236
- *
237
- * this method returns only #1
238
- */
239
- getEnvFromEnvsConfig(component: Component): EnvDefinition | undefined;
240
- /**
241
- * an env can be configured on a component in two ways:
242
- * 1) explicitly inside "teambit.envs/envs". `{ "teambit.envs/envs": { "env": "my-env" } }`
243
- * 2) the env aspect is set on the variant as any other aspect, e.g. `{ "my-env": {} }`
244
- *
245
- * this method returns only #2
246
- */
247
- getEnvsNotFromEnvsConfig(component: Component): EnvDefinition[];
248
- getEnvIdFromEnvsLegacyExtensions(extensions: ExtensionDataList): string | undefined;
249
- /**
250
- * @deprecated DO NOT USE THIS METHOD ANYMORE!!! (PLEASE USE .calculateEnvId() instead!)
251
- */
252
- calculateEnvIdFromExtensions(extensions: ExtensionDataList): Promise<string>;
253
- /**
254
- * @deprecated DO NOT USE THIS METHOD ANYMORE!!! (PLEASE USE .calculateEnv() instead!)
255
- */
256
- calculateEnvFromExtensions(extensions: ExtensionDataList): Promise<EnvDefinition>;
257
- /**
258
- * This function finds the first environment ID from a list of IDs by checking if it is register as env (to the slot).
259
- * or contains env.jsonc file
260
- * @param {string[]} ids - `ids` is an array of string values representing environment IDs. The function `findFirstEnv`
261
- * takes this array as input and returns a Promise that resolves to a string value representing the first environment ID
262
- * that matches certain conditions.
263
- * @returns The `findFirstEnv` function returns a Promise that resolves to a string or undefined. The string represents
264
- * the ID of the first environment that matches the conditions specified in the function, or undefined if no environment
265
- * is found.
266
- */
267
- private findFirstEnv;
268
- private getEnvDefinitionByLegacyExtension;
269
- getEnvIdFromEnvsConfig(component: Component): string | undefined;
270
- getEnvDefinition(id: ComponentID): EnvDefinition | undefined;
271
- getEnvDefinitionById(id: ComponentID): EnvDefinition | undefined;
272
- getEnvDefinitionByStringId(envId: string): EnvDefinition | undefined;
273
- getEnvFromComponent(envComponent: Component): EnvDefinition | undefined;
274
- /**
275
- * Return the env definition of teambit.envs/env
276
- */
277
- getEnvsEnvDefinition(): EnvDefinition;
278
- private printWarningIfFirstTime;
279
- /**
280
- * determines whether an env is registered.
281
- */
282
- isEnvRegistered(id: string): boolean;
283
- isUsingAspectEnv(component: Component): boolean;
284
- isUsingEnvEnv(component: Component): boolean;
285
- /**
286
- * Check if the given component is an env component.
287
- * @param component
288
- * @returns
289
- */
290
- isEnv(component: Component): boolean;
291
- /**
292
- * register a new environment service.
293
- */
294
- registerService(...envServices: EnvService<any>[]): this;
295
- /**
296
- * get list of services enabled on an env.
297
- */
298
- getServices(env: EnvDefinition): EnvServiceList;
299
- implements(env: EnvDefinition, service: EnvService<any>): boolean;
300
- /**
301
- * register an environment.
302
- */
303
- registerEnv(env: Environment): void;
304
- addNonLoadedEnvAsComponentIssues(components: Component[]): Promise<void>;
305
- private createRuntime;
306
- private aggregateByDefs;
307
- private getEnvAspectDef;
308
- private throwForDuplicateComponents;
309
- static slots: (((registerFn: () => string) => SlotRegistry<Environment>) | ((registerFn: () => string) => SlotRegistry<EnvService<any, {}, {}>>))[];
310
- static dependencies: import("@teambit/bit").Aspect[];
311
- static provider([graphql, loggerAspect, component, cli, worker, issues]: [
312
- GraphqlMain,
313
- LoggerMain,
314
- ComponentMain,
315
- CLIMain,
316
- WorkerMain,
317
- IssuesMain
318
- ], config: EnvsConfig, [envSlot, servicesRegistry]: [EnvsRegistry, ServicesRegistry], context: Harmony): Promise<EnvsMain>;
319
- }
320
- export {};
@@ -1,51 +0,0 @@
1
- import { Command, CommandOptions } from '@teambit/cli';
2
- import { ComponentMain, ComponentFactory } from '@teambit/component';
3
- import { EnvsMain } from './environments.main.runtime';
4
- export declare class ListEnvsCmd implements Command {
5
- private envs;
6
- private componentAspect;
7
- name: string;
8
- description: string;
9
- options: never[];
10
- group: string;
11
- constructor(envs: EnvsMain, componentAspect: ComponentMain);
12
- report(): Promise<string>;
13
- }
14
- type GetEnvOpts = {
15
- services: string;
16
- };
17
- export declare class GetEnvCmd implements Command {
18
- private envs;
19
- private componentAspect;
20
- name: string;
21
- description: string;
22
- arguments: {
23
- name: string;
24
- description: string;
25
- }[];
26
- examples: [{
27
- cmd: 'get ui/button';
28
- description: 'show config information from the env configured for ui/button';
29
- }];
30
- options: CommandOptions;
31
- group: string;
32
- constructor(envs: EnvsMain, componentAspect: ComponentMain);
33
- showEnv(id: string, host: ComponentFactory, servicesArr: string[] | undefined): Promise<string>;
34
- report([name]: [string], { services }: GetEnvOpts): Promise<string>;
35
- }
36
- export declare class EnvsCmd implements Command {
37
- private envs;
38
- private componentAspect;
39
- name: string;
40
- alias: string;
41
- description: string;
42
- options: never[];
43
- group: string;
44
- commands: Command[];
45
- private nonLoadedEnvs;
46
- constructor(envs: EnvsMain, componentAspect: ComponentMain);
47
- report(): Promise<string>;
48
- private getTable;
49
- getNonLoadedEnvsWarning(): string;
50
- }
51
- export {};
@@ -1,4 +0,0 @@
1
- import { BitError } from '@teambit/bit-error';
2
- export declare class EnvNotConfiguredForComponent extends BitError {
3
- constructor(id: string, componentId?: string);
4
- }
@@ -1,5 +0,0 @@
1
- import { BitError } from '@teambit/bit-error';
2
- export declare class EnvNotFoundInRuntime extends BitError {
3
- private id;
4
- constructor(id: string);
5
- }
@@ -1,6 +0,0 @@
1
- import { BitError } from '@teambit/bit-error';
2
- export declare class EnvNotFound extends BitError {
3
- private id;
4
- private componentId?;
5
- constructor(id: string, componentId?: string | undefined);
6
- }
@@ -1,3 +0,0 @@
1
- export { EnvNotFoundInRuntime } from './env-not-found-in-runtime';
2
- export { EnvNotFound } from './env-not-found';
3
- export { EnvNotConfiguredForComponent } from './env-not-configured-for-component';
package/dist/index.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import { EnvsAspect } from './environments.aspect';
2
- export { ServiceHandlerContext as EnvContext } from './services';
3
- export type { ServiceHandlerFactory as EnvHandler, AsyncServiceHandlerFactory as AsyncEnvHandler, ServiceHandler, ServiceTransformationMap, } from './services';
4
- export { DEFAULT_ENV } from './environments.main.runtime';
5
- export * from './environment';
6
- export { ExecutionContext } from './context';
7
- export type { EnvService, ConcreteService } from './services';
8
- export { reduceServiceHandlersFactories } from './services';
9
- export { EnvRuntime } from './runtime/env-runtime';
10
- export type { Env } from './env-interface';
11
- export type { EnvsMain, EnvTransformer, Descriptor, RegularCompDescriptor, EnvCompDescriptor, } from './environments.main.runtime';
12
- export { EnvsAspect };
13
- export { EnvsExecutionResult } from './runtime/envs-execution-result';
14
- export type { EnvServiceList } from './env-service-list';
15
- export { EnvDefinition } from './env-definition';
16
- export default EnvsAspect;
@@ -1,41 +0,0 @@
1
- import { AspectDefinition } from '@teambit/aspect-loader';
2
- import { Component } from '@teambit/component';
3
- import { Environment } from '../environment';
4
- /**
5
- * env runtime is an instance which represent the given env in a
6
- */
7
- export declare class EnvRuntime {
8
- /**
9
- * ID of the wrapping extension.
10
- */
11
- readonly id: string;
12
- /**
13
- * environment
14
- */
15
- readonly env: Environment;
16
- /**
17
- * components to be loaded in the environment
18
- */
19
- readonly components: Component[];
20
- /**
21
- * Aspect definition of the env.
22
- */
23
- readonly envAspectDefinition: AspectDefinition;
24
- constructor(
25
- /**
26
- * ID of the wrapping extension.
27
- */
28
- id: string,
29
- /**
30
- * environment
31
- */
32
- env: Environment,
33
- /**
34
- * components to be loaded in the environment
35
- */
36
- components: Component[],
37
- /**
38
- * Aspect definition of the env.
39
- */
40
- envAspectDefinition: AspectDefinition);
41
- }
@@ -1,18 +0,0 @@
1
- import { ServiceExecutionResult } from '../services';
2
- import { EnvResult } from './runtime';
3
- export declare class EnvsExecutionResult<T extends ServiceExecutionResult> {
4
- readonly results: EnvResult<T>[];
5
- constructor(results: EnvResult<T>[]);
6
- hasErrors(): boolean;
7
- /**
8
- * execution errors.
9
- */
10
- get errors(): Error[];
11
- getErrorsOfEnv(envResult: EnvResult<T>): Error[];
12
- /**
13
- * if only one error is found, throw it. otherwise, summarize the errors per env and throw the
14
- * output
15
- */
16
- throwErrorsIfExist(): void;
17
- getEnvErrorsAsString(envResult: EnvResult<T>): string;
18
- }
@@ -1,2 +0,0 @@
1
- export { Runtime } from './runtime';
2
- export { EnvRuntime } from './env-runtime';
@@ -1,49 +0,0 @@
1
- import { Logger } from '@teambit/logger';
2
- import { ExecutionContext } from '../context';
3
- import { EnvService, ServiceExecutionResult } from '../services';
4
- import { EnvRuntime } from './env-runtime';
5
- import { EnvsExecutionResult } from './envs-execution-result';
6
- export interface EnvResult<T extends ServiceExecutionResult> {
7
- env: EnvRuntime;
8
- data?: T;
9
- error?: Error;
10
- }
11
- export declare class Runtime {
12
- /**
13
- * runtime instances of the environments.
14
- */
15
- readonly runtimeEnvs: EnvRuntime[];
16
- private logger;
17
- constructor(
18
- /**
19
- * runtime instances of the environments.
20
- */
21
- runtimeEnvs: EnvRuntime[], logger: Logger);
22
- /**
23
- * execute a service on a specific env.
24
- */
25
- runEnv<T extends ServiceExecutionResult>(envRuntimeId: string, service: EnvService<T>, options?: {
26
- [key: string]: any;
27
- }): Promise<EnvsExecutionResult<T>>;
28
- /**
29
- * execute a service once for all environments.
30
- */
31
- runOnce<T extends ServiceExecutionResult>(service: EnvService<T>, options?: {
32
- [key: string]: any;
33
- }): Promise<any>;
34
- getEnvExecutionContext(): ExecutionContext[];
35
- /**
36
- * execute a service on each one of the environments.
37
- */
38
- run<T extends ServiceExecutionResult>(
39
- /**
40
- * environment service to execute.
41
- */
42
- service: EnvService<T>,
43
- /**
44
- * options to proxy to the service upon execution.
45
- */
46
- options?: {
47
- [key: string]: any;
48
- }, runtimes?: EnvRuntime[]): Promise<EnvsExecutionResult<T>>;
49
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * please do not use this.
3
- * @deprecated
4
- */
5
- export interface ConcreteService {
6
- getPackageJsonProps?: () => Record<string, any>;
7
- dependencies?: () => any;
8
- }
@@ -1,4 +0,0 @@
1
- export { Service as EnvService, ServiceExecutionResult, TransformationMap as ServiceTransformationMap, } from './service';
2
- export { ConcreteService } from './concrete-service';
3
- export { ServiceHandler, ServiceHandlerFactory, AsyncServiceHandlerFactory, reduceServiceHandlersFactories, } from './service-handler';
4
- export { ServiceHandlerContext } from './service-handler-context';
@@ -1,30 +0,0 @@
1
- import { ComponentID } from '@teambit/component';
2
- import { Harmony } from '@teambit/harmony';
3
- import { Logger, LoggerMain } from '@teambit/logger';
4
- import { WorkerMain } from '@teambit/worker';
5
- export declare class ServiceHandlerContext {
6
- /**
7
- * id of the environment defined in the context.
8
- */
9
- readonly envId: ComponentID;
10
- readonly loggerMain: LoggerMain;
11
- readonly workerMain: WorkerMain;
12
- readonly harmony: Harmony;
13
- constructor(
14
- /**
15
- * id of the environment defined in the context.
16
- */
17
- envId: ComponentID, loggerMain: LoggerMain, workerMain: WorkerMain, harmony: Harmony);
18
- /**
19
- * return a logger instance for the env.
20
- */
21
- createLogger(name?: string): Logger;
22
- /**
23
- * get an instance of an aspect. make sure it is loaded prior to requesting it.
24
- */
25
- getAspect<T>(aspectId: string): T;
26
- /**
27
- * create worker for the env context.
28
- */
29
- createWorker<T>(name: string, path: string): import("@teambit/worker").HarmonyWorker<T>;
30
- }
@@ -1,18 +0,0 @@
1
- import { ServiceHandlerContext } from './service-handler-context';
2
- /**
3
- * definition of the service handler.
4
- */
5
- export type ServiceHandlerFactory<T> = (context: ServiceHandlerContext) => ServiceHandler & T;
6
- export type AsyncServiceHandlerFactory<T> = (context: ServiceHandlerContext) => Promise<ServiceHandler & T>;
7
- export interface ServiceHandler {
8
- /**
9
- * name of the service. e.g. 'typescript-compiler'
10
- */
11
- name?: string;
12
- /**
13
- * version of the service. optional.
14
- */
15
- version?: () => string;
16
- }
17
- export type ReduceFactoryCallback<T> = (acc: T, value: T) => ServiceHandler & T;
18
- export declare function reduceServiceHandlersFactories<T>(factories: ServiceHandlerFactory<T>[], callback: ReduceFactoryCallback<T>): ServiceHandlerFactory<T>;
@@ -1,66 +0,0 @@
1
- import { Component } from '@teambit/component';
2
- import { Env } from '../env-interface';
3
- import { Environment } from '../environment';
4
- import { ServiceHandler } from './service-handler';
5
- import { ServiceHandlerContext } from './service-handler-context';
6
- export type EnvContext = {
7
- components: Component[];
8
- };
9
- export interface ServiceExecutionResult {
10
- errors?: Error[];
11
- }
12
- export type ServiceTransformHandlerFactory<T> = (handlerContext?: any) => (ServiceHandler & T) | Promise<ServiceHandler & T>;
13
- /**
14
- * definition of the service handler type
15
- * This used to define new types of handlers like
16
- * Compiler, Tester, Preview, etc.
17
- */
18
- export type TransformationMap = {
19
- /**
20
- * The name of the function that will be called on the service run/run once later.
21
- * This func will be exist on the final env object
22
- */
23
- [funcName: string]: ServiceTransformHandlerFactory<any>;
24
- };
25
- /**
26
- * services allows to reuse and standardize services for development environments.
27
- * examples for services can be: `linting`, `compilation`, `build`, and others which offer
28
- * standard services to environments such as `react`, `angular` and `vue` and different compositions of each for
29
- * more concrete needs.
30
- *
31
- * `TData` - type of data returned by the service handler.
32
- * `TOpts` is the type of options passed to the environment through execution.
33
- * `TExecResponse` is the execution result of the service.
34
- */
35
- export interface Service<TExecResponse extends ServiceExecutionResult, TData = {}, TOpts = {}> {
36
- /**
37
- * name of the service. (e.g. `compile`, `test`, etc.)
38
- */
39
- name?: string;
40
- /**
41
- * description of the env.
42
- */
43
- description?: string;
44
- /**
45
- * create a string to describe to service in the env cli.
46
- */
47
- render?(env: Environment, context: EnvContext[]): string | Promise<string>;
48
- /**
49
- * get service data from an environment.
50
- */
51
- getDescriptor?(environment: Environment, context?: EnvContext[]): TData | undefined | Promise<TData | undefined>;
52
- /**
53
- * executes a service on a subset of components.
54
- */
55
- run?(context: EnvContext, options?: TOpts): Promise<TExecResponse>;
56
- /**
57
- * run the service only once.
58
- */
59
- runOnce?(context: EnvContext[], options?: TOpts): Promise<any>;
60
- /**
61
- * Return a map of functions that will be called on the service run/run once later.
62
- * @param env the original env plugin object
63
- * @param context ServiceHandlerContext(EnvContext)
64
- */
65
- transform?(env: Env, context: ServiceHandlerContext): TransformationMap | undefined;
66
- }