@teambit/envs 0.0.549 → 0.0.555

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,4 +2,7 @@ import { EnvDefinition } from '../../env-definition';
2
2
  export declare type EnvOverviewProps = {
3
3
  envDef: EnvDefinition;
4
4
  };
5
+ /**
6
+ * renders an env overview in the terminal.
7
+ */
5
8
  export declare function EnvOverview({ envDef }: EnvOverviewProps): JSX.Element;
@@ -4,12 +4,39 @@ export declare type ServiceMap<T> = {
4
4
  [env: string]: T;
5
5
  };
6
6
  export declare class ExecutionContext {
7
+ /**
8
+ * upper scope of all environment contexts.
9
+ */
7
10
  readonly upper: Runtime;
11
+ /**
12
+ * runtime instance of the environment.
13
+ */
8
14
  readonly envRuntime: EnvRuntime;
15
+ /**
16
+ * components applied in the execution context.
17
+ */
9
18
  components: import("@teambit/component").Component[];
10
- constructor(upper: Runtime, envRuntime: EnvRuntime, components?: import("@teambit/component").Component[]);
19
+ constructor(
20
+ /**
21
+ * upper scope of all environment contexts.
22
+ */
23
+ upper: Runtime,
24
+ /**
25
+ * runtime instance of the environment.
26
+ */
27
+ envRuntime: EnvRuntime,
28
+ /**
29
+ * components applied in the execution context.
30
+ */
31
+ components?: import("@teambit/component").Component[]);
11
32
  relatedContexts: string[];
33
+ /**
34
+ * extension ID of the environment
35
+ */
12
36
  get id(): string;
37
+ /**
38
+ * environment instance.
39
+ */
13
40
  get env(): any;
14
41
  get envDefinition(): EnvDefinition;
15
42
  apply<T>(name: string, args: any[]): T;
@@ -1,10 +1,36 @@
1
1
  import { Environment } from './environment';
2
+ /**
3
+ * API for component development environment.
4
+ */
2
5
  export declare class EnvDefinition {
6
+ /**
7
+ * id of the env.
8
+ */
3
9
  readonly id: string;
10
+ /**
11
+ * env instance.
12
+ */
4
13
  readonly env: Environment;
5
- constructor(id: string, 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
+ */
6
26
  get icon(): string;
27
+ /**
28
+ * get the name of the env.
29
+ */
7
30
  get name(): string | undefined;
31
+ /**
32
+ * get the description of the env.
33
+ */
8
34
  get description(): string | undefined;
9
35
  toObject(): {
10
36
  id: string;
@@ -1,9 +1,23 @@
1
1
  import { EnvDefinition } from './env-definition';
2
2
  import { EnvService } from './services';
3
3
  export declare class EnvServiceList {
4
+ /**
5
+ * environment
6
+ */
4
7
  readonly env: EnvDefinition;
8
+ /**
9
+ * services available on the env.
10
+ */
5
11
  readonly services: [string, EnvService<any>][];
6
- constructor(env: EnvDefinition, 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>][]);
7
21
  toObject(): {
8
22
  env: {
9
23
  id: string;
@@ -12,33 +12,88 @@ import { ElementsWrapperContext } from '@teambit/elements';
12
12
  export declare type EnvDescriptor = {
13
13
  type: string;
14
14
  };
15
+ /**
16
+ * add a custom type and include all properties from within the environment.
17
+ */
15
18
  export interface Environment {
19
+ /**
20
+ * name of the environment.
21
+ */
16
22
  name?: string;
23
+ /**
24
+ * description of the environment.
25
+ */
17
26
  description?: string;
27
+ /**
28
+ * icon of the environment.
29
+ */
18
30
  icon?: string;
19
31
  [key: string]: any;
32
+ /**
33
+ * Returns the Environment descriptor
34
+ * Required for any task
35
+ */
20
36
  __getDescriptor?: () => Promise<EnvDescriptor>;
37
+ /**
38
+ * Returns a schema generator instance
39
+ */
21
40
  getSchemaExtractor?: (config?: any) => SchemaExtractor;
22
41
  }
23
42
  export interface DependenciesEnv extends Environment {
43
+ /**
44
+ * Returns the list of dependencies
45
+ * Required for any task
46
+ */
24
47
  getDependencies?: () => VariantPolicyConfigObject | Promise<VariantPolicyConfigObject>;
25
48
  }
26
49
  export interface PackageEnv extends Environment {
50
+ /**
51
+ * define the package json properties to add to each component.
52
+ * Used by `bit link` to augment package.json with new properties
53
+ */
27
54
  getPackageJsonProps?: () => PackageJsonProps;
28
55
  }
29
56
  export interface LinterEnv extends Environment {
57
+ /**
58
+ * Returns & configures the linter to use (ESLint, ...)
59
+ * Required for `bit lint`
60
+ */
30
61
  getLinter?: (context: LinterContext, transformers: any[]) => Linter;
31
62
  }
32
63
  export interface FormatterEnv extends Environment {
64
+ /**
65
+ * Returns & configures the formatter to use (prettier, ...)
66
+ * Required for `bit format`
67
+ */
33
68
  getFormatter?: (context: FormatterContext, transformers: any[]) => Formatter;
34
69
  }
35
70
  export interface PreviewEnv extends Environment {
71
+ /**
72
+ * Returns a paths to a function which mounts a given component to DOM
73
+ * Required for `bit start` & `bit build`
74
+ */
36
75
  getMounter?: () => string;
76
+ /**
77
+ * Returns a path to a docs template.
78
+ * Required for `bit start` & `bit build`
79
+ */
37
80
  getDocsTemplate?: () => string;
81
+ /**
82
+ * Returns a bundler for the preview.
83
+ * Required for `bit build` & `bit start`
84
+ */
38
85
  getBundler?: (context: BundlerContext, transformers: any[]) => Promise<Bundler>;
39
86
  }
40
87
  export interface ElementsEnv extends Environment {
88
+ /**
89
+ * Returns a function that gets the context and wrap the component with a web component
90
+ * Required for `bit build`
91
+ */
41
92
  getElementsWrapper: (context: ElementsWrapperContext) => string;
93
+ /**
94
+ * Returns a bundler for elements.
95
+ * Required for `bit build``
96
+ */
42
97
  getElementsBundler: (context: BundlerContext, transformers: any[]) => Promise<Bundler>;
43
98
  }
44
99
  export declare type PipeServiceModifiersMap = Record<string, PipeServiceModifier>;
@@ -47,19 +102,49 @@ export interface PipeServiceModifier {
47
102
  module?: any;
48
103
  }
49
104
  export interface BuilderEnv extends PreviewEnv {
105
+ /**
106
+ * @deprecated Fatal: a breaking API was introduced. Use getBuildPipe() instead.
107
+ */
50
108
  getPipe?: () => BuildTask[];
109
+ /**
110
+ * Returns the component build pipeline
111
+ * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`
112
+ */
51
113
  getBuildPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];
114
+ /**
115
+ * Returns the component tag pipeline
116
+ * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`
117
+ */
52
118
  getTagPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];
119
+ /**
120
+ * Returns the component snap pipeline
121
+ * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`
122
+ */
53
123
  getSnapPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];
54
124
  }
55
125
  export interface TesterEnv extends Environment {
126
+ /**
127
+ * Returns a tester
128
+ * Required for `bit start` & `bit test`
129
+ */
56
130
  getTester?: (path: string, tester: any) => Tester;
57
131
  }
58
132
  export interface CompilerEnv {
133
+ /**
134
+ * Returns a compiler
135
+ * Required for making and reading dists, especially for `bit compile`
136
+ */
59
137
  getCompiler: () => Compiler;
60
138
  }
61
139
  export declare function hasCompiler(obj: Environment): obj is CompilerEnv;
62
140
  export interface DevEnv extends PreviewEnv {
141
+ /**
142
+ * Required for `bit start`
143
+ */
63
144
  getDevEnvId?: (context?: any) => string;
145
+ /**
146
+ * Returns and configures the dev server
147
+ * Required for `bit start`
148
+ */
64
149
  getDevServer?: (context: DevServerContext, transformers: WebpackConfigTransformer[]) => DevServer | Promise<DevServer>;
65
150
  }
@@ -24,38 +24,114 @@ export declare type Descriptor = {
24
24
  };
25
25
  export declare const DEFAULT_ENV = "teambit.harmony/node";
26
26
  export declare class EnvsMain {
27
+ /**
28
+ * environments extension configuration.
29
+ */
27
30
  readonly config: EnvsConfig;
31
+ /**
32
+ * harmony context.
33
+ */
28
34
  private context;
35
+ /**
36
+ * slot for allowing extensions to register new environment.
37
+ */
29
38
  private envSlot;
30
39
  private logger;
31
40
  private serviceSlot;
32
41
  private componentMain;
33
42
  static runtime: import("@teambit/harmony").RuntimeDefinition;
34
43
  private alreadyShownWarning;
44
+ /**
45
+ * icon of the extension.
46
+ */
35
47
  icon(): string;
36
- constructor(config: EnvsConfig, context: Harmony, envSlot: EnvsRegistry, logger: Logger, serviceSlot: ServiceSlot, componentMain: ComponentMain);
48
+ constructor(
49
+ /**
50
+ * environments extension configuration.
51
+ */
52
+ config: EnvsConfig,
53
+ /**
54
+ * harmony context.
55
+ */
56
+ context: Harmony,
57
+ /**
58
+ * slot for allowing extensions to register new environment.
59
+ */
60
+ envSlot: EnvsRegistry, logger: Logger, serviceSlot: ServiceSlot, componentMain: ComponentMain);
61
+ /**
62
+ * creates a new runtime environments for a set of components.
63
+ */
37
64
  createEnvironment(components: Component[]): Promise<Runtime>;
65
+ /**
66
+ * get the configured default env.
67
+ */
38
68
  getDefaultEnv(): EnvDefinition;
69
+ /**
70
+ * compose a new environment from a list of environment transformers.
71
+ */
39
72
  compose(targetEnv: Environment, envTransformers: EnvTransformer[]): Environment;
73
+ /**
74
+ * create an env transformer which overrides specific env properties.
75
+ */
40
76
  override(propsToOverride: Environment): EnvTransformer;
77
+ /**
78
+ * compose two environments into one.
79
+ */
41
80
  merge<T>(targetEnv: Environment, sourceEnv: Environment): T;
42
81
  getEnvData(component: Component): AspectData;
82
+ /**
83
+ * Return the id of the env as configured in the envs data (without version by default)
84
+ * 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
85
+ * As this version is stay up to date during tagging the env along with the component
86
+ * @param component
87
+ * @param ignoreVersion
88
+ */
43
89
  private getEnvIdFromEnvsData;
90
+ /**
91
+ * get the env id of the given component.
92
+ */
44
93
  getEnvId(component: Component): string;
94
+ /**
95
+ * get the env of the given component.
96
+ * In case you are asking for the env during on load you should use calculateEnv instead
97
+ */
45
98
  getEnv(component: Component): EnvDefinition;
99
+ /**
100
+ * get an environment Descriptor.
101
+ */
46
102
  getDescriptor(component: Component): Descriptor | null;
47
103
  resolveEnv(component: Component, id: string): ComponentID | undefined;
104
+ /**
105
+ * This used to calculate the actual env during the component load.
106
+ * Do not use it to get the env (use getEnv instead)
107
+ * This should be used only during on load
108
+ */
48
109
  calculateEnv(component: Component): EnvDefinition;
49
110
  getAllEnvsConfiguredOnComponent(component: Component): EnvDefinition[];
111
+ /**
112
+ * @deprecated DO NOT USE THIS METHOD ANYMORE!!! (PLEASE USE .calculateEnv() instead!)
113
+ */
50
114
  calculateEnvFromExtensions(extensions: ExtensionDataList): EnvDefinition;
51
115
  private getEnvIdFromEnvsConfig;
52
116
  private getEnvDefinitionById;
53
117
  private getEnvDefinitionByStringId;
54
118
  private printWarningIfFirstTime;
119
+ /**
120
+ * determines whether an env is registered.
121
+ */
55
122
  isEnvRegistered(id: string): boolean;
123
+ /**
124
+ * register a new environment service.
125
+ */
56
126
  registerService(...envServices: EnvService<any>[]): this;
127
+ /**
128
+ * get list of services enabled on an env.
129
+ */
57
130
  getServices(env: EnvDefinition): EnvServiceList;
58
131
  implements(env: EnvDefinition, service: EnvService<any>): boolean;
132
+ /**
133
+ * register an environment.
134
+ */
59
135
  registerEnv(env: Environment): void;
60
136
  private createRuntime;
61
137
  private aggregateByDefs;
@@ -1,8 +1,32 @@
1
1
  import { Component } from '@teambit/component';
2
2
  import { Environment } from '../environment';
3
+ /**
4
+ * env runtime is an instance which represent the given env in a
5
+ */
3
6
  export declare class EnvRuntime {
7
+ /**
8
+ * ID of the wrapping extension.
9
+ */
4
10
  readonly id: string;
11
+ /**
12
+ * environment
13
+ */
5
14
  readonly env: Environment;
15
+ /**
16
+ * components to be loaded in the environment
17
+ */
6
18
  readonly components: Component[];
7
- constructor(id: string, env: Environment, components: Component[]);
19
+ constructor(
20
+ /**
21
+ * ID of the wrapping extension.
22
+ */
23
+ id: string,
24
+ /**
25
+ * environment
26
+ */
27
+ env: Environment,
28
+ /**
29
+ * components to be loaded in the environment
30
+ */
31
+ components: Component[]);
8
32
  }
@@ -4,8 +4,15 @@ export declare class EnvsExecutionResult<T extends ServiceExecutionResult> {
4
4
  readonly results: EnvResult<T>[];
5
5
  constructor(results: EnvResult<T>[]);
6
6
  hasErrors(): boolean;
7
+ /**
8
+ * execution errors.
9
+ */
7
10
  get errors(): Error[];
8
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
+ */
9
16
  throwErrorsIfExist(): void;
10
17
  getEnvErrorsAsString(envResult: EnvResult<T>): string;
11
18
  }
@@ -9,17 +9,41 @@ export interface EnvResult<T extends ServiceExecutionResult> {
9
9
  error?: Error;
10
10
  }
11
11
  export declare class Runtime {
12
+ /**
13
+ * runtime instances of the environments.
14
+ */
12
15
  readonly runtimeEnvs: EnvRuntime[];
13
16
  private logger;
14
- constructor(runtimeEnvs: EnvRuntime[], logger: 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
+ */
15
25
  runEnv<T>(envRuntimeId: string, service: EnvService<T>, options?: {
16
26
  [key: string]: any;
17
27
  }): Promise<EnvsExecutionResult<T>>;
28
+ /**
29
+ * execute a service once for all environments.
30
+ */
18
31
  runOnce<T>(service: EnvService<T>, options?: {
19
32
  [key: string]: any;
20
33
  }): Promise<any>;
21
34
  getEnvExecutionContext(): ExecutionContext[];
22
- run<T>(service: EnvService<T>, options?: {
35
+ /**
36
+ * execute a service on each one of the environments.
37
+ */
38
+ run<T>(
39
+ /**
40
+ * environment service to execute.
41
+ */
42
+ service: EnvService<T>,
43
+ /**
44
+ * options to proxy to the service upon execution.
45
+ */
46
+ options?: {
23
47
  [key: string]: any;
24
48
  }, runtimes?: EnvRuntime[]): Promise<EnvsExecutionResult<T>>;
25
49
  }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * please do not use this.
3
+ * @deprecated
4
+ */
1
5
  export interface ConcreteService {
2
6
  getPackageJsonProps?: () => Record<string, any>;
3
7
  dependencies?: () => any;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * definition of the service handler.
3
+ */
1
4
  export interface ServiceHandler {
2
5
  identifier: string;
3
6
  }
@@ -6,11 +6,39 @@ export declare type EnvContext = {
6
6
  export interface ServiceExecutionResult {
7
7
  errors?: Error[];
8
8
  }
9
+ /**
10
+ * services allows to reuse and standardize services for development environments.
11
+ * examples for services can be: `linting`, `compilation`, `build`, and others which offer
12
+ * standard services to environments such as `react`, `angular` and `vue` and different compositions of each for
13
+ * more concrete needs.
14
+ *
15
+ * `TData` - type of data returned by the service handler.
16
+ * `TOpts` is the type of options passed to the environment through execution.
17
+ * `TExecResponse` is the execution result of the service.
18
+ */
9
19
  export interface Service<TExecResponse extends ServiceExecutionResult, TData = {}, TOpts = {}> {
20
+ /**
21
+ * name of the service. (e.g. `compile`, `test`, etc.)
22
+ */
10
23
  name?: string;
24
+ /**
25
+ * description of the env.
26
+ */
11
27
  description?: string;
28
+ /**
29
+ * create a string to describe to service in the env cli.
30
+ */
12
31
  render?(env: Environment, context: EnvContext[]): JSX.Element | Promise<JSX.Element>;
32
+ /**
33
+ * get service data from an environment.
34
+ */
13
35
  getDescriptor?(environment: Environment, context?: EnvContext[]): TData | undefined | Promise<TData | undefined>;
36
+ /**
37
+ * executes a service on a subset of components.
38
+ */
14
39
  run?(context: EnvContext, options?: TOpts): Promise<TExecResponse>;
40
+ /**
41
+ *
42
+ */
15
43
  runOnce?(context: EnvContext[], options?: TOpts): Promise<any>;
16
44
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/envs",
3
- "version": "0.0.549",
3
+ "version": "0.0.555",
4
4
  "homepage": "https://bit.dev/teambit/envs/envs",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.envs",
8
8
  "name": "envs",
9
- "version": "0.0.549"
9
+ "version": "0.0.555"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/harmony": "0.2.11",
@@ -16,23 +16,23 @@
16
16
  "p-map-series": "2.1.0",
17
17
  "@babel/runtime": "7.12.18",
18
18
  "core-js": "^3.0.0",
19
- "@teambit/component": "0.0.549",
20
- "@teambit/builder": "0.0.549",
21
- "@teambit/bundler": "0.0.549",
22
- "@teambit/compiler": "0.0.549",
23
- "@teambit/dependency-resolver": "0.0.549",
24
- "@teambit/elements": "0.0.2",
25
- "@teambit/formatter": "0.0.100",
26
- "@teambit/linter": "0.0.549",
27
- "@teambit/pkg": "0.0.549",
28
- "@teambit/schema": "0.0.549",
29
- "@teambit/tester": "0.0.549",
30
- "@teambit/webpack": "0.0.549",
31
- "@teambit/graphql": "0.0.549",
32
- "@teambit/cli": "0.0.380",
33
- "@teambit/logger": "0.0.465",
34
- "@teambit/cli-table": "0.0.3",
35
- "@teambit/bit-error": "0.0.366"
19
+ "@teambit/component": "0.0.555",
20
+ "@teambit/builder": "0.0.555",
21
+ "@teambit/bundler": "0.0.555",
22
+ "@teambit/compiler": "0.0.555",
23
+ "@teambit/dependency-resolver": "0.0.555",
24
+ "@teambit/elements": "0.0.8",
25
+ "@teambit/formatter": "0.0.106",
26
+ "@teambit/linter": "0.0.555",
27
+ "@teambit/pkg": "0.0.555",
28
+ "@teambit/schema": "0.0.555",
29
+ "@teambit/tester": "0.0.555",
30
+ "@teambit/webpack": "0.0.555",
31
+ "@teambit/graphql": "0.0.555",
32
+ "@teambit/cli": "0.0.386",
33
+ "@teambit/logger": "0.0.471",
34
+ "@teambit/cli-table": "0.0.9",
35
+ "@teambit/bit-error": "0.0.372"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/react": "^17.0.8",
@@ -42,10 +42,10 @@
42
42
  "@types/jest": "^26.0.0",
43
43
  "@types/react-dom": "^17.0.5",
44
44
  "@types/node": "12.20.4",
45
- "@teambit/envs.aspect-docs.envs": "0.0.101"
45
+ "@teambit/envs.aspect-docs.envs": "0.0.105"
46
46
  },
47
47
  "peerDependencies": {
48
- "@teambit/legacy": "1.0.76",
48
+ "@teambit/legacy": "1.0.172",
49
49
  "react-dom": "^16.8.0 || ^17.0.0",
50
50
  "react": "^16.8.0 || ^17.0.0"
51
51
  },
@@ -73,7 +73,7 @@
73
73
  "react": "-"
74
74
  },
75
75
  "peerDependencies": {
76
- "@teambit/legacy": "1.0.76",
76
+ "@teambit/legacy": "1.0.172",
77
77
  "react-dom": "^16.8.0 || ^17.0.0",
78
78
  "react": "^16.8.0 || ^17.0.0"
79
79
  }
package/tsconfig.json CHANGED
@@ -25,7 +25,6 @@
25
25
  "strict": true,
26
26
  "noImplicitAny": false,
27
27
  "rootDir": ".",
28
- "removeComments": true,
29
28
  "preserveConstEnums": true,
30
29
  "resolveJsonModule": true
31
30
  },