@teambit/envs 1.0.107 → 1.0.108

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.
@@ -1,6 +1,6 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { EnvRuntime } from '../../runtime';
3
- export declare type EnvConsoleProps = {
3
+ export type EnvConsoleProps = {
4
4
  runtime: EnvRuntime;
5
5
  };
6
- export declare function EnvConsole(): React.JSX.Element;
6
+ export declare function EnvConsole(): JSX.Element;
@@ -1,9 +1,9 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { EnvDefinition } from '../../env-definition';
3
- export declare type EnvOverviewProps = {
3
+ export type EnvOverviewProps = {
4
4
  envDef: EnvDefinition;
5
5
  };
6
6
  /**
7
7
  * renders an env overview in the terminal.
8
8
  */
9
- export declare function EnvOverview({ envDef }: EnvOverviewProps): React.JSX.Element;
9
+ export declare function EnvOverview({ envDef }: EnvOverviewProps): JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { EnvDefinition } from '../env-definition';
2
2
  import { Environment } from '../environment';
3
3
  import { EnvRuntime, Runtime } from '../runtime';
4
- export declare type ServiceMap<T> = {
4
+ export type ServiceMap<T> = {
5
5
  [env: string]: T;
6
6
  };
7
7
  export declare class ExecutionContext {
@@ -27,15 +27,15 @@ export declare class EnvDefinition {
27
27
  /**
28
28
  * get the name of the env.
29
29
  */
30
- get name(): string | undefined;
30
+ get name(): string;
31
31
  /**
32
32
  * get the description of the env.
33
33
  */
34
- get description(): string | undefined;
34
+ get description(): string;
35
35
  toObject(): {
36
36
  id: string;
37
- description: string | undefined;
38
- name: string | undefined;
37
+ description: string;
38
+ name: string;
39
39
  icon: string;
40
40
  };
41
41
  }
@@ -21,15 +21,15 @@ export declare class EnvServiceList {
21
21
  toObject(): {
22
22
  env: {
23
23
  id: string;
24
- description: string | undefined;
25
- name: string | undefined;
24
+ description: string;
25
+ name: string;
26
26
  icon: string;
27
27
  };
28
28
  services: {
29
29
  id: string;
30
- name: string | undefined;
31
- description: string | undefined;
32
- data: {} | Promise<{} | undefined> | undefined;
30
+ name: string;
31
+ description: string;
32
+ data: {} | Promise<{}>;
33
33
  }[];
34
34
  };
35
35
  }
@@ -1,2 +1,2 @@
1
- import React from 'react';
2
- export declare const Logo: () => React.JSX.Element;
1
+ /// <reference types="react" />
2
+ export declare const Logo: () => JSX.Element;
@@ -11,7 +11,7 @@ import type { DependencyDetector, EnvPolicyConfigObject } from '@teambit/depende
11
11
  import type { Capsule } from '@teambit/isolator';
12
12
  import type { Component } from '@teambit/component';
13
13
  import { EnvPreviewConfig } from '@teambit/preview';
14
- export declare type EnvDescriptor = {
14
+ export type EnvDescriptor = {
15
15
  type: string;
16
16
  };
17
17
  /**
@@ -81,7 +81,7 @@ export interface DependenciesEnv extends Environment {
81
81
  */
82
82
  getDepDetectors?: () => DependencyDetector[] | null;
83
83
  }
84
- export declare type GetNpmIgnoreContext = {
84
+ export type GetNpmIgnoreContext = {
85
85
  capsule: Capsule;
86
86
  component: Component;
87
87
  };
@@ -137,7 +137,7 @@ export interface PreviewEnv extends Environment {
137
137
  */
138
138
  getTemplateBundler?: (context: BundlerContext, transformers?: any[]) => Promise<Bundler>;
139
139
  }
140
- export declare type PipeServiceModifiersMap = Record<string, PipeServiceModifier>;
140
+ export type PipeServiceModifiersMap = Record<string, PipeServiceModifier>;
141
141
  export interface PipeServiceModifier {
142
142
  transformers?: Function[];
143
143
  module?: any;
@@ -14,25 +14,25 @@ import { Runtime } from './runtime';
14
14
  import { EnvDefinition } from './env-definition';
15
15
  import { EnvServiceList } from './env-service-list';
16
16
  import { EnvPlugin } from './env.plugin';
17
- export declare type EnvsRegistry = SlotRegistry<Environment>;
18
- export declare type EnvsConfig = {
17
+ export type EnvsRegistry = SlotRegistry<Environment>;
18
+ export type EnvsConfig = {
19
19
  env: string;
20
20
  options: EnvOptions;
21
21
  };
22
- declare type GetCalcEnvOptions = {
22
+ type GetCalcEnvOptions = {
23
23
  skipWarnings?: boolean;
24
24
  };
25
- export declare type EnvOptions = {};
26
- export declare type EnvTransformer = (env: Environment) => Environment;
27
- export declare type ServicesRegistry = SlotRegistry<Array<EnvService<any>>>;
28
- export declare type RegularCompDescriptor = {
25
+ export type EnvOptions = {};
26
+ export type EnvTransformer = (env: Environment) => Environment;
27
+ export type ServicesRegistry = SlotRegistry<Array<EnvService<any>>>;
28
+ export type RegularCompDescriptor = {
29
29
  id: string;
30
30
  icon?: string;
31
31
  type?: string;
32
32
  name?: string;
33
33
  description?: string;
34
34
  };
35
- export declare type EnvCompDescriptorProps = RegularCompDescriptor & {
35
+ export type EnvCompDescriptorProps = RegularCompDescriptor & {
36
36
  services?: {
37
37
  env: {
38
38
  id: string;
@@ -48,10 +48,10 @@ export declare type EnvCompDescriptorProps = RegularCompDescriptor & {
48
48
  }>;
49
49
  };
50
50
  };
51
- export declare type EnvCompDescriptor = EnvCompDescriptorProps & {
51
+ export type EnvCompDescriptor = EnvCompDescriptorProps & {
52
52
  self?: EnvCompDescriptorProps;
53
53
  };
54
- export declare type Descriptor = RegularCompDescriptor | EnvCompDescriptor;
54
+ export type Descriptor = RegularCompDescriptor | EnvCompDescriptor;
55
55
  export declare const DEFAULT_ENV = "teambit.harmony/node";
56
56
  export declare class EnvsMain {
57
57
  /**
@@ -202,7 +202,7 @@ export declare class EnvsMain {
202
202
  */
203
203
  private getComponentEnvDescriptor;
204
204
  private getEnvDescriptorFromEnvDef;
205
- resolveEnv(component: Component, id: string): ComponentID | undefined;
205
+ resolveEnv(component: Component, id: string): ComponentID;
206
206
  /**
207
207
  * This used to calculate the actual env during the component load.
208
208
  * Do not use it to get the env (use getEnv instead)
@@ -267,7 +267,7 @@ export declare class EnvsMain {
267
267
  private findFirstEnv;
268
268
  private getEnvDefinitionByLegacyExtension;
269
269
  getEnvIdFromEnvsConfig(component: Component): string | undefined;
270
- getEnvDefinition(id: ComponentID): EnvDefinition | undefined;
270
+ getEnvDefinition(id: ComponentID): EnvDefinition;
271
271
  getEnvDefinitionById(id: ComponentID): EnvDefinition | undefined;
272
272
  getEnvDefinitionByLegacyId(id: ComponentID): Promise<EnvDefinition | undefined>;
273
273
  getEnvDefinitionByStringId(envId: string): EnvDefinition | undefined;
@@ -405,16 +405,16 @@ class EnvsMain {
405
405
  }
406
406
  const withVersion = this.resolveEnv(component, envIdFromEnvData);
407
407
  const withVersionMatch = this.envSlot.toArray().find(([envId]) => {
408
- return (withVersion === null || withVersion === void 0 ? void 0 : withVersion.toString()) === envId;
408
+ return withVersion?.toString() === envId;
409
409
  });
410
- const withVersionMatchId = withVersionMatch === null || withVersionMatch === void 0 ? void 0 : withVersionMatch[0];
410
+ const withVersionMatchId = withVersionMatch?.[0];
411
411
  if (withVersionMatchId) return withVersionMatchId;
412
412
 
413
413
  // Handle core envs
414
414
  const exactMatch = this.envSlot.toArray().find(([envId]) => {
415
415
  return envIdFromEnvData === envId;
416
416
  });
417
- const exactMatchId = exactMatch === null || exactMatch === void 0 ? void 0 : exactMatch[0];
417
+ const exactMatchId = exactMatch?.[0];
418
418
  if (exactMatchId) return exactMatchId;
419
419
  if (!withVersion) throw new (_exceptions().EnvNotConfiguredForComponent)(envIdFromEnvData, component.id.toString());
420
420
  return withVersion.toString();
@@ -479,9 +479,8 @@ class EnvsMain {
479
479
  * get an environment Descriptor.
480
480
  */
481
481
  getDescriptor(component) {
482
- var _this$resolveEnv;
483
482
  const envsData = this.getEnvData(component);
484
- envsData.id = ((_this$resolveEnv = this.resolveEnv(component, envsData.id)) === null || _this$resolveEnv === void 0 ? void 0 : _this$resolveEnv.toString()) || envsData.id;
483
+ envsData.id = this.resolveEnv(component, envsData.id)?.toString() || envsData.id;
485
484
  return envsData;
486
485
  }
487
486
  async calcDescriptor(component, opts = {}) {
@@ -542,7 +541,7 @@ class EnvsMain {
542
541
  ignoreVersion: true
543
542
  });
544
543
  });
545
- return matchedEntry === null || matchedEntry === void 0 ? void 0 : matchedEntry.id;
544
+ return matchedEntry?.id;
546
545
  }
547
546
 
548
547
  /**
@@ -568,7 +567,7 @@ class EnvsMain {
568
567
  ignoreVersion: true
569
568
  });
570
569
  });
571
- if (matchedEntry !== null && matchedEntry !== void 0 && matchedEntry.id) return matchedEntry === null || matchedEntry === void 0 ? void 0 : matchedEntry.id;
570
+ if (matchedEntry?.id) return matchedEntry?.id;
572
571
  }
573
572
 
574
573
  // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env
@@ -707,7 +706,7 @@ class EnvsMain {
707
706
  }
708
707
  getEnvIdFromEnvsLegacyExtensions(extensions) {
709
708
  const envsAspect = extensions.findCoreExtension(_environments().EnvsAspect.id);
710
- const envIdFromEnvsConfig = envsAspect === null || envsAspect === void 0 ? void 0 : envsAspect.data.id;
709
+ const envIdFromEnvsConfig = envsAspect?.data.id;
711
710
  return envIdFromEnvsConfig;
712
711
  }
713
712
 
@@ -717,7 +716,7 @@ class EnvsMain {
717
716
  async calculateEnvIdFromExtensions(extensions) {
718
717
  // Search first for env configured via envs aspect itself
719
718
  const envsAspect = extensions.findCoreExtension(_environments().EnvsAspect.id);
720
- const envIdFromEnvsConfig = envsAspect === null || envsAspect === void 0 ? void 0 : envsAspect.config.env;
719
+ const envIdFromEnvsConfig = envsAspect?.config.env;
721
720
  const envIdFromEnvsConfigWithoutVersion = envIdFromEnvsConfig ? _componentId().ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion() : undefined;
722
721
  if (envIdFromEnvsConfig && this.isCoreEnv(envIdFromEnvsConfig)) {
723
722
  return envIdFromEnvsConfig;
@@ -735,7 +734,7 @@ class EnvsMain {
735
734
  }
736
735
  return envIdFromEnvsConfigWithoutVersion === extension.stringId;
737
736
  });
738
- if (matchedEntry !== null && matchedEntry !== void 0 && matchedEntry.id) return matchedEntry === null || matchedEntry === void 0 ? void 0 : matchedEntry.stringId;
737
+ if (matchedEntry?.id) return matchedEntry?.stringId;
739
738
  }
740
739
 
741
740
  // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env
@@ -758,7 +757,7 @@ class EnvsMain {
758
757
  async calculateEnvFromExtensions(extensions) {
759
758
  // Search first for env configured via envs aspect itself
760
759
  const envsAspect = extensions.findCoreExtension(_environments().EnvsAspect.id);
761
- const envIdFromEnvsConfig = envsAspect === null || envsAspect === void 0 ? void 0 : envsAspect.config.env;
760
+ const envIdFromEnvsConfig = envsAspect?.config.env;
762
761
  let envIdFromEnvsConfigWithoutVersion;
763
762
  if (envIdFromEnvsConfig) {
764
763
  envIdFromEnvsConfigWithoutVersion = _componentId().ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion();
@@ -845,7 +844,7 @@ class EnvsMain {
845
844
  });
846
845
  let finalEnvId;
847
846
  if (envId) {
848
- finalEnvId = isFoundWithoutVersion ? envId === null || envId === void 0 ? void 0 : envId.split('@')[0] : envId;
847
+ finalEnvId = isFoundWithoutVersion ? envId?.split('@')[0] : envId;
849
848
  this.envIds.add(envId);
850
849
  }
851
850
  return finalEnvId;
@@ -856,7 +855,7 @@ class EnvsMain {
856
855
  }
857
856
  getEnvIdFromEnvsConfig(component) {
858
857
  const envsAspect = component.state.aspects.get(_environments().EnvsAspect.id);
859
- return envsAspect === null || envsAspect === void 0 ? void 0 : envsAspect.config.env;
858
+ return envsAspect?.config.env;
860
859
  }
861
860
  getEnvDefinition(id) {
862
861
  const allVersions = this.envSlot.toArray();