@teambit/harmony.testing.load-aspect 0.0.18 → 0.0.20
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/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/load-aspect.d.ts +6 -1
- package/dist/load-aspect.js +16 -5
- package/dist/load-aspect.js.map +1 -1
- package/dist/{preview-1674271762484.js → preview-1675083688288.js} +0 -0
- package/index.ts +1 -1
- package/load-aspect.ts +16 -3
- package/package-tar/teambit-harmony.testing.load-aspect-0.0.20.tgz +0 -0
- package/package.json +2 -2
- package/package-tar/teambit-harmony.testing.load-aspect-0.0.18.tgz +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { loadAspect, getConfig } from './load-aspect';
|
|
1
|
+
export { loadAspect, loadManyAspects, getConfig } from './load-aspect';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConfig = exports.loadAspect = void 0;
|
|
3
|
+
exports.getConfig = exports.loadManyAspects = exports.loadAspect = void 0;
|
|
4
4
|
var load_aspect_1 = require("./load-aspect");
|
|
5
5
|
Object.defineProperty(exports, "loadAspect", { enumerable: true, get: function () { return load_aspect_1.loadAspect; } });
|
|
6
|
+
Object.defineProperty(exports, "loadManyAspects", { enumerable: true, get: function () { return load_aspect_1.loadManyAspects; } });
|
|
6
7
|
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return load_aspect_1.getConfig; } });
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,6CAAuE;AAA9D,yGAAA,UAAU,OAAA;AAAE,8GAAA,eAAe,OAAA;AAAE,wGAAA,SAAS,OAAA"}
|
package/dist/load-aspect.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { Aspect } from '@teambit/harmony';
|
|
1
|
+
import { Harmony, Aspect } from '@teambit/harmony';
|
|
2
2
|
import { Config } from '@teambit/harmony/dist/harmony-config';
|
|
3
3
|
/**
|
|
4
4
|
* to make this work, export the main also as default (e.g. `export default LanesMain;`).
|
|
5
5
|
* otherwise, it'll show an error "TypeError: Cannot read property 'runtime' of undefined".
|
|
6
6
|
*/
|
|
7
7
|
export declare function loadAspect<T>(targetAspect: Aspect, cwd?: string, runtime?: string): Promise<T>;
|
|
8
|
+
/**
|
|
9
|
+
* returns an instance of Harmony. with this instance, you can get any aspect you loaded.
|
|
10
|
+
* e.g. `const workspace = harmony.get<Workspace>(WorkspaceAspect.id);`
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadManyAspects(targetAspects: Aspect[], cwd?: string, runtime?: string): Promise<Harmony>;
|
|
8
13
|
export declare function getConfig(cwd?: string): Promise<Config>;
|
package/dist/load-aspect.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getConfig = exports.loadAspect = void 0;
|
|
15
|
+
exports.getConfig = exports.loadManyAspects = exports.loadAspect = void 0;
|
|
16
16
|
const path_1 = require("path");
|
|
17
17
|
const consumer_1 = require("@teambit/legacy/dist/consumer");
|
|
18
18
|
const utils_1 = require("@teambit/legacy/dist/utils");
|
|
@@ -40,6 +40,17 @@ function getPackageName(aspect, id) {
|
|
|
40
40
|
* otherwise, it'll show an error "TypeError: Cannot read property 'runtime' of undefined".
|
|
41
41
|
*/
|
|
42
42
|
function loadAspect(targetAspect, cwd = process.cwd(), runtime = 'main') {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const harmony = yield loadManyAspects([targetAspect], cwd, runtime);
|
|
45
|
+
return harmony.get(targetAspect.id);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
exports.loadAspect = loadAspect;
|
|
49
|
+
/**
|
|
50
|
+
* returns an instance of Harmony. with this instance, you can get any aspect you loaded.
|
|
51
|
+
* e.g. `const workspace = harmony.get<Workspace>(WorkspaceAspect.id);`
|
|
52
|
+
*/
|
|
53
|
+
function loadManyAspects(targetAspects, cwd = process.cwd(), runtime = 'main') {
|
|
43
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
55
|
clearGlobalsIfNeeded();
|
|
45
56
|
const config = yield getConfig(cwd);
|
|
@@ -49,7 +60,7 @@ function loadAspect(targetAspect, cwd = process.cwd(), runtime = 'main') {
|
|
|
49
60
|
};
|
|
50
61
|
// CLIAspect is needed for register the main runtime. NodeAspect is needed to get the default env if nothing
|
|
51
62
|
// was configured. If it's not loaded here, it'll throw an error later that there is no node-env.
|
|
52
|
-
const harmony = yield harmony_1.Harmony.load([cli_1.CLIAspect, node_1.NodeAspect,
|
|
63
|
+
const harmony = yield harmony_1.Harmony.load([cli_1.CLIAspect, node_1.NodeAspect, ...targetAspects], runtime, configMap);
|
|
53
64
|
yield harmony.run((aspect, runtimeDef) => __awaiter(this, void 0, void 0, function* () {
|
|
54
65
|
const id = component_1.ComponentID.fromString(aspect.id);
|
|
55
66
|
const mainFilePath = getMainFilePath(aspect, id);
|
|
@@ -60,7 +71,7 @@ function loadAspect(targetAspect, cwd = process.cwd(), runtime = 'main') {
|
|
|
60
71
|
throw new Error(`could not find runtime '${runtimeDef.name}' for aspect ID '${aspect.id}'`);
|
|
61
72
|
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
62
73
|
const runtimeC = require((0, path_1.join)(packagePath, runtimePath));
|
|
63
|
-
if (aspect.manifest._runtimes.length === 0 || aspect.id
|
|
74
|
+
if (aspect.manifest._runtimes.length === 0 || targetAspects.includes(aspect.id)) {
|
|
64
75
|
// core-aspects running outside of bit-bin repo end up here. they don't have runtime.
|
|
65
76
|
// this makes sure to load them from the path were they're imported
|
|
66
77
|
if (!runtimeC.default) {
|
|
@@ -70,10 +81,10 @@ go to the aspect-main file and add a new line with "export default YourAspectMai
|
|
|
70
81
|
aspect.manifest.addRuntime(runtimeC.default);
|
|
71
82
|
}
|
|
72
83
|
}));
|
|
73
|
-
return harmony
|
|
84
|
+
return harmony;
|
|
74
85
|
});
|
|
75
86
|
}
|
|
76
|
-
exports.
|
|
87
|
+
exports.loadManyAspects = loadManyAspects;
|
|
77
88
|
function getMainFilePath(aspect, id) {
|
|
78
89
|
let packageName = getPackageName(aspect, id);
|
|
79
90
|
try {
|
package/dist/load-aspect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-aspect.js","sourceRoot":"","sources":["../load-aspect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAqC;AACrC,4DAA8E;AAC9E,sDAA8E;AAC9E,2BAAiC;AACjC,8CAAmD;AACnD,uFAAuF;AACvF,yEAA6E;AAC7E,kDAAiD;AACjD,sCAAyC;AACzC,wCAA2C;AAC3C,gHAAuF;AACvF,6GAAoF;AACpF,mHAA0F;AAC1F,+GAA0G;AAC1G,iEAAyE;AACzE,6GAAoF;AACpF,kHAA8G;AAE9G,SAAS,cAAc,CAAC,MAAW,EAAE,EAAe;IAClD,OAAO,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC;IAC7B,8CAA8C;IAC9C,oDAAoD;AACtD,CAAC;AAED;;;GAGG;AACH,SAAsB,UAAU,CAAI,YAAoB,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,GAAG,MAAM;;QAC7F,oBAAoB,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,G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,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC;SACf;QAED,IAAI,SAAS,IAAI,CAAC,YAAY,EAAE;YAC9B,OAAO,uBAAM,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;SAC/C;QAED,OAAO,uBAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,CAAC;CAAA;AAtBD,8BAsBC;AAED,SAAS,oBAAoB;IAC3B,IAAI,CAAC,uBAAY,CAAC,KAAK,IAAI,CAAC,iDAAsB,CAAC,+BAA+B,CAAC,MAAM,EAAE;QACzF,OAAO;KACR;IACD,OAAO,uBAAY,CAAC,KAAK,CAAC;IAC1B,0BAAe,CAAC,0BAA0B,GAAG,EAAE,CAAC;IAChD,6BAAkB,CAAC,iCAAiC,GAAG,EAAE,CAAC;IAC1D,0BAAe,CAAC,oCAAoC,GAAG,EAAE,CAAC;IAC1D,0BAAe,CAAC,8BAA8B,GAAG,EAAE,CAAC;IACpD,iDAAsB,CAAC,+BAA+B,GAAG,EAAE,CAAC;IAC5D,aAAa;IACb,wCAAkB,CAAC,kBAAkB,GAAG,SAAS,CAAC;IAClD,0BAAiB,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;IAClD,aAAa;IACb,0BAAe,CAAC,+BAA+B,GAAG,SAAS,CAAC;IAC5D,aAAa;IACb,0BAAe,CAAC,8BAA8B,GAAG,SAAS,CAAC;IAC3D,aAAa;IACb,0BAAe,CAAC,8BAA8B,GAAG,SAAS,CAAC;AAC7D,CAAC"}
|
|
File without changes
|
package/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { loadAspect, getConfig } from './load-aspect';
|
|
1
|
+
export { loadAspect, loadManyAspects, getConfig } from './load-aspect';
|
package/load-aspect.ts
CHANGED
|
@@ -27,6 +27,19 @@ function getPackageName(aspect: any, id: ComponentID) {
|
|
|
27
27
|
* otherwise, it'll show an error "TypeError: Cannot read property 'runtime' of undefined".
|
|
28
28
|
*/
|
|
29
29
|
export async function loadAspect<T>(targetAspect: Aspect, cwd = process.cwd(), runtime = 'main'): Promise<T> {
|
|
30
|
+
const harmony = await loadManyAspects([targetAspect], cwd, runtime);
|
|
31
|
+
return harmony.get(targetAspect.id);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* returns an instance of Harmony. with this instance, you can get any aspect you loaded.
|
|
36
|
+
* e.g. `const workspace = harmony.get<Workspace>(WorkspaceAspect.id);`
|
|
37
|
+
*/
|
|
38
|
+
export async function loadManyAspects(
|
|
39
|
+
targetAspects: Aspect[],
|
|
40
|
+
cwd = process.cwd(),
|
|
41
|
+
runtime = 'main'
|
|
42
|
+
): Promise<Harmony> {
|
|
30
43
|
clearGlobalsIfNeeded();
|
|
31
44
|
const config = await getConfig(cwd);
|
|
32
45
|
const configMap = config.toObject();
|
|
@@ -36,7 +49,7 @@ export async function loadAspect<T>(targetAspect: Aspect, cwd = process.cwd(), r
|
|
|
36
49
|
|
|
37
50
|
// CLIAspect is needed for register the main runtime. NodeAspect is needed to get the default env if nothing
|
|
38
51
|
// was configured. If it's not loaded here, it'll throw an error later that there is no node-env.
|
|
39
|
-
const harmony = await Harmony.load([CLIAspect, NodeAspect,
|
|
52
|
+
const harmony = await Harmony.load([CLIAspect, NodeAspect, ...targetAspects], runtime, configMap);
|
|
40
53
|
|
|
41
54
|
await harmony.run(async (aspect, runtimeDef) => {
|
|
42
55
|
const id = ComponentID.fromString(aspect.id);
|
|
@@ -47,7 +60,7 @@ export async function loadAspect<T>(targetAspect: Aspect, cwd = process.cwd(), r
|
|
|
47
60
|
if (!runtimePath) throw new Error(`could not find runtime '${runtimeDef.name}' for aspect ID '${aspect.id}'`);
|
|
48
61
|
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
49
62
|
const runtimeC = require(join(packagePath, runtimePath));
|
|
50
|
-
if (aspect.manifest._runtimes.length === 0 || aspect.id
|
|
63
|
+
if (aspect.manifest._runtimes.length === 0 || targetAspects.includes(aspect.id)) {
|
|
51
64
|
// core-aspects running outside of bit-bin repo end up here. they don't have runtime.
|
|
52
65
|
// this makes sure to load them from the path were they're imported
|
|
53
66
|
if (!runtimeC.default) {
|
|
@@ -58,7 +71,7 @@ go to the aspect-main file and add a new line with "export default YourAspectMai
|
|
|
58
71
|
}
|
|
59
72
|
});
|
|
60
73
|
|
|
61
|
-
return harmony
|
|
74
|
+
return harmony;
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
function getMainFilePath(aspect: any, id: ComponentID) {
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/harmony.testing.load-aspect",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"homepage": "https://bit.dev/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.
|
|
9
|
+
"version": "0.0.20"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/harmony": "0.4.6"
|
|
Binary file
|