@teambit/envs 1.0.667 → 1.0.668
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context/context.ts +2 -2
- package/dist/context/context.d.ts +2 -2
- package/dist/context/context.js.map +1 -1
- package/dist/env-definition.d.ts +1 -1
- package/dist/env-definition.js.map +1 -1
- package/dist/env-interface.d.ts +1 -1
- package/dist/env-interface.js.map +1 -1
- package/dist/env-jsonc.detector.d.ts +1 -1
- package/dist/env-jsonc.detector.js.map +1 -1
- package/dist/env-service-list.d.ts +2 -2
- package/dist/env-service-list.js.map +1 -1
- package/dist/env.fragment.d.ts +2 -2
- package/dist/env.fragment.js.map +1 -1
- package/dist/env.plugin.d.ts +5 -5
- package/dist/env.plugin.js.map +1 -1
- package/dist/environment.d.ts +2 -2
- package/dist/environment.js.map +1 -1
- package/dist/environments.graphql.d.ts +2 -2
- package/dist/environments.graphql.js.map +1 -1
- package/dist/environments.main.runtime.d.ts +12 -12
- package/dist/environments.main.runtime.js.map +1 -1
- package/dist/envs.cmd.d.ts +3 -3
- package/dist/envs.cmd.js.map +1 -1
- package/dist/{preview-1753809186996.js → preview-1753833698619.js} +2 -2
- package/dist/runtime/env-runtime.d.ts +3 -3
- package/dist/runtime/env-runtime.js.map +1 -1
- package/dist/runtime/envs-execution-result.d.ts +2 -2
- package/dist/runtime/envs-execution-result.js.map +1 -1
- package/dist/runtime/runtime.d.ts +3 -3
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/services/service-handler-context.d.ts +4 -4
- package/dist/services/service-handler-context.js.map +1 -1
- package/dist/services/service-handler.d.ts +1 -1
- package/dist/services/service-handler.js.map +1 -1
- package/dist/services/service.d.ts +5 -5
- package/dist/services/service.js.map +1 -1
- package/package.json +26 -26
- package/runtime/env-runtime.ts +3 -3
- package/runtime/envs-execution-result.ts +2 -2
- package/runtime/runtime.ts +3 -3
- package/services/service-handler-context.ts +4 -4
- package/services/service-handler.ts +1 -1
- package/services/service.ts +5 -5
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_component","data","require","_pMapSeries","_interopRequireDefault","_exceptions","_context","_envsExecutionResult","e","__esModule","default","Runtime","constructor","runtimeEnvs","logger","runEnv","envRuntimeId","service","options","envRuntime","find","runtime","id","ComponentID","fromString","withoutVersion","toStringWithoutVersion","EnvNotFoundInRuntime","run","runOnce","Error","envsExecutionContext","getEnvExecutionContext","serviceResult","map","env","ExecutionContext","runtimes","errors","contexts","mapSeries","err","error","message","consoleFailure","name","push","EnvsExecutionResult","exports"],"sources":["runtime.ts"],"sourcesContent":["import { Logger } from '@teambit/logger';\nimport { ComponentID } from '@teambit/component';\nimport mapSeries from 'p-map-series';\nimport { EnvNotFoundInRuntime } from '../exceptions';\nimport { ExecutionContext } from '../context';\nimport { EnvService, ServiceExecutionResult } from '../services';\nimport { EnvRuntime } from './env-runtime';\nimport { EnvsExecutionResult } from './envs-execution-result';\n\nexport interface EnvResult<T extends ServiceExecutionResult> {\n env: EnvRuntime;\n data?: T;\n error?: Error;\n}\n\nexport class Runtime {\n constructor(\n /**\n * runtime instances of the environments.\n */\n readonly runtimeEnvs: EnvRuntime[],\n\n private logger: Logger\n ) {}\n\n /**\n * execute a service on a specific env.\n */\n runEnv<T extends ServiceExecutionResult>(\n envRuntimeId: string,\n service: EnvService<T>,\n options?: { [key: string]: any }\n ): Promise<EnvsExecutionResult<T>> {\n const envRuntime = this.runtimeEnvs.find((runtime) => {\n const id = ComponentID.fromString(runtime.id);\n const withoutVersion = id.toStringWithoutVersion();\n return withoutVersion === envRuntimeId;\n });\n if (!envRuntime) throw new EnvNotFoundInRuntime(envRuntimeId);\n return this.run(service, options, [envRuntime]);\n }\n\n /**\n * execute a service once for all environments.\n */\n async runOnce<T extends ServiceExecutionResult>(\n service: EnvService<T>,\n options?: { [key: string]: any }\n ): Promise<any> {\n if (!service.runOnce) throw new Error('a service must implement `runOnce()` in order to be executed');\n const envsExecutionContext = this.getEnvExecutionContext();\n const serviceResult = await service.runOnce(envsExecutionContext, options);\n return serviceResult;\n }\n\n getEnvExecutionContext(): ExecutionContext[] {\n const envsExecutionContext = this.runtimeEnvs.map((env) => new ExecutionContext(this, env));\n return envsExecutionContext;\n }\n\n /**\n * execute a service on each one of the environments.\n */\n async run<T extends ServiceExecutionResult>(\n /**\n * environment service to execute.\n */\n service: EnvService<T>,\n\n /**\n * options to proxy to the service upon execution.\n */\n options?: { [key: string]: any },\n runtimes?: EnvRuntime[]\n ): Promise<EnvsExecutionResult<T>> {\n if (!service.run) throw new Error('a service must implement `run()` in order to be executed');\n const errors: Error[] = [];\n const contexts: EnvResult<T>[] = await mapSeries(runtimes || this.runtimeEnvs, async (env) => {\n try {\n // @ts-ignore\n const serviceResult = await service.run(new ExecutionContext(this, env), options);\n\n return {\n env,\n data: serviceResult,\n };\n } catch (err: any) {\n this.logger.error(err.message, err);\n this.logger.consoleFailure(`service \"${service.name}\" of env \"${env.id}\" has failed. error: ${err.message}`);\n errors.push(err);\n return {\n env,\n error: err,\n };\n }\n });\n\n return new EnvsExecutionResult(contexts);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAM,qB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":3,"names":["_component","data","require","_pMapSeries","_interopRequireDefault","_exceptions","_context","_envsExecutionResult","e","__esModule","default","Runtime","constructor","runtimeEnvs","logger","runEnv","envRuntimeId","service","options","envRuntime","find","runtime","id","ComponentID","fromString","withoutVersion","toStringWithoutVersion","EnvNotFoundInRuntime","run","runOnce","Error","envsExecutionContext","getEnvExecutionContext","serviceResult","map","env","ExecutionContext","runtimes","errors","contexts","mapSeries","err","error","message","consoleFailure","name","push","EnvsExecutionResult","exports"],"sources":["runtime.ts"],"sourcesContent":["import type { Logger } from '@teambit/logger';\nimport { ComponentID } from '@teambit/component';\nimport mapSeries from 'p-map-series';\nimport { EnvNotFoundInRuntime } from '../exceptions';\nimport { ExecutionContext } from '../context';\nimport type { EnvService, ServiceExecutionResult } from '../services';\nimport type { EnvRuntime } from './env-runtime';\nimport { EnvsExecutionResult } from './envs-execution-result';\n\nexport interface EnvResult<T extends ServiceExecutionResult> {\n env: EnvRuntime;\n data?: T;\n error?: Error;\n}\n\nexport class Runtime {\n constructor(\n /**\n * runtime instances of the environments.\n */\n readonly runtimeEnvs: EnvRuntime[],\n\n private logger: Logger\n ) {}\n\n /**\n * execute a service on a specific env.\n */\n runEnv<T extends ServiceExecutionResult>(\n envRuntimeId: string,\n service: EnvService<T>,\n options?: { [key: string]: any }\n ): Promise<EnvsExecutionResult<T>> {\n const envRuntime = this.runtimeEnvs.find((runtime) => {\n const id = ComponentID.fromString(runtime.id);\n const withoutVersion = id.toStringWithoutVersion();\n return withoutVersion === envRuntimeId;\n });\n if (!envRuntime) throw new EnvNotFoundInRuntime(envRuntimeId);\n return this.run(service, options, [envRuntime]);\n }\n\n /**\n * execute a service once for all environments.\n */\n async runOnce<T extends ServiceExecutionResult>(\n service: EnvService<T>,\n options?: { [key: string]: any }\n ): Promise<any> {\n if (!service.runOnce) throw new Error('a service must implement `runOnce()` in order to be executed');\n const envsExecutionContext = this.getEnvExecutionContext();\n const serviceResult = await service.runOnce(envsExecutionContext, options);\n return serviceResult;\n }\n\n getEnvExecutionContext(): ExecutionContext[] {\n const envsExecutionContext = this.runtimeEnvs.map((env) => new ExecutionContext(this, env));\n return envsExecutionContext;\n }\n\n /**\n * execute a service on each one of the environments.\n */\n async run<T extends ServiceExecutionResult>(\n /**\n * environment service to execute.\n */\n service: EnvService<T>,\n\n /**\n * options to proxy to the service upon execution.\n */\n options?: { [key: string]: any },\n runtimes?: EnvRuntime[]\n ): Promise<EnvsExecutionResult<T>> {\n if (!service.run) throw new Error('a service must implement `run()` in order to be executed');\n const errors: Error[] = [];\n const contexts: EnvResult<T>[] = await mapSeries(runtimes || this.runtimeEnvs, async (env) => {\n try {\n // @ts-ignore\n const serviceResult = await service.run(new ExecutionContext(this, env), options);\n\n return {\n env,\n data: serviceResult,\n };\n } catch (err: any) {\n this.logger.error(err.message, err);\n this.logger.consoleFailure(`service \"${service.name}\" of env \"${env.id}\" has failed. error: ${err.message}`);\n errors.push(err);\n return {\n env,\n error: err,\n };\n }\n });\n\n return new EnvsExecutionResult(contexts);\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAM,qBAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA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it/component';
|
2
|
-
import { Harmony } from '@teambit/harmony';
|
3
|
-
import { Logger, LoggerMain } from '@teambit/logger';
|
4
|
-
import { WorkerMain } from '@teambit/worker';
|
1
|
+
import type { ComponentID } from '@teambit/component';
|
2
|
+
import type { Harmony } from '@teambit/harmony';
|
3
|
+
import type { Logger, LoggerMain } from '@teambit/logger';
|
4
|
+
import type { WorkerMain } from '@teambit/worker';
|
5
5
|
export declare class ServiceHandlerContext {
|
6
6
|
/**
|
7
7
|
* id of the environment defined in the context.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ServiceHandlerContext","constructor","envId","loggerMain","workerMain","harmony","createLogger","name","loggerName","toString","getAspect","aspectId","get","createWorker","path","worker","declareWorker","exports"],"sources":["service-handler-context.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component';\nimport { Harmony } from '@teambit/harmony';\nimport { Logger, LoggerMain } from '@teambit/logger';\nimport { WorkerMain } from '@teambit/worker';\n\nexport class ServiceHandlerContext {\n constructor(\n /**\n * id of the environment defined in the context.\n */\n readonly envId: ComponentID,\n readonly loggerMain: LoggerMain,\n readonly workerMain: WorkerMain,\n readonly harmony: Harmony\n ) {}\n\n /**\n * return a logger instance for the env.\n */\n createLogger(name?: string): Logger {\n const loggerName = name ? `${this.envId.toString()}::${name}` : this.envId.toString();\n\n return this.loggerMain.createLogger(loggerName);\n }\n\n /**\n * get an instance of an aspect. make sure it is loaded prior to requesting it.\n */\n getAspect<T>(aspectId: string) {\n return this.harmony.get<T>(aspectId);\n }\n\n /**\n * create worker for the env context.\n */\n createWorker<T>(name: string, path: string) {\n const worker = this.workerMain.declareWorker<T>(name, path);\n return worker;\n }\n}\n"],"mappings":";;;;;;AAKO,MAAMA,qBAAqB,CAAC;EACjCC,WAAWA;EACT;AACJ;AACA;EACaC,KAAkB,EAClBC,UAAsB,EACtBC,UAAsB,EACtBC,OAAgB,EACzB;IAAA,KAJSH,KAAkB,GAAlBA,KAAkB;IAAA,KAClBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,OAAgB,GAAhBA,OAAgB;EACxB;;EAEH;AACF;AACA;EACEC,YAAYA,CAACC,IAAa,EAAU;IAClC,MAAMC,UAAU,GAAGD,IAAI,GAAG,GAAG,IAAI,CAACL,KAAK,CAACO,QAAQ,CAAC,CAAC,KAAKF,IAAI,EAAE,GAAG,IAAI,CAACL,KAAK,CAACO,QAAQ,CAAC,CAAC;IAErF,OAAO,IAAI,CAACN,UAAU,CAACG,YAAY,CAACE,UAAU,CAAC;EACjD;;EAEA;AACF;AACA;EACEE,SAASA,CAAIC,QAAgB,EAAE;IAC7B,OAAO,IAAI,CAACN,OAAO,CAACO,GAAG,CAAID,QAAQ,CAAC;EACtC;;EAEA;AACF;AACA;EACEE,YAAYA,CAAIN,IAAY,EAAEO,IAAY,EAAE;IAC1C,MAAMC,MAAM,GAAG,IAAI,CAACX,UAAU,CAACY,aAAa,CAAIT,IAAI,EAAEO,IAAI,CAAC;IAC3D,OAAOC,MAAM;EACf;AACF;AAACE,OAAA,CAAAjB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["ServiceHandlerContext","constructor","envId","loggerMain","workerMain","harmony","createLogger","name","loggerName","toString","getAspect","aspectId","get","createWorker","path","worker","declareWorker","exports"],"sources":["service-handler-context.ts"],"sourcesContent":["import type { ComponentID } from '@teambit/component';\nimport type { Harmony } from '@teambit/harmony';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport type { WorkerMain } from '@teambit/worker';\n\nexport class ServiceHandlerContext {\n constructor(\n /**\n * id of the environment defined in the context.\n */\n readonly envId: ComponentID,\n readonly loggerMain: LoggerMain,\n readonly workerMain: WorkerMain,\n readonly harmony: Harmony\n ) {}\n\n /**\n * return a logger instance for the env.\n */\n createLogger(name?: string): Logger {\n const loggerName = name ? `${this.envId.toString()}::${name}` : this.envId.toString();\n\n return this.loggerMain.createLogger(loggerName);\n }\n\n /**\n * get an instance of an aspect. make sure it is loaded prior to requesting it.\n */\n getAspect<T>(aspectId: string) {\n return this.harmony.get<T>(aspectId);\n }\n\n /**\n * create worker for the env context.\n */\n createWorker<T>(name: string, path: string) {\n const worker = this.workerMain.declareWorker<T>(name, path);\n return worker;\n }\n}\n"],"mappings":";;;;;;AAKO,MAAMA,qBAAqB,CAAC;EACjCC,WAAWA;EACT;AACJ;AACA;EACaC,KAAkB,EAClBC,UAAsB,EACtBC,UAAsB,EACtBC,OAAgB,EACzB;IAAA,KAJSH,KAAkB,GAAlBA,KAAkB;IAAA,KAClBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,OAAgB,GAAhBA,OAAgB;EACxB;;EAEH;AACF;AACA;EACEC,YAAYA,CAACC,IAAa,EAAU;IAClC,MAAMC,UAAU,GAAGD,IAAI,GAAG,GAAG,IAAI,CAACL,KAAK,CAACO,QAAQ,CAAC,CAAC,KAAKF,IAAI,EAAE,GAAG,IAAI,CAACL,KAAK,CAACO,QAAQ,CAAC,CAAC;IAErF,OAAO,IAAI,CAACN,UAAU,CAACG,YAAY,CAACE,UAAU,CAAC;EACjD;;EAEA;AACF;AACA;EACEE,SAASA,CAAIC,QAAgB,EAAE;IAC7B,OAAO,IAAI,CAACN,OAAO,CAACO,GAAG,CAAID,QAAQ,CAAC;EACtC;;EAEA;AACF;AACA;EACEE,YAAYA,CAAIN,IAAY,EAAEO,IAAY,EAAE;IAC1C,MAAMC,MAAM,GAAG,IAAI,CAACX,UAAU,CAACY,aAAa,CAAIT,IAAI,EAAEO,IAAI,CAAC;IAC3D,OAAOC,MAAM;EACf;AACF;AAACE,OAAA,CAAAjB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["reduceServiceHandlersFactories","factories","callback","length","Error","result","context","initialVal","shift","reduced","reduce","acc","currFactory","curr"],"sources":["service-handler.ts"],"sourcesContent":["import { ServiceHandlerContext } from './service-handler-context';\n\n/**\n * definition of the service handler.\n */\nexport type ServiceHandlerFactory<T> = (context: ServiceHandlerContext) => ServiceHandler & T;\nexport type AsyncServiceHandlerFactory<T> = (context: ServiceHandlerContext) => Promise<ServiceHandler & T>;\n\nexport interface ServiceHandler {\n /**\n * name of the service. e.g. 'typescript-compiler'\n */\n name?: string;\n /**\n * version of the service. optional.\n */\n version?: () => string;\n\n /**\n * config of the service. e.g. tsconfig.json\n */\n // config?: string;\n}\n\nexport type ReduceFactoryCallback<T> = (acc: T, value: T) => ServiceHandler & T;\nexport function reduceServiceHandlersFactories<T>(\n factories: ServiceHandlerFactory<T>[],\n callback: ReduceFactoryCallback<T>\n): ServiceHandlerFactory<T> {\n if (!factories.length) throw new Error('no factories were provided');\n const result: ServiceHandlerFactory<T> = (context: ServiceHandlerContext) => {\n // @ts-ignore\n const initialVal = factories.shift()(context);\n const reduced: ServiceHandler & T = factories.reduce((acc, currFactory) => {\n const curr = currFactory(context);\n return callback(acc, curr);\n }, initialVal);\n return reduced;\n };\n return result;\n}\n"],"mappings":";;;;;;AAEA;AACA;AACA;;AAqBO,SAASA,8BAA8BA,CAC5CC,SAAqC,EACrCC,QAAkC,EACR;EAC1B,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE,MAAM,IAAIC,KAAK,CAAC,4BAA4B,CAAC;EACpE,MAAMC,MAAgC,GAAIC,OAA8B,IAAK;IAC3E;IACA,MAAMC,UAAU,GAAGN,SAAS,CAACO,KAAK,CAAC,CAAC,CAACF,OAAO,CAAC;IAC7C,MAAMG,OAA2B,GAAGR,SAAS,CAACS,MAAM,CAAC,CAACC,GAAG,EAAEC,WAAW,KAAK;MACzE,MAAMC,IAAI,GAAGD,WAAW,CAACN,OAAO,CAAC;MACjC,OAAOJ,QAAQ,CAACS,GAAG,EAAEE,IAAI,CAAC;IAC5B,CAAC,EAAEN,UAAU,CAAC;IACd,OAAOE,OAAO;EAChB,CAAC;EACD,OAAOJ,MAAM;AACf","ignoreList":[]}
|
1
|
+
{"version":3,"names":["reduceServiceHandlersFactories","factories","callback","length","Error","result","context","initialVal","shift","reduced","reduce","acc","currFactory","curr"],"sources":["service-handler.ts"],"sourcesContent":["import type { ServiceHandlerContext } from './service-handler-context';\n\n/**\n * definition of the service handler.\n */\nexport type ServiceHandlerFactory<T> = (context: ServiceHandlerContext) => ServiceHandler & T;\nexport type AsyncServiceHandlerFactory<T> = (context: ServiceHandlerContext) => Promise<ServiceHandler & T>;\n\nexport interface ServiceHandler {\n /**\n * name of the service. e.g. 'typescript-compiler'\n */\n name?: string;\n /**\n * version of the service. optional.\n */\n version?: () => string;\n\n /**\n * config of the service. e.g. tsconfig.json\n */\n // config?: string;\n}\n\nexport type ReduceFactoryCallback<T> = (acc: T, value: T) => ServiceHandler & T;\nexport function reduceServiceHandlersFactories<T>(\n factories: ServiceHandlerFactory<T>[],\n callback: ReduceFactoryCallback<T>\n): ServiceHandlerFactory<T> {\n if (!factories.length) throw new Error('no factories were provided');\n const result: ServiceHandlerFactory<T> = (context: ServiceHandlerContext) => {\n // @ts-ignore\n const initialVal = factories.shift()(context);\n const reduced: ServiceHandler & T = factories.reduce((acc, currFactory) => {\n const curr = currFactory(context);\n return callback(acc, curr);\n }, initialVal);\n return reduced;\n };\n return result;\n}\n"],"mappings":";;;;;;AAEA;AACA;AACA;;AAqBO,SAASA,8BAA8BA,CAC5CC,SAAqC,EACrCC,QAAkC,EACR;EAC1B,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE,MAAM,IAAIC,KAAK,CAAC,4BAA4B,CAAC;EACpE,MAAMC,MAAgC,GAAIC,OAA8B,IAAK;IAC3E;IACA,MAAMC,UAAU,GAAGN,SAAS,CAACO,KAAK,CAAC,CAAC,CAACF,OAAO,CAAC;IAC7C,MAAMG,OAA2B,GAAGR,SAAS,CAACS,MAAM,CAAC,CAACC,GAAG,EAAEC,WAAW,KAAK;MACzE,MAAMC,IAAI,GAAGD,WAAW,CAACN,OAAO,CAAC;MACjC,OAAOJ,QAAQ,CAACS,GAAG,EAAEE,IAAI,CAAC;IAC5B,CAAC,EAAEN,UAAU,CAAC;IACd,OAAOE,OAAO;EAChB,CAAC;EACD,OAAOJ,MAAM;AACf","ignoreList":[]}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { Component } from '@teambit/component';
|
2
|
-
import { Env } from '../env-interface';
|
3
|
-
import { Environment } from '../environment';
|
4
|
-
import { ServiceHandler } from './service-handler';
|
5
|
-
import { ServiceHandlerContext } from './service-handler-context';
|
1
|
+
import type { Component } from '@teambit/component';
|
2
|
+
import type { Env } from '../env-interface';
|
3
|
+
import type { Environment } from '../environment';
|
4
|
+
import type { ServiceHandler } from './service-handler';
|
5
|
+
import type { ServiceHandlerContext } from './service-handler-context';
|
6
6
|
export type EnvContext = {
|
7
7
|
components: Component[];
|
8
8
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["service.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { Env } from '../env-interface';\nimport { Environment } from '../environment';\nimport { ServiceHandler } from './service-handler';\nimport { ServiceHandlerContext } from './service-handler-context';\n\nexport type EnvContext = {\n components: Component[];\n};\n\nexport interface ServiceExecutionResult {\n errors?: Error[];\n}\n\nexport type ServiceTransformHandlerFactory<T> = (\n handlerContext?: any\n) => (ServiceHandler & T) | Promise<ServiceHandler & T>;\n\n/**\n * definition of the service handler type\n * This used to define new types of handlers like\n * Compiler, Tester, Preview, etc.\n */\nexport type TransformationMap = {\n /**\n * The name of the function that will be called on the service run/run once later.\n * This func will be exist on the final env object\n */\n [funcName: string]: ServiceTransformHandlerFactory<any>;\n};\n\n/**\n * services allows to reuse and standardize services for development environments.\n * examples for services can be: `linting`, `compilation`, `build`, and others which offer\n * standard services to environments such as `react`, `angular` and `vue` and different compositions of each for\n * more concrete needs.\n *\n * `TData` - type of data returned by the service handler.\n * `TOpts` is the type of options passed to the environment through execution.\n * `TExecResponse` is the execution result of the service.\n */\nexport interface Service<TExecResponse extends ServiceExecutionResult, TData = {}, TOpts = {}> {\n /**\n * name of the service. (e.g. `compile`, `test`, etc.)\n */\n name?: string;\n\n /**\n * description of the env.\n */\n description?: string;\n\n /**\n * create a string to describe to service in the env cli.\n */\n render?(env: Environment, context: EnvContext[]): string | Promise<string>;\n\n /**\n * get service data from an environment.\n */\n getDescriptor?(environment: Environment, context?: EnvContext[]): TData | undefined | Promise<TData | undefined>;\n\n /**\n * executes a service on a subset of components.\n */\n run?(context: EnvContext, options?: TOpts): Promise<TExecResponse>;\n\n /**\n * run the service only once.\n */\n runOnce?(context: EnvContext[], options?: TOpts): Promise<any>;\n\n /**\n * Return a map of functions that will be called on the service run/run once later.\n * @param env the original env plugin object\n * @param context ServiceHandlerContext(EnvContext)\n */\n transform?(env: Env, context: ServiceHandlerContext): TransformationMap | undefined;\n}\n"],"mappings":"","ignoreList":[]}
|
1
|
+
{"version":3,"names":[],"sources":["service.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport type { Env } from '../env-interface';\nimport type { Environment } from '../environment';\nimport type { ServiceHandler } from './service-handler';\nimport type { ServiceHandlerContext } from './service-handler-context';\n\nexport type EnvContext = {\n components: Component[];\n};\n\nexport interface ServiceExecutionResult {\n errors?: Error[];\n}\n\nexport type ServiceTransformHandlerFactory<T> = (\n handlerContext?: any\n) => (ServiceHandler & T) | Promise<ServiceHandler & T>;\n\n/**\n * definition of the service handler type\n * This used to define new types of handlers like\n * Compiler, Tester, Preview, etc.\n */\nexport type TransformationMap = {\n /**\n * The name of the function that will be called on the service run/run once later.\n * This func will be exist on the final env object\n */\n [funcName: string]: ServiceTransformHandlerFactory<any>;\n};\n\n/**\n * services allows to reuse and standardize services for development environments.\n * examples for services can be: `linting`, `compilation`, `build`, and others which offer\n * standard services to environments such as `react`, `angular` and `vue` and different compositions of each for\n * more concrete needs.\n *\n * `TData` - type of data returned by the service handler.\n * `TOpts` is the type of options passed to the environment through execution.\n * `TExecResponse` is the execution result of the service.\n */\nexport interface Service<TExecResponse extends ServiceExecutionResult, TData = {}, TOpts = {}> {\n /**\n * name of the service. (e.g. `compile`, `test`, etc.)\n */\n name?: string;\n\n /**\n * description of the env.\n */\n description?: string;\n\n /**\n * create a string to describe to service in the env cli.\n */\n render?(env: Environment, context: EnvContext[]): string | Promise<string>;\n\n /**\n * get service data from an environment.\n */\n getDescriptor?(environment: Environment, context?: EnvContext[]): TData | undefined | Promise<TData | undefined>;\n\n /**\n * executes a service on a subset of components.\n */\n run?(context: EnvContext, options?: TOpts): Promise<TExecResponse>;\n\n /**\n * run the service only once.\n */\n runOnce?(context: EnvContext[], options?: TOpts): Promise<any>;\n\n /**\n * Return a map of functions that will be called on the service run/run once later.\n * @param env the original env plugin object\n * @param context ServiceHandlerContext(EnvContext)\n */\n transform?(env: Env, context: ServiceHandlerContext): TransformationMap | undefined;\n}\n"],"mappings":"","ignoreList":[]}
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/envs",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.668",
|
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.
|
9
|
+
"version": "1.0.668"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"comment-json": "4.2.5",
|
@@ -19,32 +19,32 @@
|
|
19
19
|
"@teambit/bit-error": "0.0.404",
|
20
20
|
"@teambit/component-id": "1.2.4",
|
21
21
|
"@teambit/component-issues": "0.0.160",
|
22
|
-
"@teambit/component.sources": "0.0.109",
|
23
|
-
"@teambit/legacy.consumer-component": "0.0.58",
|
24
|
-
"@teambit/legacy.extension-data": "0.0.59",
|
25
22
|
"@teambit/toolbox.array.duplications-finder": "0.0.3",
|
26
23
|
"@teambit/cli-table": "0.0.50",
|
27
|
-
"@teambit/dependency-resolver": "1.0.
|
28
|
-
"@teambit/component": "1.0.
|
29
|
-
"@teambit/aspect-loader": "1.0.
|
30
|
-
"@teambit/cli": "0.0.
|
31
|
-
"@teambit/logger": "0.0.
|
32
|
-
"@teambit/worker": "0.0.
|
33
|
-
"@teambit/builder": "1.0.
|
34
|
-
"@teambit/bundler": "1.0.
|
35
|
-
"@teambit/compiler": "1.0.
|
36
|
-
"@teambit/formatter": "1.0.
|
37
|
-
"@teambit/isolator": "1.0.
|
38
|
-
"@teambit/linter": "1.0.
|
39
|
-
"@teambit/pkg": "1.0.
|
40
|
-
"@teambit/preview": "1.0.
|
41
|
-
"@teambit/schema": "1.0.
|
42
|
-
"@teambit/tester": "1.0.
|
43
|
-
"@teambit/typescript": "1.0.
|
44
|
-
"@teambit/webpack": "1.0.
|
45
|
-
"@teambit/graphql": "1.0.
|
46
|
-
"@teambit/
|
47
|
-
"@teambit/
|
24
|
+
"@teambit/dependency-resolver": "1.0.668",
|
25
|
+
"@teambit/component": "1.0.668",
|
26
|
+
"@teambit/aspect-loader": "1.0.668",
|
27
|
+
"@teambit/cli": "0.0.1245",
|
28
|
+
"@teambit/logger": "0.0.1338",
|
29
|
+
"@teambit/worker": "0.0.1549",
|
30
|
+
"@teambit/builder": "1.0.668",
|
31
|
+
"@teambit/bundler": "1.0.668",
|
32
|
+
"@teambit/compiler": "1.0.668",
|
33
|
+
"@teambit/formatter": "1.0.668",
|
34
|
+
"@teambit/isolator": "1.0.668",
|
35
|
+
"@teambit/linter": "1.0.668",
|
36
|
+
"@teambit/pkg": "1.0.668",
|
37
|
+
"@teambit/preview": "1.0.668",
|
38
|
+
"@teambit/schema": "1.0.668",
|
39
|
+
"@teambit/tester": "1.0.668",
|
40
|
+
"@teambit/typescript": "1.0.668",
|
41
|
+
"@teambit/webpack": "1.0.668",
|
42
|
+
"@teambit/graphql": "1.0.668",
|
43
|
+
"@teambit/component.sources": "0.0.110",
|
44
|
+
"@teambit/dev-files": "1.0.668",
|
45
|
+
"@teambit/issues": "1.0.668",
|
46
|
+
"@teambit/legacy.consumer-component": "0.0.59",
|
47
|
+
"@teambit/legacy.extension-data": "0.0.60"
|
48
48
|
},
|
49
49
|
"devDependencies": {
|
50
50
|
"@types/lodash": "4.14.165",
|
package/runtime/env-runtime.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { AspectDefinition } from '@teambit/aspect-loader';
|
2
|
-
import { Component } from '@teambit/component';
|
1
|
+
import type { AspectDefinition } from '@teambit/aspect-loader';
|
2
|
+
import type { Component } from '@teambit/component';
|
3
3
|
|
4
|
-
import { Environment } from '../environment';
|
4
|
+
import type { Environment } from '../environment';
|
5
5
|
|
6
6
|
/**
|
7
7
|
* env runtime is an instance which represent the given env in a
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { flatten } from 'lodash';
|
2
2
|
|
3
|
-
import { ServiceExecutionResult } from '../services';
|
4
|
-
import { EnvResult } from './runtime';
|
3
|
+
import type { ServiceExecutionResult } from '../services';
|
4
|
+
import type { EnvResult } from './runtime';
|
5
5
|
|
6
6
|
export class EnvsExecutionResult<T extends ServiceExecutionResult> {
|
7
7
|
constructor(readonly results: EnvResult<T>[]) {}
|
package/runtime/runtime.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import { Logger } from '@teambit/logger';
|
1
|
+
import type { Logger } from '@teambit/logger';
|
2
2
|
import { ComponentID } from '@teambit/component';
|
3
3
|
import mapSeries from 'p-map-series';
|
4
4
|
import { EnvNotFoundInRuntime } from '../exceptions';
|
5
5
|
import { ExecutionContext } from '../context';
|
6
|
-
import { EnvService, ServiceExecutionResult } from '../services';
|
7
|
-
import { EnvRuntime } from './env-runtime';
|
6
|
+
import type { EnvService, ServiceExecutionResult } from '../services';
|
7
|
+
import type { EnvRuntime } from './env-runtime';
|
8
8
|
import { EnvsExecutionResult } from './envs-execution-result';
|
9
9
|
|
10
10
|
export interface EnvResult<T extends ServiceExecutionResult> {
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { ComponentID } from '@teambit/component';
|
2
|
-
import { Harmony } from '@teambit/harmony';
|
3
|
-
import { Logger, LoggerMain } from '@teambit/logger';
|
4
|
-
import { WorkerMain } from '@teambit/worker';
|
1
|
+
import type { ComponentID } from '@teambit/component';
|
2
|
+
import type { Harmony } from '@teambit/harmony';
|
3
|
+
import type { Logger, LoggerMain } from '@teambit/logger';
|
4
|
+
import type { WorkerMain } from '@teambit/worker';
|
5
5
|
|
6
6
|
export class ServiceHandlerContext {
|
7
7
|
constructor(
|
package/services/service.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import { Component } from '@teambit/component';
|
2
|
-
import { Env } from '../env-interface';
|
3
|
-
import { Environment } from '../environment';
|
4
|
-
import { ServiceHandler } from './service-handler';
|
5
|
-
import { ServiceHandlerContext } from './service-handler-context';
|
1
|
+
import type { Component } from '@teambit/component';
|
2
|
+
import type { Env } from '../env-interface';
|
3
|
+
import type { Environment } from '../environment';
|
4
|
+
import type { ServiceHandler } from './service-handler';
|
5
|
+
import type { ServiceHandlerContext } from './service-handler-context';
|
6
6
|
|
7
7
|
export type EnvContext = {
|
8
8
|
components: Component[];
|