@teambit/component.testing.mock-components 0.0.2
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 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/mock-components.d.ts +8 -0
- package/dist/mock-components.js +50 -0
- package/dist/mock-components.js.map +1 -0
- package/index.ts +1 -0
- package/mock-components.ts +33 -0
- package/package-tar/teambit-component.testing.mock-components-0.0.2.tgz +0 -0
- package/package.json +60 -0
- package/tsconfig.json +26 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mockComponents } from './mock-components';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mockComponents = void 0;
|
|
4
|
+
var mock_components_1 = require("./mock-components");
|
|
5
|
+
Object.defineProperty(exports, "mockComponents", { enumerable: true, get: function () { return mock_components_1.mockComponents; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,iHAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* create dummy components, add, link and compile them.
|
|
3
|
+
* if `numOfComponents` is more than one, the components will depend on each other.
|
|
4
|
+
*/
|
|
5
|
+
export declare function mockComponents(workspacePath: string, { numOfComponents, additionalStr }?: {
|
|
6
|
+
numOfComponents?: number;
|
|
7
|
+
additionalStr?: string;
|
|
8
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.mockComponents = void 0;
|
|
16
|
+
const compiler_1 = require("@teambit/compiler");
|
|
17
|
+
const harmony_testing_load_aspect_1 = require("@teambit/harmony.testing.load-aspect");
|
|
18
|
+
const workspace_1 = __importDefault(require("@teambit/workspace"));
|
|
19
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
20
|
+
const p_map_series_1 = __importDefault(require("p-map-series"));
|
|
21
|
+
const path_1 = __importDefault(require("path"));
|
|
22
|
+
/**
|
|
23
|
+
* create dummy components, add, link and compile them.
|
|
24
|
+
* if `numOfComponents` is more than one, the components will depend on each other.
|
|
25
|
+
*/
|
|
26
|
+
function mockComponents(workspacePath, { numOfComponents = 1, additionalStr = '' } = {}) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const getImp = (index) => {
|
|
29
|
+
if (index === numOfComponents)
|
|
30
|
+
return `module.exports = () => 'comp${index}${additionalStr}';`;
|
|
31
|
+
const nextComp = `comp${index + 1}`;
|
|
32
|
+
return `const ${nextComp} = require('../${nextComp}');
|
|
33
|
+
module.exports = () => 'comp${index}${additionalStr} and ' + ${nextComp}();`;
|
|
34
|
+
};
|
|
35
|
+
const workspace = yield (0, harmony_testing_load_aspect_1.loadAspect)(workspace_1.default, workspacePath);
|
|
36
|
+
const numOfComponentsArr = Array(numOfComponents).fill(null);
|
|
37
|
+
yield (0, p_map_series_1.default)(numOfComponentsArr, (val, key) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const i = key + 1;
|
|
39
|
+
const compDir = path_1.default.join(workspacePath, `comp${i}`);
|
|
40
|
+
yield fs_extra_1.default.outputFile(path_1.default.join(compDir, `index.js`), getImp(i));
|
|
41
|
+
yield workspace.track({ rootDir: compDir });
|
|
42
|
+
}));
|
|
43
|
+
yield workspace.bitMap.write();
|
|
44
|
+
yield workspace.link({ rewire: true });
|
|
45
|
+
const compiler = yield (0, harmony_testing_load_aspect_1.loadAspect)(compiler_1.CompilerAspect, workspacePath);
|
|
46
|
+
yield compiler.compileOnWorkspace();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
exports.mockComponents = mockComponents;
|
|
50
|
+
//# sourceMappingURL=mock-components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-components.js","sourceRoot":"","sources":["../mock-components.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAiE;AACjE,sFAAkE;AAClE,mEAAgE;AAChE,wDAA0B;AAC1B,gEAAsC;AACtC,gDAAwB;AAExB;;;GAGG;AACH,SAAsB,cAAc,CAAC,aAAqB,EAAE,EAAE,eAAe,GAAG,CAAC,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,EAAE;;QAC1G,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,EAAE;YACvB,IAAI,KAAK,KAAK,eAAe;gBAAE,OAAO,+BAA+B,KAAK,GAAG,aAAa,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,SAAS,GAAc,MAAM,IAAA,wCAAU,EAAC,mBAAe,EAAE,aAAa,CAAC,CAAC;QAC9E,MAAM,kBAAkB,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7D,MAAM,IAAA,sBAAU,EAAC,kBAAkB,EAAE,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;YACtD,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,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAA,CAAC,CAAC;QACH,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/B,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAEvC,MAAM,QAAQ,GAAiB,MAAM,IAAA,wCAAU,EAAC,yBAAc,EAAE,aAAa,CAAC,CAAC;QAC/E,MAAM,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACtC,CAAC;CAAA;AArBD,wCAqBC"}
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mockComponents } from './mock-components';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CompilerAspect, CompilerMain } from '@teambit/compiler';
|
|
2
|
+
import { loadAspect } from '@teambit/harmony.testing.load-aspect';
|
|
3
|
+
import WorkspaceAspect, { Workspace } from '@teambit/workspace';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import pMapSeries from 'p-map-series';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* create dummy components, add, link and compile them.
|
|
10
|
+
* if `numOfComponents` is more than one, the components will depend on each other.
|
|
11
|
+
*/
|
|
12
|
+
export async function mockComponents(workspacePath: string, { numOfComponents = 1, additionalStr = '' } = {}) {
|
|
13
|
+
const getImp = (index) => {
|
|
14
|
+
if (index === numOfComponents) return `module.exports = () => 'comp${index}${additionalStr}';`;
|
|
15
|
+
const nextComp = `comp${index + 1}`;
|
|
16
|
+
return `const ${nextComp} = require('../${nextComp}');
|
|
17
|
+
module.exports = () => 'comp${index}${additionalStr} and ' + ${nextComp}();`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const workspace: Workspace = await loadAspect(WorkspaceAspect, workspacePath);
|
|
21
|
+
const numOfComponentsArr = Array(numOfComponents).fill(null);
|
|
22
|
+
await pMapSeries(numOfComponentsArr, async (val, key) => {
|
|
23
|
+
const i = key + 1;
|
|
24
|
+
const compDir = path.join(workspacePath, `comp${i}`);
|
|
25
|
+
await fs.outputFile(path.join(compDir, `index.js`), getImp(i));
|
|
26
|
+
await workspace.track({ rootDir: compDir });
|
|
27
|
+
});
|
|
28
|
+
await workspace.bitMap.write();
|
|
29
|
+
await workspace.link({ rewire: true });
|
|
30
|
+
|
|
31
|
+
const compiler: CompilerMain = await loadAspect(CompilerAspect, workspacePath);
|
|
32
|
+
await compiler.compileOnWorkspace();
|
|
33
|
+
}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/component.testing.mock-components",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"componentId": {
|
|
6
|
+
"scope": "teambit.component",
|
|
7
|
+
"name": "testing/mock-components",
|
|
8
|
+
"version": "0.0.2"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"fs-extra": "10.0.0",
|
|
12
|
+
"p-map-series": "2.1.0",
|
|
13
|
+
"@teambit/harmony.testing.load-aspect": "0.0.2"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/fs-extra": "9.0.7",
|
|
17
|
+
"@types/mocha": "5.2.7",
|
|
18
|
+
"@babel/runtime": "7.12.18",
|
|
19
|
+
"@types/node": "12.20.4",
|
|
20
|
+
"@types/jest": "26.0.20"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"bit": {
|
|
25
|
+
"bindingPrefix": "@teambit",
|
|
26
|
+
"env": {},
|
|
27
|
+
"overrides": {
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@teambit/legacy": "-"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@teambit/legacy": "-",
|
|
33
|
+
"@types/mocha": "5.2.7",
|
|
34
|
+
"@babel/runtime": "7.12.18",
|
|
35
|
+
"@types/node": "12.20.4",
|
|
36
|
+
"@types/jest": "26.0.20"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"private": false,
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=12.22.0"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/teambit/bit"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"bit",
|
|
50
|
+
"components",
|
|
51
|
+
"collaboration",
|
|
52
|
+
"web",
|
|
53
|
+
"react",
|
|
54
|
+
"react-components",
|
|
55
|
+
"angular",
|
|
56
|
+
"angular-components",
|
|
57
|
+
"vue",
|
|
58
|
+
"vue-components"
|
|
59
|
+
]
|
|
60
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [
|
|
4
|
+
"es2019",
|
|
5
|
+
"DOM",
|
|
6
|
+
"ES6",
|
|
7
|
+
"DOM.Iterable"
|
|
8
|
+
],
|
|
9
|
+
"target": "es2015",
|
|
10
|
+
"module": "commonjs",
|
|
11
|
+
"jsx": "react",
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"composite": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"outDir": "dist",
|
|
18
|
+
"moduleResolution": "node",
|
|
19
|
+
"esModuleInterop": true,
|
|
20
|
+
"rootDir": ".",
|
|
21
|
+
"resolveJsonModule": true
|
|
22
|
+
},
|
|
23
|
+
"exclude": [
|
|
24
|
+
"dist"
|
|
25
|
+
]
|
|
26
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|