@teambit/envs 1.0.425 → 1.0.426

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <testsuites tests="0" failures="0" errors="0" skipped="0">
3
- <testsuite name="teambit.envs/envs@1.0.425" tests="0" failures="0" errors="0" skipped="0"/>
3
+ <testsuite name="teambit.envs/envs@1.0.426" tests="0" failures="0" errors="0" skipped="0"/>
4
4
  </testsuites>
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["teambit.envs/envs-preview"]=n():e["teambit.envs/envs-preview"]=n()}(self,(()=>(()=>{"use strict";var e={45506:(e,n,t)=>{var o={id:"teambit.envs/aspect-docs/envs@0.0.169",homepage:"https://bit.cloud/teambit/envs/aspect-docs/envs",exported:!0};Object.defineProperty(n,"__esModule",{value:!0}),n.default=d,i(t(41594));var r=t(5016),a=["components"];function i(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)({}).hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},s.apply(null,arguments)}function m(e,n){if(null==e)return{};var t,o,r=l(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],n.includes(t)||{}.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}function l(e,n){if(null==e)return{};var t={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(n.includes(o))continue;t[o]=e[o]}return t}i.__bit_component=o,s.__bit_component=o,m.__bit_component=o,l.__bit_component=o;var c={},p="wrapper";function d(e){var n=e.components,t=m(e,a);return(0,r.mdx)(p,s({},c,t,{components:n,mdxType:"MDXLayout"}),(0,r.mdx)("p",null,"The Envs aspect runs Bit environments and environment services, and defines their structure."),(0,r.mdx)("p",null,"A Bit environment is a development environment encapsulated in a Bit component. Just like other components, Bit environments can be instantly added to your workspace to start developing, testing, and building components with zero configurations.\nDifferent environments can be easily applied to multiple components in a workspace, and can be easily extended or customized to fit your needs and development stack. For example, try the React environment to start developing React components in your workspace.\nLike all Bit components, Bit environments are reusable, so you can share them across projects and teams to greatly speed up and standardize development."),(0,r.mdx)("h4",null,"Example"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'// Using the \'Node\' and \'React\' environments for different components in a Bit workspace.\n{\n "teambit.workspace/variants": {\n "components/ui": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {}\n }\n }\n}\n')),(0,r.mdx)("h4",null,"Features"),(0,r.mdx)("ul",null,(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Blazing fast environment setup"),": Setting up an environment requires nothing more than configuring a workspace to use a Bit extension.\nGet started in seconds and focus on the thing that matters most - delivering great features.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Multiple environments in a single workspace"),": No need to constantly switch between workspaces as different environments,\nset to handle different components, can all be used in parallel in a single workspace.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Less to learn"),": Using a pre-configured environment extension means you don't have to get into all the details of your build tooling.\nThat's a especially important when onboarding a new developer to your team.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Customizable and extensible"),": Environments can be extended to add or override configurations.\nQuickly add your own modifications to get an environment that best suits your needs.\nExport your environment extension to a remote scope to have it available to all your team.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Standardized development"),": Sharing and reusing environments makes it easier to maintain consistency in development across multiple decoupled Bit workspaces.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Easy to maintain"),": Get your environment's latest updates with just a simple ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit import")," command. Roll-back as easily, if needed."))),(0,r.mdx)("h2",null,"CLI reference"),(0,r.mdx)("p",null,"Bit environments make use of Bit's CLI to execute their different services. That means, ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit test"),", for example, may execute different test runners, depending on the environment in use."),(0,r.mdx)("h4",null,"start"),(0,r.mdx)("p",null,"Runs the development serve (that includes running the Workspace UI)."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"// run the dev server\nbit start\n")),(0,r.mdx)("h4",null,"build"),(0,r.mdx)("p",null,"Runs the build pipeline (without tagging components with a new release version)."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit build\n")),(0,r.mdx)("h4",null,"test"),(0,r.mdx)("p",null,"Runs all tests."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit test\n")),(0,r.mdx)("h4",null,"compile"),(0,r.mdx)("p",null,"Compiles all components."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit compile\n")),(0,r.mdx)("h4",null,"lint"),(0,r.mdx)("p",null,"Get lint results for all components."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit lint\n")),(0,r.mdx)("h2",null,"Usage"),(0,r.mdx)("h3",null,"Setting a default environment for the workspace"),(0,r.mdx)("p",null,"Environments can only be configured using the ",(0,r.mdx)("inlineCode",{parentName:"p"},"teambit.workspace/variants")," workspace API. That means the ",(0,r.mdx)("inlineCode",{parentName:"p"},"teambit.workspace/workspace")," cannot be utilized to set an environment as the default for all components. To achieve a similar result, select all components using the ",(0,r.mdx)("inlineCode",{parentName:"p"},"*")," wildcard."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "*": {\n "teambit.react/react": {}\n }\n }\n}\n')),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{style:{color:"#c31313"}},"Never use the '*' wildcard in a workspace that uses multiple environments!"),"Instead, use exclusive namespaces or directories to select and configure each group of components to use its own environment (see an example in the next section)."),(0,r.mdx)("br",null),(0,r.mdx)("br",null),(0,r.mdx)("p",null,"To learn more, see the 'Troubleshooting' section."),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"A single component (with the same version) cannot use more than a single environment.")),(0,r.mdx)("h3",null,"Setting multiple environments"),(0,r.mdx)("p",null,"A single workspace can use different environments for different sets of components. Setting an environment on a specific group of components is done by selecting the group and applying the environment. This is done using ",(0,r.mdx)("inlineCode",{parentName:"p"},"teambit.workspace/variants"),"."),(0,r.mdx)("p",null,"For example, to set the Node and React environments on two sets of components (selected by their directory):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "components/ui": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {}\n }\n }\n}\n')),(0,r.mdx)("h3",null,"Extending an environment"),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"This section goes through the steps of extending the 'main runtime'.\nSee the 'Runtime Environment' section to learn how to extend multiple runtime environments.")),(0,r.mdx)("p",null,"An environment extension is a component that extends an existing environment. An extension file will have the ",(0,r.mdx)("inlineCode",{parentName:"p"},".extension.ts")," suffix as a convention."),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The ",(0,r.mdx)("inlineCode",{parentName:"p"},"*.extensions.ts")," pattern should only be used when no other 'runtime environment' is being extended other than the 'main runtime.' For more details, see the 'runtime environments' section.")),(0,r.mdx)("p",null,"To create and use an environment extension:"),(0,r.mdx)("ol",null,(0,r.mdx)("li",{parentName:"ol"},"Create the extension files"),(0,r.mdx)("li",{parentName:"ol"},"Use and extend an existing environment"),(0,r.mdx)("li",{parentName:"ol"},"Track the new component"),(0,r.mdx)("li",{parentName:"ol"},"Use the new extension component ID to set it in the workspace configuration file"),(0,r.mdx)("li",{parentName:"ol"},"(Optional) Tag the new component"),(0,r.mdx)("li",{parentName:"ol"},"(Optional) Export the component the make it available to be used by others")),(0,r.mdx)("h4",null,"1. Create the environment extension files"),(0,r.mdx)("p",null,"We'll start by creating a new extension:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"// In the workspace's root directory\nmkdir -p extensions/custom-react\ntouch extensions/custom-react/custom-react.extension.ts\ntouch extensions/custom-react/index.ts\n")),(0,r.mdx)("h4",null,"2. Use an existing environment to extend it"),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The below code uses the React environment as an example.")),(0,r.mdx)("p",null,"Our files will have the following code (the code below will only extend the ",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit.react/react")," environment without changing its configurations):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-tsx"},"// custom-react.extension.ts\n\n// Import from the Environments aspect to register this extension as an environment\nimport { EnvsMain, EnvsAspect } from '@teambit/envs';\n// Import from the React aspect to extend it\nimport { ReactAspect, ReactMain } from '@teambit/react';\n\nexport class CustomReactExtension {\n constructor(private react: ReactMain) {}\n\n // Set the necessary dependencies to be injected (by Bit) into the following 'provider' function\n static dependencies: any = [EnvsAspect, ReactAspect];\n\n static async provider([envs, react]: [EnvsMain, ReactMain]) {\n // The 'compose' methods to compose the overrides into a single environment\n const customReactEnv = react.compose([\n // This is were the environment's 'transformers' will be used to customize it\n ]);\n\n // Register this extension as an environment using the \"registerEnv\" slot (provided by the Environments aspect).\n envs.registerEnv(customReactEnv);\n\n return new CustomReactExtension(react);\n }\n}\n")),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"// index.ts\n\nimport { CustomReactExtension } from './custom-react.extension';\nexport { CustomReactExtension };\nexport default CustomReactExtension;\n")),(0,r.mdx)("h4",null,"3. Track the extension component"),(0,r.mdx)("p",null,"We'll then track the new component (with the 'my-extensions' namespace):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit add extensions/custom-react -n my-extensions\n")),(0,r.mdx)("h4",null,"4. Set the extension component in the workspace config file"),(0,r.mdx)("p",null,"Our extension component now has a component ID that can be used in our ",(0,r.mdx)("inlineCode",{parentName:"p"},"workspace.jsonc")," configuration file:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/workspace": {\n "name": "my-workspace",\n "icon": "https://image.flaticon.com/icons/svg/185/185034.svg",\n "defaultScope": "my-org.my-extensions"\n },\n "teambit.workspace/variants": {\n "*": {\n "my-org.my-extensions/custom-react": {}\n }\n }\n}\n')),(0,r.mdx)("h3",null,"The anatomy of an environment extension"),(0,r.mdx)("p",null,"An environment extension uses the following Bit components to extend an existing environment, and to register itself as an environment:"),(0,r.mdx)("ul",null,(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},"The ",(0,r.mdx)("strong",{parentName:"p"},'"base" environment')," (e.g, ",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit/react"),") is extended and customized using its override methods. Each override method, or \"environment transformer\", corresponds to a Bit extension component used by the environment (e.g, the TypeScript component). Using an 'environment transformer' will add new configurations to the relevant Bit component and will override any conflicting ones.",(0,r.mdx)("br",null)," The full list of available 'environment transformers' can be seen in the specific environment's documentation (see: React, React Native, Node).")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},"The ",(0,r.mdx)("strong",{parentName:"p"},"'Environments' component")," (",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit/envs"),") is used to:"),(0,r.mdx)("ol",{parentName:"li"},(0,r.mdx)("li",{parentName:"ol"},'Register the new environment using its "slot"'),(0,r.mdx)("li",{parentName:"ol"},'Override a "service handler". This is done to replace a Bit component used by an environment service. For example, to set the "compiler" service handler to use Babel instead of TypeScript')))),(0,r.mdx)("h4",null,"Override the config for a Bit component used by the environment"),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The current Envs API will soon be replaced.")),(0,r.mdx)("p",null,"The example below is of a React environment extension. This new environment overrides React's DevServer configuration by setting a new Webpack configuration file."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-tsx"},"// custom-react.extension.ts\n\n// Import from the Environments aspect to register this extension as an environment\nimport { EnvsMain, EnvsAspect } from '@teambit/envs';\n// Import from the React aspect to extend it and override its DevServer config\nimport { ReactAspect, ReactMain } from '@teambit/react';\n\nconst newWebpackConfig = require('./webpack/new-webpack-config');\n\nexport class CustomReactExtension {\n constructor(private react: ReactMain) {}\n\n // Set the necessary dependencies to be injected (by Bit) into the following 'provider' function\n static dependencies: any = [EnvsAspect, ReactAspect];\n\n static async provider([envs, react]: [EnvsMain, ReactMain]) {\n // The 'compose' methods to compose the overrides into a single environment\n const customReactEnv = react.compose([\n\n // Override the Webpack configs of the DevServer aspect\n react.overrideDevServerConfig(newWebpackRules);\n\n ]);\n\n // Register this extension as an environment using the \"registerEnv\" slot (provided by the Environments aspect).\n envs.registerEnv(customReactEnv);\n\n return new CustomReactExtension(react);\n }\n}\n")),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"// index.ts\nimport { CustomReactExtension } from './custom-react.extension';\nexport { CustomReactExtension };\nexport default CustomReactExtension;\n")),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The 'provider' method will be executed by Bit. Its Bit aspects dependencies are set in the ",(0,r.mdx)("inlineCode",{parentName:"p"},"dependencies")," variable, and will be injected into the method upon execution.")),(0,r.mdx)("h4",null,"Override a 'service handler' to replace a component used by the environment"),(0,r.mdx)("p",null,"The example below is of a React environment extension. This new environment overrides the 'service handler' for the compiler service. It replaces the Bit aspect used by it, TypeScript, with another Bit aspect, Babel."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-tsx"},"// custom-react.extension.ts\n\n// Import from the Environments aspect to register this extension as an environment\nimport { EnvsMain, EnvsAspect } from '@teambit/envs';\n// Import from the React aspect to extend it and override its DevServer config\nimport { ReactAspect, ReactMain } from '@teambit/react';\n// Import the Babel aspect to configure it and set it as the new compiler\nimport { BabelAspect, BabelMain } from '@teambit.compilation/babel';\n\nconst babelConfig = require('./babel/babel-config');\n\nexport class CustomReactExtension {\n constructor(private react: ReactMain) {}\n\n // Set the necessary dependencies to be injected (by Bit) into the following 'provider' function\n static dependencies: any = [EnvsAspect, ReactAspect, BabelAspect];\n\n static async provider([envs, react, babel]: [EnvsMain, ReactMain, BabelMain]) {\n // Create a new Babel compiler with the 'babelConfig' configurations\n const babelCompiler = babel.createCompiler({\n babelTransformOptions: babelConfig,\n });\n\n // Use the 'override' method provided by the 'environments' aspect (not the React aspect)\n const compilerOverride = envs.override({\n getCompiler: () => {\n return babelCompiler;\n },\n });\n\n // Compose the overrides into a single environment\n const customReactEnv = react.compose([compilerOverride]);\n\n // Register this extension as an environment using the \"registerEnv\" slot (provided by the 'environments' aspect).\n envs.registerEnv(customReactEnv);\n\n return new CustomReactExtension(react);\n }\n}\n")),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"// index.ts\nimport { CustomReactExtension } from './custom-react.extension';\nexport { CustomReactExtension };\nexport default CustomReactExtension;\n")),(0,r.mdx)("h2",null,"Concepts and tools"),(0,r.mdx)("h3",null,"Environment Services"),(0,r.mdx)("p",null,'To become a "one-stop-shop" for components, an environment "bundles" together different Environment Services provided by various Bit aspect components. These Environment Services enable other Bit aspects to integrate into Bit\'s component life-cycle features.'),(0,r.mdx)("p",null,"For example, the 'Tester' service (",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit.defender/tester"),") enables the React environment (",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit.react/react"),") to set 'Jest' (",(0,r.mdx)("inlineCode",{parentName:"p"},"teambit.defender/jest"),") as the default test runner for its components. This will enable Jest to be executed on the ",(0,r.mdx)("inlineCode",{parentName:"p"},"bbit test")," command, to be run as a pre-tag check, to output results using Bit's logger, and even to display the generated logs in the Workspace and Scope UIs (to name just a few examples)."),(0,r.mdx)("img",{src:"https://storage.googleapis.com/docs-images/react_env_ex.png",alt:"React env using Jest with the tester service",style:{width:"50%",minWidth:500}}),(0,r.mdx)("blockquote",null,(0,r.mdx)("h5",{parentName:"blockquote"},"Services VS Build Tasks"),(0,r.mdx)("p",{parentName:"blockquote"},"Environment Services which are executed either by the development server, or via the CLI, are not identical\nto Build Tasks that run as part of the Build Pipeline.\nFor example, the TypeScript configurations used for compilation by the development server are not the same as the ones used for a component's build process.")),(0,r.mdx)("h4",null,"Compiler"),(0,r.mdx)("p",null,"Runs the environment's selected compiler (for example, TypeScript)."),(0,r.mdx)("h4",null,"Tester"),(0,r.mdx)("p",null,"Runs the environment's selected test runner (for example, Jest)"),(0,r.mdx)("h4",null,"Linter"),(0,r.mdx)("p",null,"Runs the environment's selected linter (for example, ESLint)"),(0,r.mdx)("h4",null,"Documentation"),(0,r.mdx)("p",null,"Sets the template for the auto-generated component documentation, as well as the API for customizing component docs."),(0,r.mdx)("h4",null,"Build pipeline (CI)"),(0,r.mdx)("p",null,"Sets the sequence of build tasks to run before a component is tagged with a new version."),(0,r.mdx)("h4",null,"DevServer"),(0,r.mdx)("p",null,"Bundles all components and runs a server to display them, live (using \"hot reloading\") in the workspace UI. This includes rendering the 'compositions' as well as the documentation shown in the 'Overview' tab."),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"Even though different types of components, e.g. React and Node components, run on different servers (one for each environment) the workspace is explored and navigated through as if it where a single server.")),(0,r.mdx)("h4",null,"Package"),(0,r.mdx)("p",null,"Generates the node module package for components, with properties set by the environment."),(0,r.mdx)("h4",null,"Dependencies"),(0,r.mdx)("p",null,"Sets the default dependencies (as well as their version and type) for each component handled by the environment. That includes peer dependencies used for runtime (for example, ",(0,r.mdx)("inlineCode",{parentName:"p"},"react-dom"),") and dev dependencies (for example, ",(0,r.mdx)("inlineCode",{parentName:"p"},"@types/react"),")."),(0,r.mdx)("h4",null,"Bundler"),(0,r.mdx)("p",null,"Bundles components (compositions, docs, etc.) using the environment's bundler and bundling configurations. The generated assets are use both in development (when running the development server) and when exploring component's tagged releases (for example, in the scope UI)."),(0,r.mdx)("h3",null,"Service Handlers"),(0,r.mdx)("p",null,"Service Handlers are the link that binds an environment to the various Environment Services. They are methods in the Environment class that set an Environment Service to use a specific Bit extension component or a configuration file."),(0,r.mdx)("p",null,"For example, the React environment uses the Service Handler ",(0,r.mdx)("inlineCode",{parentName:"p"},"getCompiler()")," to configure the Compiler Environment Service to run the TypeScript extension component."),(0,r.mdx)("p",null,"Environment services run on various events. Whenever a service runs, it executes its corresponding service handler which consequently runs the configured aspect (in the previous example, that would be TypeScript)."),(0,r.mdx)("p",null,"Different components in a Bit workspace may use different environments. That means environment services need to execute their corresponding service handlers in the specific environment applied on the component currently being processed."),(0,r.mdx)("p",null,"For example, if ",(0,r.mdx)("em",{parentName:"p"},"component A")," uses the Node environment then the Compiler service processing that component, will execute the Service Handler (in that case, ",(0,r.mdx)("inlineCode",{parentName:"p"},"getCompiler"),") found in the Node environment."),(0,r.mdx)("h3",null,"List of service handlers"),(0,r.mdx)("h4",null,"getTester"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getTester(...args : any[]): Tester\n")),(0,r.mdx)("p",null,"Returns a test runner to be used by the Tester service."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n constructor(\n // ...\n\n // The Jest Aspect\n private jestAspect: JestMain\n ) {}\n\n // ...\n\n getTester(jestConfigPath: string, jestModule = jest): Tester {\n const jestConfig = require.resolve('./jest/jest.config');\n return this.jestAspect.createTester(jestConfig);\n }\n}\n")),(0,r.mdx)("h4",null,"getCompiler"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getCompiler(...args : any[]): Compiler\n")),(0,r.mdx)("p",null,"Returns a compiler to be used by the Compiler service."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n\nconstructor(\n // ...\n\n // The TypeScript aspect\n private tsAspect: TypescriptMain\n){}\n\n// ...\n\ngetCompiler() {\n const tsConfig = require.resolve('./typescript/tsconfig.json')\n return this.tsAspect.createCompiler(tsConfig);\n}\n")),(0,r.mdx)("h4",null,"getLinter"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getLinter(...args : any[]): Linter\n")),(0,r.mdx)("p",null,"Returns a linter to be used by the Linter service."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"import { ESLintLinter } from '@teambit/defender.eslint-linter';\n\nexport class ReactEnv implements Environment {\n\n constructor(){\n // ...\n\n // The ESLint aspect\n private eslint: ESLintMain\n }\n\n // ...\n\n getLinter() {\n return ESLintLinter.from({\n configPath: require.resolve('./eslint/eslintrc'),\n // resolve all plugins from the react environment.\n pluginsPath: __dirname,\n });\n }\n}\n")),(0,r.mdx)("h4",null,"getDevServer"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getDevServer(...args : any[]): DevServer\n")),(0,r.mdx)("p",null,"Returns a DevServer to be used by the DevServer service. (A DevServer is essentially the combination of the bundler configurations, together with a specified 'listen' port number)"),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n constructor(\n // ...\n\n // The Webpack aspect\n private webpack: WebpackMain\n ) {}\n\n // ...\n\n getDevServer(): DevServer {\n const withDocs = Object.assign(context, {\n entry: context.entry.concat([require.resolve('./docs')]),\n });\n return this.webpack.createDevServer(withDocs, webpackConfig);\n }\n}\n")),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The above example runs the dev server with the environment's documentation template.")),(0,r.mdx)("h4",null,"getDocsTemplate"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getDocsTemplate(...args : any[]): string\n")),(0,r.mdx)("p",null,"Returns the path to the documentation template files, to be used by the Documentation service."),(0,r.mdx)("p",null,"For example (see docs files ",(0,r.mdx)("a",{parentName:"p",href:"https://github.com/teambit/bit/tree/master/scopes/react/react/docs"},"here"),"):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n // ...\n\n getDocsTemplate() {\n return require.resolve('./docs');\n }\n}\n")),(0,r.mdx)("h4",null,"getPackageJsonProps"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getPackageJsonProps(...args : any[]): object\n")),(0,r.mdx)("p",null,"Returns an object that defines the ",(0,r.mdx)("inlineCode",{parentName:"p"},"package.json")," properties of the packages generated for components handled by this environment. This configuration is used by the Packager service."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n // ...\n\n getPackageJsonProps() {\n return {\n main: 'dist/{main}.js',\n types: '{main}.ts',\n };\n }\n}\n")),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"As with any other 'merging' process, the properties defined in the above returned object will be added to configurations set by Bit.\nConflicting properties will be overridden by the properties that are set here.\nConfigurations that are set here may also be overridden, either by the 'pkg aspect' or by workspace configurations set using the 'variants API'.")),(0,r.mdx)("h4",null,"getDependencies"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getDependencies(component: any): Promise<DependencyList>\n")),(0,r.mdx)("p",null,"Returns an object that defines the default dependencies for components handled by this environment. The returned object is used by the Dependencies service."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n // ...\n\n async getDependencies() {\n return {\n dependencies: {\n react: '-',\n },\n devDependencies: {\n '@types/react': '16.9.43',\n '@types/jest': '~26.0.9',\n },\n peerDependencies: {\n react: '^16.13.1',\n 'react-dom': '^16.13.1',\n },\n };\n }\n}\n")),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"As with any other 'merging' process, the properties defined in the above returned object will be added to configurations set by Bit.\nConflicting properties will be overridden by the properties that are set here.\nConfigurations that are set here may also be overridden, either by the 'Dependency Resolver aspect' or by workspace configurations set using the 'variants API'.")),(0,r.mdx)("h4",null,"getBuildPipe"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getBuildPipe(...args : any[]): BuildTask[]\n")),(0,r.mdx)("p",null,"Returns an array of build tasks to be used by the Builder service. Tasks will be added after and before Bit's pre-configured build tasks."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n constructor(\n // ...\n\n // The Compiler aspect\n private compiler: CompilerMain,\n\n // The Tester aspect\n private tester: TesterMain\n ) {}\n\n getBuildPipe(): BuildTask[] {\n return [this.compiler.createTask('StencilCompiler', this.getCompiler()), this.tester.task];\n }\n}\n")),(0,r.mdx)("h2",null,"Extending multiple runtime environments"),(0,r.mdx)("p",null,"An environment may operate in multiple runtime environments: 'Main', which runs on the server and 'UI' and 'Preview', which run on the browser.\nEach runtime environment runs all files that are named with its corresponding file pattern."),(0,r.mdx)("p",null,'An environment extension that runs on multiple runtimes is called "Aspect" an will have the following file structure:'),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre"},"|-- env-extension\n |-- env-extension.main.ts\n |-- env-extension.ui.tsx\n |-- env-extension.preview.tsx\n |-- env.extension.aspect.ts\n")),(0,r.mdx)("h3",null,"Registering an environment as an aspect"),(0,r.mdx)("p",null,"Create a ",(0,r.mdx)("inlineCode",{parentName:"p"},"*.aspect.ts")," file:"),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"touch path/to/extension/env-extension.aspect.ts\n")),(0,r.mdx)("p",null,"Place the following lines to register your environment as a multiple runtime extension (a.k.a, an Aspect):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"// env-extension.aspect.ts\n\nimport { Aspect } from '@teambit/harmony';\n\nexport const ReactWithProvidersAspect = Aspect.create({\n // The ID should be your component's ID\n // Make sure to track your extension component before registering it as an Aspect\n id: 'my-scope.react-with-providers',\n});\n")),(0,r.mdx)("h3",null,"Registering a runtime extension"),(0,r.mdx)("p",null,"An aspect is a collection of multiple extensions, each extending a specific runtime."),(0,r.mdx)("p",null,"Register each runtime extension to its corresponding runtime, using the ",(0,r.mdx)("inlineCode",{parentName:"p"},"addRuntime")," method."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-typescript"},"// react-extension.preview.ts\n\nimport { PreviewRuntime } from '@teambit/preview';\nimport { ReactAspect, ReactPreview } from '@teambit/react';\nimport { ReactExtensionAspect } from './react-with-providers.aspect';\n\nexport class ReactExtensionPreview {\n static runtime = PreviewRuntime;\n\n static dependencies = [ReactAspect];\n\n static async provider([react]: [ReactPreview]) {\n return new ReactExtensionPreview();\n }\n}\n\nReactExtensionAspect.addRuntime(ReactExtensionPreview);\n")),(0,r.mdx)("h3",null,"Runtime environments"),(0,r.mdx)("h4",null,"Main"),(0,r.mdx)("p",null,(0,r.mdx)("inlineCode",{parentName:"p"},"*.main.runtime.ts")),(0,r.mdx)("p",null,"Node files that run in a node runtime environments and outputs to the terminal."),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Example:"),"\nThe React environment TypeScript compiler will be extended in the main runtime."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-typescript"},"// react-extension.main.ts\n\nimport { MainRuntime } from '@teambit/cli';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ReactAspect, ReactMain } from '@teambit/react';\nimport { ReactExtensionAspect } from './react-extension.aspect';\n\nconst tsconfig = require('./typescript/tsconfig.json');\n\nexport class ReactExtensionMain {\n constructor(private react: ReactMain, private envs: EnvsMain) {}\n\n icon() {\n return 'https://static.bit.dev/extensions-icons/react.svg';\n }\n\n static runtime = MainRuntime;\n\n static dependencies = [ReactAspect, EnvsAspect];\n\n static async provider([react, envs]: [ReactMain, EnvsMain]) {\n const reactExtension = envs.compose(react, [react.overrideTsConfig(tsconfig)]);\n envs.registerEnv(reactExtension);\n return new ReactWithProvidersMain(react, envs);\n }\n}\n\nReactExtensionAspect.addRuntime(ReactExtensionMain);\n")),(0,r.mdx)("h4",null,"UI"),(0,r.mdx)("p",null,(0,r.mdx)("inlineCode",{parentName:"p"},"*.ui.runtime.[ts,js,jsx,tsx]")),(0,r.mdx)("p",null,"JSX files that run in the browser, as part of the Workspace/Scope UI bundle that is being served by the development server."),(0,r.mdx)("h4",null,"Preview"),(0,r.mdx)("p",null,(0,r.mdx)("inlineCode",{parentName:"p"},"*.preview.runtime.*")),(0,r.mdx)("p",null,"These files are served by the environment's server, as part of the environment's preview bundle (i.e, the component compositions and documentation).\n(The 'preview' runtime is rendered in the Workspace/Scope UI using an iframe.)"),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Example:"),'\nA new composition provider that will "wrap" every composition using that environment will be added using the preview runtime since it is part of the component compositions (which are being served to the browser by the environment\'s server).'),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-typescript"},"// react-extension.preview.ts\n\nimport { PreviewRuntime } from '@teambit/preview';\nimport { ReactAspect, ReactPreview } from '@teambit/react';\nimport { ReactExtensionAspect } from './react-with-providers.aspect';\nimport { Center } from './my-providers/center';\n\nexport class ReactExtensionPreview {\n static runtime = PreviewRuntime;\n\n static dependencies = [ReactAspect];\n\n static async provider([react]: [ReactPreview]) {\n react.registerProvider(Center);\n\n return new ReactExtensionPreview();\n }\n}\n\nReactExtensionAspect.addRuntime(ReactExtensionPreview);\n")),(0,r.mdx)("h2",null,"Troubleshooting"),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Problem:")," Components that are configured to use a specific environment, use the workspace's default environment, instead."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "*": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {}\n }\n }\n}\n')),(0,r.mdx)("p",null,"In the above example, components in the ",(0,r.mdx)("inlineCode",{parentName:"p"},"components/utils")," directory are set to use the Node environment.\nSince that selection is more specific than the one done using the ",(0,r.mdx)("inlineCode",{parentName:"p"},"*")," wildcard selector, it is expected to override it."),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Understanding the problem:"),"\nTo select the right configurations for each component, the 'Variants' aspect sorts all workspace configurations, from the most specific to the most general.\nThe first configuration set on an aspect (the most specific one) will be the one that is selected for that aspect.\nThat means, once Variants encounters configurations for an aspect, it stops looking for additional configurations for that specific aspect."),(0,r.mdx)("p",null,"Each environment is considered as a different aspect, even though they are all under the \"environments\" category and can only be used once per component.\n'Variants' does not understand categories, only individual aspects and therefore, cannot override one environment with a different environment."),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Solution #1:")),(0,r.mdx)("p",null,"Remove the ",(0,r.mdx)("inlineCode",{parentName:"p"},"*")," general selection and use only specific and exclusive selectors to configure environments\n(that means your workspace directories/ namespaces need to be structured in a way that enables complete selection of all components using selectors that are exclusive)."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "components/react": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {}\n }\n }\n}\n')),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Solution #2:"),"\nConfigure the environment using the Envs config API."),(0,r.mdx)("p",null,"Example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "*": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {},\n "teambit.envs/envs": {\n "env": "teambit.harmony/node"\n }\n }\n }\n}\n')),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"Notice how the Node environment was added also as a standalone aspect, to ensure that it is registered as a dependency of the selected components.")),(0,r.mdx)("hr",null))}d.__bit_component=o,d.isMDXComponent=!0},10583:(e,n,t)=>{Object.defineProperty(n,"B",{enumerable:!0,get:function(){return o.default}});var o=r(t(45506));function r(e){return e&&e.__esModule?e:{default:e}}r.__bit_component={id:"teambit.envs/aspect-docs/envs@0.0.169",homepage:"https://bit.cloud/teambit/envs/aspect-docs/envs",exported:!0}},44627:(e,n,t)=>{var o={id:"teambit.envs/envs@1.0.425",homepage:"https://bit.cloud/teambit/envs/envs",exported:!0};function r(){const e=a(t(41594));return r=function(){return e},e}function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Logo=void 0,r.__bit_component=o,a.__bit_component=o;const i=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/env.svg"}));i.__bit_component=o,n.Logo=i},5016:e=>{e.exports=MdxJsReact},41594:e=>{e.exports=React}},n={};function t(o){var r=n[o];if(void 0!==r)return r.exports;var a=n[o]={exports:{}};return e[o](a,a.exports,t),a.exports}t.d=(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};t.r(o),t.d(o,{compositions:()=>x,compositions_metadata:()=>v,overview:()=>h});var r={};t.r(r),t.d(r,{default:()=>u});var a=t(44627),i=(t(41594),t(5016));const s=TeambitMdxUiMdxScopeContext;var m=t(10583),l=["components"];function c(){return c=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)({}).hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},c.apply(null,arguments)}var p={},d="wrapper";function u(e){var n=e.components,t=function(e,n){if(null==e)return{};var t,o,r=function(e,n){if(null==e)return{};var t={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(n.includes(o))continue;t[o]=e[o]}return t}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],n.includes(t)||{}.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}(e,l);return(0,i.mdx)(d,c({},p,t,{components:n,mdxType:"MDXLayout"}),(0,i.mdx)(s.MDXScopeProvider,{components:{Envs:m.B},mdxType:"MDXScopeProvider"},(0,i.mdx)(m.B,{mdxType:"Envs"})))}u.isMDXComponent=!0;const x=[a],h=[r],v={compositions:[{displayName:"Logo",identifier:"Logo"}]};return o})()));
1
+ !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["teambit.envs/envs-preview"]=n():e["teambit.envs/envs-preview"]=n()}(self,(()=>(()=>{"use strict";var e={1148:(e,n,t)=>{var o={id:"teambit.envs/aspect-docs/envs@0.0.170",homepage:"https://bit.cloud/teambit/envs/aspect-docs/envs",exported:!0};Object.defineProperty(n,"__esModule",{value:!0}),n.default=d,i(t(1594));var r=t(5016),a=["components"];function i(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)({}).hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},s.apply(null,arguments)}function m(e,n){if(null==e)return{};var t,o,r=l(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],n.includes(t)||{}.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}function l(e,n){if(null==e)return{};var t={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(n.includes(o))continue;t[o]=e[o]}return t}i.__bit_component=o,s.__bit_component=o,m.__bit_component=o,l.__bit_component=o;var c={},p="wrapper";function d(e){var n=e.components,t=m(e,a);return(0,r.mdx)(p,s({},c,t,{components:n,mdxType:"MDXLayout"}),(0,r.mdx)("p",null,"The Envs aspect runs Bit environments and environment services, and defines their structure."),(0,r.mdx)("p",null,"A Bit environment is a development environment encapsulated in a Bit component. Just like other components, Bit environments can be instantly added to your workspace to start developing, testing, and building components with zero configurations.\nDifferent environments can be easily applied to multiple components in a workspace, and can be easily extended or customized to fit your needs and development stack. For example, try the React environment to start developing React components in your workspace.\nLike all Bit components, Bit environments are reusable, so you can share them across projects and teams to greatly speed up and standardize development."),(0,r.mdx)("h4",null,"Example"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'// Using the \'Node\' and \'React\' environments for different components in a Bit workspace.\n{\n "teambit.workspace/variants": {\n "components/ui": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {}\n }\n }\n}\n')),(0,r.mdx)("h4",null,"Features"),(0,r.mdx)("ul",null,(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Blazing fast environment setup"),": Setting up an environment requires nothing more than configuring a workspace to use a Bit extension.\nGet started in seconds and focus on the thing that matters most - delivering great features.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Multiple environments in a single workspace"),": No need to constantly switch between workspaces as different environments,\nset to handle different components, can all be used in parallel in a single workspace.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Less to learn"),": Using a pre-configured environment extension means you don't have to get into all the details of your build tooling.\nThat's a especially important when onboarding a new developer to your team.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Customizable and extensible"),": Environments can be extended to add or override configurations.\nQuickly add your own modifications to get an environment that best suits your needs.\nExport your environment extension to a remote scope to have it available to all your team.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Standardized development"),": Sharing and reusing environments makes it easier to maintain consistency in development across multiple decoupled Bit workspaces.")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},(0,r.mdx)("strong",{parentName:"p"},"Easy to maintain"),": Get your environment's latest updates with just a simple ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit import")," command. Roll-back as easily, if needed."))),(0,r.mdx)("h2",null,"CLI reference"),(0,r.mdx)("p",null,"Bit environments make use of Bit's CLI to execute their different services. That means, ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit test"),", for example, may execute different test runners, depending on the environment in use."),(0,r.mdx)("h4",null,"start"),(0,r.mdx)("p",null,"Runs the development serve (that includes running the Workspace UI)."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"// run the dev server\nbit start\n")),(0,r.mdx)("h4",null,"build"),(0,r.mdx)("p",null,"Runs the build pipeline (without tagging components with a new release version)."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit build\n")),(0,r.mdx)("h4",null,"test"),(0,r.mdx)("p",null,"Runs all tests."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit test\n")),(0,r.mdx)("h4",null,"compile"),(0,r.mdx)("p",null,"Compiles all components."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit compile\n")),(0,r.mdx)("h4",null,"lint"),(0,r.mdx)("p",null,"Get lint results for all components."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit lint\n")),(0,r.mdx)("h2",null,"Usage"),(0,r.mdx)("h3",null,"Setting a default environment for the workspace"),(0,r.mdx)("p",null,"Environments can only be configured using the ",(0,r.mdx)("inlineCode",{parentName:"p"},"teambit.workspace/variants")," workspace API. That means the ",(0,r.mdx)("inlineCode",{parentName:"p"},"teambit.workspace/workspace")," cannot be utilized to set an environment as the default for all components. To achieve a similar result, select all components using the ",(0,r.mdx)("inlineCode",{parentName:"p"},"*")," wildcard."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "*": {\n "teambit.react/react": {}\n }\n }\n}\n')),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{style:{color:"#c31313"}},"Never use the '*' wildcard in a workspace that uses multiple environments!"),"Instead, use exclusive namespaces or directories to select and configure each group of components to use its own environment (see an example in the next section)."),(0,r.mdx)("br",null),(0,r.mdx)("br",null),(0,r.mdx)("p",null,"To learn more, see the 'Troubleshooting' section."),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"A single component (with the same version) cannot use more than a single environment.")),(0,r.mdx)("h3",null,"Setting multiple environments"),(0,r.mdx)("p",null,"A single workspace can use different environments for different sets of components. Setting an environment on a specific group of components is done by selecting the group and applying the environment. This is done using ",(0,r.mdx)("inlineCode",{parentName:"p"},"teambit.workspace/variants"),"."),(0,r.mdx)("p",null,"For example, to set the Node and React environments on two sets of components (selected by their directory):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "components/ui": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {}\n }\n }\n}\n')),(0,r.mdx)("h3",null,"Extending an environment"),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"This section goes through the steps of extending the 'main runtime'.\nSee the 'Runtime Environment' section to learn how to extend multiple runtime environments.")),(0,r.mdx)("p",null,"An environment extension is a component that extends an existing environment. An extension file will have the ",(0,r.mdx)("inlineCode",{parentName:"p"},".extension.ts")," suffix as a convention."),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The ",(0,r.mdx)("inlineCode",{parentName:"p"},"*.extensions.ts")," pattern should only be used when no other 'runtime environment' is being extended other than the 'main runtime.' For more details, see the 'runtime environments' section.")),(0,r.mdx)("p",null,"To create and use an environment extension:"),(0,r.mdx)("ol",null,(0,r.mdx)("li",{parentName:"ol"},"Create the extension files"),(0,r.mdx)("li",{parentName:"ol"},"Use and extend an existing environment"),(0,r.mdx)("li",{parentName:"ol"},"Track the new component"),(0,r.mdx)("li",{parentName:"ol"},"Use the new extension component ID to set it in the workspace configuration file"),(0,r.mdx)("li",{parentName:"ol"},"(Optional) Tag the new component"),(0,r.mdx)("li",{parentName:"ol"},"(Optional) Export the component the make it available to be used by others")),(0,r.mdx)("h4",null,"1. Create the environment extension files"),(0,r.mdx)("p",null,"We'll start by creating a new extension:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"// In the workspace's root directory\nmkdir -p extensions/custom-react\ntouch extensions/custom-react/custom-react.extension.ts\ntouch extensions/custom-react/index.ts\n")),(0,r.mdx)("h4",null,"2. Use an existing environment to extend it"),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The below code uses the React environment as an example.")),(0,r.mdx)("p",null,"Our files will have the following code (the code below will only extend the ",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit.react/react")," environment without changing its configurations):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-tsx"},"// custom-react.extension.ts\n\n// Import from the Environments aspect to register this extension as an environment\nimport { EnvsMain, EnvsAspect } from '@teambit/envs';\n// Import from the React aspect to extend it\nimport { ReactAspect, ReactMain } from '@teambit/react';\n\nexport class CustomReactExtension {\n constructor(private react: ReactMain) {}\n\n // Set the necessary dependencies to be injected (by Bit) into the following 'provider' function\n static dependencies: any = [EnvsAspect, ReactAspect];\n\n static async provider([envs, react]: [EnvsMain, ReactMain]) {\n // The 'compose' methods to compose the overrides into a single environment\n const customReactEnv = react.compose([\n // This is were the environment's 'transformers' will be used to customize it\n ]);\n\n // Register this extension as an environment using the \"registerEnv\" slot (provided by the Environments aspect).\n envs.registerEnv(customReactEnv);\n\n return new CustomReactExtension(react);\n }\n}\n")),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"// index.ts\n\nimport { CustomReactExtension } from './custom-react.extension';\nexport { CustomReactExtension };\nexport default CustomReactExtension;\n")),(0,r.mdx)("h4",null,"3. Track the extension component"),(0,r.mdx)("p",null,"We'll then track the new component (with the 'my-extensions' namespace):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"bit add extensions/custom-react -n my-extensions\n")),(0,r.mdx)("h4",null,"4. Set the extension component in the workspace config file"),(0,r.mdx)("p",null,"Our extension component now has a component ID that can be used in our ",(0,r.mdx)("inlineCode",{parentName:"p"},"workspace.jsonc")," configuration file:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/workspace": {\n "name": "my-workspace",\n "icon": "https://image.flaticon.com/icons/svg/185/185034.svg",\n "defaultScope": "my-org.my-extensions"\n },\n "teambit.workspace/variants": {\n "*": {\n "my-org.my-extensions/custom-react": {}\n }\n }\n}\n')),(0,r.mdx)("h3",null,"The anatomy of an environment extension"),(0,r.mdx)("p",null,"An environment extension uses the following Bit components to extend an existing environment, and to register itself as an environment:"),(0,r.mdx)("ul",null,(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},"The ",(0,r.mdx)("strong",{parentName:"p"},'"base" environment')," (e.g, ",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit/react"),") is extended and customized using its override methods. Each override method, or \"environment transformer\", corresponds to a Bit extension component used by the environment (e.g, the TypeScript component). Using an 'environment transformer' will add new configurations to the relevant Bit component and will override any conflicting ones.",(0,r.mdx)("br",null)," The full list of available 'environment transformers' can be seen in the specific environment's documentation (see: React, React Native, Node).")),(0,r.mdx)("li",{parentName:"ul"},(0,r.mdx)("p",{parentName:"li"},"The ",(0,r.mdx)("strong",{parentName:"p"},"'Environments' component")," (",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit/envs"),") is used to:"),(0,r.mdx)("ol",{parentName:"li"},(0,r.mdx)("li",{parentName:"ol"},'Register the new environment using its "slot"'),(0,r.mdx)("li",{parentName:"ol"},'Override a "service handler". This is done to replace a Bit component used by an environment service. For example, to set the "compiler" service handler to use Babel instead of TypeScript')))),(0,r.mdx)("h4",null,"Override the config for a Bit component used by the environment"),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The current Envs API will soon be replaced.")),(0,r.mdx)("p",null,"The example below is of a React environment extension. This new environment overrides React's DevServer configuration by setting a new Webpack configuration file."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-tsx"},"// custom-react.extension.ts\n\n// Import from the Environments aspect to register this extension as an environment\nimport { EnvsMain, EnvsAspect } from '@teambit/envs';\n// Import from the React aspect to extend it and override its DevServer config\nimport { ReactAspect, ReactMain } from '@teambit/react';\n\nconst newWebpackConfig = require('./webpack/new-webpack-config');\n\nexport class CustomReactExtension {\n constructor(private react: ReactMain) {}\n\n // Set the necessary dependencies to be injected (by Bit) into the following 'provider' function\n static dependencies: any = [EnvsAspect, ReactAspect];\n\n static async provider([envs, react]: [EnvsMain, ReactMain]) {\n // The 'compose' methods to compose the overrides into a single environment\n const customReactEnv = react.compose([\n\n // Override the Webpack configs of the DevServer aspect\n react.overrideDevServerConfig(newWebpackRules);\n\n ]);\n\n // Register this extension as an environment using the \"registerEnv\" slot (provided by the Environments aspect).\n envs.registerEnv(customReactEnv);\n\n return new CustomReactExtension(react);\n }\n}\n")),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"// index.ts\nimport { CustomReactExtension } from './custom-react.extension';\nexport { CustomReactExtension };\nexport default CustomReactExtension;\n")),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The 'provider' method will be executed by Bit. Its Bit aspects dependencies are set in the ",(0,r.mdx)("inlineCode",{parentName:"p"},"dependencies")," variable, and will be injected into the method upon execution.")),(0,r.mdx)("h4",null,"Override a 'service handler' to replace a component used by the environment"),(0,r.mdx)("p",null,"The example below is of a React environment extension. This new environment overrides the 'service handler' for the compiler service. It replaces the Bit aspect used by it, TypeScript, with another Bit aspect, Babel."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-tsx"},"// custom-react.extension.ts\n\n// Import from the Environments aspect to register this extension as an environment\nimport { EnvsMain, EnvsAspect } from '@teambit/envs';\n// Import from the React aspect to extend it and override its DevServer config\nimport { ReactAspect, ReactMain } from '@teambit/react';\n// Import the Babel aspect to configure it and set it as the new compiler\nimport { BabelAspect, BabelMain } from '@teambit.compilation/babel';\n\nconst babelConfig = require('./babel/babel-config');\n\nexport class CustomReactExtension {\n constructor(private react: ReactMain) {}\n\n // Set the necessary dependencies to be injected (by Bit) into the following 'provider' function\n static dependencies: any = [EnvsAspect, ReactAspect, BabelAspect];\n\n static async provider([envs, react, babel]: [EnvsMain, ReactMain, BabelMain]) {\n // Create a new Babel compiler with the 'babelConfig' configurations\n const babelCompiler = babel.createCompiler({\n babelTransformOptions: babelConfig,\n });\n\n // Use the 'override' method provided by the 'environments' aspect (not the React aspect)\n const compilerOverride = envs.override({\n getCompiler: () => {\n return babelCompiler;\n },\n });\n\n // Compose the overrides into a single environment\n const customReactEnv = react.compose([compilerOverride]);\n\n // Register this extension as an environment using the \"registerEnv\" slot (provided by the 'environments' aspect).\n envs.registerEnv(customReactEnv);\n\n return new CustomReactExtension(react);\n }\n}\n")),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"// index.ts\nimport { CustomReactExtension } from './custom-react.extension';\nexport { CustomReactExtension };\nexport default CustomReactExtension;\n")),(0,r.mdx)("h2",null,"Concepts and tools"),(0,r.mdx)("h3",null,"Environment Services"),(0,r.mdx)("p",null,'To become a "one-stop-shop" for components, an environment "bundles" together different Environment Services provided by various Bit aspect components. These Environment Services enable other Bit aspects to integrate into Bit\'s component life-cycle features.'),(0,r.mdx)("p",null,"For example, the 'Tester' service (",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit.defender/tester"),") enables the React environment (",(0,r.mdx)("inlineCode",{parentName:"p"},"@teambit.react/react"),") to set 'Jest' (",(0,r.mdx)("inlineCode",{parentName:"p"},"teambit.defender/jest"),") as the default test runner for its components. This will enable Jest to be executed on the ",(0,r.mdx)("inlineCode",{parentName:"p"},"bbit test")," command, to be run as a pre-tag check, to output results using Bit's logger, and even to display the generated logs in the Workspace and Scope UIs (to name just a few examples)."),(0,r.mdx)("img",{src:"https://storage.googleapis.com/docs-images/react_env_ex.png",alt:"React env using Jest with the tester service",style:{width:"50%",minWidth:500}}),(0,r.mdx)("blockquote",null,(0,r.mdx)("h5",{parentName:"blockquote"},"Services VS Build Tasks"),(0,r.mdx)("p",{parentName:"blockquote"},"Environment Services which are executed either by the development server, or via the CLI, are not identical\nto Build Tasks that run as part of the Build Pipeline.\nFor example, the TypeScript configurations used for compilation by the development server are not the same as the ones used for a component's build process.")),(0,r.mdx)("h4",null,"Compiler"),(0,r.mdx)("p",null,"Runs the environment's selected compiler (for example, TypeScript)."),(0,r.mdx)("h4",null,"Tester"),(0,r.mdx)("p",null,"Runs the environment's selected test runner (for example, Jest)"),(0,r.mdx)("h4",null,"Linter"),(0,r.mdx)("p",null,"Runs the environment's selected linter (for example, ESLint)"),(0,r.mdx)("h4",null,"Documentation"),(0,r.mdx)("p",null,"Sets the template for the auto-generated component documentation, as well as the API for customizing component docs."),(0,r.mdx)("h4",null,"Build pipeline (CI)"),(0,r.mdx)("p",null,"Sets the sequence of build tasks to run before a component is tagged with a new version."),(0,r.mdx)("h4",null,"DevServer"),(0,r.mdx)("p",null,"Bundles all components and runs a server to display them, live (using \"hot reloading\") in the workspace UI. This includes rendering the 'compositions' as well as the documentation shown in the 'Overview' tab."),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"Even though different types of components, e.g. React and Node components, run on different servers (one for each environment) the workspace is explored and navigated through as if it where a single server.")),(0,r.mdx)("h4",null,"Package"),(0,r.mdx)("p",null,"Generates the node module package for components, with properties set by the environment."),(0,r.mdx)("h4",null,"Dependencies"),(0,r.mdx)("p",null,"Sets the default dependencies (as well as their version and type) for each component handled by the environment. That includes peer dependencies used for runtime (for example, ",(0,r.mdx)("inlineCode",{parentName:"p"},"react-dom"),") and dev dependencies (for example, ",(0,r.mdx)("inlineCode",{parentName:"p"},"@types/react"),")."),(0,r.mdx)("h4",null,"Bundler"),(0,r.mdx)("p",null,"Bundles components (compositions, docs, etc.) using the environment's bundler and bundling configurations. The generated assets are use both in development (when running the development server) and when exploring component's tagged releases (for example, in the scope UI)."),(0,r.mdx)("h3",null,"Service Handlers"),(0,r.mdx)("p",null,"Service Handlers are the link that binds an environment to the various Environment Services. They are methods in the Environment class that set an Environment Service to use a specific Bit extension component or a configuration file."),(0,r.mdx)("p",null,"For example, the React environment uses the Service Handler ",(0,r.mdx)("inlineCode",{parentName:"p"},"getCompiler()")," to configure the Compiler Environment Service to run the TypeScript extension component."),(0,r.mdx)("p",null,"Environment services run on various events. Whenever a service runs, it executes its corresponding service handler which consequently runs the configured aspect (in the previous example, that would be TypeScript)."),(0,r.mdx)("p",null,"Different components in a Bit workspace may use different environments. That means environment services need to execute their corresponding service handlers in the specific environment applied on the component currently being processed."),(0,r.mdx)("p",null,"For example, if ",(0,r.mdx)("em",{parentName:"p"},"component A")," uses the Node environment then the Compiler service processing that component, will execute the Service Handler (in that case, ",(0,r.mdx)("inlineCode",{parentName:"p"},"getCompiler"),") found in the Node environment."),(0,r.mdx)("h3",null,"List of service handlers"),(0,r.mdx)("h4",null,"getTester"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getTester(...args : any[]): Tester\n")),(0,r.mdx)("p",null,"Returns a test runner to be used by the Tester service."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n constructor(\n // ...\n\n // The Jest Aspect\n private jestAspect: JestMain\n ) {}\n\n // ...\n\n getTester(jestConfigPath: string, jestModule = jest): Tester {\n const jestConfig = require.resolve('./jest/jest.config');\n return this.jestAspect.createTester(jestConfig);\n }\n}\n")),(0,r.mdx)("h4",null,"getCompiler"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getCompiler(...args : any[]): Compiler\n")),(0,r.mdx)("p",null,"Returns a compiler to be used by the Compiler service."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n\nconstructor(\n // ...\n\n // The TypeScript aspect\n private tsAspect: TypescriptMain\n){}\n\n// ...\n\ngetCompiler() {\n const tsConfig = require.resolve('./typescript/tsconfig.json')\n return this.tsAspect.createCompiler(tsConfig);\n}\n")),(0,r.mdx)("h4",null,"getLinter"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getLinter(...args : any[]): Linter\n")),(0,r.mdx)("p",null,"Returns a linter to be used by the Linter service."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"import { ESLintLinter } from '@teambit/defender.eslint-linter';\n\nexport class ReactEnv implements Environment {\n\n constructor(){\n // ...\n\n // The ESLint aspect\n private eslint: ESLintMain\n }\n\n // ...\n\n getLinter() {\n return ESLintLinter.from({\n configPath: require.resolve('./eslint/eslintrc'),\n // resolve all plugins from the react environment.\n pluginsPath: __dirname,\n });\n }\n}\n")),(0,r.mdx)("h4",null,"getDevServer"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getDevServer(...args : any[]): DevServer\n")),(0,r.mdx)("p",null,"Returns a DevServer to be used by the DevServer service. (A DevServer is essentially the combination of the bundler configurations, together with a specified 'listen' port number)"),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n constructor(\n // ...\n\n // The Webpack aspect\n private webpack: WebpackMain\n ) {}\n\n // ...\n\n getDevServer(): DevServer {\n const withDocs = Object.assign(context, {\n entry: context.entry.concat([require.resolve('./docs')]),\n });\n return this.webpack.createDevServer(withDocs, webpackConfig);\n }\n}\n")),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"The above example runs the dev server with the environment's documentation template.")),(0,r.mdx)("h4",null,"getDocsTemplate"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getDocsTemplate(...args : any[]): string\n")),(0,r.mdx)("p",null,"Returns the path to the documentation template files, to be used by the Documentation service."),(0,r.mdx)("p",null,"For example (see docs files ",(0,r.mdx)("a",{parentName:"p",href:"https://github.com/teambit/bit/tree/master/scopes/react/react/docs"},"here"),"):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n // ...\n\n getDocsTemplate() {\n return require.resolve('./docs');\n }\n}\n")),(0,r.mdx)("h4",null,"getPackageJsonProps"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getPackageJsonProps(...args : any[]): object\n")),(0,r.mdx)("p",null,"Returns an object that defines the ",(0,r.mdx)("inlineCode",{parentName:"p"},"package.json")," properties of the packages generated for components handled by this environment. This configuration is used by the Packager service."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n // ...\n\n getPackageJsonProps() {\n return {\n main: 'dist/{main}.js',\n types: '{main}.ts',\n };\n }\n}\n")),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"As with any other 'merging' process, the properties defined in the above returned object will be added to configurations set by Bit.\nConflicting properties will be overridden by the properties that are set here.\nConfigurations that are set here may also be overridden, either by the 'pkg aspect' or by workspace configurations set using the 'variants API'.")),(0,r.mdx)("h4",null,"getDependencies"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getDependencies(component: any): Promise<DependencyList>\n")),(0,r.mdx)("p",null,"Returns an object that defines the default dependencies for components handled by this environment. The returned object is used by the Dependencies service."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n // ...\n\n async getDependencies() {\n return {\n dependencies: {\n react: '-',\n },\n devDependencies: {\n '@types/react': '16.9.43',\n '@types/jest': '~26.0.9',\n },\n peerDependencies: {\n react: '^16.13.1',\n 'react-dom': '^16.13.1',\n },\n };\n }\n}\n")),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"As with any other 'merging' process, the properties defined in the above returned object will be added to configurations set by Bit.\nConflicting properties will be overridden by the properties that are set here.\nConfigurations that are set here may also be overridden, either by the 'Dependency Resolver aspect' or by workspace configurations set using the 'variants API'.")),(0,r.mdx)("h4",null,"getBuildPipe"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"getBuildPipe(...args : any[]): BuildTask[]\n")),(0,r.mdx)("p",null,"Returns an array of build tasks to be used by the Builder service. Tasks will be added after and before Bit's pre-configured build tasks."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"export class ReactEnv implements Environment {\n constructor(\n // ...\n\n // The Compiler aspect\n private compiler: CompilerMain,\n\n // The Tester aspect\n private tester: TesterMain\n ) {}\n\n getBuildPipe(): BuildTask[] {\n return [this.compiler.createTask('StencilCompiler', this.getCompiler()), this.tester.task];\n }\n}\n")),(0,r.mdx)("h2",null,"Extending multiple runtime environments"),(0,r.mdx)("p",null,"An environment may operate in multiple runtime environments: 'Main', which runs on the server and 'UI' and 'Preview', which run on the browser.\nEach runtime environment runs all files that are named with its corresponding file pattern."),(0,r.mdx)("p",null,'An environment extension that runs on multiple runtimes is called "Aspect" an will have the following file structure:'),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre"},"|-- env-extension\n |-- env-extension.main.ts\n |-- env-extension.ui.tsx\n |-- env-extension.preview.tsx\n |-- env.extension.aspect.ts\n")),(0,r.mdx)("h3",null,"Registering an environment as an aspect"),(0,r.mdx)("p",null,"Create a ",(0,r.mdx)("inlineCode",{parentName:"p"},"*.aspect.ts")," file:"),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-shell"},"touch path/to/extension/env-extension.aspect.ts\n")),(0,r.mdx)("p",null,"Place the following lines to register your environment as a multiple runtime extension (a.k.a, an Aspect):"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"// env-extension.aspect.ts\n\nimport { Aspect } from '@teambit/harmony';\n\nexport const ReactWithProvidersAspect = Aspect.create({\n // The ID should be your component's ID\n // Make sure to track your extension component before registering it as an Aspect\n id: 'my-scope.react-with-providers',\n});\n")),(0,r.mdx)("h3",null,"Registering a runtime extension"),(0,r.mdx)("p",null,"An aspect is a collection of multiple extensions, each extending a specific runtime."),(0,r.mdx)("p",null,"Register each runtime extension to its corresponding runtime, using the ",(0,r.mdx)("inlineCode",{parentName:"p"},"addRuntime")," method."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-typescript"},"// react-extension.preview.ts\n\nimport { PreviewRuntime } from '@teambit/preview';\nimport { ReactAspect, ReactPreview } from '@teambit/react';\nimport { ReactExtensionAspect } from './react-with-providers.aspect';\n\nexport class ReactExtensionPreview {\n static runtime = PreviewRuntime;\n\n static dependencies = [ReactAspect];\n\n static async provider([react]: [ReactPreview]) {\n return new ReactExtensionPreview();\n }\n}\n\nReactExtensionAspect.addRuntime(ReactExtensionPreview);\n")),(0,r.mdx)("h3",null,"Runtime environments"),(0,r.mdx)("h4",null,"Main"),(0,r.mdx)("p",null,(0,r.mdx)("inlineCode",{parentName:"p"},"*.main.runtime.ts")),(0,r.mdx)("p",null,"Node files that run in a node runtime environments and outputs to the terminal."),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Example:"),"\nThe React environment TypeScript compiler will be extended in the main runtime."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-typescript"},"// react-extension.main.ts\n\nimport { MainRuntime } from '@teambit/cli';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ReactAspect, ReactMain } from '@teambit/react';\nimport { ReactExtensionAspect } from './react-extension.aspect';\n\nconst tsconfig = require('./typescript/tsconfig.json');\n\nexport class ReactExtensionMain {\n constructor(\n private react: ReactMain,\n private envs: EnvsMain\n ) {}\n\n icon() {\n return 'https://static.bit.dev/extensions-icons/react.svg';\n }\n\n static runtime = MainRuntime;\n\n static dependencies = [ReactAspect, EnvsAspect];\n\n static async provider([react, envs]: [ReactMain, EnvsMain]) {\n const reactExtension = envs.compose(react, [react.overrideTsConfig(tsconfig)]);\n envs.registerEnv(reactExtension);\n return new ReactWithProvidersMain(react, envs);\n }\n}\n\nReactExtensionAspect.addRuntime(ReactExtensionMain);\n")),(0,r.mdx)("h4",null,"UI"),(0,r.mdx)("p",null,(0,r.mdx)("inlineCode",{parentName:"p"},"*.ui.runtime.[ts,js,jsx,tsx]")),(0,r.mdx)("p",null,"JSX files that run in the browser, as part of the Workspace/Scope UI bundle that is being served by the development server."),(0,r.mdx)("h4",null,"Preview"),(0,r.mdx)("p",null,(0,r.mdx)("inlineCode",{parentName:"p"},"*.preview.runtime.*")),(0,r.mdx)("p",null,"These files are served by the environment's server, as part of the environment's preview bundle (i.e, the component compositions and documentation).\n(The 'preview' runtime is rendered in the Workspace/Scope UI using an iframe.)"),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Example:"),'\nA new composition provider that will "wrap" every composition using that environment will be added using the preview runtime since it is part of the component compositions (which are being served to the browser by the environment\'s server).'),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-typescript"},"// react-extension.preview.ts\n\nimport { PreviewRuntime } from '@teambit/preview';\nimport { ReactAspect, ReactPreview } from '@teambit/react';\nimport { ReactExtensionAspect } from './react-with-providers.aspect';\nimport { Center } from './my-providers/center';\n\nexport class ReactExtensionPreview {\n static runtime = PreviewRuntime;\n\n static dependencies = [ReactAspect];\n\n static async provider([react]: [ReactPreview]) {\n react.registerProvider(Center);\n\n return new ReactExtensionPreview();\n }\n}\n\nReactExtensionAspect.addRuntime(ReactExtensionPreview);\n")),(0,r.mdx)("h2",null,"Troubleshooting"),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Problem:")," Components that are configured to use a specific environment, use the workspace's default environment, instead."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "*": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {}\n }\n }\n}\n')),(0,r.mdx)("p",null,"In the above example, components in the ",(0,r.mdx)("inlineCode",{parentName:"p"},"components/utils")," directory are set to use the Node environment.\nSince that selection is more specific than the one done using the ",(0,r.mdx)("inlineCode",{parentName:"p"},"*")," wildcard selector, it is expected to override it."),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Understanding the problem:"),"\nTo select the right configurations for each component, the 'Variants' aspect sorts all workspace configurations, from the most specific to the most general.\nThe first configuration set on an aspect (the most specific one) will be the one that is selected for that aspect.\nThat means, once Variants encounters configurations for an aspect, it stops looking for additional configurations for that specific aspect."),(0,r.mdx)("p",null,"Each environment is considered as a different aspect, even though they are all under the \"environments\" category and can only be used once per component.\n'Variants' does not understand categories, only individual aspects and therefore, cannot override one environment with a different environment."),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Solution #1:")),(0,r.mdx)("p",null,"Remove the ",(0,r.mdx)("inlineCode",{parentName:"p"},"*")," general selection and use only specific and exclusive selectors to configure environments\n(that means your workspace directories/ namespaces need to be structured in a way that enables complete selection of all components using selectors that are exclusive)."),(0,r.mdx)("p",null,"For example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "components/react": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {}\n }\n }\n}\n')),(0,r.mdx)("p",null,(0,r.mdx)("strong",{parentName:"p"},"Solution #2:"),"\nConfigure the environment using the Envs config API."),(0,r.mdx)("p",null,"Example:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-json"},'{\n "teambit.workspace/variants": {\n "*": {\n "teambit.react/react": {}\n },\n "components/utils": {\n "teambit.harmony/node": {},\n "teambit.envs/envs": {\n "env": "teambit.harmony/node"\n }\n }\n }\n}\n')),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},"Notice how the Node environment was added also as a standalone aspect, to ensure that it is registered as a dependency of the selected components.")),(0,r.mdx)("hr",null))}d.__bit_component=o,d.isMDXComponent=!0},3761:function(e,n,t){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.Envs=void 0;var r=t(1148);Object.defineProperty(n,"Envs",{enumerable:!0,get:function(){return o(r).default}})},1560:(e,n,t)=>{var o={id:"teambit.envs/envs@1.0.426",homepage:"https://bit.cloud/teambit/envs/envs",exported:!0};function r(){const e=a(t(1594));return r=function(){return e},e}function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Logo=void 0,r.__bit_component=o,a.__bit_component=o;const i=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/env.svg"}));i.__bit_component=o,n.Logo=i},5016:e=>{e.exports=MdxJsReact},1594:e=>{e.exports=React}},n={};function t(o){var r=n[o];if(void 0!==r)return r.exports;var a=n[o]={exports:{}};return e[o].call(a.exports,a,a.exports,t),a.exports}t.d=(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};t.r(o),t.d(o,{compositions:()=>x,compositions_metadata:()=>v,overview:()=>h});var r={};t.r(r),t.d(r,{default:()=>u});var a=t(1560),i=(t(1594),t(5016));const s=TeambitMdxUiMdxScopeContext;var m=t(3761),l=["components"];function c(){return c=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)({}).hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},c.apply(null,arguments)}var p={},d="wrapper";function u(e){var n=e.components,t=function(e,n){if(null==e)return{};var t,o,r=function(e,n){if(null==e)return{};var t={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(n.includes(o))continue;t[o]=e[o]}return t}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],n.includes(t)||{}.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}(e,l);return(0,i.mdx)(d,c({},p,t,{components:n,mdxType:"MDXLayout"}),(0,i.mdx)(s.MDXScopeProvider,{components:{Envs:m.Envs},mdxType:"MDXScopeProvider"},(0,i.mdx)(m.Envs,{mdxType:"Envs"})))}u.isMDXComponent=!0;const x=[a],h=[r],v={compositions:[{displayName:"Logo",identifier:"Logo"}]};return o})()));
@@ -11693,7 +11693,7 @@
11693
11693
  "componentId": {
11694
11694
  "scope": "teambit.component",
11695
11695
  "name": "sources",
11696
- "version": "0.0.33"
11696
+ "version": "0.0.34"
11697
11697
  }
11698
11698
  }
11699
11699
  }
@@ -11763,7 +11763,7 @@
11763
11763
  "componentId": {
11764
11764
  "scope": "teambit.component",
11765
11765
  "name": "sources",
11766
- "version": "0.0.33"
11766
+ "version": "0.0.34"
11767
11767
  }
11768
11768
  }
11769
11769
  },
@@ -11861,7 +11861,7 @@
11861
11861
  "componentId": {
11862
11862
  "scope": "teambit.component",
11863
11863
  "name": "sources",
11864
- "version": "0.0.33"
11864
+ "version": "0.0.34"
11865
11865
  }
11866
11866
  }
11867
11867
  },
@@ -28552,7 +28552,7 @@
28552
28552
  "componentId": {
28553
28553
  "scope": "teambit.component",
28554
28554
  "name": "sources",
28555
- "version": "0.0.33"
28555
+ "version": "0.0.34"
28556
28556
  }
28557
28557
  }
28558
28558
  }
@@ -28622,7 +28622,7 @@
28622
28622
  "componentId": {
28623
28623
  "scope": "teambit.component",
28624
28624
  "name": "sources",
28625
- "version": "0.0.33"
28625
+ "version": "0.0.34"
28626
28626
  }
28627
28627
  }
28628
28628
  },
@@ -28720,7 +28720,7 @@
28720
28720
  "componentId": {
28721
28721
  "scope": "teambit.component",
28722
28722
  "name": "sources",
28723
- "version": "0.0.33"
28723
+ "version": "0.0.34"
28724
28724
  }
28725
28725
  }
28726
28726
  },
@@ -32182,7 +32182,7 @@
32182
32182
  "componentId": {
32183
32183
  "scope": "teambit.envs",
32184
32184
  "name": "envs",
32185
- "version": "1.0.425"
32185
+ "version": "1.0.426"
32186
32186
  },
32187
32187
  "taggedModuleExports": []
32188
32188
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_path","data","require","_findRoot","_interopRequireDefault","_toolboxModules","_bit","_fsExtra","_pLocate","_commentJson","_cli","_component","_graphql","_issues","_pMapSeries","_componentIssues","_harmony","_logger","_bitError","_toolboxArray","_lodash","_worker","_componentId","_environments","_environments2","_runtime","_envDefinition","_envServiceList","_envs","_env","_exceptions","_env2","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DEFAULT_ENV","exports","EnvsMain","icon","constructor","config","harmony","envSlot","logger","servicesRegistry","componentMain","loggerMain","workerMain","envJsoncMergeCustomizerSlot","Set","createEnvironment","components","createRuntime","addFailedToLoadEnvs","id","failedToLoadEnvs","add","envIds","addFailedToLoadExt","failedToLoadExt","has","resetFailedToLoadEnvs","clear","getFailedToLoadEnvs","Array","from","extId","uniq","getDefaultEnv","defaultEnv","get","Error","EnvDefinition","getCoreEnvsIds","compose","targetEnv","envTransformers","a","reduce","acc","transformer","override","propsToOverride","env","merge","sourceEnv","allNames","prototype","getPrototypeOf","name","getOwnPropertyNames","key","fn","includes","bind","hasEnvManifest","envComponent","legacyFiles","undefined","files","filesystem","envJson","find","file","relative","getEnvManifest","object","parse","contents","toString","resolvedObject","recursivelyMergeWithParentManifest","path","originPath","extends","parentPackageName","parentPath","resolveFrom","parentResolvedPath","findRoot","existsSync","info","parentEnvJsoncPath","map","fileName","join","filePath","consoleWarning","parentStr","readFileSync","parentObject","mergedObject","mergeEnvManifests","parent","child","merged","mergeCustomizer","getAllRegisteredEnvJsoncCustomizers","customizer","oneMerged","hasEnvManifestById","envId","requesting","component","getEnvComponentByEnvId","getEnvData","envsData","state","aspects","EnvsAspect","getEnvIdFromEnvsData","ignoreVersion","rawEnvId","envIdWithoutVersion","ComponentID","fromString","toStringWithoutVersion","getEnvId","envIdFromEnvData","withVersion","resolveEnv","withVersionMatch","toArray","withVersionMatchId","exactMatch","exactMatchId","EnvNotConfiguredForComponent","isUsingCoreEnv","isCoreEnv","getEnv","envDef","getEnvDefinitionByStringId","EnvNotFound","getEnvComponent","host","getHost","newId","resolveComponentId","BitError","getOrCalculateEnv","err","calculateEnv","getDescriptor","calcDescriptor","opts","componentDescriptor","getComponentEnvDescriptor","envComponentSelfDescriptor","getEnvSelfDescriptor","result","self","isEnvRegistered","getEnvFromComponent","rawServices","getServices","services","toObject","selfDescriptor","getEnvDescriptorFromEnvDef","__getDescriptor","systemDescriptor","type","split","description","matchedEntry","entries","aspectEntry","calculateEnvId","envIdFromEnvsConfig","getEnvIdFromEnvsConfig","envIdFromEnvsConfigWithoutVersion","ids","findFirstEnv","finalId","getEnvDefinitionById","skipWarnings","printWarningIfFirstTime","envDefFromList","getAllEnvsConfiguredOnComponent","getEnvFromEnvsConfig","getEnvsNotFromEnvsConfig","hasEnvConfigured","Boolean","getAllRegisteredEnvsIds","envData","getAllRegisteredEnvs","customizerEntry","getEnvPlugin","EnvPlugin","getEnvIdFromEnvsLegacyExtensions","extensions","envsAspect","findCoreExtension","calculateEnvIdFromExtensions","extension","extensionId","stringId","calculateEnvFromExtensions","getEnvDefinitionByLegacyExtension","isFoundWithoutVersion","pLocate","idWithoutVersion","isCoreAspect","envDefWithoutVersion","hasManifest","isUsingEnvEnv","finalEnvId","getEnvDefinition","allVersions","all","first","head","getEnvsEnvDefinition","message","alreadyShownWarning","isUsingAspectEnv","isEnv","registerService","envServices","register","allServices","currentServices","service","implements","warn","EnvServiceList","registerEnv","registerEnvJsoncMergeCustomizer","addNonLoadedEnvAsComponentIssues","pMapSeries","envIdStr","foundComp","c","issues","getOrCreate","IssuesClasses","ExternalEnvWithoutVersion","componentId","NonLoadedEnv","Runtime","aggregateByDefs","throwForDuplicateComponents","envsMap","Promise","envAspectDef","getEnvAspectDef","EnvRuntime","resolvedAspects","resolveAspects","MainRuntime","requestedOnly","filterByRuntime","useScopeAspectsCapsule","def","idsStr","duplications","findDuplications","provider","graphql","loggerAspect","cli","worker","context","createLogger","envs","registerShowFragments","EnvFragment","registerAddComponentsIssues","envsCmd","EnvsCmd","commands","ListEnvsCmd","GetEnvCmd","environmentsSchema","Slot","withType","GraphqlAspect","LoggerAspect","ComponentAspect","CLIAspect","WorkerAspect","IssuesAspect","addRuntime"],"sources":["environments.main.runtime.ts"],"sourcesContent":["import { join } from 'path';\nimport findRoot from 'find-root';\nimport { resolveFrom } from '@teambit/toolbox.modules.module-resolver';\nimport { isCoreAspect } from '@teambit/bit';\nimport { existsSync, readFileSync } from 'fs-extra';\nimport pLocate from 'p-locate';\nimport { parse } from 'comment-json';\nimport { SourceFile } from '@teambit/component.sources';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect, ComponentMain } from '@teambit/component';\nimport type { EnvPolicyConfigObject } from '@teambit/dependency-resolver';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { IssuesAspect, IssuesMain } from '@teambit/issues';\nimport type { EnvJsoncPatterns } from '@teambit/dev-files';\nimport pMapSeries from 'p-map-series';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Harmony, Slot, SlotRegistry } from '@teambit/harmony';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport type { AspectDefinition } from '@teambit/aspect-loader';\nimport { ExtensionDataList, ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { BitError } from '@teambit/bit-error';\nimport { findDuplications } from '@teambit/toolbox.array.duplications-finder';\nimport { head, uniq } from 'lodash';\nimport { WorkerAspect, WorkerMain } from '@teambit/worker';\nimport { ComponentID } from '@teambit/component-id';\nimport { EnvService } from './services';\nimport { Environment } from './environment';\nimport { EnvsAspect } from './environments.aspect';\nimport { environmentsSchema } from './environments.graphql';\nimport { EnvRuntime, Runtime } from './runtime';\nimport { EnvDefinition } from './env-definition';\nimport { EnvServiceList } from './env-service-list';\nimport { EnvsCmd, GetEnvCmd, ListEnvsCmd } from './envs.cmd';\nimport { EnvFragment } from './env.fragment';\nimport { EnvNotFound, EnvNotConfiguredForComponent } from './exceptions';\nimport { EnvPlugin } from './env.plugin';\n\nexport type EnvJsonc = {\n extends?: string;\n policy?: EnvPolicyConfigObject;\n patterns?: EnvJsoncPatterns;\n};\n\nexport type EnvJsoncMergeCustomizer = (parentObj: EnvJsonc, childObj: EnvJsonc) => Partial<EnvJsonc>;\n\nexport type EnvsRegistry = SlotRegistry<Environment>;\nexport type EnvJsoncMergeCustomizerRegistry = SlotRegistry<EnvJsoncMergeCustomizer>;\n\nexport type EnvsConfig = {\n env: string;\n options: EnvOptions;\n};\n\ntype GetCalcEnvOptions = {\n skipWarnings?: boolean;\n};\n\nexport type EnvOptions = {};\n\nexport type EnvTransformer = (env: Environment) => Environment;\n\nexport type ServicesRegistry = SlotRegistry<Array<EnvService<any>>>;\n\nexport type RegularCompDescriptor = {\n id: string;\n icon?: string;\n type?: string;\n name?: string;\n description?: string;\n};\nexport type EnvCompDescriptorProps = RegularCompDescriptor & {\n services?: {\n env: {\n id: string;\n icon: string;\n name?: string;\n description?: string;\n };\n services: Array<{\n id: string;\n name?: string;\n description?: string;\n data: any;\n }>;\n };\n};\n\nexport type EnvCompDescriptor = EnvCompDescriptorProps & {\n self?: EnvCompDescriptorProps;\n};\n\nexport type Descriptor = RegularCompDescriptor | EnvCompDescriptor;\n\nexport const DEFAULT_ENV = 'teambit.harmony/node';\n\nexport class EnvsMain {\n /**\n * Envs that are failed to load\n */\n private failedToLoadEnvs = new Set<string>();\n /**\n * Extensions that are failed to load\n * We use this as sometime when we couldn't load an extension we don't know if it's an env or not\n * We should ideally take it from the aspect loader aspect, but right now the aspect loader is using envs\n */\n private failedToLoadExt = new Set<string>();\n /**\n * Ids of envs (not neccesrraly loaded successfully)\n */\n public envIds = new Set<string>();\n\n static runtime = MainRuntime;\n\n private alreadyShownWarning = {};\n\n /**\n * icon of the extension.\n */\n icon() {\n return `<svg width=\"50\" height=\"50\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"25\" cy=\"25\" r=\"20\"/>\n </svg>`;\n }\n\n constructor(\n /**\n * environments extension configuration.\n */\n readonly config: EnvsConfig,\n\n /**\n * harmony context.\n */\n private harmony: Harmony,\n\n /**\n * slot for allowing extensions to register new environment.\n */\n private envSlot: EnvsRegistry,\n\n private logger: Logger,\n\n private servicesRegistry: ServicesRegistry,\n\n private componentMain: ComponentMain,\n\n private loggerMain: LoggerMain,\n\n private workerMain: WorkerMain,\n\n private envJsoncMergeCustomizerSlot: EnvJsoncMergeCustomizerRegistry\n ) {}\n\n /**\n * creates a new runtime environments for a set of components.\n */\n async createEnvironment(components: Component[]): Promise<Runtime> {\n return this.createRuntime(components);\n }\n\n /**\n *\n * @param id\n */\n /**\n * This function adds an extension ID to a set of failed to load extensions.\n * This mostly used by the aspect loader to add such issues\n * Then it is used to hide different errors that are caused by the same issue.\n * @param {string} id - string - represents the unique identifier of an extension that failed to load.\n */\n addFailedToLoadEnvs(id: string) {\n this.failedToLoadEnvs.add(id);\n this.envIds.add(id);\n }\n\n addFailedToLoadExt(id: string) {\n this.failedToLoadExt.add(id);\n if (this.envIds.has(id)) {\n this.addFailedToLoadEnvs(id);\n }\n }\n\n resetFailedToLoadEnvs() {\n this.failedToLoadEnvs.clear();\n this.failedToLoadExt.clear();\n }\n\n getFailedToLoadEnvs() {\n const failedToLoadEnvs = Array.from(this.failedToLoadEnvs);\n // Add all extensions which are also envs\n for (const extId of this.failedToLoadExt) {\n if (this.envIds.has(extId)) {\n failedToLoadEnvs.push(extId);\n }\n }\n return uniq(failedToLoadEnvs);\n }\n\n /**\n * get the configured default env.\n */\n getDefaultEnv(): EnvDefinition {\n const defaultEnv = this.envSlot.get(DEFAULT_ENV);\n if (!defaultEnv) throw new Error('default env must be set.');\n\n return new EnvDefinition(DEFAULT_ENV, defaultEnv);\n }\n\n getCoreEnvsIds(): string[] {\n return [\n 'teambit.harmony/aspect',\n 'teambit.react/react',\n 'teambit.harmony/node',\n 'teambit.react/react-native',\n 'teambit.html/html',\n 'teambit.mdx/mdx',\n 'teambit.envs/env',\n 'teambit.mdx/readme',\n 'teambit.harmony/bit-custom-aspect',\n ];\n }\n\n /**\n * compose a new environment from a list of environment transformers.\n */\n compose(targetEnv: Environment, envTransformers: EnvTransformer[]) {\n const a = envTransformers.reduce((acc, transformer) => {\n acc = transformer(acc);\n return acc;\n }, targetEnv);\n\n return a;\n }\n\n /**\n * create an env transformer which overrides specific env properties.\n */\n override(propsToOverride: Environment): EnvTransformer {\n return (env: Environment) => {\n return this.merge(propsToOverride, env);\n };\n }\n\n /**\n * compose two environments into one.\n */\n merge<T extends Environment, S extends Environment>(targetEnv: Environment, sourceEnv: Environment): T & S {\n const allNames = new Set<string>();\n const keys = ['icon', 'name', 'description'];\n for (let o = sourceEnv; o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const name of Object.getOwnPropertyNames(o)) {\n allNames.add(name);\n }\n }\n\n allNames.forEach((key: string) => {\n const fn = sourceEnv[key];\n if (targetEnv[key]) return;\n if (keys.includes(key)) targetEnv[key] = fn;\n if (!fn || !fn.bind) {\n return;\n }\n targetEnv[key] = fn.bind(sourceEnv);\n });\n\n return targetEnv as T & S;\n }\n\n /**\n * This function checks if an environment manifest file exists in a given component or set of legacy files.\n * @param {Component} [envComponent] - A component object that represents an environment. It contains information about\n * the files and directories that make up the environment.\n * @param {SourceFile[]} [legacyFiles] - An optional array of SourceFile objects representing the files in the legacy\n * file system. If this parameter is not provided, the function will attempt to retrieve the files from the envComponent\n * parameter.\n * @returns a boolean value indicating whether an `env.jsonc` or `env.json` file exists in the `files` array of either\n * the `envComponent` object or the `legacyFiles` array. If neither `envComponent` nor `legacyFiles` are provided, the\n * function returns `undefined`.\n */\n hasEnvManifest(envComponent?: Component, legacyFiles?: SourceFile[]): boolean | undefined {\n if (!envComponent && !legacyFiles) return undefined;\n // @ts-ignore\n const files = legacyFiles || envComponent.filesystem.files;\n const envJson = files.find((file) => {\n return file.relative === 'env.jsonc' || file.relative === 'env.json';\n });\n\n if (!envJson) return false;\n return true;\n }\n\n getEnvManifest(envComponent?: Component, legacyFiles?: SourceFile[]): EnvJsonc | undefined {\n // TODO: maybe throw an error here?\n if (!envComponent && !legacyFiles) return undefined;\n // @ts-ignore\n const files = legacyFiles || envComponent.filesystem.files;\n const envJson = files.find((file) => {\n return file.relative === 'env.jsonc' || file.relative === 'env.json';\n });\n\n if (!envJson) return undefined;\n\n const object: EnvJsonc = parse(envJson.contents.toString('utf8'), undefined, true);\n const resolvedObject = this.recursivelyMergeWithParentManifest(object, envJson.path);\n return resolvedObject;\n }\n\n recursivelyMergeWithParentManifest(object: EnvJsonc, originPath: string): EnvJsonc {\n if (!object.extends) return object;\n const parentPackageName = object.extends;\n const parentPath = resolveFrom(originPath, [parentPackageName]);\n const parentResolvedPath = findRoot(parentPath);\n if (!parentResolvedPath || !existsSync(parentResolvedPath)) {\n this.logger.info(`failed finding parent manifest for ${parentPackageName} at ${parentResolvedPath}`);\n }\n const parentEnvJsoncPath = ['env.jsonc', 'env.json']\n .map((fileName) => join(parentResolvedPath, fileName))\n .find((filePath) => {\n return existsSync(filePath);\n });\n if (!parentEnvJsoncPath) {\n this.logger.consoleWarning(\n `failed finding parent manifest for ${parentPackageName} at ${parentResolvedPath} referred from ${originPath}`\n );\n return object;\n }\n const parentStr = readFileSync(parentEnvJsoncPath).toString('utf8');\n const parentObject: EnvJsonc = parse(parentStr, undefined, true);\n const mergedObject = this.mergeEnvManifests(parentObject, object);\n if (mergedObject.extends) {\n return this.recursivelyMergeWithParentManifest(mergedObject, parentEnvJsoncPath);\n }\n return mergedObject;\n }\n\n mergeEnvManifests(parent: EnvJsonc, child: EnvJsonc): EnvJsonc {\n let merged: EnvJsonc = {};\n const mergeCustomizer = this.getAllRegisteredEnvJsoncCustomizers();\n for (const customizer of mergeCustomizer) {\n const oneMerged = customizer(parent, child);\n merged = { ...merged, ...oneMerged };\n }\n // Take extends specifically from the parent so we can propagate it to the next parent\n if (parent.extends) {\n merged.extends = parent.extends;\n }\n return merged;\n }\n\n async hasEnvManifestById(envId: string, requesting: string): Promise<boolean | undefined> {\n const component = await this.getEnvComponentByEnvId(envId, requesting);\n return this.hasEnvManifest(component);\n }\n\n getEnvData(component: Component): Descriptor {\n let envsData = component.state.aspects.get(EnvsAspect.id);\n if (!envsData) {\n // TODO: remove this once we re-export old components used to store the data here\n envsData = component.state.aspects.get('teambit.workspace/workspace');\n }\n if (!envsData) throw new Error(`env was not configured on component ${component.id.toString()}`);\n return envsData.data as Descriptor;\n }\n\n /**\n * Return the id of the env as configured in the envs data (without version by default)\n * 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\n * As this version is stay up to date during tagging the env along with the component\n * @param component\n * @param ignoreVersion\n */\n private getEnvIdFromEnvsData(component: Component, ignoreVersion = true): string | undefined {\n const envsData = this.getEnvData(component);\n if (!envsData) return undefined;\n const rawEnvId = envsData.id;\n if (!rawEnvId) return undefined;\n if (!ignoreVersion) return rawEnvId;\n const envIdWithoutVersion = ComponentID.fromString(rawEnvId).toStringWithoutVersion();\n return envIdWithoutVersion;\n }\n\n /**\n * get the env id of the given component.\n */\n getEnvId(component: Component): string {\n const envIdFromEnvData = this.getEnvIdFromEnvsData(component);\n if (!envIdFromEnvData) {\n // This should never happen\n throw new Error(`no env found for ${component.id.toString()}`);\n }\n const withVersion = this.resolveEnv(component, envIdFromEnvData);\n const withVersionMatch = this.envSlot.toArray().find(([envId]) => {\n return withVersion?.toString() === envId;\n });\n const withVersionMatchId = withVersionMatch?.[0];\n if (withVersionMatchId) return withVersionMatchId;\n\n // Handle core envs\n const exactMatch = this.envSlot.toArray().find(([envId]) => {\n return envIdFromEnvData === envId;\n });\n\n const exactMatchId = exactMatch?.[0];\n if (exactMatchId) return exactMatchId;\n\n if (!withVersion) throw new EnvNotConfiguredForComponent(envIdFromEnvData, component.id.toString());\n return withVersion.toString();\n }\n\n isUsingCoreEnv(component: Component): boolean {\n const envId = this.getEnvId(component);\n return this.isCoreEnv(envId);\n }\n\n isCoreEnv(envId: string): boolean {\n return this.getCoreEnvsIds().includes(envId);\n }\n\n /**\n * get the env of the given component.\n * In case you are asking for the env during on load you should use calculateEnv instead\n */\n getEnv(component: Component): EnvDefinition {\n const id = this.getEnvId(component);\n const envDef = this.getEnvDefinitionByStringId(id);\n if (envDef) {\n return envDef;\n }\n // Do not allow a non existing env\n throw new EnvNotFound(id, component.id.toString());\n }\n\n /**\n * get the env component of the given component.\n */\n async getEnvComponent(component: Component): Promise<Component> {\n const envId = this.getEnvId(component);\n return this.getEnvComponentByEnvId(envId, component.id.toString());\n }\n\n /**\n * get the env component by the env id.\n */\n async getEnvComponentByEnvId(envId: string, requesting?: string): Promise<Component> {\n const host = this.componentMain.getHost();\n const newId = await host.resolveComponentId(envId);\n const envComponent = await host.get(newId);\n if (!envComponent) {\n throw new BitError(`can't load env. env id is ${envId} used by component ${requesting || 'unknown'}`);\n }\n return envComponent;\n }\n\n /**\n * get the env of the given component.\n * This will try to use the regular getEnv but fallback to the calculate env (in case you are using it during on load)\n * This is safe to be used on onLoad as well\n */\n getOrCalculateEnv(component: Component): EnvDefinition {\n try {\n return this.getEnv(component);\n } catch (err) {\n return this.calculateEnv(component);\n }\n }\n\n /**\n * get an environment Descriptor.\n */\n getDescriptor(component: Component): Descriptor | undefined {\n const envsData = this.getEnvData(component);\n envsData.id = this.resolveEnv(component, envsData.id)?.toString() || envsData.id;\n return envsData;\n }\n\n async calcDescriptor(component: Component, opts: GetCalcEnvOptions = {}): Promise<Descriptor | undefined> {\n const componentDescriptor = await this.getComponentEnvDescriptor(component, opts);\n if (!componentDescriptor) return undefined;\n const envComponentSelfDescriptor = await this.getEnvSelfDescriptor(component);\n const result = envComponentSelfDescriptor\n ? { ...componentDescriptor, self: envComponentSelfDescriptor }\n : componentDescriptor;\n return result;\n }\n\n /**\n * Get env descriptor from the env itself if the component is an env\n * This will be empty for regular component, and will only contain data for env themself\n */\n private async getEnvSelfDescriptor(envComponent: Component): Promise<EnvCompDescriptorProps | undefined> {\n // !important calculate only on the env itself.\n if (!this.isEnvRegistered(envComponent.id.toString())) {\n return undefined;\n }\n\n const envDef = this.getEnvFromComponent(envComponent);\n if (!envDef) return undefined;\n\n const rawServices = this.getServices(envDef);\n const services = rawServices.toObject();\n // const selfDescriptor = (await this.getEnvDescriptorFromEnvDef(envDef)) || {};\n const selfDescriptor = await this.getEnvDescriptorFromEnvDef(envDef);\n\n if (!selfDescriptor) return undefined;\n return {\n ...selfDescriptor,\n services,\n };\n }\n\n /**\n * Get env descriptor from the env that a given component is using\n */\n private async getComponentEnvDescriptor(\n component: Component,\n opts: GetCalcEnvOptions = {}\n ): Promise<RegularCompDescriptor | undefined> {\n const envDef = this.calculateEnv(component, opts);\n return this.getEnvDescriptorFromEnvDef(envDef);\n }\n\n private async getEnvDescriptorFromEnvDef(envDef: EnvDefinition): Promise<RegularCompDescriptor | undefined> {\n if (!envDef.env.__getDescriptor || typeof envDef.env.__getDescriptor !== 'function') {\n return undefined;\n }\n const systemDescriptor = await envDef.env.__getDescriptor();\n\n return {\n type: systemDescriptor.type,\n // Make sure to store the env id in the data without the version\n // The version should always come from the aspect id configured on the component\n id: envDef.id.split('@')[0],\n name: envDef.name,\n icon: envDef.env.icon,\n description: envDef.description,\n };\n }\n\n resolveEnv(component: Component, id: string) {\n const matchedEntry = component.state.aspects.entries.find((aspectEntry) => {\n return id === aspectEntry.id.toString() || id === aspectEntry.id.toString({ ignoreVersion: true });\n });\n\n return matchedEntry?.id;\n }\n\n /**\n * This used to calculate the actual env during the component load.\n * Do not use it to get the env (use getEnv instead)\n * This should be used only during on load\n */\n async calculateEnvId(component: Component): Promise<ComponentID> {\n // Search first for env configured via envs aspect itself\n const envIdFromEnvsConfig = this.getEnvIdFromEnvsConfig(component);\n // if (!envIdFromEnvsConfig) return this.getDefaultEnv();\n const envIdFromEnvsConfigWithoutVersion = envIdFromEnvsConfig\n ? ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion()\n : undefined;\n\n if (envIdFromEnvsConfig && this.isCoreEnv(envIdFromEnvsConfig)) {\n return ComponentID.fromString(envIdFromEnvsConfig);\n }\n\n // in some cases we have the id configured in the teambit.envs/envs but without the version\n // in such cases we won't find it in the slot\n // we search in the component aspect list a matching aspect which is match the id from the teambit.envs/envs\n if (envIdFromEnvsConfigWithoutVersion) {\n const matchedEntry = component.state.aspects.entries.find((aspectEntry) => {\n return (\n envIdFromEnvsConfigWithoutVersion === aspectEntry.id.toString() ||\n envIdFromEnvsConfigWithoutVersion === aspectEntry.id.toString({ ignoreVersion: true })\n );\n });\n\n if (matchedEntry?.id) return matchedEntry?.id;\n }\n\n // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env\n let ids: string[] = [];\n component.state.aspects.entries.forEach((aspectEntry) => {\n ids.push(aspectEntry.id.toString());\n // ids.push(aspectEntry.id.toString({ ignoreVersion: true }));\n });\n ids = uniq(ids);\n const envId = await this.findFirstEnv(ids);\n const finalId = envId || this.getDefaultEnv().id;\n return ComponentID.fromString(finalId);\n }\n\n /**\n * This used to calculate the actual env during the component load.\n * Do not use it to get the env (use getEnv instead)\n * This should be used only during on load\n */\n calculateEnv(component: Component, opts: GetCalcEnvOptions = {}): EnvDefinition {\n // Search first for env configured via envs aspect itself\n const envIdFromEnvsConfig = this.getEnvIdFromEnvsConfig(component);\n let envIdFromEnvsConfigWithoutVersion;\n if (envIdFromEnvsConfig) {\n envIdFromEnvsConfigWithoutVersion = ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion();\n const envDef = this.getEnvDefinitionByStringId(envIdFromEnvsConfigWithoutVersion);\n if (envDef) {\n this.envIds.add(envDef.id);\n return envDef;\n }\n }\n\n // in some cases we have the id configured in the teambit.envs/envs but without the version\n // in such cases we won't find it in the slot\n // we search in the component aspect list a matching aspect which is match the id from the teambit.envs/envs\n if (envIdFromEnvsConfigWithoutVersion) {\n const matchedEntry = component.state.aspects.entries.find((aspectEntry) => {\n return (\n envIdFromEnvsConfigWithoutVersion === aspectEntry.id.toString() ||\n envIdFromEnvsConfigWithoutVersion === aspectEntry.id.toString({ ignoreVersion: true })\n );\n });\n if (matchedEntry) {\n // during the tag process, the version in the aspect-entry-id is changed and is not the\n // same as it was when it registered to the slot.\n const envDef = this.getEnvDefinitionById(matchedEntry.id);\n if (envDef) {\n this.envIds.add(envDef.id);\n return envDef;\n }\n if (!opts.skipWarnings) {\n // Do not allow a non existing env\n this.printWarningIfFirstTime(\n matchedEntry.id.toString(),\n `environment with ID: ${matchedEntry.id.toString()} configured on component ${component.id.toString()} was not loaded (run \"bit install\")`\n );\n }\n }\n // Do not allow configure teambit.envs/envs on the component without configure the env aspect itself\n // const errMsg = new EnvNotConfiguredForComponent(envIdFromEnvsConfig as string, component.id.toString()).message;\n // this.printWarningIfFirstTime(envIdFromEnvsConfig as string, errMsg);\n }\n\n // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env\n let envDefFromList;\n component.state.aspects.entries.find((aspectEntry) => {\n const envDef = this.getEnvDefinitionById(aspectEntry.id);\n if (envDef) {\n envDefFromList = envDef;\n }\n return !!envDef;\n });\n\n if (envDefFromList) {\n this.envIds.add(envDefFromList.id);\n return envDefFromList;\n }\n return this.getDefaultEnv();\n }\n\n /**\n * an env can be configured on a component in two ways:\n * 1) explicitly inside \"teambit.envs/envs\". `{ \"teambit.envs/envs\": { \"env\": \"my-env\" } }`\n * 2) the env aspect is set on the variant as any other aspect, e.g. `{ \"my-env\": {} }`\n *\n * this method returns #1 if exists, otherwise, #2.\n */\n getAllEnvsConfiguredOnComponent(component: Component): EnvDefinition[] {\n // if a component has \"envs\" config, use it and ignore other components that are set up\n // in this components which happen to be envs.\n const envDef = this.getEnvFromEnvsConfig(component);\n if (envDef) {\n return [envDef];\n }\n\n return this.getEnvsNotFromEnvsConfig(component);\n }\n\n /**\n * whether a component has an env configured (either by variant or .bitmap).\n */\n hasEnvConfigured(component: Component): boolean {\n return Boolean(this.getAllEnvsConfiguredOnComponent(component).length);\n }\n\n getAllRegisteredEnvsIds(): string[] {\n return this.envSlot.toArray().map((envData) => envData[0]);\n }\n\n getAllRegisteredEnvs(): Environment[] {\n return this.envSlot.toArray().map((envData) => envData[1]);\n }\n\n getAllRegisteredEnvJsoncCustomizers(): EnvJsoncMergeCustomizer[] {\n return this.envJsoncMergeCustomizerSlot.toArray().map((customizerEntry) => customizerEntry[1]);\n }\n\n getEnvPlugin() {\n return new EnvPlugin(this.envSlot, this.servicesRegistry, this.loggerMain, this.workerMain, this.harmony);\n }\n\n /**\n * an env can be configured on a component in two ways:\n * 1) explicitly inside \"teambit.envs/envs\". `{ \"teambit.envs/envs\": { \"env\": \"my-env\" } }`\n * 2) the env aspect is set on the variant as any other aspect, e.g. `{ \"my-env\": {} }`\n *\n * this method returns only #1\n */\n getEnvFromEnvsConfig(component: Component): EnvDefinition | undefined {\n const envIdFromEnvsConfig = this.getEnvIdFromEnvsConfig(component);\n if (!envIdFromEnvsConfig) {\n return undefined;\n }\n const envIdFromEnvsConfigWithoutVersion = ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion();\n const envDef = this.getEnvDefinitionByStringId(envIdFromEnvsConfigWithoutVersion);\n return envDef;\n }\n\n /**\n * an env can be configured on a component in two ways:\n * 1) explicitly inside \"teambit.envs/envs\". `{ \"teambit.envs/envs\": { \"env\": \"my-env\" } }`\n * 2) the env aspect is set on the variant as any other aspect, e.g. `{ \"my-env\": {} }`\n *\n * this method returns only #2\n */\n getEnvsNotFromEnvsConfig(component: Component): EnvDefinition[] {\n return component.state.aspects.entries.reduce((acc: EnvDefinition[], aspectEntry) => {\n const envDef = this.getEnvDefinitionById(aspectEntry.id);\n if (envDef) acc.push(envDef);\n return acc;\n }, []);\n }\n\n getEnvIdFromEnvsLegacyExtensions(extensions: ExtensionDataList): string | undefined {\n const envsAspect = extensions.findCoreExtension(EnvsAspect.id);\n const envIdFromEnvsConfig = envsAspect?.data.id;\n return envIdFromEnvsConfig;\n }\n\n /**\n * @deprecated DO NOT USE THIS METHOD ANYMORE!!! (PLEASE USE .calculateEnvId() instead!)\n */\n async calculateEnvIdFromExtensions(extensions: ExtensionDataList): Promise<string> {\n // Search first for env configured via envs aspect itself\n const envsAspect = extensions.findCoreExtension(EnvsAspect.id);\n const envIdFromEnvsConfig = envsAspect?.config.env;\n\n const envIdFromEnvsConfigWithoutVersion = envIdFromEnvsConfig\n ? ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion()\n : undefined;\n\n if (envIdFromEnvsConfig && this.isCoreEnv(envIdFromEnvsConfig)) {\n return envIdFromEnvsConfig;\n }\n\n // in some cases we have the id configured in the teambit.envs/envs but without the version\n // in such cases we won't find it in the slot\n // we search in the component aspect list a matching aspect which is match the id from the teambit.envs/envs\n if (envIdFromEnvsConfigWithoutVersion) {\n const matchedEntry = extensions.find((extension) => {\n if (extension.extensionId) {\n return (\n envIdFromEnvsConfigWithoutVersion === extension.extensionId.toString() ||\n envIdFromEnvsConfigWithoutVersion === extension.extensionId.toString({ ignoreVersion: true })\n );\n }\n return envIdFromEnvsConfigWithoutVersion === extension.stringId;\n });\n if (matchedEntry?.id) return matchedEntry?.stringId;\n }\n\n // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env\n const ids: string[] = [];\n extensions.forEach((extension) => {\n if (extension.extensionId) {\n ids.push(extension.extensionId.toString());\n } else {\n ids.push(extension.stringId);\n }\n });\n const envId = await this.findFirstEnv(ids);\n const finalId = envId || this.getDefaultEnv().id;\n return finalId;\n }\n\n /**\n * @deprecated DO NOT USE THIS METHOD ANYMORE!!! (PLEASE USE .calculateEnv() instead!)\n */\n async calculateEnvFromExtensions(extensions: ExtensionDataList): Promise<EnvDefinition> {\n // Search first for env configured via envs aspect itself\n const envsAspect = extensions.findCoreExtension(EnvsAspect.id);\n const envIdFromEnvsConfig = envsAspect?.config.env;\n let envIdFromEnvsConfigWithoutVersion;\n\n if (envIdFromEnvsConfig) {\n envIdFromEnvsConfigWithoutVersion = ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion();\n const envDef = this.getEnvDefinitionByStringId(envIdFromEnvsConfigWithoutVersion);\n if (envDef) {\n this.envIds.add(envDef.id);\n return envDef;\n }\n }\n\n // in some cases we have the id configured in the teambit.envs/envs but without the version\n // in such cases we won't find it in the slot\n // we search in the component aspect list a matching aspect which is match the id from the teambit.envs/envs\n if (envIdFromEnvsConfigWithoutVersion) {\n const matchedEntry = extensions.find((extension) => {\n if (extension.extensionId) {\n return (\n envIdFromEnvsConfigWithoutVersion === extension.extensionId.toString() ||\n envIdFromEnvsConfigWithoutVersion === extension.extensionId.toString({ ignoreVersion: true })\n );\n }\n return envIdFromEnvsConfigWithoutVersion === extension.stringId;\n });\n if (matchedEntry) {\n // during the tag process, the version in the aspect-entry-id is changed and is not the\n // same as it was when it registered to the slot.\n const envDef = this.getEnvDefinitionByLegacyExtension(matchedEntry);\n if (envDef) {\n this.envIds.add(envDef.id);\n return envDef;\n }\n // Do not allow a non existing env\n // this.printWarningIfFirstTime(\n // matchedEntry.id.toString(),\n // `environment with ID: ${matchedEntry.id.toString()} was not found`\n // );\n }\n // Do not allow configure teambit.envs/envs on the component without configure the env aspect itself\n // const errMsg = new EnvNotConfiguredForComponent(envIdFromEnvsConfig).message;\n // this.printWarningIfFirstTime(envIdFromEnvsConfig, errMsg);\n }\n\n // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env\n const ids: string[] = [];\n extensions.forEach((extension) => {\n if (extension.extensionId) {\n ids.push(extension.extensionId.toString());\n } else {\n ids.push(extension.stringId);\n }\n });\n const envId = await this.findFirstEnv(ids);\n const envDef = envId ? this.getEnvDefinitionByStringId(envId) : undefined;\n\n return envDef || this.getDefaultEnv();\n }\n\n /**\n * This function finds the first environment ID from a list of IDs by checking if it is register as env (to the slot).\n * or contains env.jsonc file\n * @param {string[]} ids - `ids` is an array of string values representing environment IDs. The function `findFirstEnv`\n * takes this array as input and returns a Promise that resolves to a string value representing the first environment ID\n * that matches certain conditions.\n * @returns The `findFirstEnv` function returns a Promise that resolves to a string or undefined. The string represents\n * the ID of the first environment that matches the conditions specified in the function, or undefined if no environment\n * is found.\n */\n private async findFirstEnv(ids: string[]): Promise<string | undefined> {\n let isFoundWithoutVersion = false;\n const envId = await pLocate(ids, async (id) => {\n const idWithoutVersion = id.split('@')[0];\n if (this.isCoreEnv(idWithoutVersion)) return true;\n if (isCoreAspect(idWithoutVersion)) return false;\n const envDef = this.getEnvDefinitionByStringId(id);\n if (envDef) return true;\n const envDefWithoutVersion = this.getEnvDefinitionByStringId(idWithoutVersion);\n if (envDefWithoutVersion) {\n isFoundWithoutVersion = true;\n return true;\n }\n const envComponent = await this.getEnvComponentByEnvId(id);\n const hasManifest = this.hasEnvManifest(envComponent);\n if (hasManifest) return true;\n const isUsingEnvEnv = this.isUsingEnvEnv(envComponent);\n return !!isUsingEnvEnv;\n });\n let finalEnvId;\n if (envId) {\n finalEnvId = isFoundWithoutVersion ? envId?.split('@')[0] : envId;\n this.envIds.add(envId);\n }\n return finalEnvId;\n }\n\n private getEnvDefinitionByLegacyExtension(extension: ExtensionDataEntry): EnvDefinition | undefined {\n const envDef = extension.extensionId\n ? this.getEnvDefinitionById(extension.extensionId)\n : this.getEnvDefinitionByStringId(extension.stringId);\n return envDef;\n }\n\n getEnvIdFromEnvsConfig(component: Component): string | undefined {\n const envsAspect = component.state.aspects.get(EnvsAspect.id);\n return envsAspect?.config.env;\n }\n\n getEnvDefinition(id: ComponentID) {\n const allVersions = this.envSlot.toArray();\n const all = allVersions.filter(([envId]) => envId.includes(id.toStringWithoutVersion()));\n const first = head(all);\n if (!first) return undefined;\n const [envId, env] = first;\n return new EnvDefinition(envId, env);\n }\n\n getEnvDefinitionById(id: ComponentID): EnvDefinition | undefined {\n const envDef =\n this.getEnvDefinitionByStringId(id.toString()) ||\n this.getEnvDefinitionByStringId(id.toString({ ignoreVersion: true }));\n return envDef;\n }\n\n public getEnvDefinitionByStringId(envId: string): EnvDefinition | undefined {\n const env = this.envSlot.get(envId);\n if (env) {\n return new EnvDefinition(envId, env as Environment);\n }\n return undefined;\n }\n\n getEnvFromComponent(envComponent: Component): EnvDefinition | undefined {\n const env = this.getEnvDefinitionById(envComponent.id);\n return env;\n }\n\n /**\n * Return the env definition of teambit.envs/env\n */\n getEnvsEnvDefinition(): EnvDefinition {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.getEnvDefinitionByStringId('teambit.envs/env')!;\n }\n\n private printWarningIfFirstTime(envId: string, message: string) {\n if (!this.alreadyShownWarning[envId] && !this.failedToLoadEnvs.has(envId)) {\n this.alreadyShownWarning[envId] = true;\n this.logger.consoleWarning(message);\n this.addFailedToLoadEnvs(envId);\n }\n }\n\n /**\n * determines whether an env is registered.\n */\n public isEnvRegistered(id: string) {\n return Boolean(this.envSlot.get(id));\n }\n\n isUsingAspectEnv(component: Component): boolean {\n const data = this.getEnvData(component);\n if (!data) return false;\n return data.type === 'aspect';\n }\n\n isUsingEnvEnv(component: Component): boolean {\n const data = this.getEnvData(component);\n if (!data) return false;\n return data.type === 'env';\n }\n\n /**\n * Check if the given component is an env component.\n * @param component\n * @returns\n */\n isEnv(component: Component): boolean {\n return (\n this.isUsingEnvEnv(component) ||\n this.isEnvRegistered(component.id.toString()) ||\n this.isEnvRegistered(component.id.toStringWithoutVersion())\n );\n }\n\n /**\n * register a new environment service.\n */\n registerService(...envServices: EnvService<any>[]) {\n this.servicesRegistry.register(envServices);\n return this;\n }\n\n /**\n * get list of services enabled on an env.\n */\n getServices(env: EnvDefinition): EnvServiceList {\n const allServices = this.servicesRegistry.toArray();\n const services: [string, EnvService<any>][] = [];\n allServices.forEach(([id, currentServices]) => {\n currentServices.forEach((service) => {\n try {\n if (this.implements(env, service)) {\n services.push([id, service]);\n }\n } catch (err) {\n this.logger.warn(`failed loading service ${id} for env ${env.id}`);\n }\n });\n });\n return new EnvServiceList(env, services);\n }\n\n implements(env: EnvDefinition, service: EnvService<any>) {\n // TODO: remove this after refactoring everything and remove getDescriptor from being optional.\n if (!service.getDescriptor) return false;\n return !!service.getDescriptor(env);\n }\n\n /**\n * register an environment.\n */\n registerEnv(env: Environment) {\n return this.envSlot.register(env);\n }\n\n /**\n * register an env.jsonc merge customizer.\n */\n registerEnvJsoncMergeCustomizer(customizer: EnvJsoncMergeCustomizer) {\n return this.envJsoncMergeCustomizerSlot.register(customizer);\n }\n\n async addNonLoadedEnvAsComponentIssues(components: Component[]) {\n await pMapSeries(components, async (component) => {\n const envId = await this.calculateEnvId(component);\n const envIdStr = envId.toString();\n if (!this.isEnvRegistered(envIdStr)) {\n this.addFailedToLoadEnvs(envIdStr);\n // If there is no version and the env is not in the workspace this is not valid\n // you can't set external env without version\n if (!envIdStr.includes('@')) {\n const foundComp = components.find((c) => c.id.toStringWithoutVersion() === envIdStr);\n if (!foundComp) {\n component.state.issues.getOrCreate(IssuesClasses.ExternalEnvWithoutVersion).data = {\n envId: envIdStr,\n componentId: component.id.toString(),\n };\n } else {\n component.state.issues.getOrCreate(IssuesClasses.NonLoadedEnv).data = envIdStr;\n }\n } else {\n component.state.issues.getOrCreate(IssuesClasses.NonLoadedEnv).data = envIdStr;\n }\n }\n });\n }\n\n // refactor here\n private async createRuntime(components: Component[]): Promise<Runtime> {\n return new Runtime(await this.aggregateByDefs(components), this.logger);\n }\n\n // :TODO can be refactored to few utilities who will make repeating this very easy.\n private async aggregateByDefs(components: Component[]): Promise<EnvRuntime[]> {\n this.throwForDuplicateComponents(components);\n const envsMap = {};\n components.forEach((component: Component) => {\n const envDef = this.getEnv(component);\n const envId = envDef.id;\n const env = envDef.env;\n // handle config as well when aggregating envs.\n if (envsMap[envId]) envsMap[envId].components.push(component);\n else\n envsMap[envId] = {\n components: [component],\n env,\n };\n });\n\n return Promise.all(\n Object.keys(envsMap).map(async (key) => {\n const envAspectDef = await this.getEnvAspectDef(key);\n return new EnvRuntime(key, envsMap[key].env, envsMap[key].components, envAspectDef);\n })\n );\n }\n\n private async getEnvAspectDef(envId: string): Promise<AspectDefinition> {\n const host = this.componentMain.getHost();\n const id = await host.resolveComponentId(envId);\n // We don't want to filter by runtime here as we want to also get envs that configured as plugins. so they don't\n // contain the runtime path.\n const resolvedAspects = await host.resolveAspects(MainRuntime.name, [id], {\n requestedOnly: true,\n filterByRuntime: false,\n useScopeAspectsCapsule: true,\n });\n const def = resolvedAspects[0];\n\n return def;\n }\n\n private throwForDuplicateComponents(components: Component[]) {\n const idsStr = components.map((c) => c.id.toString());\n const duplications = findDuplications(idsStr);\n if (duplications.length) {\n throw new Error(`found duplicated components: ${duplications.join(', ')}`);\n }\n }\n\n static slots = [\n Slot.withType<Environment>(),\n Slot.withType<EnvService<any>>(),\n Slot.withType<EnvJsoncMergeCustomizerRegistry>(),\n ];\n\n static dependencies = [GraphqlAspect, LoggerAspect, ComponentAspect, CLIAspect, WorkerAspect, IssuesAspect];\n\n static async provider(\n [graphql, loggerAspect, component, cli, worker, issues]: [\n GraphqlMain,\n LoggerMain,\n ComponentMain,\n CLIMain,\n WorkerMain,\n IssuesMain\n ],\n config: EnvsConfig,\n [envSlot, servicesRegistry, envJsoncMergeCustomizerSlot]: [\n EnvsRegistry,\n ServicesRegistry,\n EnvJsoncMergeCustomizerRegistry\n ],\n context: Harmony\n ) {\n const logger = loggerAspect.createLogger(EnvsAspect.id);\n const envs = new EnvsMain(\n config,\n context,\n envSlot,\n logger,\n servicesRegistry,\n component,\n loggerAspect,\n worker,\n envJsoncMergeCustomizerSlot\n );\n component.registerShowFragments([new EnvFragment(envs)]);\n if (issues) issues.registerAddComponentsIssues(envs.addNonLoadedEnvAsComponentIssues.bind(envs));\n\n const envsCmd = new EnvsCmd(envs, component);\n envsCmd.commands = [new ListEnvsCmd(envs, component), new GetEnvCmd(envs, component)];\n cli.register(envsCmd);\n graphql.register(environmentsSchema(envs));\n return envs;\n }\n}\n\nEnvsAspect.addRuntime(EnvsMain);\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,KAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,IAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,SAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,QAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,SAAA;EAAA,MAAAP,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAM,QAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,aAAA;EAAA,MAAA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AACiD,OAAO,CAAC;IACrBV,OAAO,CAACvC,QAAQ,CAAC,IAAAsD,mCAAkB,EAACT,IAAI,CAAC,CAAC;IAC1C,OAAOA,IAAI;EACb;AACF;AAAC5Q,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAAAlB,eAAA,CAxhCYkB,QAAQ,aAgBF4P,kBAAW;AAAA9Q,eAAA,CAhBjBkB,QAAQ,WA0+BJ,CACbqR,eAAI,CAACC,QAAQ,CAAc,CAAC,EAC5BD,eAAI,CAACC,QAAQ,CAAkB,CAAC,EAChCD,eAAI,CAACC,QAAQ,CAAkC,CAAC,CACjD;AAAAxS,eAAA,CA9+BUkB,QAAQ,kBAg/BG,CAACuR,wBAAa,EAAEC,sBAAY,EAAEC,4BAAe,EAAEC,gBAAS,EAAEC,sBAAY,EAAEC,sBAAY,CAAC;AA0C7G5K,0BAAU,CAAC6K,UAAU,CAAC7R,QAAQ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_path","data","require","_findRoot","_interopRequireDefault","_toolboxModules","_bit","_fsExtra","_pLocate","_commentJson","_cli","_component","_graphql","_issues","_pMapSeries","_componentIssues","_harmony","_logger","_bitError","_toolboxArray","_lodash","_worker","_componentId","_environments","_environments2","_runtime","_envDefinition","_envServiceList","_envs","_env","_exceptions","_env2","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DEFAULT_ENV","exports","EnvsMain","icon","constructor","config","harmony","envSlot","logger","servicesRegistry","componentMain","loggerMain","workerMain","envJsoncMergeCustomizerSlot","Set","createEnvironment","components","createRuntime","addFailedToLoadEnvs","id","failedToLoadEnvs","add","envIds","addFailedToLoadExt","failedToLoadExt","has","resetFailedToLoadEnvs","clear","getFailedToLoadEnvs","Array","from","extId","uniq","getDefaultEnv","defaultEnv","get","Error","EnvDefinition","getCoreEnvsIds","compose","targetEnv","envTransformers","a","reduce","acc","transformer","override","propsToOverride","env","merge","sourceEnv","allNames","prototype","getPrototypeOf","name","getOwnPropertyNames","key","fn","includes","bind","hasEnvManifest","envComponent","legacyFiles","undefined","files","filesystem","envJson","find","file","relative","getEnvManifest","object","parse","contents","toString","resolvedObject","recursivelyMergeWithParentManifest","path","originPath","extends","parentPackageName","parentPath","resolveFrom","parentResolvedPath","findRoot","existsSync","info","parentEnvJsoncPath","map","fileName","join","filePath","consoleWarning","parentStr","readFileSync","parentObject","mergedObject","mergeEnvManifests","parent","child","merged","mergeCustomizer","getAllRegisteredEnvJsoncCustomizers","customizer","oneMerged","hasEnvManifestById","envId","requesting","component","getEnvComponentByEnvId","getEnvData","envsData","state","aspects","EnvsAspect","getEnvIdFromEnvsData","ignoreVersion","rawEnvId","envIdWithoutVersion","ComponentID","fromString","toStringWithoutVersion","getEnvId","envIdFromEnvData","withVersion","resolveEnv","withVersionMatch","toArray","withVersionMatchId","exactMatch","exactMatchId","EnvNotConfiguredForComponent","isUsingCoreEnv","isCoreEnv","getEnv","envDef","getEnvDefinitionByStringId","EnvNotFound","getEnvComponent","host","getHost","newId","resolveComponentId","BitError","getOrCalculateEnv","err","calculateEnv","getDescriptor","calcDescriptor","opts","componentDescriptor","getComponentEnvDescriptor","envComponentSelfDescriptor","getEnvSelfDescriptor","result","self","isEnvRegistered","getEnvFromComponent","rawServices","getServices","services","toObject","selfDescriptor","getEnvDescriptorFromEnvDef","__getDescriptor","systemDescriptor","type","split","description","matchedEntry","entries","aspectEntry","calculateEnvId","envIdFromEnvsConfig","getEnvIdFromEnvsConfig","envIdFromEnvsConfigWithoutVersion","ids","findFirstEnv","finalId","getEnvDefinitionById","skipWarnings","printWarningIfFirstTime","envDefFromList","getAllEnvsConfiguredOnComponent","getEnvFromEnvsConfig","getEnvsNotFromEnvsConfig","hasEnvConfigured","Boolean","getAllRegisteredEnvsIds","envData","getAllRegisteredEnvs","customizerEntry","getEnvPlugin","EnvPlugin","getEnvIdFromEnvsLegacyExtensions","extensions","envsAspect","findCoreExtension","calculateEnvIdFromExtensions","extension","extensionId","stringId","calculateEnvFromExtensions","getEnvDefinitionByLegacyExtension","isFoundWithoutVersion","pLocate","idWithoutVersion","isCoreAspect","envDefWithoutVersion","hasManifest","isUsingEnvEnv","finalEnvId","getEnvDefinition","allVersions","all","first","head","getEnvsEnvDefinition","message","alreadyShownWarning","isUsingAspectEnv","isEnv","registerService","envServices","register","allServices","currentServices","service","implements","warn","EnvServiceList","registerEnv","registerEnvJsoncMergeCustomizer","addNonLoadedEnvAsComponentIssues","pMapSeries","envIdStr","foundComp","c","issues","getOrCreate","IssuesClasses","ExternalEnvWithoutVersion","componentId","NonLoadedEnv","Runtime","aggregateByDefs","throwForDuplicateComponents","envsMap","Promise","envAspectDef","getEnvAspectDef","EnvRuntime","resolvedAspects","resolveAspects","MainRuntime","requestedOnly","filterByRuntime","useScopeAspectsCapsule","def","idsStr","duplications","findDuplications","provider","graphql","loggerAspect","cli","worker","context","createLogger","envs","registerShowFragments","EnvFragment","registerAddComponentsIssues","envsCmd","EnvsCmd","commands","ListEnvsCmd","GetEnvCmd","environmentsSchema","Slot","withType","GraphqlAspect","LoggerAspect","ComponentAspect","CLIAspect","WorkerAspect","IssuesAspect","addRuntime"],"sources":["environments.main.runtime.ts"],"sourcesContent":["import { join } from 'path';\nimport findRoot from 'find-root';\nimport { resolveFrom } from '@teambit/toolbox.modules.module-resolver';\nimport { isCoreAspect } from '@teambit/bit';\nimport { existsSync, readFileSync } from 'fs-extra';\nimport pLocate from 'p-locate';\nimport { parse } from 'comment-json';\nimport { SourceFile } from '@teambit/component.sources';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect, ComponentMain } from '@teambit/component';\nimport type { EnvPolicyConfigObject } from '@teambit/dependency-resolver';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { IssuesAspect, IssuesMain } from '@teambit/issues';\nimport type { EnvJsoncPatterns } from '@teambit/dev-files';\nimport pMapSeries from 'p-map-series';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Harmony, Slot, SlotRegistry } from '@teambit/harmony';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport type { AspectDefinition } from '@teambit/aspect-loader';\nimport { ExtensionDataList, ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { BitError } from '@teambit/bit-error';\nimport { findDuplications } from '@teambit/toolbox.array.duplications-finder';\nimport { head, uniq } from 'lodash';\nimport { WorkerAspect, WorkerMain } from '@teambit/worker';\nimport { ComponentID } from '@teambit/component-id';\nimport { EnvService } from './services';\nimport { Environment } from './environment';\nimport { EnvsAspect } from './environments.aspect';\nimport { environmentsSchema } from './environments.graphql';\nimport { EnvRuntime, Runtime } from './runtime';\nimport { EnvDefinition } from './env-definition';\nimport { EnvServiceList } from './env-service-list';\nimport { EnvsCmd, GetEnvCmd, ListEnvsCmd } from './envs.cmd';\nimport { EnvFragment } from './env.fragment';\nimport { EnvNotFound, EnvNotConfiguredForComponent } from './exceptions';\nimport { EnvPlugin } from './env.plugin';\n\nexport type EnvJsonc = {\n extends?: string;\n policy?: EnvPolicyConfigObject;\n patterns?: EnvJsoncPatterns;\n};\n\nexport type EnvJsoncMergeCustomizer = (parentObj: EnvJsonc, childObj: EnvJsonc) => Partial<EnvJsonc>;\n\nexport type EnvsRegistry = SlotRegistry<Environment>;\nexport type EnvJsoncMergeCustomizerRegistry = SlotRegistry<EnvJsoncMergeCustomizer>;\n\nexport type EnvsConfig = {\n env: string;\n options: EnvOptions;\n};\n\ntype GetCalcEnvOptions = {\n skipWarnings?: boolean;\n};\n\nexport type EnvOptions = {};\n\nexport type EnvTransformer = (env: Environment) => Environment;\n\nexport type ServicesRegistry = SlotRegistry<Array<EnvService<any>>>;\n\nexport type RegularCompDescriptor = {\n id: string;\n icon?: string;\n type?: string;\n name?: string;\n description?: string;\n};\nexport type EnvCompDescriptorProps = RegularCompDescriptor & {\n services?: {\n env: {\n id: string;\n icon: string;\n name?: string;\n description?: string;\n };\n services: Array<{\n id: string;\n name?: string;\n description?: string;\n data: any;\n }>;\n };\n};\n\nexport type EnvCompDescriptor = EnvCompDescriptorProps & {\n self?: EnvCompDescriptorProps;\n};\n\nexport type Descriptor = RegularCompDescriptor | EnvCompDescriptor;\n\nexport const DEFAULT_ENV = 'teambit.harmony/node';\n\nexport class EnvsMain {\n /**\n * Envs that are failed to load\n */\n private failedToLoadEnvs = new Set<string>();\n /**\n * Extensions that are failed to load\n * We use this as sometime when we couldn't load an extension we don't know if it's an env or not\n * We should ideally take it from the aspect loader aspect, but right now the aspect loader is using envs\n */\n private failedToLoadExt = new Set<string>();\n /**\n * Ids of envs (not neccesrraly loaded successfully)\n */\n public envIds = new Set<string>();\n\n static runtime = MainRuntime;\n\n private alreadyShownWarning = {};\n\n /**\n * icon of the extension.\n */\n icon() {\n return `<svg width=\"50\" height=\"50\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"25\" cy=\"25\" r=\"20\"/>\n </svg>`;\n }\n\n constructor(\n /**\n * environments extension configuration.\n */\n readonly config: EnvsConfig,\n\n /**\n * harmony context.\n */\n private harmony: Harmony,\n\n /**\n * slot for allowing extensions to register new environment.\n */\n private envSlot: EnvsRegistry,\n\n private logger: Logger,\n\n private servicesRegistry: ServicesRegistry,\n\n private componentMain: ComponentMain,\n\n private loggerMain: LoggerMain,\n\n private workerMain: WorkerMain,\n\n private envJsoncMergeCustomizerSlot: EnvJsoncMergeCustomizerRegistry\n ) {}\n\n /**\n * creates a new runtime environments for a set of components.\n */\n async createEnvironment(components: Component[]): Promise<Runtime> {\n return this.createRuntime(components);\n }\n\n /**\n *\n * @param id\n */\n /**\n * This function adds an extension ID to a set of failed to load extensions.\n * This mostly used by the aspect loader to add such issues\n * Then it is used to hide different errors that are caused by the same issue.\n * @param {string} id - string - represents the unique identifier of an extension that failed to load.\n */\n addFailedToLoadEnvs(id: string) {\n this.failedToLoadEnvs.add(id);\n this.envIds.add(id);\n }\n\n addFailedToLoadExt(id: string) {\n this.failedToLoadExt.add(id);\n if (this.envIds.has(id)) {\n this.addFailedToLoadEnvs(id);\n }\n }\n\n resetFailedToLoadEnvs() {\n this.failedToLoadEnvs.clear();\n this.failedToLoadExt.clear();\n }\n\n getFailedToLoadEnvs() {\n const failedToLoadEnvs = Array.from(this.failedToLoadEnvs);\n // Add all extensions which are also envs\n for (const extId of this.failedToLoadExt) {\n if (this.envIds.has(extId)) {\n failedToLoadEnvs.push(extId);\n }\n }\n return uniq(failedToLoadEnvs);\n }\n\n /**\n * get the configured default env.\n */\n getDefaultEnv(): EnvDefinition {\n const defaultEnv = this.envSlot.get(DEFAULT_ENV);\n if (!defaultEnv) throw new Error('default env must be set.');\n\n return new EnvDefinition(DEFAULT_ENV, defaultEnv);\n }\n\n getCoreEnvsIds(): string[] {\n return [\n 'teambit.harmony/aspect',\n 'teambit.react/react',\n 'teambit.harmony/node',\n 'teambit.react/react-native',\n 'teambit.html/html',\n 'teambit.mdx/mdx',\n 'teambit.envs/env',\n 'teambit.mdx/readme',\n 'teambit.harmony/bit-custom-aspect',\n ];\n }\n\n /**\n * compose a new environment from a list of environment transformers.\n */\n compose(targetEnv: Environment, envTransformers: EnvTransformer[]) {\n const a = envTransformers.reduce((acc, transformer) => {\n acc = transformer(acc);\n return acc;\n }, targetEnv);\n\n return a;\n }\n\n /**\n * create an env transformer which overrides specific env properties.\n */\n override(propsToOverride: Environment): EnvTransformer {\n return (env: Environment) => {\n return this.merge(propsToOverride, env);\n };\n }\n\n /**\n * compose two environments into one.\n */\n merge<T extends Environment, S extends Environment>(targetEnv: Environment, sourceEnv: Environment): T & S {\n const allNames = new Set<string>();\n const keys = ['icon', 'name', 'description'];\n for (let o = sourceEnv; o !== Object.prototype; o = Object.getPrototypeOf(o)) {\n for (const name of Object.getOwnPropertyNames(o)) {\n allNames.add(name);\n }\n }\n\n allNames.forEach((key: string) => {\n const fn = sourceEnv[key];\n if (targetEnv[key]) return;\n if (keys.includes(key)) targetEnv[key] = fn;\n if (!fn || !fn.bind) {\n return;\n }\n targetEnv[key] = fn.bind(sourceEnv);\n });\n\n return targetEnv as T & S;\n }\n\n /**\n * This function checks if an environment manifest file exists in a given component or set of legacy files.\n * @param {Component} [envComponent] - A component object that represents an environment. It contains information about\n * the files and directories that make up the environment.\n * @param {SourceFile[]} [legacyFiles] - An optional array of SourceFile objects representing the files in the legacy\n * file system. If this parameter is not provided, the function will attempt to retrieve the files from the envComponent\n * parameter.\n * @returns a boolean value indicating whether an `env.jsonc` or `env.json` file exists in the `files` array of either\n * the `envComponent` object or the `legacyFiles` array. If neither `envComponent` nor `legacyFiles` are provided, the\n * function returns `undefined`.\n */\n hasEnvManifest(envComponent?: Component, legacyFiles?: SourceFile[]): boolean | undefined {\n if (!envComponent && !legacyFiles) return undefined;\n // @ts-ignore\n const files = legacyFiles || envComponent.filesystem.files;\n const envJson = files.find((file) => {\n return file.relative === 'env.jsonc' || file.relative === 'env.json';\n });\n\n if (!envJson) return false;\n return true;\n }\n\n getEnvManifest(envComponent?: Component, legacyFiles?: SourceFile[]): EnvJsonc | undefined {\n // TODO: maybe throw an error here?\n if (!envComponent && !legacyFiles) return undefined;\n // @ts-ignore\n const files = legacyFiles || envComponent.filesystem.files;\n const envJson = files.find((file) => {\n return file.relative === 'env.jsonc' || file.relative === 'env.json';\n });\n\n if (!envJson) return undefined;\n\n const object: EnvJsonc = parse(envJson.contents.toString('utf8'), undefined, true);\n const resolvedObject = this.recursivelyMergeWithParentManifest(object, envJson.path);\n return resolvedObject;\n }\n\n recursivelyMergeWithParentManifest(object: EnvJsonc, originPath: string): EnvJsonc {\n if (!object.extends) return object;\n const parentPackageName = object.extends;\n const parentPath = resolveFrom(originPath, [parentPackageName]);\n const parentResolvedPath = findRoot(parentPath);\n if (!parentResolvedPath || !existsSync(parentResolvedPath)) {\n this.logger.info(`failed finding parent manifest for ${parentPackageName} at ${parentResolvedPath}`);\n }\n const parentEnvJsoncPath = ['env.jsonc', 'env.json']\n .map((fileName) => join(parentResolvedPath, fileName))\n .find((filePath) => {\n return existsSync(filePath);\n });\n if (!parentEnvJsoncPath) {\n this.logger.consoleWarning(\n `failed finding parent manifest for ${parentPackageName} at ${parentResolvedPath} referred from ${originPath}`\n );\n return object;\n }\n const parentStr = readFileSync(parentEnvJsoncPath).toString('utf8');\n const parentObject: EnvJsonc = parse(parentStr, undefined, true);\n const mergedObject = this.mergeEnvManifests(parentObject, object);\n if (mergedObject.extends) {\n return this.recursivelyMergeWithParentManifest(mergedObject, parentEnvJsoncPath);\n }\n return mergedObject;\n }\n\n mergeEnvManifests(parent: EnvJsonc, child: EnvJsonc): EnvJsonc {\n let merged: EnvJsonc = {};\n const mergeCustomizer = this.getAllRegisteredEnvJsoncCustomizers();\n for (const customizer of mergeCustomizer) {\n const oneMerged = customizer(parent, child);\n merged = { ...merged, ...oneMerged };\n }\n // Take extends specifically from the parent so we can propagate it to the next parent\n if (parent.extends) {\n merged.extends = parent.extends;\n }\n return merged;\n }\n\n async hasEnvManifestById(envId: string, requesting: string): Promise<boolean | undefined> {\n const component = await this.getEnvComponentByEnvId(envId, requesting);\n return this.hasEnvManifest(component);\n }\n\n getEnvData(component: Component): Descriptor {\n let envsData = component.state.aspects.get(EnvsAspect.id);\n if (!envsData) {\n // TODO: remove this once we re-export old components used to store the data here\n envsData = component.state.aspects.get('teambit.workspace/workspace');\n }\n if (!envsData) throw new Error(`env was not configured on component ${component.id.toString()}`);\n return envsData.data as Descriptor;\n }\n\n /**\n * Return the id of the env as configured in the envs data (without version by default)\n * 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\n * As this version is stay up to date during tagging the env along with the component\n * @param component\n * @param ignoreVersion\n */\n private getEnvIdFromEnvsData(component: Component, ignoreVersion = true): string | undefined {\n const envsData = this.getEnvData(component);\n if (!envsData) return undefined;\n const rawEnvId = envsData.id;\n if (!rawEnvId) return undefined;\n if (!ignoreVersion) return rawEnvId;\n const envIdWithoutVersion = ComponentID.fromString(rawEnvId).toStringWithoutVersion();\n return envIdWithoutVersion;\n }\n\n /**\n * get the env id of the given component.\n */\n getEnvId(component: Component): string {\n const envIdFromEnvData = this.getEnvIdFromEnvsData(component);\n if (!envIdFromEnvData) {\n // This should never happen\n throw new Error(`no env found for ${component.id.toString()}`);\n }\n const withVersion = this.resolveEnv(component, envIdFromEnvData);\n const withVersionMatch = this.envSlot.toArray().find(([envId]) => {\n return withVersion?.toString() === envId;\n });\n const withVersionMatchId = withVersionMatch?.[0];\n if (withVersionMatchId) return withVersionMatchId;\n\n // Handle core envs\n const exactMatch = this.envSlot.toArray().find(([envId]) => {\n return envIdFromEnvData === envId;\n });\n\n const exactMatchId = exactMatch?.[0];\n if (exactMatchId) return exactMatchId;\n\n if (!withVersion) throw new EnvNotConfiguredForComponent(envIdFromEnvData, component.id.toString());\n return withVersion.toString();\n }\n\n isUsingCoreEnv(component: Component): boolean {\n const envId = this.getEnvId(component);\n return this.isCoreEnv(envId);\n }\n\n isCoreEnv(envId: string): boolean {\n return this.getCoreEnvsIds().includes(envId);\n }\n\n /**\n * get the env of the given component.\n * In case you are asking for the env during on load you should use calculateEnv instead\n */\n getEnv(component: Component): EnvDefinition {\n const id = this.getEnvId(component);\n const envDef = this.getEnvDefinitionByStringId(id);\n if (envDef) {\n return envDef;\n }\n // Do not allow a non existing env\n throw new EnvNotFound(id, component.id.toString());\n }\n\n /**\n * get the env component of the given component.\n */\n async getEnvComponent(component: Component): Promise<Component> {\n const envId = this.getEnvId(component);\n return this.getEnvComponentByEnvId(envId, component.id.toString());\n }\n\n /**\n * get the env component by the env id.\n */\n async getEnvComponentByEnvId(envId: string, requesting?: string): Promise<Component> {\n const host = this.componentMain.getHost();\n const newId = await host.resolveComponentId(envId);\n const envComponent = await host.get(newId);\n if (!envComponent) {\n throw new BitError(`can't load env. env id is ${envId} used by component ${requesting || 'unknown'}`);\n }\n return envComponent;\n }\n\n /**\n * get the env of the given component.\n * This will try to use the regular getEnv but fallback to the calculate env (in case you are using it during on load)\n * This is safe to be used on onLoad as well\n */\n getOrCalculateEnv(component: Component): EnvDefinition {\n try {\n return this.getEnv(component);\n } catch (err) {\n return this.calculateEnv(component);\n }\n }\n\n /**\n * get an environment Descriptor.\n */\n getDescriptor(component: Component): Descriptor | undefined {\n const envsData = this.getEnvData(component);\n envsData.id = this.resolveEnv(component, envsData.id)?.toString() || envsData.id;\n return envsData;\n }\n\n async calcDescriptor(component: Component, opts: GetCalcEnvOptions = {}): Promise<Descriptor | undefined> {\n const componentDescriptor = await this.getComponentEnvDescriptor(component, opts);\n if (!componentDescriptor) return undefined;\n const envComponentSelfDescriptor = await this.getEnvSelfDescriptor(component);\n const result = envComponentSelfDescriptor\n ? { ...componentDescriptor, self: envComponentSelfDescriptor }\n : componentDescriptor;\n return result;\n }\n\n /**\n * Get env descriptor from the env itself if the component is an env\n * This will be empty for regular component, and will only contain data for env themself\n */\n private async getEnvSelfDescriptor(envComponent: Component): Promise<EnvCompDescriptorProps | undefined> {\n // !important calculate only on the env itself.\n if (!this.isEnvRegistered(envComponent.id.toString())) {\n return undefined;\n }\n\n const envDef = this.getEnvFromComponent(envComponent);\n if (!envDef) return undefined;\n\n const rawServices = this.getServices(envDef);\n const services = rawServices.toObject();\n // const selfDescriptor = (await this.getEnvDescriptorFromEnvDef(envDef)) || {};\n const selfDescriptor = await this.getEnvDescriptorFromEnvDef(envDef);\n\n if (!selfDescriptor) return undefined;\n return {\n ...selfDescriptor,\n services,\n };\n }\n\n /**\n * Get env descriptor from the env that a given component is using\n */\n private async getComponentEnvDescriptor(\n component: Component,\n opts: GetCalcEnvOptions = {}\n ): Promise<RegularCompDescriptor | undefined> {\n const envDef = this.calculateEnv(component, opts);\n return this.getEnvDescriptorFromEnvDef(envDef);\n }\n\n private async getEnvDescriptorFromEnvDef(envDef: EnvDefinition): Promise<RegularCompDescriptor | undefined> {\n if (!envDef.env.__getDescriptor || typeof envDef.env.__getDescriptor !== 'function') {\n return undefined;\n }\n const systemDescriptor = await envDef.env.__getDescriptor();\n\n return {\n type: systemDescriptor.type,\n // Make sure to store the env id in the data without the version\n // The version should always come from the aspect id configured on the component\n id: envDef.id.split('@')[0],\n name: envDef.name,\n icon: envDef.env.icon,\n description: envDef.description,\n };\n }\n\n resolveEnv(component: Component, id: string) {\n const matchedEntry = component.state.aspects.entries.find((aspectEntry) => {\n return id === aspectEntry.id.toString() || id === aspectEntry.id.toString({ ignoreVersion: true });\n });\n\n return matchedEntry?.id;\n }\n\n /**\n * This used to calculate the actual env during the component load.\n * Do not use it to get the env (use getEnv instead)\n * This should be used only during on load\n */\n async calculateEnvId(component: Component): Promise<ComponentID> {\n // Search first for env configured via envs aspect itself\n const envIdFromEnvsConfig = this.getEnvIdFromEnvsConfig(component);\n // if (!envIdFromEnvsConfig) return this.getDefaultEnv();\n const envIdFromEnvsConfigWithoutVersion = envIdFromEnvsConfig\n ? ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion()\n : undefined;\n\n if (envIdFromEnvsConfig && this.isCoreEnv(envIdFromEnvsConfig)) {\n return ComponentID.fromString(envIdFromEnvsConfig);\n }\n\n // in some cases we have the id configured in the teambit.envs/envs but without the version\n // in such cases we won't find it in the slot\n // we search in the component aspect list a matching aspect which is match the id from the teambit.envs/envs\n if (envIdFromEnvsConfigWithoutVersion) {\n const matchedEntry = component.state.aspects.entries.find((aspectEntry) => {\n return (\n envIdFromEnvsConfigWithoutVersion === aspectEntry.id.toString() ||\n envIdFromEnvsConfigWithoutVersion === aspectEntry.id.toString({ ignoreVersion: true })\n );\n });\n\n if (matchedEntry?.id) return matchedEntry?.id;\n }\n\n // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env\n let ids: string[] = [];\n component.state.aspects.entries.forEach((aspectEntry) => {\n ids.push(aspectEntry.id.toString());\n // ids.push(aspectEntry.id.toString({ ignoreVersion: true }));\n });\n ids = uniq(ids);\n const envId = await this.findFirstEnv(ids);\n const finalId = envId || this.getDefaultEnv().id;\n return ComponentID.fromString(finalId);\n }\n\n /**\n * This used to calculate the actual env during the component load.\n * Do not use it to get the env (use getEnv instead)\n * This should be used only during on load\n */\n calculateEnv(component: Component, opts: GetCalcEnvOptions = {}): EnvDefinition {\n // Search first for env configured via envs aspect itself\n const envIdFromEnvsConfig = this.getEnvIdFromEnvsConfig(component);\n let envIdFromEnvsConfigWithoutVersion;\n if (envIdFromEnvsConfig) {\n envIdFromEnvsConfigWithoutVersion = ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion();\n const envDef = this.getEnvDefinitionByStringId(envIdFromEnvsConfigWithoutVersion);\n if (envDef) {\n this.envIds.add(envDef.id);\n return envDef;\n }\n }\n\n // in some cases we have the id configured in the teambit.envs/envs but without the version\n // in such cases we won't find it in the slot\n // we search in the component aspect list a matching aspect which is match the id from the teambit.envs/envs\n if (envIdFromEnvsConfigWithoutVersion) {\n const matchedEntry = component.state.aspects.entries.find((aspectEntry) => {\n return (\n envIdFromEnvsConfigWithoutVersion === aspectEntry.id.toString() ||\n envIdFromEnvsConfigWithoutVersion === aspectEntry.id.toString({ ignoreVersion: true })\n );\n });\n if (matchedEntry) {\n // during the tag process, the version in the aspect-entry-id is changed and is not the\n // same as it was when it registered to the slot.\n const envDef = this.getEnvDefinitionById(matchedEntry.id);\n if (envDef) {\n this.envIds.add(envDef.id);\n return envDef;\n }\n if (!opts.skipWarnings) {\n // Do not allow a non existing env\n this.printWarningIfFirstTime(\n matchedEntry.id.toString(),\n `environment with ID: ${matchedEntry.id.toString()} configured on component ${component.id.toString()} was not loaded (run \"bit install\")`\n );\n }\n }\n // Do not allow configure teambit.envs/envs on the component without configure the env aspect itself\n // const errMsg = new EnvNotConfiguredForComponent(envIdFromEnvsConfig as string, component.id.toString()).message;\n // this.printWarningIfFirstTime(envIdFromEnvsConfig as string, errMsg);\n }\n\n // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env\n let envDefFromList;\n component.state.aspects.entries.find((aspectEntry) => {\n const envDef = this.getEnvDefinitionById(aspectEntry.id);\n if (envDef) {\n envDefFromList = envDef;\n }\n return !!envDef;\n });\n\n if (envDefFromList) {\n this.envIds.add(envDefFromList.id);\n return envDefFromList;\n }\n return this.getDefaultEnv();\n }\n\n /**\n * an env can be configured on a component in two ways:\n * 1) explicitly inside \"teambit.envs/envs\". `{ \"teambit.envs/envs\": { \"env\": \"my-env\" } }`\n * 2) the env aspect is set on the variant as any other aspect, e.g. `{ \"my-env\": {} }`\n *\n * this method returns #1 if exists, otherwise, #2.\n */\n getAllEnvsConfiguredOnComponent(component: Component): EnvDefinition[] {\n // if a component has \"envs\" config, use it and ignore other components that are set up\n // in this components which happen to be envs.\n const envDef = this.getEnvFromEnvsConfig(component);\n if (envDef) {\n return [envDef];\n }\n\n return this.getEnvsNotFromEnvsConfig(component);\n }\n\n /**\n * whether a component has an env configured (either by variant or .bitmap).\n */\n hasEnvConfigured(component: Component): boolean {\n return Boolean(this.getAllEnvsConfiguredOnComponent(component).length);\n }\n\n getAllRegisteredEnvsIds(): string[] {\n return this.envSlot.toArray().map((envData) => envData[0]);\n }\n\n getAllRegisteredEnvs(): Environment[] {\n return this.envSlot.toArray().map((envData) => envData[1]);\n }\n\n getAllRegisteredEnvJsoncCustomizers(): EnvJsoncMergeCustomizer[] {\n return this.envJsoncMergeCustomizerSlot.toArray().map((customizerEntry) => customizerEntry[1]);\n }\n\n getEnvPlugin() {\n return new EnvPlugin(this.envSlot, this.servicesRegistry, this.loggerMain, this.workerMain, this.harmony);\n }\n\n /**\n * an env can be configured on a component in two ways:\n * 1) explicitly inside \"teambit.envs/envs\". `{ \"teambit.envs/envs\": { \"env\": \"my-env\" } }`\n * 2) the env aspect is set on the variant as any other aspect, e.g. `{ \"my-env\": {} }`\n *\n * this method returns only #1\n */\n getEnvFromEnvsConfig(component: Component): EnvDefinition | undefined {\n const envIdFromEnvsConfig = this.getEnvIdFromEnvsConfig(component);\n if (!envIdFromEnvsConfig) {\n return undefined;\n }\n const envIdFromEnvsConfigWithoutVersion = ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion();\n const envDef = this.getEnvDefinitionByStringId(envIdFromEnvsConfigWithoutVersion);\n return envDef;\n }\n\n /**\n * an env can be configured on a component in two ways:\n * 1) explicitly inside \"teambit.envs/envs\". `{ \"teambit.envs/envs\": { \"env\": \"my-env\" } }`\n * 2) the env aspect is set on the variant as any other aspect, e.g. `{ \"my-env\": {} }`\n *\n * this method returns only #2\n */\n getEnvsNotFromEnvsConfig(component: Component): EnvDefinition[] {\n return component.state.aspects.entries.reduce((acc: EnvDefinition[], aspectEntry) => {\n const envDef = this.getEnvDefinitionById(aspectEntry.id);\n if (envDef) acc.push(envDef);\n return acc;\n }, []);\n }\n\n getEnvIdFromEnvsLegacyExtensions(extensions: ExtensionDataList): string | undefined {\n const envsAspect = extensions.findCoreExtension(EnvsAspect.id);\n const envIdFromEnvsConfig = envsAspect?.data.id;\n return envIdFromEnvsConfig;\n }\n\n /**\n * @deprecated DO NOT USE THIS METHOD ANYMORE!!! (PLEASE USE .calculateEnvId() instead!)\n */\n async calculateEnvIdFromExtensions(extensions: ExtensionDataList): Promise<string> {\n // Search first for env configured via envs aspect itself\n const envsAspect = extensions.findCoreExtension(EnvsAspect.id);\n const envIdFromEnvsConfig = envsAspect?.config.env;\n\n const envIdFromEnvsConfigWithoutVersion = envIdFromEnvsConfig\n ? ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion()\n : undefined;\n\n if (envIdFromEnvsConfig && this.isCoreEnv(envIdFromEnvsConfig)) {\n return envIdFromEnvsConfig;\n }\n\n // in some cases we have the id configured in the teambit.envs/envs but without the version\n // in such cases we won't find it in the slot\n // we search in the component aspect list a matching aspect which is match the id from the teambit.envs/envs\n if (envIdFromEnvsConfigWithoutVersion) {\n const matchedEntry = extensions.find((extension) => {\n if (extension.extensionId) {\n return (\n envIdFromEnvsConfigWithoutVersion === extension.extensionId.toString() ||\n envIdFromEnvsConfigWithoutVersion === extension.extensionId.toString({ ignoreVersion: true })\n );\n }\n return envIdFromEnvsConfigWithoutVersion === extension.stringId;\n });\n if (matchedEntry?.id) return matchedEntry?.stringId;\n }\n\n // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env\n const ids: string[] = [];\n extensions.forEach((extension) => {\n if (extension.extensionId) {\n ids.push(extension.extensionId.toString());\n } else {\n ids.push(extension.stringId);\n }\n });\n const envId = await this.findFirstEnv(ids);\n const finalId = envId || this.getDefaultEnv().id;\n return finalId;\n }\n\n /**\n * @deprecated DO NOT USE THIS METHOD ANYMORE!!! (PLEASE USE .calculateEnv() instead!)\n */\n async calculateEnvFromExtensions(extensions: ExtensionDataList): Promise<EnvDefinition> {\n // Search first for env configured via envs aspect itself\n const envsAspect = extensions.findCoreExtension(EnvsAspect.id);\n const envIdFromEnvsConfig = envsAspect?.config.env;\n let envIdFromEnvsConfigWithoutVersion;\n\n if (envIdFromEnvsConfig) {\n envIdFromEnvsConfigWithoutVersion = ComponentID.fromString(envIdFromEnvsConfig).toStringWithoutVersion();\n const envDef = this.getEnvDefinitionByStringId(envIdFromEnvsConfigWithoutVersion);\n if (envDef) {\n this.envIds.add(envDef.id);\n return envDef;\n }\n }\n\n // in some cases we have the id configured in the teambit.envs/envs but without the version\n // in such cases we won't find it in the slot\n // we search in the component aspect list a matching aspect which is match the id from the teambit.envs/envs\n if (envIdFromEnvsConfigWithoutVersion) {\n const matchedEntry = extensions.find((extension) => {\n if (extension.extensionId) {\n return (\n envIdFromEnvsConfigWithoutVersion === extension.extensionId.toString() ||\n envIdFromEnvsConfigWithoutVersion === extension.extensionId.toString({ ignoreVersion: true })\n );\n }\n return envIdFromEnvsConfigWithoutVersion === extension.stringId;\n });\n if (matchedEntry) {\n // during the tag process, the version in the aspect-entry-id is changed and is not the\n // same as it was when it registered to the slot.\n const envDef = this.getEnvDefinitionByLegacyExtension(matchedEntry);\n if (envDef) {\n this.envIds.add(envDef.id);\n return envDef;\n }\n // Do not allow a non existing env\n // this.printWarningIfFirstTime(\n // matchedEntry.id.toString(),\n // `environment with ID: ${matchedEntry.id.toString()} was not found`\n // );\n }\n // Do not allow configure teambit.envs/envs on the component without configure the env aspect itself\n // const errMsg = new EnvNotConfiguredForComponent(envIdFromEnvsConfig).message;\n // this.printWarningIfFirstTime(envIdFromEnvsConfig, errMsg);\n }\n\n // in case there is no config in teambit.envs/envs search the aspects for the first env that registered as env\n const ids: string[] = [];\n extensions.forEach((extension) => {\n if (extension.extensionId) {\n ids.push(extension.extensionId.toString());\n } else {\n ids.push(extension.stringId);\n }\n });\n const envId = await this.findFirstEnv(ids);\n const envDef = envId ? this.getEnvDefinitionByStringId(envId) : undefined;\n\n return envDef || this.getDefaultEnv();\n }\n\n /**\n * This function finds the first environment ID from a list of IDs by checking if it is register as env (to the slot).\n * or contains env.jsonc file\n * @param {string[]} ids - `ids` is an array of string values representing environment IDs. The function `findFirstEnv`\n * takes this array as input and returns a Promise that resolves to a string value representing the first environment ID\n * that matches certain conditions.\n * @returns The `findFirstEnv` function returns a Promise that resolves to a string or undefined. The string represents\n * the ID of the first environment that matches the conditions specified in the function, or undefined if no environment\n * is found.\n */\n private async findFirstEnv(ids: string[]): Promise<string | undefined> {\n let isFoundWithoutVersion = false;\n const envId = await pLocate(ids, async (id) => {\n const idWithoutVersion = id.split('@')[0];\n if (this.isCoreEnv(idWithoutVersion)) return true;\n if (isCoreAspect(idWithoutVersion)) return false;\n const envDef = this.getEnvDefinitionByStringId(id);\n if (envDef) return true;\n const envDefWithoutVersion = this.getEnvDefinitionByStringId(idWithoutVersion);\n if (envDefWithoutVersion) {\n isFoundWithoutVersion = true;\n return true;\n }\n const envComponent = await this.getEnvComponentByEnvId(id);\n const hasManifest = this.hasEnvManifest(envComponent);\n if (hasManifest) return true;\n const isUsingEnvEnv = this.isUsingEnvEnv(envComponent);\n return !!isUsingEnvEnv;\n });\n let finalEnvId;\n if (envId) {\n finalEnvId = isFoundWithoutVersion ? envId?.split('@')[0] : envId;\n this.envIds.add(envId);\n }\n return finalEnvId;\n }\n\n private getEnvDefinitionByLegacyExtension(extension: ExtensionDataEntry): EnvDefinition | undefined {\n const envDef = extension.extensionId\n ? this.getEnvDefinitionById(extension.extensionId)\n : this.getEnvDefinitionByStringId(extension.stringId);\n return envDef;\n }\n\n getEnvIdFromEnvsConfig(component: Component): string | undefined {\n const envsAspect = component.state.aspects.get(EnvsAspect.id);\n return envsAspect?.config.env;\n }\n\n getEnvDefinition(id: ComponentID) {\n const allVersions = this.envSlot.toArray();\n const all = allVersions.filter(([envId]) => envId.includes(id.toStringWithoutVersion()));\n const first = head(all);\n if (!first) return undefined;\n const [envId, env] = first;\n return new EnvDefinition(envId, env);\n }\n\n getEnvDefinitionById(id: ComponentID): EnvDefinition | undefined {\n const envDef =\n this.getEnvDefinitionByStringId(id.toString()) ||\n this.getEnvDefinitionByStringId(id.toString({ ignoreVersion: true }));\n return envDef;\n }\n\n public getEnvDefinitionByStringId(envId: string): EnvDefinition | undefined {\n const env = this.envSlot.get(envId);\n if (env) {\n return new EnvDefinition(envId, env as Environment);\n }\n return undefined;\n }\n\n getEnvFromComponent(envComponent: Component): EnvDefinition | undefined {\n const env = this.getEnvDefinitionById(envComponent.id);\n return env;\n }\n\n /**\n * Return the env definition of teambit.envs/env\n */\n getEnvsEnvDefinition(): EnvDefinition {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.getEnvDefinitionByStringId('teambit.envs/env')!;\n }\n\n private printWarningIfFirstTime(envId: string, message: string) {\n if (!this.alreadyShownWarning[envId] && !this.failedToLoadEnvs.has(envId)) {\n this.alreadyShownWarning[envId] = true;\n this.logger.consoleWarning(message);\n this.addFailedToLoadEnvs(envId);\n }\n }\n\n /**\n * determines whether an env is registered.\n */\n public isEnvRegistered(id: string) {\n return Boolean(this.envSlot.get(id));\n }\n\n isUsingAspectEnv(component: Component): boolean {\n const data = this.getEnvData(component);\n if (!data) return false;\n return data.type === 'aspect';\n }\n\n isUsingEnvEnv(component: Component): boolean {\n const data = this.getEnvData(component);\n if (!data) return false;\n return data.type === 'env';\n }\n\n /**\n * Check if the given component is an env component.\n * @param component\n * @returns\n */\n isEnv(component: Component): boolean {\n return (\n this.isUsingEnvEnv(component) ||\n this.isEnvRegistered(component.id.toString()) ||\n this.isEnvRegistered(component.id.toStringWithoutVersion())\n );\n }\n\n /**\n * register a new environment service.\n */\n registerService(...envServices: EnvService<any>[]) {\n this.servicesRegistry.register(envServices);\n return this;\n }\n\n /**\n * get list of services enabled on an env.\n */\n getServices(env: EnvDefinition): EnvServiceList {\n const allServices = this.servicesRegistry.toArray();\n const services: [string, EnvService<any>][] = [];\n allServices.forEach(([id, currentServices]) => {\n currentServices.forEach((service) => {\n try {\n if (this.implements(env, service)) {\n services.push([id, service]);\n }\n } catch (err) {\n this.logger.warn(`failed loading service ${id} for env ${env.id}`);\n }\n });\n });\n return new EnvServiceList(env, services);\n }\n\n implements(env: EnvDefinition, service: EnvService<any>) {\n // TODO: remove this after refactoring everything and remove getDescriptor from being optional.\n if (!service.getDescriptor) return false;\n return !!service.getDescriptor(env);\n }\n\n /**\n * register an environment.\n */\n registerEnv(env: Environment) {\n return this.envSlot.register(env);\n }\n\n /**\n * register an env.jsonc merge customizer.\n */\n registerEnvJsoncMergeCustomizer(customizer: EnvJsoncMergeCustomizer) {\n return this.envJsoncMergeCustomizerSlot.register(customizer);\n }\n\n async addNonLoadedEnvAsComponentIssues(components: Component[]) {\n await pMapSeries(components, async (component) => {\n const envId = await this.calculateEnvId(component);\n const envIdStr = envId.toString();\n if (!this.isEnvRegistered(envIdStr)) {\n this.addFailedToLoadEnvs(envIdStr);\n // If there is no version and the env is not in the workspace this is not valid\n // you can't set external env without version\n if (!envIdStr.includes('@')) {\n const foundComp = components.find((c) => c.id.toStringWithoutVersion() === envIdStr);\n if (!foundComp) {\n component.state.issues.getOrCreate(IssuesClasses.ExternalEnvWithoutVersion).data = {\n envId: envIdStr,\n componentId: component.id.toString(),\n };\n } else {\n component.state.issues.getOrCreate(IssuesClasses.NonLoadedEnv).data = envIdStr;\n }\n } else {\n component.state.issues.getOrCreate(IssuesClasses.NonLoadedEnv).data = envIdStr;\n }\n }\n });\n }\n\n // refactor here\n private async createRuntime(components: Component[]): Promise<Runtime> {\n return new Runtime(await this.aggregateByDefs(components), this.logger);\n }\n\n // :TODO can be refactored to few utilities who will make repeating this very easy.\n private async aggregateByDefs(components: Component[]): Promise<EnvRuntime[]> {\n this.throwForDuplicateComponents(components);\n const envsMap = {};\n components.forEach((component: Component) => {\n const envDef = this.getEnv(component);\n const envId = envDef.id;\n const env = envDef.env;\n // handle config as well when aggregating envs.\n if (envsMap[envId]) envsMap[envId].components.push(component);\n else\n envsMap[envId] = {\n components: [component],\n env,\n };\n });\n\n return Promise.all(\n Object.keys(envsMap).map(async (key) => {\n const envAspectDef = await this.getEnvAspectDef(key);\n return new EnvRuntime(key, envsMap[key].env, envsMap[key].components, envAspectDef);\n })\n );\n }\n\n private async getEnvAspectDef(envId: string): Promise<AspectDefinition> {\n const host = this.componentMain.getHost();\n const id = await host.resolveComponentId(envId);\n // We don't want to filter by runtime here as we want to also get envs that configured as plugins. so they don't\n // contain the runtime path.\n const resolvedAspects = await host.resolveAspects(MainRuntime.name, [id], {\n requestedOnly: true,\n filterByRuntime: false,\n useScopeAspectsCapsule: true,\n });\n const def = resolvedAspects[0];\n\n return def;\n }\n\n private throwForDuplicateComponents(components: Component[]) {\n const idsStr = components.map((c) => c.id.toString());\n const duplications = findDuplications(idsStr);\n if (duplications.length) {\n throw new Error(`found duplicated components: ${duplications.join(', ')}`);\n }\n }\n\n static slots = [\n Slot.withType<Environment>(),\n Slot.withType<EnvService<any>>(),\n Slot.withType<EnvJsoncMergeCustomizerRegistry>(),\n ];\n\n static dependencies = [GraphqlAspect, LoggerAspect, ComponentAspect, CLIAspect, WorkerAspect, IssuesAspect];\n\n static async provider(\n [graphql, loggerAspect, component, cli, worker, issues]: [\n GraphqlMain,\n LoggerMain,\n ComponentMain,\n CLIMain,\n WorkerMain,\n IssuesMain,\n ],\n config: EnvsConfig,\n [envSlot, servicesRegistry, envJsoncMergeCustomizerSlot]: [\n EnvsRegistry,\n ServicesRegistry,\n EnvJsoncMergeCustomizerRegistry,\n ],\n context: Harmony\n ) {\n const logger = loggerAspect.createLogger(EnvsAspect.id);\n const envs = new EnvsMain(\n config,\n context,\n envSlot,\n logger,\n servicesRegistry,\n component,\n loggerAspect,\n worker,\n envJsoncMergeCustomizerSlot\n );\n component.registerShowFragments([new EnvFragment(envs)]);\n if (issues) issues.registerAddComponentsIssues(envs.addNonLoadedEnvAsComponentIssues.bind(envs));\n\n const envsCmd = new EnvsCmd(envs, component);\n envsCmd.commands = [new ListEnvsCmd(envs, component), new GetEnvCmd(envs, component)];\n cli.register(envsCmd);\n graphql.register(environmentsSchema(envs));\n return envs;\n }\n}\n\nEnvsAspect.addRuntime(EnvsMain);\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,KAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,IAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,SAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,QAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EA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EjK,SAAS,CAAC;IAC5CqK,OAAO,CAACE,QAAQ,GAAG,CAAC,KAAIC,mBAAW,EAACP,IAAI,EAAEjK,SAAS,CAAC,EAAE,KAAIyK,iBAAS,EAACR,IAAI,EAAEjK,SAAS,CAAC,CAAC;IACrF6J,GAAG,CAACzC,QAAQ,CAACiD,OAAO,CAAC;IACrBV,OAAO,CAACvC,QAAQ,CAAC,IAAAsD,mCAAkB,EAACT,IAAI,CAAC,CAAC;IAC1C,OAAOA,IAAI;EACb;AACF;AAAC5Q,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAAAlB,eAAA,CAxhCYkB,QAAQ,aAgBF4P,kBAAW;AAAA9Q,eAAA,CAhBjBkB,QAAQ,WA0+BJ,CACbqR,eAAI,CAACC,QAAQ,CAAc,CAAC,EAC5BD,eAAI,CAACC,QAAQ,CAAkB,CAAC,EAChCD,eAAI,CAACC,QAAQ,CAAkC,CAAC,CACjD;AAAAxS,eAAA,CA9+BUkB,QAAQ,kBAg/BG,CAACuR,wBAAa,EAAEC,sBAAY,EAAEC,4BAAe,EAAEC,gBAAS,EAAEC,sBAAY,EAAEC,sBAAY,CAAC;AA0C7G5K,0BAAU,CAAC6K,UAAU,CAAC7R,QAAQ,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_chalk","_cliTable","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ListEnvsCmd","constructor","envs","componentAspect","report","allEnvs","getAllRegisteredEnvsIds","join","title","chalk","green","exports","GetEnvCmd","name","description","showEnv","id","host","servicesArr","component","get","resolveComponentId","Error","env","getEnv","envRuntime","createEnvironment","envExecutionContext","getEnvExecutionContext","services","getServices","allP","map","serviceId","service","includes","serviceTitle","cyan","bold","underline","content","render","all","compact","Promise","envTitle","getHost","split","undefined","EnvsCmd","Set","components","list","table","getTable","warning","getNonLoadedEnvsWarning","tableData","pMapSeries","envId","calculateEnvId","envIdStr","toString","isLoaded","isEnvRegistered","nonLoadedEnvs","add","envWithErr","red","header","CLITable","fromObject","sort","size","Array","from","values","yellow"],"sources":["envs.cmd.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport pMapSeries from 'p-map-series';\nimport chalk from 'chalk';\nimport { CLITable } from '@teambit/cli-table';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { compact } from 'lodash';\nimport { ComponentMain, ComponentFactory, Component } from '@teambit/component';\nimport { EnvsMain } from './environments.main.runtime';\n\nexport class ListEnvsCmd implements Command {\n name = 'list';\n description = 'list all envs currently used in the workspace';\n options = [];\n group = 'development';\n\n constructor(private envs: EnvsMain, private componentAspect: ComponentMain) {}\n\n async report() {\n const allEnvs = this.envs.getAllRegisteredEnvsIds().join('\\n');\n const title = chalk.green('the following envs are available in the workspace:');\n return `${title}\\n${allEnvs}`;\n }\n}\n\ntype GetEnvOpts = {\n services: string;\n};\n\nexport class GetEnvCmd implements Command {\n name = 'get <component-name>';\n description = \"show config information from a component's env\";\n arguments = [\n {\n name: 'component-name',\n description: \"the 'component name' or 'component id' of the component whose env you'd like to inspect\",\n },\n ];\n examples: [{ cmd: 'get ui/button'; description: 'show config information from the env configured for ui/button' }];\n options = [\n [\n '',\n 'services <string>',\n 'show information about the specific services only. for multiple services, separate by a comma and wrap with quotes',\n ],\n ] as CommandOptions;\n group = 'development';\n\n constructor(private envs: EnvsMain, private componentAspect: ComponentMain) {}\n\n async showEnv(id: string, host: ComponentFactory, servicesArr: string[] | undefined) {\n const component = await host.get(await host.resolveComponentId(id));\n if (!component) throw new Error(`component for env ${id} was not found`);\n const env = this.envs.getEnv(component);\n const envRuntime = await this.envs.createEnvironment([component]);\n const envExecutionContext = envRuntime.getEnvExecutionContext();\n const services = this.envs.getServices(env);\n const allP = services.services.map(async ([serviceId, service]) => {\n if (servicesArr && !servicesArr.includes(serviceId)) return null;\n const serviceTitle = chalk.cyan.bold.underline(serviceId);\n const content = service.render ? await service.render(env, envExecutionContext) : '';\n return `${serviceTitle}\\n\\n${content}`;\n });\n\n const all = compact(await Promise.all(allP));\n\n const envTitle = chalk.green(`Environment: ${env.id}`);\n return `${envTitle}\\n${all.join('\\n\\n')}`;\n }\n\n async report([name]: [string], { services }: GetEnvOpts): Promise<string> {\n const host = this.componentAspect.getHost();\n const servicesArr = services ? services.split(',') : undefined;\n\n // TODO: think what to do re this line with gilad.\n if (!host) throw new Error('error: workspace not found');\n return this.showEnv(name, host, servicesArr);\n }\n}\n\nexport class EnvsCmd implements Command {\n name = 'envs';\n alias = 'env';\n description = 'list all components maintained by the workspace and their corresponding envs';\n options = [];\n group = 'development';\n commands: Command[] = [];\n\n // private showNonLoadedEnvsWarning = false;\n private nonLoadedEnvs = new Set<string>();\n\n constructor(private envs: EnvsMain, private componentAspect: ComponentMain) {}\n\n async report(): Promise<string> {\n const host = this.componentAspect.getHost();\n // TODO: think what to do re this line with gilad.\n if (!host) throw new Error('error: workspace not found');\n const components = await host.list();\n const table = await this.getTable(components);\n const warning = this.getNonLoadedEnvsWarning();\n return warning ? `${table}\\n${warning}` : table;\n }\n\n private async getTable(components: Component[]) {\n const tableData = await pMapSeries(components, async (component) => {\n // const envId = this.envs.getEnvId(component);\n const envId = await this.envs.calculateEnvId(component);\n const envIdStr = envId.toString();\n const isLoaded = this.envs.isEnvRegistered(envIdStr);\n if (!isLoaded) {\n this.nonLoadedEnvs.add(envIdStr);\n }\n const envWithErr = isLoaded ? envIdStr : `${envIdStr} ${chalk.red('(not loaded)')}`;\n return {\n component: component.id.toString(),\n env: envWithErr,\n };\n });\n\n const header = [\n {\n value: 'component',\n },\n {\n value: 'env',\n },\n ];\n const table = CLITable.fromObject(header, tableData);\n table.sort();\n return table.render();\n }\n\n getNonLoadedEnvsWarning() {\n if (!this.nonLoadedEnvs.size) return '';\n const list = Array.from(this.nonLoadedEnvs.values()).join(',');\n return chalk.yellow(`warning: bit wasn't able to load the following envs: ${chalk.cyan(list)}.\nplease run ${chalk.cyan(\"'bit install'\")} to fix. if this doesn't help, run ${chalk.cyan(\n \"'bit status'\"\n )} to see if there are any additional issues`);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiC,SAAAC,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC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sB,KAAK,CAACC,IAAI,CAAC,IAAI,CAACV,aAAa,CAACW,MAAM,CAAC,CAAC,CAAC,CAACrE,IAAI,CAAC,GAAG,CAAC;IAC9D,OAAOE,gBAAK,CAACoE,MAAM,CAAC,wDAAwDpE,gBAAK,CAAC4B,IAAI,CAACe,IAAI,CAAC;AAChG,aAAa3C,gBAAK,CAAC4B,IAAI,CAAC,eAAe,CAAC,sCAAsC5B,gBAAK,CAAC4B,IAAI,CAClF,cACF,CAAC,4CAA4C,CAAC;EAChD;AACF;AAAC1B,OAAA,CAAAsC,OAAA,GAAAA,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_chalk","_cliTable","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ListEnvsCmd","constructor","envs","componentAspect","report","allEnvs","getAllRegisteredEnvsIds","join","title","chalk","green","exports","GetEnvCmd","name","description","showEnv","id","host","servicesArr","component","get","resolveComponentId","Error","env","getEnv","envRuntime","createEnvironment","envExecutionContext","getEnvExecutionContext","services","getServices","allP","map","serviceId","service","includes","serviceTitle","cyan","bold","underline","content","render","all","compact","Promise","envTitle","getHost","split","undefined","EnvsCmd","Set","components","list","table","getTable","warning","getNonLoadedEnvsWarning","tableData","pMapSeries","envId","calculateEnvId","envIdStr","toString","isLoaded","isEnvRegistered","nonLoadedEnvs","add","envWithErr","red","header","CLITable","fromObject","sort","size","Array","from","values","yellow"],"sources":["envs.cmd.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport pMapSeries from 'p-map-series';\nimport chalk from 'chalk';\nimport { CLITable } from '@teambit/cli-table';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { compact } from 'lodash';\nimport { ComponentMain, ComponentFactory, Component } from '@teambit/component';\nimport { EnvsMain } from './environments.main.runtime';\n\nexport class ListEnvsCmd implements Command {\n name = 'list';\n description = 'list all envs currently used in the workspace';\n options = [];\n group = 'development';\n\n constructor(\n private envs: EnvsMain,\n private componentAspect: ComponentMain\n ) {}\n\n async report() {\n const allEnvs = this.envs.getAllRegisteredEnvsIds().join('\\n');\n const title = chalk.green('the following envs are available in the workspace:');\n return `${title}\\n${allEnvs}`;\n }\n}\n\ntype GetEnvOpts = {\n services: string;\n};\n\nexport class GetEnvCmd implements Command {\n name = 'get <component-name>';\n description = \"show config information from a component's env\";\n arguments = [\n {\n name: 'component-name',\n description: \"the 'component name' or 'component id' of the component whose env you'd like to inspect\",\n },\n ];\n examples: [{ cmd: 'get ui/button'; description: 'show config information from the env configured for ui/button' }];\n options = [\n [\n '',\n 'services <string>',\n 'show information about the specific services only. for multiple services, separate by a comma and wrap with quotes',\n ],\n ] as CommandOptions;\n group = 'development';\n\n constructor(\n private envs: EnvsMain,\n private componentAspect: ComponentMain\n ) {}\n\n async showEnv(id: string, host: ComponentFactory, servicesArr: string[] | undefined) {\n const component = await host.get(await host.resolveComponentId(id));\n if (!component) throw new Error(`component for env ${id} was not found`);\n const env = this.envs.getEnv(component);\n const envRuntime = await this.envs.createEnvironment([component]);\n const envExecutionContext = envRuntime.getEnvExecutionContext();\n const services = this.envs.getServices(env);\n const allP = services.services.map(async ([serviceId, service]) => {\n if (servicesArr && !servicesArr.includes(serviceId)) return null;\n const serviceTitle = chalk.cyan.bold.underline(serviceId);\n const content = service.render ? await service.render(env, envExecutionContext) : '';\n return `${serviceTitle}\\n\\n${content}`;\n });\n\n const all = compact(await Promise.all(allP));\n\n const envTitle = chalk.green(`Environment: ${env.id}`);\n return `${envTitle}\\n${all.join('\\n\\n')}`;\n }\n\n async report([name]: [string], { services }: GetEnvOpts): Promise<string> {\n const host = this.componentAspect.getHost();\n const servicesArr = services ? services.split(',') : undefined;\n\n // TODO: think what to do re this line with gilad.\n if (!host) throw new Error('error: workspace not found');\n return this.showEnv(name, host, servicesArr);\n }\n}\n\nexport class EnvsCmd implements Command {\n name = 'envs';\n alias = 'env';\n description = 'list all components maintained by the workspace and their corresponding envs';\n options = [];\n group = 'development';\n commands: Command[] = [];\n\n // private showNonLoadedEnvsWarning = false;\n private nonLoadedEnvs = new Set<string>();\n\n constructor(\n private envs: EnvsMain,\n private componentAspect: ComponentMain\n ) {}\n\n async report(): Promise<string> {\n const host = this.componentAspect.getHost();\n // TODO: think what to do re this line with gilad.\n if (!host) throw new Error('error: workspace not found');\n const components = await host.list();\n const table = await this.getTable(components);\n const warning = this.getNonLoadedEnvsWarning();\n return warning ? `${table}\\n${warning}` : table;\n }\n\n private async getTable(components: Component[]) {\n const tableData = await pMapSeries(components, async (component) => {\n // const envId = this.envs.getEnvId(component);\n const envId = await this.envs.calculateEnvId(component);\n const envIdStr = envId.toString();\n const isLoaded = this.envs.isEnvRegistered(envIdStr);\n if (!isLoaded) {\n this.nonLoadedEnvs.add(envIdStr);\n }\n const envWithErr = isLoaded ? envIdStr : `${envIdStr} ${chalk.red('(not loaded)')}`;\n return {\n component: component.id.toString(),\n env: envWithErr,\n };\n });\n\n const header = [\n {\n value: 'component',\n },\n {\n value: 'env',\n },\n ];\n const table = CLITable.fromObject(header, tableData);\n table.sort();\n return table.render();\n }\n\n getNonLoadedEnvsWarning() {\n if (!this.nonLoadedEnvs.size) return '';\n const list = Array.from(this.nonLoadedEnvs.values()).join(',');\n return chalk.yellow(`warning: bit wasn't able to load the following envs: ${chalk.cyan(list)}.\nplease run ${chalk.cyan(\"'bit install'\")} to fix. if this doesn't help, run ${chalk.cyan(\n \"'bit status'\"\n )} to see if there are any additional issues`);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAA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{"version":3,"names":["_bitError","data","require","EnvNotFound","BitError","constructor","id","componentId","getMessage","exports","compIdDetails"],"sources":["env-not-found.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\n\nexport class EnvNotFound extends BitError {\n constructor(private id: string, private componentId?: string) {\n super(getMessage(id, componentId));\n }\n}\n\nfunction getMessage(id: string, componentId?: string): string {\n const compIdDetails = componentId ? `configured on component ${componentId}` : '';\n return `environment with ID: ${id} ${compIdDetails} was not found`;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,WAAW,SAASC,oBAAQ,CAAC;EACxCC,WAAWA,CAASC,EAAU,EAAUC,WAAoB,EAAE;IAC5D,KAAK,CAACC,UAAU,CAACF,EAAE,EAAEC,WAAW,CAAC,CAAC;IAAC,KADjBD,EAAU,GAAVA,EAAU;IAAA,KAAUC,WAAoB,GAApBA,WAAoB;EAE5D;AACF;AAACE,OAAA,CAAAN,WAAA,GAAAA,WAAA;AAED,SAASK,UAAUA,CAACF,EAAU,EAAEC,WAAoB,EAAU;EAC5D,MAAMG,aAAa,GAAGH,WAAW,GAAG,2BAA2BA,WAAW,EAAE,GAAG,EAAE;EACjF,OAAO,wBAAwBD,EAAE,IAAII,aAAa,gBAAgB;AACpE","ignoreList":[]}
1
+ {"version":3,"names":["_bitError","data","require","EnvNotFound","BitError","constructor","id","componentId","getMessage","exports","compIdDetails"],"sources":["env-not-found.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\n\nexport class EnvNotFound extends BitError {\n constructor(\n private id: string,\n private componentId?: string\n ) {\n super(getMessage(id, componentId));\n }\n}\n\nfunction getMessage(id: string, componentId?: string): string {\n const compIdDetails = componentId ? `configured on component ${componentId}` : '';\n return `environment with ID: ${id} ${compIdDetails} was not found`;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,WAAW,SAASC,oBAAQ,CAAC;EACxCC,WAAWA,CACDC,EAAU,EACVC,WAAoB,EAC5B;IACA,KAAK,CAACC,UAAU,CAACF,EAAE,EAAEC,WAAW,CAAC,CAAC;IAAC,KAH3BD,EAAU,GAAVA,EAAU;IAAA,KACVC,WAAoB,GAApBA,WAAoB;EAG9B;AACF;AAACE,OAAA,CAAAN,WAAA,GAAAA,WAAA;AAED,SAASK,UAAUA,CAACF,EAAU,EAAEC,WAAoB,EAAU;EAC5D,MAAMG,aAAa,GAAGH,WAAW,GAAG,2BAA2BA,WAAW,EAAE,GAAG,EAAE;EACjF,OAAO,wBAAwBD,EAAE,IAAII,aAAa,gBAAgB;AACpE","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.envs_envs@1.0.425/dist/env.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.envs_envs@1.0.425/dist/envs.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.envs_envs@1.0.426/dist/env.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.envs_envs@1.0.426/dist/envs.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -1,7 +1,10 @@
1
1
  import { BitError } from '@teambit/bit-error';
2
2
 
3
3
  export class EnvNotFound extends BitError {
4
- constructor(private id: string, private componentId?: string) {
4
+ constructor(
5
+ private id: string,
6
+ private componentId?: string
7
+ ) {
5
8
  super(getMessage(id, componentId));
6
9
  }
7
10
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/envs",
3
- "version": "1.0.425",
3
+ "version": "1.0.426",
4
4
  "homepage": "https://bit.cloud/teambit/envs/envs",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.envs",
8
8
  "name": "envs",
9
- "version": "1.0.425"
9
+ "version": "1.0.426"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -20,33 +20,33 @@
20
20
  "@teambit/harmony": "0.4.6",
21
21
  "@teambit/bit-error": "0.0.404",
22
22
  "@teambit/component-id": "1.2.2",
23
- "@teambit/component": "1.0.425",
24
- "@teambit/aspect-loader": "1.0.425",
25
- "@teambit/cli": "0.0.1002",
26
- "@teambit/logger": "0.0.1095",
27
- "@teambit/worker": "0.0.1306",
28
- "@teambit/builder": "1.0.425",
29
- "@teambit/bundler": "1.0.425",
30
- "@teambit/compiler": "1.0.425",
31
- "@teambit/dependency-resolver": "1.0.425",
32
- "@teambit/formatter": "1.0.425",
33
- "@teambit/isolator": "1.0.425",
34
- "@teambit/linter": "1.0.425",
35
- "@teambit/pkg": "1.0.425",
36
- "@teambit/preview": "1.0.425",
37
- "@teambit/schema": "1.0.425",
38
- "@teambit/tester": "1.0.425",
39
- "@teambit/typescript": "1.0.425",
40
- "@teambit/webpack": "1.0.425",
41
- "@teambit/graphql": "1.0.425",
42
- "@teambit/bit": "1.8.76",
23
+ "@teambit/component": "1.0.426",
24
+ "@teambit/aspect-loader": "1.0.426",
25
+ "@teambit/cli": "0.0.1003",
26
+ "@teambit/logger": "0.0.1096",
27
+ "@teambit/worker": "0.0.1307",
28
+ "@teambit/builder": "1.0.426",
29
+ "@teambit/bundler": "1.0.426",
30
+ "@teambit/compiler": "1.0.426",
31
+ "@teambit/dependency-resolver": "1.0.426",
32
+ "@teambit/formatter": "1.0.426",
33
+ "@teambit/isolator": "1.0.426",
34
+ "@teambit/linter": "1.0.426",
35
+ "@teambit/pkg": "1.0.426",
36
+ "@teambit/preview": "1.0.426",
37
+ "@teambit/schema": "1.0.426",
38
+ "@teambit/tester": "1.0.426",
39
+ "@teambit/typescript": "1.0.426",
40
+ "@teambit/webpack": "1.0.426",
41
+ "@teambit/graphql": "1.0.426",
42
+ "@teambit/bit": "1.8.77",
43
43
  "@teambit/component-issues": "0.0.151",
44
- "@teambit/component.sources": "0.0.33",
45
- "@teambit/dev-files": "1.0.425",
46
- "@teambit/issues": "1.0.425",
44
+ "@teambit/component.sources": "0.0.34",
45
+ "@teambit/dev-files": "1.0.426",
46
+ "@teambit/issues": "1.0.426",
47
47
  "@teambit/toolbox.array.duplications-finder": "0.0.1",
48
48
  "@teambit/toolbox.modules.module-resolver": "0.0.7",
49
- "@teambit/cli-table": "0.0.48"
49
+ "@teambit/cli-table": "0.0.49"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/lodash": "4.14.165",
@@ -54,7 +54,7 @@
54
54
  "@types/fs-extra": "9.0.7",
55
55
  "@types/mocha": "9.1.0",
56
56
  "@teambit/harmony.envs.core-aspect-env": "0.0.60",
57
- "@teambit/envs.aspect-docs.envs": "0.0.169"
57
+ "@teambit/envs.aspect-docs.envs": "0.0.170"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^17.0.0 || ^18.0.0",