@teambit/workspace 0.0.568 → 0.0.569

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 (64) hide show
  1. package/__snapshots__/pick-outdated-pkgs.spec.ts.snap +88 -0
  2. package/component-config-file/component-config-file.ts +98 -0
  3. package/component-config-file/exceptions/already-exists.ts +7 -0
  4. package/component-config-file/exceptions/index.ts +1 -0
  5. package/component-config-file/index.ts +2 -0
  6. package/component-tree.widget.tsx +16 -0
  7. package/dist/__snapshots__/pick-outdated-pkgs.spec.js.snap +88 -0
  8. package/dist/__snapshots__/pick-outdated-pkgs.spec.ts.snap +88 -0
  9. package/dist/pick-outdated-pkgs.d.ts +12 -0
  10. package/dist/pick-outdated-pkgs.js +201 -0
  11. package/dist/pick-outdated-pkgs.js.map +1 -0
  12. package/dist/pick-outdated-pkgs.spec.d.ts +1 -0
  13. package/dist/pick-outdated-pkgs.spec.js +64 -0
  14. package/dist/pick-outdated-pkgs.spec.js.map +1 -0
  15. package/dist/update.cmd.js +3 -5
  16. package/dist/update.cmd.js.map +1 -1
  17. package/dist/workspace.d.ts +8 -1
  18. package/dist/workspace.js +28 -2
  19. package/dist/workspace.js.map +1 -1
  20. package/eject-conf.cmd.tsx +62 -0
  21. package/events/index.ts +3 -0
  22. package/events/on-component-add-event.ts +14 -0
  23. package/events/on-component-change-event.ts +14 -0
  24. package/events/on-component-removed-event.ts +14 -0
  25. package/exceptions/dependency-type-not-supported-in-policy.ts +7 -0
  26. package/exceptions/incorrect-env-aspect.ts +8 -0
  27. package/exceptions/index.ts +1 -0
  28. package/install.cmd.tsx +67 -0
  29. package/link/component-list-links.ts +50 -0
  30. package/link/core-aspects-links.ts +50 -0
  31. package/link/get-package-name-from-target.ts +5 -0
  32. package/link/index.ts +1 -0
  33. package/link/link-row.ts +20 -0
  34. package/link/link-to-dir.ts +13 -0
  35. package/link/link.cmd.ts +96 -0
  36. package/link/nested-deps-in-nm-links.ts +47 -0
  37. package/link/rewire-row.ts +17 -0
  38. package/list.cmd.tsx +30 -0
  39. package/package-tar/teambit-workspace-0.0.569.tgz +0 -0
  40. package/package.json +54 -65
  41. package/types/asset.d.ts +29 -0
  42. package/types/style.d.ts +42 -0
  43. package/ui/index.ts +1 -0
  44. package/ui/workspace/default-component.ts +7 -0
  45. package/ui/workspace/index.ts +1 -0
  46. package/ui/workspace/use-workspace.ts +193 -0
  47. package/ui/workspace/workspace-context.tsx +5 -0
  48. package/ui/workspace/workspace-model.ts +66 -0
  49. package/ui/workspace/workspace-overview/index.ts +1 -0
  50. package/ui/workspace/workspace-overview/workspace-overview.tsx +21 -0
  51. package/ui/workspace/workspace-provider.tsx +23 -0
  52. package/ui/workspace/workspace.tsx +99 -0
  53. package/ui/workspace-components-drawer/index.ts +1 -0
  54. package/ui/workspace-components-drawer/workspace-components.drawer.tsx +49 -0
  55. package/update.cmd.tsx +30 -0
  56. package/watch/check-types.ts +5 -0
  57. package/watch/output-formatter.ts +50 -0
  58. package/watch/watch.cmd.tsx +142 -0
  59. package/watch/watcher.ts +289 -0
  60. package/workspace-component/component-status.ts +67 -0
  61. package/workspace-component/index.ts +2 -0
  62. package/workspace-component/workspace-component-loader.ts +276 -0
  63. package/workspace-component/workspace-component.ts +51 -0
  64. package/workspace.ui.runtime.tsx +215 -0
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ function _pickOutdatedPkgs() {
4
+ const data = require("./pick-outdated-pkgs");
5
+
6
+ _pickOutdatedPkgs = function () {
7
+ return data;
8
+ };
9
+
10
+ return data;
11
+ }
12
+
13
+ describe('makeOutdatedPkgChoices', () => {
14
+ it('should render choices in correct order', () => {
15
+ const choices = (0, _pickOutdatedPkgs().makeOutdatedPkgChoices)([{
16
+ name: 'zoo',
17
+ currentRange: '1.0.0',
18
+ latestRange: '1.1.0',
19
+ source: 'rootPolicy',
20
+ targetField: 'devDependencies'
21
+ }, {
22
+ name: 'qar',
23
+ currentRange: '1.0.0',
24
+ latestRange: '1.1.0',
25
+ source: 'rootPolicy',
26
+ targetField: 'dependencies'
27
+ }, {
28
+ name: 'foo',
29
+ currentRange: '1.0.0',
30
+ latestRange: '2.0.0',
31
+ source: 'rootPolicy',
32
+ targetField: 'dependencies'
33
+ }, {
34
+ name: 'bar',
35
+ currentRange: '1.0.0',
36
+ latestRange: '1.1.0',
37
+ source: 'rootPolicy',
38
+ targetField: 'peerDependencies'
39
+ }]); // @ts-ignore
40
+
41
+ expect(choices).toMatchSnapshot();
42
+ });
43
+ it('should render choices with context information', () => {
44
+ const choices = (0, _pickOutdatedPkgs().makeOutdatedPkgChoices)([{
45
+ name: 'foo',
46
+ currentRange: '1.0.0',
47
+ latestRange: '2.0.0',
48
+ source: 'component',
49
+ componentId: 'comp1',
50
+ targetField: 'dependencies'
51
+ }, {
52
+ name: 'bar',
53
+ currentRange: '1.0.0',
54
+ latestRange: '1.1.0',
55
+ source: 'variants',
56
+ variantPattern: '{comp2}',
57
+ targetField: 'peerDependencies'
58
+ }]); // @ts-ignore
59
+
60
+ expect(choices).toMatchSnapshot();
61
+ });
62
+ });
63
+
64
+ //# sourceMappingURL=pick-outdated-pkgs.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["pick-outdated-pkgs.spec.ts"],"names":["describe","it","choices","name","currentRange","latestRange","source","targetField","expect","toMatchSnapshot","componentId","variantPattern"],"mappings":";;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEAA,QAAQ,CAAC,wBAAD,EAA2B,MAAM;AACvCC,EAAAA,EAAE,CAAC,wCAAD,EAA2C,MAAM;AACjD,UAAMC,OAAO,GAAG,gDAAuB,CACrC;AACEC,MAAAA,IAAI,EAAE,KADR;AAEEC,MAAAA,YAAY,EAAE,OAFhB;AAGEC,MAAAA,WAAW,EAAE,OAHf;AAIEC,MAAAA,MAAM,EAAE,YAJV;AAKEC,MAAAA,WAAW,EAAE;AALf,KADqC,EAQrC;AACEJ,MAAAA,IAAI,EAAE,KADR;A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pick-outdated-pkgs';\n\ndescribe('makeOutdatedPkgChoices', () => {\n it('should render choices in correct order', () => {\n const choices = makeOutdatedPkgChoices([\n {\n name: 'zoo',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'rootPolicy',\n targetField: 'devDependencies',\n },\n {\n name: 'qar',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'rootPolicy',\n targetField: 'dependencies',\n },\n {\n name: 'foo',\n currentRange: '1.0.0',\n latestRange: '2.0.0',\n source: 'rootPolicy',\n targetField: 'dependencies',\n },\n {\n name: 'bar',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'rootPolicy',\n targetField: 'peerDependencies',\n },\n ]);\n // @ts-ignore\n expect(choices).toMatchSnapshot();\n });\n it('should render choices with context information', () => {\n const choices = makeOutdatedPkgChoices([\n {\n name: 'foo',\n currentRange: '1.0.0',\n latestRange: '2.0.0',\n source: 'component',\n componentId: 'comp1',\n targetField: 'dependencies',\n },\n {\n name: 'bar',\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n source: 'variants',\n variantPattern: '{comp2}',\n targetField: 'peerDependencies',\n },\n ]);\n // @ts-ignore\n expect(choices).toMatchSnapshot();\n });\n});\n"]}
@@ -35,11 +35,9 @@ class UpdateCmd {
35
35
  }
36
36
 
37
37
  async report(args, options) {
38
- if (!options.yes) {
39
- throw new Error('Interactive update is not implemented yet. Use the --yes option.');
40
- }
41
-
42
- await this.workspace.updateDependencies();
38
+ await this.workspace.updateDependencies({
39
+ all: options.yes === true
40
+ });
43
41
  return '';
44
42
  }
45
43
 
@@ -1 +1 @@
1
- {"version":3,"sources":["update.cmd.tsx"],"names":["UpdateCmd","constructor","workspace","report","args","options","yes","Error","updateDependencies"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQe,MAAMA,SAAN,CAAmC;AAQhDC,EAAAA,WAAW;AACT;AACJ;AACA;AACYC,EAAAA,SAJC,EAKT;AAAA,SADQA,SACR,GADQA,SACR;AAAA,kDAZK,QAYL;AAAA,yDAXY,qBAWZ;AAAA,mDAVM,IAUN;AAAA,mDATM,aASN;AAAA,8DARiB,EAQjB;AAAA,qDAPQ,CAAC,CAAC,GAAD,EAAM,KAAN,EAAa,4CAAb,CAAD,CAOR;AAAE;;AAEQ,QAANC,MAAM,CAACC,IAAD,EAAmBC,OAAnB,EAA8C;AACxD,QAAI,CAACA,OAAO,CAACC,GAAb,EAAkB;AAChB,YAAM,IAAIC,KAAJ,CAAU,kEAAV,CAAN;AACD;;AACD,UAAM,KAAKL,SAAL,CAAeM,kBAAf,EAAN;AACA,WAAO,EAAP;AACD;;AArB+C","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\n\nimport { Workspace } from './workspace';\n\ntype UpdateCmdOptions = {\n yes?: boolean;\n};\n\nexport default class UpdateCmd implements Command {\n name = 'update';\n description = 'update dependencies';\n alias = 'up';\n group = 'development';\n shortDescription = '';\n options = [['y', 'yes', 'automatically update all outdated packages']] as CommandOptions;\n\n constructor(\n /**\n * workspace extension.\n */\n private workspace: Workspace\n ) {}\n\n async report(args: [string[]], options: UpdateCmdOptions) {\n if (!options.yes) {\n throw new Error('Interactive update is not implemented yet. Use the --yes option.');\n }\n await this.workspace.updateDependencies();\n return '';\n }\n}\n"]}
1
+ {"version":3,"sources":["update.cmd.tsx"],"names":["UpdateCmd","constructor","workspace","report","args","options","updateDependencies","all","yes"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQe,MAAMA,SAAN,CAAmC;AAQhDC,EAAAA,WAAW;AACT;AACJ;AACA;AACYC,EAAAA,SAJC,EAKT;AAAA,SADQA,SACR,GADQA,SACR;AAAA,kDAZK,QAYL;AAAA,yDAXY,qBAWZ;AAAA,mDAVM,IAUN;AAAA,mDATM,aASN;AAAA,8DARiB,EAQjB;AAAA,qDAPQ,CAAC,CAAC,GAAD,EAAM,KAAN,EAAa,4CAAb,CAAD,CAOR;AAAE;;AAEQ,QAANC,MAAM,CAACC,IAAD,EAAmBC,OAAnB,EAA8C;AACxD,UAAM,KAAKH,SAAL,CAAeI,kBAAf,CAAkC;AACtCC,MAAAA,GAAG,EAAEF,OAAO,CAACG,GAAR,KAAgB;AADiB,KAAlC,CAAN;AAGA,WAAO,EAAP;AACD;;AApB+C","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\n\nimport { Workspace } from './workspace';\n\ntype UpdateCmdOptions = {\n yes?: boolean;\n};\n\nexport default class UpdateCmd implements Command {\n name = 'update';\n description = 'update dependencies';\n alias = 'up';\n group = 'development';\n shortDescription = '';\n options = [['y', 'yes', 'automatically update all outdated packages']] as CommandOptions;\n\n constructor(\n /**\n * workspace extension.\n */\n private workspace: Workspace\n ) {}\n\n async report(args: [string[]], options: UpdateCmdOptions) {\n await this.workspace.updateDependencies({\n all: options.yes === true,\n });\n return '';\n }\n}\n"]}
@@ -386,7 +386,14 @@ export declare class Workspace implements ComponentFactory {
386
386
  */
387
387
  install(packages?: string[], options?: WorkspaceInstallOptions): Promise<ComponentMap<string>>;
388
388
  private _getComponentsWithDependencyPolicies;
389
- updateDependencies(): Promise<ComponentMap<string>>;
389
+ /**
390
+ * Updates out-of-date dependencies in the workspace.
391
+ *
392
+ * @param options.all {Boolean} updates all outdated dependencies without showing a prompt.
393
+ */
394
+ updateDependencies(options: {
395
+ all: boolean;
396
+ }): Promise<ComponentMap<string>>;
390
397
  private _variantPatternsToDepPolicesDict;
391
398
  private _updateVariantsPolicies;
392
399
  private _saveManyComponentConfigFiles;
package/dist/workspace.js CHANGED
@@ -359,6 +359,16 @@ function _exceptions3() {
359
359
  return data;
360
360
  }
361
361
 
362
+ function _pickOutdatedPkgs() {
363
+ const data = require("./pick-outdated-pkgs");
364
+
365
+ _pickOutdatedPkgs = function () {
366
+ return data;
367
+ };
368
+
369
+ return data;
370
+ }
371
+
362
372
  function _watcher() {
363
373
  const data = require("./watch/watcher");
364
374
 
@@ -1663,8 +1673,14 @@ class Workspace {
1663
1673
  componentPoliciesById
1664
1674
  };
1665
1675
  }
1676
+ /**
1677
+ * Updates out-of-date dependencies in the workspace.
1678
+ *
1679
+ * @param options.all {Boolean} updates all outdated dependencies without showing a prompt.
1680
+ */
1666
1681
 
1667
- async updateDependencies() {
1682
+
1683
+ async updateDependencies(options) {
1668
1684
  const {
1669
1685
  componentConfigFiles,
1670
1686
  componentPoliciesById
@@ -1678,10 +1694,20 @@ class Workspace {
1678
1694
  variantPoliciesByPatterns,
1679
1695
  componentPoliciesById
1680
1696
  });
1697
+ let outdatedPkgsToUpdate;
1698
+
1699
+ if (options.all) {
1700
+ outdatedPkgsToUpdate = outdatedPkgs;
1701
+ } else {
1702
+ this.logger.off();
1703
+ outdatedPkgsToUpdate = await (0, _pickOutdatedPkgs().pickOutdatedPkgs)(outdatedPkgs);
1704
+ this.logger.on();
1705
+ }
1706
+
1681
1707
  const {
1682
1708
  updatedVariants,
1683
1709
  updatedComponents
1684
- } = this.dependencyResolver.applyUpdates(outdatedPkgs, {
1710
+ } = this.dependencyResolver.applyUpdates(outdatedPkgsToUpdate, {
1685
1711
  variantPoliciesByPatterns,
1686
1712
  componentPoliciesById
1687
1713
  });