@teambit/workspace.testing.mock-workspace 0.0.26 → 0.0.27

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.
@@ -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>;
@@ -17,10 +17,13 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
17
17
  const path_1 = __importDefault(require("path"));
18
18
  const e2e_helper_1 = __importDefault(require("@teambit/legacy/dist/e2e-helper/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
29
  const legacyHelper = new e2e_helper_1.default();
@@ -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,
@@ -43,14 +50,22 @@ exports.mockWorkspace = mockWorkspace;
43
50
  function mockBareScope(remoteToAdd, scopeNameSuffix) {
44
51
  const legacyHelper = new e2e_helper_1.default();
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,4FAAsE;AACtE,+CAAwD;AAIxD;;;;GAIG;AACH,SAAgB,aAAa,CAAC,OAAmC,EAAE;IACjE,MAAM,YAAY,GAAG,IAAI,oBAAY,EAAE,CAAC;IACxC,IAAI,IAAI,CAAC,aAAa,EAAE;QACtB,YAAY,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC;QAC5C,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7E,YAAY,CAAC,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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
@@ -5,10 +5,14 @@ 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,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/workspace.testing.mock-workspace",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
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.26"
9
+ "version": "0.0.27"
10
10
  },
11
11
  "dependencies": {
12
12
  "comment-json": "3.0.3",