@teambit/component.testing.mock-components 0.0.185 → 0.0.187
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.
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { ComponentID } from '@teambit/component-id';
|
|
2
|
+
declare type CompDirs = {
|
|
3
|
+
id: ComponentID;
|
|
4
|
+
/**
|
|
5
|
+
* absolute path to the component dir
|
|
6
|
+
*/
|
|
7
|
+
dir: string;
|
|
8
|
+
};
|
|
1
9
|
/**
|
|
2
10
|
* create dummy components, add, link and compile them.
|
|
3
11
|
* if `numOfComponents` is more than one, the components will depend on each other. by default, it's one.
|
|
@@ -5,10 +13,11 @@
|
|
|
5
13
|
export declare function mockComponents(workspacePath: string, { numOfComponents, additionalStr }?: {
|
|
6
14
|
numOfComponents?: number;
|
|
7
15
|
additionalStr?: string;
|
|
8
|
-
}): Promise<
|
|
16
|
+
}): Promise<CompDirs[]>;
|
|
9
17
|
/**
|
|
10
18
|
* make the mocked components modified by appending the `additionalStr` to the component files
|
|
11
19
|
*/
|
|
12
20
|
export declare function modifyMockedComponents(workspacePath: string, additionalStr?: string, { numOfComponents }?: {
|
|
13
21
|
numOfComponents?: number;
|
|
14
22
|
}): Promise<void>;
|
|
23
|
+
export {};
|
package/dist/mock-components.js
CHANGED
|
@@ -31,14 +31,17 @@ function mockComponents(workspacePath, { numOfComponents = 1, additionalStr = ''
|
|
|
31
31
|
const harmony = yield (0, harmony_testing_load_aspect_1.loadManyAspects)([workspace_1.default, tracker_1.default, install_1.InstallAspect, compiler_1.CompilerAspect], workspacePath);
|
|
32
32
|
const workspace = harmony.get(workspace_1.default.id);
|
|
33
33
|
const tracker = harmony.get(tracker_1.default.id);
|
|
34
|
+
const results = [];
|
|
34
35
|
yield (0, p_map_series_1.default)(compsDirs, (compDir) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
yield tracker.track({ rootDir: compDir });
|
|
36
|
+
const { componentId } = yield tracker.track({ rootDir: compDir });
|
|
37
|
+
results.push({ id: componentId, dir: compDir });
|
|
36
38
|
}));
|
|
37
39
|
yield workspace.bitMap.write();
|
|
38
40
|
const install = harmony.get(install_1.InstallAspect.id);
|
|
39
41
|
yield install.link({ rewire: true });
|
|
40
42
|
const compiler = harmony.get(compiler_1.CompilerAspect.id);
|
|
41
43
|
yield compiler.compileOnWorkspace();
|
|
44
|
+
return results;
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
exports.mockComponents = mockComponents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-components.js","sourceRoot":"","sources":["../mock-components.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAiE;AACjE,sFAAuE;AACvE,mEAAgE;AAChE,8CAAiD;AAEjD,wDAA0B;AAC1B,gEAAsC;AACtC,gDAAwB;AACxB,+DAA8D;
|
|
1
|
+
{"version":3,"file":"mock-components.js","sourceRoot":"","sources":["../mock-components.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAiE;AACjE,sFAAuE;AACvE,mEAAgE;AAChE,8CAAiD;AAEjD,wDAA0B;AAC1B,gEAAsC;AACtC,gDAAwB;AACxB,+DAA8D;AAW9D;;;GAGG;AACH,SAAsB,cAAc,CAClC,aAAqB,EACrB,EAAE,eAAe,GAAG,CAAC,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,EAAE;;QAEhD,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,aAAa,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC,CAAC;QAC5F,MAAM,OAAO,GAAG,MAAM,IAAA,6CAAe,EAAC,CAAC,mBAAe,EAAE,iBAAa,EAAE,uBAAa,EAAE,yBAAc,CAAC,EAAE,aAAa,CAAC,CAAC;QACtH,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAY,mBAAe,CAAC,EAAE,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,C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a,IAAI,CAAC;YAC/F,MAAM,QAAQ,GAAG,OAAO,KAAK,GAAG,CAAC,EAAE,CAAC;YACpC,OAAO,SAAS,QAAQ,kBAAkB,QAAQ;8BACxB,KAAK,GAAG,aAAa,YAAY,QAAQ,KAAK,CAAC;QAC3E,CAAC,CAAC;QAEF,MAAM,kBAAkB,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7D,OAAO,IAAA,sBAAU,EAAC,kBAAkB,EAAE,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;YACvD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;YAClB,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;YACrD,MAAM,kBAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/D,OAAO,OAAO,CAAC;QACjB,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;CAAA"}
|
package/mock-components.ts
CHANGED
|
@@ -7,18 +7,32 @@ import fs from 'fs-extra';
|
|
|
7
7
|
import pMapSeries from 'p-map-series';
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import TrackerAspect, { TrackerMain } from '@teambit/tracker';
|
|
10
|
+
import { ComponentID } from '@teambit/component-id';
|
|
11
|
+
|
|
12
|
+
type CompDirs = {
|
|
13
|
+
id: ComponentID;
|
|
14
|
+
/**
|
|
15
|
+
* absolute path to the component dir
|
|
16
|
+
*/
|
|
17
|
+
dir: string;
|
|
18
|
+
};
|
|
10
19
|
|
|
11
20
|
/**
|
|
12
21
|
* create dummy components, add, link and compile them.
|
|
13
22
|
* if `numOfComponents` is more than one, the components will depend on each other. by default, it's one.
|
|
14
23
|
*/
|
|
15
|
-
export async function mockComponents(
|
|
24
|
+
export async function mockComponents(
|
|
25
|
+
workspacePath: string,
|
|
26
|
+
{ numOfComponents = 1, additionalStr = '' } = {}
|
|
27
|
+
): Promise<CompDirs[]> {
|
|
16
28
|
const compsDirs = await createComponents(workspacePath, { numOfComponents, additionalStr });
|
|
17
29
|
const harmony = await loadManyAspects([WorkspaceAspect, TrackerAspect, InstallAspect, CompilerAspect], workspacePath);
|
|
18
30
|
const workspace = harmony.get<Workspace>(WorkspaceAspect.id);
|
|
19
31
|
const tracker = harmony.get<TrackerMain>(TrackerAspect.id);
|
|
32
|
+
const results: CompDirs[] = [];
|
|
20
33
|
await pMapSeries(compsDirs, async (compDir) => {
|
|
21
|
-
await tracker.track({ rootDir: compDir });
|
|
34
|
+
const { componentId } = await tracker.track({ rootDir: compDir });
|
|
35
|
+
results.push({ id: componentId, dir: compDir });
|
|
22
36
|
});
|
|
23
37
|
await workspace.bitMap.write();
|
|
24
38
|
const install = harmony.get<InstallMain>(InstallAspect.id);
|
|
@@ -26,6 +40,8 @@ export async function mockComponents(workspacePath: string, { numOfComponents =
|
|
|
26
40
|
|
|
27
41
|
const compiler = harmony.get<CompilerMain>(CompilerAspect.id);
|
|
28
42
|
await compiler.compileOnWorkspace();
|
|
43
|
+
|
|
44
|
+
return results;
|
|
29
45
|
}
|
|
30
46
|
|
|
31
47
|
/**
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/component.testing.mock-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.187",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/component/testing/mock-components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "testing/mock-components",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.187"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"fs-extra": "10.0.0",
|
|
13
13
|
"p-map-series": "2.1.0",
|
|
14
|
-
"@teambit/
|
|
14
|
+
"@teambit/component-id": "1.2.0",
|
|
15
|
+
"@teambit/harmony.testing.load-aspect": "0.0.185"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@types/fs-extra": "9.0.7",
|
|
File without changes
|