@teambit/install 0.0.0-0494a1bc1f010e387719d84abc70a90c0e5b6b7d

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 (77) hide show
  1. package/dist/esm.mjs +7 -0
  2. package/dist/exceptions/dependency-type-not-supported-in-policy.d.ts +4 -0
  3. package/dist/exceptions/dependency-type-not-supported-in-policy.js +21 -0
  4. package/dist/exceptions/dependency-type-not-supported-in-policy.js.map +1 -0
  5. package/dist/exceptions/index.d.ts +1 -0
  6. package/dist/exceptions/index.js +20 -0
  7. package/dist/exceptions/index.js.map +1 -0
  8. package/dist/index.d.ts +5 -0
  9. package/dist/index.js +35 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/install.aspect.d.ts +2 -0
  12. package/dist/install.aspect.js +18 -0
  13. package/dist/install.aspect.js.map +1 -0
  14. package/dist/install.cmd.d.ts +55 -0
  15. package/dist/install.cmd.js +154 -0
  16. package/dist/install.cmd.js.map +1 -0
  17. package/dist/install.main.runtime.d.ts +246 -0
  18. package/dist/install.main.runtime.js +1397 -0
  19. package/dist/install.main.runtime.js.map +1 -0
  20. package/dist/link/component-list-links.d.ts +9 -0
  21. package/dist/link/component-list-links.js +97 -0
  22. package/dist/link/component-list-links.js.map +1 -0
  23. package/dist/link/core-aspects-links.d.ts +7 -0
  24. package/dist/link/core-aspects-links.js +77 -0
  25. package/dist/link/core-aspects-links.js.map +1 -0
  26. package/dist/link/get-package-name-from-target.d.ts +1 -0
  27. package/dist/link/get-package-name-from-target.js +13 -0
  28. package/dist/link/get-package-name-from-target.js.map +1 -0
  29. package/dist/link/index.d.ts +1 -0
  30. package/dist/link/index.js +20 -0
  31. package/dist/link/index.js.map +1 -0
  32. package/dist/link/link-row.d.ts +12 -0
  33. package/dist/link/link-row.js +32 -0
  34. package/dist/link/link-row.js.map +1 -0
  35. package/dist/link/link-to-dir.d.ts +2 -0
  36. package/dist/link/link-to-dir.js +35 -0
  37. package/dist/link/link-to-dir.js.map +1 -0
  38. package/dist/link/link.cmd.d.ts +46 -0
  39. package/dist/link/link.cmd.js +144 -0
  40. package/dist/link/link.cmd.js.map +1 -0
  41. package/dist/link/nested-deps-in-nm-links.d.ts +7 -0
  42. package/dist/link/nested-deps-in-nm-links.js +59 -0
  43. package/dist/link/nested-deps-in-nm-links.js.map +1 -0
  44. package/dist/link/rewire-row.d.ts +6 -0
  45. package/dist/link/rewire-row.js +26 -0
  46. package/dist/link/rewire-row.js.map +1 -0
  47. package/dist/pick-outdated-pkgs.d.ts +12 -0
  48. package/dist/pick-outdated-pkgs.js +180 -0
  49. package/dist/pick-outdated-pkgs.js.map +1 -0
  50. package/dist/pick-outdated-pkgs.spec.d.ts +1 -0
  51. package/dist/pick-outdated-pkgs.spec.js +171 -0
  52. package/dist/pick-outdated-pkgs.spec.js.map +1 -0
  53. package/dist/preview-1752093506725.js +7 -0
  54. package/dist/uninstall.cmd.d.ts +12 -0
  55. package/dist/uninstall.cmd.js +26 -0
  56. package/dist/uninstall.cmd.js.map +1 -0
  57. package/dist/update.cmd.d.ts +26 -0
  58. package/dist/update.cmd.js +52 -0
  59. package/dist/update.cmd.js.map +1 -0
  60. package/esm.mjs +7 -0
  61. package/exceptions/dependency-type-not-supported-in-policy.ts +7 -0
  62. package/exceptions/index.ts +1 -0
  63. package/install.cmd.tsx +189 -0
  64. package/link/component-list-links.ts +66 -0
  65. package/link/core-aspects-links.ts +50 -0
  66. package/link/get-package-name-from-target.ts +5 -0
  67. package/link/index.ts +1 -0
  68. package/link/link-row.ts +20 -0
  69. package/link/link-to-dir.ts +13 -0
  70. package/link/link.cmd.ts +112 -0
  71. package/link/nested-deps-in-nm-links.ts +47 -0
  72. package/link/rewire-row.ts +17 -0
  73. package/package.json +95 -0
  74. package/types/asset.d.ts +41 -0
  75. package/types/style.d.ts +42 -0
  76. package/uninstall.cmd.tsx +18 -0
  77. package/update.cmd.tsx +67 -0
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+
3
+ function _chai() {
4
+ const data = require("chai");
5
+ _chai = function () {
6
+ return data;
7
+ };
8
+ return data;
9
+ }
10
+ function _stripAnsi() {
11
+ const data = _interopRequireDefault(require("strip-ansi"));
12
+ _stripAnsi = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _component() {
18
+ const data = require("@teambit/component");
19
+ _component = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _pickOutdatedPkgs() {
25
+ const data = require("./pick-outdated-pkgs");
26
+ _pickOutdatedPkgs = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
32
+ describe('makeOutdatedPkgChoices', () => {
33
+ it('should render choices in correct order', () => {
34
+ const choices = (0, _pickOutdatedPkgs().makeOutdatedPkgChoices)([{
35
+ name: 'zoo',
36
+ currentRange: '1.0.0',
37
+ latestRange: '1.1.0',
38
+ source: 'rootPolicy',
39
+ targetField: 'devDependencies'
40
+ }, {
41
+ name: 'qar',
42
+ currentRange: '1.0.0',
43
+ latestRange: '1.1.0',
44
+ source: 'rootPolicy',
45
+ targetField: 'dependencies'
46
+ }, {
47
+ name: 'foo',
48
+ currentRange: '1.0.0',
49
+ latestRange: '2.0.0',
50
+ source: 'rootPolicy',
51
+ targetField: 'dependencies'
52
+ }, {
53
+ name: 'bar',
54
+ currentRange: '1.0.0',
55
+ latestRange: '1.1.0',
56
+ source: 'rootPolicy',
57
+ targetField: 'peerDependencies'
58
+ }]);
59
+ // Removing the ansi chars for better work on bit build on ci
60
+ const stripped = stripAnsiFromChoices(choices);
61
+ // @ts-ignore
62
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
63
+ (0, _chai().expect)(stripped).to.deep.equal(orderedChoices);
64
+ });
65
+ it('should render choices with context information', () => {
66
+ const choices = (0, _pickOutdatedPkgs().makeOutdatedPkgChoices)([{
67
+ name: 'foo',
68
+ currentRange: '1.0.0',
69
+ latestRange: '2.0.0',
70
+ source: 'component',
71
+ componentId: _component().ComponentID.fromString('scope/comp1'),
72
+ targetField: 'dependencies'
73
+ }, {
74
+ name: 'bar',
75
+ currentRange: '1.0.0',
76
+ latestRange: '1.1.0',
77
+ source: 'variants',
78
+ variantPattern: '{comp2}',
79
+ targetField: 'peerDependencies'
80
+ }]);
81
+ // Removing the ansi chars for better work on bit build on ci
82
+ const stripped = stripAnsiFromChoices(choices);
83
+ // @ts-ignore
84
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
85
+ (0, _chai().expect)(stripped).to.deep.equal(contextOrders);
86
+ });
87
+ });
88
+ function stripAnsiFromChoices(choices) {
89
+ choices.forEach(choice => {
90
+ choice.message = (0, _stripAnsi().default)(choice.message);
91
+ choice.choices.forEach(currChoice => {
92
+ currChoice.message = (0, _stripAnsi().default)(currChoice.message);
93
+ });
94
+ });
95
+ return choices;
96
+ }
97
+ const orderedChoices = [{
98
+ choices: [{
99
+ message: 'foo (runtime) 1.0.0 ❯ 2.0.0 ',
100
+ name: 'foo',
101
+ value: {
102
+ currentRange: '1.0.0',
103
+ latestRange: '2.0.0',
104
+ name: 'foo',
105
+ source: 'rootPolicy',
106
+ targetField: 'dependencies'
107
+ }
108
+ }, {
109
+ message: 'qar (runtime) 1.0.0 ❯ 1.1.0 ',
110
+ name: 'qar',
111
+ value: {
112
+ currentRange: '1.0.0',
113
+ latestRange: '1.1.0',
114
+ name: 'qar',
115
+ source: 'rootPolicy',
116
+ targetField: 'dependencies'
117
+ }
118
+ }, {
119
+ message: 'zoo (dev) 1.0.0 ❯ 1.1.0 ',
120
+ name: 'zoo',
121
+ value: {
122
+ currentRange: '1.0.0',
123
+ latestRange: '1.1.0',
124
+ name: 'zoo',
125
+ source: 'rootPolicy',
126
+ targetField: 'devDependencies'
127
+ }
128
+ }, {
129
+ message: 'bar (peer) 1.0.0 ❯ 1.1.0 ',
130
+ name: 'bar',
131
+ value: {
132
+ currentRange: '1.0.0',
133
+ latestRange: '1.1.0',
134
+ name: 'bar',
135
+ source: 'rootPolicy',
136
+ targetField: 'peerDependencies'
137
+ }
138
+ }],
139
+ message: 'Root policies'
140
+ }];
141
+ const contextOrders = [{
142
+ choices: [{
143
+ message: 'foo (runtime) 1.0.0 ❯ 2.0.0 ',
144
+ name: 'foo',
145
+ value: {
146
+ componentId: _component().ComponentID.fromString('scope/comp1'),
147
+ currentRange: '1.0.0',
148
+ latestRange: '2.0.0',
149
+ name: 'foo',
150
+ source: 'component',
151
+ targetField: 'dependencies'
152
+ }
153
+ }],
154
+ message: 'scope/comp1 (component)'
155
+ }, {
156
+ choices: [{
157
+ message: 'bar (peer) 1.0.0 ❯ 1.1.0 ',
158
+ name: 'bar',
159
+ value: {
160
+ currentRange: '1.0.0',
161
+ latestRange: '1.1.0',
162
+ name: 'bar',
163
+ source: 'variants',
164
+ targetField: 'peerDependencies',
165
+ variantPattern: '{comp2}'
166
+ }
167
+ }],
168
+ message: '{comp2} (variant)'
169
+ }];
170
+
171
+ //# sourceMappingURL=pick-outdated-pkgs.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chai","data","require","_stripAnsi","_interopRequireDefault","_component","_pickOutdatedPkgs","e","__esModule","default","describe","it","choices","makeOutdatedPkgChoices","name","currentRange","latestRange","source","targetField","stripped","stripAnsiFromChoices","expect","to","deep","equal","orderedChoices","componentId","ComponentID","fromString","variantPattern","contextOrders","forEach","choice","message","stripAnsi","currChoice","value"],"sources":["pick-outdated-pkgs.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport stripAnsi from 'strip-ansi';\nimport { ComponentID } from '@teambit/component';\nimport { makeOutdatedPkgChoices } from './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 // Removing the ansi chars for better work on bit build on ci\n const stripped = stripAnsiFromChoices(choices);\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n expect(stripped).to.deep.equal(orderedChoices);\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: ComponentID.fromString('scope/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 // Removing the ansi chars for better work on bit build on ci\n const stripped = stripAnsiFromChoices(choices);\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n expect(stripped).to.deep.equal(contextOrders);\n });\n});\n\nfunction stripAnsiFromChoices(choices) {\n choices.forEach((choice) => {\n choice.message = stripAnsi(choice.message);\n choice.choices.forEach((currChoice) => {\n currChoice.message = stripAnsi(currChoice.message);\n });\n });\n return choices;\n}\n\nconst orderedChoices = [\n {\n choices: [\n {\n message: 'foo (runtime) 1.0.0 ❯ 2.0.0 ',\n name: 'foo',\n value: {\n currentRange: '1.0.0',\n latestRange: '2.0.0',\n name: 'foo',\n source: 'rootPolicy',\n targetField: 'dependencies',\n },\n },\n {\n message: 'qar (runtime) 1.0.0 ❯ 1.1.0 ',\n name: 'qar',\n value: {\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n name: 'qar',\n source: 'rootPolicy',\n targetField: 'dependencies',\n },\n },\n {\n message: 'zoo (dev) 1.0.0 ❯ 1.1.0 ',\n name: 'zoo',\n value: {\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n name: 'zoo',\n source: 'rootPolicy',\n targetField: 'devDependencies',\n },\n },\n {\n message: 'bar (peer) 1.0.0 ❯ 1.1.0 ',\n name: 'bar',\n value: {\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n name: 'bar',\n source: 'rootPolicy',\n targetField: 'peerDependencies',\n },\n },\n ],\n message: 'Root policies',\n },\n];\n\nconst contextOrders = [\n {\n choices: [\n {\n message: 'foo (runtime) 1.0.0 ❯ 2.0.0 ',\n name: 'foo',\n value: {\n componentId: ComponentID.fromString('scope/comp1'),\n currentRange: '1.0.0',\n latestRange: '2.0.0',\n name: 'foo',\n source: 'component',\n targetField: 'dependencies',\n },\n },\n ],\n message: 'scope/comp1 (component)',\n },\n {\n choices: [\n {\n message: 'bar (peer) 1.0.0 ❯ 1.1.0 ',\n name: 'bar',\n value: {\n currentRange: '1.0.0',\n latestRange: '1.1.0',\n name: 'bar',\n source: 'variants',\n targetField: 'peerDependencies',\n variantPattern: '{comp2}',\n },\n },\n ],\n message: '{comp2} (variant)',\n },\n];\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ ;
2
+ ;
3
+
4
+ export const compositions = [];
5
+ export const overview = [];
6
+
7
+ export const compositions_metadata = {"compositions":[]};
@@ -0,0 +1,12 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { InstallMain } from './install.main.runtime';
3
+ export default class UninstallCmd implements Command {
4
+ private install;
5
+ name: string;
6
+ description: string;
7
+ alias: string;
8
+ group: string;
9
+ options: CommandOptions;
10
+ constructor(install: InstallMain);
11
+ report([packages]: [string[]]): Promise<string>;
12
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ class UninstallCmd {
11
+ constructor(install) {
12
+ this.install = install;
13
+ _defineProperty(this, "name", 'uninstall [packages...]');
14
+ _defineProperty(this, "description", 'uninstall dependencies');
15
+ _defineProperty(this, "alias", 'un');
16
+ _defineProperty(this, "group", 'dependencies');
17
+ _defineProperty(this, "options", []);
18
+ }
19
+ async report([packages = []]) {
20
+ await this.install.uninstallDependencies(packages);
21
+ return '';
22
+ }
23
+ }
24
+ exports.default = UninstallCmd;
25
+
26
+ //# sourceMappingURL=uninstall.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UninstallCmd","constructor","install","_defineProperty","report","packages","uninstallDependencies","exports","default"],"sources":["uninstall.cmd.tsx"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\n\nimport { InstallMain } from './install.main.runtime';\n\nexport default class UninstallCmd implements Command {\n name = 'uninstall [packages...]';\n description = 'uninstall dependencies';\n alias = 'un';\n group = 'dependencies';\n options = [] as CommandOptions;\n\n constructor(private install: InstallMain) {}\n\n async report([packages = []]: [string[]]) {\n await this.install.uninstallDependencies(packages);\n return '';\n }\n}\n"],"mappings":";;;;;;;;;AAIe,MAAMA,YAAY,CAAoB;EAOnDC,WAAWA,CAASC,OAAoB,EAAE;IAAA,KAAtBA,OAAoB,GAApBA,OAAoB;IAAAC,eAAA,eANjC,yBAAyB;IAAAA,eAAA,sBAClB,wBAAwB;IAAAA,eAAA,gBAC9B,IAAI;IAAAA,eAAA,gBACJ,cAAc;IAAAA,eAAA,kBACZ,EAAE;EAE+B;EAE3C,MAAMC,MAAMA,CAAC,CAACC,QAAQ,GAAG,EAAE,CAAa,EAAE;IACxC,MAAM,IAAI,CAACH,OAAO,CAACI,qBAAqB,CAACD,QAAQ,CAAC;IAClD,OAAO,EAAE;EACX;AACF;AAACE,OAAA,CAAAC,OAAA,GAAAR,YAAA","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { InstallMain } from './install.main.runtime';
3
+ type UpdateCmdOptions = {
4
+ yes?: boolean;
5
+ patterns?: string[];
6
+ major?: boolean;
7
+ minor?: boolean;
8
+ patch?: boolean;
9
+ semver?: boolean;
10
+ };
11
+ export default class UpdateCmd implements Command {
12
+ private install;
13
+ name: string;
14
+ description: string;
15
+ helpUrl: string;
16
+ alias: string;
17
+ group: string;
18
+ arguments: {
19
+ name: string;
20
+ description: string;
21
+ }[];
22
+ options: CommandOptions;
23
+ constructor(install: InstallMain);
24
+ report([patterns]: [string[]], options: UpdateCmdOptions): Promise<string>;
25
+ }
26
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ class UpdateCmd {
11
+ constructor(install) {
12
+ this.install = install;
13
+ _defineProperty(this, "name", 'update [package-patterns...]');
14
+ _defineProperty(this, "description", 'update dependencies. By default, dependencies are updated to the highest semver compatible versions.');
15
+ _defineProperty(this, "helpUrl", 'reference/dependencies/configuring-dependencies/#update-dependencies');
16
+ _defineProperty(this, "alias", 'up');
17
+ _defineProperty(this, "group", 'dependencies');
18
+ _defineProperty(this, "arguments", [{
19
+ name: 'package-patterns...',
20
+ description: 'a string list of package names, or patterns (separated by spaces or commas), e.g. "@teambit/**,@my-org/ui.**". The patterns should be in glob format. By default, all packages are selected.'
21
+ }]);
22
+ _defineProperty(this, "options", [['y', 'yes', 'automatically update all outdated versions for packages specified in pattern (all if no pattern supplied) - use carefully as could result in breaking updates for dependencies'], ['', 'patch', 'update to the latest patch version. Semver rules are ignored'], ['', 'minor', 'update to the latest minor version. Semver rules are ignored'], ['', 'major', 'update to the latest major version. Semver rules are ignored'], ['', 'semver', 'update to the newest version respecting semver']]);
23
+ }
24
+ async report([patterns = []], options) {
25
+ let forceVersionBump;
26
+ if (options.major) {
27
+ forceVersionBump = 'major';
28
+ } else if (options.minor) {
29
+ forceVersionBump = 'minor';
30
+ } else if (options.patch) {
31
+ forceVersionBump = 'patch';
32
+ } else if (options.semver) {
33
+ forceVersionBump = 'compatible';
34
+ }
35
+ await this.install.updateDependencies({
36
+ all: options.yes === true,
37
+ patterns: splitPatterns(patterns),
38
+ forceVersionBump
39
+ });
40
+ return '';
41
+ }
42
+ }
43
+ exports.default = UpdateCmd;
44
+ function splitPatterns(patterns) {
45
+ const splittedPatterns = [];
46
+ for (const pattern of patterns) {
47
+ splittedPatterns.push(...pattern.split(/[, ]/));
48
+ }
49
+ return splittedPatterns;
50
+ }
51
+
52
+ //# sourceMappingURL=update.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UpdateCmd","constructor","install","_defineProperty","name","description","report","patterns","options","forceVersionBump","major","minor","patch","semver","updateDependencies","all","yes","splitPatterns","exports","default","splittedPatterns","pattern","push","split"],"sources":["update.cmd.tsx"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\n\nimport { InstallMain } from './install.main.runtime';\n\ntype UpdateCmdOptions = {\n yes?: boolean;\n patterns?: string[];\n major?: boolean;\n minor?: boolean;\n patch?: boolean;\n semver?: boolean;\n};\n\nexport default class UpdateCmd implements Command {\n name = 'update [package-patterns...]';\n description = 'update dependencies. By default, dependencies are updated to the highest semver compatible versions.';\n helpUrl = 'reference/dependencies/configuring-dependencies/#update-dependencies';\n alias = 'up';\n group = 'dependencies';\n arguments = [\n {\n name: 'package-patterns...',\n description:\n 'a string list of package names, or patterns (separated by spaces or commas), e.g. \"@teambit/**,@my-org/ui.**\". The patterns should be in glob format. By default, all packages are selected.',\n },\n ];\n options = [\n [\n 'y',\n 'yes',\n 'automatically update all outdated versions for packages specified in pattern (all if no pattern supplied) - use carefully as could result in breaking updates for dependencies',\n ],\n ['', 'patch', 'update to the latest patch version. Semver rules are ignored'],\n ['', 'minor', 'update to the latest minor version. Semver rules are ignored'],\n ['', 'major', 'update to the latest major version. Semver rules are ignored'],\n ['', 'semver', 'update to the newest version respecting semver'],\n ] as CommandOptions;\n\n constructor(private install: InstallMain) {}\n\n async report([patterns = []]: [string[]], options: UpdateCmdOptions) {\n let forceVersionBump: 'major' | 'minor' | 'patch' | 'compatible' | undefined;\n if (options.major) {\n forceVersionBump = 'major';\n } else if (options.minor) {\n forceVersionBump = 'minor';\n } else if (options.patch) {\n forceVersionBump = 'patch';\n } else if (options.semver) {\n forceVersionBump = 'compatible';\n }\n await this.install.updateDependencies({\n all: options.yes === true,\n patterns: splitPatterns(patterns),\n forceVersionBump,\n });\n return '';\n }\n}\n\nfunction splitPatterns(patterns: string[]): string[] {\n const splittedPatterns: string[] = [];\n for (const pattern of patterns) {\n splittedPatterns.push(...pattern.split(/[, ]/));\n }\n return splittedPatterns;\n}\n"],"mappings":";;;;;;;;;AAae,MAAMA,SAAS,CAAoB;EAyBhDC,WAAWA,CAASC,OAAoB,EAAE;IAAA,KAAtBA,OAAoB,GAApBA,OAAoB;IAAAC,eAAA,eAxBjC,8BAA8B;IAAAA,eAAA,sBACvB,sGAAsG;IAAAA,eAAA,kBAC1G,sEAAsE;IAAAA,eAAA,gBACxE,IAAI;IAAAA,eAAA,gBACJ,cAAc;IAAAA,eAAA,oBACV,CACV;MACEC,IAAI,EAAE,qBAAqB;MAC3BC,WAAW,EACT;IACJ,CAAC,CACF;IAAAF,eAAA,kBACS,CACR,CACE,GAAG,EACH,KAAK,EACL,gLAAgL,CACjL,EACD,CAAC,EAAE,EAAE,OAAO,EAAE,8DAA8D,CAAC,EAC7E,CAAC,EAAE,EAAE,OAAO,EAAE,8DAA8D,CAAC,EAC7E,CAAC,EAAE,EAAE,OAAO,EAAE,8DAA8D,CAAC,EAC7E,CAAC,EAAE,EAAE,QAAQ,EAAE,gDAAgD,CAAC,CACjE;EAE0C;EAE3C,MAAMG,MAAMA,CAAC,CAACC,QAAQ,GAAG,EAAE,CAAa,EAAEC,OAAyB,EAAE;IACnE,IAAIC,gBAAwE;IAC5E,IAAID,OAAO,CAACE,KAAK,EAAE;MACjBD,gBAAgB,GAAG,OAAO;IAC5B,CAAC,MAAM,IAAID,OAAO,CAACG,KAAK,EAAE;MACxBF,gBAAgB,GAAG,OAAO;IAC5B,CAAC,MAAM,IAAID,OAAO,CAACI,KAAK,EAAE;MACxBH,gBAAgB,GAAG,OAAO;IAC5B,CAAC,MAAM,IAAID,OAAO,CAACK,MAAM,EAAE;MACzBJ,gBAAgB,GAAG,YAAY;IACjC;IACA,MAAM,IAAI,CAACP,OAAO,CAACY,kBAAkB,CAAC;MACpCC,GAAG,EAAEP,OAAO,CAACQ,GAAG,KAAK,IAAI;MACzBT,QAAQ,EAAEU,aAAa,CAACV,QAAQ,CAAC;MACjCE;IACF,CAAC,CAAC;IACF,OAAO,EAAE;EACX;AACF;AAACS,OAAA,CAAAC,OAAA,GAAAnB,SAAA;AAED,SAASiB,aAAaA,CAACV,QAAkB,EAAY;EACnD,MAAMa,gBAA0B,GAAG,EAAE;EACrC,KAAK,MAAMC,OAAO,IAAId,QAAQ,EAAE;IAC9Ba,gBAAgB,CAACE,IAAI,CAAC,GAAGD,OAAO,CAACE,KAAK,CAAC,MAAM,CAAC,CAAC;EACjD;EACA,OAAOH,gBAAgB;AACzB","ignoreList":[]}
package/esm.mjs ADDED
@@ -0,0 +1,7 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import cjsModule from './index.js';
3
+
4
+ export const InstallAspect = cjsModule.InstallAspect;
5
+ export const getAnotherInstallRequiredOutput = cjsModule.getAnotherInstallRequiredOutput;
6
+
7
+ export default cjsModule;
@@ -0,0 +1,7 @@
1
+ import { BitError } from '@teambit/bit-error';
2
+
3
+ export class DependencyTypeNotSupportedInPolicy extends BitError {
4
+ constructor(type: string) {
5
+ super(`the workspace policy does not support ${type} dependencies`);
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ export { DependencyTypeNotSupportedInPolicy } from './dependency-type-not-supported-in-policy';
@@ -0,0 +1,189 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import packageNameValidate from 'validate-npm-package-name';
3
+ import { WorkspaceDependencyLifecycleType } from '@teambit/dependency-resolver';
4
+ import { Logger } from '@teambit/logger';
5
+ import chalk from 'chalk';
6
+ import { OutsideWorkspaceError, Workspace } from '@teambit/workspace';
7
+ import { InstallMain, WorkspaceInstallOptions } from './install.main.runtime';
8
+
9
+ type InstallCmdOptions = {
10
+ type: WorkspaceDependencyLifecycleType;
11
+ skipDedupe: boolean;
12
+ skipImport: boolean;
13
+ skipCompile: boolean;
14
+ skipWriteConfigFiles: boolean;
15
+ update: boolean;
16
+ updateExisting: boolean;
17
+ savePrefix: string;
18
+ addMissingDeps: boolean;
19
+ skipUnavailable: boolean;
20
+ addMissingPeers: boolean;
21
+ noOptional: boolean;
22
+ recurringInstall: boolean;
23
+ lockfileOnly: boolean;
24
+ };
25
+
26
+ type FormatOutputArgs = {
27
+ numOfComps: string;
28
+ startTime: number;
29
+ endTime: number;
30
+ oldNonLoadedEnvs: string[];
31
+ recurringInstall: boolean;
32
+ };
33
+
34
+ const recurringInstallFlagName = 'recurring-install';
35
+
36
+ export default class InstallCmd implements Command {
37
+ name = 'install [packages...]';
38
+ description = 'installs workspace dependencies';
39
+ extendedDescription =
40
+ 'when no package is specified, all workspace dependencies are installed and all workspace components are imported.';
41
+ helpUrl = 'reference/dependencies/dependency-installation';
42
+ arguments = [{ name: 'packages...', description: 'a list of packages to install (separated by spaces)' }];
43
+ alias = 'in';
44
+ group = 'dependencies';
45
+ options = [
46
+ ['t', 'type [lifecycleType]', '"runtime" (default) or "peer" (dev is not a valid option)'],
47
+ ['u', 'update', 'update all dependencies to latest version according to their semver range'],
48
+ [
49
+ '',
50
+ 'update-existing',
51
+ 'DEPRECATED (not needed anymore, it is the default now). update existing dependencies version and types',
52
+ ],
53
+ ['', 'save-prefix [savePrefix]', 'set the prefix to use when adding dependency to workspace.jsonc'],
54
+ ['', 'skip-dedupe', 'do not dedupe dependencies on installation'],
55
+ ['', 'skip-import', 'do not import bit objects post installation'],
56
+ ['', 'skip-compile', 'do not compile components'],
57
+ ['', 'skip-write-config-files', 'do not write config files (such as eslint, tsconfig, prettier, etc...)'],
58
+ ['a', 'add-missing-deps', 'install all missing dependencies'],
59
+ ['', 'skip-unavailable', 'when adding missing dependencies, skip those that are not found in the regisry'],
60
+ ['', 'add-missing-peers', 'install all missing peer dependencies'],
61
+ [
62
+ '',
63
+ recurringInstallFlagName,
64
+ 'automatically run install again if there are non loaded old envs in your workspace',
65
+ ],
66
+ ['', 'no-optional [noOptional]', 'do not install optional dependencies (works with pnpm only)'],
67
+ ['', 'lockfile-only', 'dependencies are not written to node_modules. Only the lockfile is updated'],
68
+ ] as CommandOptions;
69
+
70
+ constructor(
71
+ private install: InstallMain,
72
+ /**
73
+ * workspace extension.
74
+ */
75
+ private workspace: Workspace,
76
+
77
+ /**
78
+ * logger extension.
79
+ */
80
+ private logger: Logger
81
+ ) {}
82
+
83
+ async report([packages = []]: [string[]], options: InstallCmdOptions) {
84
+ const startTime = Date.now();
85
+ if (!this.workspace) throw new OutsideWorkspaceError();
86
+ if (options.updateExisting) {
87
+ this.logger.consoleWarning(
88
+ `--update-existing is deprecated, please omit it. "bit install" will update existing dependencies by default`
89
+ );
90
+ }
91
+
92
+ packages.forEach((pkg) => {
93
+ const pkgName = extractPackageName(pkg);
94
+ if (!packageNameValidate(pkgName).validForNewPackages) {
95
+ throw new Error(`the package name "${pkgName}" is invalid. please provide a valid package name.`);
96
+ }
97
+ });
98
+ this.logger.console(`Resolving component dependencies for workspace: '${chalk.cyan(this.workspace.name)}'`);
99
+ const installOpts: WorkspaceInstallOptions = {
100
+ lifecycleType: options.addMissingPeers ? 'peer' : options.type,
101
+ dedupe: !options.skipDedupe,
102
+ import: !options.skipImport,
103
+ updateExisting: true,
104
+ savePrefix: options.savePrefix,
105
+ addMissingDeps: options.addMissingDeps,
106
+ skipUnavailable: options.skipUnavailable,
107
+ addMissingPeers: options.addMissingPeers,
108
+ compile: !options.skipCompile,
109
+ includeOptionalDeps: !options.noOptional,
110
+ writeConfigFiles: !options.skipWriteConfigFiles,
111
+ updateAll: options.update,
112
+ recurringInstall: options.recurringInstall,
113
+ lockfileOnly: options.lockfileOnly,
114
+ };
115
+ const components = await this.install.install(packages, installOpts);
116
+ const endTime = Date.now();
117
+ const oldNonLoadedEnvs = this.install.getOldNonLoadedEnvs();
118
+ return formatOutput({
119
+ startTime,
120
+ endTime,
121
+ numOfComps: components.toArray().length.toString(),
122
+ recurringInstall: options[recurringInstallFlagName],
123
+ oldNonLoadedEnvs,
124
+ });
125
+ }
126
+ }
127
+
128
+ function calculateTime(startTime: number, endTime: number) {
129
+ const diff = endTime - startTime;
130
+ return diff / 1000;
131
+ }
132
+
133
+ function formatOutput({
134
+ numOfComps,
135
+ endTime,
136
+ startTime,
137
+ recurringInstall,
138
+ oldNonLoadedEnvs,
139
+ }: FormatOutputArgs): string {
140
+ const executionTime = calculateTime(startTime, endTime);
141
+ const summary = chalk.green(
142
+ `Successfully installed dependencies and compiled ${chalk.cyan(numOfComps)} component(s) in ${chalk.cyan(
143
+ executionTime.toString()
144
+ )} seconds`
145
+ );
146
+ const anotherInstallRequiredOutput = getAnotherInstallRequiredOutput(recurringInstall, oldNonLoadedEnvs);
147
+ return anotherInstallRequiredOutput ? `\n${anotherInstallRequiredOutput}\n\n${summary}` : `\n${summary}`;
148
+ }
149
+
150
+ export function getAnotherInstallRequiredOutput(recurringInstall = false, oldNonLoadedEnvs: string[] = []): string {
151
+ if (!oldNonLoadedEnvs.length) return '';
152
+ const oldNonLoadedEnvsStr = oldNonLoadedEnvs.join(', ');
153
+ const firstPart = `Bit was not able to install all dependencies. Please run "${chalk.cyan('bit install')}" again `;
154
+ const flag = chalk.cyan(`--${recurringInstallFlagName}`);
155
+ const suggestRecurringInstall = recurringInstall ? '' : `(or use the "${flag}" option next time).`;
156
+ const envsStr = `The following environments need to add support for "dependency policy" to fix the warning: ${chalk.cyan(
157
+ oldNonLoadedEnvsStr
158
+ )}`;
159
+ const docsLink = `Read more about how to fix this issue in: https://bit.dev/blog/using-a-static-dependency-policy-in-a-legacy-env-lihfbt9b`;
160
+
161
+ const msg = `${firstPart}${suggestRecurringInstall}\n${envsStr}\n${docsLink}`;
162
+ return chalk.yellow(msg);
163
+ }
164
+
165
+ function extractPackageName(packageString: string): string {
166
+ if (!packageString) return '';
167
+
168
+ // Handle https and git protocols. We don't allow "file" protocol here. It won't work for the consumer.
169
+ const allowedPrefixes = ['https://', 'git:', 'git+ssh://', 'git+https://'];
170
+ if (allowedPrefixes.some((prefix) => packageString.startsWith(prefix))) {
171
+ return packageString;
172
+ }
173
+
174
+ // If it's a scoped package
175
+ if (packageString.startsWith('@')) {
176
+ // Find the second '@' (first is for scope, second is for version/tag)
177
+ const atIndex = packageString.indexOf('@', 1);
178
+ if (atIndex === -1) return packageString;
179
+ const possibleVersion = packageString.slice(atIndex + 1);
180
+ // If the part after the second '@' contains a slash, it's not a version/tag
181
+ if (possibleVersion.includes('/')) return packageString;
182
+ return packageString.slice(0, atIndex);
183
+ }
184
+
185
+ // For unscoped packages, split at the last '@'
186
+ const lastAtIndex = packageString.lastIndexOf('@');
187
+ if (lastAtIndex <= 0) return packageString;
188
+ return packageString.slice(0, lastAtIndex);
189
+ }
@@ -0,0 +1,66 @@
1
+ import chalk from 'chalk';
2
+ import { NodeModulesLinksResult } from '@teambit/workspace.modules.node-modules-linker';
3
+ import { getPackageNameFromTarget } from './get-package-name-from-target';
4
+ import { LinkRow, VerboseLinkRow } from './link-row';
5
+ import { LinkDetail } from '@teambit/dependency-resolver';
6
+
7
+ type ComponentListLinksProps = {
8
+ componentListLinks?: NodeModulesLinksResult[];
9
+ verbose: boolean;
10
+ };
11
+
12
+ export function ComponentListLinks({ componentListLinks, verbose = false }: ComponentListLinksProps) {
13
+ if (!componentListLinks || !componentListLinks.length) {
14
+ return chalk.cyan('No components link were generated');
15
+ }
16
+ const title = chalk.bold.cyan('Components links');
17
+ const links = componentListLinks.map((componentLinks) => ComponentLinks({ componentLinks, verbose })).join('\n');
18
+
19
+ return `${title}\n${links}`;
20
+ }
21
+
22
+ export function packageListLinks(packageList?: LinkDetail[]) {
23
+ if (!packageList || !packageList.length) {
24
+ return '';
25
+ }
26
+ const title = chalk.bold.cyan('Non-Core Package links');
27
+
28
+ const links = packageList.map((link) => {
29
+ const id = link.packageName;
30
+ const packagePath = getPackageNameFromTarget(link.to);
31
+ return LinkRow({ title: id, target: packagePath, padding: 50 });
32
+ }).join('\n');
33
+
34
+ return `${title}\n${links}`;
35
+ }
36
+
37
+ type ComponentLinksProps = {
38
+ componentLinks: NodeModulesLinksResult;
39
+ verbose: boolean;
40
+ };
41
+ function ComponentLinks({ componentLinks, verbose = false }: ComponentLinksProps) {
42
+ if (!componentLinks.bound || componentLinks.bound.length < 1) return '';
43
+ if (verbose) return VerboseComponentLinks({ componentLinks });
44
+ return RegularComponentLinks({ componentLinks });
45
+ }
46
+
47
+ type RegularComponentLinksProps = {
48
+ componentLinks: NodeModulesLinksResult;
49
+ };
50
+ function RegularComponentLinks({ componentLinks }: RegularComponentLinksProps) {
51
+ const id = componentLinks.id.toString();
52
+ if (!componentLinks.bound || componentLinks.bound.length < 1) return '';
53
+ const packagePath = getPackageNameFromTarget(componentLinks.bound[0].to);
54
+ return LinkRow({ title: id, target: packagePath, padding: 50 });
55
+ }
56
+
57
+ type VerboseComponentLinksProps = {
58
+ componentLinks: NodeModulesLinksResult;
59
+ };
60
+ function VerboseComponentLinks({ componentLinks }: VerboseComponentLinksProps) {
61
+ const id = componentLinks.id.toString();
62
+ if (!componentLinks.bound || componentLinks.bound.length < 1) return '';
63
+ const title = chalk.bold.cyan(id);
64
+ const links = componentLinks.bound.map((link) => VerboseLinkRow({ from: link.from, to: link.to })).join('\n');
65
+ return `${title}\n${links}\n`;
66
+ }
@@ -0,0 +1,50 @@
1
+ import { CoreAspectLinkResult } from '@teambit/dependency-resolver';
2
+ import chalk from 'chalk';
3
+
4
+ import { getPackageNameFromTarget } from './get-package-name-from-target';
5
+ import { LinkRow, VerboseLinkRow } from './link-row';
6
+
7
+ type CoreAspectsLinksProps = {
8
+ coreAspectsLinks?: CoreAspectLinkResult[];
9
+ verbose: boolean;
10
+ };
11
+
12
+ export function CoreAspectsLinks({ coreAspectsLinks, verbose = false }: CoreAspectsLinksProps) {
13
+ if (!coreAspectsLinks || !coreAspectsLinks.length) {
14
+ return chalk.cyan('No core aspects were linked');
15
+ }
16
+ const title = chalk.cyan('Core aspects links');
17
+ const links = coreAspectsLinks.map((link) => CoreAspectLinkRow({ coreAspectLink: link, verbose })).join('\n');
18
+ return `${title}\n${links}`;
19
+ }
20
+
21
+ type CoreAspectLinkProps = {
22
+ coreAspectLink: CoreAspectLinkResult;
23
+ verbose: boolean;
24
+ };
25
+ function CoreAspectLinkRow({ coreAspectLink, verbose = false }: CoreAspectLinkProps) {
26
+ if (verbose) return VerboseCoreAspectLink({ coreAspectLink });
27
+ return RegularCoreAspectLink({ coreAspectLink });
28
+ }
29
+
30
+ type RegularCoreAspectLinkProps = {
31
+ coreAspectLink: CoreAspectLinkResult;
32
+ };
33
+ function RegularCoreAspectLink({ coreAspectLink }: RegularCoreAspectLinkProps) {
34
+ const id = coreAspectLink.aspectId.toString();
35
+ const packagePath = getPackageNameFromTarget(coreAspectLink.linkDetail.to);
36
+ return LinkRow({ title: id, target: packagePath, padding: 50 });
37
+ }
38
+
39
+ type VerboseCoreAspectLinkProps = {
40
+ coreAspectLink: CoreAspectLinkResult;
41
+ };
42
+ function VerboseCoreAspectLink({ coreAspectLink }: VerboseCoreAspectLinkProps) {
43
+ const id = coreAspectLink.aspectId.toString();
44
+ const title = chalk.bold.cyan(id);
45
+ const link = VerboseLinkRow({
46
+ from: coreAspectLink.linkDetail.from,
47
+ to: coreAspectLink.linkDetail.to,
48
+ });
49
+ return `${title}\n${link}`;
50
+ }