@teambit/install 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__snapshots__/pick-outdated-pkgs.spec.ts.snap +171 -0
- package/dist/__snapshots__/pick-outdated-pkgs.spec.js.snap +171 -0
- package/dist/__snapshots__/pick-outdated-pkgs.spec.ts.snap +171 -0
- package/dist/exceptions/dependency-type-not-supported-in-policy.d.ts +4 -0
- package/dist/exceptions/dependency-type-not-supported-in-policy.js +27 -0
- package/dist/exceptions/dependency-type-not-supported-in-policy.js.map +1 -0
- package/dist/exceptions/index.d.ts +1 -0
- package/dist/exceptions/index.js +23 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/install.aspect.d.ts +2 -0
- package/dist/install.aspect.js +24 -0
- package/dist/install.aspect.js.map +1 -0
- package/dist/install.cmd.d.ts +46 -0
- package/dist/install.cmd.js +86 -0
- package/dist/install.cmd.js.map +1 -0
- package/dist/install.main.runtime.d.ts +76 -0
- package/dist/install.main.runtime.js +580 -0
- package/dist/install.main.runtime.js.map +1 -0
- package/dist/link/component-list-links.d.ts +7 -0
- package/dist/link/component-list-links.js +98 -0
- package/dist/link/component-list-links.js.map +1 -0
- package/dist/link/core-aspects-links.d.ts +7 -0
- package/dist/link/core-aspects-links.js +95 -0
- package/dist/link/core-aspects-links.js.map +1 -0
- package/dist/link/get-package-name-from-target.d.ts +1 -0
- package/dist/link/get-package-name-from-target.js +16 -0
- package/dist/link/get-package-name-from-target.js.map +1 -0
- package/dist/link/index.d.ts +1 -0
- package/dist/link/index.js +23 -0
- package/dist/link/index.js.map +1 -0
- package/dist/link/link-row.d.ts +12 -0
- package/dist/link/link-row.js +38 -0
- package/dist/link/link-row.js.map +1 -0
- package/dist/link/link-to-dir.d.ts +2 -0
- package/dist/link/link-to-dir.js +45 -0
- package/dist/link/link-to-dir.js.map +1 -0
- package/dist/link/link.cmd.d.ts +46 -0
- package/dist/link/link.cmd.js +177 -0
- package/dist/link/link.cmd.js.map +1 -0
- package/dist/link/nested-deps-in-nm-links.d.ts +7 -0
- package/dist/link/nested-deps-in-nm-links.js +74 -0
- package/dist/link/nested-deps-in-nm-links.js.map +1 -0
- package/dist/link/rewire-row.d.ts +6 -0
- package/dist/link/rewire-row.js +31 -0
- package/dist/link/rewire-row.js.map +1 -0
- package/dist/pick-outdated-pkgs.d.ts +16 -0
- package/dist/pick-outdated-pkgs.js +308 -0
- package/dist/pick-outdated-pkgs.js.map +1 -0
- package/dist/pick-outdated-pkgs.spec.d.ts +1 -0
- package/dist/pick-outdated-pkgs.spec.js +121 -0
- package/dist/pick-outdated-pkgs.spec.js.map +1 -0
- package/dist/uninstall.cmd.d.ts +12 -0
- package/dist/uninstall.cmd.js +43 -0
- package/dist/uninstall.cmd.js.map +1 -0
- package/dist/update.cmd.d.ts +16 -0
- package/dist/update.cmd.js +43 -0
- package/dist/update.cmd.js.map +1 -0
- package/exceptions/dependency-type-not-supported-in-policy.ts +7 -0
- package/exceptions/index.ts +1 -0
- package/install.cmd.tsx +74 -0
- package/link/component-list-links.ts +50 -0
- package/link/core-aspects-links.ts +50 -0
- package/link/get-package-name-from-target.ts +5 -0
- package/link/index.ts +1 -0
- package/link/link-row.ts +20 -0
- package/link/link-to-dir.ts +13 -0
- package/link/link.cmd.ts +102 -0
- package/link/nested-deps-in-nm-links.ts +47 -0
- package/link/rewire-row.ts +17 -0
- package/package-tar/teambit-install-0.0.1.tgz +0 -0
- package/package.json +59 -0
- package/preview-1662608124038.js +5 -0
- package/tsconfig.json +40 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
- package/uninstall.cmd.tsx +18 -0
- package/update.cmd.tsx +24 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
6
|
+
|
7
|
+
require("core-js/modules/es.promise.js");
|
8
|
+
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
10
|
+
value: true
|
11
|
+
});
|
12
|
+
exports.default = void 0;
|
13
|
+
|
14
|
+
function _defineProperty2() {
|
15
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
16
|
+
|
17
|
+
_defineProperty2 = function () {
|
18
|
+
return data;
|
19
|
+
};
|
20
|
+
|
21
|
+
return data;
|
22
|
+
}
|
23
|
+
|
24
|
+
class UninstallCmd {
|
25
|
+
constructor(install) {
|
26
|
+
this.install = install;
|
27
|
+
(0, _defineProperty2().default)(this, "name", 'uninstall [packages...]');
|
28
|
+
(0, _defineProperty2().default)(this, "description", 'uninstall dependencies');
|
29
|
+
(0, _defineProperty2().default)(this, "alias", 'un');
|
30
|
+
(0, _defineProperty2().default)(this, "group", 'development');
|
31
|
+
(0, _defineProperty2().default)(this, "options", []);
|
32
|
+
}
|
33
|
+
|
34
|
+
async report([packages = []]) {
|
35
|
+
await this.install.uninstallDependencies(packages);
|
36
|
+
return '';
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
exports.default = UninstallCmd;
|
42
|
+
|
43
|
+
//# sourceMappingURL=uninstall.cmd.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UninstallCmd","constructor","install","report","packages","uninstallDependencies"],"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 = 'development';\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,YAAN,CAAsC;EAOnDC,WAAW,CAASC,OAAT,EAA+B;IAAA,KAAtBA,OAAsB,GAAtBA,OAAsB;IAAA,8CANnC,yBAMmC;IAAA,qDAL5B,wBAK4B;IAAA,+CAJlC,IAIkC;IAAA,+CAHlC,aAGkC;IAAA,iDAFhC,EAEgC;EAAE;;EAEhC,MAANC,MAAM,CAAC,CAACC,QAAQ,GAAG,EAAZ,CAAD,EAA8B;IACxC,MAAM,KAAKF,OAAL,CAAaG,qBAAb,CAAmCD,QAAnC,CAAN;IACA,OAAO,EAAP;EACD;;AAZkD"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
2
|
+
import { InstallMain } from './install.main.runtime';
|
3
|
+
declare type UpdateCmdOptions = {
|
4
|
+
yes?: boolean;
|
5
|
+
};
|
6
|
+
export default class UpdateCmd implements Command {
|
7
|
+
private install;
|
8
|
+
name: string;
|
9
|
+
description: string;
|
10
|
+
alias: string;
|
11
|
+
group: string;
|
12
|
+
options: CommandOptions;
|
13
|
+
constructor(install: InstallMain);
|
14
|
+
report(args: [string[]], options: UpdateCmdOptions): Promise<string>;
|
15
|
+
}
|
16
|
+
export {};
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
require("core-js/modules/es.promise.js");
|
6
|
+
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
exports.default = void 0;
|
11
|
+
|
12
|
+
function _defineProperty2() {
|
13
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
14
|
+
|
15
|
+
_defineProperty2 = function () {
|
16
|
+
return data;
|
17
|
+
};
|
18
|
+
|
19
|
+
return data;
|
20
|
+
}
|
21
|
+
|
22
|
+
class UpdateCmd {
|
23
|
+
constructor(install) {
|
24
|
+
this.install = install;
|
25
|
+
(0, _defineProperty2().default)(this, "name", 'update');
|
26
|
+
(0, _defineProperty2().default)(this, "description", 'update dependencies');
|
27
|
+
(0, _defineProperty2().default)(this, "alias", 'up');
|
28
|
+
(0, _defineProperty2().default)(this, "group", 'development');
|
29
|
+
(0, _defineProperty2().default)(this, "options", [['y', 'yes', 'automatically update all outdated packages']]);
|
30
|
+
}
|
31
|
+
|
32
|
+
async report(args, options) {
|
33
|
+
await this.install.updateDependencies({
|
34
|
+
all: options.yes === true
|
35
|
+
});
|
36
|
+
return '';
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
exports.default = UpdateCmd;
|
42
|
+
|
43
|
+
//# sourceMappingURL=update.cmd.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UpdateCmd","constructor","install","report","args","options","updateDependencies","all","yes"],"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};\n\nexport default class UpdateCmd implements Command {\n name = 'update';\n description = 'update dependencies';\n alias = 'up';\n group = 'development';\n options = [['y', 'yes', 'automatically update all outdated packages']] as CommandOptions;\n\n constructor(private install: InstallMain) {}\n\n async report(args: [string[]], options: UpdateCmdOptions) {\n await this.install.updateDependencies({\n all: options.yes === true,\n });\n return '';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQe,MAAMA,SAAN,CAAmC;EAOhDC,WAAW,CAASC,OAAT,EAA+B;IAAA,KAAtBA,OAAsB,GAAtBA,OAAsB;IAAA,8CANnC,QAMmC;IAAA,qDAL5B,qBAK4B;IAAA,+CAJlC,IAIkC;IAAA,+CAHlC,aAGkC;IAAA,iDAFhC,CAAC,CAAC,GAAD,EAAM,KAAN,EAAa,4CAAb,CAAD,CAEgC;EAAE;;EAEhC,MAANC,MAAM,CAACC,IAAD,EAAmBC,OAAnB,EAA8C;IACxD,MAAM,KAAKH,OAAL,CAAaI,kBAAb,CAAgC;MACpCC,GAAG,EAAEF,OAAO,CAACG,GAAR,KAAgB;IADe,CAAhC,CAAN;IAGA,OAAO,EAAP;EACD;;AAd+C"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { DependencyTypeNotSupportedInPolicy } from './dependency-type-not-supported-in-policy';
|
package/install.cmd.tsx
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
2
|
+
import { WorkspaceDependencyLifecycleType } from '@teambit/dependency-resolver';
|
3
|
+
import { Logger } from '@teambit/logger';
|
4
|
+
import chalk from 'chalk';
|
5
|
+
|
6
|
+
import { Workspace } from '@teambit/workspace';
|
7
|
+
import { InstallMain, WorkspaceInstallOptions } from './install.main.runtime';
|
8
|
+
|
9
|
+
type InstallCmdOptions = {
|
10
|
+
variants: string;
|
11
|
+
type: WorkspaceDependencyLifecycleType;
|
12
|
+
skipDedupe: boolean;
|
13
|
+
skipImport: boolean;
|
14
|
+
updateExisting: boolean;
|
15
|
+
savePrefix: string;
|
16
|
+
addMissingPeers: boolean;
|
17
|
+
};
|
18
|
+
|
19
|
+
export default class InstallCmd implements Command {
|
20
|
+
name = 'install [packages...]';
|
21
|
+
description = 'installs workspace dependencies';
|
22
|
+
extendedDescription =
|
23
|
+
'when no package is specified, all workspace dependencies are installed and all workspace components are imported.';
|
24
|
+
arguments = [{ name: 'packages...', description: 'a list of packages to install (separated by spaces)' }];
|
25
|
+
alias = 'in';
|
26
|
+
group = 'development';
|
27
|
+
options = [
|
28
|
+
['v', 'variants <variants>', 'add packages to specific variants'],
|
29
|
+
['t', 'type [lifecycleType]', '"runtime" (default) or "peer" (dev is not a valid option)'],
|
30
|
+
['u', 'update-existing [updateExisting]', 'update existing dependencies version and types'],
|
31
|
+
['', 'save-prefix [savePrefix]', 'set the prefix to use when adding dependency to workspace.jsonc'],
|
32
|
+
['', 'skip-dedupe [skipDedupe]', 'do not dedupe dependencies on installation'],
|
33
|
+
['', 'skip-import [skipImport]', 'do not import bit objects post installation'],
|
34
|
+
['', 'add-missing-peers [addMissingPeers]', 'install all missing peer dependencies'],
|
35
|
+
] as CommandOptions;
|
36
|
+
|
37
|
+
constructor(
|
38
|
+
private install: InstallMain,
|
39
|
+
/**
|
40
|
+
* workspace extension.
|
41
|
+
*/
|
42
|
+
private workspace: Workspace,
|
43
|
+
|
44
|
+
/**
|
45
|
+
* logger extension.
|
46
|
+
*/
|
47
|
+
private logger: Logger
|
48
|
+
) {}
|
49
|
+
|
50
|
+
async report([packages = []]: [string[]], options: InstallCmdOptions) {
|
51
|
+
const startTime = Date.now();
|
52
|
+
this.logger.console(`Resolving component dependencies for workspace: '${chalk.cyan(this.workspace.name)}'`);
|
53
|
+
const installOpts: WorkspaceInstallOptions = {
|
54
|
+
variants: options.variants,
|
55
|
+
lifecycleType: options.addMissingPeers ? 'peer' : options.type,
|
56
|
+
dedupe: !options.skipDedupe,
|
57
|
+
import: !options.skipImport,
|
58
|
+
updateExisting: options.updateExisting,
|
59
|
+
savePrefix: options.savePrefix,
|
60
|
+
addMissingPeers: options.addMissingPeers,
|
61
|
+
};
|
62
|
+
const components = await this.install.install(packages, installOpts);
|
63
|
+
const endTime = Date.now();
|
64
|
+
const executionTime = calculateTime(startTime, endTime);
|
65
|
+
return `Successfully resolved dependencies for ${chalk.cyan(
|
66
|
+
components.toArray().length.toString()
|
67
|
+
)} component(s) in ${chalk.cyan(executionTime.toString())} seconds`;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
function calculateTime(startTime: number, endTime: number) {
|
72
|
+
const diff = endTime - startTime;
|
73
|
+
return diff / 1000;
|
74
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import chalk from 'chalk';
|
2
|
+
import { LinksResult as LegacyLinksResult } from '@teambit/legacy/dist/links/node-modules-linker';
|
3
|
+
import { getPackageNameFromTarget } from './get-package-name-from-target';
|
4
|
+
import { LinkRow, VerboseLinkRow } from './link-row';
|
5
|
+
|
6
|
+
type ComponentListLinksProps = {
|
7
|
+
componentListLinks?: LegacyLinksResult[];
|
8
|
+
verbose: boolean;
|
9
|
+
};
|
10
|
+
|
11
|
+
export function ComponentListLinks({ componentListLinks, verbose = false }: ComponentListLinksProps) {
|
12
|
+
if (!componentListLinks || !componentListLinks.length) {
|
13
|
+
return chalk.cyan('No components link were generated');
|
14
|
+
}
|
15
|
+
const title = chalk.bold.cyan('Components links');
|
16
|
+
const links = componentListLinks.map((componentLinks) => ComponentLinks({ componentLinks, verbose })).join('\n');
|
17
|
+
|
18
|
+
return `${title}\n${links}`;
|
19
|
+
}
|
20
|
+
|
21
|
+
type ComponentLinksProps = {
|
22
|
+
componentLinks: LegacyLinksResult;
|
23
|
+
verbose: boolean;
|
24
|
+
};
|
25
|
+
function ComponentLinks({ componentLinks, verbose = false }: ComponentLinksProps) {
|
26
|
+
if (!componentLinks.bound || componentLinks.bound.length < 1) return '';
|
27
|
+
if (verbose) return VerboseComponentLinks({ componentLinks });
|
28
|
+
return RegularComponentLinks({ componentLinks });
|
29
|
+
}
|
30
|
+
|
31
|
+
type RegularComponentLinksProps = {
|
32
|
+
componentLinks: LegacyLinksResult;
|
33
|
+
};
|
34
|
+
function RegularComponentLinks({ componentLinks }: RegularComponentLinksProps) {
|
35
|
+
const id = componentLinks.id.toString();
|
36
|
+
if (!componentLinks.bound || componentLinks.bound.length < 1) return '';
|
37
|
+
const packagePath = getPackageNameFromTarget(componentLinks.bound[0].to);
|
38
|
+
return LinkRow({ title: id, target: packagePath, padding: 50 });
|
39
|
+
}
|
40
|
+
|
41
|
+
type VerboseComponentLinksProps = {
|
42
|
+
componentLinks: LegacyLinksResult;
|
43
|
+
};
|
44
|
+
function VerboseComponentLinks({ componentLinks }: VerboseComponentLinksProps) {
|
45
|
+
const id = componentLinks.id.toString();
|
46
|
+
if (!componentLinks.bound || componentLinks.bound.length < 1) return '';
|
47
|
+
const title = chalk.bold.cyan(id);
|
48
|
+
const links = componentLinks.bound.map((link) => VerboseLinkRow({ from: link.from, to: link.to })).join('\n');
|
49
|
+
return `${title}\n${links}\n`;
|
50
|
+
}
|
@@ -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
|
+
}
|
package/link/index.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export { LinkCommand } from './link.cmd';
|
package/link/link-row.ts
ADDED
@@ -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}\n`;
|
13
|
+
}
|
package/link/link.cmd.ts
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
2
|
+
import { LinkResults } from '@teambit/dependency-resolver';
|
3
|
+
import { Logger } from '@teambit/logger';
|
4
|
+
import { timeFormat } from '@teambit/toolbox.time.time-format';
|
5
|
+
import chalk from 'chalk';
|
6
|
+
import { Workspace } from '@teambit/workspace';
|
7
|
+
import { InstallMain, WorkspaceLinkOptions } from '../install.main.runtime';
|
8
|
+
import { ComponentListLinks } 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
|
+
};
|
20
|
+
export class LinkCommand implements Command {
|
21
|
+
name = 'link [component-names...]';
|
22
|
+
alias = '';
|
23
|
+
description = 'create links in the node_modules directory, to core aspects and to components in the workspace';
|
24
|
+
extendedDescription: string;
|
25
|
+
group = 'development';
|
26
|
+
private = false;
|
27
|
+
arguments = [{ name: 'component-names...', description: 'names or IDs of the components to link' }];
|
28
|
+
options = [
|
29
|
+
['j', 'json', 'return the output as JSON'],
|
30
|
+
['', 'verbose', 'verbose output'],
|
31
|
+
['r', 'rewire', 'Replace relative paths with module paths in code (e.g. "../foo" => "@bit/foo")'],
|
32
|
+
[
|
33
|
+
'',
|
34
|
+
'target <dir>',
|
35
|
+
'EXPERIMENTAL. link to an external directory (similar to npm-link) so other projects could use these components',
|
36
|
+
],
|
37
|
+
['', 'skip-fetching-objects', 'skip fetch missing objects from remotes before linking'],
|
38
|
+
] as CommandOptions;
|
39
|
+
|
40
|
+
constructor(
|
41
|
+
private install: InstallMain,
|
42
|
+
/**
|
43
|
+
* workspace extension.
|
44
|
+
*/
|
45
|
+
private workspace: Workspace,
|
46
|
+
|
47
|
+
/**
|
48
|
+
* logger extension.
|
49
|
+
*/
|
50
|
+
private logger: Logger,
|
51
|
+
|
52
|
+
private docsDomain: string
|
53
|
+
) {
|
54
|
+
this.extendedDescription = `https://${this.docsDomain}/workspace/component-links`;
|
55
|
+
}
|
56
|
+
|
57
|
+
async report([ids]: [string[]], opts: LinkCommandOpts) {
|
58
|
+
const startTime = Date.now();
|
59
|
+
const linkResults = await this.json([ids], opts);
|
60
|
+
const endTime = Date.now();
|
61
|
+
const numOfComponents = linkResults.legacyLinkResults?.length;
|
62
|
+
const timeDiff = timeFormat(endTime - startTime);
|
63
|
+
const coreAspectsLinksWithMainAspect = linkResults.coreAspectsLinks || [];
|
64
|
+
if (linkResults.teambitBitLink) {
|
65
|
+
coreAspectsLinksWithMainAspect.unshift(linkResults.teambitBitLink);
|
66
|
+
}
|
67
|
+
const numOfCoreAspects = coreAspectsLinksWithMainAspect.length;
|
68
|
+
|
69
|
+
const title = `Linked ${numOfComponents} components and ${numOfCoreAspects} core aspects to node_modules for workspace: ${this.workspace.name}`;
|
70
|
+
const coreLinks = CoreAspectsLinks({
|
71
|
+
coreAspectsLinks: coreAspectsLinksWithMainAspect,
|
72
|
+
verbose: opts.verbose,
|
73
|
+
});
|
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 `${title}\n${coreLinks}\n${compsLinks}\n${rewireRow}${nestedLinks}${targetLinks}${footer}`;
|
83
|
+
}
|
84
|
+
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
86
|
+
async json([ids]: [string[]], opts: LinkCommandOpts): Promise<LinkResults> {
|
87
|
+
this.logger.console(
|
88
|
+
`Linking components and core aspects to node_modules for workspaces: '${chalk.cyan(this.workspace.name)}'`
|
89
|
+
);
|
90
|
+
|
91
|
+
const linkOpts: WorkspaceLinkOptions = {
|
92
|
+
legacyLink: true,
|
93
|
+
rewire: opts.rewire,
|
94
|
+
linkCoreAspects: true,
|
95
|
+
linkTeambitBit: true,
|
96
|
+
linkToDir: opts.target,
|
97
|
+
fetchObject: !opts.skipFetchingObjects,
|
98
|
+
};
|
99
|
+
const linkResults = await this.install.link(linkOpts);
|
100
|
+
return linkResults;
|
101
|
+
}
|
102
|
+
}
|
@@ -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}\n`;
|
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/legacy/dist/consumer/component-ops/codemod-components';
|
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\n`;
|
17
|
+
}
|
Binary file
|
package/package.json
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"name": "@teambit/install",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"main": "dist/index.js",
|
5
|
+
"componentId": {
|
6
|
+
"scope": "teambit.workspace",
|
7
|
+
"name": "install",
|
8
|
+
"version": "0.0.1"
|
9
|
+
},
|
10
|
+
"dependencies": {
|
11
|
+
"chalk": "2.4.2",
|
12
|
+
"lodash": "4.17.21",
|
13
|
+
"@pnpm/colorize-semver-diff": "1.0.1",
|
14
|
+
"@pnpm/semver-diff": "1.1.0",
|
15
|
+
"enquirer": "2.3.6",
|
16
|
+
"semver": "7.3.4",
|
17
|
+
"table": "5.4.6",
|
18
|
+
"@babel/runtime": "7.12.18",
|
19
|
+
"core-js": "^3.0.0",
|
20
|
+
"@teambit/harmony": "0.3.3",
|
21
|
+
"@teambit/bit-error": "0.0.400",
|
22
|
+
"@teambit/toolbox.time.time-format": "0.0.489"
|
23
|
+
},
|
24
|
+
"devDependencies": {
|
25
|
+
"@types/lodash": "4.14.165",
|
26
|
+
"@types/semver": "7.3.4",
|
27
|
+
"@types/mocha": "9.1.0",
|
28
|
+
"@types/testing-library__jest-dom": "5.9.5",
|
29
|
+
"@types/jest": "^26.0.0",
|
30
|
+
"@types/react-dom": "^17.0.5",
|
31
|
+
"@types/react": "^17.0.8",
|
32
|
+
"@types/node": "12.20.4"
|
33
|
+
},
|
34
|
+
"peerDependencies": {
|
35
|
+
"@teambit/legacy": "1.0.345",
|
36
|
+
"react-dom": "^16.8.0 || ^17.0.0",
|
37
|
+
"react": "^16.8.0 || ^17.0.0"
|
38
|
+
},
|
39
|
+
"license": "Apache-2.0",
|
40
|
+
"private": false,
|
41
|
+
"engines": {
|
42
|
+
"node": ">=12.22.0"
|
43
|
+
},
|
44
|
+
"repository": {
|
45
|
+
"type": "git",
|
46
|
+
"url": "https://github.com/teambit/bit"
|
47
|
+
},
|
48
|
+
"keywords": [
|
49
|
+
"bit",
|
50
|
+
"bit-aspect",
|
51
|
+
"components",
|
52
|
+
"collaboration",
|
53
|
+
"web",
|
54
|
+
"react",
|
55
|
+
"react-components",
|
56
|
+
"angular",
|
57
|
+
"angular-components"
|
58
|
+
]
|
59
|
+
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"lib": [
|
4
|
+
"es2019",
|
5
|
+
"DOM",
|
6
|
+
"ES6",
|
7
|
+
"DOM.Iterable",
|
8
|
+
"ScriptHost"
|
9
|
+
],
|
10
|
+
"target": "es2015",
|
11
|
+
"module": "commonjs",
|
12
|
+
"jsx": "react",
|
13
|
+
"allowJs": true,
|
14
|
+
"composite": true,
|
15
|
+
"declaration": true,
|
16
|
+
"sourceMap": true,
|
17
|
+
"skipLibCheck": true,
|
18
|
+
"experimentalDecorators": true,
|
19
|
+
"outDir": "dist",
|
20
|
+
"moduleResolution": "node",
|
21
|
+
"esModuleInterop": true,
|
22
|
+
"rootDir": ".",
|
23
|
+
"resolveJsonModule": true,
|
24
|
+
"emitDeclarationOnly": true,
|
25
|
+
"emitDecoratorMetadata": true,
|
26
|
+
"allowSyntheticDefaultImports": true,
|
27
|
+
"strictPropertyInitialization": false,
|
28
|
+
"strict": true,
|
29
|
+
"noImplicitAny": false,
|
30
|
+
"preserveConstEnums": true
|
31
|
+
},
|
32
|
+
"exclude": [
|
33
|
+
"dist",
|
34
|
+
"package.json"
|
35
|
+
],
|
36
|
+
"include": [
|
37
|
+
"**/*",
|
38
|
+
"**/*.json"
|
39
|
+
]
|
40
|
+
}
|
package/types/asset.d.ts
ADDED
@@ -0,0 +1,29 @@
|
|
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<SVGProps<SVGSVGElement> & { title?: string }>;
|
9
|
+
const src: string;
|
10
|
+
export default src;
|
11
|
+
}
|
12
|
+
|
13
|
+
// @TODO Gilad
|
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
|
+
}
|