@teambit/envs 0.0.0-3e44e878fae3f5f31fce2dc240a57a798e67137e

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.
Files changed (108) hide show
  1. package/context/context.ts +55 -0
  2. package/context/index.ts +1 -0
  3. package/dist/context/context.d.ts +44 -0
  4. package/dist/context/context.js +61 -0
  5. package/dist/context/context.js.map +1 -0
  6. package/dist/context/index.d.ts +1 -0
  7. package/dist/context/index.js +20 -0
  8. package/dist/context/index.js.map +1 -0
  9. package/dist/env-definition.d.ts +41 -0
  10. package/dist/env-definition.js +57 -0
  11. package/dist/env-definition.js.map +1 -0
  12. package/dist/env-interface.d.ts +4 -0
  13. package/dist/env-interface.js +3 -0
  14. package/dist/env-interface.js.map +1 -0
  15. package/dist/env-jsonc.detector.d.ts +5 -0
  16. package/dist/env-jsonc.detector.js +26 -0
  17. package/dist/env-jsonc.detector.js.map +1 -0
  18. package/dist/env-service-list.d.ts +35 -0
  19. package/dist/env-service-list.js +37 -0
  20. package/dist/env-service-list.js.map +1 -0
  21. package/dist/env.composition.d.ts +1 -0
  22. package/dist/env.composition.js +29 -0
  23. package/dist/env.composition.js.map +1 -0
  24. package/dist/env.fragment.d.ts +17 -0
  25. package/dist/env.fragment.js +48 -0
  26. package/dist/env.fragment.js.map +1 -0
  27. package/dist/env.plugin.d.ts +20 -0
  28. package/dist/env.plugin.js +92 -0
  29. package/dist/env.plugin.js.map +1 -0
  30. package/dist/environment.d.ts +201 -0
  31. package/dist/environment.js +17 -0
  32. package/dist/environment.js.map +1 -0
  33. package/dist/environments.aspect.d.ts +2 -0
  34. package/dist/environments.aspect.js +18 -0
  35. package/dist/environments.aspect.js.map +1 -0
  36. package/dist/environments.graphql.d.ts +3 -0
  37. package/dist/environments.graphql.js +36 -0
  38. package/dist/environments.graphql.js.map +1 -0
  39. package/dist/environments.main.runtime.d.ts +366 -0
  40. package/dist/environments.main.runtime.js +1160 -0
  41. package/dist/environments.main.runtime.js.map +1 -0
  42. package/dist/envs.cmd.d.ts +51 -0
  43. package/dist/envs.cmd.js +153 -0
  44. package/dist/envs.cmd.js.map +1 -0
  45. package/dist/envs.docs.mdx +8 -0
  46. package/dist/esm.mjs +13 -0
  47. package/dist/exceptions/env-not-configured-for-component.d.ts +4 -0
  48. package/dist/exceptions/env-not-configured-for-component.js +24 -0
  49. package/dist/exceptions/env-not-configured-for-component.js.map +1 -0
  50. package/dist/exceptions/env-not-found-in-runtime.d.ts +5 -0
  51. package/dist/exceptions/env-not-found-in-runtime.js +22 -0
  52. package/dist/exceptions/env-not-found-in-runtime.js.map +1 -0
  53. package/dist/exceptions/env-not-found.d.ts +6 -0
  54. package/dist/exceptions/env-not-found.js +27 -0
  55. package/dist/exceptions/env-not-found.js.map +1 -0
  56. package/dist/exceptions/index.d.ts +3 -0
  57. package/dist/exceptions/index.js +46 -0
  58. package/dist/exceptions/index.js.map +1 -0
  59. package/dist/index.d.ts +16 -0
  60. package/dist/index.js +128 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/preview-1752254355761.js +7 -0
  63. package/dist/runtime/env-runtime.d.ts +41 -0
  64. package/dist/runtime/env-runtime.js +36 -0
  65. package/dist/runtime/env-runtime.js.map +1 -0
  66. package/dist/runtime/envs-execution-result.d.ts +18 -0
  67. package/dist/runtime/envs-execution-result.js +56 -0
  68. package/dist/runtime/envs-execution-result.js.map +1 -0
  69. package/dist/runtime/index.d.ts +2 -0
  70. package/dist/runtime/index.js +33 -0
  71. package/dist/runtime/index.js.map +1 -0
  72. package/dist/runtime/runtime.d.ts +49 -0
  73. package/dist/runtime/runtime.js +117 -0
  74. package/dist/runtime/runtime.js.map +1 -0
  75. package/dist/services/concrete-service.d.ts +8 -0
  76. package/dist/services/concrete-service.js +3 -0
  77. package/dist/services/concrete-service.js.map +1 -0
  78. package/dist/services/index.d.ts +4 -0
  79. package/dist/services/index.js +89 -0
  80. package/dist/services/index.js.map +1 -0
  81. package/dist/services/service-handler-context.d.ts +30 -0
  82. package/dist/services/service-handler-context.js +44 -0
  83. package/dist/services/service-handler-context.js.map +1 -0
  84. package/dist/services/service-handler.d.ts +18 -0
  85. package/dist/services/service-handler.js +25 -0
  86. package/dist/services/service-handler.js.map +1 -0
  87. package/dist/services/service.d.ts +66 -0
  88. package/dist/services/service.js +3 -0
  89. package/dist/services/service.js.map +1 -0
  90. package/env.composition.tsx +7 -0
  91. package/envs.docs.mdx +8 -0
  92. package/esm.mjs +13 -0
  93. package/exceptions/env-not-configured-for-component.ts +10 -0
  94. package/exceptions/env-not-found-in-runtime.ts +7 -0
  95. package/exceptions/env-not-found.ts +15 -0
  96. package/exceptions/index.ts +3 -0
  97. package/package.json +90 -0
  98. package/runtime/env-runtime.ts +31 -0
  99. package/runtime/envs-execution-result.ts +46 -0
  100. package/runtime/index.ts +2 -0
  101. package/runtime/runtime.ts +100 -0
  102. package/services/concrete-service.ts +8 -0
  103. package/services/index.ts +13 -0
  104. package/services/service-handler-context.ts +40 -0
  105. package/services/service-handler.ts +41 -0
  106. package/services/service.ts +79 -0
  107. package/types/asset.d.ts +41 -0
  108. package/types/style.d.ts +42 -0
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EnvPlugin = void 0;
7
+ function _component() {
8
+ const data = require("@teambit/component");
9
+ _component = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _cli() {
15
+ const data = require("@teambit/cli");
16
+ _cli = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _lodash() {
22
+ const data = require("lodash");
23
+ _lodash = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _serviceHandlerContext() {
29
+ const data = require("./services/service-handler-context");
30
+ _serviceHandlerContext = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
36
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
37
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
38
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
39
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
40
+ class EnvPlugin {
41
+ constructor(envSlot, servicesRegistry, loggerMain, workerMain, harmony) {
42
+ this.envSlot = envSlot;
43
+ this.servicesRegistry = servicesRegistry;
44
+ this.loggerMain = loggerMain;
45
+ this.workerMain = workerMain;
46
+ this.harmony = harmony;
47
+ _defineProperty(this, "pattern", '*.bit-env.*');
48
+ _defineProperty(this, "runtimes", [_cli().MainRuntime.name]);
49
+ }
50
+ createContext(envId) {
51
+ return new (_serviceHandlerContext().ServiceHandlerContext)(envId, this.loggerMain, this.workerMain, this.harmony);
52
+ }
53
+ transformToLegacyEnv(envId, env) {
54
+ const envComponentId = _component().ComponentID.fromString(envId);
55
+ const envContext = this.createContext(envComponentId);
56
+ const allServices = (0, _lodash().flatten)(this.servicesRegistry.values());
57
+ const transformers = allServices.reduce((acc, service) => {
58
+ if (!service.transform) return acc;
59
+ const currTransformer = service.transform(env, envContext);
60
+ if (!currTransformer) return acc;
61
+ return _objectSpread(_objectSpread({}, acc), currTransformer);
62
+ }, {});
63
+ return _objectSpread(_objectSpread({}, transformers), {}, {
64
+ name: env.name,
65
+ icon: env.icon,
66
+ __path: env.__path,
67
+ __resolvedPath: env.__resolvedPath,
68
+ __getDescriptor: async () => {
69
+ return {
70
+ type: env.type || env.name
71
+ };
72
+ },
73
+ id: envId
74
+ });
75
+ }
76
+ register(object, aspect) {
77
+ const env = this.transformToLegacyEnv(aspect.id, object);
78
+ // This is required when we call it manually and the aspect id fn return the wrong
79
+ // id
80
+ // We call the set directly because when we call it manually during install
81
+ // the aspect id fn return the wrong id
82
+ // Please do not change this without consulting @GiladShoham
83
+ // This manual call from install is required to make sure we re-load the envs
84
+ // when they move to another location in the node_modules
85
+ // during process is still running (like during bit new, bit switch, bit server)
86
+ this.envSlot.map.set(aspect.id, env);
87
+ return;
88
+ }
89
+ }
90
+ exports.EnvPlugin = EnvPlugin;
91
+
92
+ //# sourceMappingURL=env.plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_component","data","require","_cli","_lodash","_serviceHandlerContext","ownKeys","e","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","EnvPlugin","constructor","envSlot","servicesRegistry","loggerMain","workerMain","harmony","MainRuntime","name","createContext","envId","EnvContext","transformToLegacyEnv","env","envComponentId","ComponentID","fromString","envContext","allServices","flatten","values","transformers","reduce","acc","service","transform","currTransformer","icon","__path","__resolvedPath","__getDescriptor","type","id","register","object","aspect","map","set","exports"],"sources":["env.plugin.ts"],"sourcesContent":["import { PluginDefinition } from '@teambit/aspect-loader';\nimport { Harmony } from '@teambit/harmony';\nimport { ComponentID } from '@teambit/component';\nimport { WorkerMain } from '@teambit/worker';\nimport { MainRuntime } from '@teambit/cli';\nimport { LoggerMain } from '@teambit/logger';\nimport { flatten } from 'lodash';\nimport { ServiceHandlerContext as EnvContext } from './services/service-handler-context';\nimport { Env } from './env-interface';\nimport { EnvsRegistry, ServicesRegistry } from './environments.main.runtime';\n\nexport class EnvPlugin implements PluginDefinition {\n constructor(\n private envSlot: EnvsRegistry,\n private servicesRegistry: ServicesRegistry,\n private loggerMain: LoggerMain,\n private workerMain: WorkerMain,\n private harmony: Harmony\n ) {}\n\n pattern = '*.bit-env.*';\n\n runtimes = [MainRuntime.name];\n\n private createContext(envId: ComponentID) {\n return new EnvContext(envId, this.loggerMain, this.workerMain, this.harmony);\n }\n\n private transformToLegacyEnv(envId: string, env: Env) {\n const envComponentId = ComponentID.fromString(envId);\n const envContext = this.createContext(envComponentId);\n const allServices = flatten(this.servicesRegistry.values());\n const transformers = allServices.reduce((acc, service) => {\n if (!service.transform) return acc;\n const currTransformer = service.transform(env, envContext);\n if (!currTransformer) return acc;\n return { ...acc, ...currTransformer };\n }, {});\n\n return {\n ...transformers,\n name: env.name,\n icon: env.icon,\n __path: env.__path,\n __resolvedPath: env.__resolvedPath,\n __getDescriptor: async () => {\n return {\n type: env.type || env.name,\n };\n },\n id: envId,\n };\n }\n\n register(object: any, aspect: { id: string }) {\n const env = this.transformToLegacyEnv(aspect.id, object);\n // This is required when we call it manually and the aspect id fn return the wrong\n // id\n // We call the set directly because when we call it manually during install\n // the aspect id fn return the wrong id\n // Please do not change this without consulting @GiladShoham\n // This manual call from install is required to make sure we re-load the envs\n // when they move to another location in the node_modules\n // during process is still running (like during bit new, bit switch, bit server)\n this.envSlot.map.set(aspect.id, env);\n return;\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,KAAA;EAAA,MAAAF,IAA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,GAAG,GAAG,IAAI,CAACD,oBAAoB,CAACuB,MAAM,CAACH,EAAE,EAAEE,MAAM,CAAC;IACxD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,CAAChC,OAAO,CAACkC,GAAG,CAACC,GAAG,CAACF,MAAM,CAACH,EAAE,EAAEnB,GAAG,CAAC;IACpC;EACF;AACF;AAACyB,OAAA,CAAAtC,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -0,0 +1,201 @@
1
+ import type { Linter, LinterContext } from '@teambit/linter';
2
+ import type { Formatter, FormatterContext } from '@teambit/formatter';
3
+ import type { Tester } from '@teambit/tester';
4
+ import type { Compiler } from '@teambit/compiler';
5
+ import type { Bundler, BundlerContext, DevServer, DevServerContext } from '@teambit/bundler';
6
+ import type { BuildTask } from '@teambit/builder';
7
+ import type { SchemaExtractor } from '@teambit/schema';
8
+ import type { WebpackConfigTransformer } from '@teambit/webpack';
9
+ import type { ModifyPackageJsonFunc, PackageJsonProps } from '@teambit/pkg';
10
+ import type { DependencyDetector, EnvPolicyConfigObject } from '@teambit/dependency-resolver';
11
+ import type { Capsule } from '@teambit/isolator';
12
+ import type { Component } from '@teambit/component';
13
+ import { EnvPreviewConfig } from '@teambit/preview';
14
+ import { SchemaNodeTransformer, SchemaTransformer } from '@teambit/typescript';
15
+ export type EnvDescriptor = {
16
+ type: string;
17
+ };
18
+ /**
19
+ * add a custom type and include all properties from within the environment.
20
+ */
21
+ export interface Environment {
22
+ /**
23
+ * name of the environment.
24
+ */
25
+ name?: string;
26
+ /**
27
+ * description of the environment.
28
+ */
29
+ description?: string;
30
+ /**
31
+ * icon of the environment.
32
+ */
33
+ icon?: string;
34
+ [key: string]: any;
35
+ /**
36
+ * Returns the Environment descriptor
37
+ * Required for any task
38
+ */
39
+ __getDescriptor?: () => Promise<EnvDescriptor>;
40
+ /**
41
+ * Returns a schema generator instance
42
+ */
43
+ getSchemaExtractor?: (config?: any, tsserverPath?: string, contextPath?: string, schemaTransformers?: SchemaTransformer[], apiTransformers?: SchemaNodeTransformer[]) => SchemaExtractor;
44
+ /**
45
+ * Returns the dev patterns to match doc files
46
+ */
47
+ getDocsDevPatterns?: (component: Component) => string[];
48
+ /**
49
+ * Returns the dev patterns to match composition files
50
+ */
51
+ getCompositionsDevPatterns?: (component: Component) => string[];
52
+ /**
53
+ * Returns additional dev patterns for the component.
54
+ * Patterns that were provided by getDocsDevPatterns, getTestsDevPatterns will be considered as dev files as well, without need to add them here.
55
+ */
56
+ getDevPatterns?: (component: Component) => string[];
57
+ }
58
+ export interface DependenciesEnv extends Environment {
59
+ /**
60
+ * Returns the list of dependencies
61
+ * Required for any task
62
+ */
63
+ getDependencies?: () => EnvPolicyConfigObject | Promise<EnvPolicyConfigObject>;
64
+ /**
65
+ * Returns a list of additional test host dependencies
66
+ * this will be added to the tester context
67
+ * This can be used in cases when you want specific dependencies to be resolved from the env during testing
68
+ * but you don't want these dependencies as peer dependencies of the component (as they are not used during runtime)
69
+ * An example for this is @angular/compiler, which during running tests you want to resolve from the env, but you don't
70
+ * need it during component runtime.
71
+ */
72
+ getAdditionalTestHostDependencies?: () => string[] | Promise<string[]>;
73
+ /**
74
+ * Returns a list of additional host dependencies
75
+ * this list will be provided as globals on the window after bit preview bundle
76
+ * by default bit will merge this list with the peers from the getDependencies function
77
+ */
78
+ getAdditionalHostDependencies?: () => string[] | Promise<string[]>;
79
+ /**
80
+ * Returns a list of dependency detectors
81
+ * this list will be used to detect all the dependencies in each file of the component
82
+ */
83
+ getDepDetectors?: () => DependencyDetector[] | null;
84
+ }
85
+ export type GetNpmIgnoreContext = {
86
+ capsule: Capsule;
87
+ component: Component;
88
+ };
89
+ export interface PackageEnv extends Environment {
90
+ /**
91
+ * define the package json properties to add to each component.
92
+ * Used by `bit link` to augment package.json with new properties
93
+ */
94
+ getPackageJsonProps?: () => PackageJsonProps;
95
+ /**
96
+ * return `.npmignore` entries to be written before packing the component
97
+ */
98
+ getNpmIgnore?: (npmIgnoreContext?: GetNpmIgnoreContext) => string[];
99
+ /**
100
+ * in case the static "getPackageJsonProps" is not enough, and the package.json props need to be modified
101
+ * per component, use this function.
102
+ */
103
+ modifyPackageJson?: ModifyPackageJsonFunc;
104
+ }
105
+ export interface LinterEnv extends Environment {
106
+ /**
107
+ * Returns & configures the linter to use (ESLint, ...)
108
+ * Required for `bit lint`
109
+ */
110
+ getLinter?: (context: LinterContext, transformers: any[]) => Linter;
111
+ }
112
+ export interface FormatterEnv extends Environment {
113
+ /**
114
+ * Returns & configures the formatter to use (prettier, ...)
115
+ * Required for `bit format`
116
+ */
117
+ getFormatter?: (context: FormatterContext, transformers: any[]) => Formatter;
118
+ }
119
+ export interface PreviewEnv extends Environment {
120
+ /**
121
+ * Returns a paths to a function which mounts a given component to DOM
122
+ * Required for `bit start` & `bit build`
123
+ */
124
+ getMounter?: () => string;
125
+ /**
126
+ * Returns a path to a docs template.
127
+ * Required for `bit start` & `bit build`
128
+ */
129
+ getDocsTemplate?: () => string;
130
+ /**
131
+ * Returns a bundler for the preview.
132
+ * Required for `bit build` & `bit start`
133
+ */
134
+ getBundler?: (context: BundlerContext, transformers: any[]) => Promise<Bundler>;
135
+ /**
136
+ * Returns preview config like the strategy name to use when bundling the components for the preview
137
+ */
138
+ getPreviewConfig?: () => EnvPreviewConfig;
139
+ /**
140
+ * Returns a bundler for the env template.
141
+ * this bundler will be used to bundle the docs/compositions (or other preview) apps
142
+ * Required for `bit build` & `bit tag`
143
+ */
144
+ getTemplateBundler?: (context: BundlerContext, transformers?: any[]) => Promise<Bundler>;
145
+ }
146
+ export type PipeServiceModifiersMap = Record<string, PipeServiceModifier>;
147
+ export interface PipeServiceModifier {
148
+ transformers?: Function[];
149
+ module?: any;
150
+ }
151
+ export interface BuilderEnv extends PreviewEnv {
152
+ /**
153
+ * @deprecated Fatal: a breaking API was introduced. Use getBuildPipe() instead.
154
+ */
155
+ getPipe?: () => BuildTask[];
156
+ /**
157
+ * Returns the component build pipeline
158
+ * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`
159
+ */
160
+ getBuildPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];
161
+ /**
162
+ * Returns the component tag pipeline
163
+ * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`
164
+ */
165
+ getTagPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];
166
+ /**
167
+ * Returns the component snap pipeline
168
+ * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`
169
+ */
170
+ getSnapPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];
171
+ }
172
+ export interface TesterEnv extends Environment {
173
+ /**
174
+ * Returns a tester
175
+ * Required for `bit start` & `bit test`
176
+ */
177
+ getTester?: (path: string, tester: any) => Tester;
178
+ /**
179
+ * Returns the dev patterns to match test files
180
+ */
181
+ getTestsDevPatterns?: (component: Component) => string[];
182
+ }
183
+ export interface CompilerEnv {
184
+ /**
185
+ * Returns a compiler
186
+ * Required for making and reading dists, especially for `bit compile`
187
+ */
188
+ getCompiler: () => Compiler;
189
+ }
190
+ export declare function hasCompiler(obj: Environment): obj is CompilerEnv;
191
+ export interface DevEnv extends PreviewEnv {
192
+ /**
193
+ * Required for `bit start`
194
+ */
195
+ getDevEnvId?: (context?: any) => string;
196
+ /**
197
+ * Returns and configures the dev server
198
+ * Required for `bit start`
199
+ */
200
+ getDevServer?: (context: DevServerContext, transformers: WebpackConfigTransformer[]) => DevServer | Promise<DevServer>;
201
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasCompiler = hasCompiler;
7
+ // TODO: @gilad refactor to an abstract env.
8
+
9
+ /**
10
+ * add a custom type and include all properties from within the environment.
11
+ */
12
+
13
+ function hasCompiler(obj) {
14
+ return typeof obj.getCompiler === 'function';
15
+ }
16
+
17
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hasCompiler","obj","getCompiler"],"sources":["environment.ts"],"sourcesContent":["// TODO: @gilad refactor to an abstract env.\nimport type { Linter, LinterContext } from '@teambit/linter';\nimport type { Formatter, FormatterContext } from '@teambit/formatter';\nimport type { Tester } from '@teambit/tester';\nimport type { Compiler } from '@teambit/compiler';\nimport type { Bundler, BundlerContext, DevServer, DevServerContext } from '@teambit/bundler';\nimport type { BuildTask } from '@teambit/builder';\nimport type { SchemaExtractor } from '@teambit/schema';\nimport type { WebpackConfigTransformer } from '@teambit/webpack';\nimport type { ModifyPackageJsonFunc, PackageJsonProps } from '@teambit/pkg';\nimport type { DependencyDetector, EnvPolicyConfigObject } from '@teambit/dependency-resolver';\nimport type { Capsule } from '@teambit/isolator';\nimport type { Component } from '@teambit/component';\nimport { EnvPreviewConfig } from '@teambit/preview';\nimport { SchemaNodeTransformer, SchemaTransformer } from '@teambit/typescript';\n\nexport type EnvDescriptor = {\n type: string;\n};\n\n/**\n * add a custom type and include all properties from within the environment.\n */\nexport interface Environment {\n /**\n * name of the environment.\n */\n name?: string;\n\n /**\n * description of the environment.\n */\n description?: string;\n\n /**\n * icon of the environment.\n */\n icon?: string;\n\n [key: string]: any; // :TODO need to define an abstract type for service handlers (now using any)\n\n /**\n * Returns the Environment descriptor\n * Required for any task\n */\n __getDescriptor?: () => Promise<EnvDescriptor>;\n\n /**\n * Returns a schema generator instance\n */\n getSchemaExtractor?: (\n config?: any,\n tsserverPath?: string,\n contextPath?: string,\n schemaTransformers?: SchemaTransformer[],\n apiTransformers?: SchemaNodeTransformer[]\n ) => SchemaExtractor;\n\n /**\n * Returns the dev patterns to match doc files\n */\n getDocsDevPatterns?: (component: Component) => string[];\n\n /**\n * Returns the dev patterns to match composition files\n */\n getCompositionsDevPatterns?: (component: Component) => string[];\n\n /**\n * Returns additional dev patterns for the component.\n * Patterns that were provided by getDocsDevPatterns, getTestsDevPatterns will be considered as dev files as well, without need to add them here.\n */\n getDevPatterns?: (component: Component) => string[];\n}\n\nexport interface DependenciesEnv extends Environment {\n /**\n * Returns the list of dependencies\n * Required for any task\n */\n getDependencies?: () => EnvPolicyConfigObject | Promise<EnvPolicyConfigObject>;\n\n /**\n * Returns a list of additional test host dependencies\n * this will be added to the tester context\n * This can be used in cases when you want specific dependencies to be resolved from the env during testing\n * but you don't want these dependencies as peer dependencies of the component (as they are not used during runtime)\n * An example for this is @angular/compiler, which during running tests you want to resolve from the env, but you don't\n * need it during component runtime.\n */\n getAdditionalTestHostDependencies?: () => string[] | Promise<string[]>;\n\n /**\n * Returns a list of additional host dependencies\n * this list will be provided as globals on the window after bit preview bundle\n * by default bit will merge this list with the peers from the getDependencies function\n */\n getAdditionalHostDependencies?: () => string[] | Promise<string[]>;\n\n /**\n * Returns a list of dependency detectors\n * this list will be used to detect all the dependencies in each file of the component\n */\n getDepDetectors?: () => DependencyDetector[] | null;\n}\n\nexport type GetNpmIgnoreContext = {\n capsule: Capsule;\n component: Component;\n};\nexport interface PackageEnv extends Environment {\n /**\n * define the package json properties to add to each component.\n * Used by `bit link` to augment package.json with new properties\n */\n getPackageJsonProps?: () => PackageJsonProps;\n\n /**\n * return `.npmignore` entries to be written before packing the component\n */\n getNpmIgnore?: (npmIgnoreContext?: GetNpmIgnoreContext) => string[];\n\n /**\n * in case the static \"getPackageJsonProps\" is not enough, and the package.json props need to be modified\n * per component, use this function.\n */\n modifyPackageJson?: ModifyPackageJsonFunc;\n}\n\nexport interface LinterEnv extends Environment {\n /**\n * Returns & configures the linter to use (ESLint, ...)\n * Required for `bit lint`\n */\n getLinter?: (context: LinterContext, transformers: any[]) => Linter;\n}\n\nexport interface FormatterEnv extends Environment {\n /**\n * Returns & configures the formatter to use (prettier, ...)\n * Required for `bit format`\n */\n getFormatter?: (context: FormatterContext, transformers: any[]) => Formatter;\n}\n\nexport interface PreviewEnv extends Environment {\n /**\n * Returns a paths to a function which mounts a given component to DOM\n * Required for `bit start` & `bit build`\n */\n getMounter?: () => string;\n\n /**\n * Returns a path to a docs template.\n * Required for `bit start` & `bit build`\n */\n getDocsTemplate?: () => string;\n\n /**\n * Returns a bundler for the preview.\n * Required for `bit build` & `bit start`\n */\n getBundler?: (context: BundlerContext, transformers: any[]) => Promise<Bundler>;\n\n /**\n * Returns preview config like the strategy name to use when bundling the components for the preview\n */\n getPreviewConfig?: () => EnvPreviewConfig;\n\n /**\n * Returns a bundler for the env template.\n * this bundler will be used to bundle the docs/compositions (or other preview) apps\n * Required for `bit build` & `bit tag`\n */\n getTemplateBundler?: (context: BundlerContext, transformers?: any[]) => Promise<Bundler>;\n}\n\nexport type PipeServiceModifiersMap = Record<string, PipeServiceModifier>;\n\nexport interface PipeServiceModifier {\n transformers?: Function[];\n module?: any;\n}\n\nexport interface BuilderEnv extends PreviewEnv {\n /**\n * @deprecated Fatal: a breaking API was introduced. Use getBuildPipe() instead.\n */\n getPipe?: () => BuildTask[];\n\n /**\n * Returns the component build pipeline\n * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`\n */\n getBuildPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];\n\n /**\n * Returns the component tag pipeline\n * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`\n */\n getTagPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];\n\n /**\n * Returns the component snap pipeline\n * Either `getBuildPipe`, `getTagPipe`, or `getSnapPipe` is required for `bit build`\n */\n getSnapPipe?: (modifiersMap?: PipeServiceModifiersMap) => BuildTask[];\n}\n\nexport interface TesterEnv extends Environment {\n /**\n * Returns a tester\n * Required for `bit start` & `bit test`\n */\n getTester?: (path: string, tester: any) => Tester;\n\n /**\n * Returns the dev patterns to match test files\n */\n getTestsDevPatterns?: (component: Component) => string[];\n}\n\nexport interface CompilerEnv {\n /**\n * Returns a compiler\n * Required for making and reading dists, especially for `bit compile`\n */\n getCompiler: () => Compiler;\n}\n\nexport function hasCompiler(obj: Environment): obj is CompilerEnv {\n return typeof obj.getCompiler === 'function';\n}\n\nexport interface DevEnv extends PreviewEnv {\n /**\n * Required for `bit start`\n */\n getDevEnvId?: (context?: any) => string;\n\n /**\n * Returns and configures the dev server\n * Required for `bit start`\n */\n getDevServer?: (\n context: DevServerContext,\n transformers: WebpackConfigTransformer[]\n ) => DevServer | Promise<DevServer>;\n}\n"],"mappings":";;;;;;AAAA;;AAoBA;AACA;AACA;;AAgNO,SAASA,WAAWA,CAACC,GAAgB,EAAsB;EAChE,OAAO,OAAOA,GAAG,CAACC,WAAW,KAAK,UAAU;AAC9C","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const EnvsAspect: Aspect;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EnvsAspect = void 0;
7
+ function _harmony() {
8
+ const data = require("@teambit/harmony");
9
+ _harmony = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ const EnvsAspect = exports.EnvsAspect = _harmony().Aspect.create({
15
+ id: 'teambit.envs/envs'
16
+ });
17
+
18
+ //# sourceMappingURL=environments.aspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_harmony","data","require","EnvsAspect","exports","Aspect","create","id"],"sources":["environments.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const EnvsAspect = Aspect.create({\n id: 'teambit.envs/envs',\n});\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EACtCC,EAAE,EAAE;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import { Schema } from '@teambit/graphql';
2
+ import { EnvsMain } from './environments.main.runtime';
3
+ export declare function environmentsSchema(environments: EnvsMain): Schema;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.environmentsSchema = environmentsSchema;
7
+ function _graphqlTag() {
8
+ const data = require("graphql-tag");
9
+ _graphqlTag = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function environmentsSchema(environments) {
15
+ return {
16
+ typeDefs: (0, _graphqlTag().gql)`
17
+ extend type Component {
18
+ env: ExtensionDescriptor
19
+ }
20
+
21
+ type ExtensionDescriptor {
22
+ id: String
23
+ icon: String
24
+ }
25
+ `,
26
+ resolvers: {
27
+ Component: {
28
+ env: component => {
29
+ return environments.getDescriptor(component);
30
+ }
31
+ }
32
+ }
33
+ };
34
+ }
35
+
36
+ //# sourceMappingURL=environments.graphql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_graphqlTag","data","require","environmentsSchema","environments","typeDefs","gql","resolvers","Component","env","component","getDescriptor"],"sources":["environments.graphql.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { Schema } from '@teambit/graphql';\nimport { gql } from 'graphql-tag';\n\nimport { EnvsMain } from './environments.main.runtime';\n\nexport function environmentsSchema(environments: EnvsMain): Schema {\n return {\n typeDefs: gql`\n extend type Component {\n env: ExtensionDescriptor\n }\n\n type ExtensionDescriptor {\n id: String\n icon: String\n }\n `,\n resolvers: {\n Component: {\n env: (component: Component) => {\n return environments.getDescriptor(component);\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;AAEA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIO,SAASE,kBAAkBA,CAACC,YAAsB,EAAU;EACjE,OAAO;IACLC,QAAQ,EAAE,IAAAC,iBAAG;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;IACDC,SAAS,EAAE;MACTC,SAAS,EAAE;QACTC,GAAG,EAAGC,SAAoB,IAAK;UAC7B,OAAON,YAAY,CAACO,aAAa,CAACD,SAAS,CAAC;QAC9C;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}