@teambit/workspace 0.0.532 → 0.0.536

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/workspace",
3
- "version": "0.0.532",
3
+ "version": "0.0.536",
4
4
  "homepage": "https://bit.dev/teambit/workspace/workspace",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.workspace",
8
8
  "name": "workspace",
9
- "version": "0.0.532"
9
+ "version": "0.0.536"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -33,53 +33,53 @@
33
33
  "@teambit/base-ui.surfaces.split-pane.split-pane": "1.0.0",
34
34
  "@teambit/base-ui.graph.tree.recursive-tree": "1.0.0",
35
35
  "@teambit/cli": "0.0.380",
36
- "@teambit/isolator": "0.0.532",
36
+ "@teambit/isolator": "0.0.536",
37
37
  "@teambit/component-tree": "0.0.366",
38
- "@teambit/component.ui.component-status-resolver": "0.0.454",
39
- "@teambit/harmony.modules.resolved-component": "0.0.448",
40
- "@teambit/dependency-resolver": "0.0.532",
41
- "@teambit/logger": "0.0.456",
42
- "@teambit/compiler": "0.0.532",
43
- "@teambit/component": "0.0.532",
44
- "@teambit/graphql": "0.0.532",
45
- "@teambit/aspect-loader": "0.0.532",
46
- "@teambit/bundler": "0.0.532",
47
- "@teambit/envs": "0.0.532",
48
- "@teambit/pubsub": "0.0.532",
49
- "@teambit/scope": "0.0.532",
50
- "@teambit/ui": "0.0.532",
51
- "@teambit/variants": "0.0.458",
38
+ "@teambit/component.ui.component-status-resolver": "0.0.455",
39
+ "@teambit/harmony.modules.resolved-component": "0.0.449",
40
+ "@teambit/dependency-resolver": "0.0.536",
41
+ "@teambit/logger": "0.0.457",
42
+ "@teambit/compiler": "0.0.536",
43
+ "@teambit/component": "0.0.536",
44
+ "@teambit/graphql": "0.0.536",
45
+ "@teambit/aspect-loader": "0.0.536",
46
+ "@teambit/bundler": "0.0.536",
47
+ "@teambit/envs": "0.0.536",
48
+ "@teambit/pubsub": "0.0.536",
49
+ "@teambit/scope": "0.0.536",
50
+ "@teambit/ui": "0.0.536",
51
+ "@teambit/variants": "0.0.459",
52
52
  "@teambit/legacy-bit-id": "0.0.369",
53
53
  "@teambit/bit-error": "0.0.366",
54
54
  "@teambit/component-issues": "0.0.15",
55
55
  "@teambit/config": "0.0.391",
56
- "@teambit/harmony.modules.requireable-component": "0.0.448",
57
- "@teambit/workspace.modules.match-pattern": "0.0.450",
58
- "@teambit/command-bar": "0.0.532",
56
+ "@teambit/harmony.modules.requireable-component": "0.0.449",
57
+ "@teambit/workspace.modules.match-pattern": "0.0.451",
58
+ "@teambit/command-bar": "0.0.536",
59
59
  "@teambit/design.ui.surfaces.menu.link-item": "0.0.374",
60
- "@teambit/graph": "0.0.532",
61
- "@teambit/react-router": "0.0.532",
62
- "@teambit/sidebar": "0.0.532",
63
- "@teambit/ui-foundation.ui.main-dropdown": "0.0.450",
64
- "@teambit/ui-foundation.ui.menu": "0.0.450",
65
- "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.452",
66
- "@teambit/toolbox.time.time-format": "0.0.447",
60
+ "@teambit/graph": "0.0.536",
61
+ "@teambit/react-router": "0.0.536",
62
+ "@teambit/sidebar": "0.0.536",
63
+ "@teambit/ui-foundation.ui.main-dropdown": "0.0.451",
64
+ "@teambit/ui-foundation.ui.menu": "0.0.451",
65
+ "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.453",
66
+ "@teambit/toolbox.time.time-format": "0.0.448",
67
67
  "@teambit/component-id": "0.0.370",
68
- "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.451",
69
- "@teambit/deprecation": "0.0.532",
70
- "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.450",
71
- "@teambit/ui-foundation.ui.buttons.collapser": "0.0.155",
72
- "@teambit/ui-foundation.ui.corner": "0.0.457",
73
- "@teambit/ui-foundation.ui.notifications.notification-context": "0.0.451",
74
- "@teambit/ui-foundation.ui.top-bar": "0.0.452",
68
+ "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.452",
69
+ "@teambit/deprecation": "0.0.536",
70
+ "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.451",
71
+ "@teambit/ui-foundation.ui.buttons.collapser": "0.0.156",
72
+ "@teambit/ui-foundation.ui.corner": "0.0.458",
73
+ "@teambit/ui-foundation.ui.notifications.notification-context": "0.0.452",
74
+ "@teambit/ui-foundation.ui.top-bar": "0.0.453",
75
75
  "@teambit/design.ui.styles.ellipsis": "0.0.346",
76
76
  "@teambit/design.ui.styles.muted-italic": "0.0.35",
77
- "@teambit/ui-foundation.ui.full-loader": "0.0.450",
78
- "@teambit/ui-foundation.ui.side-bar": "0.0.454",
79
- "@teambit/ui-foundation.ui.tree.drawer": "0.0.450",
80
- "@teambit/explorer.ui.gallery.component-grid": "0.0.450",
81
- "@teambit/workspace.ui.empty-workspace": "0.0.452",
82
- "@teambit/workspace.ui.workspace-component-card": "0.0.453"
77
+ "@teambit/ui-foundation.ui.full-loader": "0.0.451",
78
+ "@teambit/ui-foundation.ui.side-bar": "0.0.455",
79
+ "@teambit/ui-foundation.ui.tree.drawer": "0.0.451",
80
+ "@teambit/explorer.ui.gallery.component-grid": "0.0.451",
81
+ "@teambit/workspace.ui.empty-workspace": "0.0.453",
82
+ "@teambit/workspace.ui.workspace-component-card": "0.0.454"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@types/react": "^17.0.8",
@@ -0,0 +1,5 @@
1
+ export enum CheckTypes {
2
+ None, // keep this. it equals zero. this way we can do "if checkTypes() ... "
3
+ EntireProject,
4
+ ChangedFile,
5
+ }
@@ -1,6 +1,5 @@
1
1
  import chalk from 'chalk';
2
2
  import moment from 'moment';
3
-
4
3
  import { Command, CommandOptions } from '@teambit/cli';
5
4
  import type { Logger } from '@teambit/logger';
6
5
  import type { BitBaseEvent, PubsubMain } from '@teambit/pubsub';
@@ -11,11 +10,12 @@ import { CompilerAspect, CompilerErrorEvent } from '@teambit/compiler';
11
10
  import { Watcher, WatchOptions } from './watcher';
12
11
  import { formatCompileResults, formatWatchPathsSortByComponent } from './output-formatter';
13
12
  import { OnComponentEventResult } from '../on-component-events';
13
+ import { CheckTypes } from './check-types';
14
14
 
15
15
  export type WatchCmdOpts = {
16
16
  verbose?: boolean;
17
17
  skipPreCompilation?: boolean;
18
- checkTypes?: boolean;
18
+ checkTypes?: string | boolean;
19
19
  };
20
20
 
21
21
  export class WatchCommand implements Command {
@@ -23,8 +23,7 @@ export class WatchCommand implements Command {
23
23
  onAll: (event, path) => this.logger.console(`Event: "${event}". Path: ${path}`),
24
24
  onStart: () => {},
25
25
  onReady: (workspace, watchPathsSortByComponent, verbose) => {
26
- // eslint-disable-next-line no-console
27
- console.clear();
26
+ clearOutdatedData();
28
27
  if (verbose) {
29
28
  this.logger.console(formatWatchPathsSortByComponent(watchPathsSortByComponent));
30
29
  }
@@ -35,8 +34,7 @@ export class WatchCommand implements Command {
35
34
  );
36
35
  },
37
36
  onChange: (filePath: string, buildResults: OnComponentEventResult[], verbose: boolean, duration) => {
38
- // eslint-disable-next-line no-console
39
- console.clear();
37
+ clearOutdatedData();
40
38
  if (!buildResults.length) {
41
39
  this.logger.console(`The file ${filePath} has been changed, but nothing to compile.\n\n`);
42
40
  return;
@@ -47,8 +45,7 @@ export class WatchCommand implements Command {
47
45
  this.logger.console(chalk.yellow(`Watching for component changes (${moment().format('HH:mm:ss')})...`));
48
46
  },
49
47
  onAdd: (filePath: string, buildResults: OnComponentEventResult[], verbose: boolean, duration) => {
50
- // eslint-disable-next-line no-console
51
- console.clear();
48
+ clearOutdatedData();
52
49
  this.logger.console(`The file ${filePath} has been added.\n\n`);
53
50
  this.logger.console(formatCompileResults(buildResults, verbose));
54
51
  this.logger.console(`Finished. (${duration}ms)`);
@@ -70,7 +67,11 @@ export class WatchCommand implements Command {
70
67
  options = [
71
68
  ['v', 'verbose', 'showing npm verbose output for inspection and prints stack trace'],
72
69
  ['', 'skip-pre-compilation', 'skip the compilation step before starting to watch'],
73
- ['t', 'check-types', 'EXPERIMENTAL. for typescript files, load an tsserver instance to check types'],
70
+ [
71
+ 't',
72
+ 'check-types [string]',
73
+ 'EXPERIMENTAL. show errors/warnings for types. options are [file, project] to investigate only changed file or entire project. defaults to project',
74
+ ],
74
75
  ] as CommandOptions;
75
76
 
76
77
  constructor(
@@ -107,14 +108,35 @@ export class WatchCommand implements Command {
107
108
 
108
109
  async report(cliArgs: [], watchCmdOpts: WatchCmdOpts) {
109
110
  const { verbose, checkTypes } = watchCmdOpts;
111
+ const getCheckTypesEnum = () => {
112
+ switch (checkTypes) {
113
+ case undefined:
114
+ case false:
115
+ return CheckTypes.None;
116
+ case 'project':
117
+ case true: // project is the default
118
+ return CheckTypes.EntireProject;
119
+ case 'file':
120
+ return CheckTypes.ChangedFile;
121
+ default:
122
+ throw new Error(`check-types can be either "file" or "project". got "${checkTypes}"`);
123
+ }
124
+ };
110
125
  const watchOpts: WatchOptions = {
111
126
  msgs: this.msgs,
112
127
  verbose,
113
128
  preCompile: !watchCmdOpts.skipPreCompilation,
114
- spawnTSServer: checkTypes, // if check-types is enabled, it must spawn the tsserver.
115
- checkTypes,
129
+ spawnTSServer: Boolean(checkTypes), // if check-types is enabled, it must spawn the tsserver.
130
+ checkTypes: getCheckTypesEnum(),
116
131
  };
117
132
  await this.watcher.watchAll(watchOpts);
118
133
  return 'watcher terminated';
119
134
  }
120
135
  }
136
+
137
+ /**
138
+ * with console.clear() all history is deleted from the console. this function preserver the history.
139
+ */
140
+ function clearOutdatedData() {
141
+ process.stdout.write('\x1Bc');
142
+ }
package/watch/watcher.ts CHANGED
@@ -19,6 +19,7 @@ import { WorkspaceAspect } from '../';
19
19
  import { OnComponentChangeEvent, OnComponentAddEvent, OnComponentRemovedEvent } from '../events';
20
20
  import { Workspace } from '../workspace';
21
21
  import { OnComponentEventResult } from '../on-component-events';
22
+ import { CheckTypes } from './check-types';
22
23
 
23
24
  export type WatcherProcessData = { watchProcess: ChildProcess; compilerId: BitId; componentIds: BitId[] };
24
25
 
@@ -27,7 +28,7 @@ export type WatchOptions = {
27
28
  initiator?: CompilationInitiator;
28
29
  verbose?: boolean; // print watch events to the console. (also ts-server events if spawnTSServer is true)
29
30
  spawnTSServer?: boolean; // needed for check types and extract API/docs.
30
- checkTypes?: boolean; // if enabled, the spawnTSServer becomes true.
31
+ checkTypes?: CheckTypes; // if enabled, the spawnTSServer becomes true.
31
32
  preCompile?: boolean; // whether compile all components before start watching
32
33
  };
33
34
 
package/workspace.ts CHANGED
@@ -631,7 +631,7 @@ export class Workspace implements ComponentFactory {
631
631
  const addResults = await addComponent.add();
632
632
  // @todo: the legacy commands have `consumer.onDestroy()` on command completion, it writes the
633
633
  // .bitmap file. workspace needs a similar mechanism. once done, remove the next line.
634
- await this.consumer.bitMap.write(this.consumer.componentFsCache);
634
+ await this.writeBitMap();
635
635
  return addResults;
636
636
  }
637
637
 
@@ -1287,17 +1287,15 @@ your workspace.jsonc has this component-id set. you might want to remove/change
1287
1287
  verbose: false,
1288
1288
  merge: false,
1289
1289
  objectsOnly: true,
1290
- withEnvironments: false,
1291
1290
  override: false,
1292
1291
  writeDists: false,
1293
1292
  writeConfig: false,
1294
1293
  installNpmPackages: false,
1295
- writePackageJson: false,
1296
1294
  importDependenciesDirectly: false,
1297
1295
  importDependents: false,
1298
1296
  };
1299
1297
  try {
1300
- const res = await importAction({ tester: false, compiler: false }, importOptions, []);
1298
+ const res = await importAction(importOptions, []);
1301
1299
  return res;
1302
1300
  } catch (err: any) {
1303
1301
  // TODO: this is a hack since the legacy throw an error, we should provide a way to not throw this error from the legacy