@teambit/harmony.testing.load-aspect 0.0.265 → 0.0.267

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.
@@ -0,0 +1,108 @@
1
+ [
2
+ "teambit.harmony/aspect-loader",
3
+ "teambit.harmony/cli",
4
+ "teambit.component/dev-files",
5
+ "teambit.workspace/workspace",
6
+ "teambit.workspace/workspace-config-files",
7
+ "teambit.workspace/install",
8
+ "teambit.defender/eslint",
9
+ "teambit.defender/prettier",
10
+ "teambit.compilation/compiler",
11
+ "teambit.defender/linter",
12
+ "teambit.defender/formatter",
13
+ "teambit.component/component",
14
+ "teambit.mdx/mdx",
15
+ "teambit.mdx/readme",
16
+ "teambit.preview/preview",
17
+ "teambit.component/component-sizer",
18
+ "teambit.docs/docs",
19
+ "teambit.dependencies/yarn",
20
+ "teambit.compositions/compositions",
21
+ "teambit.harmony/global-config",
22
+ "teambit.harmony/graphql",
23
+ "teambit.dependencies/pnpm",
24
+ "teambit.compilation/multi-compiler",
25
+ "teambit.ui-foundation/ui",
26
+ "teambit.generator/generator",
27
+ "teambit.envs/envs",
28
+ "teambit.envs/env",
29
+ "teambit.component/graph",
30
+ "teambit.harmony/pubsub",
31
+ "teambit.dependencies/dependency-resolver",
32
+ "teambit.explorer/insights",
33
+ "teambit.component/isolator",
34
+ "teambit.harmony/logger",
35
+ "teambit.pkg/pkg",
36
+ "teambit.react/react",
37
+ "teambit.harmony/worker",
38
+ "teambit.scope/scope",
39
+ "teambit.defender/tester",
40
+ "teambit.defender/multi-tester",
41
+ "teambit.pipelines/builder",
42
+ "teambit.workspace/variants",
43
+ "teambit.component/deprecation",
44
+ "teambit.harmony/express",
45
+ "teambit.harmony/aspect",
46
+ "teambit.webpack/webpack",
47
+ "teambit.semantics/schema",
48
+ "teambit.ui-foundation/react-router",
49
+ "teambit.typescript/typescript",
50
+ "teambit.ui-foundation/panels",
51
+ "teambit.compilation/babel",
52
+ "teambit.harmony/node",
53
+ "teambit.ui-foundation/notifications",
54
+ "teambit.compilation/bundler",
55
+ "teambit.defender/jest",
56
+ "teambit.harmony/cache",
57
+ "teambit.component/changelog",
58
+ "teambit.component/code",
59
+ "teambit.explorer/command-bar",
60
+ "teambit.ui-foundation/sidebar",
61
+ "teambit.component/component-tree",
62
+ "teambit.scope/sign",
63
+ "teambit.scope/update-dependencies",
64
+ "teambit.scope/export",
65
+ "teambit.scope/importer",
66
+ "teambit.ui-foundation/harmony-ui-app",
67
+ "teambit.ui-foundation/user-agent",
68
+ "teambit.harmony/application",
69
+ "teambit.workspace/eject",
70
+ "teambit.html/html",
71
+ "teambit.lanes/lanes",
72
+ "teambit.component/forking",
73
+ "teambit.component/renaming",
74
+ "teambit.component/new-component-helper",
75
+ "teambit.component/component-log",
76
+ "teambit.bit/clear-cache",
77
+ "teambit.defender/mocha",
78
+ "teambit.harmony/diagnostic",
79
+ "teambit.component/status",
80
+ "teambit.community/community",
81
+ "teambit.cloud/cloud",
82
+ "teambit.component/snapping",
83
+ "teambit.component/merging",
84
+ "teambit.component/issues",
85
+ "teambit.component/refactoring",
86
+ "teambit.component/component-compare",
87
+ "teambit.component/lister",
88
+ "teambit.dependencies/dependencies",
89
+ "teambit.component/remove",
90
+ "teambit.lanes/merge-lanes",
91
+ "teambit.component/checkout",
92
+ "teambit.component/component-writer",
93
+ "teambit.api-reference/api-reference",
94
+ "teambit.harmony/api-server",
95
+ "teambit.component/tracker",
96
+ "teambit.component/mover",
97
+ "teambit.workspace/watcher",
98
+ "teambit.component/stash",
99
+ "teambit.git/git",
100
+ "teambit.harmony/ipc-events",
101
+ "teambit.workspace/config-merger",
102
+ "teambit.scope/version-history",
103
+ "teambit.harmony/host-initializer",
104
+ "teambit.harmony/doctor",
105
+ "teambit.component/apply",
106
+ "teambit.harmony/bit",
107
+ "teambit.harmony/config"
108
+ ]
@@ -0,0 +1,108 @@
1
+ [
2
+ "teambit.harmony/aspect-loader",
3
+ "teambit.harmony/cli",
4
+ "teambit.component/dev-files",
5
+ "teambit.workspace/workspace",
6
+ "teambit.workspace/workspace-config-files",
7
+ "teambit.workspace/install",
8
+ "teambit.defender/eslint",
9
+ "teambit.defender/prettier",
10
+ "teambit.compilation/compiler",
11
+ "teambit.defender/linter",
12
+ "teambit.defender/formatter",
13
+ "teambit.component/component",
14
+ "teambit.mdx/mdx",
15
+ "teambit.mdx/readme",
16
+ "teambit.preview/preview",
17
+ "teambit.component/component-sizer",
18
+ "teambit.docs/docs",
19
+ "teambit.dependencies/yarn",
20
+ "teambit.compositions/compositions",
21
+ "teambit.harmony/global-config",
22
+ "teambit.harmony/graphql",
23
+ "teambit.dependencies/pnpm",
24
+ "teambit.compilation/multi-compiler",
25
+ "teambit.ui-foundation/ui",
26
+ "teambit.generator/generator",
27
+ "teambit.envs/envs",
28
+ "teambit.envs/env",
29
+ "teambit.component/graph",
30
+ "teambit.harmony/pubsub",
31
+ "teambit.dependencies/dependency-resolver",
32
+ "teambit.explorer/insights",
33
+ "teambit.component/isolator",
34
+ "teambit.harmony/logger",
35
+ "teambit.pkg/pkg",
36
+ "teambit.react/react",
37
+ "teambit.harmony/worker",
38
+ "teambit.scope/scope",
39
+ "teambit.defender/tester",
40
+ "teambit.defender/multi-tester",
41
+ "teambit.pipelines/builder",
42
+ "teambit.workspace/variants",
43
+ "teambit.component/deprecation",
44
+ "teambit.harmony/express",
45
+ "teambit.harmony/aspect",
46
+ "teambit.webpack/webpack",
47
+ "teambit.semantics/schema",
48
+ "teambit.ui-foundation/react-router",
49
+ "teambit.typescript/typescript",
50
+ "teambit.ui-foundation/panels",
51
+ "teambit.compilation/babel",
52
+ "teambit.harmony/node",
53
+ "teambit.ui-foundation/notifications",
54
+ "teambit.compilation/bundler",
55
+ "teambit.defender/jest",
56
+ "teambit.harmony/cache",
57
+ "teambit.component/changelog",
58
+ "teambit.component/code",
59
+ "teambit.explorer/command-bar",
60
+ "teambit.ui-foundation/sidebar",
61
+ "teambit.component/component-tree",
62
+ "teambit.scope/sign",
63
+ "teambit.scope/update-dependencies",
64
+ "teambit.scope/export",
65
+ "teambit.scope/importer",
66
+ "teambit.ui-foundation/harmony-ui-app",
67
+ "teambit.ui-foundation/user-agent",
68
+ "teambit.harmony/application",
69
+ "teambit.workspace/eject",
70
+ "teambit.html/html",
71
+ "teambit.lanes/lanes",
72
+ "teambit.component/forking",
73
+ "teambit.component/renaming",
74
+ "teambit.component/new-component-helper",
75
+ "teambit.component/component-log",
76
+ "teambit.bit/clear-cache",
77
+ "teambit.defender/mocha",
78
+ "teambit.harmony/diagnostic",
79
+ "teambit.component/status",
80
+ "teambit.community/community",
81
+ "teambit.cloud/cloud",
82
+ "teambit.component/snapping",
83
+ "teambit.component/merging",
84
+ "teambit.component/issues",
85
+ "teambit.component/refactoring",
86
+ "teambit.component/component-compare",
87
+ "teambit.component/lister",
88
+ "teambit.dependencies/dependencies",
89
+ "teambit.component/remove",
90
+ "teambit.lanes/merge-lanes",
91
+ "teambit.component/checkout",
92
+ "teambit.component/component-writer",
93
+ "teambit.api-reference/api-reference",
94
+ "teambit.harmony/api-server",
95
+ "teambit.component/tracker",
96
+ "teambit.component/mover",
97
+ "teambit.workspace/watcher",
98
+ "teambit.component/stash",
99
+ "teambit.git/git",
100
+ "teambit.harmony/ipc-events",
101
+ "teambit.workspace/config-merger",
102
+ "teambit.scope/version-history",
103
+ "teambit.harmony/host-initializer",
104
+ "teambit.harmony/doctor",
105
+ "teambit.component/apply",
106
+ "teambit.harmony/bit",
107
+ "teambit.harmony/config"
108
+ ]
@@ -25,11 +25,21 @@ const legacy_consumer_component_1 = require("@teambit/legacy.consumer-component"
25
25
  const legacy_consumer_config_1 = require("@teambit/legacy.consumer-config");
26
26
  const workspace_modules_node_modules_linker_1 = require("@teambit/workspace.modules.node-modules-linker");
27
27
  const dependencies_1 = require("@teambit/dependencies");
28
+ const legacy_extension_data_1 = require("@teambit/legacy.extension-data");
28
29
  function getPackageName(aspect, id) {
29
30
  return `@teambit/${id.name}`;
30
31
  // const [owner, name] = aspect.id.split('.');
31
32
  // return `@${owner}/${replaceAll(name, '/', '.')}`;
32
33
  }
34
+ /**
35
+ * we keep a static list of core-aspect-ids here in this component in order to not depend on bit aspect.
36
+ * it gets updated during Circle tag process.
37
+ */
38
+ function getCoreAspectIds() {
39
+ const aspectIdsFile = (0, path_1.join)(__dirname, 'core-aspects-ids.json');
40
+ const file = (0, fs_1.readFileSync)(aspectIdsFile, 'utf8');
41
+ return JSON.parse(file);
42
+ }
33
43
  /**
34
44
  * ! important ! prefer using `loadManyAspects` instead of this function. otherwise, you may end up with
35
45
  * different instances of "Workspace" aspect for example for each one of the aspects you load.
@@ -53,6 +63,10 @@ exports.loadAspect = loadAspect;
53
63
  function loadManyAspects(targetAspects, cwd = process.cwd(), runtime = 'main') {
54
64
  return __awaiter(this, void 0, void 0, function* () {
55
65
  clearGlobalsIfNeeded();
66
+ const coreAspectIds = getCoreAspectIds();
67
+ // tried alternative to avoid this. however, in some cases, during build, this component is in a capsule, so the list
68
+ // of core-aspects registered during load-bit doesn't apply here.
69
+ legacy_extension_data_1.ExtensionDataList.registerManyCoreExtensionNames(coreAspectIds);
56
70
  const config = yield getConfig(cwd);
57
71
  const configMap = config.toObject();
58
72
  configMap['teambit.harmony/bit'] = {
@@ -75,17 +89,31 @@ function loadManyAspects(targetAspects, cwd = process.cwd(), runtime = 'main') {
75
89
  if (aspect.manifest._runtimes.length === 0 || targetAspects.includes(aspect.id)) {
76
90
  // core-aspects running outside of bit-bin repo end up here. they don't have runtime.
77
91
  // this makes sure to load them from the path were they're imported
78
- if (!runtimeC.default) {
79
- throw new Error(`error: ${aspect.id} does not export its main-runtime as default.
80
- go to the aspect-main file and add a new line with "export default YourAspectMain"`);
81
- }
82
- aspect.manifest.addRuntime(runtimeC.default);
92
+ addRuntimeIfNeeded(runtimeC, aspect);
83
93
  }
84
94
  }));
85
95
  return harmony;
86
96
  });
87
97
  }
88
98
  exports.loadManyAspects = loadManyAspects;
99
+ function addRuntimeIfNeeded(runtimeC, aspect) {
100
+ if (runtimeC.default) {
101
+ aspect.manifest.addRuntime(runtimeC.default);
102
+ return;
103
+ }
104
+ const methodsOnResult = Object.keys(runtimeC);
105
+ if (methodsOnResult.length === 1) {
106
+ aspect.manifest.addRuntime(runtimeC[methodsOnResult[0]]);
107
+ return;
108
+ }
109
+ const main = methodsOnResult.filter((method) => method.endsWith('Main'));
110
+ if (main.length === 1) {
111
+ aspect.manifest.addRuntime(runtimeC[main[0]]);
112
+ return;
113
+ }
114
+ throw new Error(`error: ${aspect.id} does not export its main-runtime as default.
115
+ go to the aspect-main file and add a new line with "export default YourAspectMain"`);
116
+ }
89
117
  function getMainFilePath(aspect, id) {
90
118
  let packageName = getPackageName(aspect, id);
91
119
  try {
@@ -132,9 +160,7 @@ function clearGlobalsIfNeeded() {
132
160
  workspace_modules_node_modules_linker_1.PackageJsonTransformer.packageJsonTransformersRegistry = [];
133
161
  // @ts-ignore
134
162
  legacy_consumer_component_1.ComponentLoader.loadDeps = undefined;
135
- // don't clear this one. it's a static list of core-ids. if you delete it, you'll have to call
136
- // registerCoreExtensions() from @teambit/bit, which as far as I remember should not be a dependency of this aspect.
137
- // ExtensionDataList.coreExtensionsNames = new Map();
163
+ legacy_extension_data_1.ExtensionDataList.coreExtensionsNames = new Map();
138
164
  // @ts-ignore
139
165
  legacy_consumer_config_1.LegacyWorkspaceConfig.workspaceConfigLoadingRegistry = undefined;
140
166
  }
@@ -1 +1 @@
1
- {"version":3,"file":"load-aspect.js","sourceRoot":"","sources":["../load-aspect.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAqC;AACrC,8DAAwD;AACxD,sGAAgF;AAChF,0FAAuE;AACvE,2BAAiC;AACjC,8CAAmD;AACnD,uFAAuF;AACvF,yEAA6E;AAC7E,kDAAiD;AACjD,sCAAyC;AACzC,wCAA2C;AAC3C,kFAAqE;AACrE,4EAA6G;AAC7G,0GAAwF;AACxF,wDAA2D;AAE3D,SAAS,cAAc,CAAC,MAAW,EAAE,E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AY,EAAE,CAAC;YAC/B,OAAO,uBAAM,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,uBAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,CAAC;CAAA;AAtBD,8BAsBC;AAED,SAAS,oBAAoB;IAC3B,IAAI,CAAC,8BAAY,CAAC,KAAK,IAAI,CAAC,8DAAsB,CAAC,+BAA+B,CAAC,MAAM,EAAE,CAAC;QAC1F,OAAO;IACT,CAAC;IACD,OAAO,8BAAY,CAAC,KAAK,CAAC;IAC1B,2CAAe,CAAC,0BAA0B,GAAG,EAAE,CAAC;IAChD,2CAAkB,CAAC,iCAAiC,GAAG,EAAE,CAAC;IAC1D,wCAAe,CAAC,8BAA8B,GAAG,EAAE,CAAC;IACpD,8DAAsB,CAAC,+BAA+B,GAAG,EAAE,CAAC;IAC5D,aAAa;IACb,2CAAe,CAAC,QAAQ,GAAG,SAAS,CAAC;IACrC,yCAAiB,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;IAClD,aAAa;IACb,8CAAqB,CAAC,8BAA8B,GAAG,SAAS,CAAC;AACnE,CAAC"}
package/load-aspect.ts CHANGED
@@ -2,8 +2,8 @@ import { resolve, join } from 'path';
2
2
  import { loadConsumer } from '@teambit/legacy.consumer';
3
3
  import { getWorkspaceInfo } from '@teambit/workspace.modules.workspace-locator';
4
4
  import { findScopePath } from '@teambit/scope.modules.find-scope-path';
5
- import { readdirSync } from 'fs';
6
- import { Harmony, Aspect } from '@teambit/harmony';
5
+ import { readdirSync, readFileSync } from 'fs';
6
+ import { Harmony, Aspect, Extension } from '@teambit/harmony';
7
7
  // TODO: expose this types from harmony (once we have a way to expose it only for node)
8
8
  import { Config, ConfigOptions } from '@teambit/harmony/dist/harmony-config';
9
9
  import { ComponentID } from '@teambit/component';
@@ -13,6 +13,7 @@ import { ComponentLoader } from '@teambit/legacy.consumer-component';
13
13
  import { LegacyWorkspaceConfig, ComponentOverrides, ComponentConfig } from '@teambit/legacy.consumer-config';
14
14
  import { PackageJsonTransformer } from '@teambit/workspace.modules.node-modules-linker';
15
15
  import { DependenciesAspect } from '@teambit/dependencies';
16
+ import { ExtensionDataList } from '@teambit/legacy.extension-data';
16
17
 
17
18
  function getPackageName(aspect: any, id: ComponentID) {
18
19
  return `@teambit/${id.name}`;
@@ -20,6 +21,16 @@ function getPackageName(aspect: any, id: ComponentID) {
20
21
  // return `@${owner}/${replaceAll(name, '/', '.')}`;
21
22
  }
22
23
 
24
+ /**
25
+ * we keep a static list of core-aspect-ids here in this component in order to not depend on bit aspect.
26
+ * it gets updated during Circle tag process.
27
+ */
28
+ function getCoreAspectIds() {
29
+ const aspectIdsFile = join(__dirname, 'core-aspects-ids.json');
30
+ const file = readFileSync(aspectIdsFile, 'utf8');
31
+ return JSON.parse(file);
32
+ }
33
+
23
34
  /**
24
35
  * ! important ! prefer using `loadManyAspects` instead of this function. otherwise, you may end up with
25
36
  * different instances of "Workspace" aspect for example for each one of the aspects you load.
@@ -44,6 +55,11 @@ export async function loadManyAspects(
44
55
  runtime = 'main'
45
56
  ): Promise<Harmony> {
46
57
  clearGlobalsIfNeeded();
58
+ const coreAspectIds = getCoreAspectIds();
59
+ // tried alternative to avoid this. however, in some cases, during build, this component is in a capsule, so the list
60
+ // of core-aspects registered during load-bit doesn't apply here.
61
+ ExtensionDataList.registerManyCoreExtensionNames(coreAspectIds);
62
+
47
63
  const config = await getConfig(cwd);
48
64
  const configMap = config.toObject();
49
65
  configMap['teambit.harmony/bit'] = {
@@ -67,17 +83,32 @@ export async function loadManyAspects(
67
83
  if (aspect.manifest._runtimes.length === 0 || targetAspects.includes(aspect.id)) {
68
84
  // core-aspects running outside of bit-bin repo end up here. they don't have runtime.
69
85
  // this makes sure to load them from the path were they're imported
70
- if (!runtimeC.default) {
71
- throw new Error(`error: ${aspect.id} does not export its main-runtime as default.
72
- go to the aspect-main file and add a new line with "export default YourAspectMain"`);
73
- }
74
- aspect.manifest.addRuntime(runtimeC.default);
86
+ addRuntimeIfNeeded(runtimeC, aspect);
75
87
  }
76
88
  });
77
89
 
78
90
  return harmony;
79
91
  }
80
92
 
93
+ function addRuntimeIfNeeded(runtimeC: any, aspect: Extension) {
94
+ if (runtimeC.default) {
95
+ aspect.manifest.addRuntime(runtimeC.default);
96
+ return;
97
+ }
98
+ const methodsOnResult = Object.keys(runtimeC);
99
+ if (methodsOnResult.length === 1) {
100
+ aspect.manifest.addRuntime(runtimeC[methodsOnResult[0]]);
101
+ return;
102
+ }
103
+ const main = methodsOnResult.filter((method) => method.endsWith('Main'));
104
+ if (main.length === 1) {
105
+ aspect.manifest.addRuntime(runtimeC[main[0]]);
106
+ return;
107
+ }
108
+ throw new Error(`error: ${aspect.id} does not export its main-runtime as default.
109
+ go to the aspect-main file and add a new line with "export default YourAspectMain"`);
110
+ }
111
+
81
112
  function getMainFilePath(aspect: any, id: ComponentID) {
82
113
  let packageName = getPackageName(aspect, id);
83
114
  try {
@@ -125,9 +156,7 @@ function clearGlobalsIfNeeded() {
125
156
  PackageJsonTransformer.packageJsonTransformersRegistry = [];
126
157
  // @ts-ignore
127
158
  ComponentLoader.loadDeps = undefined;
128
- // don't clear this one. it's a static list of core-ids. if you delete it, you'll have to call
129
- // registerCoreExtensions() from @teambit/bit, which as far as I remember should not be a dependency of this aspect.
130
- // ExtensionDataList.coreExtensionsNames = new Map();
159
+ ExtensionDataList.coreExtensionsNames = new Map();
131
160
  // @ts-ignore
132
161
  LegacyWorkspaceConfig.workspaceConfigLoadingRegistry = undefined;
133
162
  }
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@teambit/harmony.testing.load-aspect",
3
- "version": "0.0.265",
3
+ "version": "0.0.267",
4
4
  "homepage": "https://bit.cloud/teambit/harmony/testing/load-aspect",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.harmony",
8
8
  "name": "testing/load-aspect",
9
- "version": "0.0.265"
9
+ "version": "0.0.267"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/harmony": "0.4.6",
13
- "@teambit/legacy.consumer-component": "0.0.12",
14
- "@teambit/legacy.consumer-config": "0.0.11",
15
- "@teambit/legacy.consumer": "0.0.11",
13
+ "@teambit/legacy.consumer-component": "0.0.13",
14
+ "@teambit/legacy.consumer-config": "0.0.12",
15
+ "@teambit/legacy.consumer": "0.0.12",
16
+ "@teambit/legacy.extension-data": "0.0.14",
16
17
  "@teambit/scope.modules.find-scope-path": "0.0.5",
17
- "@teambit/workspace.modules.node-modules-linker": "0.0.239",
18
+ "@teambit/workspace.modules.node-modules-linker": "0.0.240",
18
19
  "@teambit/workspace.modules.workspace-locator": "0.0.5"
19
20
  },
20
21
  "devDependencies": {