@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,5 @@
1
+ export function getPackageNameFromTarget(targetPath: string): string {
2
+ const subPath = targetPath.substring(targetPath.lastIndexOf('node_modules'));
3
+ const packagePath = subPath.split('/').slice(0, 3).join('/');
4
+ return `./${packagePath}`;
5
+ }
package/link/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { LinkCommand } from './link.cmd';
@@ -0,0 +1,20 @@
1
+ import chalk from 'chalk';
2
+
3
+ type LinkRowProps = {
4
+ title: string;
5
+ target: string;
6
+ padding?: number;
7
+ };
8
+ export function LinkRow({ title, target, padding = 50 }: LinkRowProps) {
9
+ return chalk.bold(`${title.padEnd(padding)} ${'>'} ${target}`);
10
+ }
11
+
12
+ type VerboseLinkRowProps = {
13
+ from: string;
14
+ to: string;
15
+ };
16
+ export function VerboseLinkRow({ from, to }: VerboseLinkRowProps) {
17
+ return `${chalk.bold('from')}: ${from}
18
+ ${chalk.bold('to')}: ${to}
19
+ `;
20
+ }
@@ -0,0 +1,13 @@
1
+ import { LinkToDirResult } from '@teambit/dependency-resolver';
2
+ import chalk from 'chalk';
3
+ import { LinkRow } from './link-row';
4
+
5
+ export function linkToDir(links?: LinkToDirResult[]) {
6
+ if (!links || !links.length) return '';
7
+ const title = chalk.bold.cyan('Target Links');
8
+ const linksOutput = links
9
+ .map(({ componentId, linksDetail }) => LinkRow({ title: componentId, target: linksDetail.to }))
10
+ .join('\n');
11
+
12
+ return `${title}\n${linksOutput}`;
13
+ }
@@ -0,0 +1,112 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { Logger } from '@teambit/logger';
3
+ import { timeFormat } from '@teambit/toolbox.time.time-format';
4
+ import { compact } from 'lodash';
5
+ import chalk from 'chalk';
6
+ import { Workspace } from '@teambit/workspace';
7
+ import { InstallMain, WorkspaceLinkOptions, WorkspaceLinkResults } from '../install.main.runtime';
8
+ import { ComponentListLinks, packageListLinks } from './component-list-links';
9
+ import { CoreAspectsLinks } from './core-aspects-links';
10
+ import { NestedComponentLinksLinks } from './nested-deps-in-nm-links';
11
+ import { RewireRow } from './rewire-row';
12
+ import { linkToDir } from './link-to-dir';
13
+
14
+ type LinkCommandOpts = {
15
+ rewire: boolean;
16
+ verbose: boolean;
17
+ target: string;
18
+ skipFetchingObjects?: boolean;
19
+ peers?: boolean;
20
+ };
21
+ export class LinkCommand implements Command {
22
+ name = 'link [component-names...]';
23
+ alias = '';
24
+ description = 'create links in the node_modules directory, to core aspects and to components in the workspace';
25
+ helpUrl = 'reference/workspace/component-links';
26
+ extendedDescription: string;
27
+ group = 'dependencies';
28
+ private = false;
29
+ arguments = [{ name: 'component-names...', description: 'names or IDs of the components to link' }];
30
+ options = [
31
+ ['j', 'json', 'return the output as JSON'],
32
+ ['', 'verbose', 'verbose output'],
33
+ ['r', 'rewire', 'Replace relative paths with module paths in code (e.g. "../foo" => "@bit/foo")'],
34
+ [
35
+ '',
36
+ 'target <dir>',
37
+ 'link to an external directory (similar to npm-link) so other projects could use these components',
38
+ ],
39
+ ['', 'skip-fetching-objects', 'skip fetch missing objects from remotes before linking'],
40
+ ['', 'peers', 'link peer dependencies of the components too'],
41
+ ] as CommandOptions;
42
+
43
+ constructor(
44
+ private install: InstallMain,
45
+ /**
46
+ * workspace extension.
47
+ */
48
+ private workspace: Workspace,
49
+
50
+ /**
51
+ * logger extension.
52
+ */
53
+ private logger: Logger
54
+ ) {}
55
+
56
+ async report([ids]: [string[]], opts: LinkCommandOpts) {
57
+ const startTime = Date.now();
58
+ const linkResults = await this.json([ids], opts);
59
+ const endTime = Date.now();
60
+ const numOfComponents = linkResults.legacyLinkResults?.length;
61
+ const timeDiff = timeFormat(endTime - startTime);
62
+ const coreAspectsLinksWithMainAspect = linkResults.coreAspectsLinks || [];
63
+ if (linkResults.teambitBitLink) {
64
+ coreAspectsLinksWithMainAspect.unshift(linkResults.teambitBitLink);
65
+ }
66
+ const numOfCoreAspects = coreAspectsLinksWithMainAspect.length;
67
+
68
+ const title = `Linked ${numOfComponents} components and ${numOfCoreAspects} core aspects to node_modules for workspace: ${this.workspace.name}`;
69
+ const coreLinks = CoreAspectsLinks({
70
+ coreAspectsLinks: coreAspectsLinksWithMainAspect,
71
+ verbose: opts.verbose,
72
+ });
73
+ const nonCorePackagesLinks = packageListLinks(linkResults.slotOriginatedLinks);
74
+ const compsLinks = ComponentListLinks({ componentListLinks: linkResults.legacyLinkResults, verbose: opts.verbose });
75
+ const rewireRow = RewireRow({ legacyCodemodResults: linkResults.legacyLinkCodemodResults });
76
+ const nestedLinks = NestedComponentLinksLinks({
77
+ nestedDepsInNmLinks: linkResults.nestedDepsInNmLinks,
78
+ verbose: opts.verbose,
79
+ });
80
+ const targetLinks = linkToDir(linkResults.linkToDirResults);
81
+ const footer = `Finished. ${timeDiff}`;
82
+ return compact([
83
+ title,
84
+ coreLinks,
85
+ nonCorePackagesLinks,
86
+ compsLinks,
87
+ rewireRow,
88
+ nestedLinks,
89
+ targetLinks,
90
+ footer,
91
+ ]).join('\n');
92
+ }
93
+
94
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
95
+ async json([ids]: [string[]], opts: LinkCommandOpts): Promise<WorkspaceLinkResults> {
96
+ this.logger.console(
97
+ `Linking components and core aspects to node_modules for workspaces: '${chalk.cyan(this.workspace.name)}'`
98
+ );
99
+
100
+ const linkOpts: WorkspaceLinkOptions = {
101
+ linkToBitRoots: true,
102
+ rewire: opts.rewire,
103
+ linkCoreAspects: true,
104
+ linkTeambitBit: true,
105
+ linkToDir: opts.target,
106
+ fetchObject: !opts.skipFetchingObjects,
107
+ includePeers: opts.peers,
108
+ };
109
+ const linkResults = await this.install.link(linkOpts);
110
+ return linkResults;
111
+ }
112
+ }
@@ -0,0 +1,47 @@
1
+ import chalk from 'chalk';
2
+ import { NestedNMDepsLinksResult } from '@teambit/dependency-resolver';
3
+ import { VerboseLinkRow } from './link-row';
4
+
5
+ type NestedComponentLinksLinksProps = {
6
+ nestedDepsInNmLinks?: NestedNMDepsLinksResult[];
7
+ verbose: boolean;
8
+ };
9
+
10
+ export function NestedComponentLinksLinks({ nestedDepsInNmLinks, verbose = false }: NestedComponentLinksLinksProps) {
11
+ if (!verbose) return '';
12
+ if (!nestedDepsInNmLinks || !nestedDepsInNmLinks.length) {
13
+ return '';
14
+ }
15
+ const title = chalk.bold.cyan('Nested dependencies links');
16
+ const links = nestedDepsInNmLinks
17
+ .map((nestedComponentLinks) =>
18
+ NestedComponentLinks({
19
+ nestedComponentLinks,
20
+ verbose,
21
+ })
22
+ )
23
+ .join('\n');
24
+ return `${title}\n${links}`;
25
+ }
26
+
27
+ type NestedComponentLinksProps = {
28
+ nestedComponentLinks: NestedNMDepsLinksResult;
29
+ verbose: boolean;
30
+ };
31
+ function NestedComponentLinks({ nestedComponentLinks, verbose = false }: NestedComponentLinksProps) {
32
+ if (!nestedComponentLinks.linksDetail || nestedComponentLinks.linksDetail.length < 1) return '';
33
+ if (verbose) return VerboseNestedComponentLinks({ nestedComponentLinks });
34
+ return '';
35
+ }
36
+
37
+ type VerboseNestedComponentLinksProps = {
38
+ nestedComponentLinks: NestedNMDepsLinksResult;
39
+ };
40
+ function VerboseNestedComponentLinks({ nestedComponentLinks }: VerboseNestedComponentLinksProps) {
41
+ const id = nestedComponentLinks.componentId.toString();
42
+ const title = chalk.cyan.bold(id);
43
+ const links = nestedComponentLinks.linksDetail
44
+ .map((link) => VerboseLinkRow({ from: link.from, to: link.to }))
45
+ .join('\n');
46
+ return `${title}\n${links}\n`;
47
+ }
@@ -0,0 +1,17 @@
1
+ import { CodemodResult } from '@teambit/workspace.modules.node-modules-linker';
2
+ import chalk from 'chalk';
3
+
4
+ type RewireRowProps = {
5
+ legacyCodemodResults?: CodemodResult[];
6
+ };
7
+ export function RewireRow({ legacyCodemodResults }: RewireRowProps) {
8
+ if (!legacyCodemodResults || legacyCodemodResults.length < 1) return '';
9
+ const totalComps = legacyCodemodResults?.length;
10
+ const totalFiles = legacyCodemodResults.reduce((acc, curr) => {
11
+ return acc + curr.changedFiles.length || 0;
12
+ }, 0);
13
+
14
+ return `rewired ${chalk.cyan(totalComps.toString())} components and total of ${chalk.cyan(
15
+ totalFiles.toString()
16
+ )} files`;
17
+ }
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@teambit/install",
3
+ "version": "0.0.0-0494a1bc1f010e387719d84abc70a90c0e5b6b7d",
4
+ "homepage": "https://bit.cloud/teambit/workspace/install",
5
+ "main": "dist/index.js",
6
+ "componentId": {
7
+ "scope": "teambit.workspace",
8
+ "name": "install",
9
+ "version": "0494a1bc1f010e387719d84abc70a90c0e5b6b7d"
10
+ },
11
+ "dependencies": {
12
+ "chalk": "4.1.2",
13
+ "validate-npm-package-name": "6.0.0",
14
+ "@pnpm/types": "900.0.0",
15
+ "fs-extra": "10.0.0",
16
+ "lodash": "4.17.21",
17
+ "object-hash": "2.1.1",
18
+ "p-filter": "2.1.0",
19
+ "p-map-series": "2.1.0",
20
+ "yesno": "0.4.0",
21
+ "@pnpm/colorize-semver-diff": "1.0.1",
22
+ "@pnpm/semver-diff": "1.1.0",
23
+ "enquirer": "2.4.1",
24
+ "table": "6.7.3",
25
+ "@teambit/harmony": "0.4.7",
26
+ "@teambit/workspace.root-components": "1.0.0",
27
+ "@teambit/bit-error": "0.0.404",
28
+ "@teambit/cli": "0.0.0-ee24c32044fb73e1432f40a04033b3f55dfc5cc0",
29
+ "@teambit/dependency-resolver": "0.0.0-25a17d94fb86cea74e7942f2e06eda9d964c0807",
30
+ "@teambit/logger": "0.0.0-2a45639381a54aac0c52aef9ba8a3340e2fe6869",
31
+ "@teambit/workspace": "0.0.0-b338ceb3d6a238393c6047fa6814ee9dbc8eecc9",
32
+ "@teambit/application": "0.0.0-93daa7917b48b80f64d729f52a5b90fe738b4f69",
33
+ "@teambit/aspect-loader": "0.0.0-c1dae0241940bebcc4f73ff642d05294906e3247",
34
+ "@teambit/bundler": "0.0.0-1b48e169d5145e75ebe590a09c723835901dce5e",
35
+ "@teambit/compiler": "0.0.0-50c24d17b38c6b201fba3cb695eb9c72f11c4ad5",
36
+ "@teambit/component-issues": "0.0.159",
37
+ "@teambit/component-package-version": "0.0.438",
38
+ "@teambit/component": "0.0.0-f7d0cd9c112ea0b3d04c56198cf0b25f8f63769e",
39
+ "@teambit/dependencies.fs.linked-dependencies": "0.0.30",
40
+ "@teambit/envs": "0.0.0-f7a880e73ba7a636a9acff1f3e70be48d5315fbb",
41
+ "@teambit/generator": "0.0.0-2686db33ed7cfb5b2e0119c54b2ba4e998b66ce2",
42
+ "@teambit/ipc-events": "0.0.0-673ddd11d8b984f0f18ea30c4af3921451257085",
43
+ "@teambit/issues": "0.0.0-652010b0985f1baafe830fb459edebf1a8515e01",
44
+ "@teambit/objects": "0.0.0-88eb316de01ab8ca10fb2fd08682fab4d638078d",
45
+ "@teambit/pkg.modules.component-package-name": "0.0.61",
46
+ "@teambit/ui": "0.0.0-3983399d42d14311627c376791069f7ff7b7e4ad",
47
+ "@teambit/variants": "0.0.0-f82a20a2c4c4a720c1a03010b63bfcb242740305",
48
+ "@teambit/workspace-config-files": "0.0.0-93939314358ef03fe1d987cfc2ecaf275d64eff5",
49
+ "@teambit/workspace.modules.node-modules-linker": "0.0.282",
50
+ "@teambit/toolbox.time.time-format": "0.0.500"
51
+ },
52
+ "devDependencies": {
53
+ "@types/fs-extra": "9.0.7",
54
+ "@types/lodash": "4.14.165",
55
+ "@types/object-hash": "1.3.4",
56
+ "strip-ansi": "6.0.0",
57
+ "@types/mocha": "9.1.0",
58
+ "@teambit/harmony.envs.core-aspect-env": "0.0.69"
59
+ },
60
+ "peerDependencies": {
61
+ "chai": "4.3.0",
62
+ "@types/chai": "4.3.19"
63
+ },
64
+ "license": "Apache-2.0",
65
+ "optionalDependencies": {},
66
+ "peerDependenciesMeta": {},
67
+ "exports": {
68
+ ".": {
69
+ "node": {
70
+ "require": "./dist/index.js",
71
+ "import": "./dist/esm.mjs"
72
+ },
73
+ "default": "./dist/index.js"
74
+ },
75
+ "./dist/*": "./dist/*",
76
+ "./artifacts/*": "./artifacts/*",
77
+ "./*": "./*.ts"
78
+ },
79
+ "private": false,
80
+ "engines": {
81
+ "node": ">=16.0.0"
82
+ },
83
+ "repository": {
84
+ "type": "git",
85
+ "url": "https://github.com/teambit/bit"
86
+ },
87
+ "keywords": [
88
+ "bit",
89
+ "bit-aspect",
90
+ "bit-core-aspect",
91
+ "components",
92
+ "collaboration",
93
+ "web"
94
+ ]
95
+ }
@@ -0,0 +1,41 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
11
+ const src: string;
12
+ export default src;
13
+ }
14
+ declare module '*.jpg' {
15
+ const value: any;
16
+ export = value;
17
+ }
18
+ declare module '*.jpeg' {
19
+ const value: any;
20
+ export = value;
21
+ }
22
+ declare module '*.gif' {
23
+ const value: any;
24
+ export = value;
25
+ }
26
+ declare module '*.bmp' {
27
+ const value: any;
28
+ export = value;
29
+ }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }
@@ -0,0 +1,18 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+
3
+ import { InstallMain } from './install.main.runtime';
4
+
5
+ export default class UninstallCmd implements Command {
6
+ name = 'uninstall [packages...]';
7
+ description = 'uninstall dependencies';
8
+ alias = 'un';
9
+ group = 'dependencies';
10
+ options = [] as CommandOptions;
11
+
12
+ constructor(private install: InstallMain) {}
13
+
14
+ async report([packages = []]: [string[]]) {
15
+ await this.install.uninstallDependencies(packages);
16
+ return '';
17
+ }
18
+ }
package/update.cmd.tsx ADDED
@@ -0,0 +1,67 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+
3
+ import { InstallMain } from './install.main.runtime';
4
+
5
+ type UpdateCmdOptions = {
6
+ yes?: boolean;
7
+ patterns?: string[];
8
+ major?: boolean;
9
+ minor?: boolean;
10
+ patch?: boolean;
11
+ semver?: boolean;
12
+ };
13
+
14
+ export default class UpdateCmd implements Command {
15
+ name = 'update [package-patterns...]';
16
+ description = 'update dependencies. By default, dependencies are updated to the highest semver compatible versions.';
17
+ helpUrl = 'reference/dependencies/configuring-dependencies/#update-dependencies';
18
+ alias = 'up';
19
+ group = 'dependencies';
20
+ arguments = [
21
+ {
22
+ name: 'package-patterns...',
23
+ description:
24
+ '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.',
25
+ },
26
+ ];
27
+ options = [
28
+ [
29
+ 'y',
30
+ 'yes',
31
+ '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',
32
+ ],
33
+ ['', 'patch', 'update to the latest patch version. Semver rules are ignored'],
34
+ ['', 'minor', 'update to the latest minor version. Semver rules are ignored'],
35
+ ['', 'major', 'update to the latest major version. Semver rules are ignored'],
36
+ ['', 'semver', 'update to the newest version respecting semver'],
37
+ ] as CommandOptions;
38
+
39
+ constructor(private install: InstallMain) {}
40
+
41
+ async report([patterns = []]: [string[]], options: UpdateCmdOptions) {
42
+ let forceVersionBump: 'major' | 'minor' | 'patch' | 'compatible' | undefined;
43
+ if (options.major) {
44
+ forceVersionBump = 'major';
45
+ } else if (options.minor) {
46
+ forceVersionBump = 'minor';
47
+ } else if (options.patch) {
48
+ forceVersionBump = 'patch';
49
+ } else if (options.semver) {
50
+ forceVersionBump = 'compatible';
51
+ }
52
+ await this.install.updateDependencies({
53
+ all: options.yes === true,
54
+ patterns: splitPatterns(patterns),
55
+ forceVersionBump,
56
+ });
57
+ return '';
58
+ }
59
+ }
60
+
61
+ function splitPatterns(patterns: string[]): string[] {
62
+ const splittedPatterns: string[] = [];
63
+ for (const pattern of patterns) {
64
+ splittedPatterns.push(...pattern.split(/[, ]/));
65
+ }
66
+ return splittedPatterns;
67
+ }