@teambit/envs 1.0.228 → 1.0.230

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ import { EnvDefinition } from '../env-definition';
2
+ import { Environment } from '../environment';
3
+ import { EnvRuntime, Runtime } from '../runtime';
4
+ export type ServiceMap<T> = {
5
+ [env: string]: T;
6
+ };
7
+ export declare class ExecutionContext {
8
+ /**
9
+ * upper scope of all environment contexts.
10
+ */
11
+ readonly upper: Runtime;
12
+ /**
13
+ * runtime instance of the environment.
14
+ */
15
+ readonly envRuntime: EnvRuntime;
16
+ /**
17
+ * components applied in the execution context.
18
+ */
19
+ components: import("@teambit/component").Component[];
20
+ constructor(
21
+ /**
22
+ * upper scope of all environment contexts.
23
+ */
24
+ upper: Runtime,
25
+ /**
26
+ * runtime instance of the environment.
27
+ */
28
+ envRuntime: EnvRuntime,
29
+ /**
30
+ * components applied in the execution context.
31
+ */
32
+ components?: import("@teambit/component").Component[]);
33
+ relatedContexts: string[];
34
+ /**
35
+ * extension ID of the environment
36
+ */
37
+ get id(): string;
38
+ /**
39
+ * environment instance.
40
+ */
41
+ get env(): Environment;
42
+ get envDefinition(): EnvDefinition;
43
+ apply<T>(name: string, args: any[]): T;
44
+ }
@@ -0,0 +1 @@
1
+ export { ExecutionContext } from './context';
@@ -0,0 +1,41 @@
1
+ import { Environment } from './environment';
2
+ /**
3
+ * API for component development environment.
4
+ */
5
+ export declare class EnvDefinition {
6
+ /**
7
+ * id of the env.
8
+ */
9
+ readonly id: string;
10
+ /**
11
+ * env instance.
12
+ */
13
+ readonly env: Environment;
14
+ constructor(
15
+ /**
16
+ * id of the env.
17
+ */
18
+ id: string,
19
+ /**
20
+ * env instance.
21
+ */
22
+ env: Environment);
23
+ /**
24
+ * get icon of the env.
25
+ */
26
+ get icon(): string;
27
+ /**
28
+ * get the name of the env.
29
+ */
30
+ get name(): string | undefined;
31
+ /**
32
+ * get the description of the env.
33
+ */
34
+ get description(): string | undefined;
35
+ toObject(): {
36
+ id: string;
37
+ description: string | undefined;
38
+ name: string | undefined;
39
+ icon: string;
40
+ };
41
+ }
@@ -0,0 +1,4 @@
1
+ import { EnvHandler } from '.';
2
+ export interface Env {
3
+ [key: string]: EnvHandler<unknown> | any;
4
+ }
@@ -0,0 +1,35 @@
1
+ import { EnvDefinition } from './env-definition';
2
+ import { EnvService } from './services';
3
+ export declare class EnvServiceList {
4
+ /**
5
+ * environment
6
+ */
7
+ readonly env: EnvDefinition;
8
+ /**
9
+ * services available on the env.
10
+ */
11
+ readonly services: [string, EnvService<any>][];
12
+ constructor(
13
+ /**
14
+ * environment
15
+ */
16
+ env: EnvDefinition,
17
+ /**
18
+ * services available on the env.
19
+ */
20
+ services: [string, EnvService<any>][]);
21
+ toObject(): {
22
+ env: {
23
+ id: string;
24
+ description: string | undefined;
25
+ name: string | undefined;
26
+ icon: string;
27
+ };
28
+ services: {
29
+ id: string;
30
+ name: string | undefined;
31
+ description: string | undefined;
32
+ data: {} | Promise<{} | undefined> | undefined;
33
+ }[];
34
+ };
35
+ }
@@ -0,0 +1 @@
1
+ export declare const Logo: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { ShowFragment, Component } from '@teambit/component';
2
+ import { EnvsMain } from './environments.main.runtime';
3
+ export declare class EnvFragment implements ShowFragment {
4
+ private envs;
5
+ constructor(envs: EnvsMain);
6
+ readonly title = "env";
7
+ renderRow(component: Component): Promise<{
8
+ title: string;
9
+ content: string;
10
+ }>;
11
+ json(component: Component): Promise<{
12
+ title: string;
13
+ json: string;
14
+ }>;
15
+ private getEnvId;
16
+ weight: number;
17
+ }
@@ -0,0 +1,18 @@
1
+ import { PluginDefinition } from '@teambit/aspect-loader';
2
+ import { Aspect, Harmony } from '@teambit/harmony';
3
+ import { WorkerMain } from '@teambit/worker';
4
+ import { LoggerMain } from '@teambit/logger';
5
+ import { EnvsRegistry, ServicesRegistry } from './environments.main.runtime';
6
+ export declare class EnvPlugin implements PluginDefinition {
7
+ private envSlot;
8
+ private servicesRegistry;
9
+ private loggerMain;
10
+ private workerMain;
11
+ private harmony;
12
+ constructor(envSlot: EnvsRegistry, servicesRegistry: ServicesRegistry, loggerMain: LoggerMain, workerMain: WorkerMain, harmony: Harmony);
13
+ pattern: string;
14
+ runtimes: string[];
15
+ private createContext;
16
+ private transformToLegacyEnv;
17
+ register(object: any, aspect: Aspect): void;
18
+ }
@@ -0,0 +1,196 @@
1
+ import type { Linter, LinterContext } from '@teambit/linter';
2
+ import type { Formatter, FormatterContext } from '@teambit/formatter';
3
+ import type { Tester } from '@teambit/tester';
4
+ import type { Compiler } from '@teambit/compiler';
5
+ import type { Bundler, BundlerContext, DevServer, DevServerContext } from '@teambit/bundler';
6
+ import type { BuildTask } from '@teambit/builder';
7
+ import type { SchemaExtractor } from '@teambit/schema';
8
+ import type { WebpackConfigTransformer } from '@teambit/webpack';
9
+ import type { PackageJsonProps } from '@teambit/pkg';
10
+ import type { DependencyDetector, EnvPolicyConfigObject } from '@teambit/dependency-resolver';
11
+ import type { Capsule } from '@teambit/isolator';
12
+ import type { Component } from '@teambit/component';
13
+ import { EnvPreviewConfig } from '@teambit/preview';
14
+ import { SchemaNodeTransformer, SchemaTransformer } from '@teambit/typescript';
15
+ export type EnvDescriptor = {
16
+ type: string;
17
+ };
18
+ /**
19
+ * add a custom type and include all properties from within the environment.
20
+ */
21
+ export interface Environment {
22
+ /**
23
+ * name of the environment.
24
+ */
25
+ name?: string;
26
+ /**
27
+ * description of the environment.
28
+ */
29
+ description?: string;
30
+ /**
31
+ * icon of the environment.
32
+ */
33
+ icon?: string;
34
+ [key: string]: any;
35
+ /**
36
+ * Returns the Environment descriptor
37
+ * Required for any task
38
+ */
39
+ __getDescriptor?: () => Promise<EnvDescriptor>;
40
+ /**
41
+ * Returns a schema generator instance
42
+ */
43
+ getSchemaExtractor?: (config?: any, tsserverPath?: string, contextPath?: string, schemaTransformers?: SchemaTransformer[], apiTransformers?: SchemaNodeTransformer[]) => SchemaExtractor;
44
+ /**
45
+ * Returns the dev patterns to match doc files
46
+ */
47
+ getDocsDevPatterns?: (component: Component) => string[];
48
+ /**
49
+ * Returns the dev patterns to match composition files
50
+ */
51
+ getCompositionsDevPatterns?: (component: Component) => string[];
52
+ /**
53
+ * Returns additional dev patterns for the component.
54
+ * Patterns that were provided by getDocsDevPatterns, getTestsDevPatterns will be considered as dev files as well, without need to add them here.
55
+ */
56
+ getDevPatterns?: (component: Component) => string[];
57
+ }
58
+ export interface DependenciesEnv extends Environment {
59
+ /**
60
+ * Returns the list of dependencies
61
+ * Required for any task
62
+ */
63
+ getDependencies?: () => EnvPolicyConfigObject | Promise<EnvPolicyConfigObject>;
64
+ /**
65
+ * Returns a list of additional test host dependencies
66
+ * this will be added to the tester context
67
+ * This can be used in cases when you want specific dependencies to be resolved from the env during testing
68
+ * but you don't want these dependencies as peer dependencies of the component (as they are not used during runtime)
69
+ * An example for this is @angular/compiler, which during running tests you want to resolve from the env, but you don't
70
+ * need it during component runtime.
71
+ */
72
+ getAdditionalTestHostDependencies?: () => string[] | Promise<string[]>;
73
+ /**
74
+ * Returns a list of additional host dependencies
75
+ * this list will be provided as globals on the window after bit preview bundle
76
+ * by default bit will merge this list with the peers from the getDependencies function
77
+ */
78
+ getAdditionalHostDependencies?: () => string[] | Promise<string[]>;
79
+ /**
80
+ * Returns a list of dependency detectors
81
+ * this list will be used to detect all the dependencies in each file of the component
82
+ */
83
+ getDepDetectors?: () => DependencyDetector[] | null;
84
+ }
85
+ export type GetNpmIgnoreContext = {
86
+ capsule: Capsule;
87
+ component: Component;
88
+ };
89
+ export interface PackageEnv extends Environment {
90
+ /**
91
+ * define the package json properties to add to each component.
92
+ * Used by `bit link` to augment package.json with new properties
93
+ */
94
+ getPackageJsonProps?: () => PackageJsonProps;
95
+ /**
96
+ * return `.npmignore` entries to be written before packing the component
97
+ */
98
+ getNpmIgnore?: (npmIgnoreContext?: GetNpmIgnoreContext) => string[];
99
+ }
100
+ export interface LinterEnv extends Environment {
101
+ /**
102
+ * Returns & configures the linter to use (ESLint, ...)
103
+ * Required for `bit lint`
104
+ */
105
+ getLinter?: (context: LinterContext, transformers: any[]) => Linter;
106
+ }
107
+ export interface FormatterEnv extends Environment {
108
+ /**
109
+ * Returns & configures the formatter to use (prettier, ...)
110
+ * Required for `bit format`
111
+ */
112
+ getFormatter?: (context: FormatterContext, transformers: any[]) => Formatter;
113
+ }
114
+ export interface PreviewEnv extends Environment {
115
+ /**
116
+ * Returns a paths to a function which mounts a given component to DOM
117
+ * Required for `bit start` & `bit build`
118
+ */
119
+ getMounter?: () => string;
120
+ /**
121
+ * Returns a path to a docs template.
122
+ * Required for `bit start` & `bit build`
123
+ */
124
+ getDocsTemplate?: () => string;
125
+ /**
126
+ * Returns a bundler for the preview.
127
+ * Required for `bit build` & `bit start`
128
+ */
129
+ getBundler?: (context: BundlerContext, transformers: any[]) => Promise<Bundler>;
130
+ /**
131
+ * Returns preview config like the strategy name to use when bundling the components for the preview
132
+ */
133
+ getPreviewConfig?: () => EnvPreviewConfig;
134
+ /**
135
+ * Returns a bundler for the env template.
136
+ * this bundler will be used to bundle the docs/compositions (or other preview) apps
137
+ * Required for `bit build` & `bit tag`
138
+ */
139
+ getTemplateBundler?: (context: BundlerContext, transformers?: any[]) => Promise<Bundler>;
140
+ }
141
+ export type PipeServiceModifiersMap = Record<string, PipeServiceModifier>;
142
+ export interface PipeServiceModifier {
143
+ transformers?: Function[];
144
+ module?: any;
145
+ }
146
+ export interface BuilderEnv extends PreviewEnv {
147
+ /**
148
+ * @deprecated Fatal: a breaking API was introduced. Use getBuildPipe() instead.
149
+ */
150
+ getPipe?: () => BuildTask[];
151
+ /**
152
+ * Returns the component build pipeline
153
+ * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`
154
+ */
155
+ getBuildPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];
156
+ /**
157
+ * Returns the component tag pipeline
158
+ * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`
159
+ */
160
+ getTagPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];
161
+ /**
162
+ * Returns the component snap pipeline
163
+ * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`
164
+ */
165
+ getSnapPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];
166
+ }
167
+ export interface TesterEnv extends Environment {
168
+ /**
169
+ * Returns a tester
170
+ * Required for `bit start` & `bit test`
171
+ */
172
+ getTester?: (path: string, tester: any) => Tester;
173
+ /**
174
+ * Returns the dev patterns to match test files
175
+ */
176
+ getTestsDevPatterns?: (component: Component) => string[];
177
+ }
178
+ export interface CompilerEnv {
179
+ /**
180
+ * Returns a compiler
181
+ * Required for making and reading dists, especially for `bit compile`
182
+ */
183
+ getCompiler: () => Compiler;
184
+ }
185
+ export declare function hasCompiler(obj: Environment): obj is CompilerEnv;
186
+ export interface DevEnv extends PreviewEnv {
187
+ /**
188
+ * Required for `bit start`
189
+ */
190
+ getDevEnvId?: (context?: any) => string;
191
+ /**
192
+ * Returns and configures the dev server
193
+ * Required for `bit start`
194
+ */
195
+ getDevServer?: (context: DevServerContext, transformers: WebpackConfigTransformer[]) => DevServer | Promise<DevServer>;
196
+ }
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const EnvsAspect: Aspect;
@@ -0,0 +1,3 @@
1
+ import { Schema } from '@teambit/graphql';
2
+ import { EnvsMain } from './environments.main.runtime';
3
+ export declare function environmentsSchema(environments: EnvsMain): Schema;