@teambit/workspace 0.0.881 → 0.0.883

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.
Files changed (108) hide show
  1. package/dist/bit-map.js +10 -51
  2. package/dist/bit-map.js.map +1 -1
  3. package/dist/build-graph-from-fs.js +1 -53
  4. package/dist/build-graph-from-fs.js.map +1 -1
  5. package/dist/capsule.cmd.js +2 -34
  6. package/dist/capsule.cmd.js.map +1 -1
  7. package/dist/component-config-file/component-config-file.js +2 -60
  8. package/dist/component-config-file/component-config-file.js.map +1 -1
  9. package/dist/component-config-file/exceptions/already-exists.js +0 -6
  10. package/dist/component-config-file/exceptions/already-exists.js.map +1 -1
  11. package/dist/component-config-file/exceptions/index.js +0 -3
  12. package/dist/component-config-file/exceptions/index.js.map +1 -1
  13. package/dist/component-config-file/index.js +0 -6
  14. package/dist/component-config-file/index.js.map +1 -1
  15. package/dist/component-tree.widget.js +0 -18
  16. package/dist/component-tree.widget.js.map +1 -1
  17. package/dist/constants.js.map +1 -1
  18. package/dist/eject-conf.cmd.js +0 -23
  19. package/dist/eject-conf.cmd.js.map +1 -1
  20. package/dist/envs-subcommands/envs-replace.cmd.js +0 -13
  21. package/dist/envs-subcommands/envs-replace.cmd.js.map +1 -1
  22. package/dist/envs-subcommands/envs-set.cmd.js +0 -16
  23. package/dist/envs-subcommands/envs-set.cmd.js.map +1 -1
  24. package/dist/envs-subcommands/envs-unset.cmd.js +0 -18
  25. package/dist/envs-subcommands/envs-unset.cmd.js.map +1 -1
  26. package/dist/events/index.js +0 -6
  27. package/dist/events/index.js.map +1 -1
  28. package/dist/events/on-component-add-event.js +1 -12
  29. package/dist/events/on-component-add-event.js.map +1 -1
  30. package/dist/events/on-component-change-event.js +1 -12
  31. package/dist/events/on-component-change-event.js.map +1 -1
  32. package/dist/events/on-component-removed-event.js +1 -12
  33. package/dist/events/on-component-removed-event.js.map +1 -1
  34. package/dist/exceptions/incorrect-env-aspect.js +0 -6
  35. package/dist/exceptions/incorrect-env-aspect.js.map +1 -1
  36. package/dist/index.js +0 -19
  37. package/dist/index.js.map +1 -1
  38. package/dist/list.cmd.js +2 -15
  39. package/dist/list.cmd.js.map +1 -1
  40. package/dist/pattern.cmd.js +0 -16
  41. package/dist/pattern.cmd.js.map +1 -1
  42. package/dist/scope-subcommands/scope-set.cmd.js +0 -17
  43. package/dist/scope-subcommands/scope-set.cmd.js.map +1 -1
  44. package/dist/ui/index.js +0 -3
  45. package/dist/ui/index.js.map +1 -1
  46. package/dist/ui/workspace/default-component.js.map +1 -1
  47. package/dist/ui/workspace/index.js +0 -2
  48. package/dist/ui/workspace/index.js.map +1 -1
  49. package/dist/ui/workspace/use-workspace.js +14 -49
  50. package/dist/ui/workspace/use-workspace.js.map +1 -1
  51. package/dist/ui/workspace/workspace-context.js +0 -7
  52. package/dist/ui/workspace/workspace-context.js.map +1 -1
  53. package/dist/ui/workspace/workspace-model.js +2 -14
  54. package/dist/ui/workspace/workspace-model.js.map +1 -1
  55. package/dist/ui/workspace/workspace-overview/index.js +0 -3
  56. package/dist/ui/workspace/workspace-overview/index.js.map +1 -1
  57. package/dist/ui/workspace/workspace-overview/workspace-overview.js +0 -23
  58. package/dist/ui/workspace/workspace-overview/workspace-overview.js.map +1 -1
  59. package/dist/ui/workspace/workspace-provider.js +0 -8
  60. package/dist/ui/workspace/workspace-provider.js.map +1 -1
  61. package/dist/ui/workspace/workspace.js +2 -52
  62. package/dist/ui/workspace/workspace.js.map +1 -1
  63. package/dist/use.cmd.js +0 -13
  64. package/dist/use.cmd.js.map +1 -1
  65. package/dist/watch/check-types.js +0 -1
  66. package/dist/watch/check-types.js.map +1 -1
  67. package/dist/watch/output-formatter.js +1 -12
  68. package/dist/watch/output-formatter.js.map +1 -1
  69. package/dist/watch/watch-queue.js +0 -13
  70. package/dist/watch/watch-queue.js.map +1 -1
  71. package/dist/watch/watch.cmd.js +6 -41
  72. package/dist/watch/watch.cmd.js.map +1 -1
  73. package/dist/watch/watcher.js +13 -133
  74. package/dist/watch/watcher.js.map +1 -1
  75. package/dist/workspace-component/component-status.js +0 -4
  76. package/dist/workspace-component/component-status.js.map +1 -1
  77. package/dist/workspace-component/index.js +0 -6
  78. package/dist/workspace-component/index.js.map +1 -1
  79. package/dist/workspace-component/workspace-component-loader.js +31 -116
  80. package/dist/workspace-component/workspace-component-loader.js.map +1 -1
  81. package/dist/workspace-component/workspace-component.js +1 -11
  82. package/dist/workspace-component/workspace-component.js.map +1 -1
  83. package/dist/workspace-section.js +2 -0
  84. package/dist/workspace-section.js.map +1 -1
  85. package/dist/workspace.aspect.js +0 -5
  86. package/dist/workspace.aspect.js.map +1 -1
  87. package/dist/workspace.composition.js +0 -6
  88. package/dist/workspace.composition.js.map +1 -1
  89. package/dist/workspace.d.ts +1 -0
  90. package/dist/workspace.graphql.js +0 -12
  91. package/dist/workspace.graphql.js.map +1 -1
  92. package/dist/workspace.js +141 -545
  93. package/dist/workspace.js.map +1 -1
  94. package/dist/workspace.main.runtime.js +0 -55
  95. package/dist/workspace.main.runtime.js.map +1 -1
  96. package/dist/workspace.provider.js +8 -77
  97. package/dist/workspace.provider.js.map +1 -1
  98. package/dist/workspace.ui-root.js +3 -17
  99. package/dist/workspace.ui-root.js.map +1 -1
  100. package/dist/workspace.ui.drawer.js +2 -24
  101. package/dist/workspace.ui.drawer.js.map +1 -1
  102. package/dist/workspace.ui.runtime.js +0 -75
  103. package/dist/workspace.ui.runtime.js.map +1 -1
  104. package/package-tar/teambit-workspace-0.0.883.tgz +0 -0
  105. package/package.json +18 -18
  106. package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
  107. package/workspace-component/workspace-component-loader.ts +13 -3
  108. package/package-tar/teambit-workspace-0.0.881.tgz +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["IncorrectEnvAspect","BitError","constructor","id","envType","envId"],"sources":["incorrect-env-aspect.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\n\nexport class IncorrectEnvAspect extends BitError {\n constructor(id: string, envType: string, envId: string) {\n super(`\"${id}\" is configured in workspace.json, but using the \"${envId}\" environment, which is type \"${envType}\".\nplease make sure to either apply the aspect environment or a composition of the aspect environment for the aspect to load.`);\n }\n}\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,kBAAN,SAAiCC,oBAAjC,CAA0C;EAC/CC,WAAW,CAACC,EAAD,EAAaC,OAAb,EAA8BC,KAA9B,EAA6C;IACtD,MAAO,IAAGF,EAAG,qDAAoDE,KAAM,iCAAgCD,OAAQ;AACnH,2HADI;EAED;;AAJ8C"}
1
+ {"version":3,"names":["IncorrectEnvAspect","BitError","constructor","id","envType","envId"],"sources":["incorrect-env-aspect.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\n\nexport class IncorrectEnvAspect extends BitError {\n constructor(id: string, envType: string, envId: string) {\n super(`\"${id}\" is configured in workspace.json, but using the \"${envId}\" environment, which is type \"${envType}\".\nplease make sure to either apply the aspect environment or a composition of the aspect environment for the aspect to load.`);\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,kBAAkB,SAASC,oBAAQ,CAAC;EAC/CC,WAAW,CAACC,EAAU,EAAEC,OAAe,EAAEC,KAAa,EAAE;IACtD,KAAK,CAAE,IAAGF,EAAG,qDAAoDE,KAAM,iCAAgCD,OAAQ;AACnH,2HAA2H,CAAC;EAC1H;AACF;AAAC"}
package/dist/index.js CHANGED
@@ -48,29 +48,21 @@ Object.defineProperty(exports, "WorkspaceModelComponent", {
48
48
  }
49
49
  });
50
50
  exports.default = void 0;
51
-
52
51
  function _workspace() {
53
52
  const data = require("./workspace.aspect");
54
-
55
53
  _workspace = function () {
56
54
  return data;
57
55
  };
58
-
59
56
  return data;
60
57
  }
61
-
62
58
  function _checkTypes() {
63
59
  const data = require("./watch/check-types");
64
-
65
60
  _checkTypes = function () {
66
61
  return data;
67
62
  };
68
-
69
63
  return data;
70
64
  }
71
-
72
65
  var _events = require("./events");
73
-
74
66
  Object.keys(_events).forEach(function (key) {
75
67
  if (key === "default" || key === "__esModule") return;
76
68
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -82,39 +74,28 @@ Object.keys(_events).forEach(function (key) {
82
74
  }
83
75
  });
84
76
  });
85
-
86
77
  function _workspaceComponent() {
87
78
  const data = require("./workspace-component");
88
-
89
79
  _workspaceComponent = function () {
90
80
  return data;
91
81
  };
92
-
93
82
  return data;
94
83
  }
95
-
96
84
  function _workspaceModel() {
97
85
  const data = require("./ui/workspace/workspace-model");
98
-
99
86
  _workspaceModel = function () {
100
87
  return data;
101
88
  };
102
-
103
89
  return data;
104
90
  }
105
-
106
91
  function _workspaceContext() {
107
92
  const data = require("./ui/workspace/workspace-context");
108
-
109
93
  _workspaceContext = function () {
110
94
  return data;
111
95
  };
112
-
113
96
  return data;
114
97
  }
115
-
116
98
  var _default = _workspace().WorkspaceAspect;
117
-
118
99
  exports.default = _default;
119
100
 
120
101
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["WorkspaceAspect"],"sources":["index.ts"],"sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace, ExtensionsOrigin } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport type { WatchOptions } from './watch/watcher';\nexport { CheckTypes } from './watch/check-types';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentLoad, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport { WorkspaceModelComponent, Workspace as WorkspaceModel } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport type { WorkspaceComponent } from './workspace-component';\nexport type { ComponentConfigFile } from './component-config-file';\n\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAQA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;eAKeA,4B"}
1
+ {"version":3,"names":["WorkspaceAspect"],"sources":["index.ts"],"sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace, ExtensionsOrigin } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport type { WatchOptions } from './watch/watcher';\nexport { CheckTypes } from './watch/check-types';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentLoad, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport { WorkspaceModelComponent, Workspace as WorkspaceModel } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport type { WorkspaceComponent } from './workspace-component';\nexport type { ComponentConfigFile } from './component-config-file';\n\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAoE,eAKrDA,4BAAe;AAAA"}
package/dist/list.cmd.js CHANGED
@@ -1,46 +1,36 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.promise.js");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.ListCmd = void 0;
11
-
12
9
  function _defineProperty2() {
13
10
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
11
  _defineProperty2 = function () {
16
12
  return data;
17
13
  };
18
-
19
14
  return data;
20
15
  }
21
-
22
16
  function _ink() {
23
17
  const data = require("ink");
24
-
25
18
  _ink = function () {
26
19
  return data;
27
20
  };
28
-
29
21
  return data;
30
22
  }
31
-
32
23
  function _react() {
33
24
  const data = _interopRequireDefault(require("react"));
34
-
35
25
  _react = function () {
36
26
  return data;
37
27
  };
38
-
39
28
  return data;
40
29
  }
41
-
42
30
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+
43
32
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+
44
34
  class ListCmd {
45
35
  constructor(workspace) {
46
36
  this.workspace = workspace;
@@ -51,7 +41,6 @@ class ListCmd {
51
41
  (0, _defineProperty2().default)(this, "alias", '');
52
42
  (0, _defineProperty2().default)(this, "options", []);
53
43
  }
54
-
55
44
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
56
45
  async render(params, options) {
57
46
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -60,9 +49,7 @@ class ListCmd {
60
49
  color: "green"
61
50
  }, "hi there");
62
51
  }
63
-
64
52
  }
65
-
66
53
  exports.ListCmd = ListCmd;
67
54
 
68
55
  //# sourceMappingURL=list.cmd.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ListCmd","constructor","workspace","render","params","options","list"],"sources":["list.cmd.tsx"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Command } from '@teambit/cli';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Text } from 'ink';\nimport React from 'react';\n\nimport { Workspace } from './workspace';\n\nexport class ListCmd implements Command {\n constructor(private workspace: Workspace) {}\n\n name = 'lister';\n\n description = 'list all components in the workspace';\n\n summery = 'a different text i dont really need';\n\n group = 'workspace';\n\n alias = '';\n\n options = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async render(params: any, options: { [key: string]: any }) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const list = await this.workspace.list();\n return <Text color=\"green\">hi there</Text>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAJA;AAEA;AAMO,MAAMA,OAAN,CAAiC;EACtCC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,8CAEnC,QAFmC;IAAA,qDAI5B,sCAJ4B;IAAA,iDAMhC,qCANgC;IAAA,+CAQlC,WARkC;IAAA,+CAUlC,EAVkC;IAAA,iDAYhC,EAZgC;EAAE;;EAc5C;EACY,MAANC,MAAM,CAACC,MAAD,EAAcC,OAAd,EAA+C;IACzD;IACA,MAAMC,IAAI,GAAG,MAAM,KAAKJ,SAAL,CAAeI,IAAf,EAAnB;IACA,oBAAO,+BAAC,WAAD;MAAM,KAAK,EAAC;IAAZ,cAAP;EACD;;AApBqC"}
1
+ {"version":3,"names":["ListCmd","constructor","workspace","render","params","options","list"],"sources":["list.cmd.tsx"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Command } from '@teambit/cli';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Text } from 'ink';\nimport React from 'react';\n\nimport { Workspace } from './workspace';\n\nexport class ListCmd implements Command {\n constructor(private workspace: Workspace) {}\n\n name = 'lister';\n\n description = 'list all components in the workspace';\n\n summery = 'a different text i dont really need';\n\n group = 'workspace';\n\n alias = '';\n\n options = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async render(params: any, options: { [key: string]: any }) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const list = await this.workspace.list();\n return <Text color=\"green\">hi there</Text>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAJA;;AAEA;;AAMO,MAAMA,OAAO,CAAoB;EACtCC,WAAW,CAASC,SAAoB,EAAE;IAAA,KAAtBA,SAAoB,GAApBA,SAAoB;IAAA,8CAEjC,QAAQ;IAAA,qDAED,sCAAsC;IAAA,iDAE1C,qCAAqC;IAAA,+CAEvC,WAAW;IAAA,+CAEX,EAAE;IAAA,iDAEA,EAAE;EAZ+B;EAc3C;EACA,MAAMC,MAAM,CAACC,MAAW,EAAEC,OAA+B,EAAE;IACzD;IACA,MAAMC,IAAI,GAAG,MAAM,IAAI,CAACJ,SAAS,CAACI,IAAI,EAAE;IACxC,oBAAO,+BAAC,WAAI;MAAC,KAAK,EAAC;IAAO,cAAgB;EAC5C;AACF;AAAC"}
@@ -1,36 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  require("core-js/modules/es.promise.js");
8
-
9
6
  Object.defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
9
  exports.PatternCommand = void 0;
13
-
14
10
  function _defineProperty2() {
15
11
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
12
  _defineProperty2 = function () {
18
13
  return data;
19
14
  };
20
-
21
15
  return data;
22
16
  }
23
-
24
17
  function _chalk() {
25
18
  const data = _interopRequireDefault(require("chalk"));
26
-
27
19
  _chalk = function () {
28
20
  return data;
29
21
  };
30
-
31
22
  return data;
32
23
  }
33
-
34
24
  class PatternCommand {
35
25
  constructor(workspace) {
36
26
  this.workspace = workspace;
@@ -65,21 +55,15 @@ the matching algorithm is done by multimatch (@see https://github.com/sindresorh
65
55
  (0, _defineProperty2().default)(this, "private", false);
66
56
  (0, _defineProperty2().default)(this, "options", [['j', 'json', 'return the output as JSON']]);
67
57
  }
68
-
69
58
  async report([pattern]) {
70
59
  const ids = await this.json([pattern]);
71
-
72
60
  const title = _chalk().default.green(`found ${_chalk().default.bold(ids.length.toString())} components matching the pattern`);
73
-
74
61
  return `${title}\n${ids.join('\n')}`;
75
62
  }
76
-
77
63
  async json([pattern]) {
78
64
  return this.workspace.idsByPattern(pattern, false);
79
65
  }
80
-
81
66
  }
82
-
83
67
  exports.PatternCommand = PatternCommand;
84
68
 
85
69
  //# sourceMappingURL=pattern.cmd.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PatternCommand","constructor","workspace","cmd","description","report","pattern","ids","json","title","chalk","green","bold","length","toString","join","idsByPattern"],"sources":["pattern.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\n\nexport class PatternCommand implements Command {\n name = 'pattern <pattern>';\n alias = '';\n description = 'list the component ids matching the given pattern';\n extendedDescription = `this command helps validating a pattern before using it in other commands.\na pattern can be a simple component-id or component-name. e.g. \"ui/button\".\na pattern can be used with wildcards for multiple component ids, e.g. \"org.scope/utils/**\".\nto enter multiple patterns, separate them by a comma, e.g. \"ui/*, lib/*\"\nto exclude, use \"!\". e.g. \"ui/**, !ui/button\"\nalways wrap the pattern with quotes to avoid collision with shell commands.\nthe matching algorithm is done by multimatch (@see https://github.com/sindresorhus/multimatch)\n`;\n examples = [\n { cmd: 'bit pattern \"**\"', description: 'matches all components' },\n {\n cmd: 'bit pattern \"*/ui/*\"',\n description:\n 'matches components with any scope-name and the \"ui\" namespace. e.g. \"ui/button\" but not \"ui/elements/button\"',\n },\n {\n cmd: 'bit pattern \"*/ui/**\"',\n description: 'matches components that their namespace starts with \"ui/\" e.g. \"ui/button\", \"ui/elements/button\"',\n },\n { cmd: 'bit pattern \"bar, foo\"', description: 'matches two components: bar and foo' },\n { cmd: 'bit pattern \"my-scope.org/**\"', description: 'matches all components of the scope \"my-scope.org\"' },\n ];\n group = 'development';\n private = false;\n options = [['j', 'json', 'return the output as JSON']] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const ids = await this.json([pattern]);\n const title = chalk.green(`found ${chalk.bold(ids.length.toString())} components matching the pattern`);\n return `${title}\\n${ids.join('\\n')}`;\n }\n\n async json([pattern]: [string]) {\n return this.workspace.idsByPattern(pattern, false);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,cAAN,CAAwC;EA8B7CC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,8CA7BnC,mBA6BmC;IAAA,+CA5BlC,EA4BkC;IAAA,qDA3B5B,mDA2B4B;IAAA,6DA1BnB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,CAmB4C;IAAA,kDAlB/B,CACT;MAAEC,GAAG,EAAE,kBAAP;MAA2BC,WAAW,EAAE;IAAxC,CADS,EAET;MACED,GAAG,EAAE,sBADP;MAEEC,WAAW,EACT;IAHJ,CAFS,EAOT;MACED,GAAG,EAAE,uBADP;MAEEC,WAAW,EAAE;IAFf,CAPS,EAWT;MAAED,GAAG,EAAE,wBAAP;MAAiCC,WAAW,EAAE;IAA9C,CAXS,EAYT;MAAED,GAAG,EAAE,+BAAP;MAAwCC,WAAW,EAAE;IAArD,CAZS,CAkB+B;IAAA,+CAJlC,aAIkC;IAAA,iDAHhC,KAGgC;IAAA,iDAFhC,CAAC,CAAC,GAAD,EAAM,MAAN,EAAc,2BAAd,CAAD,CAEgC;EAAE;;EAEhC,MAANC,MAAM,CAAC,CAACC,OAAD,CAAD,EAAsB;IAChC,MAAMC,GAAG,GAAG,MAAM,KAAKC,IAAL,CAAU,CAACF,OAAD,CAAV,CAAlB;;IACA,MAAMG,KAAK,GAAGC,gBAAA,CAAMC,KAAN,CAAa,SAAQD,gBAAA,CAAME,IAAN,CAAWL,GAAG,CAACM,MAAJ,CAAWC,QAAX,EAAX,CAAkC,kCAAvD,CAAd;;IACA,OAAQ,GAAEL,KAAM,KAAIF,GAAG,CAACQ,IAAJ,CAAS,IAAT,CAAe,EAAnC;EACD;;EAES,MAAJP,IAAI,CAAC,CAACF,OAAD,CAAD,EAAsB;IAC9B,OAAO,KAAKJ,SAAL,CAAec,YAAf,CAA4BV,OAA5B,EAAqC,KAArC,CAAP;EACD;;AAxC4C"}
1
+ {"version":3,"names":["PatternCommand","constructor","workspace","cmd","description","report","pattern","ids","json","title","chalk","green","bold","length","toString","join","idsByPattern"],"sources":["pattern.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\n\nexport class PatternCommand implements Command {\n name = 'pattern <pattern>';\n alias = '';\n description = 'list the component ids matching the given pattern';\n extendedDescription = `this command helps validating a pattern before using it in other commands.\na pattern can be a simple component-id or component-name. e.g. \"ui/button\".\na pattern can be used with wildcards for multiple component ids, e.g. \"org.scope/utils/**\".\nto enter multiple patterns, separate them by a comma, e.g. \"ui/*, lib/*\"\nto exclude, use \"!\". e.g. \"ui/**, !ui/button\"\nalways wrap the pattern with quotes to avoid collision with shell commands.\nthe matching algorithm is done by multimatch (@see https://github.com/sindresorhus/multimatch)\n`;\n examples = [\n { cmd: 'bit pattern \"**\"', description: 'matches all components' },\n {\n cmd: 'bit pattern \"*/ui/*\"',\n description:\n 'matches components with any scope-name and the \"ui\" namespace. e.g. \"ui/button\" but not \"ui/elements/button\"',\n },\n {\n cmd: 'bit pattern \"*/ui/**\"',\n description: 'matches components that their namespace starts with \"ui/\" e.g. \"ui/button\", \"ui/elements/button\"',\n },\n { cmd: 'bit pattern \"bar, foo\"', description: 'matches two components: bar and foo' },\n { cmd: 'bit pattern \"my-scope.org/**\"', description: 'matches all components of the scope \"my-scope.org\"' },\n ];\n group = 'development';\n private = false;\n options = [['j', 'json', 'return the output as JSON']] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const ids = await this.json([pattern]);\n const title = chalk.green(`found ${chalk.bold(ids.length.toString())} components matching the pattern`);\n return `${title}\\n${ids.join('\\n')}`;\n }\n\n async json([pattern]: [string]) {\n return this.workspace.idsByPattern(pattern, false);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,cAAc,CAAoB;EA8B7CC,WAAW,CAASC,SAAoB,EAAE;IAAA,KAAtBA,SAAoB,GAApBA,SAAoB;IAAA,8CA7BjC,mBAAmB;IAAA,+CAClB,EAAE;IAAA,qDACI,mDAAmD;IAAA,6DAC1C;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;IAAA,kDACY,CACT;MAAEC,GAAG,EAAE,kBAAkB;MAAEC,WAAW,EAAE;IAAyB,CAAC,EAClE;MACED,GAAG,EAAE,sBAAsB;MAC3BC,WAAW,EACT;IACJ,CAAC,EACD;MACED,GAAG,EAAE,uBAAuB;MAC5BC,WAAW,EAAE;IACf,CAAC,EACD;MAAED,GAAG,EAAE,wBAAwB;MAAEC,WAAW,EAAE;IAAsC,CAAC,EACrF;MAAED,GAAG,EAAE,+BAA+B;MAAEC,WAAW,EAAE;IAAqD,CAAC,CAC5G;IAAA,+CACO,aAAa;IAAA,iDACX,KAAK;IAAA,iDACL,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,2BAA2B,CAAC,CAAC;EAEX;EAE3C,MAAMC,MAAM,CAAC,CAACC,OAAO,CAAW,EAAE;IAChC,MAAMC,GAAG,GAAG,MAAM,IAAI,CAACC,IAAI,CAAC,CAACF,OAAO,CAAC,CAAC;IACtC,MAAMG,KAAK,GAAGC,gBAAK,CAACC,KAAK,CAAE,SAAQD,gBAAK,CAACE,IAAI,CAACL,GAAG,CAACM,MAAM,CAACC,QAAQ,EAAE,CAAE,kCAAiC,CAAC;IACvG,OAAQ,GAAEL,KAAM,KAAIF,GAAG,CAACQ,IAAI,CAAC,IAAI,CAAE,EAAC;EACtC;EAEA,MAAMP,IAAI,CAAC,CAACF,OAAO,CAAW,EAAE;IAC9B,OAAO,IAAI,CAACJ,SAAS,CAACc,YAAY,CAACV,OAAO,EAAE,KAAK,CAAC;EACpD;AACF;AAAC"}
@@ -1,46 +1,33 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  require("core-js/modules/es.promise.js");
8
-
9
6
  Object.defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
9
  exports.ScopeSetCmd = void 0;
13
-
14
10
  function _defineProperty2() {
15
11
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
12
  _defineProperty2 = function () {
18
13
  return data;
19
14
  };
20
-
21
15
  return data;
22
16
  }
23
-
24
17
  function _constants() {
25
18
  const data = require("@teambit/legacy/dist/constants");
26
-
27
19
  _constants = function () {
28
20
  return data;
29
21
  };
30
-
31
22
  return data;
32
23
  }
33
-
34
24
  function _chalk() {
35
25
  const data = _interopRequireDefault(require("chalk"));
36
-
37
26
  _chalk = function () {
38
27
  return data;
39
28
  };
40
-
41
29
  return data;
42
30
  }
43
-
44
31
  class ScopeSetCmd {
45
32
  constructor(workspace) {
46
33
  this.workspace = workspace;
@@ -59,7 +46,6 @@ class ScopeSetCmd {
59
46
 
60
47
  ${(0, _constants().PATTERN_HELP)('scope set scope-name')}`);
61
48
  }
62
-
63
49
  async report([scopeName, pattern]) {
64
50
  if (pattern) {
65
51
  const componentsIds = await this.workspace.idsByPattern(pattern);
@@ -67,14 +53,11 @@ ${(0, _constants().PATTERN_HELP)('scope set scope-name')}`);
67
53
  return _chalk().default.green(`successfully set ${_chalk().default.bold(scopeName)} as the default-scope for the following component(s):
68
54
  ${_chalk().default.reset(changedIds.map(id => id.toString()).join('\n'))}`);
69
55
  }
70
-
71
56
  const oldScope = this.workspace.defaultScope;
72
57
  await this.workspace.setDefaultScope(scopeName);
73
58
  return _chalk().default.green(`successfully set the default-scope to ${_chalk().default.bold(scopeName)}. (previous scope was "${oldScope}")`);
74
59
  }
75
-
76
60
  }
77
-
78
61
  exports.ScopeSetCmd = ScopeSetCmd;
79
62
 
80
63
  //# sourceMappingURL=scope-set.cmd.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ScopeSetCmd","constructor","workspace","name","description","PATTERN_HELP","report","scopeName","pattern","componentsIds","idsByPattern","changedIds","setDefaultScopeToComponents","chalk","green","bold","reset","map","id","toString","join","oldScope","defaultScope","setDefaultScope"],"sources":["scope-set.cmd.ts"],"sourcesContent":["import { Command } from '@teambit/cli';\nimport { PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport chalk from 'chalk';\nimport { Workspace } from '../workspace';\n\nexport class ScopeSetCmd implements Command {\n name = 'set <scope-name> [component-pattern]';\n description =\n 'Sets components with a default-scope. If no component is specified, sets the workspace with a default scope';\n arguments = [\n { name: 'scope-name', description: 'the scope name to use as the default scope' },\n {\n name: 'component-pattern',\n description:\n 'component name, component id, or component pattern. use component pattern to select multiple components. \\nuse comma to separate patterns and \"!\" to exclude. e.g. \"ui/**, !ui/button\"\\nwrap the pattern with quotes',\n },\n ];\n options = [];\n group = 'development';\n extendedDescription = `default scopes for components are set in the bitmap file. the default scope for a workspace is set in the workspace.jsonc. a component is set with a scope (as oppose to default scope) only once it is versioned.'\n\n${PATTERN_HELP('scope set scope-name')}`;\n\n constructor(private workspace: Workspace) {}\n\n async report([scopeName, pattern]: [string, string]) {\n if (pattern) {\n const componentsIds = await this.workspace.idsByPattern(pattern);\n const changedIds = await this.workspace.setDefaultScopeToComponents(componentsIds, scopeName);\n return chalk.green(`successfully set ${chalk.bold(scopeName)} as the default-scope for the following component(s):\n ${chalk.reset(changedIds.map((id) => id.toString()).join('\\n'))}`);\n }\n const oldScope = this.workspace.defaultScope;\n await this.workspace.setDefaultScope(scopeName);\n return chalk.green(\n `successfully set the default-scope to ${chalk.bold(scopeName)}. (previous scope was \"${oldScope}\")`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,WAAN,CAAqC;EAkB1CC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,8CAjBnC,sCAiBmC;IAAA,qDAfxC,6GAewC;IAAA,mDAd9B,CACV;MAAEC,IAAI,EAAE,YAAR;MAAsBC,WAAW,EAAE;IAAnC,CADU,EAEV;MACED,IAAI,EAAE,mBADR;MAEEC,WAAW,EACT;IAHJ,CAFU,CAc8B;IAAA,iDANhC,EAMgC;IAAA,+CALlC,aAKkC;IAAA,6DAJnB;AACzB;AACA,EAAE,IAAAC,yBAAA,EAAa,sBAAb,CAAqC,EAEK;EAAE;;EAEhC,MAANC,MAAM,CAAC,CAACC,SAAD,EAAYC,OAAZ,CAAD,EAAyC;IACnD,IAAIA,OAAJ,EAAa;MACX,MAAMC,aAAa,GAAG,MAAM,KAAKP,SAAL,CAAeQ,YAAf,CAA4BF,OAA5B,CAA5B;MACA,MAAMG,UAAU,GAAG,MAAM,KAAKT,SAAL,CAAeU,2BAAf,CAA2CH,aAA3C,EAA0DF,SAA1D,CAAzB;MACA,OAAOM,gBAAA,CAAMC,KAAN,CAAa,oBAAmBD,gBAAA,CAAME,IAAN,CAAWR,SAAX,CAAsB;AACnE,IAAIM,gBAAA,CAAMG,KAAN,CAAYL,UAAU,CAACM,GAAX,CAAgBC,EAAD,IAAQA,EAAE,CAACC,QAAH,EAAvB,EAAsCC,IAAtC,CAA2C,IAA3C,CAAZ,CAA8D,EADrD,CAAP;IAED;;IACD,MAAMC,QAAQ,GAAG,KAAKnB,SAAL,CAAeoB,YAAhC;IACA,MAAM,KAAKpB,SAAL,CAAeqB,eAAf,CAA+BhB,SAA/B,CAAN;IACA,OAAOM,gBAAA,CAAMC,KAAN,CACJ,yCAAwCD,gBAAA,CAAME,IAAN,CAAWR,SAAX,CAAsB,0BAAyBc,QAAS,IAD5F,CAAP;EAGD;;AAhCyC"}
1
+ {"version":3,"names":["ScopeSetCmd","constructor","workspace","name","description","PATTERN_HELP","report","scopeName","pattern","componentsIds","idsByPattern","changedIds","setDefaultScopeToComponents","chalk","green","bold","reset","map","id","toString","join","oldScope","defaultScope","setDefaultScope"],"sources":["scope-set.cmd.ts"],"sourcesContent":["import { Command } from '@teambit/cli';\nimport { PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport chalk from 'chalk';\nimport { Workspace } from '../workspace';\n\nexport class ScopeSetCmd implements Command {\n name = 'set <scope-name> [component-pattern]';\n description =\n 'Sets components with a default-scope. If no component is specified, sets the workspace with a default scope';\n arguments = [\n { name: 'scope-name', description: 'the scope name to use as the default scope' },\n {\n name: 'component-pattern',\n description:\n 'component name, component id, or component pattern. use component pattern to select multiple components. \\nuse comma to separate patterns and \"!\" to exclude. e.g. \"ui/**, !ui/button\"\\nwrap the pattern with quotes',\n },\n ];\n options = [];\n group = 'development';\n extendedDescription = `default scopes for components are set in the bitmap file. the default scope for a workspace is set in the workspace.jsonc. a component is set with a scope (as oppose to default scope) only once it is versioned.'\n\n${PATTERN_HELP('scope set scope-name')}`;\n\n constructor(private workspace: Workspace) {}\n\n async report([scopeName, pattern]: [string, string]) {\n if (pattern) {\n const componentsIds = await this.workspace.idsByPattern(pattern);\n const changedIds = await this.workspace.setDefaultScopeToComponents(componentsIds, scopeName);\n return chalk.green(`successfully set ${chalk.bold(scopeName)} as the default-scope for the following component(s):\n ${chalk.reset(changedIds.map((id) => id.toString()).join('\\n'))}`);\n }\n const oldScope = this.workspace.defaultScope;\n await this.workspace.setDefaultScope(scopeName);\n return chalk.green(\n `successfully set the default-scope to ${chalk.bold(scopeName)}. (previous scope was \"${oldScope}\")`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,WAAW,CAAoB;EAkB1CC,WAAW,CAASC,SAAoB,EAAE;IAAA,KAAtBA,SAAoB,GAApBA,SAAoB;IAAA,8CAjBjC,sCAAsC;IAAA,qDAE3C,6GAA6G;IAAA,mDACnG,CACV;MAAEC,IAAI,EAAE,YAAY;MAAEC,WAAW,EAAE;IAA6C,CAAC,EACjF;MACED,IAAI,EAAE,mBAAmB;MACzBC,WAAW,EACT;IACJ,CAAC,CACF;IAAA,iDACS,EAAE;IAAA,+CACJ,aAAa;IAAA,6DACE;AACzB;AACA,EAAE,IAAAC,yBAAY,EAAC,sBAAsB,CAAE,EAAC;EAEK;EAE3C,MAAMC,MAAM,CAAC,CAACC,SAAS,EAAEC,OAAO,CAAmB,EAAE;IACnD,IAAIA,OAAO,EAAE;MACX,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACP,SAAS,CAACQ,YAAY,CAACF,OAAO,CAAC;MAChE,MAAMG,UAAU,GAAG,MAAM,IAAI,CAACT,SAAS,CAACU,2BAA2B,CAACH,aAAa,EAAEF,SAAS,CAAC;MAC7F,OAAOM,gBAAK,CAACC,KAAK,CAAE,oBAAmBD,gBAAK,CAACE,IAAI,CAACR,SAAS,CAAE;AACnE,IAAIM,gBAAK,CAACG,KAAK,CAACL,UAAU,CAACM,GAAG,CAAEC,EAAE,IAAKA,EAAE,CAACC,QAAQ,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAE,EAAC,CAAC;IAChE;IACA,MAAMC,QAAQ,GAAG,IAAI,CAACnB,SAAS,CAACoB,YAAY;IAC5C,MAAM,IAAI,CAACpB,SAAS,CAACqB,eAAe,CAAChB,SAAS,CAAC;IAC/C,OAAOM,gBAAK,CAACC,KAAK,CACf,yCAAwCD,gBAAK,CAACE,IAAI,CAACR,SAAS,CAAE,0BAAyBc,QAAS,IAAG,CACrG;EACH;AACF;AAAC"}
package/dist/ui/index.js CHANGED
@@ -9,14 +9,11 @@ Object.defineProperty(exports, "Workspace", {
9
9
  return _workspace().Workspace;
10
10
  }
11
11
  });
12
-
13
12
  function _workspace() {
14
13
  const data = require("./workspace");
15
-
16
14
  _workspace = function () {
17
15
  return data;
18
16
  };
19
-
20
17
  return data;
21
18
  }
22
19
 
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { Workspace } from './workspace';\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { Workspace } from './workspace';\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["defaultComponent","id","server","url","env"],"sources":["default-component.ts"],"sourcesContent":["export const defaultComponent = {\n id: '',\n server: {\n url: '',\n env: '',\n },\n};\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAG;EAC9BC,EAAE,EAAE,EAD0B;EAE9BC,MAAM,EAAE;IACNC,GAAG,EAAE,EADC;IAENC,GAAG,EAAE;EAFC;AAFsB,CAAzB"}
1
+ {"version":3,"names":["defaultComponent","id","server","url","env"],"sources":["default-component.ts"],"sourcesContent":["export const defaultComponent = {\n id: '',\n server: {\n url: '',\n env: '',\n },\n};\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAG;EAC9BC,EAAE,EAAE,EAAE;EACNC,MAAM,EAAE;IACNC,GAAG,EAAE,EAAE;IACPC,GAAG,EAAE;EACP;AACF,CAAC;AAAC"}
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _workspace = require("./workspace");
8
-
9
7
  Object.keys(_workspace).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _workspace[key]) return;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './workspace';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './workspace';\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -1,108 +1,76 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.useWorkspace = useWorkspace;
11
-
12
9
  function _defineProperty2() {
13
10
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
11
  _defineProperty2 = function () {
16
12
  return data;
17
13
  };
18
-
19
14
  return data;
20
15
  }
21
-
22
16
  function _objectWithoutProperties2() {
23
17
  const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
24
-
25
18
  _objectWithoutProperties2 = function () {
26
19
  return data;
27
20
  };
28
-
29
21
  return data;
30
22
  }
31
-
32
23
  function _react() {
33
24
  const data = require("react");
34
-
35
25
  _react = function () {
36
26
  return data;
37
27
  };
38
-
39
28
  return data;
40
29
  }
41
-
42
30
  function _component() {
43
31
  const data = require("@teambit/component");
44
-
45
32
  _component = function () {
46
33
  return data;
47
34
  };
48
-
49
35
  return data;
50
36
  }
51
-
52
37
  function _latest() {
53
38
  const data = _interopRequireDefault(require("@react-hook/latest"));
54
-
55
39
  _latest = function () {
56
40
  return data;
57
41
  };
58
-
59
42
  return data;
60
43
  }
61
-
62
44
  function _uiFoundationUiHooks() {
63
45
  const data = require("@teambit/ui-foundation.ui.hooks.use-data-query");
64
-
65
46
  _uiFoundationUiHooks = function () {
66
47
  return data;
67
48
  };
68
-
69
49
  return data;
70
50
  }
71
-
72
51
  function _client() {
73
52
  const data = require("@apollo/client");
74
-
75
53
  _client = function () {
76
54
  return data;
77
55
  };
78
-
79
56
  return data;
80
57
  }
81
-
82
58
  function _componentId() {
83
59
  const data = require("@teambit/component-id");
84
-
85
60
  _componentId = function () {
86
61
  return data;
87
62
  };
88
-
89
63
  return data;
90
64
  }
91
-
92
65
  function _workspaceModel() {
93
66
  const data = require("./workspace-model");
94
-
95
67
  _workspaceModel = function () {
96
68
  return data;
97
69
  };
98
-
99
70
  return data;
100
71
  }
101
-
102
72
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
103
-
104
73
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
105
-
106
74
  const wcComponentFields = (0, _client().gql)`
107
75
  fragment wcComponentFields on Component {
108
76
  id {
@@ -187,15 +155,13 @@ const COMPONENT_SUBSCRIPTION_REMOVED = (0, _client().gql)`
187
155
  }
188
156
  }
189
157
  `;
190
-
191
158
  function useWorkspace(options = {}) {
192
159
  const _useDataQuery = (0, _uiFoundationUiHooks().useDataQuery)(WORKSPACE),
193
- {
194
- data,
195
- subscribeToMore
196
- } = _useDataQuery,
197
- rest = (0, _objectWithoutProperties2().default)(_useDataQuery, ["data", "subscribeToMore"]);
198
-
160
+ {
161
+ data,
162
+ subscribeToMore
163
+ } = _useDataQuery,
164
+ rest = (0, _objectWithoutProperties2().default)(_useDataQuery, ["data", "subscribeToMore"]);
199
165
  const optionsRef = (0, _latest().default)(options);
200
166
  (0, _react().useEffect)(() => {
201
167
  const unSubCompAddition = subscribeToMore({
@@ -204,18 +170,17 @@ function useWorkspace(options = {}) {
204
170
  subscriptionData
205
171
  }) => {
206
172
  var _update$componentAdde;
207
-
208
173
  const update = subscriptionData.data;
209
174
  const addedComponent = update === null || update === void 0 ? void 0 : (_update$componentAdde = update.componentAdded) === null || _update$componentAdde === void 0 ? void 0 : _update$componentAdde.component;
210
175
  if (!addedComponent) return prev;
211
176
  const componentExists = prev.workspace.components.find(component => _componentId().ComponentID.isEqualObj(component.id, addedComponent.id, {
212
177
  ignoreVersion: true
213
178
  }));
214
- if (componentExists) return prev; // side effect - trigger observers
179
+ if (componentExists) return prev;
215
180
 
181
+ // side effect - trigger observers
216
182
  setTimeout(() => {
217
183
  var _optionsRef$current$o, _optionsRef$current;
218
-
219
184
  return (_optionsRef$current$o = (_optionsRef$current = optionsRef.current).onComponentAdded) === null || _optionsRef$current$o === void 0 ? void 0 : _optionsRef$current$o.call(_optionsRef$current, [_component().ComponentModel.from(addedComponent)]);
220
185
  });
221
186
  return _objectSpread(_objectSpread({}, prev), {}, {
@@ -232,11 +197,10 @@ function useWorkspace(options = {}) {
232
197
  }) => {
233
198
  const update = subscriptionData.data;
234
199
  if (!update) return prev;
235
- const updatedComponent = update.componentChanged.component; // side effect - trigger observers
236
-
200
+ const updatedComponent = update.componentChanged.component;
201
+ // side effect - trigger observers
237
202
  setTimeout(() => {
238
203
  var _optionsRef$current$o2, _optionsRef$current2;
239
-
240
204
  return (_optionsRef$current$o2 = (_optionsRef$current2 = optionsRef.current).onComponentUpdated) === null || _optionsRef$current$o2 === void 0 ? void 0 : _optionsRef$current$o2.call(_optionsRef$current2, [_component().ComponentModel.from(updatedComponent)]);
241
205
  });
242
206
  return _objectSpread(_objectSpread({}, prev), {}, {
@@ -252,13 +216,12 @@ function useWorkspace(options = {}) {
252
216
  subscriptionData
253
217
  }) => {
254
218
  var _subscriptionData$dat, _subscriptionData$dat2;
255
-
256
219
  const idsToRemove = (_subscriptionData$dat = subscriptionData.data) === null || _subscriptionData$dat === void 0 ? void 0 : (_subscriptionData$dat2 = _subscriptionData$dat.componentRemoved) === null || _subscriptionData$dat2 === void 0 ? void 0 : _subscriptionData$dat2.componentIds;
257
- if (!idsToRemove || idsToRemove.length === 0) return prev; // side effect - trigger observers
220
+ if (!idsToRemove || idsToRemove.length === 0) return prev;
258
221
 
222
+ // side effect - trigger observers
259
223
  setTimeout(() => {
260
224
  var _optionsRef$current$o3, _optionsRef$current3;
261
-
262
225
  return (_optionsRef$current$o3 = (_optionsRef$current3 = optionsRef.current).onComponentRemoved) === null || _optionsRef$current$o3 === void 0 ? void 0 : _optionsRef$current$o3.call(_optionsRef$current3, idsToRemove.map(id => _componentId().ComponentID.fromObject(id)));
263
226
  });
264
227
  return _objectSpread(_objectSpread({}, prev), {}, {
@@ -267,7 +230,9 @@ function useWorkspace(options = {}) {
267
230
  })
268
231
  });
269
232
  }
270
- }); // TODO - sub to component removal
233
+ });
234
+
235
+ // TODO - sub to component removal
271
236
 
272
237
  return () => {
273
238
  unSubCompAddition();
@@ -1 +1 @@
1
- {"version":3,"names":["wcComponentFields","gql","WORKSPACE","COMPONENT_SUBSCRIPTION_ADDED","COMPONENT_SUBSCRIPTION_CHANGED","COMPONENT_SUBSCRIPTION_REMOVED","useWorkspace","options","useDataQuery","data","subscribeToMore","rest","optionsRef","useLatest","useEffect","unSubCompAddition","document","updateQuery","prev","subscriptionData","update","addedComponent","componentAdded","component","componentExists","workspace","components","find","ComponentID","isEqualObj","id","ignoreVersion","setTimeout","current","onComponentAdded","ComponentModel","from","unSubCompChange","updatedComponent","componentChanged","onComponentUpdated","map","name","unSubCompRemoved","idsToRemove","componentRemoved","componentIds","length","onComponentRemoved","fromObject","filter","every","useMemo","Workspace","undefined"],"sources":["use-workspace.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { ComponentModel } from '@teambit/component';\nimport useLatest from '@react-hook/latest';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { gql } from '@apollo/client';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\n\nimport { Workspace } from './workspace-model';\n\ntype UseWorkspaceOptions = {\n onComponentAdded?: (component: ComponentModel[]) => void;\n onComponentUpdated?: (component: ComponentModel[]) => void;\n onComponentRemoved?: (compId: ComponentID[]) => void;\n};\ntype RawComponent = { id: ComponentIdObj };\n\nconst wcComponentFields = gql`\n fragment wcComponentFields on Component {\n id {\n name\n version\n scope\n }\n compositions {\n identifier\n }\n description\n issuesCount\n status {\n isOutdated\n isNew\n isInScope\n isStaged\n modifyInfo {\n hasModifiedFiles\n hasModifiedDependencies\n }\n isDeleted\n }\n preview {\n isScaling\n }\n deprecation {\n isDeprecate\n newId\n }\n server {\n env\n url\n }\n env {\n id\n icon\n }\n }\n`;\n\nconst WORKSPACE = gql`\n query workspace {\n workspace {\n name\n path\n icon\n components {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n name\n version\n scope\n }\n }\n }\n`;\n\nexport function useWorkspace(options: UseWorkspaceOptions = {}) {\n const { data, subscribeToMore, ...rest } = useDataQuery(WORKSPACE);\n const optionsRef = useLatest(options);\n\n useEffect(() => {\n const unSubCompAddition = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_ADDED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n const addedComponent = update?.componentAdded?.component;\n if (!addedComponent) return prev;\n\n const componentExists = prev.workspace.components.find((component: any) =>\n ComponentID.isEqualObj(component.id, addedComponent.id, { ignoreVersion: true })\n );\n if (componentExists) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentAdded?.([ComponentModel.from(addedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: [...prev.workspace.components, addedComponent],\n },\n };\n },\n });\n\n const unSubCompChange = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_CHANGED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n if (!update) return prev;\n\n const updatedComponent = update.componentChanged.component;\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentUpdated?.([ComponentModel.from(updatedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.map((component) =>\n component.id.name === updatedComponent.id.name ? updatedComponent : component\n ),\n },\n };\n },\n });\n\n const unSubCompRemoved = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_REMOVED,\n updateQuery: (prev, { subscriptionData }) => {\n const idsToRemove: ComponentIdObj[] | undefined = subscriptionData.data?.componentRemoved?.componentIds;\n if (!idsToRemove || idsToRemove.length === 0) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentRemoved?.(idsToRemove.map((id) => ComponentID.fromObject(id))));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.filter((component: RawComponent) =>\n idsToRemove.every((id) => !ComponentID.isEqualObj(id, component.id))\n ),\n },\n };\n },\n });\n\n // TODO - sub to component removal\n\n return () => {\n unSubCompAddition();\n unSubCompChange();\n unSubCompRemoved();\n };\n }, [optionsRef]);\n\n const workspace = useMemo(() => {\n return data?.workspace ? Workspace.from(data?.workspace) : undefined;\n }, [data?.workspace]);\n\n return {\n workspace,\n subscribeToMore,\n ...rest,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AASA,MAAMA,iBAAiB,GAAG,IAAAC,aAAA,CAAI;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAvCA;AAyCA,MAAMC,SAAS,GAAG,IAAAD,aAAA,CAAI;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,iBAAkB;AACtB,CA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A;IACEA,SADF;IAEEf;EAFF,GAGKC,IAHL;AAKD"}
1
+ {"version":3,"names":["wcComponentFields","gql","WORKSPACE","COMPONENT_SUBSCRIPTION_ADDED","COMPONENT_SUBSCRIPTION_CHANGED","COMPONENT_SUBSCRIPTION_REMOVED","useWorkspace","options","useDataQuery","data","subscribeToMore","rest","optionsRef","useLatest","useEffect","unSubCompAddition","document","updateQuery","prev","subscriptionData","update","addedComponent","componentAdded","component","componentExists","workspace","components","find","ComponentID","isEqualObj","id","ignoreVersion","setTimeout","current","onComponentAdded","ComponentModel","from","unSubCompChange","updatedComponent","componentChanged","onComponentUpdated","map","name","unSubCompRemoved","idsToRemove","componentRemoved","componentIds","length","onComponentRemoved","fromObject","filter","every","useMemo","Workspace","undefined"],"sources":["use-workspace.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { ComponentModel } from '@teambit/component';\nimport useLatest from '@react-hook/latest';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { gql } from '@apollo/client';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\n\nimport { Workspace } from './workspace-model';\n\ntype UseWorkspaceOptions = {\n onComponentAdded?: (component: ComponentModel[]) => void;\n onComponentUpdated?: (component: ComponentModel[]) => void;\n onComponentRemoved?: (compId: ComponentID[]) => void;\n};\ntype RawComponent = { id: ComponentIdObj };\n\nconst wcComponentFields = gql`\n fragment wcComponentFields on Component {\n id {\n name\n version\n scope\n }\n compositions {\n identifier\n }\n description\n issuesCount\n status {\n isOutdated\n isNew\n isInScope\n isStaged\n modifyInfo {\n hasModifiedFiles\n hasModifiedDependencies\n }\n isDeleted\n }\n preview {\n isScaling\n }\n deprecation {\n isDeprecate\n newId\n }\n server {\n env\n url\n }\n env {\n id\n icon\n }\n }\n`;\n\nconst WORKSPACE = gql`\n query workspace {\n workspace {\n name\n path\n icon\n components {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...wcComponentFields\n }\n }\n }\n ${wcComponentFields}\n`;\n\nconst COMPONENT_SUBSCRIPTION_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n name\n version\n scope\n }\n }\n }\n`;\n\nexport function useWorkspace(options: UseWorkspaceOptions = {}) {\n const { data, subscribeToMore, ...rest } = useDataQuery(WORKSPACE);\n const optionsRef = useLatest(options);\n\n useEffect(() => {\n const unSubCompAddition = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_ADDED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n const addedComponent = update?.componentAdded?.component;\n if (!addedComponent) return prev;\n\n const componentExists = prev.workspace.components.find((component: any) =>\n ComponentID.isEqualObj(component.id, addedComponent.id, { ignoreVersion: true })\n );\n if (componentExists) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentAdded?.([ComponentModel.from(addedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: [...prev.workspace.components, addedComponent],\n },\n };\n },\n });\n\n const unSubCompChange = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_CHANGED,\n updateQuery: (prev, { subscriptionData }) => {\n const update = subscriptionData.data;\n if (!update) return prev;\n\n const updatedComponent = update.componentChanged.component;\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentUpdated?.([ComponentModel.from(updatedComponent)]));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.map((component) =>\n component.id.name === updatedComponent.id.name ? updatedComponent : component\n ),\n },\n };\n },\n });\n\n const unSubCompRemoved = subscribeToMore({\n document: COMPONENT_SUBSCRIPTION_REMOVED,\n updateQuery: (prev, { subscriptionData }) => {\n const idsToRemove: ComponentIdObj[] | undefined = subscriptionData.data?.componentRemoved?.componentIds;\n if (!idsToRemove || idsToRemove.length === 0) return prev;\n\n // side effect - trigger observers\n setTimeout(() => optionsRef.current.onComponentRemoved?.(idsToRemove.map((id) => ComponentID.fromObject(id))));\n\n return {\n ...prev,\n workspace: {\n ...prev.workspace,\n components: prev.workspace.components.filter((component: RawComponent) =>\n idsToRemove.every((id) => !ComponentID.isEqualObj(id, component.id))\n ),\n },\n };\n },\n });\n\n // TODO - sub to component removal\n\n return () => {\n unSubCompAddition();\n unSubCompChange();\n unSubCompRemoved();\n };\n }, [optionsRef]);\n\n const workspace = useMemo(() => {\n return data?.workspace ? Workspace.from(data?.workspace) : undefined;\n }, [data?.workspace]);\n\n return {\n workspace,\n subscribeToMore,\n ...rest,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA8C;AAAA;AAS9C,MAAMA,iBAAiB,GAAG,IAAAC,aAAG,CAAC;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,SAAS,GAAG,IAAAD,aAAG,CAAC;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,iBAAkB;AACtB,CAAC;AAED,MAAMG,4BAA4B,GAAG,IA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