@teambit/workspace.testing.mock-workspace 0.0.26 → 0.0.28
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/mock-workspace.d.ts +5 -1
- package/dist/mock-workspace.js +18 -3
- package/dist/mock-workspace.js.map +1 -1
- package/mock-workspace.ts +17 -1
- package/package.json +4 -3
- package/dist/tsconfig.json +0 -32
- package/tsconfig.json +0 -32
- /package/dist/{preview-1708466611462.js → preview-1733830651067.js} +0 -0
package/dist/mock-workspace.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type WorkspaceData = {
|
|
2
2
|
workspacePath: string;
|
|
3
3
|
remoteScopePath: string;
|
|
4
4
|
remoteScopeName: string;
|
|
@@ -7,6 +7,8 @@ export declare type WorkspaceData = {
|
|
|
7
7
|
* setup a new workspace on a temp directory and setup a bare-scope locally to simulate a remote scope for commands
|
|
8
8
|
* such as `bit export`.
|
|
9
9
|
* call `destroyWorkspace()` once the tests completed to keep the filesystem clean.
|
|
10
|
+
*
|
|
11
|
+
* to print the path of the workspace, run the tests with `--debug` flag.
|
|
10
12
|
*/
|
|
11
13
|
export declare function mockWorkspace(opts?: {
|
|
12
14
|
bareScopeName?: string;
|
|
@@ -17,6 +19,8 @@ export declare function mockBareScope(remoteToAdd: string, scopeNameSuffix?: str
|
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
19
21
|
* deletes the paths created by mockWorkspace. pass the results you got from `mockWorkspace()`
|
|
22
|
+
*
|
|
23
|
+
* to keep the workspace and the remote scope, run the tests with `--debug` flag.
|
|
20
24
|
*/
|
|
21
25
|
export declare function destroyWorkspace(workspaceData: WorkspaceData): Promise<void>;
|
|
22
26
|
export declare function setWorkspaceConfig(workspacePath: string, key: string, val: any): Promise<void>;
|
package/dist/mock-workspace.js
CHANGED
|
@@ -15,15 +15,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.setWorkspaceConfig = exports.destroyWorkspace = exports.mockBareScope = exports.mockWorkspace = void 0;
|
|
16
16
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
|
-
const
|
|
18
|
+
const legacy_e2e_helper_1 = require("@teambit/legacy.e2e-helper");
|
|
19
19
|
const comment_json_1 = require("comment-json");
|
|
20
|
+
const isDebugMode = () => process.argv.includes('--debug');
|
|
20
21
|
/**
|
|
21
22
|
* setup a new workspace on a temp directory and setup a bare-scope locally to simulate a remote scope for commands
|
|
22
23
|
* such as `bit export`.
|
|
23
24
|
* call `destroyWorkspace()` once the tests completed to keep the filesystem clean.
|
|
25
|
+
*
|
|
26
|
+
* to print the path of the workspace, run the tests with `--debug` flag.
|
|
24
27
|
*/
|
|
25
28
|
function mockWorkspace(opts = {}) {
|
|
26
|
-
const legacyHelper = new
|
|
29
|
+
const legacyHelper = new legacy_e2e_helper_1.Helper();
|
|
27
30
|
if (opts.bareScopeName) {
|
|
28
31
|
legacyHelper.scopeHelper.reInitLocalScope();
|
|
29
32
|
legacyHelper.scopes.setRemoteScope(undefined, undefined, opts.bareScopeName);
|
|
@@ -33,6 +36,10 @@ function mockWorkspace(opts = {}) {
|
|
|
33
36
|
legacyHelper.scopeHelper.setNewLocalAndRemoteScopes();
|
|
34
37
|
}
|
|
35
38
|
legacyHelper.workspaceJsonc.setupDefault();
|
|
39
|
+
if (isDebugMode()) {
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
console.log('workspace created at ', legacyHelper.scopes.localPath);
|
|
42
|
+
}
|
|
36
43
|
return {
|
|
37
44
|
workspacePath: legacyHelper.scopes.localPath,
|
|
38
45
|
remoteScopePath: legacyHelper.scopes.remotePath,
|
|
@@ -41,16 +48,24 @@ function mockWorkspace(opts = {}) {
|
|
|
41
48
|
}
|
|
42
49
|
exports.mockWorkspace = mockWorkspace;
|
|
43
50
|
function mockBareScope(remoteToAdd, scopeNameSuffix) {
|
|
44
|
-
const legacyHelper = new
|
|
51
|
+
const legacyHelper = new legacy_e2e_helper_1.Helper();
|
|
45
52
|
const { scopeName, scopePath } = legacyHelper.scopeHelper.getNewBareScope(scopeNameSuffix, undefined, remoteToAdd);
|
|
53
|
+
if (isDebugMode()) {
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
55
|
+
console.log('base-scope created at ', scopePath);
|
|
56
|
+
}
|
|
46
57
|
return { scopeName, scopePath };
|
|
47
58
|
}
|
|
48
59
|
exports.mockBareScope = mockBareScope;
|
|
49
60
|
/**
|
|
50
61
|
* deletes the paths created by mockWorkspace. pass the results you got from `mockWorkspace()`
|
|
62
|
+
*
|
|
63
|
+
* to keep the workspace and the remote scope, run the tests with `--debug` flag.
|
|
51
64
|
*/
|
|
52
65
|
function destroyWorkspace(workspaceData) {
|
|
53
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
if (isDebugMode())
|
|
68
|
+
return;
|
|
54
69
|
const { workspacePath, remoteScopePath } = workspaceData;
|
|
55
70
|
yield Promise.all([workspacePath, remoteScopePath].map((_) => fs_extra_1.default.remove(_)));
|
|
56
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-workspace.js","sourceRoot":"","sources":["../mock-workspace.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"mock-workspace.js","sourceRoot":"","sources":["../mock-workspace.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AACxB,kEAAoE;AACpE,+CAAwD;AAIxD,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,OAAmC,EAAE;IACjE,MAAM,YAAY,GAAG,IAAI,0BAAY,EAAE,CAAC;IACxC,IAAI,IA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AAE,eAAe,EAAE,GAAG,aAAa,CAAC;QACzD,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC;CAAA;AAJD,4CAIC;AAED,SAAsB,kBAAkB,CAAC,aAAqB,EAAE,GAAW,EAAE,GAAQ;;QACnF,MAAM,mBAAmB,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;QACxE,MAAM,OAAO,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,eAAe,GAAG,IAAA,oBAAK,EAAC,OAAO,CAAC,CAAC;QACvC,MAAM,GAAG,GAAG;YACV,CAAC,GAAG,CAAC,EAAE,GAAG;SACX,CAAC;QACF,MAAM,OAAO,GAAG,IAAA,qBAAM,EAAC,eAAe,EAAE,GAAG,CAAC,CAAC;QAC7C,MAAM,cAAc,GAAG,IAAA,wBAAS,EAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnD,MAAM,kBAAE,CAAC,SAAS,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;CAAA;AAVD,gDAUC"}
|
package/mock-workspace.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import LegacyHelper from '@teambit/legacy
|
|
3
|
+
import { Helper as LegacyHelper } from '@teambit/legacy.e2e-helper';
|
|
4
4
|
import { assign, parse, stringify } from 'comment-json';
|
|
5
5
|
|
|
6
6
|
export type WorkspaceData = { workspacePath: string; remoteScopePath: string; remoteScopeName: string };
|
|
7
7
|
|
|
8
|
+
const isDebugMode = () => process.argv.includes('--debug');
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* setup a new workspace on a temp directory and setup a bare-scope locally to simulate a remote scope for commands
|
|
10
12
|
* such as `bit export`.
|
|
11
13
|
* call `destroyWorkspace()` once the tests completed to keep the filesystem clean.
|
|
14
|
+
*
|
|
15
|
+
* to print the path of the workspace, run the tests with `--debug` flag.
|
|
12
16
|
*/
|
|
13
17
|
export function mockWorkspace(opts: { bareScopeName?: string } = {}): WorkspaceData {
|
|
14
18
|
const legacyHelper = new LegacyHelper();
|
|
@@ -20,6 +24,10 @@ export function mockWorkspace(opts: { bareScopeName?: string } = {}): WorkspaceD
|
|
|
20
24
|
legacyHelper.scopeHelper.setNewLocalAndRemoteScopes();
|
|
21
25
|
}
|
|
22
26
|
legacyHelper.workspaceJsonc.setupDefault();
|
|
27
|
+
if (isDebugMode()) {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.log('workspace created at ', legacyHelper.scopes.localPath);
|
|
30
|
+
}
|
|
23
31
|
|
|
24
32
|
return {
|
|
25
33
|
workspacePath: legacyHelper.scopes.localPath,
|
|
@@ -31,13 +39,21 @@ export function mockWorkspace(opts: { bareScopeName?: string } = {}): WorkspaceD
|
|
|
31
39
|
export function mockBareScope(remoteToAdd: string, scopeNameSuffix?: string) {
|
|
32
40
|
const legacyHelper = new LegacyHelper();
|
|
33
41
|
const { scopeName, scopePath } = legacyHelper.scopeHelper.getNewBareScope(scopeNameSuffix, undefined, remoteToAdd);
|
|
42
|
+
if (isDebugMode()) {
|
|
43
|
+
// eslint-disable-next-line no-console
|
|
44
|
+
console.log('base-scope created at ', scopePath);
|
|
45
|
+
}
|
|
46
|
+
|
|
34
47
|
return { scopeName, scopePath };
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
/**
|
|
38
51
|
* deletes the paths created by mockWorkspace. pass the results you got from `mockWorkspace()`
|
|
52
|
+
*
|
|
53
|
+
* to keep the workspace and the remote scope, run the tests with `--debug` flag.
|
|
39
54
|
*/
|
|
40
55
|
export async function destroyWorkspace(workspaceData: WorkspaceData) {
|
|
56
|
+
if (isDebugMode()) return;
|
|
41
57
|
const { workspacePath, remoteScopePath } = workspaceData;
|
|
42
58
|
await Promise.all([workspacePath, remoteScopePath].map((_) => fs.remove(_)));
|
|
43
59
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/workspace.testing.mock-workspace",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/workspace/testing/mock-workspace",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.workspace",
|
|
8
8
|
"name": "testing/mock-workspace",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.28"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"comment-json": "3.0.3",
|
|
13
|
-
"fs-extra": "10.0.0"
|
|
13
|
+
"fs-extra": "10.0.0",
|
|
14
|
+
"@teambit/legacy.e2e-helper": "0.0.1"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/fs-extra": "9.0.7",
|
package/dist/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
"experimentalDecorators": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
|
-
"moduleResolution": "node",
|
|
20
|
-
"esModuleInterop": true,
|
|
21
|
-
"rootDir": ".",
|
|
22
|
-
"resolveJsonModule": true
|
|
23
|
-
},
|
|
24
|
-
"exclude": [
|
|
25
|
-
"dist",
|
|
26
|
-
"package.json"
|
|
27
|
-
],
|
|
28
|
-
"include": [
|
|
29
|
-
"**/*",
|
|
30
|
-
"**/*.json"
|
|
31
|
-
]
|
|
32
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
"experimentalDecorators": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
|
-
"moduleResolution": "node",
|
|
20
|
-
"esModuleInterop": true,
|
|
21
|
-
"rootDir": ".",
|
|
22
|
-
"resolveJsonModule": true
|
|
23
|
-
},
|
|
24
|
-
"exclude": [
|
|
25
|
-
"dist",
|
|
26
|
-
"package.json"
|
|
27
|
-
],
|
|
28
|
-
"include": [
|
|
29
|
-
"**/*",
|
|
30
|
-
"**/*.json"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
File without changes
|